Probelm with Custom DS filter on Windows Mobile 5.0

Hi,

I have created "NULL Render" custom filter for windows mobile 5.0. Please note that I used the following code which is given by Gary Daniels[MS] in one of the forum.

When I call AMovieDllRegisterServer2() I crash, into disassembly.If I replace DECLARE_IUNKNOWN in the following example with the expanded macro then I see it is crashing in AddRef because GetOwner() is returning 0x000001 and then crashing on
GetOwner()->AddRef().

I try to run this on emulator & Dell Axim 51v PDA and I get the same crash.

I would really appreciate any ideas you have to solve this issue.

Regards,
Raj

IDE Used: Visual Studio 2005
Project: Win32 smart device application(DLL)


LIBRARIES ===
You need to link to these libraries in order to compile.
TARGETLIBS are strmiids.lib, uuid.lib, ole32.lib, mmtimer.lib, and
coredll.lib
SOURCELIBS is strmbase.lib


End LIBRARIES ====


NULLREND.def ==========
// These exports are necessary in order for com to register the filter
LIBRARY nullrend.dll
EXPORTS
DllMain PRIVATE
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE


End NULLREND.DEF ===================


NULLREND.CPP ====================================
#include <windows.h>
#include <streams.h>
#include <initguid.h>


// this is needed for COM to register the component with RegSvr
extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
STDAPI DllRegisterServer() { return AMovieDllRegisterServer2( TRUE ); }
STDAPI DllUnregisterServer() { return AMovieDllRegisterServer2( FALSE ); }
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{ return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved); }


// Define your filter guid here
DEFINE_GUID(CLSID_NullRend,
0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);


// Fill in media type information below, this information is used when
registering the filter with dshow
const AMOVIESETUP_MEDIATYPE sudPinTypes =
{ &MEDIATYPE_NULL, &MEDIASUBTYPE_NULL };
const AMOVIESETUP_PIN sudPins =
{ L"Null", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, 1, &sudPinTypes };
const AMOVIESETUP_FILTER sudNULL =
{ &CLSID_NullRend, L"NullRend", MERIT_DO_NOT_USE, 1, &sudPins };


// this filter is based off of the base renderer, so it has 1 input pin and
no output pins.
// It's currently a no-op renderer which will connect to anything
(CheckMediaType always
// succeeds and DoRenderSample does nothing with the sample.
class CNullRend : public CBaseRenderer
{
public:
DECLARE_IUNKNOWN;


CNullRend(LPUNKNOWN pUnk, HRESULT *phr) :
CBaseRenderer(CLSID_NullRend, NAME("CNullRend"), pUnk, phr) {}


static CUnknown* WINAPI CreateInstance(LPUNKNOWN punk, HRESULT *phr)
{ return
new CNullRend(punk, phr); }
HRESULT CheckMediaType(const CMediaType *pMT) { return S_OK; }
// This is called for each media sample received.
HRESULT DoRenderSample(IMediaSample *pMediaSample) { return S_OK; }
// this is necessary for automatic registration of the filter when doing
a regsvr32.
AMOVIESETUP_FILTER *GetSetupData() { return((AMOVIESETUP_FILTER
*)&sudNULL); }


private:

};


CFactoryTemplate g_Templates[] =
{ L"NullRend", &CLSID_NullRend, CNullRend::CreateInstance, NULL, &sudNULL };
int g_cTemplates = 1;

End NULLREND.cpp =================================



Answer this question

Probelm with Custom DS filter on Windows Mobile 5.0

  • Tony Vaughan

    Hi,

    I have created "NULL Render" custom filter for windows mobile 5.0. Please note that I used the following code which is given by Gary Daniels[MS] in one of the forum.

    When I call AMovieDllRegisterServer2() I crash, into disassembly.If I replace DECLARE_IUNKNOWN in the following example with the expanded macro then I see it is crashing in AddRef because GetOwner() is returning 0x000001 and then crashing on
    GetOwner()->AddRef().

    I try to run this on emulator & Dell Axim 51v PDA and I get the same crash.

    I would really appreciate any ideas you have to solve this issue.

    Regards,
    Raj

    IDE Used: Visual Studio 2005
    Project: Win32 smart device application(DLL)


    LIBRARIES ===
    You need to link to these libraries in order to compile.
    TARGETLIBS are strmiids.lib, uuid.lib, ole32.lib, mmtimer.lib, and
    coredll.lib
    SOURCELIBS is strmbase.lib


    End LIBRARIES ====


    NULLREND.def ==========
    // These exports are necessary in order for com to register the filter
    LIBRARY nullrend.dll
    EXPORTS
    DllMain PRIVATE
    DllGetClassObject PRIVATE
    DllCanUnloadNow PRIVATE
    DllRegisterServer PRIVATE
    DllUnregisterServer PRIVATE


    End NULLREND.DEF ===================


    NULLREND.CPP ====================================
    #include <windows.h>
    #include <streams.h>
    #include <initguid.h>


    // this is needed for COM to register the component with RegSvr
    extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
    STDAPI DllRegisterServer() { return AMovieDllRegisterServer2( TRUE ); }
    STDAPI DllUnregisterServer() { return AMovieDllRegisterServer2( FALSE ); }
    BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
    { return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved); }


    // Define your filter guid here
    DEFINE_GUID(CLSID_NullRend,
    0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);


    // Fill in media type information below, this information is used when
    registering the filter with dshow
    const AMOVIESETUP_MEDIATYPE sudPinTypes =
    { &MEDIATYPE_NULL, &MEDIASUBTYPE_NULL };
    const AMOVIESETUP_PIN sudPins =
    { L"Null", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, 1, &sudPinTypes };
    const AMOVIESETUP_FILTER sudNULL =
    { &CLSID_NullRend, L"NullRend", MERIT_DO_NOT_USE, 1, &sudPins };


    // this filter is based off of the base renderer, so it has 1 input pin and
    no output pins.
    // It's currently a no-op renderer which will connect to anything
    (CheckMediaType always
    // succeeds and DoRenderSample does nothing with the sample.
    class CNullRend : public CBaseRenderer
    {
    public:
    DECLARE_IUNKNOWN;


    CNullRend(LPUNKNOWN pUnk, HRESULT *phr) :
    CBaseRenderer(CLSID_NullRend, NAME("CNullRend"), pUnk, phr) {}


    static CUnknown* WINAPI CreateInstance(LPUNKNOWN punk, HRESULT *phr)
    { return
    new CNullRend(punk, phr); }
    HRESULT CheckMediaType(const CMediaType *pMT) { return S_OK; }
    // This is called for each media sample received.
    HRESULT DoRenderSample(IMediaSample *pMediaSample) { return S_OK; }
    // this is necessary for automatic registration of the filter when doing
    a regsvr32.
    AMOVIESETUP_FILTER *GetSetupData() { return((AMOVIESETUP_FILTER
    *)&sudNULL); }


    private:

    };


    CFactoryTemplate g_Templates[] =
    { L"NullRend", &CLSID_NullRend, CNullRend::CreateInstance, NULL, &sudNULL };
    int g_cTemplates = 1;

    End NULLREND.cpp =================================


  • Probelm with Custom DS filter on Windows Mobile 5.0