Resources are not Properly Released in DShow Transform Filter ...
The EndStreaming() fn is not called properly to release the resources.Afterwards I looked on the Dshow MSDN CTransformFilter Docs.it is not EndStreaming() fn.
we have to implement StopStreaming() fn to release the Resources.
Next I got the error like this.
---------------------------
GraphEdit
---------------------------
Some filters reported an error while stopping. The graph may become unpredictable. Unspecified error (Return code: 0x80004005)
---------------------------
OK
---------------------------
So I put the breakpoint and checked the application.The cause of the Error is
BYTE* pbData;
without allocating memory to it,I released it as follows :
if(pbData) { delete[] pbData; pbData = NULL; }
it causes the failure in execution.
So if we are allocating the memory for the pointer, just set it as NULL during initialization.
Showing posts with label Directshow problems. Show all posts
Showing posts with label Directshow problems. Show all posts
Wednesday, February 06, 2008
Tuesday, January 22, 2008
How to get the MPEG4 encoded bitstream headers within a MPEG4 Decoder Filter
1.I opened the ( highway176x144_30fps.mp4) file in a GraphEdit.
I dumped the MPEG encoded contents in to a file using the following graph:
MP4 Source Filter -> Sample Grabber Filter ->Dump Filter ( highway176x144_30fps.bits)
if I passed the dump file to the MPEG4 decoder application,It gives an error.
( Because the Encoded content also have some Header information ... It is missing )
2.I used my Temporal decoder filter to open the same Mp4 file ( highway176x144_30fps.mp4)
MP4 Source Filter -> Temporal Decoder Filter -> Video Renderer
within my temporal Decoder, I checked the MPEG2VIDEOINFO header of an Tempora Decoder filter's Input Pin.
MPEG2VIDEOINFo header is having some values like as follows:
DWORD cbSequenceHeader; // Size of the Encoded contents Header
DWORD dwSequenceHeader[1]; // Contains header info.
we can typecast it as follows to get the buffer,
BYTE* pbData =(BYTE*) mpg2VideoInfo->dwSequenceHeader;
I dumped this Encoded data to a file.( highway176x144_30fps.mpeg4hdr)
3.I created the Sample application to merge these two files.
The new File ( highway_mpeg4.bits) must have the following :
0. Create a new file ( highway_mpeg4.bits)
i. Append the contents of highway176x144_30fps.mpeg4hdr file to the highway_mpeg4.bits
ii. Append the contents of highway176x144_30fps.bits file to the highway_mpeg4.bits
4.Next I did the following.
Using FFMpeg to decode the MPEG4 contents as follows :
ffmpeg -s 176x144 -vcodec mpeg4 -i d:\media\MpegInput\highway_mpeg4.bits -vcodec rawvideo D:\media\MpegInput\highway_mpeg4.yuv
ffmpeg successully generated the Output file "D:\media\MpegInput\highway_mpeg4.yuv".
I Opened this YUV file in YUV player. it is working fine.
I dumped the MPEG encoded contents in to a file using the following graph:
MP4 Source Filter -> Sample Grabber Filter ->Dump Filter ( highway176x144_30fps.bits)
if I passed the dump file to the MPEG4 decoder application,It gives an error.
( Because the Encoded content also have some Header information ... It is missing )
2.I used my Temporal decoder filter to open the same Mp4 file ( highway176x144_30fps.mp4)
MP4 Source Filter -> Temporal Decoder Filter -> Video Renderer
within my temporal Decoder, I checked the MPEG2VIDEOINFO header of an Tempora Decoder filter's Input Pin.
MPEG2VIDEOINFo header is having some values like as follows:
DWORD cbSequenceHeader; // Size of the Encoded contents Header
DWORD dwSequenceHeader[1]; // Contains header info.
we can typecast it as follows to get the buffer,
BYTE* pbData =(BYTE*) mpg2VideoInfo->dwSequenceHeader;
I dumped this Encoded data to a file.( highway176x144_30fps.mpeg4hdr)
3.I created the Sample application to merge these two files.
The new File ( highway_mpeg4.bits) must have the following :
0. Create a new file ( highway_mpeg4.bits)
i. Append the contents of highway176x144_30fps.mpeg4hdr file to the highway_mpeg4.bits
ii. Append the contents of highway176x144_30fps.bits file to the highway_mpeg4.bits
4.Next I did the following.
Using FFMpeg to decode the MPEG4 contents as follows :
ffmpeg -s 176x144 -vcodec mpeg4 -i d:\media\MpegInput\highway_mpeg4.bits -vcodec rawvideo D:\media\MpegInput\highway_mpeg4.yuv
ffmpeg successully generated the Output file "D:\media\MpegInput\highway_mpeg4.yuv".
I Opened this YUV file in YUV player. it is working fine.
Labels:
Directshow,
Directshow problems,
MPEG4
Thursday, January 17, 2008
How can we test the Temporal Decoder Filter Framework
How can we test the Temporal Decoder Filter Framework :
---------------------------------------------------------
1. For Temporal Decoder, the Input buffer size may vary...
So Implement the custom allocator for the input pin
2. Open Some Image file using OpenCV .
Based on the Image Size, allocate the Output pin buffer size using DecideBufferSize() fn.
copy the Image buffer in to the output buffer.
Thru this we can test the temporal decoder filter...
if we print the Input( source) Sample Size and Output(destination) Sample Size.
we can identify the variable Input Buffer size.
But the Output Buffer size is always constant.
Construct the Filter graph as follows in GraphEdit :
MP4 Video --> Temporal Decoder --> Video Renderer
Run the Graph if it runs the graph and displays the Image properly. then it is fine...
---------------------------------------------------------
1. For Temporal Decoder, the Input buffer size may vary...
So Implement the custom allocator for the input pin
2. Open Some Image file using OpenCV .
Based on the Image Size, allocate the Output pin buffer size using DecideBufferSize() fn.
copy the Image buffer in to the output buffer.
Thru this we can test the temporal decoder filter...
if we print the Input( source) Sample Size and Output(destination) Sample Size.
we can identify the variable Input Buffer size.
But the Output Buffer size is always constant.
Construct the Filter graph as follows in GraphEdit :
MP4 Video --> Temporal Decoder --> Video Renderer
Run the Graph if it runs the graph and displays the Image properly. then it is fine...
GetMediaType() fn 's Execution in a DShow Filter
About GetMediaType() fn :
----------------------------
1. I opened the Image File in a GetMediaType() fn of a Temporal Decoder filter.
2. I added this filter to the GraphEdit as follows
Mp4 Video -> Temporal Decoder Filter ->Video Renderer
it is working fine ...
I saved this filter graph in .grf (graph) file.
If I opened the Graph(.grf ) file directly in GraphEdit, it gives error,
Because the GetMediaType() is not called in a filter. So The invalid memory is copied to my filter.
It causes the error in Graphedit while running the graph.
So instead of opening the Graph File,
Open the MP4 File in a graph edit and build the Graph manually every time as follows :
MP4 Video --> Temporal Decoder --> Video Renderer
----------------------------
1. I opened the Image File in a GetMediaType() fn of a Temporal Decoder filter.
2. I added this filter to the GraphEdit as follows
Mp4 Video -> Temporal Decoder Filter ->Video Renderer
it is working fine ...
I saved this filter graph in .grf (graph) file.
If I opened the Graph(.grf ) file directly in GraphEdit, it gives error,
Because the GetMediaType() is not called in a filter. So The invalid memory is copied to my filter.
It causes the error in Graphedit while running the graph.
So instead of opening the Graph File,
Open the MP4 File in a graph edit and build the Graph manually every time as follows :
MP4 Video --> Temporal Decoder --> Video Renderer
GetMediaType() fn 's Execution in a DShow Filter
About GetMediaType() fn :
----------------------------
1. I opened the Image File in a GetMediaType() fn of a Temporal Decoder filter.
2. I added this filter to the GraphEdit as follows
Mp4 Video -> Temporal Decoder Filter ->Video Renderer
it is working fine ...
I saved this filter graph in .grf (graph) file.
If I opened the Graph(.grf ) file directly in GraphEdit, it gives error,
Because the GetMediaType() is not called in a filter. So The invalid memory is copied to my filter.
It causes the error in Graphedit while running the graph.
So instead of opening the Graph File,
Open the MP4 File in a graph edit and build the Graph manually every time as follows :
MP4 Video --> Temporal Decoder --> Video Renderer
----------------------------
1. I opened the Image File in a GetMediaType() fn of a Temporal Decoder filter.
2. I added this filter to the GraphEdit as follows
Mp4 Video -> Temporal Decoder Filter ->Video Renderer
it is working fine ...
I saved this filter graph in .grf (graph) file.
If I opened the Graph(.grf ) file directly in GraphEdit, it gives error,
Because the GetMediaType() is not called in a filter. So The invalid memory is copied to my filter.
It causes the error in Graphedit while running the graph.
So instead of opening the Graph File,
Open the MP4 File in a graph edit and build the Graph manually every time as follows :
MP4 Video --> Temporal Decoder --> Video Renderer
How to develop only one custom Pin for a CTransformFilter
How to override only one Pin of a CTransformFilter?
-------------------------------------------------------
1.I want to implement the allocator for the Transform input pin.
How can we do this ?...
I developed my own CTransformInputPin derived class as follows :
class CMyAllocator : public CMemAllocator
{
};
class CNewTransformInputPin :public CTransformInputPin
{
friend class CMyAllocator;
};
I initialized my "CNewTransformInputPin" as follows :
class CMyTransformFilter : CTransformFilter
{
public:
CMyTransformFilter()
{
m_pInput = new CNewTransformInputPin();
}
};
while running the Graph, the GraphEdit hangs and I closed the application.
Solution :
-------------------
I modified it as follows :
class CMyTransformFilter : CTransformFilter
{
public:
CBasePin* GetPin(int i)
{
if( m_pInput == NULL)
{
m_pInput = new CNewTransformInputPin();
}
if( m_pOutput == NULL)
{
m_pOutput = new CTransformOutputPin();
}
if( i== 0) { return m_pInput;}
else if (i == 1) { return m_pOutput;}
else return NULL;
}
};
Now we can override the single Pin in a transform filter by Overriding the CBasePin* GetPin() fn...
-------------------------------------------------------
1.I want to implement the allocator for the Transform input pin.
How can we do this ?...
I developed my own CTransformInputPin derived class as follows :
class CMyAllocator : public CMemAllocator
{
};
class CNewTransformInputPin :public CTransformInputPin
{
friend class CMyAllocator;
};
I initialized my "CNewTransformInputPin" as follows :
class CMyTransformFilter : CTransformFilter
{
public:
CMyTransformFilter()
{
m_pInput = new CNewTransformInputPin();
}
};
while running the Graph, the GraphEdit hangs and I closed the application.
Solution :
-------------------
I modified it as follows :
class CMyTransformFilter : CTransformFilter
{
public:
CBasePin* GetPin(int i)
{
if( m_pInput == NULL)
{
m_pInput = new CNewTransformInputPin();
}
if( m_pOutput == NULL)
{
m_pOutput = new CTransformOutputPin();
}
if( i== 0) { return m_pInput;}
else if (i == 1) { return m_pOutput;}
else return NULL;
}
};
Now we can override the single Pin in a transform filter by Overriding the CBasePin* GetPin() fn...
Friday, December 21, 2007
iQualityControl Notify Error
---------------------------
Hard coded break point
---------------------------
"IQualityControl::Notify not over-ridden from CBasePin. (IGNORE is OK)"
At line 2346 of C:\DXSDK\Samples\C++\DirectShow\BaseClasses\amfilter.cpp
Continue? (Cancel to debug)
---------------------------
Yes No Cancel
---------------------------
Solution :
This Error is displayed at runtime in a filter graph. So
for This Error I added the code as follows :
HRESULT Notify(IBaseFilter *pSelf,Quality q ) { return S_OK;}
in classes derived from CBasePin, Now it is working well...
Hard coded break point
---------------------------
"IQualityControl::Notify not over-ridden from CBasePin. (IGNORE is OK)"
At line 2346 of C:\DXSDK\Samples\C++\DirectShow\BaseClasses\amfilter.cpp
Continue? (Cancel to debug)
---------------------------
Yes No Cancel
---------------------------
Solution :
This Error is displayed at runtime in a filter graph. So
for This Error I added the code as follows :
HRESULT Notify(IBaseFilter *pSelf,Quality q ) { return S_OK;}
in classes derived from CBasePin, Now it is working well...
Filter or DLL or .ocx registration Error
Filter or DLL or .ocx registration Error :
-------------------------------------------
Eventhough the DLL compiles and links well while registering the filter or DLL or.ocx using regsvr32 utility, I got this Error.
---------------------------
RegSvr32
---------------------------
.\Debug\HTTPWriterSinkFilterd.ax was loaded, but the DllRegisterServer entry point was not found.
.\Debug\HTTPWriterSinkFilterd.ax does not appear to be a .DLL or .OCX file.
---------------------------
OK
---------------------------
Solution Steps :
---------------
1.I Opened that DLL file in "Depends viewer" available in a visual studio tools
2. no function is exported from the DLL or filter file.
3.For Exporting the Functions, I used the .def file (module definition file).
4. Next I have opened the DLL,ax files in "Depends viewer" that are successfully registered
There the Dependency viewer displays the exported functions.
5. So the problem is in Exporting the functions
6. Next I opened the Project->Settings-> Linker->input ...
and I checked anywhere my .def file is specified there is nothing like that.
So I added the the following options
Project -> Settings-> Linker -> Input -> /DEF:My.def
Now I compiled the application and register it with regsvr32 utitily.
Now the registeration is done successfully .
if I opened that registered DLL in "Depends viewer", It displays the exported functions.
PostScript :
------------
In Some DLLs,even though they created the application as DLL,
without including this "/DEF:my.def", that dll also registers well.
-------------------------------------------
Eventhough the DLL compiles and links well while registering the filter or DLL or.ocx using regsvr32 utility, I got this Error.
---------------------------
RegSvr32
---------------------------
.\Debug\HTTPWriterSinkFilterd.ax was loaded, but the DllRegisterServer entry point was not found.
.\Debug\HTTPWriterSinkFilterd.ax does not appear to be a .DLL or .OCX file.
---------------------------
OK
---------------------------
Solution Steps :
---------------
1.I Opened that DLL file in "Depends viewer" available in a visual studio tools
2. no function is exported from the DLL or filter file.
3.For Exporting the Functions, I used the .def file (module definition file).
4. Next I have opened the DLL,ax files in "Depends viewer" that are successfully registered
There the Dependency viewer displays the exported functions.
5. So the problem is in Exporting the functions
6. Next I opened the Project->Settings-> Linker->input ...
and I checked anywhere my .def file is specified there is nothing like that.
So I added the the following options
Project -> Settings-> Linker -> Input -> /DEF:My.def
Now I compiled the application and register it with regsvr32 utitily.
Now the registeration is done successfully .
if I opened that registered DLL in "Depends viewer", It displays the exported functions.
PostScript :
------------
In Some DLLs,even though they created the application as DLL,
without including this "/DEF:my.def", that dll also registers well.
Friday, August 31, 2007
Compilation of VC++ 6.0 with Directshow
I got this following error codes......already i put strmiids.lib and build the baseclasses after that add the strmbasd.lib in link tab (settings)...
c:\dxsdk\samples\c++\directshow\baseclasses\wxutil.h(530) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\ctlutil.h(437) : error C2504: 'IBasicVideo2' : base class undefined
c:\dxsdk\samples\c++\directshow\baseclasses\ctlutil.h(904) : error C2146: syntax error : missing ';' before identifier 'm_dwAdvise'
c:\dxsdk\samples\c++\directshow\baseclasses\ctlutil.h(904) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\ctlutil.h(904) : error C2501: 'm_dwAdvise' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(286) : error C2061: syntax error : identifier 'LONG_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(951) : error C2504: 'IPinFlowControl' : base class undefined
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(982) : error C2061: syntax error : identifier 'IGraphConfig'
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1067) : error C2143: syntax error : missing ';' before '*'
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1067) : error C2501: 'IGraphConfig' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1067) : error C2501: 'm_pGraphConfig' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1340) : error C2504: 'IMemAllocatorCallbackTemp' : base class undefined
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1444) : error C2143: syntax error : missing ';' before '*'
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1444) : error C2501: 'IMemAllocatorNotifyCallbackTemp' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1444) : error C2501: 'm_pNotify' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1506) : error C2061: syntax error : identifier 'IMemAllocatorNotifyCallbackTemp'
c:\dxsdk\samples\c++\directshow\baseclasses\renbase.h(68) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\renbase.h(78) : error C2146: syntax error : missing ';' before identifier 'm_dwAdvise'
c:\dxsdk\samples\c++\directshow\baseclasses\renbase.h(78) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\renbase.h(78) : error C2501: 'm_dwAdvise' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\winctrl.h(103) : error C2061: syntax error : identifier 'LONG_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(24) : error C2146: syntax error : missing ';' before identifier 'AddAdvisePacket'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(24) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(26) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(47) : error C2146: syntax error : missing ';' before identifier 'm_dwAdviseCookie'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(47) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(47) : error C2501: 'm_dwAdviseCookie' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(85) : error C2146: syntax error : missing ';' before identifier 'Cookie'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(85) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(86) : warning C4183: 'Cookie': member function definition looks like a ctor, but name does not match enclosing class
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(96) : error C2146: syntax error : missing ';' before identifier 'm_dwNextCookie'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(96) : error C2501: 'm_dwNextCookie' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(102) : error C2146: syntax error : missing ';' before identifier 'AddAdvisePacket'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(102) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\refclock.h(103) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\refclock.h(111) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\refclock.h(121) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\sysclock.h(20) : error C2504: 'IAMClockAdjust' : base class undefined
fSnake.cpp
I got the Error like urs :
I did the following things :
1. open the Directshow baseclasses .dsw (which gives output as strmbasd.lib)file in an VC++6.0 and compiled it.
( Make sure whether the VC++ 6.0's compiled strmbasd.lib included in a directshow application)
2. Next I included this strmbasd.lib in Linker's Input option.
3. in Tools ->options->Include Files option,
Included the C:\DXSDK\Include directory in Tools ->options
after the inclusion of this directory also I got an error.
Solution :
I rearranged the directories order in an ascending order
Previously the Directory order is as follows :
C:\Program Files\ Visual studio \ lib
C:\DXSDK\Include
4.Add the C:\DXSDK\Lib directory in Tools->options ->Library Files
5.Now compiling the filter works well.
this gives the problem so I rearranged it in an ascending order as follows :
C:\DXSDK\Include
C:\Program Files\ Visual studio \ lib
4. Added the following directory in a Tools->options->Include Files option ( related to Directx);
C:\DXSDK\Include\DShowIDL
c:\dxsdk\samples\c++\directshow\baseclasses\wxutil.h(530) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\ctlutil.h(437) : error C2504: 'IBasicVideo2' : base class undefined
c:\dxsdk\samples\c++\directshow\baseclasses\ctlutil.h(904) : error C2146: syntax error : missing ';' before identifier 'm_dwAdvise'
c:\dxsdk\samples\c++\directshow\baseclasses\ctlutil.h(904) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\ctlutil.h(904) : error C2501: 'm_dwAdvise' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(286) : error C2061: syntax error : identifier 'LONG_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(951) : error C2504: 'IPinFlowControl' : base class undefined
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(982) : error C2061: syntax error : identifier 'IGraphConfig'
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1067) : error C2143: syntax error : missing ';' before '*'
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1067) : error C2501: 'IGraphConfig' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1067) : error C2501: 'm_pGraphConfig' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1340) : error C2504: 'IMemAllocatorCallbackTemp' : base class undefined
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1444) : error C2143: syntax error : missing ';' before '*'
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1444) : error C2501: 'IMemAllocatorNotifyCallbackTemp' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1444) : error C2501: 'm_pNotify' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1506) : error C2061: syntax error : identifier 'IMemAllocatorNotifyCallbackTemp'
c:\dxsdk\samples\c++\directshow\baseclasses\renbase.h(68) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\renbase.h(78) : error C2146: syntax error : missing ';' before identifier 'm_dwAdvise'
c:\dxsdk\samples\c++\directshow\baseclasses\renbase.h(78) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\renbase.h(78) : error C2501: 'm_dwAdvise' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\winctrl.h(103) : error C2061: syntax error : identifier 'LONG_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(24) : error C2146: syntax error : missing ';' before identifier 'AddAdvisePacket'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(24) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(26) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(47) : error C2146: syntax error : missing ';' before identifier 'm_dwAdviseCookie'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(47) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(47) : error C2501: 'm_dwAdviseCookie' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(85) : error C2146: syntax error : missing ';' before identifier 'Cookie'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(85) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(86) : warning C4183: 'Cookie': member function definition looks like a ctor, but name does not match enclosing class
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(96) : error C2146: syntax error : missing ';' before identifier 'm_dwNextCookie'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(96) : error C2501: 'm_dwNextCookie' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(102) : error C2146: syntax error : missing ';' before identifier 'AddAdvisePacket'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(102) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\refclock.h(103) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\refclock.h(111) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\refclock.h(121) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\sysclock.h(20) : error C2504: 'IAMClockAdjust' : base class undefined
fSnake.cpp
I got the Error like urs :
I did the following things :
1. open the Directshow baseclasses .dsw (which gives output as strmbasd.lib)file in an VC++6.0 and compiled it.
( Make sure whether the VC++ 6.0's compiled strmbasd.lib included in a directshow application)
2. Next I included this strmbasd.lib in Linker's Input option.
3. in Tools ->options->Include Files option,
Included the C:\DXSDK\Include directory in Tools ->options
after the inclusion of this directory also I got an error.
Solution :
I rearranged the directories order in an ascending order
Previously the Directory order is as follows :
C:\Program Files\ Visual studio \ lib
C:\DXSDK\Include
4.Add the C:\DXSDK\Lib directory in Tools->options ->Library Files
5.Now compiling the filter works well.
this gives the problem so I rearranged it in an ascending order as follows :
C:\DXSDK\Include
C:\Program Files\ Visual studio \ lib
4. Added the following directory in a Tools->options->Include Files option ( related to Directx);
C:\DXSDK\Include\DShowIDL
Friday, August 24, 2007
BDL VideoQuality Filter Seeking problem
check whether the seeking is working with BDL video Quality Filter ?
How I fixed the problem in back ward Seeking ?...
Solution steps :
1 I Read Media time(Current Position) for the samples and added it to the ArrayList ...
2. From the List, Set the Seeking Position
3. Play the Filter graph again...
4. Then the Video is running, then the problem lies with setting proper media time
5. I Identified this problem, I have allocated the time boxinglimit( 7.15 pm to 8.10 pm)
6.Previously I set the media time somewhat truncated media time obtained from the Track Bar % value...
(and then use the IVideoFrameStep interface with the video Quality client, else the BDL video quality Filter is a problem)
How I fixed the problem in back ward Seeking ?...
Solution steps :
1 I Read Media time(Current Position) for the samples and added it to the ArrayList ...
2. From the List, Set the Seeking Position
3. Play the Filter graph again...
4. Then the Video is running, then the problem lies with setting proper media time
5. I Identified this problem, I have allocated the time boxinglimit( 7.15 pm to 8.10 pm)
6.Previously I set the media time somewhat truncated media time obtained from the Track Bar % value...
(and then use the IVideoFrameStep interface with the video Quality client, else the BDL video quality Filter is a problem)
Wednesday, August 01, 2007
Multiple video Renderer problem
Multiple Renderer in a Single Graph Builder :
if we have multiple renderer in a graph builder ,then
1. we may face the problem as follows
Source 1 video : Video Renderer 001 we can get the video window from VideoRenderer 001 for Source1 video.
Source 2 Video : Video Renderer 002 we can get the video window from the videoRenderer 002 for Source2 video.
output video : Video Renderer 003 we can get the video window from the videoRenderer 003 for Output video.
Normal search like "video Renderer" will not help if the filter have multiple renderers.
http://groups.google.co.in/group/microsoft.public.win32.programmer.directx.video/browse_thread/thread/c5f52fbfa798def4/2eece8fd096b3879?lnk=st&q=SetNotifyWindow+%2B+multiple+render+problem&rnum=1&hl=en#2eece8fd096b3879
if we have multiple renderer in a graph builder ,then
1. we may face the problem as follows
Source 1 video : Video Renderer 001 we can get the video window from VideoRenderer 001 for Source1 video.
Source 2 Video : Video Renderer 002 we can get the video window from the videoRenderer 002 for Source2 video.
output video : Video Renderer 003 we can get the video window from the videoRenderer 003 for Output video.
Normal search like "video Renderer" will not help if the filter have multiple renderers.
http://groups.google.co.in/group/microsoft.public.win32.programmer.directx.video/browse_thread/thread/c5f52fbfa798def4/2eece8fd096b3879?lnk=st&q=SetNotifyWindow+%2B+multiple+render+problem&rnum=1&hl=en#2eece8fd096b3879
IVideoWindow Query failed...
windowless Mode using IVideoWindow :
------------------------------------------------------------
m_pVideoWindow->put_Owner() returns E_NOINTERFACE ...
IVideoWindow method's put_Owner() failed...
The reason is after building the filter graph completely , we can call the put_Owner() method ...
In my application I just followed the sequence of steps ...
i) Add the source filter
ii) Set the video Window...
iii) Render the Source filter's output pin
But I am not able to set my video window to the specified control...
The reason is we can set the video window handle only after the video renderer filter is connected to the filter graph.
One More reason is we actually got the IVideoWindow interface from the renderer filter. So without the renderer filter the
Querying of IVideoWindow from the filter graph failed...
------------------------------------------------------------
m_pVideoWindow->put_Owner() returns E_NOINTERFACE ...
IVideoWindow method's put_Owner() failed...
The reason is after building the filter graph completely , we can call the put_Owner() method ...
In my application I just followed the sequence of steps ...
i) Add the source filter
ii) Set the video Window...
iii) Render the Source filter's output pin
But I am not able to set my video window to the specified control...
The reason is we can set the video window handle only after the video renderer filter is connected to the filter graph.
One More reason is we actually got the IVideoWindow interface from the renderer filter. So without the renderer filter the
Querying of IVideoWindow from the filter graph failed...
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.
-----------
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
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.
This pin cannot use the supplied media type and Cannot allocate a sample when the allocator is not active.
---------------------------
GraphEdit
---------------------------
The graph could not change state.
This pin cannot use the supplied media type. (Return code: 0x8004022a)
---------------------------
OK
---------------------------
9.00 - 9.30 - I tried to change the media type using SetMediaType() fn well ... I got an enough output window in GraphEdit
I got an error as
---------------------------
GraphEdit
---------------------------
The graph could not change state.
This pin cannot use the supplied media type. (Return code: 0x8004022a)
---------------------------
OK
---------------------------
One thing I noted in SetMediaType() fn's MediaType that is
I had the width and height and size of the VIDEOINFOHEADER as correct as output pin.( 400,400)..
But rcTarget and rcSource rectangle remains like as input pin... (240,320)
9.30 - 10.30 - Even though I set the rcTarget and rcSource rectangle I got an error...
Still I am not able to get the IMediaSample of an Output pin...
the process of getting IMediaSample of an output pin is failed...
10.30 - 11.30 - I tried several approaches all are failed...
-Output Pin's NonDelegatingAddRef() and NonDelegatingRelease() continuously called
I commented the DisplayHistogram() fn for Output pin...
AM_SAMPLE2_PROPERTIES * const pProps = m_ip[0]->SampleProps();
DWORD dwFlags = 0;
pProps->dwSampleFlags - 273
AM_SAMPLE_SPLICEPOINT - 1
AM_SAMPLE_TIMEVALID - 16
AM_SAMPLE_STOPVALID - 256
if ( ! (pProps->dwSampleFlags & AM_SAMPLE_SPLICEPOINT ) )
{
//if the dwSampleFlags is Even number then only the condition will becomes true
}
GetBuffer() fn they tried the following :
HRESULT hr = m_op->m_pAllocator->GetBuffer(
&pOutSample
, pProps->dwSampleFlags & AM_SAMPLE_TIMEVALID ?
&pProps->tStart : NULL
, pProps->dwSampleFlags & AM_SAMPLE_STOPVALID ?
&pProps->tStop : NULL
, dwFlags
);
dwFlags - 0
Flags passed to the GetBuffer() fn...
#define AM_GBF_PREVFRAMESKIPPED 1
#define AM_GBF_NOTASYNCPOINT 2
#define AM_GBF_NOWAIT 4
#define AM_GBF_NODDSURFACELOCK 8
//For Displaying the DirectShow Error...
void ShowError(HRESULT hr)
{
if (FAILED(hr))
{
TCHAR szErr[MAX_ERROR_TEXT_LEN];
DWORD res = AMGetErrorText(hr, szErr, MAX_ERROR_TEXT_LEN);
if (res == 0)
{
wsprintf(szErr, "Unknown Error: 0x%2x", hr);
}
MessageBox(0, szErr, TEXT("Error!"), MB_OK | MB_ICONERROR);
}
}
//For displaying Error With ErrorCode :
void ShowError(HRESULT hr)
{
if (FAILED(hr))
{
TCHAR szErr[MAX_ERROR_TEXT_LEN];
TCHAR szNumber[20];
DWORD res = AMGetErrorText(hr, szErr, MAX_ERROR_TEXT_LEN);
if (res == 0)
{
wsprintf(szErr, "Unknown Error: 0x%2x", hr);
}
wsprintf(szNumber," :0x%2x",hr);
strcat(szErr,szNumber);
MessageBox(0, szErr, TEXT("Error!"), MB_OK | MB_ICONERROR);
}
}
I got an error while try to get the output media sample...
---------------------------
Error!
---------------------------
Cannot allocate a sample when the allocator is not active. :0x80040211
---------------------------
OK
---------------------------
VFW_E_NOT_COMMITTED - Allocator is decommitted.
This is returned by the output pin's allocator's GetBuffer() fn...
For Solving this problem ... I looked the documentation Before getting the output pin's media sample using GetBuffer() we have to call the
Commit() fn of an allocator. This will be Done in Active () fn of an output pin and after calling the GetBuffer() fn we have to call the Decommit()
fn to decommit the media samples this is called in Inactive() fn of an output pin...
CMyFilter is the class derived from CBaseFilter.
CMyFilter :: Pause()
{
outputPin->Active()
}
CMyFilter::Stop()
{
outputPin->Inactive();
}
HRESULT COutputPin :: Active()
{
return outputAllocator->commit();
}
After calling Pause() we have to call the GetBuffer() fn of an output allocator to get the IMediaSample of an output pin...
while closing we have to call stop() decommit the allocated samples.
HRESULT COutputPin:: InActive()
{
return OutputAllocator->Decommit();
}
After solving this problem I got the previous error like
"this pin cannot use the specified media type..."
I specified the invalid values in rcSource and rcTarget rectangles in the media type.
we have to set this media type to the output pin...After setting the media type, we have to delete the media type
using DeleteMediaType() fn.
Now the output window has invalid video data ... it is like flickering...
and displayed the error " This pin can not use the specified media type ".I am not able to fi x the problem...
Now the problem is how to set the media type for an output pin ?
GetMediaType should create a media type for the output based on the input
format (and your known transformation characteristics). SetMediaType should
set the selected format and its buffer size, and then DecideBufferSize
should set the allocator's buffer size based on the type passed to
SetMediaType. But remember that if you want to work with the video
renderer, you may get a dynamic type change on the first buffer, typically
to change the stride, and you need to use that type.
CTransformOutput pin class:
1.CheckMediaType()
2.SetMediaType()
3.GetMediaType( )...
CTransformFilter class
1.GetMediaType() fn
"This pin can not use the specified media type"
To avoid this error...
Get the sample size of an Output Pins media sample size...
and remove the setMediatype() fn...
I get the sample size using the
OutputSample->GetMediaType(pmt);
VIDEOINFOHEADER* pvi = (VIDEOINFOHEADER*)pmt->pbFormat;
long lSize;
lSize = pvi->bmiHeader.biSizeImage;
DeleteMediaType(pmt);
I am looking on Output Pin's media Type setting...
we can retrieve the Output pin's media sample's properties and its media type...
So I may try this approach to set the media type...
iMediaSample has properties AM_SAMPLE2_PROPERTIES like that...
we can set the Media Type to the pMediaType member of the AM_SAMPLE2_PROPERTIES obtained from Output pin's
media sample's mediatype.
I can change the media type in two ways..
1. Change the Mediatype using AM_SAMPLE2_PROPERTIES structure and Set it as a Output pin's media sample
media type
2.Another way is to imitate the GetMediaType() function of the CTransformFilter
( In my thought, This seems better option because The GetMediaType() executed only two or 3 times whereas
the first process will be executed for each Transform() fn )...
GetMediaType() is not getting executed.So I have to identify the reason.
Actually i didnt print the debug string in Outputpin's GetMediaType() fn..
GetMediaType() with EnumMediatypes() works well.. but the output window is same as input pin..
SetMediaType() fn with EnumMediaTypes() works well , but the output window can be different from input pin...
so the problem lies with the EnumMediaTypes() fn...
In the second approach I faced many problems and finally the Output pin's media type is not set properly.
So I got an error as follows :
---------------------------
GraphEdit
---------------------------
The graph could not change state.
This pin cannot use the supplied media type. (Return code: 0x8004022a)
---------------------------
OK
---------------------------
So change the media type in the first way...
Eventhough I changed the media type Still I got the same error...
But I didnt get an error anywhere in my program and output also some flickering due to invalid output pin's video size...
Look at the Working of CTransformOutputPin's GetMediaType() fn...
and check whether any EnumMediaTypes() function used in CTransformOutputPin class..
GraphEdit
---------------------------
The graph could not change state.
This pin cannot use the supplied media type. (Return code: 0x8004022a)
---------------------------
OK
---------------------------
9.00 - 9.30 - I tried to change the media type using SetMediaType() fn well ... I got an enough output window in GraphEdit
I got an error as
---------------------------
GraphEdit
---------------------------
The graph could not change state.
This pin cannot use the supplied media type. (Return code: 0x8004022a)
---------------------------
OK
---------------------------
One thing I noted in SetMediaType() fn's MediaType that is
I had the width and height and size of the VIDEOINFOHEADER as correct as output pin.( 400,400)..
But rcTarget and rcSource rectangle remains like as input pin... (240,320)
9.30 - 10.30 - Even though I set the rcTarget and rcSource rectangle I got an error...
Still I am not able to get the IMediaSample of an Output pin...
the process of getting IMediaSample of an output pin is failed...
10.30 - 11.30 - I tried several approaches all are failed...
-Output Pin's NonDelegatingAddRef() and NonDelegatingRelease() continuously called
I commented the DisplayHistogram() fn for Output pin...
AM_SAMPLE2_PROPERTIES * const pProps = m_ip[0]->SampleProps();
DWORD dwFlags = 0;
pProps->dwSampleFlags - 273
AM_SAMPLE_SPLICEPOINT - 1
AM_SAMPLE_TIMEVALID - 16
AM_SAMPLE_STOPVALID - 256
if ( ! (pProps->dwSampleFlags & AM_SAMPLE_SPLICEPOINT ) )
{
//if the dwSampleFlags is Even number then only the condition will becomes true
}
GetBuffer() fn they tried the following :
HRESULT hr = m_op->m_pAllocator->GetBuffer(
&pOutSample
, pProps->dwSampleFlags & AM_SAMPLE_TIMEVALID ?
&pProps->tStart : NULL
, pProps->dwSampleFlags & AM_SAMPLE_STOPVALID ?
&pProps->tStop : NULL
, dwFlags
);
dwFlags - 0
Flags passed to the GetBuffer() fn...
#define AM_GBF_PREVFRAMESKIPPED 1
#define AM_GBF_NOTASYNCPOINT 2
#define AM_GBF_NOWAIT 4
#define AM_GBF_NODDSURFACELOCK 8
//For Displaying the DirectShow Error...
void ShowError(HRESULT hr)
{
if (FAILED(hr))
{
TCHAR szErr[MAX_ERROR_TEXT_LEN];
DWORD res = AMGetErrorText(hr, szErr, MAX_ERROR_TEXT_LEN);
if (res == 0)
{
wsprintf(szErr, "Unknown Error: 0x%2x", hr);
}
MessageBox(0, szErr, TEXT("Error!"), MB_OK | MB_ICONERROR);
}
}
//For displaying Error With ErrorCode :
void ShowError(HRESULT hr)
{
if (FAILED(hr))
{
TCHAR szErr[MAX_ERROR_TEXT_LEN];
TCHAR szNumber[20];
DWORD res = AMGetErrorText(hr, szErr, MAX_ERROR_TEXT_LEN);
if (res == 0)
{
wsprintf(szErr, "Unknown Error: 0x%2x", hr);
}
wsprintf(szNumber," :0x%2x",hr);
strcat(szErr,szNumber);
MessageBox(0, szErr, TEXT("Error!"), MB_OK | MB_ICONERROR);
}
}
I got an error while try to get the output media sample...
---------------------------
Error!
---------------------------
Cannot allocate a sample when the allocator is not active. :0x80040211
---------------------------
OK
---------------------------
VFW_E_NOT_COMMITTED - Allocator is decommitted.
This is returned by the output pin's allocator's GetBuffer() fn...
For Solving this problem ... I looked the documentation Before getting the output pin's media sample using GetBuffer() we have to call the
Commit() fn of an allocator. This will be Done in Active () fn of an output pin and after calling the GetBuffer() fn we have to call the Decommit()
fn to decommit the media samples this is called in Inactive() fn of an output pin...
CMyFilter is the class derived from CBaseFilter.
CMyFilter :: Pause()
{
outputPin->Active()
}
CMyFilter::Stop()
{
outputPin->Inactive();
}
HRESULT COutputPin :: Active()
{
return outputAllocator->commit();
}
After calling Pause() we have to call the GetBuffer() fn of an output allocator to get the IMediaSample of an output pin...
while closing we have to call stop() decommit the allocated samples.
HRESULT COutputPin:: InActive()
{
return OutputAllocator->Decommit();
}
After solving this problem I got the previous error like
"this pin cannot use the specified media type..."
I specified the invalid values in rcSource and rcTarget rectangles in the media type.
we have to set this media type to the output pin...After setting the media type, we have to delete the media type
using DeleteMediaType() fn.
Now the output window has invalid video data ... it is like flickering...
and displayed the error " This pin can not use the specified media type ".I am not able to fi x the problem...
Now the problem is how to set the media type for an output pin ?
GetMediaType should create a media type for the output based on the input
format (and your known transformation characteristics). SetMediaType should
set the selected format and its buffer size, and then DecideBufferSize
should set the allocator's buffer size based on the type passed to
SetMediaType. But remember that if you want to work with the video
renderer, you may get a dynamic type change on the first buffer, typically
to change the stride, and you need to use that type.
CTransformOutput pin class:
1.CheckMediaType()
2.SetMediaType()
3.GetMediaType( )...
CTransformFilter class
1.GetMediaType() fn
"This pin can not use the specified media type"
To avoid this error...
Get the sample size of an Output Pins media sample size...
and remove the setMediatype() fn...
I get the sample size using the
OutputSample->GetMediaType(pmt);
VIDEOINFOHEADER* pvi = (VIDEOINFOHEADER*)pmt->pbFormat;
long lSize;
lSize = pvi->bmiHeader.biSizeImage;
DeleteMediaType(pmt);
I am looking on Output Pin's media Type setting...
we can retrieve the Output pin's media sample's properties and its media type...
So I may try this approach to set the media type...
iMediaSample has properties AM_SAMPLE2_PROPERTIES like that...
we can set the Media Type to the pMediaType member of the AM_SAMPLE2_PROPERTIES obtained from Output pin's
media sample's mediatype.
I can change the media type in two ways..
1. Change the Mediatype using AM_SAMPLE2_PROPERTIES structure and Set it as a Output pin's media sample
media type
2.Another way is to imitate the GetMediaType() function of the CTransformFilter
( In my thought, This seems better option because The GetMediaType() executed only two or 3 times whereas
the first process will be executed for each Transform() fn )...
GetMediaType() is not getting executed.So I have to identify the reason.
Actually i didnt print the debug string in Outputpin's GetMediaType() fn..
GetMediaType() with EnumMediatypes() works well.. but the output window is same as input pin..
SetMediaType() fn with EnumMediaTypes() works well , but the output window can be different from input pin...
so the problem lies with the EnumMediaTypes() fn...
In the second approach I faced many problems and finally the Output pin's media type is not set properly.
So I got an error as follows :
---------------------------
GraphEdit
---------------------------
The graph could not change state.
This pin cannot use the supplied media type. (Return code: 0x8004022a)
---------------------------
OK
---------------------------
So change the media type in the first way...
Eventhough I changed the media type Still I got the same error...
But I didnt get an error anywhere in my program and output also some flickering due to invalid output pin's video size...
Look at the Working of CTransformOutputPin's GetMediaType() fn...
and check whether any EnumMediaTypes() function used in CTransformOutputPin class..
Input pin size is different from Outputpin size
1. GetMediaType() fn
we returned the size of the output pin's media type
CheckMediaType() fn is also called before setting the media type
or SetMediaType() function we have to specify the output pin's width and Height
2.DecideBufferSize() fn
allocate the output pin's allocator buffer by specifying width and height
HRESULT OutputPin :: SetMediaType(const CMediaType* pmt) fn...
{
// I doubted whether it is possible to change the output pin;'s size with this method
// The reason is it is CMediaType is constant so they may not allow us to change the media type.
// It is true , we are in need to change only the output video size ... which resides in the pointer(pbFormat) so we can change it easily
VIDEOINFOHEADER* pvi = (VIDEOINFOHEADER*) pmt->pbFormat;
pvi ->bmiHeader.biWidth = 400;
pvi->bmiHeader.biHeight = 400;
pvi->bmiHeader.biSizeImage = pvi->bmiHeader.biWidth * pvi->bmiHeader.biHeight * (pvi->bmiHeader.biBitCount / 8);
}
I completed both the steps...
Next look on Deliver () fn...
we have to copy the output image to the Output pin's media sample as follows in
InitializeOutputSamples() in CTransformFilter class
we returned the size of the output pin's media type
CheckMediaType() fn is also called before setting the media type
or SetMediaType() function we have to specify the output pin's width and Height
2.DecideBufferSize() fn
allocate the output pin's allocator buffer by specifying width and height
HRESULT OutputPin :: SetMediaType(const CMediaType* pmt) fn...
{
// I doubted whether it is possible to change the output pin;'s size with this method
// The reason is it is CMediaType is constant so they may not allow us to change the media type.
// It is true , we are in need to change only the output video size ... which resides in the pointer(pbFormat) so we can change it easily
VIDEOINFOHEADER* pvi = (VIDEOINFOHEADER*) pmt->pbFormat;
pvi ->bmiHeader.biWidth = 400;
pvi->bmiHeader.biHeight = 400;
pvi->bmiHeader.biSizeImage = pvi->bmiHeader.biWidth * pvi->bmiHeader.biHeight * (pvi->bmiHeader.biBitCount / 8);
}
I completed both the steps...
Next look on Deliver () fn...
we have to copy the output image to the Output pin's media sample as follows in
InitializeOutputSamples() in CTransformFilter class
Friday, March 30, 2007
Directshow Image File Source Filter problem
Directshow source filter problem :
while developing the filter, I got confusion in the following....
pvi->bmiHeader.biCompression = BI_RGB; //This is the compression format
while using JPEG we have to use BI_JPEG and for PNG we have to change it as BI_PNG...
But I didnt do anything... if I made it like this for JPEG i got an error...
So what I have done is whatever may be the file format, I simply used the BI_RGB to represent all the types of file formats
regardless of the JPEG or pNg image.. BI_RGB may be acceptable due to OpenCV...
OpenCV may give the decompressed data as bytes from the file.. For Example if the JPEG is a compressed file..
if we are loading the JPEG image with cvLoadImage() fn ,openCV will loads the decompressed buffer of the JPEg file...
So we need not specify the things in pvi->bmiHeader.biCompression.
HRESULT CMySourceStream::GetMediaType(CMediaType* pMediaType)
{
try
{
HRESULT hr = S_OK;
CheckPointer(pMediaType,E_POINTER);
OutputDebugString("\n CMySourceStream::GetMediaType() fn");
ZeroMemory(pMediaType,sizeof(CMediaType));
VIDEOINFO *pvi = (VIDEOINFO*)pMediaType->AllocFormatBuffer(sizeof(VIDEOINFO));
if(m_pSrcImage == NULL)
{
m_pSrcImage = cvLoadImage("D:\\cartoon.png");
cvFlip(m_pSrcImage);
}
//check the file extension...
//if JPEG or jpg extension - BI_JPEG
//if BMP extension - BI_RGB
//if PNG extension - BI_PNG...
pvi->bmiHeader.biCompression = BI_RGB;
pvi->bmiHeader.biBitCount = (m_pSrcImage->nChannels * 8 );
pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pvi->bmiHeader.biWidth = m_pSrcImage->width;
pvi->bmiHeader.biHeight = m_pSrcImage->height;
pvi->bmiHeader.biPlanes = 1;
pvi->bmiHeader.biSizeImage = m_pSrcImage->imageSize;
pvi->bmiHeader.biClrImportant = 0;
SetRectEmpty(&(pvi->rcSource));
SetRectEmpty(&(pvi->rcTarget));
pMediaType->SetType(&MEDIATYPE_Video);
pMediaType->SetFormatType(&FORMAT_VideoInfo);
pMediaType->SetTemporalCompression(FALSE);
//pMediaType->SetSubtype(&MEDIASUBTYPE_Vi)
const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader);
pMediaType->SetSubtype(&SubTypeGUID);
pMediaType->SetSampleSize(pvi->bmiHeader.biSizeImage);
m_bmpInfo.bmiHeader = pvi->bmiHeader;
return hr;
}
catch(...)
{
OutputDebugString("\n Errror in CMySourceStream::GetMediaType() fn");
return E_FAIL;
}
}
while developing the filter, I got confusion in the following....
pvi->bmiHeader.biCompression = BI_RGB; //This is the compression format
while using JPEG we have to use BI_JPEG and for PNG we have to change it as BI_PNG...
But I didnt do anything... if I made it like this for JPEG i got an error...
So what I have done is whatever may be the file format, I simply used the BI_RGB to represent all the types of file formats
regardless of the JPEG or pNg image.. BI_RGB may be acceptable due to OpenCV...
OpenCV may give the decompressed data as bytes from the file.. For Example if the JPEG is a compressed file..
if we are loading the JPEG image with cvLoadImage() fn ,openCV will loads the decompressed buffer of the JPEg file...
So we need not specify the things in pvi->bmiHeader.biCompression.
HRESULT CMySourceStream::GetMediaType(CMediaType* pMediaType)
{
try
{
HRESULT hr = S_OK;
CheckPointer(pMediaType,E_POINTER);
OutputDebugString("\n CMySourceStream::GetMediaType() fn");
ZeroMemory(pMediaType,sizeof(CMediaType));
VIDEOINFO *pvi = (VIDEOINFO*)pMediaType->AllocFormatBuffer(sizeof(VIDEOINFO));
if(m_pSrcImage == NULL)
{
m_pSrcImage = cvLoadImage("D:\\cartoon.png");
cvFlip(m_pSrcImage);
}
//check the file extension...
//if JPEG or jpg extension - BI_JPEG
//if BMP extension - BI_RGB
//if PNG extension - BI_PNG...
pvi->bmiHeader.biCompression = BI_RGB;
pvi->bmiHeader.biBitCount = (m_pSrcImage->nChannels * 8 );
pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pvi->bmiHeader.biWidth = m_pSrcImage->width;
pvi->bmiHeader.biHeight = m_pSrcImage->height;
pvi->bmiHeader.biPlanes = 1;
pvi->bmiHeader.biSizeImage = m_pSrcImage->imageSize;
pvi->bmiHeader.biClrImportant = 0;
SetRectEmpty(&(pvi->rcSource));
SetRectEmpty(&(pvi->rcTarget));
pMediaType->SetType(&MEDIATYPE_Video);
pMediaType->SetFormatType(&FORMAT_VideoInfo);
pMediaType->SetTemporalCompression(FALSE);
//pMediaType->SetSubtype(&MEDIASUBTYPE_Vi)
const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader);
pMediaType->SetSubtype(&SubTypeGUID);
pMediaType->SetSampleSize(pvi->bmiHeader.biSizeImage);
m_bmpInfo.bmiHeader = pvi->bmiHeader;
return hr;
}
catch(...)
{
OutputDebugString("\n Errror in CMySourceStream::GetMediaType() fn");
return E_FAIL;
}
}
Directshow source filter Error
I developed the source filter for displaying numbers on the screen...
The code related to this ...
HRESULT CMySourceStream::GetMediaType(CMediaType* pMediaType)
{
try
{
HRESULT hr = S_OK;
CheckPointer(pMediaType,E_POINTER);
OutputDebugString("\n CMySourceStream::GetMediaType() fn");
ZeroMemory(pMediaType,sizeof(CMediaType));
VIDEOINFO *pvi = (VIDEOINFO*)pMediaType->AllocFormatBuffer(sizeof(VIDEOINFO));
pvi->bmiHeader.biCompression = BI_RGB;
pvi->bmiHeader.biBitCount = 24;
pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pvi->bmiHeader.biWidth = 300;
pvi->bmiHeader.biHeight = 300;
pvi->bmiHeader.biPlanes = 1;
pvi->bmiHeader.biSizeImage = pvi->bmiHeader.biWidth * pvi->bmiHeader.biHeight * (pvi->bmiHeader.biBitCount/8);
pvi->bmiHeader.biClrImportant = 0;
SetRectEmpty(&(pvi->rcSource));
SetRectEmpty(&(pvi->rcTarget));
pMediaType->SetType(&MEDIATYPE_Video);
pMediaType->SetFormatType(&FORMAT_VideoInfo);
pMediaType->SetTemporalCompression(FALSE);
//pMediaType->SetSubtype(&MEDIASUBTYPE_Vi)
const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader);
pMediaType->SetSubtype(&SubTypeGUID);
pMediaType->SetSampleSize(pvi->bmiHeader.biSizeImage);
m_bmpInfo.bmiHeader = pvi->bmiHeader;
return hr;
}
catch(...)
{
OutputDebugString("\n Errror in CMySourceStream::GetMediaType() fn");
return E_FAIL;
}
}
But I faced the following problem...
---------------------------
GraphEdit
---------------------------
Sorry, the Filter Graph cannot render this pin.
Class not registered (Return code: 0x80040154)
---------------------------
OK
---------------------------
Solution :
--------------
1.I added the checkMediaType() fn as follows...
CheckMediaType() is an important Function for any filter....
without it, the filter will not work...
HRESULT CMySourceStream::CheckMediaType(const CMediaType *pMediaType)
{
CheckPointer(pMediaType,E_POINTER);
try
{
OutputDebugString("\n CheckMediaType fn...");
if((*(pMediaType->Type()) != MEDIATYPE_Video) || // we only output video
!(pMediaType->IsFixedSize())) // in fixed size samples
{
return E_INVALIDARG;
}
// Check for the subtypes we support
const GUID *SubType = pMediaType->Subtype();
if (SubType == NULL)
return E_INVALIDARG;
if(*SubType != MEDIASUBTYPE_RGB24)
{
return E_INVALIDARG;
}
// Get the format area of the media type
VIDEOINFO *pvi = (VIDEOINFO *) pMediaType->Format();
if(pvi == NULL)
return E_INVALIDARG;
if(pvi->bmiHeader.biBitCount==24)
return NOERROR;
else
return E_INVALIDARG;
}
catch(...)
{
OutputDebugString("\n Exception in CheckMediaType() fn...");
return E_INVALIDARG;
}
}
The code related to this ...
HRESULT CMySourceStream::GetMediaType(CMediaType* pMediaType)
{
try
{
HRESULT hr = S_OK;
CheckPointer(pMediaType,E_POINTER);
OutputDebugString("\n CMySourceStream::GetMediaType() fn");
ZeroMemory(pMediaType,sizeof(CMediaType));
VIDEOINFO *pvi = (VIDEOINFO*)pMediaType->AllocFormatBuffer(sizeof(VIDEOINFO));
pvi->bmiHeader.biCompression = BI_RGB;
pvi->bmiHeader.biBitCount = 24;
pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pvi->bmiHeader.biWidth = 300;
pvi->bmiHeader.biHeight = 300;
pvi->bmiHeader.biPlanes = 1;
pvi->bmiHeader.biSizeImage = pvi->bmiHeader.biWidth * pvi->bmiHeader.biHeight * (pvi->bmiHeader.biBitCount/8);
pvi->bmiHeader.biClrImportant = 0;
SetRectEmpty(&(pvi->rcSource));
SetRectEmpty(&(pvi->rcTarget));
pMediaType->SetType(&MEDIATYPE_Video);
pMediaType->SetFormatType(&FORMAT_VideoInfo);
pMediaType->SetTemporalCompression(FALSE);
//pMediaType->SetSubtype(&MEDIASUBTYPE_Vi)
const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader);
pMediaType->SetSubtype(&SubTypeGUID);
pMediaType->SetSampleSize(pvi->bmiHeader.biSizeImage);
m_bmpInfo.bmiHeader = pvi->bmiHeader;
return hr;
}
catch(...)
{
OutputDebugString("\n Errror in CMySourceStream::GetMediaType() fn");
return E_FAIL;
}
}
But I faced the following problem...
---------------------------
GraphEdit
---------------------------
Sorry, the Filter Graph cannot render this pin.
Class not registered (Return code: 0x80040154)
---------------------------
OK
---------------------------
Solution :
--------------
1.I added the checkMediaType() fn as follows...
CheckMediaType() is an important Function for any filter....
without it, the filter will not work...
HRESULT CMySourceStream::CheckMediaType(const CMediaType *pMediaType)
{
CheckPointer(pMediaType,E_POINTER);
try
{
OutputDebugString("\n CheckMediaType fn...");
if((*(pMediaType->Type()) != MEDIATYPE_Video) || // we only output video
!(pMediaType->IsFixedSize())) // in fixed size samples
{
return E_INVALIDARG;
}
// Check for the subtypes we support
const GUID *SubType = pMediaType->Subtype();
if (SubType == NULL)
return E_INVALIDARG;
if(*SubType != MEDIASUBTYPE_RGB24)
{
return E_INVALIDARG;
}
// Get the format area of the media type
VIDEOINFO *pvi = (VIDEOINFO *) pMediaType->Format();
if(pvi == NULL)
return E_INVALIDARG;
if(pvi->bmiHeader.biBitCount==24)
return NOERROR;
else
return E_INVALIDARG;
}
catch(...)
{
OutputDebugString("\n Exception in CheckMediaType() fn...");
return E_INVALIDARG;
}
}
Monday, March 26, 2007
Display video after Pause the video...
After closing or paused the video in graphedit, I just only got the video as a still without moving...
that means the existing image kept as it is. My code which cause this problem...
void CAbsDiffFilter::Run()
{
for (i=0;i< m_nInputPinsCount;i++)
{
if (m_ip[i]->IsConnected() == FALSE)
{
NotConnected=true;
break;
}
}
if (NotConnected)
{
for (i=0;i m_ip[i]->EndOfStream();
}
hr = CBaseFilter::Run(tStart);
return hr;
}
Modified code :...
void CAbsDiffFilter::Run()
{
hr = CBaseFilter::Run(tStart);
for (i=0;i< m_nInputPinsCount;i++)
{
if (m_ip[i]->IsConnected() == FALSE) // if input pins are not connected
//m_ip[i] are input pins...
{
NotConnected=true;
break;
}
}
if (NotConnected)
{
for (i=0;i m_ip[i]->EndOfStream();
}
return hr;
}
that means the existing image kept as it is. My code which cause this problem...
void CAbsDiffFilter::Run()
{
for (i=0;i< m_nInputPinsCount;i++)
{
if (m_ip[i]->IsConnected() == FALSE)
{
NotConnected=true;
break;
}
}
if (NotConnected)
{
for (i=0;i
}
hr = CBaseFilter::Run(tStart);
return hr;
}
Modified code :...
void CAbsDiffFilter::Run()
{
hr = CBaseFilter::Run(tStart);
for (i=0;i< m_nInputPinsCount;i++)
{
if (m_ip[i]->IsConnected() == FALSE) // if input pins are not connected
//m_ip[i] are input pins...
{
NotConnected=true;
break;
}
}
if (NotConnected)
{
for (i=0;i
}
return hr;
}
Friday, March 23, 2007
AbsDiff() filter error
AbsDiff filter Error :
we can add the filter in two ways...
1. First we render two media files and insert the AbsDiff filter(two
input pin filter...). In this way, the filter works well...
2.Second way, we insert the filter first and then render the two media
files, it will automatically connect to the AbsDiff Filter( Two Input Pin
filter...)
In the second way, i got the error...
I am not able to identify the error where it is...
Solution :
I previously have the input and output pin's CheckMediaType() as follows..
HRESULT CheckMediaType(const CMediaType* pmt)
{
// Check this is a VIDEOINFO type
if (*pmt->FormatType() != FORMAT_VideoInfo)
{
return E_INVALIDARG;
}
VIDEOINFO* vi = (VIDEOINFO*)pmt->Format();
if(vi->bmiHeader.biBitCount != 24)
{
return E_INVALIDARG;
}
return NOERROR;
}
I changed the input and output pin's CheckMediaType as follows...
HRESULT cvSyncOutputPin::CheckMediaType(const CMediaType* pMediaType)
{
// Check this is a VIDEOINFO type
// we accept the following image type: (RGB24, ARGB32 or RGB32)
if (IsEqualGUID(*pMediaType->Type(), MEDIATYPE_Video))
{
if (IsEqualGUID(*pMediaType->Subtype(), MEDIASUBTYPE_RGB24))
{
VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER *) pMediaType->Format();
if(pvi->bmiHeader.biBitCount == 24)
{
return NOERROR;
}
}
}
return E_INVALIDARG;
}
So the Problem lies in while we check the media type,
we checked the FormatType() of the input media type...
I changed it as only checking MEDIATYPE (Type())and MEDIASUBTYPE (SubType())
of the input media type...
This is the excellent problem solving ... I didnt met before like this...
(vennai Olungaa program pannuda...)
I solved the problem of Intelligent Connect ... The problem is due to the CheckMediaType() conditions.....
I changed the CheckMediaType() fn conditions as like as TransformFilter....
Now It is working...
The problem is CheckMediaType() fn...
we can add the filter in two ways...
1. First we render two media files and insert the AbsDiff filter(two
input pin filter...). In this way, the filter works well...
2.Second way, we insert the filter first and then render the two media
files, it will automatically connect to the AbsDiff Filter( Two Input Pin
filter...)
In the second way, i got the error...
I am not able to identify the error where it is...
Solution :
I previously have the input and output pin's CheckMediaType() as follows..
HRESULT CheckMediaType(const CMediaType* pmt)
{
// Check this is a VIDEOINFO type
if (*pmt->FormatType() != FORMAT_VideoInfo)
{
return E_INVALIDARG;
}
VIDEOINFO* vi = (VIDEOINFO*)pmt->Format();
if(vi->bmiHeader.biBitCount != 24)
{
return E_INVALIDARG;
}
return NOERROR;
}
I changed the input and output pin's CheckMediaType as follows...
HRESULT cvSyncOutputPin::CheckMediaType(const CMediaType* pMediaType)
{
// Check this is a VIDEOINFO type
// we accept the following image type: (RGB24, ARGB32 or RGB32)
if (IsEqualGUID(*pMediaType->Type(), MEDIATYPE_Video))
{
if (IsEqualGUID(*pMediaType->Subtype(), MEDIASUBTYPE_RGB24))
{
VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER *) pMediaType->Format();
if(pvi->bmiHeader.biBitCount == 24)
{
return NOERROR;
}
}
}
return E_INVALIDARG;
}
So the Problem lies in while we check the media type,
we checked the FormatType() of the input media type...
I changed it as only checking MEDIATYPE (Type())and MEDIASUBTYPE (SubType())
of the input media type...
This is the excellent problem solving ... I didnt met before like this...
(vennai Olungaa program pannuda...)
I solved the problem of Intelligent Connect ... The problem is due to the CheckMediaType() conditions.....
I changed the CheckMediaType() fn conditions as like as TransformFilter....
Now It is working...
The problem is CheckMediaType() fn...
Subscribe to:
Posts (Atom)