elliottso
December 5th, 2005, 10:30 PM
Hi,
I am trying to implement a video streaming application using the directshow.
The program consists of 3 threads, the TCP control message thread, the UDP stream thread and the main thread. Because of my bad programming manner, the code is hard to read and it would be hard to post here.
The problem is that when the control thread is running, the stream thread cannot proceed and is blocked in the following line:
hr = mRemoteVideoGraph->GetGraph()->Connect(pOut, pIn);
I would like to ask if there are any suggestions about blocking the function.
Thank you.
Marc G
December 6th, 2005, 01:59 AM
[ moved thread ]
elliottso
December 7th, 2005, 01:15 AM
I am still working on the problem.
The graph is first created.
mRemoteVideoGraph = new CDXGraph();
mRemoteVideoGraph->Create();
The following two filers are being created and connected.
mVideoReceiver = new CFilterNetReceiver(NULL, &hr);
IBaseFilter * pFilter = NULL;
mVideoReceiver->QueryInterface(IID_IBaseFilter, (void**)&pFilter);
mRemoteVideoGraph->AddFilter(pFilter, L"Video Receiver");
mVideoRenderer = new CDXFilter(mRemoteVideoGraph->GetGraph(), CLSID_VideoRenderer, "Video Renderer");
mVideoRenderer->CreateFilter();
The following is the CreateFilter function.
BOOL CDXFilter::CreateFilter(void)
{
if (!mFilter && mGraph)
{
if (SUCCEEDED(CoCreateInstance(mClsid, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&mFilter)))
{
if (SUCCEEDED(mGraph->AddFilter(mFilter, mName)))
{
return TRUE;
}
}
}
ReleaseFilter();
return FALSE;
}
When I try to connect them using the following, the program is blocked.
IPin * pOut = mVideoReceiver->GetPin(0);
IPin * pIn = mVideoRenderer->GetPin(TRUE);
hr = mRemoteVideoGraph->GetGraph()->Connect(pOut, pIn);
While I try to connect them using the second method, an error message appears telling that the two pins cannot be connected.
IPin * pOut = mVideoReceiver->GetPin(0);
IPin * pIn = mVideoRenderer->GetPin(TRUE);
hr = mRemoteVideoGraph->ConnectFilters(pOut, pIn);
The following is the ConnectFilters function.
BOOL CDXGraph::ConnectFilters(IPin * inOutputPin, IPin * inInputPin, const AM_MEDIA_TYPE * inMediaType)
{
if (mGraph && inOutputPin && inInputPin)
{
HRESULT hr = mGraph->ConnectDirect(inOutputPin, inInputPin, inMediaType);
this->ShowError(hr);
return SUCCEEDED(hr) ? TRUE : FALSE;
}
return FALSE;
}
I would like to ask if there are any problems above. If no, I am afraid if the problem is not related to the code segments above that there is a deadlock occured among the threads.
PLease help.
Thank you very much.