View Full Version : [Delphi] DShow filter


Sirber
19th October 2004, 01:40
Hi

I'm trying to create a DShow filter that will load when RealVideo (FOURCC: RV40) will be played. I started a project with Delphi 7 and DSPack. So far I have not much. I'm also very new to DirectShow.

I'd like to know what do I need to do to have the filter loaded.

Currently my code is:unit UMain;

interface
uses BaseClass, ActiveX, DirectShow9, Windows;

const
CLSID_MyClass : TGUID = '{18F161CA-DEE6-4751-B103-5D8A05EB6BCE}';

MyPinTypes : TRegPinTypes =
(clsMajorType: @MEDIATYPE_NULL;
clsMinorType: @MEDIASUBTYPE_NULL);

MyPins : array[0..1] of TRegFilterPins =
((strName: 'Input'; bRendered: FALSE; bOutput: FALSE; bZero: FALSE; bMany: FALSE; oFilter: nil; strConnectsToPin: nil; nMediaTypes: 1; lpMediaType: @MyPinTypes),
(strName: 'Output'; bRendered: FALSE; bOutput: TRUE; bZero: FALSE; bMany: FALSE; oFilter: nil; strConnectsToPin: nil; nMediaTypes: 1; lpMediaType: @MyPinTypes));

type
THFE = class(TBCTransInPlaceFilter)
// Overrides the PURE virtual Transform of CTransInPlaceFilter base class
// This is where the "real work" is done by altering *pSample.
// We do the Null transform by leaving it alone.
function Transform(Sample: IMediaSample): HRESULT; override;

// We accept any input type. We'd return S_FALSE for any we didn't like.
function CheckInputType(mtin: PAMMediaType): HRESULT; override;

end;

implementation

{ THFE }

function THFE.CheckInputType(mtin: PAMMediaType): HRESULT;
begin
//if IsEqualGUID(mtin.majortype, MEDIATYPE_Video) and IsEqualGUID(mtin.subtype, MEDIASUBTYPE_RGB24) then result := S_OK else result := S_False;

result := S_OK;
end;

function THFE.Transform(Sample: IMediaSample): HRESULT;
begin
result := NOERROR;
end;

initialization
TBCClassFactory.CreateFilter(THFE, 'RealVideo Decoder Config', CLSID_MyClass,
CLSID_LegacyAmFilterCategory, MERIT_DO_NOT_USE, 2, @MyPins);
end.

Thanks!!! :D

dragongodz
19th October 2004, 01:47
[EDIT]

bad example. so removed. will try to find a better one. :)

Sirber
19th October 2004, 01:55
lol :D

I don't need to manage any datas, just to be able to shot my GUI from MPC when playing a RV40 clip.

dragongodz
19th October 2004, 01:59
ok well i found this
http://www.dsp-worx.de/

directshow filters for mp3 and mod source available in left panel.
sorry i dont use delphi. hope its of some use anyway. :)

Sirber
19th October 2004, 02:05
Thanks for the effort :D, but I think it's a too big exemple to start with :(

Sirber
19th October 2004, 02:47
I made some progress. I still have to force the load of the filter with MPC, but now I can click on the name to access the property page. It still don't load, but it's a start :)

if someone wants to play with it, here's the current code:

http://www.detritus.qc.ca/hfe/HFE_DShow.rar

Note: This "filter" will be opensource once completed.

Sirber
19th October 2004, 03:54
I succeded to display something when I click the name. How can make this filter autoload? I can handle the rest I think :)

dcoder
19th October 2004, 07:41
you must change the merit to MERIT_PREFERED + X. X depeneds on where you want to place the Filter. In case you want it before the RealVideo Decoder, you should give it a number which is by one higher than the RealVideo Decoder.

btw, i´ve updated the BaseClasses in the last days. There was a Bug when connecting YUV MediaTypes. Make sure you´re using the latest CVS or your Filter might crash.

Sirber
19th October 2004, 12:55
Cool!

Gonna try tonight :D