Wednesday, July 09, 2008

Camera Driver Pin resolution problem


Camera Driver Pin resolution problem:
---------------------------------------------------------
1.Capture pin resolutions must be supported in Preview Pin Resolution;
if Capture Pin resolutions are not matched with the Preview Pin Resolution;
Cause:
--------
This is the bug in camera or capture driver;Capture Pin resolution must be supported in Preview Pin resolution;

Labels: , ,

Tuesday, July 01, 2008

Problem while Playing the video less than one second

Problem while Playing the video less than one second:
-----------------------------------------------------
if the video is having less than one second, media player seek bar never reaches the end position;
I have tested the video which is having less than 8 seconds with
AAC Encoded audio;QCELP Encoded audio,AMR Nb Encoded audio in a 3GP file;
I got the Same Error as follows:

For the video less than 1 seconds:
-----------------------------------
GetDuration : 7930000
End Stop value of Media Sample is : 7190001
7190001 / 7930000 = 0.90 So the Trackbar is not shown at the end of the media player




For Video > 1 seconds:
-------------------
GetDuration : 172400000
End Stop Value of Media Sample is : 172200001
172200001 /172400000 = 0.99 So the Error is not shown clearly in this large video;
The Track bar never reaches the end position of the media player;
So the Problem is with the Timestamp calculation;

Labels: ,

No Time stamp has been set for this sample Error

I got the "No Time stamp has been set for this sample" while playing the 3gp file;
-----------------------------------------------------------------------------------
HRESULT FillBuffer()
{
HRESULT hr;
hr = GetMP4Sample (pSample);
if(SUCCEEDED(hr))
{
REFERENCE_TIME rtStart = 0, rtStop = 0;
hr = pSample->GetTime(&rtStart, &rtStop);
if(SUCCEEDED(hr))
{
wchar_t szMsg[MAX_PATH];
swprintf(szMsg,L"\n 0-vid,1- audio,TrackType = %d, Start = %ld, Stop : %ld",m_nTrakType,(LONG)rtStart,(LONG) rtStop);
OutputDebugString(szMsg);
}
}
return hr;

}



Solution:
===========
the above code displays the "No timestamp has been set for this sample " error;
Reason is
if GetTime() is failed, then that hr value will be returned from the
FillBuffer() fn; So I got this error; if I modified it as follows, then I wont get an error;

hr = GetMP4Sample (pSample);
if(SUCCEEDED(hr))
{
REFERENCE_TIME rtStart = 0, rtStop = 0;
HRESULT temphr = pSample->GetTime(&rtStart, &rtStop);
if(SUCCEEDED(temphr))
{
wchar_t szMsg[MAX_PATH];
swprintf(szMsg,L"\n 0-vid,1- audio,TrackType = %d, Start = %ld, Stop : %ld",m_nTrakType,(LONG)rtStart,(LONG) rtStop);
OutputDebugString(szMsg);
}
}

Labels: ,

Record the video and audio using PIMG with desired video and audio encoder

Record the video and audio using PIMG with desired video and audio encoder:
----------------------------------------------------------------------------

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Pictures\Camera\OEM\AudioEncoderClassID as AAC Encoder's ClassID
\VideoProfile\1\AudioEncoderCLassID
\VideoProfile\2\AudioEncoderClassID
\VideoProfile\3\AudioEncoderClassID;
\VideoEncoderClassID
\MuxerClassID

{f0db0b53-53ff-49b9-8c51-4ed44cec6d46} - AAC Encoder
just copy our encoder DMO class ID at the above specified registry location;
The Pimg ( Microsoft's PIMG pictures and videos) record , encode and multiplex the video according to the OEM registry settings;
I have tested this behavior in Motorola; But some mobiles may not implement this behavior; Example : Asus;
By Default if it is recording wmv file means, those informations will be available in this registry location;

Labels: , ,

Friday, June 27, 2008

Performance of video rendering in Capture application

Performance of video rendering in Capture application
-------------------------------------------------------------------------------
I am loading the COM environment for every graph building;
Loading of COM environment and releasing of an environment done by CoInitialize() fn and
CoUninitialize() fn;
it takes much time to render the video in Recorder application ( loading of COM environment every time takes much time);
if I am loading the COM environment everytime that takes much time but if I am loading the COM
environment only once that makes the rendering of video so fast compare to everytime loading of
COM environment;

Labels:

Error While Releasing the Dshow Filters ( Windows Mobile)

Error while releasing filters:
-------------------------------
Data Abort: Thread=8a9e50b4 Proc=88a8b6d0 'RecorderApp.exe'
AKY=00020001 PC=000175f8(RecorderApp.exe+0x000075f8) RA=0001562c(RecorderApp.exe+0x0000562c) BVA=24000008 FSR=00000007
Solution:
----------
Just Stop the Recording using ControlStream() fn and Stop the Media Control ( pMediacontrol->Stop() fn);
and then Release the filters; this error wont occur;

Labels:

CLSID_VideoCapture Filter Problem in windows Mobile Recorder application

CLSID_VideoCapture Filter problem:
----------------------------------------
I have developed the video capture application;
I have created the object for video capture filter( CoCreateInstance(CLSID_VideoCapture)),
and rendered the video successfully, if I released the video capture filter and created the CoCreateInstance(CLSID_VideoCapture Filter) I got the problem
in
PropertyBag->Load() fn;


CComPtr m_pPropertyBag;
CPropertyBag m_PropBag;
CComVariant m_varCamName;

hr = CoCreateInstance( CLSID_VideoCapture, NULL, CLSCTX_INPROC,
IID_IBaseFilter, (void** ) &m_pVideoCaptureFilter );

hr = m_pVideoCaptureFilter->QueryInterface( &m_pPropertyBag );
m_varCamName = _T ("CAM1:");
hr = m_PropBag.Write( L"VCapName", &m_varCamName );
hr = m_pPropertyBag->Load( &m_PropBag, NULL);
m_pPropertyBag.Release();
If I released the video capture filter and created the Second time , I got the error in


hr = m_pPropertyBag->Load( &m_PropBag, NULL); fn, it returns error as
" The Specified network resource or device is no longer available"


Solution:
------------
Error Message indicates "Video capture filter was not properly released;"
We need to release it properly;



We are releasing the video Capture Filter properly But it is not released; So Next time we got problems;
So Just confirm it, we have to release the video capture Filters only after all the Streams are stopped;




Code:
---------
For Releasing All the Filters and their Pins use the following code:

For Releasing the Source Filter use the following two methods and release all other things normally;
void CRecorder::NukeDownstream(IBaseFilter *pf)
{
IPin *pP=0, *pTo=0;
ULONG u;
IEnumPins *pins = NULL;
PIN_INFO pininfo;
if (!pf)
return;
HRESULT hr = pf->EnumPins(&pins);
pins->Reset();
while(hr == NOERROR)
{
hr = pins->Next(1, &pP, &u);
if(hr == S_OK && pP)
{
pP->ConnectedTo(&pTo);
if(pTo)
{
hr = pTo->QueryPinInfo(&pininfo);
if(hr == NOERROR)
{
if(pininfo.dir == PINDIR_INPUT)
{
NukeDownstream(pininfo.pFilter);
m_pGraphBuilder->Disconnect(pTo);
m_pGraphBuilder->Disconnect(pP);
m_pGraphBuilder->RemoveFilter(pininfo.pFilter);
}
pininfo.pFilter->Release();
}
pTo->Release();
}
pP->Release();
}
}
if(pins)
pins->Release();
}



void CRecorder::MyNukeDown( IBaseFilter *pFilter )
{
IEnumPins *pEnumPins;
IPin *pPin;
ULONG uNumPin;
HRESULT hr;
do
{
if( NULL == pFilter )
{
break;
}
hr = pFilter->EnumPins(&pEnumPins);
pEnumPins->Reset();
if( FAILED(hr) )
{
break;
}
while( S_OK == pEnumPins->Next( 1, &pPin, &uNumPin ) )
{
hr = m_pGraphBuilder->Disconnect(pPin);
if( S_OK != hr )
{
OutputDebugString(L"\n Disconect Failed");
}
}
m_pGraphBuilder->RemoveFilter( pFilter );
pFilter->Release();
//HELPER_RELEASE( pFilter );
pPin->Release();
pEnumPins->Release();
}while( FALSE );
}
Usage of this code is as follows:
NukeDownstream(m_pVideoCaptureFilter);
MyNukeDown(m_pVideoCaptureFilter);
CHECK_AND_RELEASE_COM_QI(m_pVideoWindow);
#ifdef _STILL
CHECK_AND_RELEASE_COM(m_pIImageSinkFilter);
CHECK_AND_RELEASE_COM(m_pImageSinkFilter);
#endif

CHECK_AND_RELEASE_COM(m_pVideoRenderer);
CHECK_AND_RELEASE_COM(m_pVideoEncoder);
CHECK_AND_RELEASE_COM(m_pVideoCaptureFilter);

Labels:

Dshow Camera capture application Problem in Windows Mobile


Dshow Camera capture application Problem in Windows Mobile:
-----------------------------------------------------------
pimg.exe (Pictures and videos) behavior:
-----------------------------------------
if we are writing camera capture application, whenever the user hits Home button, the application must release the
Video and audio Capture Source; whenever the back button is pressed (if available) or Thru Task manager they switch to the Camera application ,
the camera capture application must starts its execution normally (render video from video source);
It makes use of the video and audio capture filters;
So Every camera capture application must follow this behavior;
I am writing the camera capture application, whenever the user hits the Home Button, the application focus is changed;
So The Windows Mobile OS will send the following messages sequentially;
1.WM_ACTIVATE 's WA_INACTIVE
2.WM_ACTIVATE 's WA_ACTIVE

So whenever the user hits the Home button, the WM_ACTIVATE message with WA_INACTIVE fired.
Steps:
-------
1.Home Button was pressed ( that indicates WM_ACTIVATE's WA_INACTIVE),Release the video and audio capture filters in WM_ACTIVATE's WA_INACTIVE and
set the boolean variable bInActive as TRUE;
2.When Back button was pressed, The camera application was focused; But it didnt get any message like focus or Activate app or WM_ACTIVATE message;
So what I did was, whenever our camera application got focus, it must paint the camera application window;
So within WM_PAINT message, I will check if bInActive flag was set, then CreateInstance for the video capture filter and audio capture filter and Starts rendering video;

Labels: , ,

Dshow Camera capture application Problem in Windows Mobile

Dshow Camera capture application Problem in Windows Mobile:
-----------------------------------------------------------
pimg.exe (Pictures and videos) behavior:
-----------------------------------------
if we are writing camera capture application, whenever the user hits Home button, the application must release the
Video and audio Capture Source; whenever the back button is pressed (if available) or Thru Task manager they switch to the Camera application ,
the camera capture application must starts its execution normally (render video from video source);
It makes use of the video and audio capture filters;
So Every camera capture application must follow this behavior;
I am writing the camera capture application, whenever the user hits the Home Button, the application focus is changed;
So The Windows Mobile OS will send the following messages sequentially;
1.WM_ACTIVATE 's WA_INACTIVE
2.WM_ACTIVATE 's WA_ACTIVE

So whenever the user hits the Home button, the WM_ACTIVATE message with WA_INACTIVE fired.
Steps:
-------
1.Home Button was pressed ( that indicates WM_ACTIVATE's WA_INACTIVE),Release the video and audio capture filters in WM_ACTIVATE's WA_INACTIVE and
set the boolean variable bInActive as TRUE;
2.When Back button was pressed, The camera application was focused; But it didnt get any message like focus or Activate app or WM_ACTIVATE message;
So what I did was, whenever our camera application got focus, it must paint the camera application window;
So within WM_PAINT message, I will check if bInActive flag was set, then CreateInstance for the video capture filter and audio capture filter and Starts rendering video;

Labels: , ,

Monday, April 21, 2008

Problems Faced in registering the Filter DLL in Windows CE

Problems Faced in registering the Filter DLL in Windows CE:
-----------------------------------------------------------
I faced the problem in registering the DLL ;
Solution:
-----------
There is no such file to register the DLL in Windows Mobile Emulator evnvironment like regsvr32 ;
So I developed the my own version of RegSvr32 application with the help of MSDN KB Code;
My Register application will do the following:
1.Loads the DLL
2.GetProcAddress() fn to get the address of the "DllRegisterserver" and call it;
3.Unloads the DLL;
Now it was registered in to the registry;








Because the .def file is not included in DLL project input; what it means was
within this .def file we specified the DLL functions as follows:
DllRegisterServer
DllUnRegisterServer
Then only we will get the correct address of the DllRegisterServer fn. otherwise we will get Null pointer;



One More problem I faced while calling the DllRegisterServer() fn address from My Register application:
The application was hanged and not giving any error, I got the execption within that fn;
I am not able to figure out the problem;


Solution:
-------------
So I checked the MSDN documentation as follows:
For Windows CE,we need to do the following:
STDAPI DllRegisterServer()
{
return AMovieDLLRegisterServer( );// Windows Desktop- AMovieDLLRegisterServer2(TRUE) - these are not supported in WinCE
}
STDAPI DllUnregisterServer()
{
return AMovieDLLUnRegisterServer( ); //Windows desktop-AMovieDLLRegisterServer2(FALSE)to unregister-these are not supported in WinCE
}
However, within DllRegisterServer and DllUnregisterServer you can customize the registration process as needed.
One more thing we need to
CFactoryTemplate g_Templates[] =
{
{
g_wszName, // Name.
&CLSID_SomeFilter, // CLSID.
CSomeFilter::CreateInstance, // Creation function.
NULL,
&sudFilterReg // Pointer to filter information.
}
};
int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);

LPAMOVIESETUP_FILTER CSomeFilter::GetSetupData() //we must implement this one for Windows CE
{
return (LPAMOVIESETUP_FILTER) & sudFilterReg;
}

Labels: ,

Saturday, April 19, 2008

Windows CE Directshiw Filter Error

Windows CE Directshow Filter Error :
-------------------------------------
I developed the Ball Source filter in Windows CE;
I got these errors:
Creating library Pocket PC 2003 (ARMV4)\Release/Ball_Filter.lib and object Pocket PC 2003 (ARMV4)\Release/Ball_Filter.exp
1>fball.obj : error LNK2019: unresolved external symbol "public: __cdecl CSourceStream::CSourceStream(wchar_t *,long *,class CSource *,wchar_t const *)" (??0CSourceStream@@QAA@PA_WPAJPAVCSource@@PB_W@Z) referenced in function "public: __cdecl CBallStream::CBallStream(long *,class CBouncingBall *,wchar_t const *)" (??0CBallStream@@QAA@PAJPAVCBouncingBall@@PB_W@Z)
1>fball.obj : error LNK2001: unresolved external symbol "protected: virtual long __cdecl CSourceStream::QueryId(wchar_t * *)" (?QueryId@CSourceStream@@MAAJPAPA_W@Z)
1>fball.obj : error LNK2019: unresolved external symbol "public: __cdecl CSource::CSource(wchar_t *,struct IUnknown *,struct _GUID)" (??0CSource@@QAA@PA_WPAUIUnknown@@U_GUID@@@Z) referenced in function "private: __cdecl CBouncingBall::CBouncingBall(struct IUnknown *,long *)" (??0CBouncingBall@@AAA@PAUIUnknown@@PAJ@Z)
1>fball.obj : error LNK2001: unresolved external symbol "public: virtual long __cdecl CSource::FindPin(wchar_t const *,struct IPin * *)" (?FindPin@CSource@@UAAJPB_WPAPAUIPin@@@Z)
1>fball.obj : error LNK2001: unresolved external symbol "public: virtual long __cdecl CBaseFilter::JoinFilterGraph(struct IFilterGraph *,wchar_t const *)" (?JoinFilterGraph@CBaseFilter@@UAAJPAUIFilterGraph@@PB_W@Z)
1>fball.obj : error LNK2001: unresolved external symbol "public: virtual long __cdecl CBaseFilter::QueryVendorInfo(wchar_t * *)" (?QueryVendorInfo@CBaseFilter@@UAAJPAPA_W@Z)
1>Pocket PC 2003 (ARMV4)\Release/Ball_Filter.dll : fatal error LNK1120: 6 unresolved externals


Solution Steps:
--------------------
I modified the things in "Release" Mode:

it may be due to calling convention mechanism;
But ARM doesnt have calling convention compiler option( /Gr, Gd,Gz);
Calling convention is applicable only to x86 machines now I am using ARM;

I doubt whether the Strmbase.lib is built in x86; if it is so means, Previously I developed the dshow Player application
with this same "strmbase.lib"; So there is nothing wrong in lib;
I closely watched the all the error fns; they are all contains wchar_t;
It may due to some unicode problem?
Solution:
----------
Project->Properties->C++ ->Language ->
Treat wchar_t as Built In Type:Yes

I just modified this property to No;
Treat wchar_t as Built In Type: No

Now all the linker errors are resolved;
Now I am not having any error;


Note:
---------
Even though I did all the above things in Debug Mode, I got the following error:
Creating library Pocket PC 2003 (ARMV4)\Debug/Ball_Filter.lib and object Pocket PC 2003 (ARMV4)\Debug/Ball_Filter.exp
fball.obj : error LNK2001: unresolved external symbol "public: virtual unsigned long __cdecl CBaseFilter::NonDelegatingRelease(void)" (?NonDelegatingRelease@CBaseFilter@@UAAKXZ)
Pocket PC 2003 (ARMV4)\Debug/Ball_Filter.dll : fatal error LNK1120: 1 unresolved externals
For Debug Mode:
I have added this code within the CSource derived class;
public:
STDMETHODIMP_(ULONG) NonDelegatingAddRef()
{
return InterlockedIncrement(&m_cRef);
}


//-----------------------------------------------------------------------------
// Decrement the reference count for an interface
// ////////////////////////////////////////
STDMETHODIMP_(ULONG) NonDelegatingRelease()
{
if(InterlockedDecrement(&m_cRef) == 0)
{
delete this;
return 0;
}
return m_cRef;
}
Now it is working fine;

I have successfully build the filter code;

Labels: ,