/* -LICENSE-START-
** Copyright (c) 2018 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-
*/
/* DeckLinkAPI_v10_11.idl */

// Enumeration Mapping

/* Enum BMDDisplayModeSupport_v10_11 - Output mode supported flags */

typedef [v1_enum] enum	_BMDDisplayModeSupport_v10_11 {
    bmdDisplayModeNotSupported_v10_11                               = 0,
    bmdDisplayModeSupported_v10_11,
    bmdDisplayModeSupportedWithConversion_v10_11
} BMDDisplayModeSupport_v10_11;

/* Enum BMDDuplexMode - Duplex for configurable ports */

typedef [v1_enum] enum	_BMDDuplexMode_v10_11 {
    bmdDuplexModeFull_v10_11                                        = /* 'fdup' */ 0x66647570,
    bmdDuplexModeHalf_v10_11                                        = /* 'hdup' */ 0x68647570
} BMDDuplexMode_v10_11;

/* Enum BMDDeckLinkConfigurationID - DeckLink Configuration ID */

typedef [v1_enum] enum	_BMDDeckLinkConfigurationID_v10_11 {

    /* Video Input/Output Integers */

    bmdDeckLinkConfigDuplexMode_v10_11                              = /* 'dupx' */ 0x64757078,

} BMDDeckLinkConfigurationID_v10_11;

/* Enum BMDDeckLinkAttributeID - DeckLink Attribute ID */

typedef [v1_enum] enum	_BMDDeckLinkAttributeID_v10_11 {

    /* Flags */

    BMDDeckLinkSupportsDuplexModeConfiguration_v10_11               = /* 'dupx' */ 0x64757078,
    BMDDeckLinkSupportsHDKeying_v10_11                              = /* 'keyh' */ 0x6B657968,

    /* Integers */

    BMDDeckLinkPairedDevicePersistentID_v10_11                      = /* 'ppid' */ 0x70706964,
    BMDDeckLinkSupportsFullDuplex_v10_11                            = /* 'fdup' */ 0x66647570,

} BMDDeckLinkAttributeID_v10_11;

typedef [v1_enum] enum	_BMDDeckLinkStatusID_v10_11 {
	bmdDeckLinkStatusDuplexMode_v10_11								= /* 'dupx' */ 0x64757078,
} BMDDeckLinkStatusID_v10_11;

/* Enum BMDDuplexStatus - Duplex status of the device */

typedef [v1_enum] enum	_BMDDuplexStatus_v10_11 {
    bmdDuplexFullDuplex_v10_11                                      = /* 'fdup' */ 0x66647570,
    bmdDuplexHalfDuplex_v10_11                                      = /* 'hdup' */ 0x68647570,
    bmdDuplexSimplex_v10_11                                         = /* 'splx' */ 0x73706C78,
    bmdDuplexInactive_v10_11                                        = /* 'inac' */ 0x696E6163
} BMDDuplexStatus_v10_11;

// Forward Declarations

interface IDeckLinkConfiguration_v10_11;
interface IDeckLinkAttributes_v10_11;
interface IDeckLinkNotification_v10_11;

/* Interface IDeckLinkConfiguration_v10_11 - DeckLink Configuration interface */

[
    object,
    uuid(EF90380B-4AE5-4346-9077-E288E149F129),
    local, 
    helpstring("DeckLink Configuration interface")
] interface IDeckLinkConfiguration_v10_11 : IUnknown
{
    HRESULT SetFlag([in] BMDDeckLinkConfigurationID cfgID, [in] BOOL value);
    HRESULT GetFlag([in] BMDDeckLinkConfigurationID cfgID, [out] BOOL *value);
    HRESULT SetInt([in] BMDDeckLinkConfigurationID cfgID, [in] LONGLONG value);
    HRESULT GetInt([in] BMDDeckLinkConfigurationID cfgID, [out] LONGLONG *value);
    HRESULT SetFloat([in] BMDDeckLinkConfigurationID cfgID, [in] double value);
    HRESULT GetFloat([in] BMDDeckLinkConfigurationID cfgID, [out] double *value);
    HRESULT SetString([in] BMDDeckLinkConfigurationID cfgID, [in] BSTR value);
    HRESULT GetString([in] BMDDeckLinkConfigurationID cfgID, [out] BSTR *value);
    HRESULT WriteConfigurationToPreferences(void);
};

/* Interface IDeckLinkAttributes_v10_11 - DeckLink Attribute interface */

[
    object,
    uuid(ABC11843-D966-44CB-96E2-A1CB5D3135C4),
    local, 
    helpstring("DeckLink Attribute interface")
] interface IDeckLinkAttributes_v10_11 : 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 IDeckLinkOutput_v10_11 - DeckLink output interface. */

[
    object,
    uuid(CC5C8A6E-3F2F-4B3A-87EA-FD78AF300564),
    local,
    helpstring("Created by QueryInterface from IDeckLink.")
] interface IDeckLinkOutput_v10_11 : IUnknown
{
    HRESULT DoesSupportVideoMode([in] BMDDisplayMode displayMode, [in] BMDPixelFormat pixelFormat, [in] BMDVideoOutputFlags flags, [out] BMDDisplayModeSupport_v10_11 *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] int width, [in] int height, [in] int 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 int *bufferedFrameCount);

    /* Audio Output */

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

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

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

    HRESULT GetBufferedAudioSampleFrameCount([out] unsigned int *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_v10_11 - DeckLink input interface. */

[
    object,
    uuid(AF22762B-DFAC-4846-AA79-FA8883560995),
    helpstring("Created by QueryInterface from IDeckLink.")
] interface IDeckLinkInput_v10_11 : IUnknown
{
    HRESULT DoesSupportVideoMode([in] BMDDisplayMode displayMode, [in] BMDPixelFormat pixelFormat, [in] BMDVideoInputFlags flags, [out] BMDDisplayModeSupport_v10_11 *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 int *availableFrameCount);
    HRESULT SetVideoInputFrameMemoryAllocator([in] IDeckLinkMemoryAllocator *theAllocator);

    /* Audio Input */

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

    /* Input Control */

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

    /* Hardware Timing */

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

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

[
    object,
    uuid(270587DA-6B7D-42E7-A1F0-6D853F581185),
    helpstring("Created by QueryInterface from IDeckLink.")
] interface IDeckLinkEncoderInput_v10_11 : IUnknown
{
    HRESULT DoesSupportVideoMode([in] BMDDisplayMode displayMode, [in] BMDPixelFormat pixelFormat, [in] BMDVideoInputFlags flags, [out] BMDDisplayModeSupport_v10_11 *result, [out] IDeckLinkDisplayMode **resultDisplayMode);
    HRESULT GetDisplayModeIterator([out] IDeckLinkDisplayModeIterator **iterator);

    /* Video Input */

    HRESULT EnableVideoInput([in] BMDDisplayMode displayMode, [in] BMDPixelFormat pixelFormat, [in] BMDVideoInputFlags flags);
    HRESULT DisableVideoInput(void);
    HRESULT GetAvailablePacketsCount([out] unsigned int *availablePacketsCount);
    HRESULT SetMemoryAllocator([in] IDeckLinkMemoryAllocator *theAllocator);

    /* Audio Input */

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

    /* Input Control */

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

    /* Hardware Timing */

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

/* Interface IDeckLinkNotification_v10_11 - DeckLink Notification interface */

[
    object,
    uuid(0A1FB207-E215-441B-9B19-6FA1575946C5),
    local,
    helpstring("DeckLink Notification interface")
] interface IDeckLinkNotification_v10_11 : IUnknown
{
    HRESULT Subscribe([in] BMDNotifications topic, [in] IDeckLinkNotificationCallback *theCallback);
    HRESULT Unsubscribe([in] BMDNotifications topic, [in] IDeckLinkNotificationCallback *theCallback);
};

importlib("stdole2.tlb");

[
    uuid(87D2693F-8D4A-45C7-B43F-10ACBA25E68F),
    helpstring("CDeckLinkIterator_v10_11 Class")
] coclass CDeckLinkIterator_v10_11
{
    [default] interface IDeckLinkIterator;
};

[
    uuid(652615D4-26CD-4514-B161-2FD5072ED008),
    helpstring("CDeckLinkDiscovery_v10_11 Class")
] coclass CDeckLinkDiscovery_v10_11
{
    [default] interface IDeckLinkDiscovery;
};
