/* -LICENSE-START-
** Copyright (c) 2014 Blackmagic Design
**
** Permission is hereby granted, free of charge, to any person or organization
** obtaining a copy of the software and accompanying documentation covered by
** this license (the "Software") to use, reproduce, display, distribute,
** execute, and transmit the Software, and to prepare derivative works of the
** Software, and to permit third-parties to whom the Software is furnished to
** do so, all subject to the following:
**
** The copyright notices in the Software and this entire statement, including
** the above license grant, this restriction and the following disclaimer,
** must be included in all copies of the Software, in whole or in part, and
** all derivative works of the Software, unless such copies or derivative
** works are solely in the form of machine-executable object code generated by
** a source language processor.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
** DEALINGS IN THE SOFTWARE.
** -LICENSE-END-
*/


#ifndef BMD_CONST
    #if defined(_MSC_VER)
        #define BMD_CONST __declspec(selectany) static const
    #else
        #define BMD_CONST static const
    #endif
#endif

/* DeckLink API */

import "unknwn.idl";

[uuid(D864517A-EDD5-466D-867D-C819F1C052BB),
version(1.0), helpstring("DeckLink API Library")]
library DeckLinkAPI
{

#include "DeckLinkAPITypes.idl"
#include "DeckLinkAPIModes.idl"
#include "DeckLinkAPIDiscovery.idl"
#include "DeckLinkAPIConfiguration.idl"
#include "DeckLinkAPIDeckControl.idl"
#include "DeckLinkAPIStreaming.idl"

// Type Declarations


// Enumeration Mapping

cpp_quote("typedef unsigned long BMDFrameFlags;")
cpp_quote("typedef unsigned long BMDVideoInputFlags;")
cpp_quote("typedef unsigned long BMDVideoInputFormatChangedEvents;")
cpp_quote("typedef unsigned long BMDDetectedVideoInputFormatFlags;")
cpp_quote("typedef unsigned long BMDDeckLinkCapturePassthroughMode;")
cpp_quote("typedef unsigned long BMDAnalogVideoFlags;")
cpp_quote("typedef unsigned long BMDDeviceBusyState;")
cpp_quote("#if 0")
typedef enum _BMDFrameFlags BMDFrameFlags;
typedef enum _BMDVideoInputFlags BMDVideoInputFlags;
typedef enum _BMDVideoInputFormatChangedEvents BMDVideoInputFormatChangedEvents;
typedef enum _BMDDetectedVideoInputFormatFlags BMDDetectedVideoInputFormatFlags;
typedef enum _BMDDeckLinkCapturePassthroughMode BMDDeckLinkCapturePassthroughMode;
typedef enum _BMDAnalogVideoFlags BMDAnalogVideoFlags;
typedef enum _BMDDeviceBusyState BMDDeviceBusyState;
cpp_quote("#endif")

/* Enum BMDVideoOutputFlags - Flags to control the output of ancillary data along with video. */

typedef [v1_enum] enum	_BMDVideoOutputFlags {
    bmdVideoOutputFlagDefault                                    = 0,
    bmdVideoOutputVANC                                           = 1 << 0,
    bmdVideoOutputVITC                                           = 1 << 1,
    bmdVideoOutputRP188                                          = 1 << 2,
    bmdVideoOutputDualStream3D                                   = 1 << 4
} BMDVideoOutputFlags;

/* Enum BMDFrameFlags - Frame flags */

[v1_enum] enum	_BMDFrameFlags {
    bmdFrameFlagDefault                                          = 0,
    bmdFrameFlagFlipVertical                                     = 1 << 0,

    /* Flags that are applicable only to instances of IDeckLinkVideoInputFrame */

    bmdFrameHasNoInputSource                                     = 1 << 31
};

/* Enum BMDVideoInputFlags - Flags applicable to video input */

[v1_enum] enum	_BMDVideoInputFlags {
    bmdVideoInputFlagDefault                                     = 0,
    bmdVideoInputEnableFormatDetection                           = 1 << 0,
    bmdVideoInputDualStream3D                                    = 1 << 1
};

/* Enum BMDVideoInputFormatChangedEvents - Bitmask passed to the VideoInputFormatChanged notification to identify the properties of the input signal that have changed */

[v1_enum] enum	_BMDVideoInputFormatChangedEvents {
    bmdVideoInputDisplayModeChanged                              = 1 << 0,
    bmdVideoInputFieldDominanceChanged                           = 1 << 1,
    bmdVideoInputColorspaceChanged                               = 1 << 2
};

/* Enum BMDDetectedVideoInputFormatFlags - Flags passed to the VideoInputFormatChanged notification to describe the detected video input signal */

[v1_enum] enum	_BMDDetectedVideoInputFormatFlags {
    bmdDetectedVideoInputYCbCr422                                = 1 << 0,
    bmdDetectedVideoInputRGB444                                  = 1 << 1,
    bmdDetectedVideoInputDualStream3D                            = 1 << 2
};

/* Enum BMDDeckLinkCapturePassthroughMode - Enumerates whether the video output is electrically connected to the video input or if the clean switching mode is enabled */

[v1_enum] enum	_BMDDeckLinkCapturePassthroughMode {
    bmdDeckLinkCapturePassthroughModeDirect                      = /* 'pdir' */ 0x70646972,
    bmdDeckLinkCapturePassthroughModeCleanSwitch                 = /* 'pcln' */ 0x70636C6E
};

/* Enum BMDOutputFrameCompletionResult - Frame Completion Callback */

typedef [v1_enum] enum	_BMDOutputFrameCompletionResult {
    bmdOutputFrameCompleted,
    bmdOutputFrameDisplayedLate,
    bmdOutputFrameDropped,
    bmdOutputFrameFlushed
} BMDOutputFrameCompletionResult;

/* Enum BMDReferenceStatus - GenLock input status */

typedef [v1_enum] enum	_BMDReferenceStatus {
    bmdReferenceNotSupportedByHardware                           = 1 << 0,
    bmdReferenceLocked                                           = 1 << 1
} BMDReferenceStatus;

/* Enum BMDAudioSampleRate - Audio sample rates supported for output/input */

typedef [v1_enum] enum	_BMDAudioSampleRate {
    bmdAudioSampleRate48kHz                                      = 48000
} BMDAudioSampleRate;

/* Enum BMDAudioSampleType - Audio sample sizes supported for output/input */

typedef [v1_enum] enum	_BMDAudioSampleType {
    bmdAudioSampleType16bitInteger                               = 16,
    bmdAudioSampleType32bitInteger                               = 32
} BMDAudioSampleType;

/* Enum BMDAudioOutputStreamType - Audio output stream type */

typedef [v1_enum] enum	_BMDAudioOutputStreamType {
    bmdAudioOutputStreamContinuous,
    bmdAudioOutputStreamContinuousDontResample,
    bmdAudioOutputStreamTimestamped
} BMDAudioOutputStreamType;

/* Enum BMDDisplayModeSupport - Output mode supported flags */

typedef [v1_enum] enum	_BMDDisplayModeSupport {
    bmdDisplayModeNotSupported                                   = 0,
    bmdDisplayModeSupported,
    bmdDisplayModeSupportedWithConversion
} BMDDisplayModeSupport;

/* Enum BMDTimecodeFormat - Timecode formats for frame metadata */

typedef [v1_enum] enum	_BMDTimecodeFormat {
    bmdTimecodeRP188VITC1                                        = /* 'rpv1' */ 0x72707631,	// RP188 timecode where DBB1 equals VITC1 (line 9)
    bmdTimecodeRP188VITC2                                        = /* 'rp12' */ 0x72703132,	// RP188 timecode where DBB1 equals VITC2 (line 9 for progressive or line 571 for interlaced/PsF)
    bmdTimecodeRP188LTC                                          = /* 'rplt' */ 0x72706C74,	// RP188 timecode where DBB1 equals LTC (line 10)
    bmdTimecodeRP188Any                                          = /* 'rp18' */ 0x72703138,	// For capture: return the first valid timecode in {VITC1, LTC ,VITC2} - For playback: set the timecode as VITC1
    bmdTimecodeVITC                                              = /* 'vitc' */ 0x76697463,
    bmdTimecodeVITCField2                                        = /* 'vit2' */ 0x76697432,
    bmdTimecodeSerial                                            = /* 'seri' */ 0x73657269
} BMDTimecodeFormat;

/* Enum BMDAnalogVideoFlags - Analog video display flags */

[v1_enum] enum	_BMDAnalogVideoFlags {
    bmdAnalogVideoFlagCompositeSetup75                           = 1 << 0,
    bmdAnalogVideoFlagComponentBetacamLevels                     = 1 << 1
};

/* Enum BMDAudioOutputAnalogAESSwitch - Audio output Analog/AESEBU switch */

typedef [v1_enum] enum	_BMDAudioOutputAnalogAESSwitch {
    bmdAudioOutputSwitchAESEBU                                   = /* 'aes ' */ 0x61657320,
    bmdAudioOutputSwitchAnalog                                   = /* 'anlg' */ 0x616E6C67
} BMDAudioOutputAnalogAESSwitch;

/* Enum BMDVideoOutputConversionMode - Video/audio conversion mode */

typedef [v1_enum] enum	_BMDVideoOutputConversionMode {
    bmdNoVideoOutputConversion                                   = /* 'none' */ 0x6E6F6E65,
    bmdVideoOutputLetterboxDownconversion                        = /* 'ltbx' */ 0x6C746278,
    bmdVideoOutputAnamorphicDownconversion                       = /* 'amph' */ 0x616D7068,
    bmdVideoOutputHD720toHD1080Conversion                        = /* '720c' */ 0x37323063,
    bmdVideoOutputHardwareLetterboxDownconversion                = /* 'HWlb' */ 0x48576C62,
    bmdVideoOutputHardwareAnamorphicDownconversion               = /* 'HWam' */ 0x4857616D,
    bmdVideoOutputHardwareCenterCutDownconversion                = /* 'HWcc' */ 0x48576363,
    bmdVideoOutputHardware720p1080pCrossconversion               = /* 'xcap' */ 0x78636170,
    bmdVideoOutputHardwareAnamorphic720pUpconversion             = /* 'ua7p' */ 0x75613770,
    bmdVideoOutputHardwareAnamorphic1080iUpconversion            = /* 'ua1i' */ 0x75613169,
    bmdVideoOutputHardwareAnamorphic149To720pUpconversion        = /* 'u47p' */ 0x75343770,
    bmdVideoOutputHardwareAnamorphic149To1080iUpconversion       = /* 'u41i' */ 0x75343169,
    bmdVideoOutputHardwarePillarbox720pUpconversion              = /* 'up7p' */ 0x75703770,
    bmdVideoOutputHardwarePillarbox1080iUpconversion             = /* 'up1i' */ 0x75703169
} BMDVideoOutputConversionMode;

/* Enum BMDVideoInputConversionMode - Video input conversion mode */

typedef [v1_enum] enum	_BMDVideoInputConversionMode {
    bmdNoVideoInputConversion                                    = /* 'none' */ 0x6E6F6E65,
    bmdVideoInputLetterboxDownconversionFromHD1080               = /* '10lb' */ 0x31306C62,
    bmdVideoInputAnamorphicDownconversionFromHD1080              = /* '10am' */ 0x3130616D,
    bmdVideoInputLetterboxDownconversionFromHD720                = /* '72lb' */ 0x37326C62,
    bmdVideoInputAnamorphicDownconversionFromHD720               = /* '72am' */ 0x3732616D,
    bmdVideoInputLetterboxUpconversion                           = /* 'lbup' */ 0x6C627570,
    bmdVideoInputAnamorphicUpconversion                          = /* 'amup' */ 0x616D7570
} BMDVideoInputConversionMode;

/* Enum BMDVideo3DPackingFormat - Video 3D packing format */

typedef [v1_enum] enum	_BMDVideo3DPackingFormat {
    bmdVideo3DPackingSidebySideHalf                              = /* 'sbsh' */ 0x73627368,
    bmdVideo3DPackingLinebyLine                                  = /* 'lbyl' */ 0x6C62796C,
    bmdVideo3DPackingTopAndBottom                                = /* 'tabo' */ 0x7461626F,
    bmdVideo3DPackingFramePacking                                = /* 'frpk' */ 0x6672706B,
    bmdVideo3DPackingLeftOnly                                    = /* 'left' */ 0x6C656674,
    bmdVideo3DPackingRightOnly                                   = /* 'righ' */ 0x72696768
} BMDVideo3DPackingFormat;

/* Enum BMDIdleVideoOutputOperation - Video output operation when not playing video */

typedef [v1_enum] enum	_BMDIdleVideoOutputOperation {
    bmdIdleVideoOutputBlack                                      = /* 'blac' */ 0x626C6163,
    bmdIdleVideoOutputLastFrame                                  = /* 'lafa' */ 0x6C616661,
    bmdIdleVideoOutputDesktop                                    = /* 'desk' */ 0x6465736B
} BMDIdleVideoOutputOperation;

/* Enum BMDDeckLinkAttributeID - DeckLink Attribute ID */

typedef [v1_enum] enum	_BMDDeckLinkAttributeID {

    /* Flags */

    BMDDeckLinkSupportsInternalKeying                            = /* 'keyi' */ 0x6B657969,
    BMDDeckLinkSupportsExternalKeying                            = /* 'keye' */ 0x6B657965,
    BMDDeckLinkSupportsHDKeying                                  = /* 'keyh' */ 0x6B657968,
    BMDDeckLinkSupportsInputFormatDetection                      = /* 'infd' */ 0x696E6664,
    BMDDeckLinkHasReferenceInput                                 = /* 'hrin' */ 0x6872696E,
    BMDDeckLinkHasSerialPort                                     = /* 'hspt' */ 0x68737074,
    BMDDeckLinkHasAnalogVideoOutputGain                          = /* 'avog' */ 0x61766F67,
    BMDDeckLinkCanOnlyAdjustOverallVideoOutputGain               = /* 'ovog' */ 0x6F766F67,
    BMDDeckLinkHasVideoInputAntiAliasingFilter                   = /* 'aafl' */ 0x6161666C,
    BMDDeckLinkHasBypass                                         = /* 'byps' */ 0x62797073,
    BMDDeckLinkSupportsDesktopDisplay                            = /* 'extd' */ 0x65787464,
    BMDDeckLinkSupportsClockTimingAdjustment                     = /* 'ctad' */ 0x63746164,
    BMDDeckLinkSupportsFullDuplex                                = /* 'fdup' */ 0x66647570,
    BMDDeckLinkSupportsFullFrameReferenceInputTimingOffset       = /* 'frin' */ 0x6672696E,

    /* Integers */

    BMDDeckLinkMaximumAudioChannels                              = /* 'mach' */ 0x6D616368,
    BMDDeckLinkMaximumAnalogAudioChannels                        = /* 'aach' */ 0x61616368,
    BMDDeckLinkNumberOfSubDevices                                = /* 'nsbd' */ 0x6E736264,
    BMDDeckLinkSubDeviceIndex                                    = /* 'subi' */ 0x73756269,
    BMDDeckLinkPersistentID                                      = /* 'peid' */ 0x70656964,
    BMDDeckLinkTopologicalID                                     = /* 'toid' */ 0x746F6964,
    BMDDeckLinkVideoOutputConnections                            = /* 'vocn' */ 0x766F636E,
    BMDDeckLinkVideoInputConnections                             = /* 'vicn' */ 0x7669636E,
    BMDDeckLinkAudioOutputConnections                            = /* 'aocn' */ 0x616F636E,
    BMDDeckLinkAudioInputConnections                             = /* 'aicn' */ 0x6169636E,
    BMDDeckLinkDeviceBusyState                                   = /* 'dbst' */ 0x64627374,
    BMDDeckLinkVideoIOSupport                                    = /* 'vios' */ 0x76696F73,	// Returns a BMDVideoIOSupport bit field

    /* Floats */

    BMDDeckLinkVideoInputGainMinimum                             = /* 'vigm' */ 0x7669676D,
    BMDDeckLinkVideoInputGainMaximum                             = /* 'vigx' */ 0x76696778,
    BMDDeckLinkVideoOutputGainMinimum                            = /* 'vogm' */ 0x766F676D,
    BMDDeckLinkVideoOutputGainMaximum                            = /* 'vogx' */ 0x766F6778,

    /* Strings */

    BMDDeckLinkSerialPortDeviceName                              = /* 'slpn' */ 0x736C706E
} BMDDeckLinkAttributeID;

/* Enum BMDDeckLinkAPIInformationID - DeckLinkAPI information ID */

typedef [v1_enum] enum	_BMDDeckLinkAPIInformationID {
    BMDDeckLinkAPIVersion                                        = /* 'vers' */ 0x76657273
} BMDDeckLinkAPIInformationID;

/* Enum BMDDeviceBusyState - Current device busy state */

[v1_enum] enum	_BMDDeviceBusyState {
    bmdDeviceCaptureBusy                                         = 1 << 0,
    bmdDevicePlaybackBusy                                        = 1 << 1,
    bmdDeviceSerialPortBusy                                      = 1 << 2
};

/* Enum BMDVideoIOSupport - Device video input/output support */

typedef [v1_enum] enum	_BMDVideoIOSupport {
    bmdDeviceSupportsCapture                                     = 1 << 0,
    bmdDeviceSupportsPlayback                                    = 1 << 1
} BMDVideoIOSupport;

/* Enum BMD3DPreviewFormat - Linked Frame preview format */

typedef [v1_enum] enum	_BMD3DPreviewFormat {
    bmd3DPreviewFormatDefault                                    = /* 'defa' */ 0x64656661,
    bmd3DPreviewFormatLeftOnly                                   = /* 'left' */ 0x6C656674,
    bmd3DPreviewFormatRightOnly                                  = /* 'righ' */ 0x72696768,
    bmd3DPreviewFormatSideBySide                                 = /* 'side' */ 0x73696465,
    bmd3DPreviewFormatTopBottom                                  = /* 'topb' */ 0x746F7062
} BMD3DPreviewFormat;

/* Enum BMDNotifications - Events that can be subscribed through IDeckLinkNotification */

typedef [v1_enum] enum	_BMDNotifications {
    bmdPreferencesChanged                                        = /* 'pref' */ 0x70726566
} BMDNotifications;

// Forward Declarations

interface IDeckLinkVideoOutputCallback;
interface IDeckLinkInputCallback;
interface IDeckLinkMemoryAllocator;
interface IDeckLinkAudioOutputCallback;
interface IDeckLinkIterator;
interface IDeckLinkAPIInformation;
interface IDeckLinkOutput;
interface IDeckLinkInput;
interface IDeckLinkVideoFrame;
interface IDeckLinkMutableVideoFrame;
interface IDeckLinkVideoFrame3DExtensions;
interface IDeckLinkVideoInputFrame;
interface IDeckLinkVideoFrameAncillary;
interface IDeckLinkAudioInputPacket;
interface IDeckLinkScreenPreviewCallback;
interface IDeckLinkGLScreenPreviewHelper;
interface IDeckLinkDX9ScreenPreviewHelper;
interface IDeckLinkNotificationCallback;
interface IDeckLinkNotification;
interface IDeckLinkAttributes;
interface IDeckLinkKeyer;
interface IDeckLinkVideoConversion;
interface IDeckLinkDeviceNotificationCallback;
interface IDeckLinkDiscovery;

/* Interface IDeckLinkVideoOutputCallback - Frame completion callback. */

[
    object,
    uuid(20AA5225-1958-47CB-820B-80A8D521A6EE),
    helpstring("Frame completion callback.")
] interface IDeckLinkVideoOutputCallback : IUnknown
{
    HRESULT ScheduledFrameCompleted([in] IDeckLinkVideoFrame *completedFrame, [in] BMDOutputFrameCompletionResult result);
    HRESULT ScheduledPlaybackHasStopped(void);
};

/* Interface IDeckLinkInputCallback - Frame arrival callback. */

[
    object,
    uuid(DD04E5EC-7415-42AB-AE4A-E80C4DFC044A),
    helpstring("Frame arrival callback.")
] interface IDeckLinkInputCallback : IUnknown
{
    HRESULT VideoInputFormatChanged([in] BMDVideoInputFormatChangedEvents notificationEvents, [in] IDeckLinkDisplayMode *newDisplayMode, [in] BMDDetectedVideoInputFormatFlags detectedSignalFlags);
    HRESULT VideoInputFrameArrived([in] IDeckLinkVideoInputFrame* videoFrame, [in] IDeckLinkAudioInputPacket* audioPacket);
};

/* Interface IDeckLinkMemoryAllocator - Memory allocator for video frames. */

[
    object,
    uuid(B36EB6E7-9D29-4AA8-92EF-843B87A289E8),
    local,
    helpstring("Memory allocator for video frames.")
] interface IDeckLinkMemoryAllocator : IUnknown
{
    HRESULT AllocateBuffer([in] unsigned long bufferSize, [out] void **allocatedBuffer);
    HRESULT ReleaseBuffer([in] void *buffer);

    HRESULT Commit(void);
    HRESULT Decommit(void);
};

/* Interface IDeckLinkAudioOutputCallback - Optional callback to allow audio samples to be pulled as required. */

[
    object,
    uuid(403C681B-7F46-4A12-B993-2BB127084EE6),
    local,
    helpstring("Optional callback to allow audio samples to be pulled as required.")
] interface IDeckLinkAudioOutputCallback : IUnknown
{
    HRESULT RenderAudioSamples([in] BOOL preroll);
};

/* Interface IDeckLinkIterator - enumerates installed DeckLink hardware */

[
    object,
    uuid(50FB36CD-3063-4B73-BDBB-958087F2D8BA),
    helpstring("enumerates installed DeckLink hardware")
] interface IDeckLinkIterator : IUnknown
{
    HRESULT Next([out] IDeckLink **deckLinkInstance);
};

/* Interface IDeckLinkAPIInformation - DeckLinkAPI attribute interface */

[
    object,
    uuid(7BEA3C68-730D-4322-AF34-8A7152B532A4),
    helpstring("DeckLinkAPI attribute interface")
] interface IDeckLinkAPIInformation : IUnknown
{
    HRESULT GetFlag([in] BMDDeckLinkAPIInformationID cfgID, [out] BOOL *value);
    HRESULT GetInt([in] BMDDeckLinkAPIInformationID cfgID, [out] LONGLONG *value);
    HRESULT GetFloat([in] BMDDeckLinkAPIInformationID cfgID, [out] double *value);
    HRESULT GetString([in] BMDDeckLinkAPIInformationID cfgID, [out] BSTR *value);
};

/* Interface IDeckLinkOutput - Created by QueryInterface from IDeckLink. */

[
    object,
    uuid(CC5C8A6E-3F2F-4B3A-87EA-FD78AF300564),
    local,
    helpstring("Created by QueryInterface from IDeckLink.")
] interface IDeckLinkOutput : IUnknown
{
    HRESULT DoesSupportVideoMode([in] BMDDisplayMode displayMode, [in] BMDPixelFormat pixelFormat, [in] BMDVideoOutputFlags flags, [out] BMDDisplayModeSupport *result, [out] IDeckLinkDisplayMode **resultDisplayMode);
    HRESULT GetDisplayModeIterator([out] IDeckLinkDisplayModeIterator **iterator);

    HRESULT SetScreenPreviewCallback([in] IDeckLinkScreenPreviewCallback *previewCallback);

    /* Video Output */

    HRESULT EnableVideoOutput([in] BMDDisplayMode displayMode, [in] BMDVideoOutputFlags flags);
    HRESULT DisableVideoOutput(void);

    HRESULT SetVideoOutputFrameMemoryAllocator([in] IDeckLinkMemoryAllocator *theAllocator);
    HRESULT CreateVideoFrame([in] long width, [in] long height, [in] long rowBytes, [in] BMDPixelFormat pixelFormat, [in] BMDFrameFlags flags, [out] IDeckLinkMutableVideoFrame **outFrame);
    HRESULT CreateAncillaryData([in] BMDPixelFormat pixelFormat, [out] IDeckLinkVideoFrameAncillary **outBuffer);

    HRESULT DisplayVideoFrameSync([in] IDeckLinkVideoFrame *theFrame);
    HRESULT ScheduleVideoFrame([in] IDeckLinkVideoFrame *theFrame, [in] BMDTimeValue displayTime, [in] BMDTimeValue displayDuration, [in] BMDTimeScale timeScale);
    HRESULT SetScheduledFrameCompletionCallback([in] IDeckLinkVideoOutputCallback *theCallback);
    HRESULT GetBufferedVideoFrameCount([out] unsigned long *bufferedFrameCount);

    /* Audio Output */

    HRESULT EnableAudioOutput([in] BMDAudioSampleRate sampleRate, [in] BMDAudioSampleType sampleType, [in] unsigned long channelCount, [in] BMDAudioOutputStreamType streamType);
    HRESULT DisableAudioOutput(void);

    HRESULT WriteAudioSamplesSync([in] void *buffer, [in] unsigned long sampleFrameCount, [out] unsigned long *sampleFramesWritten);

    HRESULT BeginAudioPreroll(void);
    HRESULT EndAudioPreroll(void);
    HRESULT ScheduleAudioSamples([in] void *buffer, [in] unsigned long sampleFrameCount, [in] BMDTimeValue streamTime, [in] BMDTimeScale timeScale, [out] unsigned long *sampleFramesWritten);

    HRESULT GetBufferedAudioSampleFrameCount([out] unsigned long *bufferedSampleFrameCount);
    HRESULT FlushBufferedAudioSamples(void);

    HRESULT SetAudioCallback([in] IDeckLinkAudioOutputCallback *theCallback);

    /* Output Control */

    HRESULT StartScheduledPlayback([in] BMDTimeValue playbackStartTime, [in] BMDTimeScale timeScale, [in] double playbackSpeed);
    HRESULT StopScheduledPlayback([in] BMDTimeValue stopPlaybackAtTime, [out] BMDTimeValue *actualStopTime, [in] BMDTimeScale timeScale);
    HRESULT IsScheduledPlaybackRunning([out] BOOL *active);
    HRESULT GetScheduledStreamTime([in] BMDTimeScale desiredTimeScale, [out] BMDTimeValue *streamTime, [out] double *playbackSpeed);
    HRESULT GetReferenceStatus([out] BMDReferenceStatus *referenceStatus);

    /* Hardware Timing */

    HRESULT GetHardwareReferenceClock([in] BMDTimeScale desiredTimeScale, [out] BMDTimeValue *hardwareTime, [out] BMDTimeValue *timeInFrame, [out] BMDTimeValue *ticksPerFrame);
    HRESULT GetFrameCompletionReferenceTimestamp([in] IDeckLinkVideoFrame *theFrame, [in] BMDTimeScale desiredTimeScale, [out] BMDTimeValue *frameCompletionTimestamp);
};

/* Interface IDeckLinkInput - Created by QueryInterface from IDeckLink. */

[
    object,
    uuid(AF22762B-DFAC-4846-AA79-FA8883560995),
    helpstring("Created by QueryInterface from IDeckLink.")
] interface IDeckLinkInput : IUnknown
{
    HRESULT DoesSupportVideoMode([in] BMDDisplayMode displayMode, [in] BMDPixelFormat pixelFormat, [in] BMDVideoInputFlags flags, [out] BMDDisplayModeSupport *result, [out] IDeckLinkDisplayMode **resultDisplayMode);
    HRESULT GetDisplayModeIterator([out] IDeckLinkDisplayModeIterator **iterator);

    HRESULT SetScreenPreviewCallback([in] IDeckLinkScreenPreviewCallback *previewCallback);

    /* Video Input */

    HRESULT EnableVideoInput([in] BMDDisplayMode displayMode, [in] BMDPixelFormat pixelFormat, [in] BMDVideoInputFlags flags);
    HRESULT DisableVideoInput(void);
    HRESULT GetAvailableVideoFrameCount([out] unsigned long *availableFrameCount);
    HRESULT SetVideoInputFrameMemoryAllocator([in] IDeckLinkMemoryAllocator *theAllocator);

    /* Audio Input */

    HRESULT EnableAudioInput([in] BMDAudioSampleRate sampleRate, [in] BMDAudioSampleType sampleType, [in] unsigned long channelCount);
    HRESULT DisableAudioInput(void);
    HRESULT GetAvailableAudioSampleFrameCount([out] unsigned long *availableSampleFrameCount);

    /* Input Control */

    HRESULT StartStreams(void);
    HRESULT StopStreams(void);
    HRESULT PauseStreams(void);
    HRESULT FlushStreams(void);
    HRESULT SetCallback([in] IDeckLinkInputCallback *theCallback);

    /* Hardware Timing */

    HRESULT GetHardwareReferenceClock([in] BMDTimeScale desiredTimeScale, [out] BMDTimeValue *hardwareTime, [out] BMDTimeValue *timeInFrame, [out] BMDTimeValue *ticksPerFrame);
};

/* Interface IDeckLinkVideoFrame - Interface to encapsulate a video frame; can be caller-implemented. */

[
    object,
    uuid(3F716FE0-F023-4111-BE5D-EF4414C05B17),
    local,
    helpstring("Interface to encapsulate a video frame; can be caller-implemented.")
] interface IDeckLinkVideoFrame : IUnknown
{
    long GetWidth(void);
    long GetHeight(void);
    long GetRowBytes(void);
    BMDPixelFormat GetPixelFormat(void);
    BMDFrameFlags GetFlags(void);
    HRESULT GetBytes([out] void **buffer);

    HRESULT GetTimecode([in] BMDTimecodeFormat format, [out] IDeckLinkTimecode **timecode);
    HRESULT GetAncillaryData([out] IDeckLinkVideoFrameAncillary **ancillary);
};

/* Interface IDeckLinkMutableVideoFrame - Created by IDeckLinkOutput::CreateVideoFrame. */

[
    object,
    uuid(69E2639F-40DA-4E19-B6F2-20ACE815C390),
    local,
    helpstring("Created by IDeckLinkOutput::CreateVideoFrame.")
] interface IDeckLinkMutableVideoFrame : IDeckLinkVideoFrame
{
    HRESULT SetFlags([in] BMDFrameFlags newFlags);

    HRESULT SetTimecode([in] BMDTimecodeFormat format, [in] IDeckLinkTimecode *timecode);
    HRESULT SetTimecodeFromComponents([in] BMDTimecodeFormat format, [in] unsigned char hours, [in] unsigned char minutes, [in] unsigned char seconds, [in] unsigned char frames, [in] BMDTimecodeFlags flags);
    HRESULT SetAncillaryData([in] IDeckLinkVideoFrameAncillary *ancillary);
    HRESULT SetTimecodeUserBits([in] BMDTimecodeFormat format, [in] BMDTimecodeUserBits userBits);
};

/* Interface IDeckLinkVideoFrame3DExtensions - Optional interface implemented on IDeckLinkVideoFrame to support 3D frames */

[
    object,
    uuid(DA0F7E4A-EDC7-48A8-9CDD-2DB51C729CD7),
    local,
    helpstring("Optional interface implemented on IDeckLinkVideoFrame to support 3D frames")
] interface IDeckLinkVideoFrame3DExtensions : IUnknown
{
    BMDVideo3DPackingFormat Get3DPackingFormat(void);
    HRESULT GetFrameForRightEye([out] IDeckLinkVideoFrame* *rightEyeFrame);
};

/* Interface IDeckLinkVideoInputFrame - Provided by the IDeckLinkVideoInput frame arrival callback. */

[
    object,
    uuid(05CFE374-537C-4094-9A57-680525118F44),
    local,
    helpstring("Provided by the IDeckLinkVideoInput frame arrival callback.")
] interface IDeckLinkVideoInputFrame : IDeckLinkVideoFrame
{
    HRESULT GetStreamTime([out] BMDTimeValue *frameTime, [out] BMDTimeValue *frameDuration, [in] BMDTimeScale timeScale);
    HRESULT GetHardwareReferenceTimestamp([in] BMDTimeScale timeScale, [out] BMDTimeValue *frameTime, [out] BMDTimeValue *frameDuration);
};

/* Interface IDeckLinkVideoFrameAncillary - Obtained through QueryInterface() on an IDeckLinkVideoFrame object. */

[
    object,
    uuid(732E723C-D1A4-4E29-9E8E-4A88797A0004),
    local,
    helpstring("Obtained through QueryInterface() on an IDeckLinkVideoFrame object.")
] interface IDeckLinkVideoFrameAncillary : IUnknown
{

    HRESULT GetBufferForVerticalBlankingLine([in] unsigned long lineNumber, [out] void **buffer);
    BMDPixelFormat GetPixelFormat(void);
    BMDDisplayMode GetDisplayMode(void);
};

/* Interface IDeckLinkAudioInputPacket - Provided by the IDeckLinkInput callback. */

[
    object,
    uuid(E43D5870-2894-11DE-8C30-0800200C9A66),
    local,
    helpstring("Provided by the IDeckLinkInput callback.")
] interface IDeckLinkAudioInputPacket : IUnknown
{
    long GetSampleFrameCount(void);
    HRESULT GetBytes([out] void **buffer);
    HRESULT GetPacketTime([out] BMDTimeValue *packetTime, [in] BMDTimeScale timeScale);
};

/* Interface IDeckLinkScreenPreviewCallback - Screen preview callback */

[
    object,
    uuid(B1D3F49A-85FE-4C5D-95C8-0B5D5DCCD438),
    local,
    helpstring("Screen preview callback")
] interface IDeckLinkScreenPreviewCallback : IUnknown
{
    HRESULT DrawFrame([in] IDeckLinkVideoFrame *theFrame);
};

/* Interface IDeckLinkGLScreenPreviewHelper - Created with CoCreateInstance(). */

[
    object,
    uuid(504E2209-CAC7-4C1A-9FB4-C5BB6274D22F),
    local,
    helpstring("Created with CoCreateInstance().")
] interface IDeckLinkGLScreenPreviewHelper : IUnknown
{

    /* Methods must be called with OpenGL context set */

    HRESULT InitializeGL(void);
    HRESULT PaintGL(void);
    HRESULT SetFrame([in] IDeckLinkVideoFrame *theFrame);
    HRESULT Set3DPreviewFormat([in] BMD3DPreviewFormat previewFormat);
};

/* Interface IDeckLinkDX9ScreenPreviewHelper - Created with CoCreateInstance(). */

[
    object,
    uuid(2094B522-D1A1-40C0-9AC7-1C012218EF02),
    local,
    helpstring("Created with CoCreateInstance().")
] interface IDeckLinkDX9ScreenPreviewHelper : IUnknown
{
    HRESULT Initialize([in] void *device);
    HRESULT Render([in] RECT *rc);
    HRESULT SetFrame([in] IDeckLinkVideoFrame *theFrame);
    HRESULT Set3DPreviewFormat([in] BMD3DPreviewFormat previewFormat);
};

/* Interface IDeckLinkNotificationCallback - DeckLink Notification Callback Interface */

[
    object,
    uuid(b002a1ec-070d-4288-8289-bd5d36e5ff0d),
    local,
    helpstring("DeckLink Notification Callback Interface")
] interface IDeckLinkNotificationCallback : IUnknown
{
    HRESULT Notify([in] BMDNotifications topic, [in] ULONGLONG param1, [in] ULONGLONG param2);
};

/* Interface IDeckLinkNotification - DeckLink Notification interface */

[
    object,
    uuid(0a1fb207-e215-441b-9b19-6fa1575946c5),
    local,
    helpstring("DeckLink Notification interface")
] interface IDeckLinkNotification : IUnknown
{
    HRESULT Subscribe([in] BMDNotifications topic, [in] IDeckLinkNotificationCallback *theCallback);
    HRESULT Unsubscribe([in] BMDNotifications topic, [in] IDeckLinkNotificationCallback *theCallback);
};

/* Interface IDeckLinkAttributes - DeckLink Attribute interface */

[
    object,
    uuid(ABC11843-D966-44CB-96E2-A1CB5D3135C4),
    local,
    helpstring("DeckLink Attribute interface")
] interface IDeckLinkAttributes : IUnknown
{
    HRESULT GetFlag([in] BMDDeckLinkAttributeID cfgID, [out] BOOL *value);
    HRESULT GetInt([in] BMDDeckLinkAttributeID cfgID, [out] LONGLONG *value);
    HRESULT GetFloat([in] BMDDeckLinkAttributeID cfgID, [out] double *value);
    HRESULT GetString([in] BMDDeckLinkAttributeID cfgID, [out] BSTR *value);
};

/* Interface IDeckLinkKeyer - DeckLink Keyer interface */

[
    object,
    uuid(89AFCAF5-65F8-421E-98F7-96FE5F5BFBA3),
    local,
    helpstring("DeckLink Keyer interface")
] interface IDeckLinkKeyer : IUnknown
{
    HRESULT Enable([in] BOOL isExternal);
    HRESULT SetLevel([in] unsigned char level);
    HRESULT RampUp([in] unsigned long numberOfFrames);
    HRESULT RampDown([in] unsigned long numberOfFrames);
    HRESULT Disable(void);
};

/* Interface IDeckLinkVideoConversion - Created with CoCreateInstance(). */

[
    object,
    uuid(3BBCB8A2-DA2C-42D9-B5D8-88083644E99A),
    local,
    helpstring("Created with CoCreateInstance().")
] interface IDeckLinkVideoConversion : IUnknown
{
    HRESULT ConvertFrame([in] IDeckLinkVideoFrame* srcFrame, [in] IDeckLinkVideoFrame* dstFrame);
};

/* Interface IDeckLinkDeviceNotificationCallback - DeckLink device arrival/removal notification callbacks */

[
    object,
    uuid(4997053B-0ADF-4CC8-AC70-7A50C4BE728F),
    helpstring("DeckLink device arrival/removal notification callbacks")
] interface IDeckLinkDeviceNotificationCallback : IUnknown
{
    HRESULT DeckLinkDeviceArrived([in] IDeckLink* deckLinkDevice);
    HRESULT DeckLinkDeviceRemoved([in] IDeckLink* deckLinkDevice);
};

/* Interface IDeckLinkDiscovery - DeckLink device discovery */

[
    object,
    uuid(CDBF631C-BC76-45FA-B44D-C55059BC6101),
    helpstring("DeckLink device discovery")
] interface IDeckLinkDiscovery : IUnknown
{
    HRESULT InstallDeviceNotifications([in] IDeckLinkDeviceNotificationCallback* deviceNotificationCallback);
    HRESULT UninstallDeviceNotifications(void);
};

/* Coclasses */

[
    uuid(1F2E109A-8F4F-49E4-9203-135595CB6FA5),
    helpstring("CDeckLinkIterator Class")
] coclass CDeckLinkIterator
{
    [default] interface IDeckLinkIterator;
};

[
    uuid(263CA19F-ED09-482E-9F9D-84005783A237),
    helpstring("CDeckLinkAPIInformation Class")
] coclass CDeckLinkAPIInformation
{
    [default] interface IDeckLinkAPIInformation;
};

[
    uuid(F63E77C7-B655-4A4A-9AD0-3CA85D394343),
    helpstring("CDeckLinkGLScreenPreviewHelper Class")
] coclass CDeckLinkGLScreenPreviewHelper
{
    [default] interface IDeckLinkGLScreenPreviewHelper;
};

[
    uuid(CC010023-E01D-4525-9D59-80C8AB3DC7A0),
    helpstring("CDeckLinkDX9ScreenPreviewHelper Class")
] coclass CDeckLinkDX9ScreenPreviewHelper
{
    [default] interface IDeckLinkDX9ScreenPreviewHelper;
};

[
    uuid(7DBBBB11-5B7B-467D-AEA4-CEA468FD368C),
    helpstring("CDeckLinkVideoConversion Class")
] coclass CDeckLinkVideoConversion
{
    [default] interface IDeckLinkVideoConversion;
};

[
    uuid(1073A05C-D885-47E9-B3C6-129B3F9F648B),
    helpstring("CDeckLinkDiscovery Class")
] coclass CDeckLinkDiscovery
{
    [default] interface IDeckLinkDiscovery;
};

};
