summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h
blob: c4c7aca16c740f5bee3efee27e5823484aba3d4d (plain)
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
/*
 *  Copyright (C) 2005-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "../AddonBase.h"
#include "../c-api/addon-instance/inputstream.h"
#include "inputstream/StreamCodec.h"
#include "inputstream/StreamConstants.h"
#include "inputstream/StreamCrypto.h"
#include "inputstream/TimingConstants.h"

#ifdef __cplusplus

#include <map>

namespace kodi
{
namespace addon
{

//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// "C++" Doxygen group set for the definitions
//{{{

//==============================================================================
/// @defgroup cpp_kodi_addon_inputstream_Defs Definitions, structures and enumerators
/// @ingroup cpp_kodi_addon_inputstream
/// @brief **Inputstream add-on instance definition values**\n
/// All inputstream functions associated data structures.
///
/// Used to exchange the available options between Kodi and addon.\n
/// The groups described here correspond to the groups of functions on inputstream
/// instance class.
///
/// In addition, some of the things described here are also used on the
/// @ref cpp_kodi_addon_videocodec "video codec" addon.
///

//##############################################################################
/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface 1. Interface
/// @ingroup cpp_kodi_addon_inputstream_Defs
/// @brief **Inputstream add-on general variables**\n
/// Used to exchange the available options between Kodi and addon.
///

//##############################################################################
/// @defgroup cpp_kodi_addon_inputstream_Defs_StreamConstants 2. Stream constants
/// @ingroup cpp_kodi_addon_inputstream_Defs
/// @brief **Used to exchange any additional data between the caller and processor.**\n
/// This includes the standardized values, in addition, an addon can also use
/// its own special uses to be exchanged in the same way.
///
/// These values can be used by other addons (e.g. video addon) or stream files
/// to select the respective inputstream addon and to transfer additional values.
///
/// ----------------------------------------------------------------------------
///
/// **Example:**
///
/// This example use the @ref STREAM_PROPERTY_INPUTSTREAM on a <b>`*.strm`</b>
/// file to select needed addon and a additional value where related to selected
/// addon itself.
///
/// ~~~~~~~~~~~~
/// #KODIPROP:inputstream=inputstream.adaptive
/// #KODIPROP:inputstream.adaptive.manifest_type=mpd
/// http://rdmedia.bbc.co.uk/dash/ondemand/testcard/1/client_manifest-events-multilang.mpd
/// ~~~~~~~~~~~~
///
/// These are then given to Kodi and the respectively selected addon by means of
/// his @ref kodi::addon::CInstanceInputStream::Open "Open" call
/// in @ref kodi::addon::InputstreamProperty::GetProperties.
///
/// The largest possible amount of these <b>`#KODIPROP`</b> values is defined
/// with @ref STREAM_MAX_PROPERTY_COUNT.
///

//##############################################################################
/// @defgroup cpp_kodi_addon_inputstream_Defs_TimingConstants 3. Stream timing
/// @ingroup cpp_kodi_addon_inputstream_Defs
/// @brief **Timebase and timestamp definitions.**\n
/// Used to exchange the available options between Kodi and addon.
///

//##############################################################################
/// @defgroup cpp_kodi_addon_inputstream_Defs_StreamCodec 4. Stream codec
/// @ingroup cpp_kodi_addon_inputstream_Defs
/// @brief **Inputstream codec control**\n
/// Used to manage stream codec data.
///

//##############################################################################
/// @defgroup cpp_kodi_addon_inputstream_Defs_StreamEncryption 5. Stream encryption
/// @ingroup cpp_kodi_addon_inputstream_Defs
/// @brief **Inputstream encryption control**\n
/// Used to manage encrypted streams within addon.
///

//}}}
//______________________________________________________________________________

class CInstanceInputStream;

//==============================================================================
/// @defgroup cpp_kodi_addon_inputstream_Defs_InputstreamProperty class InputstreamProperty
/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface
/// @brief <b>URL and Data of key/value pairs passed to addon on @ref kodi::addon::CInstanceInputStream::Open "Open".</b>\n
/// This is used to have the necessary data of the stream to be opened.
///
/// ----------------------------------------------------------------------------
///
/// @copydetails cpp_kodi_addon_inputstream_Defs_InputstreamProperty_Help
///
/// @warning This data are only given from Kodi to addon and can't be used
/// on other places on addon.
///
///@{
class ATTRIBUTE_HIDDEN InputstreamProperty
  : public CStructHdl<InputstreamProperty, INPUTSTREAM_PROPERTY>
{
  /*! \cond PRIVATE */
  friend class CInstanceInputStream;
  /*! \endcond */

public:
  /// @defgroup cpp_kodi_addon_inputstream_Defs_InputstreamProperty_Help Value Help
  /// @ingroup cpp_kodi_addon_inputstream_Defs_InputstreamProperty
  ///
  /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_InputstreamProperty :</b>
  /// | Name | Type | Get call
  /// |------|------|----------
  /// | **Stream URL** | `std::string` | @ref InputstreamProperty::GetURL "GetURL"
  /// | **Mime type** | `std::string` | @ref InputstreamProperty::GetMimeType "GetMimeType"
  /// | **Available amount of properties** | `unsigned int` | @ref InputstreamProperty::GetPropertiesAmount "GetPropertiesAmount"
  /// | **List of properties** | `std::map<std::string, std::string>` | @ref InputstreamProperty::GetProperties "GetProperties"
  /// | **Get addon library folder** | `std::string` | @ref InputstreamProperty::GetLibFolder "GetLibFolder"
  /// | **Get addon profile/user folder** | `std::string` | @ref InputstreamProperty::GetProfileFolder "GetProfileFolder"

  /// @addtogroup cpp_kodi_addon_inputstream_Defs_InputstreamProperty
  ///@{

  /// @brief Stream URL to open.
  std::string GetURL() const { return m_cStructure->m_strURL; }

  /// @brief Stream mime type.
  std::string GetMimeType() const { return m_cStructure->m_mimeType; }

  /// @brief Amount of available properties.
  unsigned int GetPropertiesAmount() const
  {
    return m_cStructure->m_nCountInfoValues;
  }

  /// @brief List of available properties-
  const std::map<std::string, std::string> GetProperties() const
  {
    std::map<std::string, std::string> props;
    for (unsigned int i = 0; i < m_cStructure->m_nCountInfoValues; ++i)
    {
      props.emplace(m_cStructure->m_ListItemProperties[i].m_strKey,
                    m_cStructure->m_ListItemProperties[i].m_strValue);
    }
    return props;
  }

  /// @brief Get addon library folder.
  ///
  /// @note As alternative can also @ref kodi::GetAddonPath used.
  std::string GetLibFolder() const { return m_cStructure->m_libFolder; }

  /// @brief Get addon profile/user folder.
  ///
  /// @note As alternative can also @ref kodi::GetBaseUserPath used.
  std::string GetProfileFolder() const { return m_cStructure->m_profileFolder; }

  ///@}

private:
  InputstreamProperty() = delete;
  InputstreamProperty(const InputstreamProperty& stream) = delete;
  InputstreamProperty(const INPUTSTREAM_PROPERTY* stream) : CStructHdl(stream) {}
  InputstreamProperty(INPUTSTREAM_PROPERTY* stream) : CStructHdl(stream) {}
};
///@}
//------------------------------------------------------------------------------

//==============================================================================
/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities class InputstreamCapabilities
/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface
/// @brief **InputStream add-on capabilities. All capabilities are set to "false" as default.**\n
/// Asked to addon on @ref kodi::addon::CInstanceInputStream::GetCapabilities "GetCapabilities".
///
/// ----------------------------------------------------------------------------
///
/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities_Help
///
///@{
class ATTRIBUTE_HIDDEN InputstreamCapabilities
  : public CStructHdl<InputstreamCapabilities, INPUTSTREAM_CAPABILITIES>
{
  /*! \cond PRIVATE */
  friend class CInstanceInputStream;
  /*! \endcond */

public:
  /*! \cond PRIVATE */
  InputstreamCapabilities() = default;
  InputstreamCapabilities(const InputstreamCapabilities& stream) : CStructHdl(stream) {}
  /*! \endcond */

  /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities_Help Value Help
  /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities
  ///
  /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities :</b>
  /// | Name | Type | Set call | Get call
  /// |------|------|----------|----------
  /// | **Capabilities bit mask** | `uint32_t` | @ref InputstreamCapabilities::SetMask "SetMask" | @ref InputstreamCapabilities::GetMask "GetMask"

  /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities
  ///@{

  /// @brief Set of supported capabilities.
  void SetMask(uint32_t mask) const { m_cStructure->m_mask = mask; }

  /// @brief Get of supported capabilities.
  uint32_t GetMask() const { return m_cStructure->m_mask; }

  ///@}

private:
  InputstreamCapabilities(const INPUTSTREAM_CAPABILITIES* stream) : CStructHdl(stream) {}
  InputstreamCapabilities(INPUTSTREAM_CAPABILITIES* stream) : CStructHdl(stream) {}
};
///@}
//------------------------------------------------------------------------------

//==============================================================================
/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata class InputstreamMasteringMetadata
/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface
/// @brief **Mastering metadata.**\n
/// Describes the metadata for [HDR10](https://en.wikipedia.org/wiki/High-dynamic-range_video).
///
/// Used when video is compressed using [High Efficiency Video Coding (HEVC)](https://en.wikipedia.org/wiki/High_Efficiency_Video_Coding).
/// This is used to describe the capabilities  of the display used to master the
/// content and the luminance values of the content.
///
/// Used on @ref kodi::addon::InputstreamInfo::SetMasteringMetadata and @ref kodi::addon::InputstreamInfo::GetMasteringMetadata.
///
/// ----------------------------------------------------------------------------
///
/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata_Help
///
///@{
class ATTRIBUTE_HIDDEN InputstreamMasteringMetadata
  : public CStructHdl<InputstreamMasteringMetadata, INPUTSTREAM_MASTERING_METADATA>
{
  /*! \cond PRIVATE */
  friend class CInstanceInputStream;
  friend class InputstreamInfo;
  /*! \endcond */

public:
  /*! \cond PRIVATE */
  InputstreamMasteringMetadata() = default;
  InputstreamMasteringMetadata(const InputstreamMasteringMetadata& stream) : CStructHdl(stream) {}
  /*! \endcond */

  /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata_Help Value Help
  /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata
  ///
  /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata :</b>
  /// | Name | Type | Set call | Get call
  /// |------|------|----------|----------
  /// | **Chromaticity X coordinates of the red** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryR_ChromaticityX "SetPrimaryR_ChromaticityX" | @ref InputstreamMasteringMetadata::GetPrimaryR_ChromaticityX "GetPrimaryR_ChromaticityX"
  /// | **Chromaticity Y coordinates of the red** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryR_ChromaticityY "SetPrimaryR_ChromaticityY" | @ref InputstreamMasteringMetadata::GetPrimaryR_ChromaticityY "GetPrimaryR_ChromaticityY"
  /// | **Chromaticity X coordinates of the green** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryG_ChromaticityX "SetPrimaryG_ChromaticityX" | @ref InputstreamMasteringMetadata::GetPrimaryG_ChromaticityX "GetPrimaryG_ChromaticityX"
  /// | **Chromaticity Y coordinates of the green** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryG_ChromaticityY "SetPrimaryG_ChromaticityY" | @ref InputstreamMasteringMetadata::GetPrimaryG_ChromaticityY "GetPrimaryG_ChromaticityY"
  /// | **Chromaticity X coordinates of the blue** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryB_ChromaticityX "SetPrimaryB_ChromaticityX" | @ref InputstreamMasteringMetadata::GetPrimaryB_ChromaticityX "GetPrimaryB_ChromaticityX"
  /// | **Chromaticity Y coordinates of the blue** | `double` | @ref InputstreamMasteringMetadata::SetPrimaryB_ChromaticityY "SetPrimaryB_ChromaticityY" | @ref InputstreamMasteringMetadata::GetPrimaryB_ChromaticityY "GetPrimaryB_ChromaticityY"
  /// | **Chromaticity X coordinates of the white point** | `double` | @ref InputstreamMasteringMetadata::SetWhitePoint_ChromaticityX "SetWhitePoint_ChromaticityX" | @ref InputstreamMasteringMetadata::GetWhitePoint_ChromaticityX "GetWhitePoint_ChromaticityX"
  /// | **Chromaticity Y coordinates of the white point** | `double` | @ref InputstreamMasteringMetadata::SetWhitePoint_ChromaticityY "SetWhitePoint_ChromaticityY" | @ref InputstreamMasteringMetadata::GetWhitePoint_ChromaticityY "GetWhitePoint_ChromaticityY"
  /// | **Maximum number of bits of the display** | `double` | @ref InputstreamMasteringMetadata::SetLuminanceMax "SetLuminanceMax" | @ref InputstreamMasteringMetadata::GetLuminanceMax "GetLuminanceMax"
  /// | **Minimum number of bits of the display** | `double` | @ref InputstreamMasteringMetadata::SetLuminanceMin "SetLuminanceMin" | @ref InputstreamMasteringMetadata::GetLuminanceMin "GetLuminanceMin"

  /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata
  ///@{

  /// @brief Metadata class compare.
  ///
  /// To compare the metadata with another one.
  ///
  /// @return true if they equal, false otherwise
  bool operator==(const kodi::addon::InputstreamMasteringMetadata& right) const
  {
    if (memcmp(m_cStructure, right.m_cStructure, sizeof(INPUTSTREAM_MASTERING_METADATA)) == 0)
      return true;
    return false;
  }

  /// @brief Set the chromaticity coordinates of the red value in the
  /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
  ///
  /// X coordinate. The values are normalized to 50,000.
  void SetPrimaryR_ChromaticityX(double value) { m_cStructure->primary_r_chromaticity_x = value; }

  /// @brief Get the chromaticity X coordinates of the red value.
  double GetPrimaryR_ChromaticityX() { return m_cStructure->primary_r_chromaticity_x; }

  /// @brief The chromaticity coordinates of the red value in the
  /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
  ///
  /// Y coordinate. The values are normalized to 50,000.
  void SetPrimaryR_ChromaticityY(double value) { m_cStructure->primary_r_chromaticity_y = value; }

  /// @brief Get the chromaticity Y coordinates of the red value.
  double GetPrimaryR_ChromaticityY() { return m_cStructure->primary_r_chromaticity_y; }

  /// @brief Set the chromaticity coordinates of the green value in the
  /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
  ///
  /// X coordinate. The values are normalized to 50,000.
  void SetPrimaryG_ChromaticityX(double value) { m_cStructure->primary_g_chromaticity_x = value; }

  /// @brief Get the chromaticity X coordinates of the green value.
  double GetPrimaryG_ChromaticityX() { return m_cStructure->primary_g_chromaticity_x; }

  /// @brief Set the chromaticity coordinates of the green value in the
  /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
  ///
  /// Y coordinate. The values are normalized to 50,000.
  void SetPrimaryG_ChromaticityY(double value) { m_cStructure->primary_g_chromaticity_y = value; }

  /// @brief Get the chromaticity Y coordinates of the green value.
  double GetPrimaryG_ChromaticityY() { return m_cStructure->primary_g_chromaticity_y; }

  /// @brief The chromaticity coordinates of the blue value in the
  /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
  ///
  /// X coordinate. The values are normalized to 50,000.
  void SetPrimaryB_ChromaticityX(double value) { m_cStructure->primary_b_chromaticity_x = value; }

  /// @brief Get the chromaticity X coordinates of the blue value.
  double GetPrimaryB_ChromaticityX() { return m_cStructure->primary_b_chromaticity_x; }

  /// @brief The chromaticity coordinates of the blue value in the
  /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
  ///
  /// Y coordinate. The values are normalized to 50,000.
  void SetPrimaryB_ChromaticityY(double value) { m_cStructure->primary_b_chromaticity_y = value; }

  /// @brief Get the chromaticity Y coordinates of the blue value.
  double GetPrimaryB_ChromaticityY() { return m_cStructure->primary_b_chromaticity_y; }

  /// @brief Set the chromaticity coordinates of the white point in the
  /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
  ///
  /// X coordinate. The values are normalized to 50,000.
  void SetWhitePoint_ChromaticityX(double value)
  {
    m_cStructure->white_point_chromaticity_x = value;
  }

  /// @brief Get the chromaticity X coordinates of the white point
  double GetWhitePoint_ChromaticityX() { return m_cStructure->white_point_chromaticity_x; }

  /// @brief Set the chromaticity coordinates of the white point in the
  /// [CIE1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space.
  ///
  /// Y coordinate. The values are normalized to 50,000.
  void SetWhitePoint_ChromaticityY(double value)
  {
    m_cStructure->white_point_chromaticity_y = value;
  }

  /// @brief Get the chromaticity Y coordinates of the white point.
  double GetWhitePoint_ChromaticityY() { return m_cStructure->white_point_chromaticity_y; }

  /// @brief Set the maximum number of bits of the display used to master the content.
  ///
  /// Values are normalized to 10,000.
  void SetLuminanceMax(double value) { m_cStructure->luminance_max = value; }

  /// @brief Get the maximum number of bits of the display.
  double GetLuminanceMax() { return m_cStructure->luminance_max; }

  /// @brief Set the minimum number of bits of the display used to master the content.
  ///
  /// Values are normalized to 10,000.
  void SetLuminanceMin(double value) { m_cStructure->luminance_min = value; }

  /// @brief Get the minimum number of bits of the display.
  double GetLuminanceMin() { return m_cStructure->luminance_min; }

  ///@}

private:
  InputstreamMasteringMetadata(const INPUTSTREAM_MASTERING_METADATA* stream) : CStructHdl(stream) {}
  InputstreamMasteringMetadata(INPUTSTREAM_MASTERING_METADATA* stream) : CStructHdl(stream) {}
};
///@}
//------------------------------------------------------------------------------

//==============================================================================
/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata class InputstreamContentlightMetadata
/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface
/// @brief **Contentlight metadata**\n
/// Describes the metadata for [HDR10](https://en.wikipedia.org/wiki/High-dynamic-range_video).
/// See also @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata "InputstreamMasteringMetadata".
///
/// Used on @ref kodi::addon::InputstreamInfo::SetContentLightMetadata and @ref kodi::addon::InputstreamInfo::GetContentLightMetadata.
///
/// ----------------------------------------------------------------------------
///
/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata_Help
///
///@{
class ATTRIBUTE_HIDDEN InputstreamContentlightMetadata
  : public CStructHdl<InputstreamContentlightMetadata, INPUTSTREAM_CONTENTLIGHT_METADATA>
{
  /*! \cond PRIVATE */
  friend class CInstanceInputStream;
  friend class InputstreamInfo;
  /*! \endcond */

public:
  /*! \cond PRIVATE */
  InputstreamContentlightMetadata() = default;
  InputstreamContentlightMetadata(const InputstreamContentlightMetadata& stream)
    : CStructHdl(stream)
  {
  }
  /*! \endcond */

  /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata_Help Value Help
  /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata
  ///
  /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata :</b>
  /// | Name | Type | Set call | Get call
  /// |------|------|----------|----------
  /// | **Maximum content light level** | `double` | @ref InputstreamContentlightMetadata::SetMaxCll "SetMaxCll" | @ref InputstreamContentlightMetadata::GetMaxCll "GetMaxCll"
  /// | **Maximum frame average light level** | `double` | @ref InputstreamContentlightMetadata::SetMaxFall "SetMaxFall" | @ref InputstreamContentlightMetadata::GetMaxFall "GetMaxFall"

  /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata
  ///@{

  /// @brief Metadata class compare.
  ///
  /// To compare the metadata with another one.
  ///
  /// @return true if they equal, false otherwise
  bool operator==(const kodi::addon::InputstreamContentlightMetadata& right) const
  {
    if (memcmp(m_cStructure, right.m_cStructure, sizeof(INPUTSTREAM_CONTENTLIGHT_METADATA)) == 0)
      return true;
    return false;
  }

  /// @brief Set the maximum content light level (MaxCLL).
  ///
  /// This is the bit value corresponding to the brightest pixel used anywhere
  /// in the content.
  void SetMaxCll(uint64_t value) { m_cStructure->max_cll = value; }

  /// @brief Get the maximum content light level (MaxCLL).
  uint64_t GetMaxCll() { return m_cStructure->max_cll; }

  /// @brief Set the maximum frame average light level (MaxFALL).
  ///
  /// This is the bit value corresponding to the average luminance of the frame
  /// which has the brightest average luminance anywhere in the content.
  void SetMaxFall(uint64_t value) { m_cStructure->max_fall = value; }

  /// @brief Get the maximum frame average light level (MaxFALL).
  uint64_t GetMaxFall() { return m_cStructure->max_fall; }

  ///@}

private:
  InputstreamContentlightMetadata(const INPUTSTREAM_CONTENTLIGHT_METADATA* stream)
    : CStructHdl(stream)
  {
  }
  InputstreamContentlightMetadata(INPUTSTREAM_CONTENTLIGHT_METADATA* stream) : CStructHdl(stream) {}
};
///@}
//------------------------------------------------------------------------------

//==============================================================================
/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo class InputstreamInfo
/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface
/// @brief **Inputstream add-on stream info**\n
/// This is used to give Kodi the associated and necessary data for an open stream.
///
/// Used on @ref kodi::addon::CInstanceInputStream::GetStream().
///
/// ----------------------------------------------------------------------------
///
/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo_Help
///
///@{
class ATTRIBUTE_HIDDEN InputstreamInfo : public CStructHdl<InputstreamInfo, INPUTSTREAM_INFO>
{
  /*! \cond PRIVATE */
  friend class CInstanceInputStream;
  /*! \endcond */

public:
  /*! \cond PRIVATE */
  InputstreamInfo() = default;
  InputstreamInfo(const InputstreamInfo& stream) : CStructHdl(stream)
  {
    SetCryptoSession(stream.GetCryptoSession());
    CopyExtraData();
  }
  /*! \endcond */

  /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo_Help Value Help
  /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo
  ///
  /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo :</b>
  /// | Name | Type used | Required | Set call | Get call
  /// |------|-----------|----------|----------|---------
  /// | **Stream type** | all | yes | @ref InputstreamInfo::SetStreamType "SetStreamType" | @ref InputstreamInfo::GetStreamType "GetStreamType"
  /// | **Feature flags** | all | yes | @ref InputstreamInfo::SetFeatures "SetFeatures" | @ref InputstreamInfo::GetFeatures "GetFeatures"
  /// | **Flags** | all | yes | @ref InputstreamInfo::SetFlags "SetFlags" | @ref InputstreamInfo::GetFlags "GetFlags"
  /// | **Name** | all | no | @ref InputstreamInfo::SetName "SetName" | @ref InputstreamInfo::GetName "GetName"
  /// | **Codec name** | all | yes | @ref InputstreamInfo::SetCodecName "SetCodecName" | @ref InputstreamInfo::GetCodecName "GetCodecName"
  /// | **Codec internal name** | all | no | @ref InputstreamInfo::SetCodecInternalName "SetCodecInternalName" | @ref InputstreamInfo::GetCodecInternalName "GetCodecInternalName"
  /// | **Codec Profile** | all | no | @ref InputstreamInfo::SetCodecProfile "SetCodecProfile" | @ref InputstreamInfo::GetCodecProfile "GetCodecProfile"
  /// | **Physical index** | all | yes | @ref InputstreamInfo::SetPhysicalIndex "SetPhysicalIndex" | @ref InputstreamInfo::GetPhysicalIndex "GetPhysicalIndex"
  /// | **Extra data** | Subtitle / all | Type related required | @ref InputstreamInfo::SetExtraData "SetExtraData" | @ref InputstreamInfo::GetExtraData "GetExtraData"
  /// | **RFC 5646 language code** | all | no | @ref InputstreamInfo::SetLanguage "SetLanguage" | @ref InputstreamInfo::GetLanguage "GetLanguage"
  /// | **FPS scale** | Video | Type related required | @ref InputstreamInfo::SetFpsScale "SetFpsScale" | @ref InputstreamInfo::GetFpsScale "GetFpsScale"
  /// | **FPS rate** | Video | Type related required | @ref InputstreamInfo::SetFpsRate "SetFpsRate" | @ref InputstreamInfo::GetFpsRate "GetFpsRate"
  /// | **Height** | Video | Type related required | @ref InputstreamInfo::SetHeight "SetHeight" | @ref InputstreamInfo::GetHeight "GetHeight"
  /// | **Width** | Video | Type related required | @ref InputstreamInfo::SetWidth "SetWidth" | @ref InputstreamInfo::GetWidth "GetWidth"
  /// | **Aspect** | Video | Type related required | @ref InputstreamInfo::SetAspect "SetAspect" | @ref InputstreamInfo::GetAspect "GetAspect"
  /// | **Channel quantity** | Audio | Type related required | @ref InputstreamInfo::SetChannels "SetChannels" | @ref InputstreamInfo::GetChannels "GetChannels"
  /// | **Sample rate** | Audio | Type related required | @ref InputstreamInfo::SetSampleRate "SetSampleRate" | @ref InputstreamInfo::GetSampleRate "GetSampleRate"
  /// | **Bit rate** | Audio | Type related required | @ref InputstreamInfo::SetBitRate "SetBitRate" | @ref InputstreamInfo::GetBitRate "GetBitRate"
  /// | **Bits per sample** | Audio | Type related required | @ref InputstreamInfo::SetBitsPerSample "SetBitsPerSample" | @ref InputstreamInfo::GetBitsPerSample "GetBitsPerSample"
  /// | **Block align** |  | no | @ref InputstreamInfo::SetBlockAlign "SetBlockAlign" | @ref InputstreamInfo::GetBlockAlign "GetBlockAlign"
  /// | **Crypto session info** |  | no | @ref InputstreamInfo::SetCryptoSession "SetCryptoSession" | @ref InputstreamInfo::GetCryptoSession "GetCryptoSession"
  /// | **Four CC code** |  | no | @ref InputstreamInfo::SetCodecFourCC "SetCodecFourCC" | @ref InputstreamInfo::GetCodecFourCC "GetCodecFourCC"
  /// | **Color space** |  | no | @ref InputstreamInfo::SetColorSpace "SetColorSpace" | @ref InputstreamInfo::GetColorSpace "GetColorSpace"
  /// | **Color range** |  | no | @ref InputstreamInfo::SetColorRange "SetColorRange" | @ref InputstreamInfo::GetColorRange "GetColorRange"
  /// | **Color primaries** |  | no | @ref InputstreamInfo::SetColorPrimaries "SetColorPrimaries" | @ref InputstreamInfo::GetColorPrimaries "GetColorPrimaries"
  /// | **Color transfer characteristic** |  | no | @ref InputstreamInfo::SetColorTransferCharacteristic "SetColorTransferCharacteristic" | @ref InputstreamInfo::GetColorTransferCharacteristic "GetColorTransferCharacteristic"
  /// | **Mastering metadata** |  | no | @ref InputstreamInfo::SetMasteringMetadata "SetMasteringMetadata" | @ref InputstreamInfo::GetMasteringMetadata "GetMasteringMetadata"
  /// | **Content light metadata** |  | no | @ref InputstreamInfo::SetContentLightMetadata "SetContentLightMetadata" | @ref InputstreamInfo::GetContentLightMetadata "GetContentLightMetadata"
  ///

  /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo
  ///@{

  /// @brief Set the wanted stream type.
  ///
  /// @param[in] streamType By @ref INPUTSTREAM_TYPE defined type
  void SetStreamType(INPUTSTREAM_TYPE streamType) { m_cStructure->m_streamType = streamType; }

  /// @brief To get with @ref SetStreamType changed values.
  INPUTSTREAM_TYPE GetStreamType() const { return m_cStructure->m_streamType; }

  /// @brief Set special supported feature flags of inputstream.
  ///
  /// @param[in] features By @ref INPUTSTREAM_CODEC_FEATURES defined type
  void SetFeatures(uint32_t features) { m_cStructure->m_features = features; }

  /// @brief To get with @ref SetFeatures changed values.
  uint32_t GetFeatures() const { return m_cStructure->m_features; }

  /// @brief Set supported flags of inputstream.
  ///
  /// @param[in] flags The on @ref INPUTSTREAM_FLAGS defined flags to set
  void SetFlags(uint32_t flags) { m_cStructure->m_flags = flags; }

  /// @brief To get with @ref SetFeatures changed values.
  uint32_t GetFlags() const { return m_cStructure->m_flags; }

  /// @brief (optional) Name of the stream, leave empty for default handling.
  ///
  /// @param[in] name Stream name
  void SetName(const std::string& name)
  {
    strncpy(m_cStructure->m_name, name.c_str(), INPUTSTREAM_MAX_STRING_NAME_SIZE);
  }

  /// @brief To get with @ref SetName changed values.
  std::string GetName() const { return m_cStructure->m_name; }

  /// @brief (required) Name of codec according to ffmpeg.
  ///
  /// See https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/codec_desc.c about
  /// available names.
  ///
  /// @remark On @ref INPUTSTREAM_TYPE_TELETEXT and @ref INPUTSTREAM_TYPE_RDS
  /// this can be ignored and leaved empty.
  ///
  /// @param[in] codeName Codec name
  void SetCodecName(const std::string& codecName)
  {
    strncpy(m_cStructure->m_codecName, codecName.c_str(), INPUTSTREAM_MAX_STRING_CODEC_SIZE);
  }

  /// @brief To get with @ref SetCodecName changed values.
  std::string GetCodecName() const { return m_cStructure->m_codecName; }

  /// @brief (optional) Internal name of codec (selectionstream info).
  ///
  /// @param[in] codecName Internal codec name
  void SetCodecInternalName(const std::string& codecName)
  {
    strncpy(m_cStructure->m_codecInternalName, codecName.c_str(),
            INPUTSTREAM_MAX_STRING_CODEC_SIZE);
  }

  /// @brief To get with @ref SetCodecInternalName changed values.
  std::string GetCodecInternalName() const { return m_cStructure->m_codecInternalName; }

  /// @brief (optional) The profile of the codec.
  ///
  /// @param[in] codecProfile Values with @ref STREAMCODEC_PROFILE to use
  void SetCodecProfile(STREAMCODEC_PROFILE codecProfile)
  {
    m_cStructure->m_codecProfile = codecProfile;
  }

  /// @brief To get with @ref SetCodecProfile changed values.
  STREAMCODEC_PROFILE GetCodecProfile() const { return m_cStructure->m_codecProfile; }

  /// @brief (required) Physical index.
  ///
  /// @param[in] id Index identifier
  void SetPhysicalIndex(unsigned int id) { m_cStructure->m_pID = id; }

  /// @brief To get with @ref SetPhysicalIndex changed values.
  unsigned int GetPhysicalIndex() const { return m_cStructure->m_pID; }

  /// @brief Additional data where can needed on streams.
  ///
  /// @param[in] extraData List with memory of extra data
  void SetExtraData(const std::vector<uint8_t>& extraData)
  {
    m_extraData = extraData;
    m_cStructure->m_ExtraData = m_extraData.data();
    m_cStructure->m_ExtraSize = m_extraData.size();
  }

  /// @brief Additional data where can needed on streams.
  ///
  /// @param[in] extraData Pointer with memory of extra data
  /// @param[in] extraSize Size to store
  void SetExtraData(const uint8_t* extraData, size_t extraSize)
  {
    m_extraData.clear();
    if (extraData && extraSize > 0)
    {
      for (size_t i = 0; i < extraSize; ++i)
        m_extraData.emplace_back(extraData[i]);
    }

    m_cStructure->m_ExtraData = m_extraData.data();
    m_cStructure->m_ExtraSize = m_extraData.size();
  }

  /// @brief To get with @ref SetExtraData changed values.
  const std::vector<uint8_t>& GetExtraData() { return m_extraData; }

  /// @brief To get size with @ref SetExtraData changed values.
  size_t GetExtraDataSize() { return m_extraData.size(); }

  /// @brief Compare extra data from outside with class
  ///
  /// @param[in] extraData Pointer with memory of extra data for compare
  /// @param[in] extraSize Size to compare
  /// @return true if they equal, false otherwise
  bool CompareExtraData(const uint8_t* extraData, size_t extraSize) const
  {
    if (!extraData || m_extraData.size() != extraSize)
      return false;
    for (size_t i = 0; i < extraSize; ++i)
    {
      if (m_extraData[i] != extraData[i])
        return false;
    }
    return true;
  }

  /// @brief Clear additional data.
  void ClearExtraData()
  {
    m_extraData.clear();
    m_cStructure->m_ExtraData = m_extraData.data();
    m_cStructure->m_ExtraSize = m_extraData.size();
  }

  /// @brief RFC 5646 language code (empty string if undefined).
  ///
  /// @param[in] language The language to set
  void SetLanguage(const std::string& language)
  {
    strncpy(m_cStructure->m_language, language.c_str(), INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE);
  }

  /// @brief To get with @ref SetLanguage changed values.
  std::string GetLanguage() const { return m_cStructure->m_language; }

  /// @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps.
  ///
  /// @param[in] fpsScale Scale rate
  void SetFpsScale(unsigned int fpsScale) { m_cStructure->m_FpsScale = fpsScale; }

  /// @brief To get with @ref SetFpsScale changed values.
  unsigned int GetFpsScale() const { return m_cStructure->m_FpsScale; }

  /// @brief Rate to use for stream.
  ///
  /// @param[in] fpsRate Rate to use
  void SetFpsRate(unsigned int fpsRate) { m_cStructure->m_FpsRate = fpsRate; }

  /// @brief To get with @ref SetFpsRate changed values.
  unsigned int GetFpsRate() const { return m_cStructure->m_FpsRate; }

  /// @brief Height of the stream reported by the demuxer.
  ///
  /// @param[in] height Height to use
  void SetHeight(unsigned int height) { m_cStructure->m_Height = height; }

  /// @brief To get with @ref SetHeight changed values.
  unsigned int GetHeight() const { return m_cStructure->m_Height; }

  /// @brief Width of the stream reported by the demuxer.
  ///
  /// @param[in] width Width to use
  void SetWidth(unsigned int width) { m_cStructure->m_Width = width; }

  /// @brief To get with @ref SetWidth changed values.
  unsigned int GetWidth() const { return m_cStructure->m_Width; }

  /// @brief Display aspect of stream.
  ///
  /// @param[in] aspect Aspect ratio to use
  void SetAspect(float aspect) { m_cStructure->m_Aspect = aspect; }

  /// @brief To get with @ref SetAspect changed values.
  float GetAspect() const { return m_cStructure->m_Aspect; }

  /// @brief (required) Amount of channels.
  ///
  /// @param[in] sampleRate Channels to use
  void SetChannels(unsigned int channels) { m_cStructure->m_Channels = channels; }

  /// @brief To get with @ref SetChannels changed values.
  unsigned int GetChannels() const { return m_cStructure->m_Channels; }

  /// @brief (required) Sample rate.
  ///
  /// @param[in] sampleRate Rate to use
  void SetSampleRate(unsigned int sampleRate) { m_cStructure->m_SampleRate = sampleRate; }

  /// @brief To get with @ref SetSampleRate changed values.
  unsigned int GetSampleRate() const { return m_cStructure->m_SampleRate; }

  /// @brief Bit rate.
  ///
  /// @param[in] bitRate Rate to use
  void SetBitRate(unsigned int bitRate) { m_cStructure->m_BitRate = bitRate; }

  /// @brief To get with @ref SetBitRate changed values.
  unsigned int GetBitRate() const { return m_cStructure->m_BitRate; }

  /// @brief (required) Bits per sample.
  ///
  /// @param[in] bitsPerSample Bits per sample to use
  void SetBitsPerSample(unsigned int bitsPerSample)
  {
    m_cStructure->m_BitsPerSample = bitsPerSample;
  }

  /// @brief To get with @ref SetBitsPerSample changed values.
  unsigned int GetBitsPerSample() const { return m_cStructure->m_BitsPerSample; }

  /// @brief To set the necessary stream block alignment size.
  ///
  /// @param[in] blockAlign Block size in byte
  void SetBlockAlign(unsigned int blockAlign) { m_cStructure->m_BlockAlign = blockAlign; }

  /// @brief To get with @ref SetBlockAlign changed values.
  unsigned int GetBlockAlign() const { return m_cStructure->m_BlockAlign; }

  /// @brief To set stream crypto session informations.
  ///
  /// @param[in] cryptoSession The with @ref cpp_kodi_addon_inputstream_Defs_Interface_StreamCryptoSession setable info
  ///
  void SetCryptoSession(const kodi::addon::StreamCryptoSession& cryptoSession)
  {
    m_cryptoSession = cryptoSession;
    memcpy(&m_cStructure->m_cryptoSession, m_cryptoSession.GetCStructure(),
           sizeof(STREAM_CRYPTO_SESSION));
  }

  /// @brief To get with @ref GetCryptoSession changed values.
  const kodi::addon::StreamCryptoSession& GetCryptoSession() const { return m_cryptoSession; }

  /// @brief Codec If available, the fourcc code codec.
  ///
  /// @param[in] codecFourCC Codec four CC code
  void SetCodecFourCC(unsigned int codecFourCC) { m_cStructure->m_codecFourCC = codecFourCC; }

  /// @brief To get with @ref SetCodecFourCC changed values
  unsigned int GetCodecFourCC() const { return m_cStructure->m_codecFourCC; }

  /// @brief Definition of colorspace.
  ///
  /// @param[in] colorSpace The with @ref INPUTSTREAM_COLORSPACE setable color space
  void SetColorSpace(INPUTSTREAM_COLORSPACE colorSpace) { m_cStructure->m_colorSpace = colorSpace; }

  /// @brief To get with @ref SetColorSpace changed values.
  INPUTSTREAM_COLORSPACE GetColorSpace() const { return m_cStructure->m_colorSpace; }

  /// @brief Color range if available.
  ///
  /// @param[in] colorRange The with @ref INPUTSTREAM_COLORRANGE setable color space
  void SetColorRange(INPUTSTREAM_COLORRANGE colorRange) { m_cStructure->m_colorRange = colorRange; }

  /// @brief To get with @ref SetColorRange changed values.
  INPUTSTREAM_COLORRANGE GetColorRange() const { return m_cStructure->m_colorRange; }

  /// @brief Chromaticity coordinates of the source primaries. These values match the ones defined by ISO/IEC 23001-8_2013 § 7.1.
  ///
  /// @param[in] colorPrimaries The with @ref INPUTSTREAM_COLORPRIMARIES setable values
  void SetColorPrimaries(INPUTSTREAM_COLORPRIMARIES colorPrimaries)
  {
    m_cStructure->m_colorPrimaries = colorPrimaries;
  }

  /// @brief To get with @ref SetColorPrimaries changed values.
  INPUTSTREAM_COLORPRIMARIES GetColorPrimaries() const { return m_cStructure->m_colorPrimaries; }

  /// @brief Color Transfer Characteristic. These values match the ones defined by ISO/IEC 23001-8_2013 § 7.2.
  ///
  /// @param[in] colorTransferCharacteristic The with @ref INPUTSTREAM_COLORTRC setable characteristic
  void SetColorTransferCharacteristic(INPUTSTREAM_COLORTRC colorTransferCharacteristic)
  {
    m_cStructure->m_colorTransferCharacteristic = colorTransferCharacteristic;
  }

  /// @brief To get with @ref SetColorTransferCharacteristic changed values.
  INPUTSTREAM_COLORTRC GetColorTransferCharacteristic() const
  {
    return m_cStructure->m_colorTransferCharacteristic;
  }

  /// @brief Mastering static Metadata.
  ///
  /// Describes the metadata for HDR10, used when video is compressed using High
  /// Efficiency Video Coding (HEVC). This is used to describe the capabilities
  /// of the display used to master the content and the luminance values of the
  /// content.
  ///
  /// @param[in] masteringMetadata The with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamMasteringMetadata setable metadata
  void SetMasteringMetadata(const kodi::addon::InputstreamMasteringMetadata& masteringMetadata)
  {
    m_masteringMetadata = masteringMetadata;
    m_cStructure->m_masteringMetadata = m_masteringMetadata;
  }

  /// @brief To get with @ref SetMasteringMetadata changed values.
  const kodi::addon::InputstreamMasteringMetadata& GetMasteringMetadata() const
  {
    return m_masteringMetadata;
  }

  /// @brief Clear mastering static Metadata.
  void ClearMasteringMetadata() { m_cStructure->m_masteringMetadata = nullptr; }

  /// @brief Content light static Metadata.
  ///
  /// The maximum content light level (MaxCLL) and frame average light level
  /// (MaxFALL) for the metadata for HDR10.
  ///
  /// @param[in] contentLightMetadata The with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamContentlightMetadata setable metadata
  void SetContentLightMetadata(
      const kodi::addon::InputstreamContentlightMetadata& contentLightMetadata)
  {
    m_contentLightMetadata = contentLightMetadata;
    m_cStructure->m_contentLightMetadata = m_contentLightMetadata;
  }

  /// @brief To get with @ref SetContentLightMetadata changed values.
  const kodi::addon::InputstreamContentlightMetadata& GetContentLightMetadata() const
  {
    return m_contentLightMetadata;
  }

  /// @brief Clear content light static Metadata.
  void ClearContentLightMetadata() { m_cStructure->m_contentLightMetadata = nullptr; }

  ///@}

private:
  InputstreamInfo(const INPUTSTREAM_INFO* stream) : CStructHdl(stream)
  {
    SetCryptoSession(StreamCryptoSession(&stream->m_cryptoSession));
    CopyExtraData();
  }
  InputstreamInfo(INPUTSTREAM_INFO* stream) : CStructHdl(stream)
  {
    SetCryptoSession(StreamCryptoSession(&stream->m_cryptoSession));
    CopyExtraData();
  }

  void CopyExtraData()
  {
    if (m_cStructure->m_ExtraData && m_cStructure->m_ExtraSize > 0)
    {
      for (unsigned int i = 0; i < m_cStructure->m_ExtraSize; ++i)
        m_extraData.emplace_back(m_cStructure->m_ExtraData[i]);
    }
    if (m_cStructure->m_masteringMetadata)
      m_masteringMetadata = m_cStructure->m_masteringMetadata;
    if (m_cStructure->m_contentLightMetadata)
      m_contentLightMetadata = m_cStructure->m_contentLightMetadata;
  }
  std::vector<uint8_t> m_extraData;
  StreamCryptoSession m_cryptoSession;
  InputstreamMasteringMetadata m_masteringMetadata;
  InputstreamContentlightMetadata m_contentLightMetadata;
};
///@}
//------------------------------------------------------------------------------

//==============================================================================
/// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes class InputstreamTimes
/// @ingroup cpp_kodi_addon_inputstream_Defs_Interface
/// @brief **Inputstream add-on times**\n
/// Used on @ref kodi::addon::CInstanceInputStream::GetTimes().
///
/// ----------------------------------------------------------------------------
///
/// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes_Help
///
///@{
class ATTRIBUTE_HIDDEN InputstreamTimes : public CStructHdl<InputstreamTimes, INPUTSTREAM_TIMES>
{
  /*! \cond PRIVATE */
  friend class CInstanceInputStream;
  /*! \endcond */

public:
  /*! \cond PRIVATE */
  InputstreamTimes() = default;
  InputstreamTimes(const InputstreamTimes& stream) : CStructHdl(stream) {}
  /*! \endcond */

  /// @defgroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes_Help Value Help
  /// @ingroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes
  ///
  /// <b>The following table contains values that can be set with @ref cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes :</b>
  /// | Name | Type | Set call | Get call
  /// |------|------|----------|--------------------
  /// | **Start time** | `time_t` | @ref InputstreamTimes::SetStartTime "SetStartTime" | @ref InputstreamTimes::GetStartTime "GetStartTime"
  /// | **PTS start** | `double` | @ref InputstreamTimes::SetPtsStart "SetPtsStart" | @ref InputstreamTimes::GetPtsStart "GetPtsStart"
  /// | **PTS begin** | `double` | @ref InputstreamTimes::SetPtsBegin "SetPtsBegin" | @ref InputstreamTimes::GetPtsBegin "GetPtsBegin"
  /// | **PTS end** | `double` | @ref InputstreamTimes::SetPtsEnd "SetPtsEnd" | @ref InputstreamTimes::GetPtsEnd "GetPtsEnd"
  ///

  /// @addtogroup cpp_kodi_addon_inputstream_Defs_Interface_InputstreamTimes
  ///@{

  /// @brief Start time in milliseconds
  void SetStartTime(time_t startTime) const { m_cStructure->startTime = startTime; }

  /// @brief To get with @ref SetStartTime changed values
  time_t GetStartTime() const { return m_cStructure->startTime; }

  /// @brief Start PTS
  void SetPtsStart(double ptsStart) const { m_cStructure->ptsStart = ptsStart; }

  /// @brief To get with @ref SetPtsStart changed values
  double GetPtsStart() const { return m_cStructure->ptsStart; }

  /// @brief Begin PTS
  void SetPtsBegin(double ptsBegin) const { m_cStructure->ptsBegin = ptsBegin; }

  /// @brief To get with @ref SetPtsBegin changed values
  double GetPtsBegin() const { return m_cStructure->ptsBegin; }

  /// @brief End PTS
  void SetPtsEnd(double ptsEnd) const { m_cStructure->ptsEnd = ptsEnd; }

  /// @brief To get with @ref SetPtsEnd changed values
  double GetPtsEnd() const { return m_cStructure->ptsEnd; }

  ///@}

private:
  InputstreamTimes(const INPUTSTREAM_TIMES* stream) : CStructHdl(stream) {}
  InputstreamTimes(INPUTSTREAM_TIMES* stream) : CStructHdl(stream) {}
};
///@}
//------------------------------------------------------------------------------

//============================================================================
///
/// @addtogroup cpp_kodi_addon_inputstream
/// @brief \cpp_class{ kodi::addon::CInstanceInputStream }
/// **Inputstream add-on instance**
///
/// This instance type is for using input streams to video and audio, to process
/// and then give them to Kodi.
///
/// This usage can be requested under various conditions, for example explicitly
/// by another addon, by a Mimetype protocol defined in `addon.xml` or supported
/// file extensions.
///
/// In addition, stream files (* .strm) can be linked to an inputstream addon
/// using <b>`#KODIPROP:inputstream=<ADDON_NAME>`</b>.
///
/// Include the header @ref Inputstream.h "#include <kodi/addon-instance/Inputstream.h>"
/// to use this class.
///
/// ----------------------------------------------------------------------------
///
/// Here is an example of what the <b>`addon.xml.in`</b> would look like for an inputstream addon:
///
/// ~~~~~~~~~~~~~{.xml}
/// <?xml version="1.0" encoding="UTF-8"?>
/// <addon
///   id="inputstream.myspecialnamefor"
///   version="1.0.0"
///   name="My InputStream addon"
///   provider-name="Your Name">
///   <requires>@ADDON_DEPENDS@</requires>
///   <extension
///     point="kodi.inputstream"
///     extension=".xyz|.zyx"
///     listitemprops="license_type|license_key|license_data|license_flags"
///     protocols="myspecialnamefor|myspecialnamefors"
///     library_@PLATFORM@="@LIBRARY_FILENAME@"/>
///   <extension point="xbmc.addon.metadata">
///     <summary lang="en_GB">My InputStream addon</summary>
///     <description lang="en_GB">My InputStream description</description>
///     <platform>@PLATFORM@</platform>
///   </extension>
/// </addon>
/// ~~~~~~~~~~~~~
///
///
/// At <b>`<extension point="kodi.inputstream" ...>`</b> the basic instance definition is declared, this is intended to identify the addon as an input stream and to see its supported types:
/// | Name | Description
/// |------|----------------------
/// | <b>`point`</b> | The identification of the addon instance to inputstream is mandatory <b>`kodi.inputstream`</b>. In addition, the instance declared in the first <b>`<extension ... />`</b> is also
/// | <b>`extension`</b> | A filename extension is an identifier specified as a suffix to the name of a computer file where supported by addon.
/// | <b>`listitemprops`</b> | Values that are available to the addon at @ref InputstreamProperty::GetProperties() and that can be passed to @ref CInstanceInputStream::Open() ith the respective values.
/// | <b>`protocols`</b> | The streaming protocol is a special protocol supported by the addon for the transmission of streaming media data over a network.
/// | <b>`library_@PLATFORM@`</b> | The runtime library used for the addon. This is usually declared by cmake and correctly displayed in the translated `addon.xml`.
///
///
/// @remark For more detailed description of the <b>`addon.xml`</b>, see also https://kodi.wiki/view/Addon.xml.
///
///
/// --------------------------------------------------------------------------
///
///
/// **Example:**
///
/// ~~~~~~~~~~~~~{.cpp}
/// #include <kodi/addon-instance/Inputstream.h>
///
/// class CMyInputstream : public kodi::addon::CInstanceInputStream
/// {
/// public:
///   CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion);
///
///   void GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities) override;
///   bool Open(const kodi::addon::InputstreamProperty& props) override;
///   void Close() override;
///   ...
/// };
///
/// CMyInputstream::CMyInputstream(KODI_HANDLE instance, const std::string& kodiVersion)
///   : kodi::addon::CInstanceInputStream(instance, kodiVersion)
/// {
///   ...
/// }
///
/// void CMyInputstream::GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities)
/// {
///   capabilities.SetMask(INPUTSTREAM_SUPPORTS_IDEMUX | INPUTSTREAM_SUPPORTS_PAUSE);
/// }
///
/// void CMyInputstream::Open(const kodi::addon::InputstreamProperty& props)
/// {
///   std::string url = props.GetURL();
///   ...
/// }
///
/// void CMyInputstream::Close()
/// {
///   ...
/// }
///
/// ...
///
/// //----------------------------------------------------------------------
///
/// class CMyAddon : public kodi::addon::CAddonBase
/// {
/// public:
///   CMyAddon() = default;
///   ADDON_STATUS CreateInstance(int instanceType,
///                               std::string instanceID,
///                               KODI_HANDLE instance,
///                               const std::string& version,
///                               KODI_HANDLE& addonInstance) override;
/// };
///
/// // If you use only one instance in your add-on, can be instanceType and
/// // instanceID ignored
/// ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
///                                       std::string instanceID,
///                                       KODI_HANDLE instance,
///                                       const std::string& version,
///                                       KODI_HANDLE& addonInstance)
/// {
///   if (instanceType == ADDON_INSTANCE_INPUTSTREAM)
///   {
///     kodi::Log(ADDON_LOG_NOTICE, "Creating my Inputstream");
///     addonInstance = new CMyInputstream(instance, version);
///     return ADDON_STATUS_OK;
///   }
///   else if (...)
///   {
///     ...
///   }
///   return ADDON_STATUS_UNKNOWN;
/// }
///
/// ADDONCREATOR(CMyAddon)
/// ~~~~~~~~~~~~~
///
/// The destruction of the example class `CMyInputstream` is called from
/// Kodi's header. Manually deleting the add-on instance is not required.
///
//------------------------------------------------------------------------------
class ATTRIBUTE_HIDDEN CInstanceInputStream : public IAddonInstance
{
public:
  //============================================================================
  /// @ingroup cpp_kodi_addon_inputstream
  /// @brief Inputstream class constructor used to support multiple instance
  /// types
  ///
  /// @param[in] instance The instance value given to <b>`kodi::addon::CAddonBase::CreateInstance(...)`</b>
  /// @param[in] kodiVersion [opt] Version used in Kodi for this instance, to
  ///                        allow compatibility to older Kodi versions.
  ///
  /// @warning Only use `instance` from the @ref CAddonBase::CreateInstance call.
  ///
  explicit CInstanceInputStream(KODI_HANDLE instance, const std::string& kodiVersion = "")
    : IAddonInstance(ADDON_INSTANCE_INPUTSTREAM,
                     !kodiVersion.empty() ? kodiVersion
                                          : GetKodiTypeVersion(ADDON_INSTANCE_INPUTSTREAM))
  {
    if (CAddonBase::m_interface->globalSingleInstance != nullptr)
      throw std::logic_error("kodi::addon::CInstanceInputStream: Creation of multiple together "
                             "with single instance way is not allowed!");

    SetAddonStruct(instance, m_kodiVersion);
  }
  //----------------------------------------------------------------------------

  //============================================================================
  /// @ingroup cpp_kodi_addon_inputstream
  /// @brief Destructor
  ///
  ~CInstanceInputStream() override = default;
  //----------------------------------------------------------------------------

  //============================================================================
  /// @ingroup cpp_kodi_addon_inputstream
  /// @brief Get the list of features that this add-on provides.
  ///
  /// Called by Kodi to query the add-on's capabilities.
  /// Used to check which options should be presented in the UI, which methods to call, etc.
  /// All capabilities that the add-on supports should be set to true.
  ///
  /// @param[out] capabilities The with @ref cpp_kodi_addon_inputstream_Defs_Capabilities defined add-on's capabilities.
  ///
  ///
  /// --------------------------------------------------------------------------
  ///
  /// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamCapabilities_Help
  ///
  /// --------------------------------------------------------------------------
  /// @note Valid implementation required.
  ///
  ///
  /// --------------------------------------------------------------------------
  ///
  /// **Example:**
  ///
  /// ~~~~~~~~~~~~~{.cpp}
  /// void CMyInputstream::GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities)
  /// {
  ///   capabilities.SetMask(INPUTSTREAM_SUPPORTS_IDEMUX | INPUTSTREAM_SUPPORTS_PAUSE);
  /// }
  /// ~~~~~~~~~~~~~
  ///
  virtual void GetCapabilities(kodi::addon::InputstreamCapabilities& capabilities) = 0;
  //----------------------------------------------------------------------------

  //============================================================================
  /// @ingroup cpp_kodi_addon_inputstream
  /// @brief Open a stream.
  ///
  /// @param[in] props The used properties about the stream
  /// @return True if the stream has been opened successfully, false otherwise.
  ///
  ///
  /// --------------------------------------------------------------------------
  ///
  /// @copydetails cpp_kodi_addon_inputstream_Defs_InputstreamProperty_Help
  ///
  /// --------------------------------------------------------------------------
  /// @note Valid implementation required.
  ///
  ///
  /// --------------------------------------------------------------------------
  ///
  /// **Example:**
  ///
  /// ~~~~~~~~~~~~~{.cpp}
  /// void CMyInputstream::Open(const kodi::addon::InputstreamProperty& props)
  /// {
  ///   std::string url = props.GetURL();
  ///   std::string license_key = props.GetProperties()["inputstream.myspecialnamefor.license_key"];
  ///   ...
  /// }
  /// ~~~~~~~~~~~~~
  ///
  virtual bool Open(const kodi::addon::InputstreamProperty& props) = 0;
  //----------------------------------------------------------------------------

  //============================================================================
  /// @ingroup cpp_kodi_addon_inputstream
  /// @brief Close an open stream.
  ///
  /// @remarks
  ///
  ///
  /// --------------------------------------------------------------------------
  /// @note Valid implementation required.
  ///
  virtual void Close() = 0;
  //----------------------------------------------------------------------------

  //============================================================================
  /// @ingroup cpp_kodi_addon_inputstream
  /// @brief Check for real-time streaming
  ///
  /// @return true if current stream is real-time
  ///
  virtual bool IsRealTimeStream() { return true; }
  //----------------------------------------------------------------------------

  //############################################################################
  /// @defgroup cpp_kodi_addon_inputstream_Read 1. Stream read
  /// @brief **Functions required to read streams direct and demux inside Kodi.**
  ///
  /// This part contains at least the functions necessary for addon that have to
  /// be supported. This can only be ignored if you use your own demux.
  ///
  /// The data loaded by Kodi is then processed in it itself. The source does not
  /// matter, only Kodi must be able to process this stream data itself and is
  /// therefore limited in some things.
  ///
  /// For more complex things, the addon must integrate its own demuxer and,
  /// if necessary, even its own codec processing (see @ref cpp_kodi_addon_codec "Codec").
  ///
  /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_IDEMUX
  /// is <em><b>undefined</b></em> in the capabilities (see @ref GetCapabilities()).
  /// Otherwise becomes @ref cpp_kodi_addon_inputstream_Demux "demuxing" used.
  ///
  /// @ingroup cpp_kodi_addon_inputstream
  ///@{

  //============================================================================
  /// @brief Read from an open stream.
  ///
  /// @param[in] buffer The buffer to store the data in.
  /// @param[in] bufferSize The amount of bytes to read.
  /// @return The amount of bytes that were actually read from the stream.
  ///
  virtual int ReadStream(uint8_t* buffer, unsigned int bufferSize) { return -1; }
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief Seek in a stream.
  ///
  /// @param[in] position The position to seek to
  /// @param[in] whence offset relative to<br>
  /// You can set the value of whence to one of three things:
  /// |     Value    |  int  | Description                                         |
  /// |:------------:|:-----:|:----------------------------------------------------|
  /// | **SEEK_SET** |  `0`  | position is relative to the beginning of the file. This is probably what you had in mind anyway, and is the most commonly used value for whence.
  /// | **SEEK_CUR** |  `1`  | position is relative to the current file pointer position. So, in effect, you can say, "Move to my current position plus 30 bytes," or, "move to my current position minus 20 bytes."
  /// | **SEEK_END** |  `2`  | position is relative to the end of the file. Just like SEEK_SET except from the other end of the file. Be sure to use negative values for offset if you want to back up from the end of the file, instead of going past the end into oblivion.
  ///
  /// @return Returns the resulting offset location as measured in bytes from
  /// the beginning of the file. On error, the value -1 is returned.
  ///
  /// @remarks Optional and can leaved away or return -1 if this add-on won't
  /// provide this function.
  ///
  virtual int64_t SeekStream(int64_t position, int whence = SEEK_SET) { return -1; }
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief The position in the stream that's currently being read.
  ///
  /// @return Stream position
  ///
  /// @remarks Optional and can leaved away or return -1 if this add-on won't
  /// provide this function.
  ///
  virtual int64_t PositionStream() { return -1; }
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief The Total length of the stream that's currently being read.
  ///
  /// @return Length of the stream
  ///
  /// @remarks Optional and can leaved away or return -1 if this add-on won't
  /// provide this function.
  ///
  virtual int64_t LengthStream() { return -1; }
  //--------------------------------------------------------------------------

  //==========================================================================
  /// @brief Obtain the chunk size to use when reading streams.
  ///
  /// @return Block chunk size
  ///
  /// @remarks Optional and can leaved away or return 0 if this add-on won't
  /// provide this function.
  ///
  virtual int GetBlockSize() { return 0; }
  //--------------------------------------------------------------------------

  ///@}

  //############################################################################
  /// @defgroup cpp_kodi_addon_inputstream_Demux 2. Stream demuxing (optional)
  /// @brief **Read demux streams.**
  ///
  /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_IDEMUX is set in the capabilities (see @ref GetCapabilities()).
  ///
  /// @ingroup cpp_kodi_addon_inputstream
  ///@{

  //============================================================================
  /// @brief Get IDs of available streams
  ///
  /// @param[in] ids list of used identifications
  /// @return true if successfully done, otherwise false
  ///
  /// @remarks This id's are used to identify wanted data on @ref GetStream call.
  ///
  ///
  /// --------------------------------------------------------------------------
  ///
  /// **Example:**
  ///
  /// ~~~~~~~~~~~~~{.cpp}
  ///
  /// bool CMyInputstream::GetStreamIds(std::vector<unsigned int>& ids)
  /// {
  ///   kodi::Log(ADDON_LOG_DEBUG, "GetStreamIds(...)");
  ///
  ///   if (m_opened)
  ///   {
  ///     // This check not needed to have, the ABI checks also about, but make
  ///     // sure you not give more as 32 streams.
  ///     if (m_myStreams.size() > MAX_STREAM_COUNT)
  ///     {
  ///       kodi::Log(ADDON_LOG_ERROR, "Too many streams, only %u supported", MAX_STREAM_COUNT);
  ///       return false;
  ///     }
  ///
  ///     ids.emplace_back(m_myAudioStreamId);
  ///
  ///     for (const auto& streamPair : m_myOtherStreams)
  ///     {
  ///       ids.emplace_back(streamPair.second->uniqueId);
  ///     }
  ///   }
  ///
  ///   return !ids.empty();
  /// }
  /// ~~~~~~~~~~~~~
  ///
  virtual bool GetStreamIds(std::vector<unsigned int>& ids) { return false; }
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief Function for giving detailed stream information
  ///
  /// The associated information is set here for IDs previously given with
  /// @ref GetStreamIds.
  ///
  /// This data is required to identify the associated codec and, if necessary,
  /// to refer to your own codec (if available in the addon).
  ///
  /// @param[in] streamid unique id of stream
  /// @param[out] stream Information data of wanted stream
  /// @return true if successfully done, otherwise false
  ///
  /// @remarks Available stream id's previously asked by @ref GetStreamIds
  ///
  ///
  /// --------------------------------------------------------------------------
  ///
  /// @copydetails cpp_kodi_addon_inputstream_Defs_Interface_InputstreamInfo_Help
  ///
  /// --------------------------------------------------------------------------
  ///
  /// **Example:**
  ///
  /// ~~~~~~~~~~~~~{.cpp}
  /// bool CMyInputstream::GetStream(int streamid, kodi::addon::InputstreamInfo& stream)
  /// {
  ///   // This is just a small example, this type will be significantly larger
  ///   // for larger and more complex streams.
  ///   if (streamid == m_myAudioStreamId)
  ///   {
  ///     // This only a minimal exampl
  ///     stream.SetStreamType(INPUTSTREAM_TYPE_AUDIO);
  ///     stream.SetFeatures(INPUTSTREAM_FEATURE_NONE); // Only added to example, INPUTSTREAM_FEATURE_NONE is default and no need to call
  ///     stream.SetFlags(INPUTSTREAM_FLAG_NONE); // Only added to example, INPUTSTREAM_FLAG_NONE is default and no need to call
  ///     stream.SetCodecName("mp2"); // Codec name, string must by equal with FFmpeg, see https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/codec_desc.c
  ///     stream.SetPhysicalIndex(1); // Identifier required to set
  ///     stream.SetLanguage("en");
  ///     stream.SetChannels(2);
  ///     stream.SetSampleRate(48000);
  ///     stream.SetBitRate(0);
  ///     stream.SetBitsPerSample(16);
  ///   }
  ///   else ...
  ///   ...
  ///   return true;
  /// }
  /// ~~~~~~~~~~~~~
  ///
  virtual bool GetStream(int streamid, kodi::addon::InputstreamInfo& stream) { return false; }
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief Enable or disable a stream.
  ///
  /// A disabled stream does not send demux packets
  ///
  /// @param[in] streamid unique id of stream
  /// @param[in] enable true for enable, false for disable
  ///
  /// @remarks Available stream id's previously asked by @ref GetStreamIds
  ///
  ///
  /// --------------------------------------------------------------------------
  /// @note Valid implementation required.
  ///
  virtual void EnableStream(int streamid, bool enable) {}
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief Opens a stream for playback.
  ///
  /// @param[in] streamid unique id of stream
  ///
  /// @remarks Available stream id's previously asked by @ref GetStreamIds
  ///
  ///
  /// --------------------------------------------------------------------------
  /// @note Valid implementation required.
  ///
  virtual bool OpenStream(int streamid) { return false; }
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief Reset the demultiplexer in the add-on.
  ///
  /// @remarks Optional, and only used if addon has its own demuxer.
  ///
  virtual void DemuxReset() {}
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief Abort the demultiplexer thread in the add-on.
  ///
  /// @remarks Optional, and only used if addon has its own demuxer.
  ///
  virtual void DemuxAbort() {}
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief Flush all data that's currently in the demultiplexer buffer in the add-on.
  ///
  /// @remarks Optional, and only used if addon has its own demuxer.
  ///
  virtual void DemuxFlush() {}
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief Read the next packet from the demultiplexer, if there is one.
  ///
  /// @return The next packet.
  ///         If there is no next packet, then the add-on should return the
  ///         packet created by calling @ref AllocateDemuxPacket "AllocateDemuxPacket(0)" on the callback.
  ///         If the stream changed and Kodi's player needs to be reinitialised,
  ///         then, the add-on should call @ref AllocateDemuxPacket "AllocateDemuxPacket(0)" on the
  ///         callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and
  ///         return the value.
  ///         The add-on should return <b>`nullptr`</b> if an error occured.
  ///
  /// @remarks Return <b>`nullptr`</b> if this add-on won't provide this function.
  ///
  virtual DEMUX_PACKET* DemuxRead() { return nullptr; }
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief Notify the InputStream addon/demuxer that Kodi wishes to seek the stream by time
  ///
  /// Demuxer is required to set stream to an IDR frame
  ///
  /// @param[in] time The absolute time since stream start
  /// @param[in] backwards True to seek to keyframe BEFORE time, else AFTER
  /// @param[in] startpts can be updated to point to where display should start
  /// @return True if the seek operation was possible
  ///
  /// @remarks Optional, and only used if addon has its own demuxer.
  ///
  virtual bool DemuxSeekTime(double time, bool backwards, double& startpts) { return false; }
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief Notify the InputStream addon/demuxer that Kodi wishes to change playback speed
  ///
  /// @param[in] speed The requested playback speed
  ///
  /// @remarks Optional, and only used if addon has its own demuxer.
  ///
  virtual void DemuxSetSpeed(int speed) {}
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief Sets desired width / height
  ///
  /// @param[in] width Width to set
  /// @param[in] height Height to set
  ///
  virtual void SetVideoResolution(int width, int height) {}
  //----------------------------------------------------------------------------

  //=============================================================================
  /// @brief Allocate a demux packet. Free with @ref FreeDemuxPacket
  ///
  /// @param[in] dataSize The size of the data that will go into the packet
  /// @return The allocated packet
  ///
  /// @remarks Only called from addon itself
  ///
  DEMUX_PACKET* AllocateDemuxPacket(int dataSize)
  {
    return m_instanceData->toKodi->allocate_demux_packet(m_instanceData->toKodi->kodiInstance,
                                                         dataSize);
  }
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief Allocate a encrypted demux packet. Free with @ref FreeDemuxPacket
  ///
  /// @param[in] dataSize The size of the data that will go into the packet
  /// @param[in] encryptedSubsampleCount The encrypted subsample count
  /// @return The allocated packet
  ///
  /// @remarks Only called from addon itself
  ///
  DEMUX_PACKET* AllocateEncryptedDemuxPacket(int dataSize, unsigned int encryptedSubsampleCount)
  {
    return m_instanceData->toKodi->allocate_encrypted_demux_packet(
        m_instanceData->toKodi->kodiInstance, dataSize, encryptedSubsampleCount);
  }
  //----------------------------------------------------------------------------

  //============================================================================
  /// @brief Free a packet that was allocated with AllocateDemuxPacket
  ///
  /// @param[in] packet The packet to free
  ///
  /// @remarks Only called from addon itself
  ///
  void FreeDemuxPacket(DEMUX_PACKET* packet)
  {
    return m_instanceData->toKodi->free_demux_packet(m_instanceData->toKodi->kodiInstance, packet);
  }
  //----------------------------------------------------------------------------

  ///@}

  //############################################################################
  /// @defgroup cpp_kodi_addon_inputstream_Time 3. Time (optional)
  /// @brief **To get stream position time.**
  ///
  /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_IDISPLAYTIME is set in the capabilities (see @ref GetCapabilities()).
  ///
  /// @ingroup cpp_kodi_addon_inputstream
  ///@{

  //==========================================================================
  /// @brief Totel time in ms
  ///
  /// @return Total time in milliseconds
  ///
  /// @remarks
  ///
  virtual int GetTotalTime() { return -1; }
  //--------------------------------------------------------------------------

  //==========================================================================
  /// @brief Playing time in ms
  ///
  /// @return Playing time in milliseconds
  ///
  /// @remarks
  ///
  virtual int GetTime() { return -1; }
  //--------------------------------------------------------------------------

  ///@}

  //############################################################################
  /// @defgroup cpp_kodi_addon_inputstream_Times 4. Times (optional)
  /// @brief **Another way to get stream position time.**
  ///
  /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_ITIME is set in the capabilities (see @ref GetCapabilities()).
  ///
  /// @ingroup cpp_kodi_addon_inputstream
  ///@{

  //============================================================================
  /// @brief Get current timing values in PTS scale
  ///
  /// @param[out] times The with @ref InputstreamTimes to given times
  /// @return true if successfully done, false if not
  ///
  /// @copydetails cpp_kodi_addon_inputstream_Defs_Times_Help
  ///
  /// @remarks
  ///
  virtual bool GetTimes(InputstreamTimes& times) { return false; }
  //----------------------------------------------------------------------------

  ///@}

  //############################################################################
  /// @defgroup cpp_kodi_addon_inputstream_PosTime 5. Position time (optional)
  /// @brief **Third way get stream position time.**
  ///
  /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_IPOSTIME is set in the capabilities (see @ref GetCapabilities()).
  ///
  /// @ingroup cpp_kodi_addon_inputstream
  ///@{

  //============================================================================
  /// @brief Positions inputstream to playing time given in ms
  ///
  /// @param[in] ms Position time in milliseconds
  ///
  /// @remarks
  ///
  virtual bool PosTime(int ms) { return false; }
  //----------------------------------------------------------------------------

  ///@}

  //############################################################################
  /// @defgroup cpp_kodi_addon_inputstream_Chapter 6. Chapter (optional)
  /// @brief **Used to get available chapters.**
  ///
  /// @note These are used and must be set by the addon if the @ref INPUTSTREAM_SUPPORTS_ICHAPTER is set in the capabilities (see @ref GetCapabilities()).
  ///
  /// @ingroup cpp_kodi_addon_inputstream
  ///@{

  //==========================================================================
  ///
  /// @brief Return currently selected chapter
  ///
  /// @return Chapter number
  ///
  /// @remarks
  ///
  virtual int GetChapter() { return -1; };
  //--------------------------------------------------------------------------

  //==========================================================================
  ///
  /// @brief Return number of available chapters
  ///
  /// @return Chapter count
  ///
  /// @remarks
  ///
  virtual int GetChapterCount() { return 0; };
  //--------------------------------------------------------------------------

  //==========================================================================
  ///
  /// @brief Return name of chapter
  ///
  /// @param[in] ch Chapter identifier
  /// @return Chapter name
  ///
  /// @remarks
  ///
  virtual const char* GetChapterName(int ch) { return nullptr; };
  //--------------------------------------------------------------------------

  //==========================================================================
  ///
  /// @brief Return position if chapter # ch in milliseconds
  ///
  /// @param[in] ch Chapter to get position from
  /// @return Position in milliseconds
  ///
  /// @remarks
  ///
  virtual int64_t GetChapterPos(int ch) { return 0; };
  //--------------------------------------------------------------------------

  //==========================================================================
  ///
  /// @brief Seek to the beginning of chapter # ch
  ///
  /// @param[in] ch Chapter to seek
  /// @return True if successfully done, false if not
  ///
  /// @remarks
  ///
  virtual bool SeekChapter(int ch) { return false; };
  //--------------------------------------------------------------------------

  ///@}

private:
  static int compareVersion(const int v1[3], const int v2[3])
  {
    for (unsigned i(0); i < 3; ++i)
      if (v1[i] != v2[i])
        return v1[i] - v2[i];
    return 0;
  }

  void SetAddonStruct(KODI_HANDLE instance, const std::string& kodiVersion)
  {
    if (instance == nullptr)
      throw std::logic_error("kodi::addon::CInstanceInputStream: Creation with empty addon "
                             "structure not allowed, table must be given from Kodi!");
    int api[3] = { 0, 0, 0 };
    sscanf(kodiVersion.c_str(), "%d.%d.%d", &api[0], &api[1], &api[2]);

    m_instanceData = static_cast<AddonInstance_InputStream*>(instance);
    m_instanceData->toAddon->addonInstance = this;
    m_instanceData->toAddon->open = ADDON_Open;
    m_instanceData->toAddon->close = ADDON_Close;
    m_instanceData->toAddon->get_capabilities = ADDON_GetCapabilities;

    m_instanceData->toAddon->get_stream_ids = ADDON_GetStreamIds;
    m_instanceData->toAddon->get_stream = ADDON_GetStream;
    m_instanceData->toAddon->enable_stream = ADDON_EnableStream;
    m_instanceData->toAddon->open_stream = ADDON_OpenStream;
    m_instanceData->toAddon->demux_reset = ADDON_DemuxReset;
    m_instanceData->toAddon->demux_abort = ADDON_DemuxAbort;
    m_instanceData->toAddon->demux_flush = ADDON_DemuxFlush;
    m_instanceData->toAddon->demux_read = ADDON_DemuxRead;
    m_instanceData->toAddon->demux_seek_time = ADDON_DemuxSeekTime;
    m_instanceData->toAddon->demux_set_speed = ADDON_DemuxSetSpeed;
    m_instanceData->toAddon->set_video_resolution = ADDON_SetVideoResolution;

    m_instanceData->toAddon->get_total_time = ADDON_GetTotalTime;
    m_instanceData->toAddon->get_time = ADDON_GetTime;

    m_instanceData->toAddon->get_times = ADDON_GetTimes;
    m_instanceData->toAddon->pos_time = ADDON_PosTime;

    m_instanceData->toAddon->read_stream = ADDON_ReadStream;
    m_instanceData->toAddon->seek_stream = ADDON_SeekStream;
    m_instanceData->toAddon->position_stream = ADDON_PositionStream;
    m_instanceData->toAddon->length_stream = ADDON_LengthStream;
    m_instanceData->toAddon->is_real_time_stream = ADDON_IsRealTimeStream;

    // Added on 2.0.10
    m_instanceData->toAddon->get_chapter = ADDON_GetChapter;
    m_instanceData->toAddon->get_chapter_count = ADDON_GetChapterCount;
    m_instanceData->toAddon->get_chapter_name = ADDON_GetChapterName;
    m_instanceData->toAddon->get_chapter_pos = ADDON_GetChapterPos;
    m_instanceData->toAddon->seek_chapter = ADDON_SeekChapter;

    // Added on 2.0.12
    m_instanceData->toAddon->block_size_stream = ADDON_GetBlockSize;

    /*
    // Way to include part on new API version
    int minPartVersion[3] = { 3, 0, 0 };
    if (compareVersion(api, minPartVersion) >= 0)
    {

    }
    */
  }

  inline static bool ADDON_Open(const AddonInstance_InputStream* instance,
                                INPUTSTREAM_PROPERTY* props)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->Open(props);
  }

  inline static void ADDON_Close(const AddonInstance_InputStream* instance)
  {
    static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->Close();
  }

  inline static void ADDON_GetCapabilities(const AddonInstance_InputStream* instance,
                                           INPUTSTREAM_CAPABILITIES* capabilities)
  {
    InputstreamCapabilities caps(capabilities);
    static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetCapabilities(caps);
  }


  // IDemux
  inline static bool ADDON_GetStreamIds(const AddonInstance_InputStream* instance,
                                        struct INPUTSTREAM_IDS* ids)
  {
    std::vector<unsigned int> idList;
    bool ret =
        static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetStreamIds(idList);
    if (ret)
    {
      for (size_t i = 0; i < idList.size() && i < INPUTSTREAM_MAX_STREAM_COUNT; ++i)
      {
        ids->m_streamCount++;
        ids->m_streamIds[i] = idList[i];
      }
    }
    return ret;
  }

  inline static bool ADDON_GetStream(
      const AddonInstance_InputStream* instance,
      int streamid,
      struct INPUTSTREAM_INFO* info,
      KODI_HANDLE* demuxStream,
      KODI_HANDLE (*transfer_stream)(KODI_HANDLE handle,
                                     int streamId,
                                     struct INPUTSTREAM_INFO* stream))
  {
    InputstreamInfo infoData(info);
    bool ret = static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
                   ->GetStream(streamid, infoData);
    if (ret && transfer_stream)
    {
      // Do this with given callback to prevent memory problems and leaks. This
      // then create on Kodi the needed class where then given back on demuxStream.
      *demuxStream = transfer_stream(instance->toKodi->kodiInstance, streamid, info);
    }
    return ret;
  }

  inline static void ADDON_EnableStream(const AddonInstance_InputStream* instance,
                                        int streamid,
                                        bool enable)
  {
    static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
        ->EnableStream(streamid, enable);
  }

  inline static bool ADDON_OpenStream(const AddonInstance_InputStream* instance, int streamid)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
        ->OpenStream(streamid);
  }

  inline static void ADDON_DemuxReset(const AddonInstance_InputStream* instance)
  {
    static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxReset();
  }

  inline static void ADDON_DemuxAbort(const AddonInstance_InputStream* instance)
  {
    static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxAbort();
  }

  inline static void ADDON_DemuxFlush(const AddonInstance_InputStream* instance)
  {
    static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxFlush();
  }

  inline static DEMUX_PACKET* ADDON_DemuxRead(const AddonInstance_InputStream* instance)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxRead();
  }

  inline static bool ADDON_DemuxSeekTime(const AddonInstance_InputStream* instance,
                                         double time,
                                         bool backwards,
                                         double* startpts)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
        ->DemuxSeekTime(time, backwards, *startpts);
  }

  inline static void ADDON_DemuxSetSpeed(const AddonInstance_InputStream* instance, int speed)
  {
    static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->DemuxSetSpeed(speed);
  }

  inline static void ADDON_SetVideoResolution(const AddonInstance_InputStream* instance,
                                              int width,
                                              int height)
  {
    static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
        ->SetVideoResolution(width, height);
  }


  // IDisplayTime
  inline static int ADDON_GetTotalTime(const AddonInstance_InputStream* instance)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetTotalTime();
  }

  inline static int ADDON_GetTime(const AddonInstance_InputStream* instance)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetTime();
  }

  // ITime
  inline static bool ADDON_GetTimes(const AddonInstance_InputStream* instance,
                                    INPUTSTREAM_TIMES* times)
  {
    InputstreamTimes cppTimes(times);
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetTimes(cppTimes);
  }

  // IPosTime
  inline static bool ADDON_PosTime(const AddonInstance_InputStream* instance, int ms)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->PosTime(ms);
  }

  inline static int ADDON_GetChapter(const AddonInstance_InputStream* instance)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetChapter();
  }

  inline static int ADDON_GetChapterCount(const AddonInstance_InputStream* instance)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetChapterCount();
  }

  inline static const char* ADDON_GetChapterName(const AddonInstance_InputStream* instance, int ch)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetChapterName(ch);
  }

  inline static int64_t ADDON_GetChapterPos(const AddonInstance_InputStream* instance, int ch)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetChapterPos(ch);
  }

  inline static bool ADDON_SeekChapter(const AddonInstance_InputStream* instance, int ch)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->SeekChapter(ch);
  }

  inline static int ADDON_ReadStream(const AddonInstance_InputStream* instance,
                                     uint8_t* buffer,
                                     unsigned int bufferSize)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
        ->ReadStream(buffer, bufferSize);
  }

  inline static int64_t ADDON_SeekStream(const AddonInstance_InputStream* instance,
                                         int64_t position,
                                         int whence)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)
        ->SeekStream(position, whence);
  }

  inline static int64_t ADDON_PositionStream(const AddonInstance_InputStream* instance)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->PositionStream();
  }

  inline static int64_t ADDON_LengthStream(const AddonInstance_InputStream* instance)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->LengthStream();
  }

  inline static int ADDON_GetBlockSize(const AddonInstance_InputStream* instance)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->GetBlockSize();
  }

  inline static bool ADDON_IsRealTimeStream(const AddonInstance_InputStream* instance)
  {
    return static_cast<CInstanceInputStream*>(instance->toAddon->addonInstance)->IsRealTimeStream();
  }

  AddonInstance_InputStream* m_instanceData;
};
//------------------------------------------------------------------------------

} /* namespace addon */
} /* namespace kodi */

#endif /* __cplusplus */