Code Repo    |     RSS
MD's Technical Sharing



Wednesday, May 28, 2008

DirectShow: Null Transform filter for Windows CE

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 (\DX90SDK\Samples\C++\DirectShow\Filters\NullNull)

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

Read More »

Sunday, May 18, 2008

Windows Server 2003 under Virtual PC: Sound card

Virtual PC emulates Sound Blaster 16 (ISA slot) but Windows Server 2003 does not have the driver for it. To get the sound card working, the sound card driver must be copied from Windows XP and install manually in Driver Manager.

Download the driver here
Read More »

Thursday, May 15, 2008

Windows 3.1 under Virtual PC

To get Windows 3.1 run on Microsoft Virtual PC, the necessary drivers for the hardware emulated by Virtual PC must be installed. Except for Sound Blaster 16, for which Windows 3.1 may already have the driver, other drivers must be downloaded and installed manually

Sound Blaster 16 (ISA Slot)
S3 video card (support up to 1024x768 screen resolution and 256 colors)
DEC Ethernet card

As for network connection, the following 2 components are needed:

TCP/IP stack
WinSock (copy and paste to C:\Windows or C:\Windows\System when prompted for missing DLL)

The last version of Internet Explorer that works on Windows 3.1 is Internet Explorer 5.0 16-bit edition.

Download all of the above here
Read More »

Saturday, May 10, 2008

Virtual PC 2007 slowness when running on laptop

Virtual PC 2007 may respond slowly when running on some computers. To fix this, edit the default configuration file options.xml in C:\Documents and Settings\Username\Application Data\Microsoft\Virtual PC by adding the following line:

<virtual_machines>
enable_idle_thread type="boolean">true/enable_idle_thread>
</virtual_machines>

under the virtual_network section and before the window section.

On a side note, the configuration file can be safely deleted- a new file will be created the next time to start Virtual PC.
Read More »

Friday, May 9, 2008

Virtual PC 2007: VM Additions

Virtual PC 2007 does not officially support DOS, Windows 3.1 and Linux so the VM Additions disk image is not available on these operating systems. However, these images taken from Virtual PC 2004 will still work under Virtual PC 2007.

To retrieve the VM Additions for these unsupported OS, install Virtual PC 2004 and copy the files from C:\Program Files\Microsoft Virtual PC\Virtual Machine Additions.
Read More »