Unit DSUtil

Description

Methods & usefull Class for Direct Show programming.

Classes, Interfaces and Objects

NameDescription
Class EDirectShowException DirectShow Exception class
Class EDSPackException  
Interface IDivXFilterInterface Interface to control the Divx Decoder filter. TODO: discover the last function ...
Class TBaseFilter This class can store a custom filter as a moniker within the dfm file.
Class TEnumMediaType This class can retrieve all media types from a pin, a file or an IEnumMediaTypes interface.
Class TFilterList This class can enumerate all filters in a FilterGraph.
Class TMediaType Uses TMediaType to configure media types. This class have a special property editor. See TSampleGrabber
Class TPersistentMemory For internal use. This class is designed to store a custom memory stream with a form. It is the ancestor of TBaseFilter.
Class TPinList Helper class to enumerate pins on a filter.
Class TSysDevEnum Usefull class to enumerate availables filters. See "Filter Enumerator" sample.

Functions and Procedures

Overview

function AddGraphToRot(Graph: IFilterGraph; out ID: integer): HRESULT;
function CheckDSError(HR: HRESULT): HRESULT;
procedure CopyMediaType(pmtTarget: PAMMediaType; pmtSource: PAMMediaType);
function CreateAudioMediaType(pwfx: PWaveFormatEx; pmt: PAMMediaType; bSetFormat: boolean): HRESULT;
function CreateMediaType(pSrc: PAMMediaType): PAMMediaType;
procedure DeleteMediaType(pmt: PAMMediaType);
function FCC(str: String): Cardinal;
function FOURCCMap(Fourcc: Cardinal): TGUID;
procedure FreeAndNil(var Obj);
procedure FreeMediaType(mt: PAMMediaType);
function GetBitmapFormatSize(const Header: TBitmapInfoHeader): Integer;
function GetBitmapSize(const pHeader: TBITMAPINFOHEADER): DWORD;
function GetErrorString(hr: HRESULT): string;
function GetEventCodeDef(code: longint): string;
function GetFOURCC(Fourcc: Cardinal): string;
function GetMediaTypeDescription(MediaType: TAMMediaType): string;
function GetSourceRectFromMediaType(const MediaType: TAMMediaType): TRect;
function HaveFilterPropertyPage(Filter: IBaseFilter; PropertyPage: TPropertyPage = ppDefault): boolean;
function IntToTimeCode(x : longint): TDVDTimeCode;
function MAKEFOURCC(ch0, ch1, ch2, ch3: char): Cardinal;
function MiliSecToRefTime(Milisec: int64): Int64;
function ProfileFromGUID(const GUID: TGUID): TWMPofiles8;
function RefTimeToMiliSec(RefTime: Int64): Cardinal;
function RemoveGraphFromRot(ID: integer): HRESULT;
function ShowFilterPropertyPage(parent: THandle; Filter: IBaseFilter; PropertyPage: TPropertyPage = ppDefault): HRESULT;
function ShowPinPropertyPage(parent: THandle; Pin: IPin): HRESULT;
function StretchRect(R, IR: TRect): TRect;

Description

function AddGraphToRot(Graph: IFilterGraph; out ID: integer): HRESULT;

Enable Graphedit to connect with a filter graph.
The application must register the filter graph instance in the Running Object Table (ROT). The ROT is a globally accessible look-up table that keeps track of running objects. Objects are registered in the ROT by moniker. To connect to the graph, GraphEdit searches the ROT for monikers whose display name matches a particular format: !FilterGraph X pid Y.
Graph: a graph interface (IGraphBuilder, IFilterGraph, IFilterGraph2).
ID: return the ROT identifier.

function CheckDSError(HR: HRESULT): HRESULT;

raise EDirectShowException exception if failed.

procedure CopyMediaType(pmtTarget: PAMMediaType; pmtSource: PAMMediaType);

The CopyMediaType function copies an AM_MEDIA_TYPE structure into another structure, including the format block. This function allocates the memory for the format block. If the pmtTarget parameter already contains an allocated format block, a memory leak will occur. To avoid a memory leak, call FreeMediaType before calling this function.

function CreateAudioMediaType(pwfx: PWaveFormatEx; pmt: PAMMediaType; bSetFormat: boolean): HRESULT;

The CreateAudioMediaType function initializes a media type from a TWAVEFORMATEX structure. If the bSetFormat parameter is TRUE, the method allocates the memory for the format block. If the pmt parameter already contains an allocated format block, a memory leak will occur. To avoid a memory leak, call FreeMediaType before calling this function. After the method returns, call FreeMediaType again to free the format block.

function CreateMediaType(pSrc: PAMMediaType): PAMMediaType;

The CreateMediaType function allocates a new AM_MEDIA_TYPE structure, including the format block. This also comes in useful when using the IEnumMediaTypes interface so that you can copy a media type, you can do nearly the same by creating a TMediaType class but as soon as it goes out of scope the destructor will delete the memory it allocated (this takes a copy of the memory).

procedure DeleteMediaType(pmt: PAMMediaType);

General purpose function to delete a heap allocated TAM_MEDIA_TYPE structure which is useful when calling IEnumMediaTypes.Next as the interface implementation allocates the structures which you must later delete the format block may also be a pointer to an interface to release.

function FCC(str: String): Cardinal;

Convert a FCC (Four Char Codes) to Cardinal. A FCC identifie a media type.

function FOURCCMap(Fourcc: Cardinal): TGUID;

The FOURCCMap function provides conversion between GUID media subtypes and old-style FOURCC 32-bit media tags. In the original Microsoft® Windows® multimedia APIs, media types were tagged with 32-bit values created from four 8-bit characters and were known as FOURCCs. Microsoft DirectShow® media types have GUIDs for the subtype, partly because these are simpler to create (creation of a new FOURCC requires its registration with Microsoft). Because FOURCCs are unique, a one-to-one mapping has been made possible by allocating a range of 4,000 million GUIDs representing FOURCCs. This range is all GUIDs of the form: XXXXXXXX-0000-0010-8000-00AA00389B71.

procedure FreeAndNil(var Obj);

Frees an object reference and replaces the reference with Nil. (Delphi4 compatibility)

procedure FreeMediaType(mt: PAMMediaType);

The FreeMediaType function frees the format block in an AM_MEDIA_TYPE structure. Use this function to free just the format block. To delete the AM_MEDIA_TYPE structure, call DeleteMediaType.

function GetBitmapFormatSize(const Header: TBitmapInfoHeader): Integer;

The mechanism for describing a bitmap format is with the BITMAPINFOHEADER This is really messy to deal with because it invariably has fields that follow it holding bit fields, palettes and the rest. This function gives the number of bytes required to hold a VIDEOINFO that represents it. This count includes the prefix information (like the rcSource rectangle) the BITMAPINFOHEADER field, and any other colour information on the end. WARNING If you want to copy a BITMAPINFOHEADER into a VIDEOINFO always make sure that you use the HEADER macro because the BITMAPINFOHEADER field isn't right at the start of the VIDEOINFO (there are a number of other fields), CopyMemory(HEADER(pVideoInfo),pbmi,sizeof(BITMAPINFOHEADER));

function GetBitmapSize(const pHeader: TBITMAPINFOHEADER): DWORD;

Retrieve the Size needed to store a bitmat

function GetErrorString(hr: HRESULT): string;

The GetErrorString function retrieves the error message for a given return code, using the current language setting.

function GetEventCodeDef(code: longint): string;

Return a string explaining a filter graph event.

function GetFOURCC(Fourcc: Cardinal): string;

Find the four-character codes wich identifi a codec.

function GetMediaTypeDescription(MediaType: TAMMediaType): string;

This function examine a media type and return a short description like GraphEdit.

function GetSourceRectFromMediaType(const MediaType: TAMMediaType): TRect;

Retrieve original source rectangle from a TAM_Media_type record.

function HaveFilterPropertyPage(Filter: IBaseFilter; PropertyPage: TPropertyPage = ppDefault): boolean;

Return true if the specified property page is provided by the Filter.

function IntToTimeCode(x : longint): TDVDTimeCode;

deprecated, convert a Time code event to TDVD_TimeCode record.

function MAKEFOURCC(ch0, ch1, ch2, ch3: char): Cardinal;

Create the four-character codes from a Cardinal value.

function MiliSecToRefTime(Milisec: int64): Int64;

Convert milisecondes to 100 nano sec unit

function ProfileFromGUID(const GUID: TGUID): TWMPofiles8;

 

function RefTimeToMiliSec(RefTime: Int64): Cardinal;

Convert 100 nano sec unit to milisecondes.

function RemoveGraphFromRot(ID: integer): HRESULT;

Disable Graphedit to connect with your filter graph.
ID: identifier provided by the AddGraphToRot method.

function ShowFilterPropertyPage(parent: THandle; Filter: IBaseFilter; PropertyPage: TPropertyPage = ppDefault): HRESULT;

Show the property page associated with the Filter. A property page is one way for a filter to support properties that the user can set. Many of the filters provided with DirectShow support property pages, they are intended for debugging purposes, and are not recommended for application use. In most cases the equivalent functionality is provided through a custom interface on the filter. An application should control these filters programatically, rather than expose their property pages to users.

function ShowPinPropertyPage(parent: THandle; Pin: IPin): HRESULT;

Show the property page associated with the Pin.
See also: ShowFilterPropertyPage.

function StretchRect(R, IR: TRect): TRect;

TODO -oMichael Andersen: make documentation

Types

NameDescription
TPropertyPage Property pages.
See also: ShowFilterPropertyPage, HaveFilterPropertyPage.
TVORBISFORMAT Ogg Vorbis
TWMPofiles8 WMF9 Utils

Constants

NameDescription
CLSID_div3 div3
CLSID_DIV3_ DIV3
CLSID_div4 div4
CLSID_DIV4_ DIV4
CLSID_div5 div5
CLSID_DIV5_ DIV5
CLSID_div6 div6
CLSID_DIV6_ DIV6
CLSID_DIVX divx
CLSID_DIVXCodec  
CLSID_DivXPropertiesPage  
CLSID_DivX_ dvx1
CLSID_DivX_U DIVX
CLSID_DivX__U DVX1
CLSID_dx50 dx50
CLSID_DX50_ DX50
CLSID_OggDSAboutPage 77983549-ffda-4a88-b48f-b924e8d1f01c
CLSID_OggMux 8cae96b7-85b1-4605-b23c-17ff5262b296
CLSID_OggMuxPropPage {AB97AFC3-D08E-4e2d-98E0-AEE6D4634BA4
CLSID_OggSplitPropPage {078C3DAA-9E58-4d42-9E1C-7C8EE79539C5
CLSID_OggSplitter f07e245f-5a1f-4d1e-8bff-dc31d84a55ab
CLSID_VorbisDec 02391f44-2767-4e6a-a484-9b47b506f3a4
CLSID_VorbisEnc {889EF574-0656-4B52-9091-072E52BB1B80
CLSID_VorbisEncPropPage {c5379125-fd36-4277-a7cd-fab469ef3a2f
FORMAT_VorbisFormat 6bddfa7e-9f22-46a9-ab5e-884eff294d9f
IID_IIDivXFilterInterface  
IID_IMoniker  
IID_IPersistStream  
IID_IPropertyBag  
IID_ISpecifyPropertyPages  
MAX_TIME  
MEDIASUBTYPE_DIVX DIVX
MEDIASUBTYPE_MP42 MS Mepg4 DMO
MEDIASUBTYPE_Ogg {D2855FA9-61A7-4db0-B979-71F297C17A04
MEDIASUBTYPE_Vorbis cddca2d5-6d75-4f98-840e-737bedd5c63b
MEDIASUBTYPE_VOXWARE VoxWare MetaSound
MiliSecPerDay  
WMProfiles8  

Author

Henri Gourvest: hgourvest@progdigy.com

Created

Mar 14, 2002

Last Modified

Feb 21, 2002


Generated by DIPasDoc 0.8.0 on Sun 1 Jun 2003 23:53:07