Inserting third-party filters
Inserting third-party filters
Third-party filters may be inserted in the preview, recording, or playback streams, in the order they were added to the list.
To simply add a filter to the graph, invoke ThirdPartyFilter_AddToList (tpf_AddToGraph,...) as shown in the example below.
If the file path of the filter is specified in the OptionalDLLPath parameter, the filter does not need to be registered with regsvr32.exe; it will be loaded directly from the .AX or .DLL file.
A third-party filter may also be used as a video source or an audio source when VideoSource = vs_ThirdPartyFilter (explained in the last paragraph below).
A filter can be inserted only ONCE in the same list.
To use a third-party filter, proceed as follows:
Overview
1. register the filter on the current platform, either manually from the command line with regsvr32, or programmatically with the ComObj unit's RegisterComServer function,
2. choose the location of the filter,
3. retrieve the CLSID of the filter,
4. declare the filter in TVideoGrabber before starting preview, capture or playback
5. the filter will now be used in the next preview, recording or playback.
- install and register the third-party filter
Let's suppose the filter to use is named "myfilter.ax": 1a. third-party filter registered from the command line - copy the myfilter.ax file into the windows/system32 or winnt/system32 directory
- click on "Start", "Run", then enter the following command line: regsvr32 c:/windows/system32/myfilter.ax
1b. third-party filter registered programmatically
- add the unit ComObj to the "uses" statement of the unit,
- copy the myfilter.ax file into the windows/system32 or winnt/system32 directory (e.g. using CopyFile),
- call RegisterComServer ('c:/windows/system32/myfilter.ax');
2. choose the location of the filter
within the preview, recording or playback graph. Find the right location according to the TThirdPartyFilterList location. This location tells ThirdPartyFilter_AddToList where to place the filter in the audio or video graph.
- retrieve the filter's CLSID
We have to know the CLSID of the filter. It can either be found in the filter's user guide or retrieved from the registry.
To retrieve the CLSID from the registry, proceed as follows: - run regedit
- at the top of the tree, click "edit"
- click "search"
- enter the file name of the filter (e.g. myfilter.ax).
- start searching.
-
when the search stops, locate the CLSID of the filter and copy the GUID key. It has to be passed as a string to the ThirdPartyFilter_AddToList function.
-
add the filter to the list
Call ThirdPartyFilter_AddToList with the CLSID of the filter.
E.g. to simply add a filter to the graph:
procedure TForm1.Button1Click (Sender: TObject);
const
CLSID_MYFILTER: String = "{463D645D-48F7-11D4-8464-0008C782A257}";
begin
if VideoGrabber1.ThirdPartyFilter_AddToList(tpf_AddToGraph, CLSID_MYFILTER, "", "my custom source filter", True, True) then begin
...
end;
end;
Alternatively it is possible to give the direct file path to the filter .AX or .DLL file, so it does not need to be registered with regsvr32.exe, e.g.:
procedure TForm1.Button1Click (Sender: TObject);
const
CLSID_MYFILTER: String = "{463D645D-48F7-11D4-8464-0008C782A257}";
begin
if VideoGrabber1.ThirdPartyFilter_AddToList(tpf_AddToGraph, CLSID_MYFILTER, "c:/myfolder.ax", "my custom source filter", True, True) then begin
...
end;
end;
- set the filter properties
- either interactively using ThirdPartyFilter_ShowDialog,
-
or programmatically using the OnThirdPartyFilterConnected event, which returns the filter's IUnknown interface when the graph starts. It is possible that some filters don't show the dialog if a graph is not running (preview, capture or playback).
-
Now the filter(s) will be automatically used
during the next preview / recording / playback until ThirdPartyFilter_ClearList is called or the filter is disabled with ThirdPartyFilter_Enable.
How to use third-party filters as a video or video+audio source
If the third-party filter needs to be used as a video source:
- set VideoSource = vs_ThirdPartyFilter
- invoke
VideoGrabber1.ThirdPartyFilter_AddToList(tpf_ThirdPartyVideoSource, CLSID of the video third-party filter, '', '...any label...', True, True);
- then invoke StartPreview or StartRecording
a) if this filter exposes an audio pin and AudioDeviceRendering or AudioRecording is enabled, the audio out will be used as audio source if AudioSource = as_Default
b) if the video filter does not expose an audio pin and audio is needed from another third-party filter, invoke:
VideoGrabber1.ThirdPartyFilter_AddToList(tpf_ThirdPartyAudioSource, CLSID of the audio third-party filter, '', '...any label...', True, True);
(if the video filter also exposes an audio pin, set AudioSource = as_UseExternalAudio to ignore the audio pin of the video filter and use the audio pin of the audio filter instead).
How to use a third-party filter as an audio source only
If the third-party filter needs to be used as an audio source:
- set VideoSource = vs_ThirdPartyFilter
- invoke
VideoGrabber1.ThirdPartyFilter_AddToList(tpf_ThirdPartyAudioSource, CLSID of the third-party filter, '', '...any label...', True, True);
- then invoke StartAudioRendering or StartAudioRecording
If the filter exposes an audio pin and AudioDeviceRendering or AudioRecording is enabled, the audio out will be used as audio source if AudioSource = as_Default