1 /* -LICENSE-START- 2 ** Copyright (c) 2019 Blackmagic Design 3 ** 4 ** Permission is hereby granted, free of charge, to any person or organization 5 ** obtaining a copy of the software and accompanying documentation covered by 6 ** this license (the "Software") to use, reproduce, display, distribute, 7 ** execute, and transmit the Software, and to prepare derivative works of the 8 ** Software, and to permit third-parties to whom the Software is furnished to 9 ** do so, all subject to the following: 10 ** 11 ** The copyright notices in the Software and this entire statement, including 12 ** the above license grant, this restriction and the following disclaimer, 13 ** must be included in all copies of the Software, in whole or in part, and 14 ** all derivative works of the Software, unless such copies or derivative 15 ** works are solely in the form of machine-executable object code generated by 16 ** a source language processor. 17 ** 18 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 ** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 21 ** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 22 ** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 23 ** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 ** DEALINGS IN THE SOFTWARE. 25 ** -LICENSE-END- 26 */ 27 28 #ifndef BMD_DECKLINKAPISTREAMING_H 29 #define BMD_DECKLINKAPISTREAMING_H 30 31 32 #ifndef BMD_CONST 33 #if defined(_MSC_VER) 34 #define BMD_CONST __declspec(selectany) static const 35 #else 36 #define BMD_CONST static const 37 #endif 38 #endif 39 40 #ifndef BMD_PUBLIC 41 #define BMD_PUBLIC 42 #endif 43 44 // Type Declarations 45 46 47 // Interface ID Declarations 48 49 BMD_CONST REFIID IID_IBMDStreamingDeviceNotificationCallback = /* F9531D64-3305-4B29-A387-7F74BB0D0E84 */ {0xF9,0x53,0x1D,0x64,0x33,0x05,0x4B,0x29,0xA3,0x87,0x7F,0x74,0xBB,0x0D,0x0E,0x84}; 50 BMD_CONST REFIID IID_IBMDStreamingH264InputCallback = /* 823C475F-55AE-46F9-890C-537CC5CEDCCA */ {0x82,0x3C,0x47,0x5F,0x55,0xAE,0x46,0xF9,0x89,0x0C,0x53,0x7C,0xC5,0xCE,0xDC,0xCA}; 51 BMD_CONST REFIID IID_IBMDStreamingDiscovery = /* 2C837444-F989-4D87-901A-47C8A36D096D */ {0x2C,0x83,0x74,0x44,0xF9,0x89,0x4D,0x87,0x90,0x1A,0x47,0xC8,0xA3,0x6D,0x09,0x6D}; 52 BMD_CONST REFIID IID_IBMDStreamingVideoEncodingMode = /* 1AB8035B-CD13-458D-B6DF-5E8F7C2141D9 */ {0x1A,0xB8,0x03,0x5B,0xCD,0x13,0x45,0x8D,0xB6,0xDF,0x5E,0x8F,0x7C,0x21,0x41,0xD9}; 53 BMD_CONST REFIID IID_IBMDStreamingMutableVideoEncodingMode = /* 19BF7D90-1E0A-400D-B2C6-FFC4E78AD49D */ {0x19,0xBF,0x7D,0x90,0x1E,0x0A,0x40,0x0D,0xB2,0xC6,0xFF,0xC4,0xE7,0x8A,0xD4,0x9D}; 54 BMD_CONST REFIID IID_IBMDStreamingVideoEncodingModePresetIterator = /* 7AC731A3-C950-4AD0-804A-8377AA51C6C4 */ {0x7A,0xC7,0x31,0xA3,0xC9,0x50,0x4A,0xD0,0x80,0x4A,0x83,0x77,0xAA,0x51,0xC6,0xC4}; 55 BMD_CONST REFIID IID_IBMDStreamingDeviceInput = /* 24B6B6EC-1727-44BB-9818-34FF086ACF98 */ {0x24,0xB6,0xB6,0xEC,0x17,0x27,0x44,0xBB,0x98,0x18,0x34,0xFF,0x08,0x6A,0xCF,0x98}; 56 BMD_CONST REFIID IID_IBMDStreamingH264NALPacket = /* E260E955-14BE-4395-9775-9F02CC0A9D89 */ {0xE2,0x60,0xE9,0x55,0x14,0xBE,0x43,0x95,0x97,0x75,0x9F,0x02,0xCC,0x0A,0x9D,0x89}; 57 BMD_CONST REFIID IID_IBMDStreamingAudioPacket = /* D9EB5902-1AD2-43F4-9E2C-3CFA50B5EE19 */ {0xD9,0xEB,0x59,0x02,0x1A,0xD2,0x43,0xF4,0x9E,0x2C,0x3C,0xFA,0x50,0xB5,0xEE,0x19}; 58 BMD_CONST REFIID IID_IBMDStreamingMPEG2TSPacket = /* 91810D1C-4FB3-4AAA-AE56-FA301D3DFA4C */ {0x91,0x81,0x0D,0x1C,0x4F,0xB3,0x4A,0xAA,0xAE,0x56,0xFA,0x30,0x1D,0x3D,0xFA,0x4C}; 59 BMD_CONST REFIID IID_IBMDStreamingH264NALParser = /* 5867F18C-5BFA-4CCC-B2A7-9DFD140417D2 */ {0x58,0x67,0xF1,0x8C,0x5B,0xFA,0x4C,0xCC,0xB2,0xA7,0x9D,0xFD,0x14,0x04,0x17,0xD2}; 60 61 /* Enum BMDStreamingDeviceMode - Device modes */ 62 63 typedef uint32_t BMDStreamingDeviceMode; 64 enum _BMDStreamingDeviceMode { 65 bmdStreamingDeviceIdle = 'idle', 66 bmdStreamingDeviceEncoding = 'enco', 67 bmdStreamingDeviceStopping = 'stop', 68 bmdStreamingDeviceUnknown = 'munk' 69 }; 70 71 /* Enum BMDStreamingEncodingFrameRate - Encoded frame rates */ 72 73 typedef uint32_t BMDStreamingEncodingFrameRate; 74 enum _BMDStreamingEncodingFrameRate { 75 76 /* Interlaced rates */ 77 78 bmdStreamingEncodedFrameRate50i = 'e50i', 79 bmdStreamingEncodedFrameRate5994i = 'e59i', 80 bmdStreamingEncodedFrameRate60i = 'e60i', 81 82 /* Progressive rates */ 83 84 bmdStreamingEncodedFrameRate2398p = 'e23p', 85 bmdStreamingEncodedFrameRate24p = 'e24p', 86 bmdStreamingEncodedFrameRate25p = 'e25p', 87 bmdStreamingEncodedFrameRate2997p = 'e29p', 88 bmdStreamingEncodedFrameRate30p = 'e30p', 89 bmdStreamingEncodedFrameRate50p = 'e50p', 90 bmdStreamingEncodedFrameRate5994p = 'e59p', 91 bmdStreamingEncodedFrameRate60p = 'e60p' 92 }; 93 94 /* Enum BMDStreamingEncodingSupport - Output encoding mode supported flag */ 95 96 typedef uint32_t BMDStreamingEncodingSupport; 97 enum _BMDStreamingEncodingSupport { 98 bmdStreamingEncodingModeNotSupported = 0, 99 bmdStreamingEncodingModeSupported, 100 bmdStreamingEncodingModeSupportedWithChanges 101 }; 102 103 /* Enum BMDStreamingVideoCodec - Video codecs */ 104 105 typedef uint32_t BMDStreamingVideoCodec; 106 enum _BMDStreamingVideoCodec { 107 bmdStreamingVideoCodecH264 = 'H264' 108 }; 109 110 /* Enum BMDStreamingH264Profile - H264 encoding profile */ 111 112 typedef uint32_t BMDStreamingH264Profile; 113 enum _BMDStreamingH264Profile { 114 bmdStreamingH264ProfileHigh = 'high', 115 bmdStreamingH264ProfileMain = 'main', 116 bmdStreamingH264ProfileBaseline = 'base' 117 }; 118 119 /* Enum BMDStreamingH264Level - H264 encoding level */ 120 121 typedef uint32_t BMDStreamingH264Level; 122 enum _BMDStreamingH264Level { 123 bmdStreamingH264Level12 = 'lv12', 124 bmdStreamingH264Level13 = 'lv13', 125 bmdStreamingH264Level2 = 'lv2 ', 126 bmdStreamingH264Level21 = 'lv21', 127 bmdStreamingH264Level22 = 'lv22', 128 bmdStreamingH264Level3 = 'lv3 ', 129 bmdStreamingH264Level31 = 'lv31', 130 bmdStreamingH264Level32 = 'lv32', 131 bmdStreamingH264Level4 = 'lv4 ', 132 bmdStreamingH264Level41 = 'lv41', 133 bmdStreamingH264Level42 = 'lv42' 134 }; 135 136 /* Enum BMDStreamingH264EntropyCoding - H264 entropy coding */ 137 138 typedef uint32_t BMDStreamingH264EntropyCoding; 139 enum _BMDStreamingH264EntropyCoding { 140 bmdStreamingH264EntropyCodingCAVLC = 'EVLC', 141 bmdStreamingH264EntropyCodingCABAC = 'EBAC' 142 }; 143 144 /* Enum BMDStreamingAudioCodec - Audio codecs */ 145 146 typedef uint32_t BMDStreamingAudioCodec; 147 enum _BMDStreamingAudioCodec { 148 bmdStreamingAudioCodecAAC = 'AAC ' 149 }; 150 151 /* Enum BMDStreamingEncodingModePropertyID - Encoding mode properties */ 152 153 typedef uint32_t BMDStreamingEncodingModePropertyID; 154 enum _BMDStreamingEncodingModePropertyID { 155 156 /* Integers, Video Properties */ 157 158 bmdStreamingEncodingPropertyVideoFrameRate = 'vfrt', // Uses values of type BMDStreamingEncodingFrameRate 159 bmdStreamingEncodingPropertyVideoBitRateKbps = 'vbrt', 160 161 /* Integers, H264 Properties */ 162 163 bmdStreamingEncodingPropertyH264Profile = 'hprf', 164 bmdStreamingEncodingPropertyH264Level = 'hlvl', 165 bmdStreamingEncodingPropertyH264EntropyCoding = 'hent', 166 167 /* Flags, H264 Properties */ 168 169 bmdStreamingEncodingPropertyH264HasBFrames = 'hBfr', 170 171 /* Integers, Audio Properties */ 172 173 bmdStreamingEncodingPropertyAudioCodec = 'acdc', 174 bmdStreamingEncodingPropertyAudioSampleRate = 'asrt', 175 bmdStreamingEncodingPropertyAudioChannelCount = 'achc', 176 bmdStreamingEncodingPropertyAudioBitRateKbps = 'abrt' 177 }; 178 179 // Forward Declarations 180 181 class IBMDStreamingDeviceNotificationCallback; 182 class IBMDStreamingH264InputCallback; 183 class IBMDStreamingDiscovery; 184 class IBMDStreamingVideoEncodingMode; 185 class IBMDStreamingMutableVideoEncodingMode; 186 class IBMDStreamingVideoEncodingModePresetIterator; 187 class IBMDStreamingDeviceInput; 188 class IBMDStreamingH264NALPacket; 189 class IBMDStreamingAudioPacket; 190 class IBMDStreamingMPEG2TSPacket; 191 class IBMDStreamingH264NALParser; 192 193 /* Interface IBMDStreamingDeviceNotificationCallback - Device notification callbacks. */ 194 195 class BMD_PUBLIC IBMDStreamingDeviceNotificationCallback : public IUnknown 196 { 197 public: 198 virtual HRESULT StreamingDeviceArrived (/* in */ IDeckLink* device) = 0; 199 virtual HRESULT StreamingDeviceRemoved (/* in */ IDeckLink* device) = 0; 200 virtual HRESULT StreamingDeviceModeChanged (/* in */ IDeckLink* device, /* in */ BMDStreamingDeviceMode mode) = 0; 201 202 protected: ~IBMDStreamingDeviceNotificationCallback()203 virtual ~IBMDStreamingDeviceNotificationCallback () {} // call Release method to drop reference count 204 }; 205 206 /* Interface IBMDStreamingH264InputCallback - H264 input callbacks. */ 207 208 class BMD_PUBLIC IBMDStreamingH264InputCallback : public IUnknown 209 { 210 public: 211 virtual HRESULT H264NALPacketArrived (/* in */ IBMDStreamingH264NALPacket* nalPacket) = 0; 212 virtual HRESULT H264AudioPacketArrived (/* in */ IBMDStreamingAudioPacket* audioPacket) = 0; 213 virtual HRESULT MPEG2TSPacketArrived (/* in */ IBMDStreamingMPEG2TSPacket* tsPacket) = 0; 214 virtual HRESULT H264VideoInputConnectorScanningChanged (void) = 0; 215 virtual HRESULT H264VideoInputConnectorChanged (void) = 0; 216 virtual HRESULT H264VideoInputModeChanged (void) = 0; 217 218 protected: ~IBMDStreamingH264InputCallback()219 virtual ~IBMDStreamingH264InputCallback () {} // call Release method to drop reference count 220 }; 221 222 /* Interface IBMDStreamingDiscovery - Installs device notifications */ 223 224 class BMD_PUBLIC IBMDStreamingDiscovery : public IUnknown 225 { 226 public: 227 virtual HRESULT InstallDeviceNotifications (/* in */ IBMDStreamingDeviceNotificationCallback* theCallback) = 0; 228 virtual HRESULT UninstallDeviceNotifications (void) = 0; 229 230 protected: ~IBMDStreamingDiscovery()231 virtual ~IBMDStreamingDiscovery () {} // call Release method to drop reference count 232 }; 233 234 /* Interface IBMDStreamingVideoEncodingMode - Represents an encoded video mode. */ 235 236 class BMD_PUBLIC IBMDStreamingVideoEncodingMode : public IUnknown 237 { 238 public: 239 virtual HRESULT GetName (/* out */ CFStringRef *name) = 0; 240 virtual unsigned int GetPresetID (void) = 0; 241 virtual unsigned int GetSourcePositionX (void) = 0; 242 virtual unsigned int GetSourcePositionY (void) = 0; 243 virtual unsigned int GetSourceWidth (void) = 0; 244 virtual unsigned int GetSourceHeight (void) = 0; 245 virtual unsigned int GetDestWidth (void) = 0; 246 virtual unsigned int GetDestHeight (void) = 0; 247 virtual HRESULT GetFlag (/* in */ BMDStreamingEncodingModePropertyID cfgID, /* out */ bool* value) = 0; 248 virtual HRESULT GetInt (/* in */ BMDStreamingEncodingModePropertyID cfgID, /* out */ int64_t* value) = 0; 249 virtual HRESULT GetFloat (/* in */ BMDStreamingEncodingModePropertyID cfgID, /* out */ double* value) = 0; 250 virtual HRESULT GetString (/* in */ BMDStreamingEncodingModePropertyID cfgID, /* out */ CFStringRef *value) = 0; 251 virtual HRESULT CreateMutableVideoEncodingMode (/* out */ IBMDStreamingMutableVideoEncodingMode** newEncodingMode) = 0; // Creates a mutable copy of the encoding mode 252 253 protected: ~IBMDStreamingVideoEncodingMode()254 virtual ~IBMDStreamingVideoEncodingMode () {} // call Release method to drop reference count 255 }; 256 257 /* Interface IBMDStreamingMutableVideoEncodingMode - Represents a mutable encoded video mode. */ 258 259 class BMD_PUBLIC IBMDStreamingMutableVideoEncodingMode : public IBMDStreamingVideoEncodingMode 260 { 261 public: 262 virtual HRESULT SetSourceRect (/* in */ uint32_t posX, /* in */ uint32_t posY, /* in */ uint32_t width, /* in */ uint32_t height) = 0; 263 virtual HRESULT SetDestSize (/* in */ uint32_t width, /* in */ uint32_t height) = 0; 264 virtual HRESULT SetFlag (/* in */ BMDStreamingEncodingModePropertyID cfgID, /* in */ bool value) = 0; 265 virtual HRESULT SetInt (/* in */ BMDStreamingEncodingModePropertyID cfgID, /* in */ int64_t value) = 0; 266 virtual HRESULT SetFloat (/* in */ BMDStreamingEncodingModePropertyID cfgID, /* in */ double value) = 0; 267 virtual HRESULT SetString (/* in */ BMDStreamingEncodingModePropertyID cfgID, /* in */ CFStringRef value) = 0; 268 269 protected: ~IBMDStreamingMutableVideoEncodingMode()270 virtual ~IBMDStreamingMutableVideoEncodingMode () {} // call Release method to drop reference count 271 }; 272 273 /* Interface IBMDStreamingVideoEncodingModePresetIterator - Enumerates encoding mode presets */ 274 275 class BMD_PUBLIC IBMDStreamingVideoEncodingModePresetIterator : public IUnknown 276 { 277 public: 278 virtual HRESULT Next (/* out */ IBMDStreamingVideoEncodingMode** videoEncodingMode) = 0; 279 280 protected: ~IBMDStreamingVideoEncodingModePresetIterator()281 virtual ~IBMDStreamingVideoEncodingModePresetIterator () {} // call Release method to drop reference count 282 }; 283 284 /* Interface IBMDStreamingDeviceInput - Created by QueryInterface from IDeckLink */ 285 286 class BMD_PUBLIC IBMDStreamingDeviceInput : public IUnknown 287 { 288 public: 289 290 /* Input modes */ 291 292 virtual HRESULT DoesSupportVideoInputMode (/* in */ BMDDisplayMode inputMode, /* out */ bool* result) = 0; 293 virtual HRESULT GetVideoInputModeIterator (/* out */ IDeckLinkDisplayModeIterator** iterator) = 0; 294 virtual HRESULT SetVideoInputMode (/* in */ BMDDisplayMode inputMode) = 0; 295 virtual HRESULT GetCurrentDetectedVideoInputMode (/* out */ BMDDisplayMode* detectedMode) = 0; 296 297 /* Capture modes */ 298 299 virtual HRESULT GetVideoEncodingMode (/* out */ IBMDStreamingVideoEncodingMode** encodingMode) = 0; 300 virtual HRESULT GetVideoEncodingModePresetIterator (/* in */ BMDDisplayMode inputMode, /* out */ IBMDStreamingVideoEncodingModePresetIterator** iterator) = 0; 301 virtual HRESULT DoesSupportVideoEncodingMode (/* in */ BMDDisplayMode inputMode, /* in */ IBMDStreamingVideoEncodingMode* encodingMode, /* out */ BMDStreamingEncodingSupport* result, /* out */ IBMDStreamingVideoEncodingMode** changedEncodingMode) = 0; 302 virtual HRESULT SetVideoEncodingMode (/* in */ IBMDStreamingVideoEncodingMode* encodingMode) = 0; 303 304 /* Input control */ 305 306 virtual HRESULT StartCapture (void) = 0; 307 virtual HRESULT StopCapture (void) = 0; 308 virtual HRESULT SetCallback (/* in */ IUnknown* theCallback) = 0; 309 310 protected: ~IBMDStreamingDeviceInput()311 virtual ~IBMDStreamingDeviceInput () {} // call Release method to drop reference count 312 }; 313 314 /* Interface IBMDStreamingH264NALPacket - Represent an H.264 NAL packet */ 315 316 class BMD_PUBLIC IBMDStreamingH264NALPacket : public IUnknown 317 { 318 public: 319 virtual long GetPayloadSize (void) = 0; 320 virtual HRESULT GetBytes (/* out */ void** buffer) = 0; 321 virtual HRESULT GetBytesWithSizePrefix (/* out */ void** buffer) = 0; // Contains a 32-bit unsigned big endian size prefix 322 virtual HRESULT GetDisplayTime (/* in */ uint64_t requestedTimeScale, /* out */ uint64_t* displayTime) = 0; 323 virtual HRESULT GetPacketIndex (/* out */ uint32_t* packetIndex) = 0; // Deprecated 324 325 protected: ~IBMDStreamingH264NALPacket()326 virtual ~IBMDStreamingH264NALPacket () {} // call Release method to drop reference count 327 }; 328 329 /* Interface IBMDStreamingAudioPacket - Represents a chunk of audio data */ 330 331 class BMD_PUBLIC IBMDStreamingAudioPacket : public IUnknown 332 { 333 public: 334 virtual BMDStreamingAudioCodec GetCodec (void) = 0; 335 virtual long GetPayloadSize (void) = 0; 336 virtual HRESULT GetBytes (/* out */ void** buffer) = 0; 337 virtual HRESULT GetPlayTime (/* in */ uint64_t requestedTimeScale, /* out */ uint64_t* playTime) = 0; 338 virtual HRESULT GetPacketIndex (/* out */ uint32_t* packetIndex) = 0; // Deprecated 339 340 protected: ~IBMDStreamingAudioPacket()341 virtual ~IBMDStreamingAudioPacket () {} // call Release method to drop reference count 342 }; 343 344 /* Interface IBMDStreamingMPEG2TSPacket - Represent an MPEG2 Transport Stream packet */ 345 346 class BMD_PUBLIC IBMDStreamingMPEG2TSPacket : public IUnknown 347 { 348 public: 349 virtual long GetPayloadSize (void) = 0; 350 virtual HRESULT GetBytes (/* out */ void** buffer) = 0; 351 352 protected: ~IBMDStreamingMPEG2TSPacket()353 virtual ~IBMDStreamingMPEG2TSPacket () {} // call Release method to drop reference count 354 }; 355 356 /* Interface IBMDStreamingH264NALParser - For basic NAL parsing */ 357 358 class BMD_PUBLIC IBMDStreamingH264NALParser : public IUnknown 359 { 360 public: 361 virtual HRESULT IsNALSequenceParameterSet (/* in */ IBMDStreamingH264NALPacket* nal) = 0; 362 virtual HRESULT IsNALPictureParameterSet (/* in */ IBMDStreamingH264NALPacket* nal) = 0; 363 virtual HRESULT GetProfileAndLevelFromSPS (/* in */ IBMDStreamingH264NALPacket* nal, /* out */ uint32_t* profileIdc, /* out */ uint32_t* profileCompatability, /* out */ uint32_t* levelIdc) = 0; 364 365 protected: ~IBMDStreamingH264NALParser()366 virtual ~IBMDStreamingH264NALParser () {} // call Release method to drop reference count 367 }; 368 369 /* Functions */ 370 371 extern "C" { 372 373 IBMDStreamingDiscovery* BMD_PUBLIC CreateBMDStreamingDiscoveryInstance (void); 374 IBMDStreamingH264NALParser* BMD_PUBLIC CreateBMDStreamingH264NALParser (void); 375 376 } 377 378 379 #endif /* defined(BMD_DECKLINKAPISTREAMING_H) */ 380