PDA

View Full Version : Null pointer returned from CoCreateInstance



Juanma
May 25, 2007, 14:35:06
Hallo,

I am having some problems while trying to create an instance of MVMotionDetection filter. First say that I googled a lot before coming here, this is my last chance before going nuts.

I have a DLL written in C++(Visual Studio 2005) which I use to create GraphEdit graphs to test some video hardware. As far as I know, any filter which is listed in Graphedit can be instanced (using C++) using the CoCreateInstance in the following way. However, I tried to insert MV I/O Not filter and worked, now I am trying to insert the MV Motion Detection Filter and I get an hr which succeeds put the pointer returning the interface holds null. What am I doing wrong? (in Graphedit I can insert it)

Code used to insert it ->
<<
HRESULT hr = CoCreateInstance(CLSID_MVMotionDetection, 0, CLSCTX_INPROC_SERVER,
IID_IBaseFilter,
reinterpret_cast<void**>(&pF));

AfxMessageBox(L"Check whether succeeded or not ");

if (hr = REGDB_E_CLASSNOTREG)
{
AfxMessageBox(L"REGDB_E_CLASSNOTREG");
}
if (hr = CLASS_E_NOAGGREGATION)
{
AfxMessageBox(L"CLASS_E_NOAGGREGATION");
}
if (hr = E_NOINTERFACE)
{
AfxMessageBox(L"E_NOINTERFACE");
}
if (hr = S_OK)
{
AfxMessageBox(L"S_OK");
}
if (pF == NULL)
{
AfxMessageBox(L"Null pointer returned");
}
if (SUCCEEDED(hr))
{
AfxMessageBox(L"SUCCEEDED, now going to add filter");
hr = pGraph->AddFilter(pF, wszName);
}

>>
Then the output I get is:
-Check whether succeeded or not
-REGDB_E_CLASSNOTREG
-CLASS_E_NOAGGREGATION
-E_NOINTERFACE
-Null pointer returned
-SUCCEEDED, now going to add filter

So, how can it be that Succeeded(hr) reports a true when all this Errors are seen inside hr? And second and most important, then why the pointer does not holds the address of the IID_IBaseFilter interface of the MVMotionDetection Filter class instance??????

Please help!

Thanks a lot

Marc Cymontkowski
May 25, 2007, 16:07:47
Hi,

> So, how can it be that Succeeded(hr) reports a
> true when all this Errors are seen inside hr?

Simple answer here: Replace "hr = REGDB_E_CLASSNOTREG" with "hr == REGDB_E_CLASSNOTREG", etc.

> why the pointer does not holds the address of the
> IID_IBaseFilter interface of the MVMotionDetection
> Filter class instance?

That question is harder to answer. Can you send sample app with source code to support@montivision.com?


Best Regards,

Marc Cymontkowski

Juanma
May 29, 2007, 12:05:02
Hi,
> So, how can it be that Succeeded(hr) reports a
> true when all this Errors are seen inside hr?

Simple answer here: Replace "hr = REGDB_E_CLASSNOTREG" with "hr == REGDB_E_CLASSNOTREG", etc.

Yes, I had it like that before, but since I was getting no error then (but of course null-pointer), I have thought the assignment "==" was wrong.



> why the pointer does not holds the address of the
> IID_IBaseFilter interface of the MVMotionDetection
> Filter class instance?

That question is harder to answer. Can you send sample app with source code to support@montivision.com?


I tried with version 3.0 of your SDK and with that one it works with this code (so it is correct). But I must use the MV 2.2 since that is the one I have the license for :( Any other solution?

Thanks for the quick reply.

Marc Cymontkowski
May 29, 2007, 12:12:30
Hi,

Maybe the CLSID is wrong for some reason? Is CLSID_MVMotionDetection == 0E3640A7-8494-4226-AE5C-8100E4D52DAF?


Best Regards,

Marc Cymontkowski

Juanma
May 29, 2007, 12:19:59
Hi Marc,


Hi,
Maybe the CLSID is wrong for some reason? Is CLSID_MVMotionDetection == 0E3640A7-8494-4226-AE5C-8100E4D52DAF?


This is the CLSID, I have included MVFilterGUIDs.h so it should be the correct one. I have tried looking by name (enumerating the filters within the ImageProcessing sub types, and even though it finds the filter by the name, again when the call to CoCreate is done, it returns null pointer.

I am trying to figure out wheter I can use the MVMotionDetection filter from the SDK3.0 but all the rest from 2.2. Could I do this?

Best regards, and thanks again

Juanma.

Marc Cymontkowski
May 29, 2007, 12:49:20
Hi Juanma,

Yes, that is possible.


Best Regrads,

Marc Cymontkowski

Juanma
May 30, 2007, 09:21:01
Ok Marc,

Yes I got it running using the Motion Detection filter from SDK version 3.0, but as I was afraid of, now in the "about" tab of this filter appears as unregistered and so it runs with the limitations of detecting motion for 30min and then switches to bypass mode.

Any solution to this problem?

Marc Cymontkowski
May 30, 2007, 09:36:44
Hi Juanma,

Please contact support@montivision.com for a further discussion.

Best Regards,

Marc Cymontkowski