⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grabberds.h

📁 Handle Videos in Forms Delphi... Play/Stop/Pause/FullScreen
💻 H
字号:

// Begin

/*
	grabberds.h - header file with declaration of interfaces for capturing video frames
	during media file rendering or video source capture

	(c) 2005 - 2007 Aleksei Kazantsev (ajk.xyz@gmail.com)

	VERSION 1.0

	last-modified: 2007/05/19

	It is free software and is distributed under
	the terms of the GNU Lesser General Public License Version 2.1.

	This software comes with ABSOLUTELY NO WARRANTY.
*/

//
#pragma once
//

//
#ifndef SAFE_RELEASE
#define SAFE_RELEASE(x) { if(x) { x->Release(); x = NULL; } }
#endif
//

//
interface IVideoGrabber;
//

//
typedef HRESULT (__fastcall *vg_callback)(IVideoGrabber *vg, void *buffer);
typedef IVideoGrabber video_grabber;
//

//
interface IVideoGrabber
{
 // Destroys the object
 virtual void __fastcall Release() = 0;
 
 // Enables video subtype (all disabled by default)
 // Supported subtypes: MEDIASUBTYPE_RGB32, MEDIASUBTYPE_ARGB32,
 // MEDIASUBTYPE_RGB24, MEDIASUBTYPE_RGB555, MEDIASUBTYPE_RGB565,
 // MEDIASUBTYPE_YUY2, MEDIASUBTYPE_UYVY, MEDIASUBTYPE_YV12, MEDIASUBTYPE_NV12
 virtual void __fastcall EnableSubtype(const GUID *subtype, BOOL enable = TRUE) = 0;
 
 // Gets current video subtype
 virtual const GUID* __fastcall GetSubtype() = 0;
 
 // Returns the frame width
 virtual DWORD __fastcall GetCX() = 0;
 
 // Returns the frame height
 virtual DWORD __fastcall GetCY() = 0;
 
 // Returns the aspect ratio X
 virtual DWORD __fastcall GetAspectX() = 0;
 
 // Returns the aspect ratio Y
 virtual DWORD __fastcall GetAspectY() = 0;
 
 // Renders the selected file without running it
 virtual HRESULT __fastcall RenderMediaFile(LPCWSTR szFile, BOOL enable_audio = FALSE) = 0;
 
 // Renders the video capture source without running it
 // is szName is NULL - renders the first available video capture source
 virtual HRESULT __fastcall RenderVideoCaptureSource(LPCWSTR szName) = 0;
 
 // Sets the callback function
 virtual void __fastcall SetCallback(vg_callback callback) = 0;
 
 // Sets the user object to retrieve it later with GetUserObject
 virtual void __fastcall SetUserObject(void *obj) = 0;
 
 // Get the user object set by SetUserObject
 virtual void* __fastcall GetUserObject() = 0;
 
 // Gets the IMediaControl interface without incrementing its reference count
 virtual IUnknown* __fastcall GetMediaControl() = 0;
 
 // Enables or disables repeating of the media file
 virtual void __fastcall EnableLoop(BOOL bEnable) = 0;
 
 // Suggests the video format for video capture source pin
 // - call this function before call to RenderVideoCaptureSource
 // - fill subtype with GUID_NULL for default video format suggestion
 virtual void __fastcall SuggestVideoCaptureFormat(const GUID *subtype, SIZE sz, float fps) = 0;
 
 // Gets the video format for video capture source pin
 // - call this function after call to RenderVideoCaptureSource
 virtual HRESULT __fastcall GetVideoCaptureFormat(GUID *subtype, SIZE *sz, float *fps) = 0;
 
 // TRUE if filter graph contains video renderer
 virtual BOOL __fastcall IsVideo() = 0;
 
 // TRUE if filter graph contains audio renderer
 virtual BOOL __fastcall IsAudio() = 0;
};
//

//
extern "C"
HRESULT __fastcall VideoGrabberCreate(IVideoGrabber **grabber);
//

// Start enumeration of video capture sources
// - *ppEnumMoniker will actually hold the reference to IEnumMoniker interface
extern "C"
HRESULT __fastcall EnumVideoCaptureSourcesStart(IUnknown **ppEnumMoniker);
//

// Retrieve the name of the next available video capture source
// S_OK - success
// S_FALSE - no more sources available
// - this function calls VariantInit on pName,
//   so pName should not contain any valid VARIANT before call to this function
// - if the function succeeds the pName will hold the BSTR value
// - *ppMoniker will hold the reference to IMoniker interface
//   (you may pass NULL if IMoniker is not required)
extern "C"
HRESULT __fastcall EnumVideoCaptureSourcesNext(IUnknown *pEnumMoniker, VARIANT *pName,
											IUnknown **ppMoniker);
//

// End the enumeration of video capture sources
extern "C"
void __fastcall EnumVideoCaptureSourcesEnd(IUnknown *pEnumMoniker);
//

// Starts the enumeration of the video formats for video capture source pin
// szVideoCaptureSource - friendly name of the video capture source
// nFormats - will hold format count for capture pin of szVideoCaptureSource
// ppAMStreamConfig - will hold the reference to IAMStreamConfig interface
extern "C"
HRESULT __fastcall EnumVideoCaptureFormatsStart(LPWSTR szVideoCaptureSource,
											 IUnknown **ppAMStreamConfig,
											 DWORD *nFormats);
//

// Requests video format for video capture source pin by format index
// pAMStreamConfig - pointer returned as a result of EnumVideoCaptureFormatsStart call
// iFormat - format index
// subtype - video subtype for the pin
// szMin - minimal available size of the video frame
// szMax - maximal available size of the video frame
// szStep - step for adjustment video size from szMin to szMax
// fpsMin - minimal available framerate for capturing video
// fpsMax - maximal available framerate for capturing video
// szDef - default video size
// fpsDef - default framerate
// S_OK - if the requested format is the default format
// S_FALSE - if the requested format is not the default format
extern "C"
HRESULT __fastcall EnumVideoCaptureFormatsByIndex(IUnknown *pAMStreamConfig, DWORD iFormat,
											   GUID *subtype,
											   SIZE *szMin, SIZE *szMax, SIZE *szStep,
											   float *fpsMin, float *fpsMax,
											   SIZE *szDef, float *fpsDef);
										
//

// Ends the enumeration of the video capture formats
extern "C"
void __fastcall EnumVideoCaptureFormatsEnd(IUnknown *pAMStreamConfig);
//

// End

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -