Re: Problem with Registering filter on windows mobile

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Dear Gary Daniels,

Thank you for your update.

I tried to use `Sample Grabber` directshow filter on windows mobile
5.0, but I got the same issue (crash in AddRef() ) as mentioned in my
earlier discussion.

Issue: Crashing when the CSampleGrabber constructor is called and it
calls the CBaseRenderer constructor. If I replace DECLARE_IUNKNOWN in
SampleGrabber.h with the expanded macro then I see it is crashing in
AddRef because GetOwner() is returning 0x000001 andthen crashing on
GetOwner()->AddRef().

It looks like few other people are also facing the same issue.

e.g
1. http://www.itpost.cn/en/1951/posts/195130814.shtml
2.
http://groups.google.co.in/group/microsoft.public.pocketpc.developer/browse_thread/thread/73d9baf31bf9f877/18de5059b33ec9c3?lnk=st&q=Sample+Grabber+windows+mobile&rnum=2&hl=en#18de5059b33ec9c3

3. http://www.eggheadcafe.com/forumarchives/win32programmerdirectxaudio/sep2005/post23723142.asp

Please let me know if you have any comment on link(1) & link(2).

Is it possible for you to provide the solution for our problem? It
will be really useful for everyone who develops a ds filter windows
mobile 5.0.

Awaiting for your response,
Thanks & Regards,





On Feb 22, 12:09 am, "Gary Daniels [MS]"
<gary...@xxxxxxxxxxxxxxxxxxxx> wrote:
If you install the desktop DirectX SDK, the sample grabberfiltershipped
with that will register and work onwindowsmobile. The only modification
necessary is the addition of GetSetupData. Sample filters are shipped withWindowsCE, but not with theWindowsMobileSDK yet. You could download the
evaluation version ofWindowsCE to look at them.

AMovieDllRegisterServer has been deprecated, try using
AMovieDllRegisterServer2 instead. It will use the setup data to register thefilter, so you don't need to call RegisterFilter, RegisterPins, etc.

Gary DanielsWindowsCE Multimedia and Graphics

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.

"suresh" <raja_t_...@xxxxxxxxxxxxx> wrote in message

news:1172068577.301310.224640@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



Dear Gary Daniels,

Thanks you so much for looking at this issue.

I have added the function which you had given, but it was not getting
called while invoking AMovieDllRegisterServer() function, But I am
getting the crash in AddRef(void) function . Following is the stack
trace of the crash.

SourceFilter.dll!CFruitFilter::AddRef(void) Line: 37, Byte Offsets:
0x10
SourceFilter.dll!GetInterface(IUnknown* pUnk = 0x00120630, void** ppv
= 0x2611f198) Line: 213, Byte Offsets: 0x28
SourceFilter.dll!CBaseFilter::NonDelegatingQueryInterface(_GUID& riid
= {...}, void** ppv = 0x00000000) Line: 319, Byte
SourceFilter.dll!CFruitFilter::NonDelegatingQueryInterface(_GUID& riid
= {...}, void** ppv = 0x2611f198) Line: 224, Byte
SourceFilter.dll!CClassFactory::CreateInstance(IUnknown* pUnkOuter =
0x2611f198, _GUID& riid = {...},
SourceFilter.dll!AMovieDllRegisterServer(void) Line: 410, Byte
Offsets: 0x130 C++

Can you able to make out whether I am doing any mistake here ? For
last 2 weeks, I have been trying to create dsfilter, but still not
able to get. I have attached the source code of myfilter. Can you
please look at this issue and give your feedback?

I am not able to find any sample customfilterforwindowsmobile5.0.
Is it possible to get atlease one simplefilterforwindowsmobile
5.0?

Thanks & regards,
Awaiting for your kind response...

*.h File:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class CFruitFilter: public CSource, public IFileSourceFilter
{
public:
static CUnknown * WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT
*phr);
OLECHAR m_szFileName[_MAX_PATH];
private:
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
return GetOwner()->QueryInterface(riid,ppv);
};
STDMETHODIMP_(ULONG) AddRef()
{
return GetOwner()->AddRef();
};
STDMETHODIMP_(ULONG) Release()
{
return GetOwner()->Release();
};
STDMETHODIMP GetCurFile(LPOLESTR * ppszFileName,AM_MEDIA_TYPE
*pmt);
STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE
__RPC_FAR *pmt);
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **
ppv);

CFruitFilter(LPUNKNOWN lpunk, HRESULT *phr);

LPAMOVIESETUP_FILTER GetSetupData();
};
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++
.cpp file
// SourceFilter.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include <windows.h>
#include <commctrl.h>

#include <streams.h>
#include <olectl.h>
#include <initguid.h>
#include "js97uuid.h"
#include "fFilter.h"
#include "fTxtStrm.h"

extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
BOOL a= DllEntryPoint((HINSTANCE)(hModule), ul_reason_for_call,
lpReserved);

return TRUE;
}

STDAPI DllRegisterServer()
{

hr = AMovieDllRegisterServer1( );
//return hr;
hr = CoCreateInstance( CLSID_FilterMapper
, NULL
, CLSCTX_INPROC_SERVER
, IID_IFilterMapper
, (void **)&pFm );

if(FAILED(hr))
return hr;

hr = pFm->RegisterFilter(
CLSID_FruitFilter,
L"ABC - InvertFilter", // name shown to the user
MERIT_DO_NOT_USE);

hr = pFm->RegisterPin(CLSID_FruitFilter,L"Output", FALSE, TRUE,
FALSE, FALSE, CLSID_NULL,NULL);
hr = pFm-
RegisterPinType(CLSID_FruitFilter,L"Output",MEDIATYPE_JS97Text,MEDIASUBTY­PE_NULL);

return hr;
}

//
// DllUnregisterServer
//
STDAPI DllUnregisterServer()
{
TCHAR achTemp[MAX_PATH];
OLECHAR szCLSID[CHARS_IN_GUID];

// Convert GUID to a string
HRESULT hr = StringFromGUID2( MEDIATYPE_JS97Text, szCLSID,
CHARS_IN_GUID );

// Delete Key in registry
wsprintf( achTemp, L"Media Type\\%ls", szCLSID);
RegDeleteKey(HKEY_CLASSES_ROOT, (LPCTSTR)achTemp);

return AMovieDllUnregisterServer( );

}

const AMOVIESETUP_MEDIATYPE sudOpPinTypes =
{
&MEDIATYPE_JS97Text, // Major type
&MEDIASUBTYPE_NULL // Minor type
};

const AMOVIESETUP_PIN sudOpPin =
{
L"Text", // Pin string name
FALSE, // Is it rendered
TRUE, // Is it an output
FALSE, // Can we have none
FALSE, // Can we have many
&CLSID_NULL, // Connects tofilter
NULL, // Connects to pin
1, // Number of types
&sudOpPinTypes }; // Pin details

AMOVIESETUP_FILTER sudFruitFilter=
{
&CLSID_FruitFilter, //FilterCLSID
L"ABC - Fruit SourceFilter", // String name
MERIT_DO_NOT_USE, //Filtermerit
1, // Number pins
&sudOpPin // Pin details
};

// COM global table of objects in this dll

CFactoryTemplate g_Templates[] = {
{ L"ABC - Fruit SourceFilter"
, &CLSID_FruitFilter
, CFruitFilter::CreateInstance
, NULL
, &sudFruitFilter }
};
int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);

// CreateInstance
//
CUnknown * WINAPI CFruitFilter::CreateInstance(LPUNKNOWN lpunk,
HRESULT *phr)
{
CUnknown *punk = new CFruitFilter(lpunk, phr);
if (punk == NULL) {
*phr = E_OUTOFMEMORY;
}
return punk;

}

// Constructor
CFruitFilter::CFruitFilter(LPUNKNOWN lpunk, HRESULT *phr) :
CSource(NAME("Fruit SourceFilter"), lpunk, CLSID_FruitFilter)
{
CAutoLock cAutoLock(&m_cStateLock);

new CFruitStreamText(phr, this, L"Text!");
if (m_paStreams[0] == NULL) {
*phr = E_OUTOFMEMORY;
return;
}
}

// NonDelegatingQueryInterface

STDMETHODIMP CFruitFilter::NonDelegatingQueryInterface(REFIID riid,
void ** ppv)
{
CheckPointer(ppv,E_POINTER);
//CAutoLock lock(&m_Lock);

// Do we have this interface
if (riid == IID_IFileSourceFilter)
return GetInterface((IFileSourceFilter *) this, ppv);

return CSource::NonDelegatingQueryInterface(riid, ppv);
}

#include <string.h>

STDMETHODIMP CFruitFilter::Load(LPCOLESTR pszFileName,const
AM_MEDIA_TYPE *pmt)
{

wcscpy(m_szFileName, pszFileName);
return NOERROR;
}

STDMETHODIMP CFruitFilter::GetCurFile(LPOLESTR *
ppszFileName,AM_MEDIA_TYPE *pmt)
{
CheckPointer(ppszFileName, E_POINTER);
*ppszFileName = (LPOLESTR)
CoTaskMemAlloc(sizeof(WCHAR) * (1+lstrlenW(m_szFileName)));
if (*ppszFileName != NULL) {
wcscpy(*ppszFileName, m_szFileName);
}

if(pmt) {
ZeroMemory(pmt, sizeof(*pmt));
pmt->majortype = MEDIATYPE_NULL;
pmt->subtype = MEDIASUBTYPE_NULL;
}
return S_OK;
}

#ifdef UNDER_CE
LPAMOVIESETUP_FILTER CFruitFilter::GetSetupData() {return
(LPAMOVIESETUP_FILTER) &sudFruitFilter; }
#endif
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

On Feb 17, 2:50 am, "Gary Daniels [MS]" <gary...@xxxxxxxxxxxxxxxxxxxx>
wrote:
I suspect your problem is because of a slight difference between
DirectShow
on desktopWindowsandWindowsMobile. Add the following function to your
source file (this particular version is from the sample grabberfilter):

#ifdef UNDER_CE
LPAMOVIESETUP_FILTER CSampleGrabber::GetSetupData() {return
(LPAMOVIESETUP_FILTER) &sudSampleGrabber; }
#endif

Without this function defined theDirectShowregistration doesn't work,
but
the dll registration does.

Gary Daniels
WindowsCE Multimedia and Graphics

This posting is provided "AS IS" with no warranties, and confers no
rights.
You assume all risk for your use.

"suresh" <raja_t_...@xxxxxxxxxxxxx> wrote in message

news:1171545243.704675.212990@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi,

I am facing following couple of problems with dsfilter. Can you
please give your comment on these issues.
Thanks,

Issue1: Problem with Registeringfilter
Normally we use the following function to register thefilter.
STDAPI DllRegisterServer(void)
{
return AMovieDllRegisterServer( );
}

This function should register the dll withfilterinformations that
are provided in struct `AMOVIESETUP_FILTER`.

But when I call this function, only the dll informations are getting
registered ( clsid & dll name) but not thefilterinformation (pins,
media types etc). At the same time the function always returns failure
onwindowsmobile. Someone says it is not supported onwindowsmobile.

I have found that `IFilterMapper` interface can used to register the
information offilter, so changed the function as mentioned below. Is
it the right thing to do?

STDAPI

...

read more »- Hide quoted text -

- Show quoted text -


.



Relevant Pages

  • Re: Problem with Registering filter on windows mobile
    ... I tried to use `Sample Grabber` directshow filter on windows mobile ... It will use the setup data to register thefilter, so you don't need to call RegisterFilter, RegisterPins, etc. ... getting the crash in AddReffunction. ... STDMETHODIMP GetCurFile(LPOLESTR * ppszFileName,AM_MEDIA_TYPE ...
    (microsoft.public.windowsce.app.development)
  • RE: Cannot turn on automatic updates nor use windows update
    ... I couldn't register the "Wuaueng.dll". ... "Install the ActiveX control required to view the website. ... gives me an error message saying that "Windows cannot find 'scf'....". ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Why RosAsm Breaks on a large number of symbols
    ... focus - the point of interest was whether you could duplicate windows ... in memory, and kernel mode memory is something you don't want to waste too ... how long it takes before the child process terminates. ... By "register preservation", I mean "make sure that, on exit of your ...
    (alt.lang.asm)
  • Re: Problem with Registering filter on windows mobile
    ... If you install the desktop DirectX SDK, the sample grabber filter shipped ... with that will register and work on windows mobile. ... but not with the Windows Mobile SDK yet. ... STDMETHODIMP GetCurFile(LPOLESTR * ppszFileName,AM_MEDIA_TYPE ...
    (microsoft.public.windowsce.app.development)
  • Re: Office 2003 went into a very limited function Mode
    ... When I first got the machines no ... | registration for Windows XP or Windows Office 2003 came up with the ... | preloaded software so I had assumed that all activication was done by ... | Did not register the first time. ...
    (microsoft.public.office.setup)