/* -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-
*/
import "unknwn.idl";
import "strmif.idl";

/**
 * This interface contains methods shared between the capture and render
 * filters. It is not accessed directly, but through the IKsDeckLinkCapture and
 * IKsDeckLinkRender interfaces.
 */
[
	uuid(15022C2F-9D0E-4477-A66A-2D82F696BC1C),
	version( 1.0 ),
	helpstring( "DeckLink Kernel Streaming library" ),
	control
]
library KsDeckLink
{
	[v1_enum] enum KsDeckLinkDisplayMode
	{
		/* SD Modes */

		ksDeckLinkModeNTSC = /* 'ntsc' */ 0x6E747363,
		ksDeckLinkModeNTSC2398 = /* 'nt23' */ 0x6E743233,	// 3:2 pulldown
		ksDeckLinkModePAL = /* 'pal ' */ 0x70616C20,
		ksDeckLinkModeNTSCp = /* 'ntsp' */ 0x6E747370,
		ksDeckLinkModePALp = /* 'palp' */ 0x70616C70,

		/* HD 1080 Modes */

		ksDeckLinkModeHD1080p2398 = /* '23ps' */ 0x32337073,
		ksDeckLinkModeHD1080p24 = /* '24ps' */ 0x32347073,
		ksDeckLinkModeHD1080p25 = /* 'Hp25' */ 0x48703235,
		ksDeckLinkModeHD1080p2997 = /* 'Hp29' */ 0x48703239,
		ksDeckLinkModeHD1080p30 = /* 'Hp30' */ 0x48703330,
		ksDeckLinkModeHD1080i50 = /* 'Hi50' */ 0x48693530,
		ksDeckLinkModeHD1080i5994 = /* 'Hi59' */ 0x48693539,
		ksDeckLinkModeHD1080i6000 = /* 'Hi60' */ 0x48693630,	// N.B. This _really_ is 60.00 Hz.
		ksDeckLinkModeHD1080p50 = /* 'Hp50' */ 0x48703530,
		ksDeckLinkModeHD1080p5994 = /* 'Hp59' */ 0x48703539,
		ksDeckLinkModeHD1080p6000 = /* 'Hp60' */ 0x48703630,	// N.B. This _really_ is 60.00 Hz.

		/* HD 720 Modes */

		ksDeckLinkModeHD720p50 = /* 'hp50' */ 0x68703530,
		ksDeckLinkModeHD720p5994 = /* 'hp59' */ 0x68703539,
		ksDeckLinkModeHD720p60 = /* 'hp60' */ 0x68703630,

		/* 2K DCI Modes */

		ksDeckLinkMode2kDCI2398 = /* '2d23' */ 0x32643233,
		ksDeckLinkMode2kDCI24 = /* '2d24' */ 0x32643234,
		ksDeckLinkMode2kDCI25 = /* '2d25' */ 0x32643235,

		/* 4K Modes */

		ksDeckLinkMode4K2160p2398 = /* '4k23' */ 0x346B3233,
		ksDeckLinkMode4K2160p24 = /* '4k24' */ 0x346B3234,
		ksDeckLinkMode4K2160p25 = /* '4k25' */ 0x346B3235,
		ksDeckLinkMode4K2160p2997 = /* '4k29' */ 0x346B3239,
		ksDeckLinkMode4K2160p30 = /* '4k30' */ 0x346B3330,
		ksDeckLinkMode4K2160p50 = /* '4k50' */ 0x346B3530,
		ksDeckLinkMode4K2160p5994 = /* '4k59' */ 0x346B3539,
		ksDeckLinkMode4K2160p60 = /* '4k60' */ 0x346B3630,

		/* 4K DCI Modes */

		ksDeckLinkMode4kDCI2398 = /* '4d23' */ 0x34643233,
		ksDeckLinkMode4kDCI24 = /* '4d24' */ 0x34643234,
		ksDeckLinkMode4kDCI25 = /* '4d25' */ 0x34643235,

		/* Special Modes */

		ksDeckLinkModeAuto = /* 'auto' */ 0x6175746F,
		ksDeckLinkModeUnknown = /* 'iunk' */ 0x69756E6B
	};

	[v1_enum] enum KsDeckLinkPixelFormat
	{
		ksDeckLinkFormat8BitYUV = /* '2vuy' */ 0x32767579,
		ksDeckLinkFormat10BitYUV = /* 'v210' */ 0x76323130,
		ksDeckLinkFormat8BitBGRA = /* 'BGRA' */ 0x42475241,
		ksDeckLinkFormat10BitRGB = /* 'r210' */ 0x72323130,	// Big-endian RGB 10-bit per component with SMPTE video levels (64-960). Packed as 2:10:10:10
	};

	[
		object,
		uuid(8A0B4C61-7827-4c79-84E8-AEC1D8DB1ACD),
		pointer_default(unique)
	]
	interface IKsDeckLink : IUnknown
	{
		/**
		 * Set/Get the structure format used for the video information. The
		 * parameter can either be FORMAT_VideoInfo or FORMAT_VideoInfo2.
		 */
		HRESULT SetDataFormat( [in] REFGUID dataFormat );
		HRESULT GetDataFormat( [out] GUID *dataFormat );

		/**
		 * Returns the device's persistent ID. This ID will not change regardless
		 * of unplugging and replugging the device.
		 */
		HRESULT GetPersistentID( [out] DWORD *persistentId );

		/**
		* Returns the device's topological ID. This ID will can identify a device
		* when the persistent ID is not available. Unplugging and replugging the
		* device may cause this ID to change.
		*/
		HRESULT GetTopologicalID([out] DWORD *topologicalId);

		/**
		 * VideoInfoHeader provides no way to differentiate between some mode
		 * pairs (such as 1080i50 and 1080p25), where the only difference is
		 * whether the mode is interlaced or not. This setting tells the device
		 * whether those modes should be treated as progressive or interlaced.
		 *
		 * This option has no affect on VideoInfoHeader2, because it contains all
		 * the information needed to tell the modes apart.
		 */
		HRESULT SetVideoInfoHeaderPrefersProgressive( [in] BOOL progressive );
		HRESULT GetVideoInfoHeaderPrefersProgressive( [out] BOOL *progressive );
	};

	/* Capture filter interfaces */
	[
		object,
		uuid(CDEF8D04-B36A-430d-ACC5-D38910261413),
		pointer_default(unique)
	]
	interface IKsDeckLinkCapture : IKsDeckLink
	{
		/**
		 * Enable automatic mode detection. This should be done before you
		 * query the list of data ranges.
		 */
		HRESULT EnableFormatDetection( );

		/**
		 * Blocks waiting for a mode change, or the specified number of milliseconds
		 * to pass.
		 */
		HRESULT GetFormatChangeNotification( [in] DWORD milliseconds );

		/**
		 * Disables automatic mode detection
		 */
		HRESULT DisableFormatDetection( );

		/**
		 * Contrain the modes enuperated by IAMStreamConfig to those that match the
		 * provided details.
		 */
		HRESULT SetOverride( [in] enum KsDeckLinkDisplayMode displayMode, [in] enum KsDeckLinkPixelFormat pixelFormat );

		/**
		 * Returns the display mode/pixel format that is overriding the supported mode list.
		 * If no override is set, the function will return S_FALSE.
		 */
		HRESULT GetOverride( [out] enum KsDeckLinkDisplayMode* displayMode, [out] enum KsDeckLinkPixelFormat* pixelFormat );

		/**
		 * Allow all supported modes to be enumerated by IAMStreamConfig.
		 */
		HRESULT ClearOverride( );

		/**
		 * Returns true if the device supports the ksDeckLinkModeAuto value being passed to
		 * IKsDeckLinkCapture::SetOverride(...)
		 */
		HRESULT DoesSupportAutoOverride( [out] BOOL* supported );
	};

	/* Render filter interfaces */
	[
		object,
		uuid(AB480A38-1186-4c11-8815-9F088CF949AF),
		pointer_default(unique)
	]
	interface IKsDeckLinkRender : IKsDeckLink
	{
	};

	/* Property pages */
	[
		uuid(C4D3CE08-505A-4747-BE12-95CE01D39CC0),
		helpstring( "Video Capture Property Page Class" )
	]
	coclass KsDeckLinkVideoCapturePage
	{
		[default] interface IPropertyPage;
	};

	[
		uuid(E7422C96-9108-4894-921C-9BDCF20A9255),
		helpstring( "Audio Capture Property Page Class" )
	]
	coclass KsDeckLinkAudioCapturePage
	{
		[default] interface IPropertyPage;
	};
};
