1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use glib::error::ErrorDomain;
use glib::translate::*;
use glib::value::FromValue;
use glib::value::FromValueOptional;
use glib::value::SetValue;
use glib::value::Value;
use glib::Quark;
use glib::StaticType;
use glib::Type;
use gobject_sys;
use gst_sys;

/// The different types of buffering methods.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum BufferingMode {
    /// a small amount of data is buffered
    Stream,
    /// the stream is being downloaded
    Download,
    /// the stream is being downloaded in a ringbuffer
    Timeshift,
    /// the stream is a live stream
    Live,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for BufferingMode {
    type GlibType = gst_sys::GstBufferingMode;

    fn to_glib(&self) -> gst_sys::GstBufferingMode {
        match *self {
            BufferingMode::Stream => gst_sys::GST_BUFFERING_STREAM,
            BufferingMode::Download => gst_sys::GST_BUFFERING_DOWNLOAD,
            BufferingMode::Timeshift => gst_sys::GST_BUFFERING_TIMESHIFT,
            BufferingMode::Live => gst_sys::GST_BUFFERING_LIVE,
            BufferingMode::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstBufferingMode> for BufferingMode {
    fn from_glib(value: gst_sys::GstBufferingMode) -> Self {
        skip_assert_initialized!();
        match value {
            0 => BufferingMode::Stream,
            1 => BufferingMode::Download,
            2 => BufferingMode::Timeshift,
            3 => BufferingMode::Live,
            value => BufferingMode::__Unknown(value),
        }
    }
}

impl StaticType for BufferingMode {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_buffering_mode_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for BufferingMode {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for BufferingMode {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for BufferingMode {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The result values for a GstBusSyncHandler.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum BusSyncReply {
    /// drop the message
    Drop,
    /// pass the message to the async queue
    Pass,
    /// pass message to async queue, continue if message is handled
    Async,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for BusSyncReply {
    type GlibType = gst_sys::GstBusSyncReply;

    fn to_glib(&self) -> gst_sys::GstBusSyncReply {
        match *self {
            BusSyncReply::Drop => gst_sys::GST_BUS_DROP,
            BusSyncReply::Pass => gst_sys::GST_BUS_PASS,
            BusSyncReply::Async => gst_sys::GST_BUS_ASYNC,
            BusSyncReply::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstBusSyncReply> for BusSyncReply {
    fn from_glib(value: gst_sys::GstBusSyncReply) -> Self {
        skip_assert_initialized!();
        match value {
            0 => BusSyncReply::Drop,
            1 => BusSyncReply::Pass,
            2 => BusSyncReply::Async,
            value => BusSyncReply::__Unknown(value),
        }
    }
}

impl StaticType for BusSyncReply {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_bus_sync_reply_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for BusSyncReply {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for BusSyncReply {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for BusSyncReply {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Modes of caps intersection
///
/// `CapsIntersectMode::ZigZag` tries to preserve overall order of both caps
/// by iterating on the caps' structures as the following matrix shows:
///
/// ```text
///          caps1
///       +-------------
///       | 1  2  4  7
/// caps2 | 3  5  8 10
///       | 6  9 11 12
/// ```
/// Used when there is no explicit precedence of one caps over the other. e.g.
/// tee's sink pad getcaps function, it will probe its src pad peers' for their
/// caps and intersect them with this mode.
///
/// `CapsIntersectMode::First` is useful when an element wants to preserve
/// another element's caps priority order when intersecting with its own caps.
/// Example: If caps1 is [A, B, C] and caps2 is [E, B, D, A], the result
/// would be [A, B], maintaining the first caps priority on the intersection.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum CapsIntersectMode {
    /// Zig-zags over both caps.
    ZigZag,
    /// Keeps the first caps order.
    First,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for CapsIntersectMode {
    type GlibType = gst_sys::GstCapsIntersectMode;

    fn to_glib(&self) -> gst_sys::GstCapsIntersectMode {
        match *self {
            CapsIntersectMode::ZigZag => gst_sys::GST_CAPS_INTERSECT_ZIG_ZAG,
            CapsIntersectMode::First => gst_sys::GST_CAPS_INTERSECT_FIRST,
            CapsIntersectMode::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstCapsIntersectMode> for CapsIntersectMode {
    fn from_glib(value: gst_sys::GstCapsIntersectMode) -> Self {
        skip_assert_initialized!();
        match value {
            0 => CapsIntersectMode::ZigZag,
            1 => CapsIntersectMode::First,
            value => CapsIntersectMode::__Unknown(value),
        }
    }
}

impl StaticType for CapsIntersectMode {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_caps_intersect_mode_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for CapsIntersectMode {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for CapsIntersectMode {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for CapsIntersectMode {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The type of the clock entry
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum ClockEntryType {
    /// a single shot timeout
    Single,
    /// a periodic timeout request
    Periodic,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for ClockEntryType {
    type GlibType = gst_sys::GstClockEntryType;

    fn to_glib(&self) -> gst_sys::GstClockEntryType {
        match *self {
            ClockEntryType::Single => gst_sys::GST_CLOCK_ENTRY_SINGLE,
            ClockEntryType::Periodic => gst_sys::GST_CLOCK_ENTRY_PERIODIC,
            ClockEntryType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstClockEntryType> for ClockEntryType {
    fn from_glib(value: gst_sys::GstClockEntryType) -> Self {
        skip_assert_initialized!();
        match value {
            0 => ClockEntryType::Single,
            1 => ClockEntryType::Periodic,
            value => ClockEntryType::__Unknown(value),
        }
    }
}

impl StaticType for ClockEntryType {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_clock_entry_type_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for ClockEntryType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for ClockEntryType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for ClockEntryType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The return value of a clock operation.
#[must_use]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum ClockReturn {
    /// The operation succeeded.
    Ok,
    /// The operation was scheduled too late.
    Early,
    /// The clockID was unscheduled
    Unscheduled,
    /// The ClockID is busy
    Busy,
    /// A bad time was provided to a function.
    Badtime,
    /// An error occurred
    Error,
    /// Operation is not supported
    Unsupported,
    /// The ClockID is done waiting
    Done,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for ClockReturn {
    type GlibType = gst_sys::GstClockReturn;

    fn to_glib(&self) -> gst_sys::GstClockReturn {
        match *self {
            ClockReturn::Ok => gst_sys::GST_CLOCK_OK,
            ClockReturn::Early => gst_sys::GST_CLOCK_EARLY,
            ClockReturn::Unscheduled => gst_sys::GST_CLOCK_UNSCHEDULED,
            ClockReturn::Busy => gst_sys::GST_CLOCK_BUSY,
            ClockReturn::Badtime => gst_sys::GST_CLOCK_BADTIME,
            ClockReturn::Error => gst_sys::GST_CLOCK_ERROR,
            ClockReturn::Unsupported => gst_sys::GST_CLOCK_UNSUPPORTED,
            ClockReturn::Done => gst_sys::GST_CLOCK_DONE,
            ClockReturn::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstClockReturn> for ClockReturn {
    fn from_glib(value: gst_sys::GstClockReturn) -> Self {
        skip_assert_initialized!();
        match value {
            0 => ClockReturn::Ok,
            1 => ClockReturn::Early,
            2 => ClockReturn::Unscheduled,
            3 => ClockReturn::Busy,
            4 => ClockReturn::Badtime,
            5 => ClockReturn::Error,
            6 => ClockReturn::Unsupported,
            7 => ClockReturn::Done,
            value => ClockReturn::__Unknown(value),
        }
    }
}

impl StaticType for ClockReturn {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_clock_return_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for ClockReturn {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for ClockReturn {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for ClockReturn {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The different kind of clocks.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum ClockType {
    /// time since Epoch
    Realtime,
    /// monotonic time since some unspecified starting
    ///  point
    Monotonic,
    /// some other time source is used (Since: 1.0.5)
    Other,
    /// time since Epoch, but using International Atomic Time
    ///  as reference (Since: 1.18)
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    Tai,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for ClockType {
    type GlibType = gst_sys::GstClockType;

    fn to_glib(&self) -> gst_sys::GstClockType {
        match *self {
            ClockType::Realtime => gst_sys::GST_CLOCK_TYPE_REALTIME,
            ClockType::Monotonic => gst_sys::GST_CLOCK_TYPE_MONOTONIC,
            ClockType::Other => gst_sys::GST_CLOCK_TYPE_OTHER,
            #[cfg(any(feature = "v1_18", feature = "dox"))]
            ClockType::Tai => gst_sys::GST_CLOCK_TYPE_TAI,
            ClockType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstClockType> for ClockType {
    fn from_glib(value: gst_sys::GstClockType) -> Self {
        skip_assert_initialized!();
        match value {
            0 => ClockType::Realtime,
            1 => ClockType::Monotonic,
            2 => ClockType::Other,
            #[cfg(any(feature = "v1_18", feature = "dox"))]
            3 => ClockType::Tai,
            value => ClockType::__Unknown(value),
        }
    }
}

impl StaticType for ClockType {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_clock_type_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for ClockType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for ClockType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for ClockType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Core errors are errors inside the core GStreamer library.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum CoreError {
    /// a general error which doesn't fit in any other
    /// category. Make sure you add a custom message to the error call.
    Failed,
    /// do not use this except as a placeholder for
    /// deciding where to go while developing code.
    TooLazy,
    /// use this when you do not want to implement
    /// this functionality yet.
    NotImplemented,
    /// used for state change errors.
    StateChange,
    /// used for pad-related errors.
    Pad,
    /// used for thread-related errors.
    Thread,
    /// used for negotiation-related errors.
    Negotiation,
    /// used for event-related errors.
    Event,
    /// used for seek-related errors.
    Seek,
    /// used for caps-related errors.
    Caps,
    /// used for negotiation-related errors.
    Tag,
    /// used if a plugin is missing.
    MissingPlugin,
    /// used for clock related errors.
    Clock,
    /// used if functionality has been disabled at
    ///  compile time.
    Disabled,
    /// the number of core error types.
    NumErrors,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for CoreError {
    type GlibType = gst_sys::GstCoreError;

    fn to_glib(&self) -> gst_sys::GstCoreError {
        match *self {
            CoreError::Failed => gst_sys::GST_CORE_ERROR_FAILED,
            CoreError::TooLazy => gst_sys::GST_CORE_ERROR_TOO_LAZY,
            CoreError::NotImplemented => gst_sys::GST_CORE_ERROR_NOT_IMPLEMENTED,
            CoreError::StateChange => gst_sys::GST_CORE_ERROR_STATE_CHANGE,
            CoreError::Pad => gst_sys::GST_CORE_ERROR_PAD,
            CoreError::Thread => gst_sys::GST_CORE_ERROR_THREAD,
            CoreError::Negotiation => gst_sys::GST_CORE_ERROR_NEGOTIATION,
            CoreError::Event => gst_sys::GST_CORE_ERROR_EVENT,
            CoreError::Seek => gst_sys::GST_CORE_ERROR_SEEK,
            CoreError::Caps => gst_sys::GST_CORE_ERROR_CAPS,
            CoreError::Tag => gst_sys::GST_CORE_ERROR_TAG,
            CoreError::MissingPlugin => gst_sys::GST_CORE_ERROR_MISSING_PLUGIN,
            CoreError::Clock => gst_sys::GST_CORE_ERROR_CLOCK,
            CoreError::Disabled => gst_sys::GST_CORE_ERROR_DISABLED,
            CoreError::NumErrors => gst_sys::GST_CORE_ERROR_NUM_ERRORS,
            CoreError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstCoreError> for CoreError {
    fn from_glib(value: gst_sys::GstCoreError) -> Self {
        skip_assert_initialized!();
        match value {
            1 => CoreError::Failed,
            2 => CoreError::TooLazy,
            3 => CoreError::NotImplemented,
            4 => CoreError::StateChange,
            5 => CoreError::Pad,
            6 => CoreError::Thread,
            7 => CoreError::Negotiation,
            8 => CoreError::Event,
            9 => CoreError::Seek,
            10 => CoreError::Caps,
            11 => CoreError::Tag,
            12 => CoreError::MissingPlugin,
            13 => CoreError::Clock,
            14 => CoreError::Disabled,
            15 => CoreError::NumErrors,
            value => CoreError::__Unknown(value),
        }
    }
}

impl ErrorDomain for CoreError {
    fn domain() -> Quark {
        skip_assert_initialized!();
        unsafe { from_glib(gst_sys::gst_core_error_quark()) }
    }

    fn code(self) -> i32 {
        self.to_glib()
    }

    fn from(code: i32) -> Option<Self> {
        skip_assert_initialized!();
        match code {
            1 => Some(CoreError::Failed),
            2 => Some(CoreError::TooLazy),
            3 => Some(CoreError::NotImplemented),
            4 => Some(CoreError::StateChange),
            5 => Some(CoreError::Pad),
            6 => Some(CoreError::Thread),
            7 => Some(CoreError::Negotiation),
            8 => Some(CoreError::Event),
            9 => Some(CoreError::Seek),
            10 => Some(CoreError::Caps),
            11 => Some(CoreError::Tag),
            12 => Some(CoreError::MissingPlugin),
            13 => Some(CoreError::Clock),
            14 => Some(CoreError::Disabled),
            15 => Some(CoreError::NumErrors),
            _ => Some(CoreError::Failed),
        }
    }
}

impl StaticType for CoreError {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_core_error_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for CoreError {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for CoreError {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for CoreError {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The level defines the importance of a debugging message. The more important a
/// message is, the greater the probability that the debugging system outputs it.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum DebugLevel {
    /// No debugging level specified or desired. Used to deactivate
    ///  debugging output.
    None,
    /// Error messages are to be used only when an error occurred
    ///  that stops the application from keeping working correctly.
    ///  An examples is gst_element_error, which outputs a message with this priority.
    ///  It does not mean that the application is terminating as with g_error.
    Error,
    /// Warning messages are to inform about abnormal behaviour
    ///  that could lead to problems or weird behaviour later on. An example of this
    ///  would be clocking issues ("your computer is pretty slow") or broken input
    ///  data ("Can't synchronize to stream.")
    Warning,
    /// Fixme messages are messages that indicate that something
    ///  in the executed code path is not fully implemented or handled yet. Note
    ///  that this does not replace proper error handling in any way, the purpose
    ///  of this message is to make it easier to spot incomplete/unfinished pieces
    ///  of code when reading the debug log.
    Fixme,
    /// Informational messages should be used to keep the developer
    ///  updated about what is happening.
    ///  Examples where this should be used are when a typefind function has
    ///  successfully determined the type of the stream or when an mp3 plugin detects
    ///  the format to be used. ("This file has mono sound.")
    Info,
    /// Debugging messages should be used when something common
    ///  happens that is not the expected default behavior, or something that's
    ///  useful to know but doesn't happen all the time (ie. per loop iteration or
    ///  buffer processed or event handled).
    ///  An example would be notifications about state changes or receiving/sending
    ///  of events.
    Debug,
    /// Log messages are messages that are very common but might be
    ///  useful to know. As a rule of thumb a pipeline that is running as expected
    ///  should never output anything else but LOG messages whilst processing data.
    ///  Use this log level to log recurring information in chain functions and
    ///  loop functions, for example.
    Log,
    /// Tracing-related messages.
    ///  Examples for this are referencing/dereferencing of objects.
    Trace,
    /// memory dump messages are used to log (small) chunks of
    ///  data as memory dumps in the log. They will be displayed as hexdump with
    ///  ASCII characters.
    Memdump,
    /// The number of defined debugging levels.
    Count,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for DebugLevel {
    type GlibType = gst_sys::GstDebugLevel;

    fn to_glib(&self) -> gst_sys::GstDebugLevel {
        match *self {
            DebugLevel::None => gst_sys::GST_LEVEL_NONE,
            DebugLevel::Error => gst_sys::GST_LEVEL_ERROR,
            DebugLevel::Warning => gst_sys::GST_LEVEL_WARNING,
            DebugLevel::Fixme => gst_sys::GST_LEVEL_FIXME,
            DebugLevel::Info => gst_sys::GST_LEVEL_INFO,
            DebugLevel::Debug => gst_sys::GST_LEVEL_DEBUG,
            DebugLevel::Log => gst_sys::GST_LEVEL_LOG,
            DebugLevel::Trace => gst_sys::GST_LEVEL_TRACE,
            DebugLevel::Memdump => gst_sys::GST_LEVEL_MEMDUMP,
            DebugLevel::Count => gst_sys::GST_LEVEL_COUNT,
            DebugLevel::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstDebugLevel> for DebugLevel {
    fn from_glib(value: gst_sys::GstDebugLevel) -> Self {
        skip_assert_initialized!();
        match value {
            0 => DebugLevel::None,
            1 => DebugLevel::Error,
            2 => DebugLevel::Warning,
            3 => DebugLevel::Fixme,
            4 => DebugLevel::Info,
            5 => DebugLevel::Debug,
            6 => DebugLevel::Log,
            7 => DebugLevel::Trace,
            9 => DebugLevel::Memdump,
            10 => DebugLevel::Count,
            value => DebugLevel::__Unknown(value),
        }
    }
}

impl StaticType for DebugLevel {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_debug_level_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for DebugLevel {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for DebugLevel {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for DebugLevel {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// `EventType` lists the standard event types that can be sent in a pipeline.
///
/// The custom event types can be used for private messages between elements
/// that can't be expressed using normal
/// GStreamer buffer passing semantics. Custom events carry an arbitrary
/// `Structure`.
/// Specific custom events are distinguished by the name of the structure.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum EventType {
    /// unknown event.
    Unknown,
    /// Start a flush operation. This event clears all data
    ///  from the pipeline and unblock all streaming threads.
    FlushStart,
    /// Stop a flush operation. This event resets the
    ///  running-time of the pipeline.
    FlushStop,
    /// Event to mark the start of a new stream. Sent before any
    ///  other serialized event and only sent at the start of a new stream,
    ///  not after flushing seeks.
    StreamStart,
    /// `Caps` event. Notify the pad of a new media type.
    Caps,
    /// A new media segment follows in the dataflow. The
    ///  segment events contains information for clipping buffers and
    ///  converting buffer timestamps to running-time and
    ///  stream-time.
    Segment,
    /// A new `StreamCollection` is available (Since: 1.10)
    StreamCollection,
    /// A new set of metadata tags has been found in the stream.
    Tag,
    /// Notification of buffering requirements. Currently not
    ///  used yet.
    Buffersize,
    /// An event that sinks turn into a message. Used to
    ///  send messages that should be emitted in sync with
    ///  rendering.
    SinkMessage,
    /// Indicates that there is no more data for
    ///  the stream group ID in the message. Sent before EOS
    ///  in some instances and should be handled mostly the same. (Since: 1.10)
    #[cfg(any(feature = "v1_10", feature = "dox"))]
    StreamGroupDone,
    /// End-Of-Stream. No more data is to be expected to follow
    ///  without either a STREAM_START event, or a FLUSH_STOP and a SEGMENT
    ///  event.
    Eos,
    /// An event which indicates that a new table of contents (TOC)
    ///  was found or updated.
    Toc,
    /// An event which indicates that new or updated
    ///  encryption information has been found in the stream.
    Protection,
    /// Marks the end of a segment playback.
    SegmentDone,
    /// Marks a gap in the datastream.
    Gap,
    /// Notify downstream that a playback rate override
    ///  should be applied as soon as possible. (Since: 1.18)
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    InstantRateChange,
    /// A quality message. Used to indicate to upstream elements
    ///  that the downstream elements should adjust their processing
    ///  rate.
    Qos,
    /// A request for a new playback position and rate.
    Seek,
    /// Navigation events are usually used for communicating
    ///  user requests, such as mouse or keyboard movements,
    ///  to upstream elements.
    Navigation,
    /// Notification of new latency adjustment. Sinks will use
    ///  the latency information to adjust their synchronisation.
    Latency,
    /// A request for stepping through the media. Sinks will usually
    ///  execute the step operation.
    Step,
    /// A request for upstream renegotiating caps and reconfiguring.
    Reconfigure,
    /// A request for a new playback position based on TOC
    ///  entry's UID.
    TocSelect,
    /// A request to select one or more streams (Since: 1.10)
    #[cfg(any(feature = "v1_10", feature = "dox"))]
    SelectStreams,
    /// Sent by the pipeline to notify elements that handle the
    ///  instant-rate-change event about the running-time when
    ///  the rate multiplier should be applied (or was applied). (Since: 1.18)
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    InstantRateSyncTime,
    /// Upstream custom event
    CustomUpstream,
    /// Downstream custom event that travels in the
    ///  data flow.
    CustomDownstream,
    /// Custom out-of-band downstream event.
    CustomDownstreamOob,
    /// Custom sticky downstream event.
    CustomDownstreamSticky,
    /// Custom upstream or downstream event.
    ///  In-band when travelling downstream.
    CustomBoth,
    /// Custom upstream or downstream out-of-band event.
    CustomBothOob,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for EventType {
    type GlibType = gst_sys::GstEventType;

    fn to_glib(&self) -> gst_sys::GstEventType {
        match *self {
            EventType::Unknown => gst_sys::GST_EVENT_UNKNOWN,
            EventType::FlushStart => gst_sys::GST_EVENT_FLUSH_START,
            EventType::FlushStop => gst_sys::GST_EVENT_FLUSH_STOP,
            EventType::StreamStart => gst_sys::GST_EVENT_STREAM_START,
            EventType::Caps => gst_sys::GST_EVENT_CAPS,
            EventType::Segment => gst_sys::GST_EVENT_SEGMENT,
            EventType::StreamCollection => gst_sys::GST_EVENT_STREAM_COLLECTION,
            EventType::Tag => gst_sys::GST_EVENT_TAG,
            EventType::Buffersize => gst_sys::GST_EVENT_BUFFERSIZE,
            EventType::SinkMessage => gst_sys::GST_EVENT_SINK_MESSAGE,
            #[cfg(any(feature = "v1_10", feature = "dox"))]
            EventType::StreamGroupDone => gst_sys::GST_EVENT_STREAM_GROUP_DONE,
            EventType::Eos => gst_sys::GST_EVENT_EOS,
            EventType::Toc => gst_sys::GST_EVENT_TOC,
            EventType::Protection => gst_sys::GST_EVENT_PROTECTION,
            EventType::SegmentDone => gst_sys::GST_EVENT_SEGMENT_DONE,
            EventType::Gap => gst_sys::GST_EVENT_GAP,
            #[cfg(any(feature = "v1_18", feature = "dox"))]
            EventType::InstantRateChange => gst_sys::GST_EVENT_INSTANT_RATE_CHANGE,
            EventType::Qos => gst_sys::GST_EVENT_QOS,
            EventType::Seek => gst_sys::GST_EVENT_SEEK,
            EventType::Navigation => gst_sys::GST_EVENT_NAVIGATION,
            EventType::Latency => gst_sys::GST_EVENT_LATENCY,
            EventType::Step => gst_sys::GST_EVENT_STEP,
            EventType::Reconfigure => gst_sys::GST_EVENT_RECONFIGURE,
            EventType::TocSelect => gst_sys::GST_EVENT_TOC_SELECT,
            #[cfg(any(feature = "v1_10", feature = "dox"))]
            EventType::SelectStreams => gst_sys::GST_EVENT_SELECT_STREAMS,
            #[cfg(any(feature = "v1_18", feature = "dox"))]
            EventType::InstantRateSyncTime => gst_sys::GST_EVENT_INSTANT_RATE_SYNC_TIME,
            EventType::CustomUpstream => gst_sys::GST_EVENT_CUSTOM_UPSTREAM,
            EventType::CustomDownstream => gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM,
            EventType::CustomDownstreamOob => gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM_OOB,
            EventType::CustomDownstreamSticky => gst_sys::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY,
            EventType::CustomBoth => gst_sys::GST_EVENT_CUSTOM_BOTH,
            EventType::CustomBothOob => gst_sys::GST_EVENT_CUSTOM_BOTH_OOB,
            EventType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstEventType> for EventType {
    fn from_glib(value: gst_sys::GstEventType) -> Self {
        skip_assert_initialized!();
        match value {
            0 => EventType::Unknown,
            2563 => EventType::FlushStart,
            5127 => EventType::FlushStop,
            10254 => EventType::StreamStart,
            12814 => EventType::Caps,
            17934 => EventType::Segment,
            19230 => EventType::StreamCollection,
            20510 => EventType::Tag,
            23054 => EventType::Buffersize,
            25630 => EventType::SinkMessage,
            #[cfg(any(feature = "v1_10", feature = "dox"))]
            26894 => EventType::StreamGroupDone,
            28174 => EventType::Eos,
            30750 => EventType::Toc,
            33310 => EventType::Protection,
            38406 => EventType::SegmentDone,
            40966 => EventType::Gap,
            #[cfg(any(feature = "v1_18", feature = "dox"))]
            46090 => EventType::InstantRateChange,
            48641 => EventType::Qos,
            51201 => EventType::Seek,
            53761 => EventType::Navigation,
            56321 => EventType::Latency,
            58881 => EventType::Step,
            61441 => EventType::Reconfigure,
            64001 => EventType::TocSelect,
            #[cfg(any(feature = "v1_10", feature = "dox"))]
            66561 => EventType::SelectStreams,
            #[cfg(any(feature = "v1_18", feature = "dox"))]
            66817 => EventType::InstantRateSyncTime,
            69121 => EventType::CustomUpstream,
            71686 => EventType::CustomDownstream,
            74242 => EventType::CustomDownstreamOob,
            76830 => EventType::CustomDownstreamSticky,
            79367 => EventType::CustomBoth,
            81923 => EventType::CustomBothOob,
            value => EventType::__Unknown(value),
        }
    }
}

impl StaticType for EventType {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_event_type_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for EventType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for EventType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for EventType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The result of passing data to a pad.
///
/// Note that the custom return values should not be exposed outside of the
/// element scope.
#[must_use]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum FlowReturn {
    /// Pre-defined custom success code.
    CustomSuccess2,
    /// Pre-defined custom success code (define your
    ///  custom success code to this to avoid compiler
    ///  warnings).
    CustomSuccess1,
    /// Elements can use values starting from
    ///  this (and higher) to define custom success
    ///  codes.
    CustomSuccess,
    /// Data passing was ok.
    Ok,
    /// Pad is not linked.
    NotLinked,
    /// Pad is flushing.
    Flushing,
    /// Pad is EOS.
    Eos,
    /// Pad is not negotiated.
    NotNegotiated,
    /// Some (fatal) error occurred. Element generating
    ///  this error should post an error message with more
    ///  details.
    Error,
    /// This operation is not supported.
    NotSupported,
    /// Elements can use values starting from
    ///  this (and lower) to define custom error codes.
    CustomError,
    /// Pre-defined custom error code (define your
    ///  custom error code to this to avoid compiler
    ///  warnings).
    CustomError1,
    /// Pre-defined custom error code.
    CustomError2,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for FlowReturn {
    type GlibType = gst_sys::GstFlowReturn;

    fn to_glib(&self) -> gst_sys::GstFlowReturn {
        match *self {
            FlowReturn::CustomSuccess2 => gst_sys::GST_FLOW_CUSTOM_SUCCESS_2,
            FlowReturn::CustomSuccess1 => gst_sys::GST_FLOW_CUSTOM_SUCCESS_1,
            FlowReturn::CustomSuccess => gst_sys::GST_FLOW_CUSTOM_SUCCESS,
            FlowReturn::Ok => gst_sys::GST_FLOW_OK,
            FlowReturn::NotLinked => gst_sys::GST_FLOW_NOT_LINKED,
            FlowReturn::Flushing => gst_sys::GST_FLOW_FLUSHING,
            FlowReturn::Eos => gst_sys::GST_FLOW_EOS,
            FlowReturn::NotNegotiated => gst_sys::GST_FLOW_NOT_NEGOTIATED,
            FlowReturn::Error => gst_sys::GST_FLOW_ERROR,
            FlowReturn::NotSupported => gst_sys::GST_FLOW_NOT_SUPPORTED,
            FlowReturn::CustomError => gst_sys::GST_FLOW_CUSTOM_ERROR,
            FlowReturn::CustomError1 => gst_sys::GST_FLOW_CUSTOM_ERROR_1,
            FlowReturn::CustomError2 => gst_sys::GST_FLOW_CUSTOM_ERROR_2,
            FlowReturn::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstFlowReturn> for FlowReturn {
    fn from_glib(value: gst_sys::GstFlowReturn) -> Self {
        skip_assert_initialized!();
        match value {
            102 => FlowReturn::CustomSuccess2,
            101 => FlowReturn::CustomSuccess1,
            100 => FlowReturn::CustomSuccess,
            0 => FlowReturn::Ok,
            -1 => FlowReturn::NotLinked,
            -2 => FlowReturn::Flushing,
            -3 => FlowReturn::Eos,
            -4 => FlowReturn::NotNegotiated,
            -5 => FlowReturn::Error,
            -6 => FlowReturn::NotSupported,
            -100 => FlowReturn::CustomError,
            -101 => FlowReturn::CustomError1,
            -102 => FlowReturn::CustomError2,
            value => FlowReturn::__Unknown(value),
        }
    }
}

impl StaticType for FlowReturn {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_flow_return_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for FlowReturn {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for FlowReturn {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for FlowReturn {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Standard predefined formats
#[cfg_attr(feature = "ser_de", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum Format {
    /// undefined format
    Undefined,
    /// the default format of the pad/element. This can be
    ///  samples for raw audio, frames/fields for raw video (some, but not all,
    ///  elements support this; use `Format::Time` if you don't have a good
    ///  reason to query for samples/frames)
    Default,
    /// bytes
    Bytes,
    /// time in nanoseconds
    Time,
    /// buffers (few, if any, elements implement this as of
    ///  May 2009)
    Buffers,
    /// percentage of stream (few, if any, elements implement
    ///  this as of May 2009)
    Percent,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for Format {
    type GlibType = gst_sys::GstFormat;

    fn to_glib(&self) -> gst_sys::GstFormat {
        match *self {
            Format::Undefined => gst_sys::GST_FORMAT_UNDEFINED,
            Format::Default => gst_sys::GST_FORMAT_DEFAULT,
            Format::Bytes => gst_sys::GST_FORMAT_BYTES,
            Format::Time => gst_sys::GST_FORMAT_TIME,
            Format::Buffers => gst_sys::GST_FORMAT_BUFFERS,
            Format::Percent => gst_sys::GST_FORMAT_PERCENT,
            Format::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstFormat> for Format {
    fn from_glib(value: gst_sys::GstFormat) -> Self {
        skip_assert_initialized!();
        match value {
            0 => Format::Undefined,
            1 => Format::Default,
            2 => Format::Bytes,
            3 => Format::Time,
            4 => Format::Buffers,
            5 => Format::Percent,
            value => Format::__Unknown(value),
        }
    }
}

impl StaticType for Format {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_format_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for Format {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for Format {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for Format {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Library errors are for errors from the library being used by elements
/// (initializing, finalizing, settings, ...)
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum LibraryError {
    /// a general error which doesn't fit in any other
    /// category. Make sure you add a custom message to the error call.
    Failed,
    /// do not use this except as a placeholder for
    /// deciding where to go while developing code.
    TooLazy,
    /// used when the library could not be opened.
    Init,
    /// used when the library could not be closed.
    Shutdown,
    /// used when the library doesn't accept settings.
    Settings,
    /// used when the library generated an encoding error.
    Encode,
    /// the number of library error types.
    NumErrors,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for LibraryError {
    type GlibType = gst_sys::GstLibraryError;

    fn to_glib(&self) -> gst_sys::GstLibraryError {
        match *self {
            LibraryError::Failed => gst_sys::GST_LIBRARY_ERROR_FAILED,
            LibraryError::TooLazy => gst_sys::GST_LIBRARY_ERROR_TOO_LAZY,
            LibraryError::Init => gst_sys::GST_LIBRARY_ERROR_INIT,
            LibraryError::Shutdown => gst_sys::GST_LIBRARY_ERROR_SHUTDOWN,
            LibraryError::Settings => gst_sys::GST_LIBRARY_ERROR_SETTINGS,
            LibraryError::Encode => gst_sys::GST_LIBRARY_ERROR_ENCODE,
            LibraryError::NumErrors => gst_sys::GST_LIBRARY_ERROR_NUM_ERRORS,
            LibraryError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstLibraryError> for LibraryError {
    fn from_glib(value: gst_sys::GstLibraryError) -> Self {
        skip_assert_initialized!();
        match value {
            1 => LibraryError::Failed,
            2 => LibraryError::TooLazy,
            3 => LibraryError::Init,
            4 => LibraryError::Shutdown,
            5 => LibraryError::Settings,
            6 => LibraryError::Encode,
            7 => LibraryError::NumErrors,
            value => LibraryError::__Unknown(value),
        }
    }
}

impl ErrorDomain for LibraryError {
    fn domain() -> Quark {
        skip_assert_initialized!();
        unsafe { from_glib(gst_sys::gst_library_error_quark()) }
    }

    fn code(self) -> i32 {
        self.to_glib()
    }

    fn from(code: i32) -> Option<Self> {
        skip_assert_initialized!();
        match code {
            1 => Some(LibraryError::Failed),
            2 => Some(LibraryError::TooLazy),
            3 => Some(LibraryError::Init),
            4 => Some(LibraryError::Shutdown),
            5 => Some(LibraryError::Settings),
            6 => Some(LibraryError::Encode),
            7 => Some(LibraryError::NumErrors),
            _ => Some(LibraryError::Failed),
        }
    }
}

impl StaticType for LibraryError {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_library_error_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for LibraryError {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for LibraryError {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for LibraryError {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The direction of a pad.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PadDirection {
    /// direction is unknown.
    Unknown,
    /// the pad is a source pad.
    Src,
    /// the pad is a sink pad.
    Sink,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for PadDirection {
    type GlibType = gst_sys::GstPadDirection;

    fn to_glib(&self) -> gst_sys::GstPadDirection {
        match *self {
            PadDirection::Unknown => gst_sys::GST_PAD_UNKNOWN,
            PadDirection::Src => gst_sys::GST_PAD_SRC,
            PadDirection::Sink => gst_sys::GST_PAD_SINK,
            PadDirection::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstPadDirection> for PadDirection {
    fn from_glib(value: gst_sys::GstPadDirection) -> Self {
        skip_assert_initialized!();
        match value {
            0 => PadDirection::Unknown,
            1 => PadDirection::Src,
            2 => PadDirection::Sink,
            value => PadDirection::__Unknown(value),
        }
    }
}

impl StaticType for PadDirection {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_pad_direction_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for PadDirection {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for PadDirection {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for PadDirection {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Result values from gst_pad_link and friends.
#[must_use]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PadLinkReturn {
    /// link succeeded
    Ok,
    /// pads have no common grandparent
    WrongHierarchy,
    /// pad was already linked
    WasLinked,
    /// pads have wrong direction
    WrongDirection,
    /// pads do not have common format
    Noformat,
    /// pads cannot cooperate in scheduling
    Nosched,
    /// refused for some reason
    Refused,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for PadLinkReturn {
    type GlibType = gst_sys::GstPadLinkReturn;

    fn to_glib(&self) -> gst_sys::GstPadLinkReturn {
        match *self {
            PadLinkReturn::Ok => gst_sys::GST_PAD_LINK_OK,
            PadLinkReturn::WrongHierarchy => gst_sys::GST_PAD_LINK_WRONG_HIERARCHY,
            PadLinkReturn::WasLinked => gst_sys::GST_PAD_LINK_WAS_LINKED,
            PadLinkReturn::WrongDirection => gst_sys::GST_PAD_LINK_WRONG_DIRECTION,
            PadLinkReturn::Noformat => gst_sys::GST_PAD_LINK_NOFORMAT,
            PadLinkReturn::Nosched => gst_sys::GST_PAD_LINK_NOSCHED,
            PadLinkReturn::Refused => gst_sys::GST_PAD_LINK_REFUSED,
            PadLinkReturn::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstPadLinkReturn> for PadLinkReturn {
    fn from_glib(value: gst_sys::GstPadLinkReturn) -> Self {
        skip_assert_initialized!();
        match value {
            0 => PadLinkReturn::Ok,
            -1 => PadLinkReturn::WrongHierarchy,
            -2 => PadLinkReturn::WasLinked,
            -3 => PadLinkReturn::WrongDirection,
            -4 => PadLinkReturn::Noformat,
            -5 => PadLinkReturn::Nosched,
            -6 => PadLinkReturn::Refused,
            value => PadLinkReturn::__Unknown(value),
        }
    }
}

impl StaticType for PadLinkReturn {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_pad_link_return_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for PadLinkReturn {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for PadLinkReturn {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for PadLinkReturn {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The status of a GstPad. After activating a pad, which usually happens when the
/// parent element goes from READY to PAUSED, the GstPadMode defines if the
/// pad operates in push or pull mode.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PadMode {
    /// Pad will not handle dataflow
    None,
    /// Pad handles dataflow in downstream push mode
    Push,
    /// Pad handles dataflow in upstream pull mode
    Pull,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for PadMode {
    type GlibType = gst_sys::GstPadMode;

    fn to_glib(&self) -> gst_sys::GstPadMode {
        match *self {
            PadMode::None => gst_sys::GST_PAD_MODE_NONE,
            PadMode::Push => gst_sys::GST_PAD_MODE_PUSH,
            PadMode::Pull => gst_sys::GST_PAD_MODE_PULL,
            PadMode::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstPadMode> for PadMode {
    fn from_glib(value: gst_sys::GstPadMode) -> Self {
        skip_assert_initialized!();
        match value {
            0 => PadMode::None,
            1 => PadMode::Push,
            2 => PadMode::Pull,
            value => PadMode::__Unknown(value),
        }
    }
}

impl StaticType for PadMode {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_pad_mode_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for PadMode {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for PadMode {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for PadMode {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Indicates when this pad will become available.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PadPresence {
    /// the pad is always available
    Always,
    /// the pad will become available depending on the media stream
    Sometimes,
    /// the pad is only available on request with
    ///  `ElementExt::request_pad`.
    Request,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for PadPresence {
    type GlibType = gst_sys::GstPadPresence;

    fn to_glib(&self) -> gst_sys::GstPadPresence {
        match *self {
            PadPresence::Always => gst_sys::GST_PAD_ALWAYS,
            PadPresence::Sometimes => gst_sys::GST_PAD_SOMETIMES,
            PadPresence::Request => gst_sys::GST_PAD_REQUEST,
            PadPresence::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstPadPresence> for PadPresence {
    fn from_glib(value: gst_sys::GstPadPresence) -> Self {
        skip_assert_initialized!();
        match value {
            0 => PadPresence::Always,
            1 => PadPresence::Sometimes,
            2 => PadPresence::Request,
            value => PadPresence::__Unknown(value),
        }
    }
}

impl StaticType for PadPresence {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_pad_presence_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for PadPresence {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for PadPresence {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for PadPresence {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Different return values for the `GstPadProbeCallback`.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PadProbeReturn {
    /// drop data in data probes. For push mode this means that
    ///  the data item is not sent downstream. For pull mode, it means that
    ///  the data item is not passed upstream. In both cases, no other probes
    ///  are called for this item and `FlowReturn::Ok` or `true` is returned to the
    ///  caller.
    Drop,
    /// normal probe return value. This leaves the probe in
    ///  place, and defers decisions about dropping or passing data to other
    ///  probes, if any. If there are no other probes, the default behaviour
    ///  for the probe type applies ('block' for blocking probes,
    ///  and 'pass' for non-blocking probes).
    Ok,
    /// remove this probe.
    Remove,
    /// pass the data item in the block probe and block on the
    ///  next item.
    Pass,
    /// Data has been handled in the probe and will not be
    ///  forwarded further. For events and buffers this is the same behaviour as
    ///  `PadProbeReturn::Drop` (except that in this case you need to unref the buffer
    ///  or event yourself). For queries it will also return `true` to the caller.
    ///  The probe can also modify the `FlowReturn` value by using the
    ///  `GST_PAD_PROBE_INFO_FLOW_RETURN`() accessor.
    ///  Note that the resulting query must contain valid entries.
    ///  Since: 1.6
    Handled,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for PadProbeReturn {
    type GlibType = gst_sys::GstPadProbeReturn;

    fn to_glib(&self) -> gst_sys::GstPadProbeReturn {
        match *self {
            PadProbeReturn::Drop => gst_sys::GST_PAD_PROBE_DROP,
            PadProbeReturn::Ok => gst_sys::GST_PAD_PROBE_OK,
            PadProbeReturn::Remove => gst_sys::GST_PAD_PROBE_REMOVE,
            PadProbeReturn::Pass => gst_sys::GST_PAD_PROBE_PASS,
            PadProbeReturn::Handled => gst_sys::GST_PAD_PROBE_HANDLED,
            PadProbeReturn::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstPadProbeReturn> for PadProbeReturn {
    fn from_glib(value: gst_sys::GstPadProbeReturn) -> Self {
        skip_assert_initialized!();
        match value {
            0 => PadProbeReturn::Drop,
            1 => PadProbeReturn::Ok,
            2 => PadProbeReturn::Remove,
            3 => PadProbeReturn::Pass,
            4 => PadProbeReturn::Handled,
            value => PadProbeReturn::__Unknown(value),
        }
    }
}

impl StaticType for PadProbeReturn {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_pad_probe_return_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for PadProbeReturn {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for PadProbeReturn {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for PadProbeReturn {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The different parsing errors that can occur.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum ParseError {
    /// A syntax error occurred.
    Syntax,
    /// The description contained an unknown element
    NoSuchElement,
    /// An element did not have a specified property
    NoSuchProperty,
    /// There was an error linking two pads.
    Link,
    /// There was an error setting a property
    CouldNotSetProperty,
    /// An empty bin was specified.
    EmptyBin,
    /// An empty description was specified
    Empty,
    /// A delayed link did not get resolved.
    DelayedLink,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for ParseError {
    type GlibType = gst_sys::GstParseError;

    fn to_glib(&self) -> gst_sys::GstParseError {
        match *self {
            ParseError::Syntax => gst_sys::GST_PARSE_ERROR_SYNTAX,
            ParseError::NoSuchElement => gst_sys::GST_PARSE_ERROR_NO_SUCH_ELEMENT,
            ParseError::NoSuchProperty => gst_sys::GST_PARSE_ERROR_NO_SUCH_PROPERTY,
            ParseError::Link => gst_sys::GST_PARSE_ERROR_LINK,
            ParseError::CouldNotSetProperty => gst_sys::GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY,
            ParseError::EmptyBin => gst_sys::GST_PARSE_ERROR_EMPTY_BIN,
            ParseError::Empty => gst_sys::GST_PARSE_ERROR_EMPTY,
            ParseError::DelayedLink => gst_sys::GST_PARSE_ERROR_DELAYED_LINK,
            ParseError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstParseError> for ParseError {
    fn from_glib(value: gst_sys::GstParseError) -> Self {
        skip_assert_initialized!();
        match value {
            0 => ParseError::Syntax,
            1 => ParseError::NoSuchElement,
            2 => ParseError::NoSuchProperty,
            3 => ParseError::Link,
            4 => ParseError::CouldNotSetProperty,
            5 => ParseError::EmptyBin,
            6 => ParseError::Empty,
            7 => ParseError::DelayedLink,
            value => ParseError::__Unknown(value),
        }
    }
}

impl ErrorDomain for ParseError {
    fn domain() -> Quark {
        skip_assert_initialized!();
        unsafe { from_glib(gst_sys::gst_parse_error_quark()) }
    }

    fn code(self) -> i32 {
        self.to_glib()
    }

    fn from(code: i32) -> Option<Self> {
        skip_assert_initialized!();
        match code {
            0 => Some(ParseError::Syntax),
            1 => Some(ParseError::NoSuchElement),
            2 => Some(ParseError::NoSuchProperty),
            3 => Some(ParseError::Link),
            4 => Some(ParseError::CouldNotSetProperty),
            5 => Some(ParseError::EmptyBin),
            6 => Some(ParseError::Empty),
            7 => Some(ParseError::DelayedLink),
            value => Some(ParseError::__Unknown(value)),
        }
    }
}

impl StaticType for ParseError {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_parse_error_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for ParseError {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for ParseError {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for ParseError {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The plugin loading errors
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PluginError {
    /// The plugin could not be loaded
    Module,
    /// The plugin has unresolved dependencies
    Dependencies,
    /// The plugin has already be loaded from a different file
    NameMismatch,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for PluginError {
    type GlibType = gst_sys::GstPluginError;

    fn to_glib(&self) -> gst_sys::GstPluginError {
        match *self {
            PluginError::Module => gst_sys::GST_PLUGIN_ERROR_MODULE,
            PluginError::Dependencies => gst_sys::GST_PLUGIN_ERROR_DEPENDENCIES,
            PluginError::NameMismatch => gst_sys::GST_PLUGIN_ERROR_NAME_MISMATCH,
            PluginError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstPluginError> for PluginError {
    fn from_glib(value: gst_sys::GstPluginError) -> Self {
        skip_assert_initialized!();
        match value {
            0 => PluginError::Module,
            1 => PluginError::Dependencies,
            2 => PluginError::NameMismatch,
            value => PluginError::__Unknown(value),
        }
    }
}

impl ErrorDomain for PluginError {
    fn domain() -> Quark {
        skip_assert_initialized!();
        unsafe { from_glib(gst_sys::gst_plugin_error_quark()) }
    }

    fn code(self) -> i32 {
        self.to_glib()
    }

    fn from(code: i32) -> Option<Self> {
        skip_assert_initialized!();
        match code {
            0 => Some(PluginError::Module),
            1 => Some(PluginError::Dependencies),
            2 => Some(PluginError::NameMismatch),
            value => Some(PluginError::__Unknown(value)),
        }
    }
}

impl StaticType for PluginError {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_plugin_error_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for PluginError {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for PluginError {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for PluginError {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The type of a `MessageType::Progress`. The progress messages inform the
/// application of the status of asynchronous tasks.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum ProgressType {
    /// A new task started.
    Start,
    /// A task completed and a new one continues.
    Continue,
    /// A task completed.
    Complete,
    /// A task was canceled.
    Canceled,
    /// A task caused an error. An error message is also
    ///  posted on the bus.
    Error,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for ProgressType {
    type GlibType = gst_sys::GstProgressType;

    fn to_glib(&self) -> gst_sys::GstProgressType {
        match *self {
            ProgressType::Start => gst_sys::GST_PROGRESS_TYPE_START,
            ProgressType::Continue => gst_sys::GST_PROGRESS_TYPE_CONTINUE,
            ProgressType::Complete => gst_sys::GST_PROGRESS_TYPE_COMPLETE,
            ProgressType::Canceled => gst_sys::GST_PROGRESS_TYPE_CANCELED,
            ProgressType::Error => gst_sys::GST_PROGRESS_TYPE_ERROR,
            ProgressType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstProgressType> for ProgressType {
    fn from_glib(value: gst_sys::GstProgressType) -> Self {
        skip_assert_initialized!();
        match value {
            0 => ProgressType::Start,
            1 => ProgressType::Continue,
            2 => ProgressType::Complete,
            3 => ProgressType::Canceled,
            4 => ProgressType::Error,
            value => ProgressType::__Unknown(value),
        }
    }
}

impl StaticType for ProgressType {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_progress_type_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for ProgressType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for ProgressType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for ProgressType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The result of a `Promise`
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PromiseResult {
    /// Initial state. Waiting for transition to any
    ///     other state.
    Pending,
    /// Interrupted by the consumer as it doesn't
    ///     want the value anymore.
    Interrupted,
    /// A producer marked a reply
    Replied,
    /// The promise expired (the carrying object
    ///     lost all refs) and the promise will never be fulfilled.
    ///
    /// Feature: `v1_14`
    ///
    Expired,
    #[doc(hidden)]
    __Unknown(i32),
}

#[cfg(any(feature = "v1_14", feature = "dox"))]
#[doc(hidden)]
impl ToGlib for PromiseResult {
    type GlibType = gst_sys::GstPromiseResult;

    fn to_glib(&self) -> gst_sys::GstPromiseResult {
        match *self {
            PromiseResult::Pending => gst_sys::GST_PROMISE_RESULT_PENDING,
            PromiseResult::Interrupted => gst_sys::GST_PROMISE_RESULT_INTERRUPTED,
            PromiseResult::Replied => gst_sys::GST_PROMISE_RESULT_REPLIED,
            PromiseResult::Expired => gst_sys::GST_PROMISE_RESULT_EXPIRED,
            PromiseResult::__Unknown(value) => value,
        }
    }
}

#[cfg(any(feature = "v1_14", feature = "dox"))]
#[doc(hidden)]
impl FromGlib<gst_sys::GstPromiseResult> for PromiseResult {
    fn from_glib(value: gst_sys::GstPromiseResult) -> Self {
        skip_assert_initialized!();
        match value {
            0 => PromiseResult::Pending,
            1 => PromiseResult::Interrupted,
            2 => PromiseResult::Replied,
            3 => PromiseResult::Expired,
            value => PromiseResult::__Unknown(value),
        }
    }
}

#[cfg(any(feature = "v1_14", feature = "dox"))]
impl StaticType for PromiseResult {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_promise_result_get_type()) }
    }
}

#[cfg(any(feature = "v1_14", feature = "dox"))]
impl<'a> FromValueOptional<'a> for PromiseResult {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

#[cfg(any(feature = "v1_14", feature = "dox"))]
impl<'a> FromValue<'a> for PromiseResult {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

#[cfg(any(feature = "v1_14", feature = "dox"))]
impl SetValue for PromiseResult {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The different types of QoS events that can be given to the
/// `Event::new_qos` method.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum QOSType {
    /// The QoS event type that is produced when upstream
    ///  elements are producing data too quickly and the element can't keep up
    ///  processing the data. Upstream should reduce their production rate. This
    ///  type is also used when buffers arrive early or in time.
    Overflow,
    /// The QoS event type that is produced when upstream
    ///  elements are producing data too slowly and need to speed up their
    ///  production rate.
    Underflow,
    /// The QoS event type that is produced when the
    ///  application enabled throttling to limit the data rate.
    Throttle,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for QOSType {
    type GlibType = gst_sys::GstQOSType;

    fn to_glib(&self) -> gst_sys::GstQOSType {
        match *self {
            QOSType::Overflow => gst_sys::GST_QOS_TYPE_OVERFLOW,
            QOSType::Underflow => gst_sys::GST_QOS_TYPE_UNDERFLOW,
            QOSType::Throttle => gst_sys::GST_QOS_TYPE_THROTTLE,
            QOSType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstQOSType> for QOSType {
    fn from_glib(value: gst_sys::GstQOSType) -> Self {
        skip_assert_initialized!();
        match value {
            0 => QOSType::Overflow,
            1 => QOSType::Underflow,
            2 => QOSType::Throttle,
            value => QOSType::__Unknown(value),
        }
    }
}

impl StaticType for QOSType {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_qos_type_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for QOSType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for QOSType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for QOSType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Element priority ranks. Defines the order in which the autoplugger (or
/// similar rank-picking mechanisms, such as e.g. `Element::make_from_uri`)
/// will choose this element over an alternative one with the same function.
///
/// These constants serve as a rough guidance for defining the rank of a
/// `PluginFeature`. Any value is valid, including values bigger than
/// `Rank::Primary`.
#[derive(Debug, Clone, Copy)]
#[non_exhaustive]
pub enum Rank {
    /// will be chosen last or not at all
    None,
    /// unlikely to be chosen
    Marginal,
    /// likely to be chosen
    Secondary,
    /// will be chosen first
    Primary,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for Rank {
    type GlibType = gst_sys::GstRank;

    fn to_glib(&self) -> gst_sys::GstRank {
        match *self {
            Rank::None => gst_sys::GST_RANK_NONE,
            Rank::Marginal => gst_sys::GST_RANK_MARGINAL,
            Rank::Secondary => gst_sys::GST_RANK_SECONDARY,
            Rank::Primary => gst_sys::GST_RANK_PRIMARY,
            Rank::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstRank> for Rank {
    fn from_glib(value: gst_sys::GstRank) -> Self {
        skip_assert_initialized!();
        match value {
            0 => Rank::None,
            64 => Rank::Marginal,
            128 => Rank::Secondary,
            256 => Rank::Primary,
            value => Rank::__Unknown(value),
        }
    }
}

impl StaticType for Rank {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_rank_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for Rank {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for Rank {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for Rank {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Resource errors are for any resource used by an element:
/// memory, files, network connections, process space, ...
/// They're typically used by source and sink elements.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum ResourceError {
    /// a general error which doesn't fit in any other
    /// category. Make sure you add a custom message to the error call.
    Failed,
    /// do not use this except as a placeholder for
    /// deciding where to go while developing code.
    TooLazy,
    /// used when the resource could not be found.
    NotFound,
    /// used when resource is busy.
    Busy,
    /// used when resource fails to open for reading.
    OpenRead,
    /// used when resource fails to open for writing.
    OpenWrite,
    /// used when resource cannot be opened for
    /// both reading and writing, or either (but unspecified which).
    OpenReadWrite,
    /// used when the resource can't be closed.
    Close,
    /// used when the resource can't be read from.
    Read,
    /// used when the resource can't be written to.
    Write,
    /// used when a seek on the resource fails.
    Seek,
    /// used when a synchronize on the resource fails.
    Sync,
    /// used when settings can't be manipulated on.
    Settings,
    /// used when the resource has no space left.
    NoSpaceLeft,
    /// used when the resource can't be opened
    ///  due to missing authorization.
    ///  (Since: 1.2.4)
    NotAuthorized,
    /// the number of resource error types.
    NumErrors,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for ResourceError {
    type GlibType = gst_sys::GstResourceError;

    fn to_glib(&self) -> gst_sys::GstResourceError {
        match *self {
            ResourceError::Failed => gst_sys::GST_RESOURCE_ERROR_FAILED,
            ResourceError::TooLazy => gst_sys::GST_RESOURCE_ERROR_TOO_LAZY,
            ResourceError::NotFound => gst_sys::GST_RESOURCE_ERROR_NOT_FOUND,
            ResourceError::Busy => gst_sys::GST_RESOURCE_ERROR_BUSY,
            ResourceError::OpenRead => gst_sys::GST_RESOURCE_ERROR_OPEN_READ,
            ResourceError::OpenWrite => gst_sys::GST_RESOURCE_ERROR_OPEN_WRITE,
            ResourceError::OpenReadWrite => gst_sys::GST_RESOURCE_ERROR_OPEN_READ_WRITE,
            ResourceError::Close => gst_sys::GST_RESOURCE_ERROR_CLOSE,
            ResourceError::Read => gst_sys::GST_RESOURCE_ERROR_READ,
            ResourceError::Write => gst_sys::GST_RESOURCE_ERROR_WRITE,
            ResourceError::Seek => gst_sys::GST_RESOURCE_ERROR_SEEK,
            ResourceError::Sync => gst_sys::GST_RESOURCE_ERROR_SYNC,
            ResourceError::Settings => gst_sys::GST_RESOURCE_ERROR_SETTINGS,
            ResourceError::NoSpaceLeft => gst_sys::GST_RESOURCE_ERROR_NO_SPACE_LEFT,
            ResourceError::NotAuthorized => gst_sys::GST_RESOURCE_ERROR_NOT_AUTHORIZED,
            ResourceError::NumErrors => gst_sys::GST_RESOURCE_ERROR_NUM_ERRORS,
            ResourceError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstResourceError> for ResourceError {
    fn from_glib(value: gst_sys::GstResourceError) -> Self {
        skip_assert_initialized!();
        match value {
            1 => ResourceError::Failed,
            2 => ResourceError::TooLazy,
            3 => ResourceError::NotFound,
            4 => ResourceError::Busy,
            5 => ResourceError::OpenRead,
            6 => ResourceError::OpenWrite,
            7 => ResourceError::OpenReadWrite,
            8 => ResourceError::Close,
            9 => ResourceError::Read,
            10 => ResourceError::Write,
            11 => ResourceError::Seek,
            12 => ResourceError::Sync,
            13 => ResourceError::Settings,
            14 => ResourceError::NoSpaceLeft,
            15 => ResourceError::NotAuthorized,
            16 => ResourceError::NumErrors,
            value => ResourceError::__Unknown(value),
        }
    }
}

impl ErrorDomain for ResourceError {
    fn domain() -> Quark {
        skip_assert_initialized!();
        unsafe { from_glib(gst_sys::gst_resource_error_quark()) }
    }

    fn code(self) -> i32 {
        self.to_glib()
    }

    fn from(code: i32) -> Option<Self> {
        skip_assert_initialized!();
        match code {
            1 => Some(ResourceError::Failed),
            2 => Some(ResourceError::TooLazy),
            3 => Some(ResourceError::NotFound),
            4 => Some(ResourceError::Busy),
            5 => Some(ResourceError::OpenRead),
            6 => Some(ResourceError::OpenWrite),
            7 => Some(ResourceError::OpenReadWrite),
            8 => Some(ResourceError::Close),
            9 => Some(ResourceError::Read),
            10 => Some(ResourceError::Write),
            11 => Some(ResourceError::Seek),
            12 => Some(ResourceError::Sync),
            13 => Some(ResourceError::Settings),
            14 => Some(ResourceError::NoSpaceLeft),
            15 => Some(ResourceError::NotAuthorized),
            16 => Some(ResourceError::NumErrors),
            _ => Some(ResourceError::Failed),
        }
    }
}

impl StaticType for ResourceError {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_resource_error_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for ResourceError {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for ResourceError {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for ResourceError {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The different types of seek events. When constructing a seek event with
/// `Event::new_seek` or when doing gst_segment_do_seek ().
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum SeekType {
    /// no change in position is required
    None,
    /// absolute position is requested
    Set,
    /// relative position to duration is requested
    End,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for SeekType {
    type GlibType = gst_sys::GstSeekType;

    fn to_glib(&self) -> gst_sys::GstSeekType {
        match *self {
            SeekType::None => gst_sys::GST_SEEK_TYPE_NONE,
            SeekType::Set => gst_sys::GST_SEEK_TYPE_SET,
            SeekType::End => gst_sys::GST_SEEK_TYPE_END,
            SeekType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstSeekType> for SeekType {
    fn from_glib(value: gst_sys::GstSeekType) -> Self {
        skip_assert_initialized!();
        match value {
            0 => SeekType::None,
            1 => SeekType::Set,
            2 => SeekType::End,
            value => SeekType::__Unknown(value),
        }
    }
}

impl StaticType for SeekType {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_seek_type_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for SeekType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for SeekType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for SeekType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The possible states an element can be in. States can be changed using
/// `Element::set_state` and checked using `Element::get_state`.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum State {
    /// no pending state.
    VoidPending,
    /// the NULL state or initial state of an element.
    Null,
    /// the element is ready to go to PAUSED.
    Ready,
    /// the element is PAUSED, it is ready to accept and
    ///  process data. Sink elements however only accept one
    ///  buffer and then block.
    Paused,
    /// the element is PLAYING, the `Clock` is running and
    ///  the data is flowing.
    Playing,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for State {
    type GlibType = gst_sys::GstState;

    fn to_glib(&self) -> gst_sys::GstState {
        match *self {
            State::VoidPending => gst_sys::GST_STATE_VOID_PENDING,
            State::Null => gst_sys::GST_STATE_NULL,
            State::Ready => gst_sys::GST_STATE_READY,
            State::Paused => gst_sys::GST_STATE_PAUSED,
            State::Playing => gst_sys::GST_STATE_PLAYING,
            State::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstState> for State {
    fn from_glib(value: gst_sys::GstState) -> Self {
        skip_assert_initialized!();
        match value {
            0 => State::VoidPending,
            1 => State::Null,
            2 => State::Ready,
            3 => State::Paused,
            4 => State::Playing,
            value => State::__Unknown(value),
        }
    }
}

impl StaticType for State {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_state_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for State {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for State {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for State {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// These are the different state changes an element goes through.
/// `State::Null` &rArr; `State::Playing` is called an upwards state change
/// and `State::Playing` &rArr; `State::Null` a downwards state change.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum StateChange {
    /// state change from NULL to READY.
    ///  * The element must check if the resources it needs are available. Device
    ///  sinks and -sources typically try to probe the device to constrain their
    ///  caps.
    ///  * The element opens the device (in case feature need to be probed).
    NullToReady,
    /// state change from READY to PAUSED.
    ///  * The element pads are activated in order to receive data in PAUSED.
    ///  Streaming threads are started.
    ///  * Some elements might need to return `StateChangeReturn::Async` and complete
    ///  the state change when they have enough information. It is a requirement
    ///  for sinks to return `StateChangeReturn::Async` and complete the state change
    ///  when they receive the first buffer or `EventType::Eos` (preroll).
    ///  Sinks also block the dataflow when in PAUSED.
    ///  * A pipeline resets the running_time to 0.
    ///  * Live sources return `StateChangeReturn::NoPreroll` and don't generate data.
    ReadyToPaused,
    /// state change from PAUSED to PLAYING.
    ///  * Most elements ignore this state change.
    ///  * The pipeline selects a `Clock` and distributes this to all the children
    ///  before setting them to PLAYING. This means that it is only allowed to
    ///  synchronize on the `Clock` in the PLAYING state.
    ///  * The pipeline uses the `Clock` and the running_time to calculate the
    ///  base_time. The base_time is distributed to all children when performing
    ///  the state change.
    ///  * Sink elements stop blocking on the preroll buffer or event and start
    ///  rendering the data.
    ///  * Sinks can post `MessageType::Eos` in the PLAYING state. It is not allowed
    ///  to post `MessageType::Eos` when not in the PLAYING state.
    ///  * While streaming in PAUSED or PLAYING elements can create and remove
    ///  sometimes pads.
    ///  * Live sources start generating data and return `StateChangeReturn::Success`.
    PausedToPlaying,
    /// state change from PLAYING to PAUSED.
    ///  * Most elements ignore this state change.
    ///  * The pipeline calculates the running_time based on the last selected
    ///  `Clock` and the base_time. It stores this information to continue
    ///  playback when going back to the PLAYING state.
    ///  * Sinks unblock any `Clock` wait calls.
    ///  * When a sink does not have a pending buffer to play, it returns
    ///  `StateChangeReturn::Async` from this state change and completes the state
    ///  change when it receives a new buffer or an `EventType::Eos`.
    ///  * Any queued `MessageType::Eos` items are removed since they will be reposted
    ///  when going back to the PLAYING state. The EOS messages are queued in
    ///  `Bin` containers.
    ///  * Live sources stop generating data and return `StateChangeReturn::NoPreroll`.
    PlayingToPaused,
    /// state change from PAUSED to READY.
    ///  * Sinks unblock any waits in the preroll.
    ///  * Elements unblock any waits on devices
    ///  * Chain or get_range functions return `FlowReturn::Flushing`.
    ///  * The element pads are deactivated so that streaming becomes impossible and
    ///  all streaming threads are stopped.
    ///  * The sink forgets all negotiated formats
    ///  * Elements remove all sometimes pads
    PausedToReady,
    /// state change from READY to NULL.
    ///  * Elements close devices
    ///  * Elements reset any internal state.
    ReadyToNull,
    /// state change from NULL to NULL. (Since: 1.14)
    NullToNull,
    /// state change from READY to READY,
    /// This might happen when going to PAUSED asynchronously failed, in that case
    /// elements should make sure they are in a proper, coherent READY state. (Since: 1.14)
    ReadyToReady,
    /// state change from PAUSED to PAUSED.
    /// This might happen when elements were in PLAYING state and 'lost state',
    /// they should make sure to go back to real 'PAUSED' state (prerolling for example). (Since: 1.14)
    PausedToPaused,
    /// state change from PLAYING to PLAYING. (Since: 1.14)
    PlayingToPlaying,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for StateChange {
    type GlibType = gst_sys::GstStateChange;

    fn to_glib(&self) -> gst_sys::GstStateChange {
        match *self {
            StateChange::NullToReady => gst_sys::GST_STATE_CHANGE_NULL_TO_READY,
            StateChange::ReadyToPaused => gst_sys::GST_STATE_CHANGE_READY_TO_PAUSED,
            StateChange::PausedToPlaying => gst_sys::GST_STATE_CHANGE_PAUSED_TO_PLAYING,
            StateChange::PlayingToPaused => gst_sys::GST_STATE_CHANGE_PLAYING_TO_PAUSED,
            StateChange::PausedToReady => gst_sys::GST_STATE_CHANGE_PAUSED_TO_READY,
            StateChange::ReadyToNull => gst_sys::GST_STATE_CHANGE_READY_TO_NULL,
            StateChange::NullToNull => gst_sys::GST_STATE_CHANGE_NULL_TO_NULL,
            StateChange::ReadyToReady => gst_sys::GST_STATE_CHANGE_READY_TO_READY,
            StateChange::PausedToPaused => gst_sys::GST_STATE_CHANGE_PAUSED_TO_PAUSED,
            StateChange::PlayingToPlaying => gst_sys::GST_STATE_CHANGE_PLAYING_TO_PLAYING,
            StateChange::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstStateChange> for StateChange {
    fn from_glib(value: gst_sys::GstStateChange) -> Self {
        skip_assert_initialized!();
        match value {
            10 => StateChange::NullToReady,
            19 => StateChange::ReadyToPaused,
            28 => StateChange::PausedToPlaying,
            35 => StateChange::PlayingToPaused,
            26 => StateChange::PausedToReady,
            17 => StateChange::ReadyToNull,
            9 => StateChange::NullToNull,
            18 => StateChange::ReadyToReady,
            27 => StateChange::PausedToPaused,
            36 => StateChange::PlayingToPlaying,
            value => StateChange::__Unknown(value),
        }
    }
}

impl StaticType for StateChange {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_state_change_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for StateChange {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for StateChange {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for StateChange {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The possible return values from a state change function such as
/// `Element::set_state`. Only `StateChangeReturn::Failure` is a real failure.
#[must_use]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum StateChangeReturn {
    /// the state change failed
    Failure,
    /// the state change succeeded
    Success,
    /// the state change will happen asynchronously
    Async,
    /// the state change succeeded but the element
    ///  cannot produce data in `State::Paused`.
    ///  This typically happens with live sources.
    NoPreroll,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for StateChangeReturn {
    type GlibType = gst_sys::GstStateChangeReturn;

    fn to_glib(&self) -> gst_sys::GstStateChangeReturn {
        match *self {
            StateChangeReturn::Failure => gst_sys::GST_STATE_CHANGE_FAILURE,
            StateChangeReturn::Success => gst_sys::GST_STATE_CHANGE_SUCCESS,
            StateChangeReturn::Async => gst_sys::GST_STATE_CHANGE_ASYNC,
            StateChangeReturn::NoPreroll => gst_sys::GST_STATE_CHANGE_NO_PREROLL,
            StateChangeReturn::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstStateChangeReturn> for StateChangeReturn {
    fn from_glib(value: gst_sys::GstStateChangeReturn) -> Self {
        skip_assert_initialized!();
        match value {
            0 => StateChangeReturn::Failure,
            1 => StateChangeReturn::Success,
            2 => StateChangeReturn::Async,
            3 => StateChangeReturn::NoPreroll,
            value => StateChangeReturn::__Unknown(value),
        }
    }
}

impl StaticType for StateChangeReturn {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_state_change_return_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for StateChangeReturn {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for StateChangeReturn {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for StateChangeReturn {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Stream errors are for anything related to the stream being processed:
/// format errors, media type errors, ...
/// They're typically used by decoders, demuxers, converters, ...
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum StreamError {
    /// a general error which doesn't fit in any other
    /// category. Make sure you add a custom message to the error call.
    Failed,
    /// do not use this except as a placeholder for
    /// deciding where to go while developing code.
    TooLazy,
    /// use this when you do not want to implement
    /// this functionality yet.
    NotImplemented,
    /// used when the element doesn't know the
    /// stream's type.
    TypeNotFound,
    /// used when the element doesn't handle this type
    /// of stream.
    WrongType,
    /// used when there's no codec to handle the
    /// stream's type.
    CodecNotFound,
    /// used when decoding fails.
    Decode,
    /// used when encoding fails.
    Encode,
    /// used when demuxing fails.
    Demux,
    /// used when muxing fails.
    Mux,
    /// used when the stream is of the wrong format
    /// (for example, wrong caps).
    Format,
    /// used when the stream is encrypted and can't be
    /// decrypted because this is not supported by the element.
    Decrypt,
    /// used when the stream is encrypted and
    /// can't be decrypted because no suitable key is available.
    DecryptNokey,
    /// the number of stream error types.
    NumErrors,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for StreamError {
    type GlibType = gst_sys::GstStreamError;

    fn to_glib(&self) -> gst_sys::GstStreamError {
        match *self {
            StreamError::Failed => gst_sys::GST_STREAM_ERROR_FAILED,
            StreamError::TooLazy => gst_sys::GST_STREAM_ERROR_TOO_LAZY,
            StreamError::NotImplemented => gst_sys::GST_STREAM_ERROR_NOT_IMPLEMENTED,
            StreamError::TypeNotFound => gst_sys::GST_STREAM_ERROR_TYPE_NOT_FOUND,
            StreamError::WrongType => gst_sys::GST_STREAM_ERROR_WRONG_TYPE,
            StreamError::CodecNotFound => gst_sys::GST_STREAM_ERROR_CODEC_NOT_FOUND,
            StreamError::Decode => gst_sys::GST_STREAM_ERROR_DECODE,
            StreamError::Encode => gst_sys::GST_STREAM_ERROR_ENCODE,
            StreamError::Demux => gst_sys::GST_STREAM_ERROR_DEMUX,
            StreamError::Mux => gst_sys::GST_STREAM_ERROR_MUX,
            StreamError::Format => gst_sys::GST_STREAM_ERROR_FORMAT,
            StreamError::Decrypt => gst_sys::GST_STREAM_ERROR_DECRYPT,
            StreamError::DecryptNokey => gst_sys::GST_STREAM_ERROR_DECRYPT_NOKEY,
            StreamError::NumErrors => gst_sys::GST_STREAM_ERROR_NUM_ERRORS,
            StreamError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstStreamError> for StreamError {
    fn from_glib(value: gst_sys::GstStreamError) -> Self {
        skip_assert_initialized!();
        match value {
            1 => StreamError::Failed,
            2 => StreamError::TooLazy,
            3 => StreamError::NotImplemented,
            4 => StreamError::TypeNotFound,
            5 => StreamError::WrongType,
            6 => StreamError::CodecNotFound,
            7 => StreamError::Decode,
            8 => StreamError::Encode,
            9 => StreamError::Demux,
            10 => StreamError::Mux,
            11 => StreamError::Format,
            12 => StreamError::Decrypt,
            13 => StreamError::DecryptNokey,
            14 => StreamError::NumErrors,
            value => StreamError::__Unknown(value),
        }
    }
}

impl ErrorDomain for StreamError {
    fn domain() -> Quark {
        skip_assert_initialized!();
        unsafe { from_glib(gst_sys::gst_stream_error_quark()) }
    }

    fn code(self) -> i32 {
        self.to_glib()
    }

    fn from(code: i32) -> Option<Self> {
        skip_assert_initialized!();
        match code {
            1 => Some(StreamError::Failed),
            2 => Some(StreamError::TooLazy),
            3 => Some(StreamError::NotImplemented),
            4 => Some(StreamError::TypeNotFound),
            5 => Some(StreamError::WrongType),
            6 => Some(StreamError::CodecNotFound),
            7 => Some(StreamError::Decode),
            8 => Some(StreamError::Encode),
            9 => Some(StreamError::Demux),
            10 => Some(StreamError::Mux),
            11 => Some(StreamError::Format),
            12 => Some(StreamError::Decrypt),
            13 => Some(StreamError::DecryptNokey),
            14 => Some(StreamError::NumErrors),
            _ => Some(StreamError::Failed),
        }
    }
}

impl StaticType for StreamError {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_stream_error_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for StreamError {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for StreamError {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for StreamError {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The type of a `MessageType::StreamStatus`. The stream status messages inform the
/// application of new streaming threads and their status.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum StreamStatusType {
    /// A new thread need to be created.
    Create,
    /// a thread entered its loop function
    Enter,
    /// a thread left its loop function
    Leave,
    /// a thread is destroyed
    Destroy,
    /// a thread is started
    Start,
    /// a thread is paused
    Pause,
    /// a thread is stopped
    Stop,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for StreamStatusType {
    type GlibType = gst_sys::GstStreamStatusType;

    fn to_glib(&self) -> gst_sys::GstStreamStatusType {
        match *self {
            StreamStatusType::Create => gst_sys::GST_STREAM_STATUS_TYPE_CREATE,
            StreamStatusType::Enter => gst_sys::GST_STREAM_STATUS_TYPE_ENTER,
            StreamStatusType::Leave => gst_sys::GST_STREAM_STATUS_TYPE_LEAVE,
            StreamStatusType::Destroy => gst_sys::GST_STREAM_STATUS_TYPE_DESTROY,
            StreamStatusType::Start => gst_sys::GST_STREAM_STATUS_TYPE_START,
            StreamStatusType::Pause => gst_sys::GST_STREAM_STATUS_TYPE_PAUSE,
            StreamStatusType::Stop => gst_sys::GST_STREAM_STATUS_TYPE_STOP,
            StreamStatusType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstStreamStatusType> for StreamStatusType {
    fn from_glib(value: gst_sys::GstStreamStatusType) -> Self {
        skip_assert_initialized!();
        match value {
            0 => StreamStatusType::Create,
            1 => StreamStatusType::Enter,
            2 => StreamStatusType::Leave,
            3 => StreamStatusType::Destroy,
            8 => StreamStatusType::Start,
            9 => StreamStatusType::Pause,
            10 => StreamStatusType::Stop,
            value => StreamStatusType::__Unknown(value),
        }
    }
}

impl StaticType for StreamStatusType {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_stream_status_type_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for StreamStatusType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for StreamStatusType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for StreamStatusType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The type of a `MessageType::StructureChange`.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum StructureChangeType {
    /// Pad linking is starting or done.
    Link,
    /// Pad unlinking is starting or done.
    Unlink,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for StructureChangeType {
    type GlibType = gst_sys::GstStructureChangeType;

    fn to_glib(&self) -> gst_sys::GstStructureChangeType {
        match *self {
            StructureChangeType::Link => gst_sys::GST_STRUCTURE_CHANGE_TYPE_PAD_LINK,
            StructureChangeType::Unlink => gst_sys::GST_STRUCTURE_CHANGE_TYPE_PAD_UNLINK,
            StructureChangeType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstStructureChangeType> for StructureChangeType {
    fn from_glib(value: gst_sys::GstStructureChangeType) -> Self {
        skip_assert_initialized!();
        match value {
            0 => StructureChangeType::Link,
            1 => StructureChangeType::Unlink,
            value => StructureChangeType::__Unknown(value),
        }
    }
}

impl StaticType for StructureChangeType {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_structure_change_type_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for StructureChangeType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for StructureChangeType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for StructureChangeType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Extra tag flags used when registering tags.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum TagFlag {
    /// undefined flag
    Undefined,
    /// tag is meta data
    Meta,
    /// tag is encoded
    Encoded,
    /// tag is decoded
    Decoded,
    /// number of tag flags
    Count,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for TagFlag {
    type GlibType = gst_sys::GstTagFlag;

    fn to_glib(&self) -> gst_sys::GstTagFlag {
        match *self {
            TagFlag::Undefined => gst_sys::GST_TAG_FLAG_UNDEFINED,
            TagFlag::Meta => gst_sys::GST_TAG_FLAG_META,
            TagFlag::Encoded => gst_sys::GST_TAG_FLAG_ENCODED,
            TagFlag::Decoded => gst_sys::GST_TAG_FLAG_DECODED,
            TagFlag::Count => gst_sys::GST_TAG_FLAG_COUNT,
            TagFlag::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstTagFlag> for TagFlag {
    fn from_glib(value: gst_sys::GstTagFlag) -> Self {
        skip_assert_initialized!();
        match value {
            0 => TagFlag::Undefined,
            1 => TagFlag::Meta,
            2 => TagFlag::Encoded,
            3 => TagFlag::Decoded,
            4 => TagFlag::Count,
            value => TagFlag::__Unknown(value),
        }
    }
}

impl StaticType for TagFlag {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_tag_flag_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for TagFlag {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for TagFlag {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for TagFlag {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The different tag merging modes are basically replace, overwrite and append,
/// but they can be seen from two directions. Given two taglists: (A) the tags
/// already in the element and (B) the ones that are supplied to the element (
/// e.g. via `TagSetter::merge_tags` / `TagSetter::add_tags` or a
/// `EventType::Tag`), how are these tags merged?
/// In the table below this is shown for the cases that a tag exists in the list
/// (A) or does not exists (!A) and combinations thereof.
///
/// | merge mode | A + B | A + !B | !A + B | !A + !B |
/// | ----------- | ----- | ------ | ------ | ------- |
/// | REPLACE_ALL | B | ø | B | ø |
/// | REPLACE | B | A | B | ø |
/// | APPEND | A, B | A | B | ø |
/// | PREPEND | B, A | A | B | ø |
/// | KEEP | A | A | B | ø |
/// | KEEP_ALL | A | A | ø | ø |
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum TagMergeMode {
    /// undefined merge mode
    Undefined,
    /// replace all tags (clear list and append)
    ReplaceAll,
    /// replace tags
    Replace,
    /// append tags
    Append,
    /// prepend tags
    Prepend,
    /// keep existing tags
    Keep,
    /// keep all existing tags
    KeepAll,
    /// the number of merge modes
    Count,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for TagMergeMode {
    type GlibType = gst_sys::GstTagMergeMode;

    fn to_glib(&self) -> gst_sys::GstTagMergeMode {
        match *self {
            TagMergeMode::Undefined => gst_sys::GST_TAG_MERGE_UNDEFINED,
            TagMergeMode::ReplaceAll => gst_sys::GST_TAG_MERGE_REPLACE_ALL,
            TagMergeMode::Replace => gst_sys::GST_TAG_MERGE_REPLACE,
            TagMergeMode::Append => gst_sys::GST_TAG_MERGE_APPEND,
            TagMergeMode::Prepend => gst_sys::GST_TAG_MERGE_PREPEND,
            TagMergeMode::Keep => gst_sys::GST_TAG_MERGE_KEEP,
            TagMergeMode::KeepAll => gst_sys::GST_TAG_MERGE_KEEP_ALL,
            TagMergeMode::Count => gst_sys::GST_TAG_MERGE_COUNT,
            TagMergeMode::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstTagMergeMode> for TagMergeMode {
    fn from_glib(value: gst_sys::GstTagMergeMode) -> Self {
        skip_assert_initialized!();
        match value {
            0 => TagMergeMode::Undefined,
            1 => TagMergeMode::ReplaceAll,
            2 => TagMergeMode::Replace,
            3 => TagMergeMode::Append,
            4 => TagMergeMode::Prepend,
            5 => TagMergeMode::Keep,
            6 => TagMergeMode::KeepAll,
            7 => TagMergeMode::Count,
            value => TagMergeMode::__Unknown(value),
        }
    }
}

impl StaticType for TagMergeMode {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_tag_merge_mode_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for TagMergeMode {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for TagMergeMode {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for TagMergeMode {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// GstTagScope specifies if a taglist applies to the complete
/// medium or only to one single stream.
#[cfg_attr(feature = "ser_de", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum TagScope {
    /// tags specific to this single stream
    Stream,
    /// global tags for the complete medium
    Global,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for TagScope {
    type GlibType = gst_sys::GstTagScope;

    fn to_glib(&self) -> gst_sys::GstTagScope {
        match *self {
            TagScope::Stream => gst_sys::GST_TAG_SCOPE_STREAM,
            TagScope::Global => gst_sys::GST_TAG_SCOPE_GLOBAL,
            TagScope::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstTagScope> for TagScope {
    fn from_glib(value: gst_sys::GstTagScope) -> Self {
        skip_assert_initialized!();
        match value {
            0 => TagScope::Stream,
            1 => TagScope::Global,
            value => TagScope::__Unknown(value),
        }
    }
}

impl StaticType for TagScope {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_tag_scope_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for TagScope {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for TagScope {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for TagScope {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The different states a task can be in
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum TaskState {
    /// the task is started and running
    Started,
    /// the task is stopped
    Stopped,
    /// the task is paused
    Paused,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for TaskState {
    type GlibType = gst_sys::GstTaskState;

    fn to_glib(&self) -> gst_sys::GstTaskState {
        match *self {
            TaskState::Started => gst_sys::GST_TASK_STARTED,
            TaskState::Stopped => gst_sys::GST_TASK_STOPPED,
            TaskState::Paused => gst_sys::GST_TASK_PAUSED,
            TaskState::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstTaskState> for TaskState {
    fn from_glib(value: gst_sys::GstTaskState) -> Self {
        skip_assert_initialized!();
        match value {
            0 => TaskState::Started,
            1 => TaskState::Stopped,
            2 => TaskState::Paused,
            value => TaskState::__Unknown(value),
        }
    }
}

impl StaticType for TaskState {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_task_state_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for TaskState {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for TaskState {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for TaskState {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The different types of TOC entries (see `TocEntry`).
///
/// There are two types of TOC entries: alternatives or parts in a sequence.
#[cfg_attr(feature = "ser_de", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum TocEntryType {
    /// entry is an angle (i.e. an alternative)
    Angle,
    /// entry is a version (i.e. alternative)
    Version,
    /// entry is an edition (i.e. alternative)
    Edition,
    /// invalid entry type value
    Invalid,
    /// entry is a title (i.e. a part of a sequence)
    Title,
    /// entry is a track (i.e. a part of a sequence)
    Track,
    /// entry is a chapter (i.e. a part of a sequence)
    Chapter,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for TocEntryType {
    type GlibType = gst_sys::GstTocEntryType;

    fn to_glib(&self) -> gst_sys::GstTocEntryType {
        match *self {
            TocEntryType::Angle => gst_sys::GST_TOC_ENTRY_TYPE_ANGLE,
            TocEntryType::Version => gst_sys::GST_TOC_ENTRY_TYPE_VERSION,
            TocEntryType::Edition => gst_sys::GST_TOC_ENTRY_TYPE_EDITION,
            TocEntryType::Invalid => gst_sys::GST_TOC_ENTRY_TYPE_INVALID,
            TocEntryType::Title => gst_sys::GST_TOC_ENTRY_TYPE_TITLE,
            TocEntryType::Track => gst_sys::GST_TOC_ENTRY_TYPE_TRACK,
            TocEntryType::Chapter => gst_sys::GST_TOC_ENTRY_TYPE_CHAPTER,
            TocEntryType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstTocEntryType> for TocEntryType {
    fn from_glib(value: gst_sys::GstTocEntryType) -> Self {
        skip_assert_initialized!();
        match value {
            -3 => TocEntryType::Angle,
            -2 => TocEntryType::Version,
            -1 => TocEntryType::Edition,
            0 => TocEntryType::Invalid,
            1 => TocEntryType::Title,
            2 => TocEntryType::Track,
            3 => TocEntryType::Chapter,
            value => TocEntryType::__Unknown(value),
        }
    }
}

impl StaticType for TocEntryType {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_toc_entry_type_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for TocEntryType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for TocEntryType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for TocEntryType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// How a `TocEntry` should be repeated. By default, entries are played a
/// single time.
#[cfg_attr(feature = "ser_de", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum TocLoopType {
    /// single forward playback
    None,
    /// repeat forward
    Forward,
    /// repeat backward
    Reverse,
    /// repeat forward and backward
    PingPong,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for TocLoopType {
    type GlibType = gst_sys::GstTocLoopType;

    fn to_glib(&self) -> gst_sys::GstTocLoopType {
        match *self {
            TocLoopType::None => gst_sys::GST_TOC_LOOP_NONE,
            TocLoopType::Forward => gst_sys::GST_TOC_LOOP_FORWARD,
            TocLoopType::Reverse => gst_sys::GST_TOC_LOOP_REVERSE,
            TocLoopType::PingPong => gst_sys::GST_TOC_LOOP_PING_PONG,
            TocLoopType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstTocLoopType> for TocLoopType {
    fn from_glib(value: gst_sys::GstTocLoopType) -> Self {
        skip_assert_initialized!();
        match value {
            0 => TocLoopType::None,
            1 => TocLoopType::Forward,
            2 => TocLoopType::Reverse,
            3 => TocLoopType::PingPong,
            value => TocLoopType::__Unknown(value),
        }
    }
}

impl StaticType for TocLoopType {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_toc_loop_type_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for TocLoopType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for TocLoopType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for TocLoopType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The scope of a TOC.
#[cfg_attr(feature = "ser_de", derive(Serialize, Deserialize))]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum TocScope {
    /// global TOC representing all selectable options
    ///  (this is what applications are usually interested in)
    Global,
    /// TOC for the currently active/selected stream
    ///  (this is a TOC representing the current stream from start to EOS,
    ///  and is what a TOC writer / muxer is usually interested in; it will
    ///  usually be a subset of the global TOC, e.g. just the chapters of
    ///  the current title, or the chapters selected for playback from the
    ///  current title)
    Current,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for TocScope {
    type GlibType = gst_sys::GstTocScope;

    fn to_glib(&self) -> gst_sys::GstTocScope {
        match *self {
            TocScope::Global => gst_sys::GST_TOC_SCOPE_GLOBAL,
            TocScope::Current => gst_sys::GST_TOC_SCOPE_CURRENT,
            TocScope::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstTocScope> for TocScope {
    fn from_glib(value: gst_sys::GstTocScope) -> Self {
        skip_assert_initialized!();
        match value {
            1 => TocScope::Global,
            2 => TocScope::Current,
            value => TocScope::__Unknown(value),
        }
    }
}

impl StaticType for TocScope {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_toc_scope_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for TocScope {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for TocScope {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for TocScope {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The probability of the typefind function. Higher values have more certainty
/// in doing a reliable typefind.
#[derive(Debug, Clone, Copy)]
#[non_exhaustive]
pub enum TypeFindProbability {
    /// type undetected.
    None,
    /// unlikely typefind.
    Minimum,
    /// possible type detected.
    Possible,
    /// likely a type was detected.
    Likely,
    /// nearly certain that a type was detected.
    NearlyCertain,
    /// very certain a type was detected.
    Maximum,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for TypeFindProbability {
    type GlibType = gst_sys::GstTypeFindProbability;

    fn to_glib(&self) -> gst_sys::GstTypeFindProbability {
        match *self {
            TypeFindProbability::None => gst_sys::GST_TYPE_FIND_NONE,
            TypeFindProbability::Minimum => gst_sys::GST_TYPE_FIND_MINIMUM,
            TypeFindProbability::Possible => gst_sys::GST_TYPE_FIND_POSSIBLE,
            TypeFindProbability::Likely => gst_sys::GST_TYPE_FIND_LIKELY,
            TypeFindProbability::NearlyCertain => gst_sys::GST_TYPE_FIND_NEARLY_CERTAIN,
            TypeFindProbability::Maximum => gst_sys::GST_TYPE_FIND_MAXIMUM,
            TypeFindProbability::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstTypeFindProbability> for TypeFindProbability {
    fn from_glib(value: gst_sys::GstTypeFindProbability) -> Self {
        skip_assert_initialized!();
        match value {
            0 => TypeFindProbability::None,
            1 => TypeFindProbability::Minimum,
            50 => TypeFindProbability::Possible,
            80 => TypeFindProbability::Likely,
            99 => TypeFindProbability::NearlyCertain,
            100 => TypeFindProbability::Maximum,
            value => TypeFindProbability::__Unknown(value),
        }
    }
}

impl StaticType for TypeFindProbability {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_type_find_probability_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for TypeFindProbability {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for TypeFindProbability {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for TypeFindProbability {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Different URI-related errors that can occur.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum URIError {
    /// The protocol is not supported
    UnsupportedProtocol,
    /// There was a problem with the URI
    BadUri,
    /// Could not set or change the URI because the
    ///  URI handler was in a state where that is not possible or not permitted
    BadState,
    /// There was a problem with the entity that
    ///  the URI references
    BadReference,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for URIError {
    type GlibType = gst_sys::GstURIError;

    fn to_glib(&self) -> gst_sys::GstURIError {
        match *self {
            URIError::UnsupportedProtocol => gst_sys::GST_URI_ERROR_UNSUPPORTED_PROTOCOL,
            URIError::BadUri => gst_sys::GST_URI_ERROR_BAD_URI,
            URIError::BadState => gst_sys::GST_URI_ERROR_BAD_STATE,
            URIError::BadReference => gst_sys::GST_URI_ERROR_BAD_REFERENCE,
            URIError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstURIError> for URIError {
    fn from_glib(value: gst_sys::GstURIError) -> Self {
        skip_assert_initialized!();
        match value {
            0 => URIError::UnsupportedProtocol,
            1 => URIError::BadUri,
            2 => URIError::BadState,
            3 => URIError::BadReference,
            value => URIError::__Unknown(value),
        }
    }
}

impl ErrorDomain for URIError {
    fn domain() -> Quark {
        skip_assert_initialized!();
        unsafe { from_glib(gst_sys::gst_uri_error_quark()) }
    }

    fn code(self) -> i32 {
        self.to_glib()
    }

    fn from(code: i32) -> Option<Self> {
        skip_assert_initialized!();
        match code {
            0 => Some(URIError::UnsupportedProtocol),
            1 => Some(URIError::BadUri),
            2 => Some(URIError::BadState),
            3 => Some(URIError::BadReference),
            value => Some(URIError::__Unknown(value)),
        }
    }
}

impl StaticType for URIError {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_uri_error_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for URIError {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for URIError {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for URIError {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The different types of URI direction.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum URIType {
    /// The URI direction is unknown
    Unknown,
    /// The URI is a consumer.
    Sink,
    /// The URI is a producer.
    Src,
    #[doc(hidden)]
    __Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for URIType {
    type GlibType = gst_sys::GstURIType;

    fn to_glib(&self) -> gst_sys::GstURIType {
        match *self {
            URIType::Unknown => gst_sys::GST_URI_UNKNOWN,
            URIType::Sink => gst_sys::GST_URI_SINK,
            URIType::Src => gst_sys::GST_URI_SRC,
            URIType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<gst_sys::GstURIType> for URIType {
    fn from_glib(value: gst_sys::GstURIType) -> Self {
        skip_assert_initialized!();
        match value {
            0 => URIType::Unknown,
            1 => URIType::Sink,
            2 => URIType::Src,
            value => URIType::__Unknown(value),
        }
    }
}

impl StaticType for URIType {
    fn static_type() -> Type {
        unsafe { from_glib(gst_sys::gst_uri_type_get_type()) }
    }
}

impl<'a> FromValueOptional<'a> for URIType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for URIType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for URIType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}