DirectShow: Null Transform filter for Windows CE

0.00 avg. rating (0% score) - 0 votes
A null-transform filter helps retrieve the raw camera frame buffer as well as perform necessary conversion in the buffer data.

Compilation

Most of the source codes are taken from the NullNull sample of the DirectShow for Windows XP SDK (DX90SDKSamplesC++DirectShowFiltersNullNull)

The class-library solution must be built in release mode and must export itself via COM using a module definition file. It can either be deployed by Visual Studio by setting COM Self Register to TRUE or by using regsvrce.exe

To prevent compile errors about string types, go to Project Properties>Configuration Properties>C/C++>Language and change Treat wchar_t as built-in type to No
To control which media type the filter will accept and which will be rejected, modify the function CheckInputType. Return S_OK to accept the media and S_FALSE to reject.

HRESULT CheckInputType(const CMediaType* mtIn)
{
if (mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_YV12)
return S_OK;
else
return S_FALSE;
}


Usage

The DLL exports 2 interfaces:

DEFINE_GUID(CLSID_NullNull, 0xba1864f4, 0x6988, 0x4e86, 0xb2, 0x8f, 0x60, 0x33, 0x5b, 0xae, 0x85, 0x5f);
DEFINE_GUID(IID_ITransformFilter, 0x6b652fff, 0x11fe, 0x4fce, 0x92, 0xad, 0x02, 0x66, 0xb5, 0xd7, 0xc7, 0x8f);

CLSID_NullNull identifies the filter when added to the graph whereas IID_ITransformFilter defines an interface providing a call-back function which will invokes when the camera data is available. To create a new GUID, use the Visual Studio menu Tools->Create GUID

To add the filter to the graph, use:

CComPtr
<IBaseFilter> pNullTransform;
hr
= pNullTransform.CoCreateInstance(CLSID_NullNull);
hr
= pFilterGraph->AddFilter(pNullTransform, L“NullNull”);

To get the callback function when the camera data is available. CameraSampleReceived will be called when a frame is received from the camera

hr = pNullTransform->QueryInterface(IID_ITransformFilter, (void**)&pTransform);
hr
= pTransform->SetCallback(&CameraSampleReceived);

HRESULT CameraSampleReceived(IMediaSample *pSample, int width, int height)
{
}
 
The source code can be download here

See also

0.00 avg. rating (0% score) - 0 votes
ToughDev

ToughDev

A tough developer who likes to work on just about anything, from software development to electronics, and share his knowledge with the rest of the world.

5 thoughts on “DirectShow: Null Transform filter for Windows CE

  • November 11, 2011 at 9:10 pm
    Permalink

    Hi,
    I compiled your sample using the headers/libs from a Wince5 platform builder eval I downloaded.
    The compilation went fine but upon deployment/registering, the pin info is not found in the HKEY_CLASSES_ROOT/CLSID/GUID_OF_FILTER key.

    Am I missing something in the project settings?

    Thanks,
    dragan

  • November 11, 2011 at 9:13 pm
    Permalink

    Hi,

    You will need to COM-register the DLL during deployment. There is a settings called "register output" (or something like that) in the project settings. If that doesn't work, try to find a tool that helps you call DllRegisterServer on a given DLL.

    Some device may have built-in security settings that prevents registering of unknown DLLs. You need to turn this off. Check this article http://msdn.microsoft.com/en-us/library/bb416353.aspx

  • November 11, 2011 at 10:13 pm
    Permalink

    Thanks for the info.
    The registration works with both Visual Studio and regsvrce.exe and the GUID is added to the HKEY_CLASSES_ROOT/CLSID path but the filter info (the Pins) key is not added automatically.
    Should the Pins be in another place in the registry ?
    Also AmovieDllRegisterServer2 (TRUE) returns S_FALSE.

    I will look into the link you provided to see if the security is the problem.

  • November 11, 2011 at 10:51 pm
    Permalink

    Hi,

    This null transform filter is working fine in many of my Windows CE apps. Try using Visual Studio Tools > Create GUID to generate a different GUID for the transform filter. Then, in Visual Studio 2008, use Tools>Device Security Manager and set the lowest level of security possible.

    If it is installed properly, the following code should always return S_OK when adding the filter to the graph:

    CComPtr pNull;
    HRESULT hr = pNull.CoCreateInstance(CLSID_NullNull));
    hr = pFilterGraph->AddFilter(pNull, L"Null Transform"));
    hr = pNull->QueryInterface(IID_ITransformFilter, (void**) &g_pNull));

  • November 11, 2011 at 11:24 pm
    Permalink

    Hi,
    Thank you very much for the help. I finally created another project and added just strmbase.lib and strmiids.lib to the linker input field in project settings.
    This seams to fix the registration problem…although I don't know why.

    Thanks again,
    dragan

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>