Thursday, June 19, 2008

WinCE Live Capture ControlStream problem

ControlStream Function:
------------------------

m_pCaptureGraphBuilder2->ControlStream //Stop the capture Pin
(
&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video,
m_pVideoCaptureFilter,
&rtStart,
&rtStop,1,2
);


ControlStream of Live Source will do the Start and Stop of the Stream;


0,MAXLONGLONG - To Start the Stream
MAXLONGLONG,0 - To Stop the Stream;

Problem :
----------
1. I have Stopped the Capture Pin and Started the Preview Pin using
ControlStream() fn;

it gives the Black rectangle instead of rendering video;

Solution;
---------
I have deeply analyzed the Stream;

Reason for the problem is I have not Started the MediaControl using
Run() method;


if I called the IMediaControl's Run() method it works fine;


HRESULT StartPreview()
{

HRESULT hr = S_OK;
REFERENCE_TIME rtPreviewStart = 0,rtPreviewStop = MAXLONGLONG;
REFERENCE_TIME rtStart, rtStop;
rtStart = MAXLONGLONG;
rtStop = 0;


hr = m_pCaptureGraphBuilder2->ControlStream //Stop the capture Pin
(
&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video,
m_pVideoCaptureFilter,
&rtStart,
&rtStop,1,2
);

if(FAILED(hr))
{
printf("\n VideoControlStream() Stop Failure Error Code:%x",hr);
return hr;
}
//Start the Preview Stream
hr = m_pCaptureGraphBuilder2->ControlStream( &PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Video,
m_pVideoCaptureFilter,
&rtPreviewStart, // Start now.
&rtPreviewStop, // (Don't care.)
3,4
);


if(FAILED(hr))
{
printf("\n ControlStream() fn Error : %x",hr);
return hr;
}

hr = m_pCaptureGraphBuilder2->ControlStream( &PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Audio,
m_pAudioCaptureFilter,
&rtStart, // Start now.
&rtStop, // (Don't care.)
5,6
);


if(FAILED(hr))
{
printf("\n Audio ControlStream() Stop Failure Error Code:%x",hr);
return hr;
}
}

if(m_pMediaControl)
{
m_pMediaControl->Run();
}

return hr;


}

No comments: