kodi
inputstream.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #ifndef C_API_ADDONINSTANCE_INPUTSTREAM_H
10 #define C_API_ADDONINSTANCE_INPUTSTREAM_H
11 
12 #include "../addon_base.h"
13 #include "inputstream/demux_packet.h"
14 #include "inputstream/stream_codec.h"
15 #include "inputstream/stream_constants.h"
16 #include "inputstream/stream_crypto.h"
17 #include "inputstream/timing_constants.h"
18 
19 #include <time.h>
20 
21 // Increment this level always if you add features which can lead to compile failures in the addon
22 #define INPUTSTREAM_VERSION_LEVEL 4
23 
24 #define INPUTSTREAM_MAX_INFO_COUNT 8
25 #define INPUTSTREAM_MAX_STREAM_COUNT 256
26 #define INPUTSTREAM_MAX_STRING_NAME_SIZE 256
27 #define INPUTSTREAM_MAX_STRING_CODEC_SIZE 32
28 #define INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE 64
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif /* __cplusplus */
34 
35  //==============================================================================
47  enum INPUTSTREAM_MASKTYPE
48  {
52  INPUTSTREAM_SUPPORTS_IDEMUX = (1 << 0),
53 
59  INPUTSTREAM_SUPPORTS_IPOSTIME = (1 << 1),
60 
67  INPUTSTREAM_SUPPORTS_IDISPLAYTIME = (1 << 2),
68 
70  INPUTSTREAM_SUPPORTS_SEEK = (1 << 3),
71 
73  INPUTSTREAM_SUPPORTS_PAUSE = (1 << 4),
74 
81  INPUTSTREAM_SUPPORTS_ITIME = (1 << 5),
82 
86  INPUTSTREAM_SUPPORTS_ICHAPTER = (1 << 6),
87  };
89  //----------------------------------------------------------------------------
90 
95  {
97  uint32_t m_mask;
98  };
99 
104  {
105  const char* m_strURL;
106  const char* m_mimeType;
107 
108  unsigned int m_nCountInfoValues;
110  {
111  const char* m_strKey;
112  const char* m_strValue;
113  } m_ListItemProperties[STREAM_MAX_PROPERTY_COUNT];
114 
115  const char* m_libFolder;
116  const char* m_profileFolder;
117  };
118 
123  {
124  unsigned int m_streamCount;
125  unsigned int m_streamIds[INPUTSTREAM_MAX_STREAM_COUNT];
126  };
127 
132  {
133  double primary_r_chromaticity_x;
134  double primary_r_chromaticity_y;
135  double primary_g_chromaticity_x;
136  double primary_g_chromaticity_y;
137  double primary_b_chromaticity_x;
138  double primary_b_chromaticity_y;
139  double white_point_chromaticity_x;
140  double white_point_chromaticity_y;
141  double luminance_max;
142  double luminance_min;
143  };
144 
149  {
150  uint64_t max_cll;
151  uint64_t max_fall;
152  };
153 
154  //==============================================================================
164  {
167 
170 
173 
176 
179 
182 
185  };
187  //------------------------------------------------------------------------------
188 
189  //==============================================================================
201  {
204 
207  };
209  //----------------------------------------------------------------------------
210 
211  //============================================================================
223  {
226 
229 
232 
235 
238 
241 
244 
247 
250 
253  };
255  //----------------------------------------------------------------------------
256 
257  // Keep in sync with AVColorSpace
258  //============================================================================
268  {
271 
274 
277 
281 
284 
287 
290 
293 
296 
299 
303 
306 
309 
312 
315 
318 
321 
324  };
326  //------------------------------------------------------------------------------
327 
328  // Keep in sync with AVColorPrimaries
329  //==============================================================================
339  {
342 
345 
348 
351 
354 
357 
360 
363 
366 
369 
372 
376 
379 
382 
385 
388  };
390  //------------------------------------------------------------------------------
391 
392  // Keep in sync with AVColorRange
393  //==============================================================================
403  {
406 
409 
412 
415  };
417  //------------------------------------------------------------------------------
418 
419  // keep in sync with AVColorTransferCharacteristic
420  //==============================================================================
430  {
433 
436 
439 
442 
445 
448 
451 
454 
457 
460 
463 
466 
469 
472 
475 
478 
481 
484 
487 
490 
493 
496  };
498  //------------------------------------------------------------------------------
499 
504  {
505  enum INPUTSTREAM_TYPE m_streamType;
506  uint32_t m_features;
507  uint32_t m_flags;
508 
510  char m_name[INPUTSTREAM_MAX_STRING_NAME_SIZE];
511 
513  char m_codecName[INPUTSTREAM_MAX_STRING_CODEC_SIZE];
514 
516  char m_codecInternalName[INPUTSTREAM_MAX_STRING_CODEC_SIZE];
517 
519  enum STREAMCODEC_PROFILE m_codecProfile;
520 
522  unsigned int m_pID;
523 
524  const uint8_t* m_ExtraData;
525  unsigned int m_ExtraSize;
526 
528  char m_language[INPUTSTREAM_MAX_STRING_LANGUAGE_SIZE];
529 
531 
532 
534  unsigned int m_FpsScale;
535 
536  unsigned int m_FpsRate;
537 
539  unsigned int m_Height;
540 
542  unsigned int m_Width;
543 
545  float m_Aspect;
546 
548 
550 
551 
553  unsigned int m_Channels;
554 
556  unsigned int m_SampleRate;
557 
559  unsigned int m_BitRate;
560 
562  unsigned int m_BitsPerSample;
563 
564  unsigned int m_BlockAlign;
565 
567 
568  struct STREAM_CRYPTO_SESSION m_cryptoSession;
569 
570  // new in API version 2.0.8
572  unsigned int m_codecFourCC;
574 
576  enum INPUTSTREAM_COLORSPACE m_colorSpace;
577 
579  enum INPUTSTREAM_COLORRANGE m_colorRange;
581 
582  //new in API 2.0.9 / INPUTSTREAM_VERSION_LEVEL 1
584  enum INPUTSTREAM_COLORPRIMARIES m_colorPrimaries;
585  enum INPUTSTREAM_COLORTRC m_colorTransferCharacteristic;
587 
590 
593  };
594 
596  {
597  time_t startTime;
598  double ptsStart;
599  double ptsBegin;
600  double ptsEnd;
601  };
602 
607  // this are properties given to the addon on create
608  // at this time we have no parameters for the addon
609  typedef struct AddonProps_InputStream /* internal */
610  {
611  int dummy;
613 
614  typedef struct AddonToKodiFuncTable_InputStream /* internal */
615  {
616  KODI_HANDLE kodiInstance;
617  struct DEMUX_PACKET* (*allocate_demux_packet)(void* kodiInstance, int data_size);
618  struct DEMUX_PACKET* (*allocate_encrypted_demux_packet)(void* kodiInstance,
619  unsigned int data_size,
620  unsigned int encrypted_subsample_count);
621  void (*free_demux_packet)(void* kodiInstance, struct DEMUX_PACKET* packet);
623 
625  typedef struct KodiToAddonFuncTable_InputStream /* internal */
626  {
627  KODI_HANDLE addonInstance;
628 
629  bool(__cdecl* open)(const struct AddonInstance_InputStream* instance,
630  struct INPUTSTREAM_PROPERTY* props);
631  void(__cdecl* close)(const struct AddonInstance_InputStream* instance);
632  const char*(__cdecl* get_path_list)(const struct AddonInstance_InputStream* instance);
633  void(__cdecl* get_capabilities)(const struct AddonInstance_InputStream* instance,
634  struct INPUTSTREAM_CAPABILITIES* capabilities);
635 
636  // IDemux
637  bool(__cdecl* get_stream_ids)(const struct AddonInstance_InputStream* instance,
638  struct INPUTSTREAM_IDS* ids);
639  bool(__cdecl* get_stream)(const struct AddonInstance_InputStream* instance,
640  int streamid,
641  struct INPUTSTREAM_INFO* info,
642  KODI_HANDLE* demuxStream,
643  KODI_HANDLE (*transfer_stream)(KODI_HANDLE handle,
644  int streamId,
645  struct INPUTSTREAM_INFO* stream));
646  void(__cdecl* enable_stream)(const struct AddonInstance_InputStream* instance,
647  int streamid,
648  bool enable);
649  bool(__cdecl* open_stream)(const struct AddonInstance_InputStream* instance, int streamid);
650  void(__cdecl* demux_reset)(const struct AddonInstance_InputStream* instance);
651  void(__cdecl* demux_abort)(const struct AddonInstance_InputStream* instance);
652  void(__cdecl* demux_flush)(const struct AddonInstance_InputStream* instance);
653  struct DEMUX_PACKET*(__cdecl* demux_read)(const struct AddonInstance_InputStream* instance);
654  bool(__cdecl* demux_seek_time)(const struct AddonInstance_InputStream* instance,
655  double time,
656  bool backwards,
657  double* startpts);
658  void(__cdecl* demux_set_speed)(const struct AddonInstance_InputStream* instance, int speed);
659  void(__cdecl* set_video_resolution)(const struct AddonInstance_InputStream* instance,
660  unsigned int width,
661  unsigned int height,
662  unsigned int maxWidth,
663  unsigned int maxHeight);
664 
665  // IDisplayTime
666  int(__cdecl* get_total_time)(const struct AddonInstance_InputStream* instance);
667  int(__cdecl* get_time)(const struct AddonInstance_InputStream* instance);
668 
669  // ITime
670  bool(__cdecl* get_times)(const struct AddonInstance_InputStream* instance,
671  struct INPUTSTREAM_TIMES* times);
672 
673  // IPosTime
674  bool(__cdecl* pos_time)(const struct AddonInstance_InputStream* instance, int ms);
675 
676  int(__cdecl* read_stream)(const struct AddonInstance_InputStream* instance,
677  uint8_t* buffer,
678  unsigned int bufferSize);
679  int64_t(__cdecl* seek_stream)(const struct AddonInstance_InputStream* instance,
680  int64_t position,
681  int whence);
682  int64_t(__cdecl* position_stream)(const struct AddonInstance_InputStream* instance);
683  int64_t(__cdecl* length_stream)(const struct AddonInstance_InputStream* instance);
684  bool(__cdecl* is_real_time_stream)(const struct AddonInstance_InputStream* instance);
685 
686  // IChapter
687  int(__cdecl* get_chapter)(const struct AddonInstance_InputStream* instance);
688  int(__cdecl* get_chapter_count)(const struct AddonInstance_InputStream* instance);
689  const char*(__cdecl* get_chapter_name)(const struct AddonInstance_InputStream* instance,
690  int ch);
691  int64_t(__cdecl* get_chapter_pos)(const struct AddonInstance_InputStream* instance, int ch);
692  bool(__cdecl* seek_chapter)(const struct AddonInstance_InputStream* instance, int ch);
693 
694  int(__cdecl* block_size_stream)(const struct AddonInstance_InputStream* instance);
696 
697  typedef struct AddonInstance_InputStream /* internal */
698  {
699  struct AddonProps_InputStream* props;
700  struct AddonToKodiFuncTable_InputStream* toKodi;
701  struct KodiToAddonFuncTable_InputStream* toAddon;
703 
704 #ifdef __cplusplus
705 } /* extern "C" */
706 #endif /* __cplusplus */
707 
708 #endif /* !C_API_ADDONINSTANCE_INPUTSTREAM_H */
The maximum value to use in a list.
Definition: inputstream.h:323
The maximum value to use in a list.
Definition: inputstream.h:387
0000 0000 1000 0000 : Hearing impaired
Definition: inputstream.h:249
6 : To identify cpp_kodi_addon_inputstream_Defs_Info as Audio ID3 tags
Definition: inputstream.h:184
Definition: inputstream.h:697
3 : To set colorspace reserved
Definition: inputstream.h:283
2 : To set stream is unspecified
Definition: inputstream.h:276
0000 0000 0100 0000 : Forced
Definition: inputstream.h:246
1 : To identify cpp_kodi_addon_inputstream_Defs_Info as Video
Definition: inputstream.h:169
12 : Chromaticity-derived non-constant luminance system
Definition: inputstream.h:314
4 : To identify cpp_kodi_addon_inputstream_Defs_Info as Teletext
Definition: inputstream.h:178
17 : Same as INPUTSTREAM_COLORTRC_SMPTE428
Definition: inputstream.h:489
0 : Order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
Definition: inputstream.h:270
Array of stream IDs.
Definition: inputstream.h:122
INPUTSTREAM_COLORSPACE
Definition: inputstream.h:267
unsigned int m_Channels
Audio stream related data.
Definition: inputstream.h:553
16 : SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems
Definition: inputstream.h:480
0000 0001 0000 0000 : Visual impaired
Definition: inputstream.h:252
unsigned int m_Width
width of the stream reported by the demuxer
Definition: inputstream.h:542
7 : Functionally identical to above
Definition: inputstream.h:362
The maximum value to use in a list.
Definition: inputstream.h:495
10 : SMPTE ST 428-1 (CIE 1931 XYZ)
Definition: inputstream.h:371
The maximum value to use in a list.
Definition: inputstream.h:414
unsigned int m_BitRate
(required) bit rate
Definition: inputstream.h:559
13 : Chromaticity-derived constant luminance system
Definition: inputstream.h:317
16 : Same as INPUTSTREAM_COLORTRC_SMPTE2084
Definition: inputstream.h:483
4 : FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: inputstream.h:286
2 : Unspecified
Definition: inputstream.h:438
11 : SMPTE 2085, Y&#39;D&#39;zD&#39;x
Definition: inputstream.h:311
8 : Colour filters using Illuminant C
Definition: inputstream.h:365
CONTENTLIGHT Metadata.
Definition: inputstream.h:148
1 : Also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
Definition: inputstream.h:344
0000 0000 0000 0000 : Empty to set if nothing is used
Definition: inputstream.h:225
10 : ITU-R BT2020 constant luminance system
Definition: inputstream.h:308
1 : Also ITU-R BT1361
Definition: inputstream.h:435
12 : SMPTE ST 432-1 (2010) / P3 D65 / Display P3
Definition: inputstream.h:381
Definition: stream_crypto.h:120
11 : SMPTE ST 431-2 (2011) / DCI P3
Definition: inputstream.h:378
8 : To set colorspace as YCOCG
Definition: inputstream.h:302
2 : To identify cpp_kodi_addon_inputstream_Defs_Info as Audio
Definition: inputstream.h:172
8 : Linear transfer characteristics
Definition: inputstream.h:456
MASTERING Metadata.
Definition: inputstream.h:131
Definition: inputstream.h:595
0000 0000 0000 1000 : Comment
Definition: inputstream.h:237
0 : To set nothing defined
Definition: inputstream.h:166
10 :
Definition: inputstream.h:375
unsigned int m_FpsScale
Video stream related data.
Definition: inputstream.h:534
INPUTSTREAM_CODEC_FEATURES
Definition: inputstream.h:200
7 : Functionally identical to above INPUTSTREAM_COLORSPACE_SMPTE170M
Definition: inputstream.h:295
0000 0000 0000 0001 : To set addon decode should used with Video Codec.
Definition: inputstream.h:206
6 : Also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
Definition: inputstream.h:450
0000 0000 0000 0001 : Default
Definition: inputstream.h:228
7 : Functionally identical to above INPUTSTREAM_COLORTRC_SMPTE170M
Definition: inputstream.h:453
uint32_t m_mask
set of supported capabilities
Definition: inputstream.h:97
17 : SMPTE ST 428-1
Definition: inputstream.h:486
unsigned int m_Height
height of the stream reported by the demuxer
Definition: inputstream.h:539
Definition: addon_base.h:267
INPUTSTREAM_TYPE
Definition: inputstream.h:163
0000 0000 0000 0010 : Dub
Definition: inputstream.h:231
5 : Also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601...
Definition: inputstream.h:289
6 : Also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: inputstream.h:359
InputStream add-on capabilities. All capabilities are set to "false" as default.
Definition: inputstream.h:94
Definition: inputstream.h:109
0 : To define as unknown
Definition: inputstream.h:405
INPUTSTREAM_COLORTRC
Definition: inputstream.h:429
9 : ITU-R BT2020 non-constant luminance system
Definition: inputstream.h:305
0000 0000 0000 0100 : Original
Definition: inputstream.h:234
9 : Logarithmic transfer characteristic (100:1 range)
Definition: inputstream.h:459
0000 0000 0010 0000 : Karaoke
Definition: inputstream.h:243
INPUTSTREAM_FLAGS
Definition: inputstream.h:222
3 : Reserved
Definition: inputstream.h:441
5 : To identify cpp_kodi_addon_inputstream_Defs_Info as Radio RDS
Definition: inputstream.h:181
2 : The normal 2^n-1 "JPEG" YUV ranges
Definition: inputstream.h:411
0 : Reserved
Definition: inputstream.h:341
15 : ITU-R BT2020 for 12-bit system
Definition: inputstream.h:477
struct INPUTSTREAM_MASTERING_METADATA * m_masteringMetadata
mastering static Metadata
Definition: inputstream.h:589
4 : Also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
Definition: inputstream.h:444
11 : IEC 61966-2-4
Definition: inputstream.h:465
3 : Reserved
Definition: inputstream.h:350
Definition: demux_packet.h:45
5 : Also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
Definition: inputstream.h:356
1 : The normal 219*2^(n-8) "MPEG" YUV ranges
Definition: inputstream.h:408
2 : Unspecified
Definition: inputstream.h:347
unsigned int m_BitsPerSample
(required) bits per sample
Definition: inputstream.h:562
Definition: inputstream.h:614
INPUTSTREAM_COLORPRIMARIES
Definition: inputstream.h:338
structure of key/value pairs passed to addon on Open()
Definition: inputstream.h:103
18 : ARIB STD-B67, known as "Hybrid log-gamma"
Definition: inputstream.h:492
2 : To set stream is unknown
Definition: inputstream.h:280
4 : Also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: inputstream.h:353
unsigned int m_SampleRate
(required) sample rate
Definition: inputstream.h:556
struct INPUTSTREAM_CONTENTLIGHT_METADATA * m_contentLightMetadata
content light static Metadata
Definition: inputstream.h:592
stream properties
Definition: inputstream.h:503
9 : ITU-R BT2020
Definition: inputstream.h:368
13 : IEC 61966-2-1 (sRGB or sYCC)
Definition: inputstream.h:471
1 : Also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
Definition: inputstream.h:273
3 : To identify cpp_kodi_addon_inputstream_Defs_Info as Subtitle
Definition: inputstream.h:175
INPUTSTREAM_COLORRANGE
Definition: inputstream.h:402
0000 0000 0000 0000 : Empty to set if nothing is used
Definition: inputstream.h:203
0 : Reserved
Definition: inputstream.h:432
22 : JEDEC P22 phosphors
Definition: inputstream.h:384
12 : ITU-R BT1361 Extended Colour Gamut
Definition: inputstream.h:468
unsigned int m_pID
(required) physical index
Definition: inputstream.h:522
STREAMCODEC_PROFILE
Definition: stream_codec.h:24
8 : Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
Definition: inputstream.h:298
"C" ABI Structures to transfer the methods from this to Kodi
Definition: inputstream.h:609
5 : Also ITU-R BT470BG
Definition: inputstream.h:447
6 : Also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: inputstream.h:292
0000 0000 0001 0000 : Lyrics
Definition: inputstream.h:240
float m_Aspect
display aspect of stream
Definition: inputstream.h:545
10 : Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)
Definition: inputstream.h:462
Definition: inputstream.h:625
14 : ITU-R BT.2100-0, ICtCp
Definition: inputstream.h:320
14 : ITU-R BT2020 for 10-bit system
Definition: inputstream.h:474