Wednesday, November 11, 2009
Some times I feel like...
Thursday, June 25, 2009
Learnings
Today I learnt two things:
1.How to load the WMP with local file ?
2.FourCC codes in AVI file format
How to load WMP with local file:
VS2005 debugger :
File path : wmPlayer
command line arguments : file://My documents//incredibles.avi
FourCC codes in AVI file:
FOURCC('0','0','d','c') - video
FOURCC('0','1','w','b') - audio
dc - indicates video stream
wb - indicates audio stream
00 - indicates the Stream number
01 - '' ''
Usually video will be the first stream and audio will be the second stream.
But For Some avi files, (Problematic avi file)
we found the audio as first stream and video as second stream.
So we need to check only the dc or wb to identify the stream type ( video or audio).
Monday, May 11, 2009
waiting for the right chance
I am waiting for the right chance to die.
Friday, April 10, 2009
How to handle seek operation in Splitter or Source Filter ?
-----------------------------------------------------------
1.SetPositions () called multiple times for a Single Seek operation.
2.we have to Set m_bSeeked variable in SetPositions() and Start Seek position
3.We have to store the Previous Seek value.within FillBuffer(), if m_bSeeked set,check for the seeked position and Previous seek position. if they are different, then send a seek request tostack or file parser.
So even Multiple SetPositions () ( 3 times) called for a single seek, operation from our filter we will send a seek request onceby having seeked Flag and Checking the Previous seek position with current seek position.
During Seeking, FillBuffer must not wait for any event... it must be unblocked ... ( Set Positions () fn will call flushing in all the output pins. Flushing will wait for the FillBuffer to complete its operation.
Tuesday, March 31, 2009
How to Assert the thread was closed (dead) or Not ?
WaitForSingleObject( hThread, INFINITE) ; // This statement will blocks until the thread dies.
if the Thread comes out of the loop, then hThread handle is like signalled.
The Next statement to WaitForSingleObject () will be executed.
How to modify the 3gp streaming filter to read Only rtp data?
================================================
( 3gp streaming stack it will receives the rtsp and rtp data)
Solution:Quick and dirty way to do this:
===============================
Use Some SDP file to create the dummy audio and video output pin. ( We can create it with rtsp:// URL itself);
Hard code the media type, File duration (instead of the file duration configure duration as much as we need to receive data for RTP),config data in a filter .
How to get SDP file for any RTSP file?
RTSP response will have the SDP description
if we are having rtsp URL, we can open it with Quick time Player and at the same time, we can open the Ethereal to capture the net logs.
RTSP response RTSP/1.1 200 OK will have a SDP description.
Even with this SDP description and save it into SDP file and open it in Quick time, we are able to play it in Quick time
Sunday, March 29, 2009
Audio goes off after seeking several times
Audio goes off after seeking several times :
When I seek several times, the audio goes off.
Reason:
After seeking, negative timestamps are set to video and audio media samples.
In case of video even though it was negative, it was rendered.But In case of audio,
it was not rendered fine because the audio is the reference clock for both video and audio.
Moreover audio and video are synchronized with this audio timestamp.
So the audio timestamp must not be negavtive, after seeking. if it is so, we cant predict the
rendering ( Sometimes it might render and sometimes it may not render)
Solution:
I modified Source filter in such a way to output positive timestamp for video and audio after seeking. Now the issue was resolved.
Wednesday, March 04, 2009
RegSvr32 error
I am able to compile the filter ; while registering I got the following error:
---------------------------
RegSvr32
---------------------------
DllRegisterServer in D:\PushSource\Debug_Unicode\PushSource.dll failed.
Return code was: 0xc0000005
---------------------------
OK
---------------------------
Solution:
============
This error will come if any dependency has been removed
The problem is it doesnt have any dependency. I have checked it with depends.exe.
CFactoryTemplate g_Templates[3] =
{
{
g_wszPushDesktop, // Name
&CLSID_RxVideoReceiver, // CLSID
CRxReceiver::CreateInstance, // Method to create an instance of MyComponent
NULL, // Initialization function
&sudPushSourceDesktop // Set-up information (for filters)
}
};
I modified the above code as
CFactoryTemplate g_Templates[] =
{
{
g_wszPushDesktop, // Name
&CLSID_RxVideoReceiver, // CLSID
CRxReceiver::CreateInstance, // Method to create an instance of MyComponent
NULL, // Initialization function
&sudPushSourceDesktop // Set-up information (for filters)
}
};
Now I am not getting any errors.
if I g_Templates[3] means, the regsvr32.exe expects the another 2 GUIDs and informations. Since it doesnt have the values,
it gives read violation error.
Tuesday, February 24, 2009
WindowsMobile Microsoft video renderer crashes for Odd resolution width
AKY=00080001 PC=03fa0060(coredll.dll+0x00054060) RA=0305798c(quartz.dll+0x0007398c) BVA=29b9a01c FSR=00000007
Unhandled exception at 0x03fa0060 in wmplayer.exe: 0xC0000005: Access violation reading location 0x01b9a01c.
Unhandled exception at 0x03fa0060 in wmplayer.exe: 0xC0000005: Access violation reading location 0x01b9a01c.
DecideBufferSize () size as 179x99*2
SetActualDatalength() as 179x99 * 2
Solution :
--------------
if I modified the DecideBufferSize to 180x99*2 then it is working fine.
renderer is doing some alignment for odd resolution clip is it so ?
Before giving the output to the renderer from our decoder, we need to align width and height to multiple's 0f 4 or 2;
----------------
if( nFrameWidth & 0x03)
{
nFrameWidth = nFrameWidth - ( nFrameWidth & 0x03);
}
Alignment to 2 :
-----------------
if(nFrameWidth & 0x01)
{
nFrameWidth = nFrameWidth - 1;
}
Monday, February 23, 2009
fatal error LNK1104: cannot open file 'x0__ar10.lib'
fatal error LNK1104: cannot open file 'x0__ar10.lib'
Solution:
-------------------
Search this library in Visual studio 8 installation folder.In the
following path it has that library.
D:\Program Files\Microsoft Visual Studio 8\VC\ce\bin\x86_arm
Thursday, February 19, 2009
Regarding the how to set the relative path:
==================================================
D:\tech\code\fileformats\3gpp\reader
..\..\..\..\inc
it refers the path as follows:
excape from the four directories:
D:\tech\inc
My Current directory is as follows:
D:\tech\code\Apps\Mp4Propertybag_Source\Mp4PropertyPag
common.h file's Current Directory D:\NokiaPCFilters\tech\inc
Relative path: ..\..\..\..\inc
Target directory:
D:\tech\code\fileformats\3gpp\reader\inc
Relative path:
..\..\..\fileformats\3gpp\reader\inc
Target Dir:
-------------
D:\tech\code\fileformats\3gpp\inc
Relative path:
--------------
..\..\..\fileformats\3gpp\inc
Target dir:
--------------
D:\tech\code\filters\inc
Relative path:
--------------
..\..\..\filters\inc
Integer division by error with Audio Decoder filter
i) if I deliver it then I got a crash in Decoder as "Integer division by zero".
So I modified the AvgBytesPerSec member of WAVEFORMATEX structure as follows:
wfx.nBlockAlign = 1 ;
wfx.nAvgBytesPerSec = MP3hdr->bitrate * 1000 / 8;
Solution:
--------------
Assign the proper values for WAVEFORMATEX header.
Modified value as follows Now the Filter is working fine.
wfx.nBlockAlign = 2 * nchannels ;
wfx.nAvgBytesPerSec = pwfxout->wfx.nSamplesPerSec * pwfxout->wfx.nBlockAlign ;
Wednesday, February 18, 2009
How to do dynamic format change from the Decoder Filter?...
How to do dynamic format change from the Decoder Filter?...
Scenario:
-------------
Assume that we reading video data from the RTP or from real media file.
we will receive the video with 320x240 resolution. In the middle of the stream, it might give you video data with 640x480
resolution. How will u handle the situation ? we can do it with Dynamic format change.
what needs to be done at decoder level:
---------------------------------------
For getting width and height, we will refer the config data from the Source filter's VIDEOINFOHEADER config data or from
the video frame itself have the config information .
We have the Create the Decoder with current width and height( 320x240) resolution.
DecodeFrame() fn itself must have the ability to detect new config. if some new config arrived, the DecodeFrame () returns
E_NEW_CONFIG;
when the new width and height found, we have to delete/release the decoder ( Not a decoder filter) and we have to
create the new decoder with new resolution and then try to decode the frame.
Here we need to change Decoder filter's output pin media type as well as the reallocate renderer's allocator with new
resolution.
Logic is as follows:
if( DecodeFrame() == E_NEW_CONFIG)
{
DeleteDecoder();
hr =CreateDecoder(newWidth,newHeight);
//Change the output pin's media type resolution
//Rellocate the renderer's allocator with new resolution (640x480)
//DecodeFrame() once again and give it out.
}
if we want the dynamic format change, we have to use upstream filter's(video renderer) allocator .
For Windows mobile:
-------------------
Microsoft video renderer doesnt have the dynamic format change support.
So we can develop the new video renderer.
if( DecodeFrame() == E_NEW_CONFIG)
{
DeleteDecoder();
hr =CreateDecoder(newWidth,newHeight);
//Change the output pin's media type resolution
//Rellocate the renderer's allocator with new resolution (640x480)
hr = m_pInput->ReceiveConnection(m_pOutput,mediatypeWithNewRes); // m_pInput is just a pointer to upstream
filter's // input pin ( video renderer input pin
DecodeFrame();
Deliver(pSample);
}
In Video renderer:
-------------------
upstream filter input pin (Renderer input Pin):
we have to override the ReceiveConnection() fn;
HRESULT ReceiveConnection(IPin* m_Connected, AM_MEDIA_TYPE* mtWithNewRes)
{
if( m_Connected)
{
// this condition will be satisfied if ReceiveConnection() called from the Decoder manually (while // the graph was running
int Width = getWidth(mtwithNewRes);
int height = getHeight(mtWithNewRes);
if( CheckMediaType(mtWithNewRes) != S_OK)
{
return E_FAIL;
}
SetMediaType(mtWithNewRes);
m_pAllocator->Decommit();
m_pAllocator->SetProperties(Width,height);
m_pAllocator->Commit();
}
else
{
return CBasePin::ReceiveConnection();
}
}
For PC:
----------
For PC, Video renderer has the support for dynamic format change.
we will do as follows:
within Decoder:
if( DecodeFrame() == E_NEW_CONFIG)
{
DeleteDecoder();
hr =CreateDecoder(newWidth,newHeight);
//Change the output pin's media type resolution
//Rellocate the renderer's allocator with new resolution (640x480)
hr = m_pInput->ReceiveConnection(mediatypeWithNewRes);
m_pInput->m_pAllocator->Decommit();
m_pInput->m_pAllocator->SetProperties(new Resolution Size);
m_pInput->m_pAllocator->Commit();
DecodeFrame();
Deliver(pSample);
}
Renderer have the ability to change to new allocated buffer;;