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

// Enumeration Mapping

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

[
    object,
    uuid(065A0F6C-C508-4D0D-B919-F5EB0EBFC96B),
    local,
    helpstring("Created by QueryInterface from IDeckLink.")
] interface IDeckLinkOutput_v11_4 : IUnknown
{
    HRESULT DoesSupportVideoMode ([in] BMDVideoConnection connection /* If a value of 0 is specified, the caller does not care about the connection */, [in] BMDDisplayMode requestedMode, [in] BMDPixelFormat requestedPixelFormat, [in] BMDSupportedVideoModeFlags flags, [out] BMDDisplayMode* actualMode, [out] BOOL* supported);
    HRESULT GetDisplayMode ([in] BMDDisplayMode displayMode, [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);	// Use of IDeckLinkVideoFrameAncillaryPackets is preferred
    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_v11_4 - Created by QueryInterface from IDeckLink. */

[
    object,
    uuid(2A88CF76-F494-4216-A7EF-DC74EEB83882),
    helpstring("Created by QueryInterface from IDeckLink.")
] interface IDeckLinkInput_v11_4 : IUnknown
{
    HRESULT DoesSupportVideoMode ([in] BMDVideoConnection connection /* If a value of 0 is specified, the caller does not care about the connection */, [in] BMDDisplayMode requestedMode, [in] BMDPixelFormat requestedPixelFormat, [in] BMDSupportedVideoModeFlags flags, [out] BOOL* supported);
    HRESULT GetDisplayMode ([in] BMDDisplayMode displayMode, [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);
};
