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 ds filter , but still not
able to get. I have attached the source code of my filter. Can you
please look at this issue and give your feedback?
I am not able to find any sample custom filter for windows mobile 5.0.
Is it possible to get atlease one simple filter for windows mobile
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 - Invert Filter", // 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,MEDIASUBTYPE_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 to filter
NULL, // Connects to pin
1, // Number of types
&sudOpPinTypes }; // Pin details
AMOVIESETUP_FILTER sudFruitFilter=
{
&CLSID_FruitFilter, // Filter CLSID
L"ABC - Fruit Source Filter", // String name
MERIT_DO_NOT_USE, // Filter merit
1, // Number pins
&sudOpPin // Pin details
};
// COM global table of objects in this dll
CFactoryTemplate g_Templates[] = {
{ L"ABC - Fruit Source Filter"
, &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 Source Filter"), 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
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I suspect your problem is because of a slight difference between DirectShow
on desktop Windows and Windows Mobile. Add the following function to your
#ifdef UNDER_CE
LPAMOVIESETUP_FILTER CSampleGrabber::GetSetupData() {return
(LPAMOVIESETUP_FILTER) &sudSampleGrabber; }
#endif
Without this function defined the DirectShow registration doesn't work, but
the dll registration does.
Gary Daniels
Windows CE Multimedia and Graphics
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
Post by sureshHi,
I am facing following couple of problems with ds filter. Can you
please give your comment on these issues.
Thanks,
Issue1: Problem with Registering filter
Normally we use the following function to register the filter.
STDAPI DllRegisterServer(void)
{
return AMovieDllRegisterServer( );
}
This function should register the dll with filter informations 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 the filter information (pins,
media types etc). At the same time the function always returns failure
on windows mobile. Someone says it is not supported on windows mobile.
I have found that `IFilterMapper` interface can used to register the
information of filter, so changed the function as mentioned below. Is
it the right thing to do?
STDAPI DllRegisterServer(void)
{
HRESULT hr = AMovieDllRegisterServer( );
IFilterMapper *pFm = 0;
hr = pFm->RegisterFilter()
hr = pFm->RegisterPin()
hr = pFm->RegisterPinType()
pFm->Release();
}
Issue2: Not able to use Registered filter.
We use "CoCreateFunction(CLSID_NEEDFILTER)" function to get the
registered filter. But it always returns the error "Error in the dll"
on emulator. I have used some other functions
(LoadLibrary ,GetProcAddress ) to make sure that the dll got
registered properly. Any solution for this issue?- Hide quoted text -
- Show quoted text -