Wednesday, April 25, 2007

Get IMemInputPin from CBaseOutputPin and more errors

Today :
-----------
1. work with MergeFrames filter

Still I got the same error...


Allocator is not committed...

So I commented the code in Output Pin' s DecideAllocator() fn


within that I added only the code related to output pin... and removed all the code for the input pin...

Now it is working...




After displaying one image in the video window, the video window is blocked.

Expected Causes :
--------------------------
So Somewhere the thread is blocked...

1.So see the things related to thread and blocking ...

2. Identify the why the receive() fn is not called continuously...


Execution Order :
---------------------------
1.cvSyncInputPin::Receive() fn
2. VideoOverlay::Receive() fn
3. VideoOverlay::Transform() fn
4. cvSyncOutputPin::NonDelegatingAddRef() fn
5. cvSyncOutputPin::Deliver()


look at the COutputQueue class...

GetGUIDname() fn used to get the name of the GUID...




The following fn used to Display the GUID name.
char* GetGUIDName(const GUID &guid)
{
static char fourcc_buffer[20];
struct TGUID2NAME
{
char *szName;
GUID guid;
};
#define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
{ #name, { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } },
TGUID2NAME names[] =
{
#include
};

if(guid==GUID_NULL)
{
return "GUID_NULL";
}
for(int i=0;i {
if(names[i].guid==guid)
{
return names[i].szName;
}
}
//if we get here, the return value is only valid until the next call to this function
if(guid.Data2==0 && guid.Data3==0x10 && ((DWORD *)guid.Data4)[0]==0xaa000080 && ((DWORD *)guid.Data4)[1]==0x719b3800)
{
char tmp[sizeof(DWORD)+1];
memset(tmp,0,sizeof(DWORD)+1);
memcpy(tmp,&guid.Data1,sizeof(DWORD));
_snprintf(fourcc_buffer,20,"FOURCC '%s'",tmp);
return fourcc_buffer;
}
BYTE *Uuid=NULL;
static char uuidbuffer[50];
UuidToString(const_cast(&guid), &Uuid);
sprintf(uuidbuffer,"{%s}",Uuid);
RpcStringFree(&Uuid);
return uuidbuffer;
}




CBaseOutputPin internally stored only one input pin.

so if we have multiple input pins we have to use our own pin derived from CBasePin.


or we have to define the output pin's Deliver() fn as follows :

Normal Output pin ans its deliver :
-------------------------------------------------
OutputPin :: Deliver(IMediaSample * pSample)
{

return m_pOutput->m_pInputPin->Receive(pMediaSample);

}



Change it as follows :

OutputPin::Deliver(IMediaSample* pSample1, IMediaSample* pSample2 )
{
m_pOutput->m_pInputPin1->Receive(pSample1);
m_pOutput->m_pInputPin1->Receive(pSample2);
}



COuptutQueue has Thread and blocking mechanism...

we called its function Receive() in Output pin's Deliver() fn.

So the problem is in COutputQueue class.That is why the Directshow window is blocked and

that is the reason we got the Deliver() fn as the last debug string..

Look at the COutputQueue class implementation

or without calling Deliver() fn, we need to call the


m_pFilter->m_ip[0]->Receive(pMediaSample[0]);
m_pFilter->m_ip[1]->Receive(pMediaSample[1]);

This is not worked well So we need to look on another way...



Create separate Queue for both input pins and ...
work with it...




I got an error like this ...

GraphEdit Error like as follows :
"Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."


How to Get the IPin* from CBaseInputPin :
----------------------------------------------------------

hr = m_pFilter->m_ip[0]->QueryInterface(IID_IMemInputPin,(void**)&m_pInputPin0);
if (FAILED(hr))
{
OutputDebugString("\n Error while Querying InputPin0 at cvSyncOutputPin::Active()");
return hr;
}
hr = m_pFilter->m_ip[1]->QueryInterface(IID_IMemInputPin,(void**)&m_pInputPin1);
if (FAILED(hr))
{
OutputDebugString("\n Error while Querying InputPin0 at cvSyncOutputPin::Active()");
return hr;
}





Multiplexer means multiple input and single output ...
Demultiplexer means one input and multiple output.

No comments: