DeckLinkAPIDeckControl.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /* -LICENSE-START-
  2. ** Copyright (c) 2021 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. #ifndef BMD_DECKLINKAPIDECKCONTROL_H
  28. #define BMD_DECKLINKAPIDECKCONTROL_H
  29. #ifndef BMD_CONST
  30. #if defined(_MSC_VER)
  31. #define BMD_CONST __declspec(selectany) static const
  32. #else
  33. #define BMD_CONST static const
  34. #endif
  35. #endif
  36. #ifndef BMD_PUBLIC
  37. #define BMD_PUBLIC
  38. #endif
  39. // Type Declarations
  40. // Interface ID Declarations
  41. BMD_CONST REFIID IID_IDeckLinkDeckControlStatusCallback = /* 53436FFB-B434-4906-BADC-AE3060FFE8EF */ { 0x53,0x43,0x6F,0xFB,0xB4,0x34,0x49,0x06,0xBA,0xDC,0xAE,0x30,0x60,0xFF,0xE8,0xEF };
  42. BMD_CONST REFIID IID_IDeckLinkDeckControl = /* 8E1C3ACE-19C7-4E00-8B92-D80431D958BE */ { 0x8E,0x1C,0x3A,0xCE,0x19,0xC7,0x4E,0x00,0x8B,0x92,0xD8,0x04,0x31,0xD9,0x58,0xBE };
  43. /* Enum BMDDeckControlMode - DeckControl mode */
  44. typedef uint32_t BMDDeckControlMode;
  45. enum _BMDDeckControlMode {
  46. bmdDeckControlNotOpened = /* 'ntop' */ 0x6E746F70,
  47. bmdDeckControlVTRControlMode = /* 'vtrc' */ 0x76747263,
  48. bmdDeckControlExportMode = /* 'expm' */ 0x6578706D,
  49. bmdDeckControlCaptureMode = /* 'capm' */ 0x6361706D
  50. };
  51. /* Enum BMDDeckControlEvent - DeckControl event */
  52. typedef uint32_t BMDDeckControlEvent;
  53. enum _BMDDeckControlEvent {
  54. bmdDeckControlAbortedEvent = /* 'abte' */ 0x61627465, // This event is triggered when a capture or edit-to-tape operation is aborted.
  55. /* Export-To-Tape events */
  56. bmdDeckControlPrepareForExportEvent = /* 'pfee' */ 0x70666565, // This event is triggered a few frames before reaching the in-point. IDeckLinkInput::StartScheduledPlayback should be called at this point.
  57. bmdDeckControlExportCompleteEvent = /* 'exce' */ 0x65786365, // This event is triggered a few frames after reaching the out-point. At this point, it is safe to stop playback. Upon reception of this event the deck's control mode is set back to bmdDeckControlVTRControlMode.
  58. /* Capture events */
  59. bmdDeckControlPrepareForCaptureEvent = /* 'pfce' */ 0x70666365, // This event is triggered a few frames before reaching the in-point. The serial timecode attached to IDeckLinkVideoInputFrames is now valid.
  60. bmdDeckControlCaptureCompleteEvent = /* 'ccev' */ 0x63636576 // This event is triggered a few frames after reaching the out-point. Upon reception of this event the deck's control mode is set back to bmdDeckControlVTRControlMode.
  61. };
  62. /* Enum BMDDeckControlVTRControlState - VTR Control state */
  63. typedef uint32_t BMDDeckControlVTRControlState;
  64. enum _BMDDeckControlVTRControlState {
  65. bmdDeckControlNotInVTRControlMode = /* 'nvcm' */ 0x6E76636D,
  66. bmdDeckControlVTRControlPlaying = /* 'vtrp' */ 0x76747270,
  67. bmdDeckControlVTRControlRecording = /* 'vtrr' */ 0x76747272,
  68. bmdDeckControlVTRControlStill = /* 'vtra' */ 0x76747261,
  69. bmdDeckControlVTRControlShuttleForward = /* 'vtsf' */ 0x76747366,
  70. bmdDeckControlVTRControlShuttleReverse = /* 'vtsr' */ 0x76747372,
  71. bmdDeckControlVTRControlJogForward = /* 'vtjf' */ 0x76746A66,
  72. bmdDeckControlVTRControlJogReverse = /* 'vtjr' */ 0x76746A72,
  73. bmdDeckControlVTRControlStopped = /* 'vtro' */ 0x7674726F
  74. };
  75. /* Enum BMDDeckControlStatusFlags - Deck Control status flags */
  76. typedef uint32_t BMDDeckControlStatusFlags;
  77. enum _BMDDeckControlStatusFlags {
  78. bmdDeckControlStatusDeckConnected = 1 << 0,
  79. bmdDeckControlStatusRemoteMode = 1 << 1,
  80. bmdDeckControlStatusRecordInhibited = 1 << 2,
  81. bmdDeckControlStatusCassetteOut = 1 << 3
  82. };
  83. /* Enum BMDDeckControlExportModeOpsFlags - Export mode flags */
  84. typedef uint32_t BMDDeckControlExportModeOpsFlags;
  85. enum _BMDDeckControlExportModeOpsFlags {
  86. bmdDeckControlExportModeInsertVideo = 1 << 0,
  87. bmdDeckControlExportModeInsertAudio1 = 1 << 1,
  88. bmdDeckControlExportModeInsertAudio2 = 1 << 2,
  89. bmdDeckControlExportModeInsertAudio3 = 1 << 3,
  90. bmdDeckControlExportModeInsertAudio4 = 1 << 4,
  91. bmdDeckControlExportModeInsertAudio5 = 1 << 5,
  92. bmdDeckControlExportModeInsertAudio6 = 1 << 6,
  93. bmdDeckControlExportModeInsertAudio7 = 1 << 7,
  94. bmdDeckControlExportModeInsertAudio8 = 1 << 8,
  95. bmdDeckControlExportModeInsertAudio9 = 1 << 9,
  96. bmdDeckControlExportModeInsertAudio10 = 1 << 10,
  97. bmdDeckControlExportModeInsertAudio11 = 1 << 11,
  98. bmdDeckControlExportModeInsertAudio12 = 1 << 12,
  99. bmdDeckControlExportModeInsertTimeCode = 1 << 13,
  100. bmdDeckControlExportModeInsertAssemble = 1 << 14,
  101. bmdDeckControlExportModeInsertPreview = 1 << 15,
  102. bmdDeckControlUseManualExport = 1 << 16
  103. };
  104. /* Enum BMDDeckControlError - Deck Control error */
  105. typedef uint32_t BMDDeckControlError;
  106. enum _BMDDeckControlError {
  107. bmdDeckControlNoError = /* 'noer' */ 0x6E6F6572,
  108. bmdDeckControlModeError = /* 'moer' */ 0x6D6F6572,
  109. bmdDeckControlMissedInPointError = /* 'mier' */ 0x6D696572,
  110. bmdDeckControlDeckTimeoutError = /* 'dter' */ 0x64746572,
  111. bmdDeckControlCommandFailedError = /* 'cfer' */ 0x63666572,
  112. bmdDeckControlDeviceAlreadyOpenedError = /* 'dalo' */ 0x64616C6F,
  113. bmdDeckControlFailedToOpenDeviceError = /* 'fder' */ 0x66646572,
  114. bmdDeckControlInLocalModeError = /* 'lmer' */ 0x6C6D6572,
  115. bmdDeckControlEndOfTapeError = /* 'eter' */ 0x65746572,
  116. bmdDeckControlUserAbortError = /* 'uaer' */ 0x75616572,
  117. bmdDeckControlNoTapeInDeckError = /* 'nter' */ 0x6E746572,
  118. bmdDeckControlNoVideoFromCardError = /* 'nvfc' */ 0x6E766663,
  119. bmdDeckControlNoCommunicationError = /* 'ncom' */ 0x6E636F6D,
  120. bmdDeckControlBufferTooSmallError = /* 'btsm' */ 0x6274736D,
  121. bmdDeckControlBadChecksumError = /* 'chks' */ 0x63686B73,
  122. bmdDeckControlUnknownError = /* 'uner' */ 0x756E6572
  123. };
  124. #if defined(__cplusplus)
  125. // Forward Declarations
  126. class IDeckLinkDeckControlStatusCallback;
  127. class IDeckLinkDeckControl;
  128. /* Interface IDeckLinkDeckControlStatusCallback - Deck control state change callback. */
  129. class BMD_PUBLIC IDeckLinkDeckControlStatusCallback : public IUnknown
  130. {
  131. public:
  132. virtual HRESULT TimecodeUpdate (/* in */ BMDTimecodeBCD currentTimecode) = 0;
  133. virtual HRESULT VTRControlStateChanged (/* in */ BMDDeckControlVTRControlState newState, /* in */ BMDDeckControlError error) = 0;
  134. virtual HRESULT DeckControlEventReceived (/* in */ BMDDeckControlEvent event, /* in */ BMDDeckControlError error) = 0;
  135. virtual HRESULT DeckControlStatusChanged (/* in */ BMDDeckControlStatusFlags flags, /* in */ uint32_t mask) = 0;
  136. protected:
  137. virtual ~IDeckLinkDeckControlStatusCallback () {} // call Release method to drop reference count
  138. };
  139. /* Interface IDeckLinkDeckControl - Deck Control main interface */
  140. class BMD_PUBLIC IDeckLinkDeckControl : public IUnknown
  141. {
  142. public:
  143. virtual HRESULT Open (/* in */ BMDTimeScale timeScale, /* in */ BMDTimeValue timeValue, /* in */ bool timecodeIsDropFrame, /* out */ BMDDeckControlError* error) = 0;
  144. virtual HRESULT Close (/* in */ bool standbyOn) = 0;
  145. virtual HRESULT GetCurrentState (/* out */ BMDDeckControlMode* mode, /* out */ BMDDeckControlVTRControlState* vtrControlState, /* out */ BMDDeckControlStatusFlags* flags) = 0;
  146. virtual HRESULT SetStandby (/* in */ bool standbyOn) = 0;
  147. virtual HRESULT SendCommand (/* in */ uint8_t* inBuffer, /* in */ uint32_t inBufferSize, /* out */ uint8_t* outBuffer, /* out */ uint32_t* outDataSize, /* in */ uint32_t outBufferSize, /* out */ BMDDeckControlError* error) = 0;
  148. virtual HRESULT Play (/* out */ BMDDeckControlError* error) = 0;
  149. virtual HRESULT Stop (/* out */ BMDDeckControlError* error) = 0;
  150. virtual HRESULT TogglePlayStop (/* out */ BMDDeckControlError* error) = 0;
  151. virtual HRESULT Eject (/* out */ BMDDeckControlError* error) = 0;
  152. virtual HRESULT GoToTimecode (/* in */ BMDTimecodeBCD timecode, /* out */ BMDDeckControlError* error) = 0;
  153. virtual HRESULT FastForward (/* in */ bool viewTape, /* out */ BMDDeckControlError* error) = 0;
  154. virtual HRESULT Rewind (/* in */ bool viewTape, /* out */ BMDDeckControlError* error) = 0;
  155. virtual HRESULT StepForward (/* out */ BMDDeckControlError* error) = 0;
  156. virtual HRESULT StepBack (/* out */ BMDDeckControlError* error) = 0;
  157. virtual HRESULT Jog (/* in */ double rate, /* out */ BMDDeckControlError* error) = 0;
  158. virtual HRESULT Shuttle (/* in */ double rate, /* out */ BMDDeckControlError* error) = 0;
  159. virtual HRESULT GetTimecodeString (/* out */ CFStringRef* currentTimeCode, /* out */ BMDDeckControlError* error) = 0;
  160. virtual HRESULT GetTimecode (/* out */ IDeckLinkTimecode** currentTimecode, /* out */ BMDDeckControlError* error) = 0;
  161. virtual HRESULT GetTimecodeBCD (/* out */ BMDTimecodeBCD* currentTimecode, /* out */ BMDDeckControlError* error) = 0;
  162. virtual HRESULT SetPreroll (/* in */ uint32_t prerollSeconds) = 0;
  163. virtual HRESULT GetPreroll (/* out */ uint32_t* prerollSeconds) = 0;
  164. virtual HRESULT SetExportOffset (/* in */ int32_t exportOffsetFields) = 0;
  165. virtual HRESULT GetExportOffset (/* out */ int32_t* exportOffsetFields) = 0;
  166. virtual HRESULT GetManualExportOffset (/* out */ int32_t* deckManualExportOffsetFields) = 0;
  167. virtual HRESULT SetCaptureOffset (/* in */ int32_t captureOffsetFields) = 0;
  168. virtual HRESULT GetCaptureOffset (/* out */ int32_t* captureOffsetFields) = 0;
  169. virtual HRESULT StartExport (/* in */ BMDTimecodeBCD inTimecode, /* in */ BMDTimecodeBCD outTimecode, /* in */ BMDDeckControlExportModeOpsFlags exportModeOps, /* out */ BMDDeckControlError* error) = 0;
  170. virtual HRESULT StartCapture (/* in */ bool useVITC, /* in */ BMDTimecodeBCD inTimecode, /* in */ BMDTimecodeBCD outTimecode, /* out */ BMDDeckControlError* error) = 0;
  171. virtual HRESULT GetDeviceID (/* out */ uint16_t* deviceId, /* out */ BMDDeckControlError* error) = 0;
  172. virtual HRESULT Abort (void) = 0;
  173. virtual HRESULT CrashRecordStart (/* out */ BMDDeckControlError* error) = 0;
  174. virtual HRESULT CrashRecordStop (/* out */ BMDDeckControlError* error) = 0;
  175. virtual HRESULT SetCallback (/* in */ IDeckLinkDeckControlStatusCallback* callback) = 0;
  176. protected:
  177. virtual ~IDeckLinkDeckControl () {} // call Release method to drop reference count
  178. };
  179. /* Functions */
  180. extern "C" {
  181. }
  182. #endif /* defined(__cplusplus) */
  183. #endif /* defined(BMD_DECKLINKAPIDECKCONTROL_H) */