A null-transform filter helps retrieve the raw camera frame buffer as well as perform necessary conversion in the buffer data.
Compilation
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;
}
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
Hello
ReplyDeleteI wanna download the source code that you have posted but seems that your monthly traffic limit it´s reached so I can´t. Can you send me a copy of the source code to my email or could you tell me where I can find it to download?
I also want a copy of the DirectShow: Null Renderer that you made.
Thanks a lot
P.S: Sorry for my poor english
I forgot to write my email: superja.yo@gmail.com
ReplyDeleteHi
ReplyDeleteThanks for informing me about the broken links. I have updated the link. Please try again. Let me know if you have any other problems. :)
Hi,
ReplyDeleteI 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
Hi,
ReplyDeleteYou 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
Thanks for the info.
ReplyDeleteThe 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.
Hi,
ReplyDeleteThis 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));
Hi,
ReplyDeleteThank 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