Example #1
0
void 
recChannel_t::refresh_channel(bool all)
{
     __CONTEXT("recChannel_t::refresh_channel");
    pControl->Stop();
#ifdef _WINDOWS
    if (fControl)
    {
        fControl->CWnd::ShowWindow(SW_HIDE);
    }
#endif
	
	if (pSource!=NULL)
    {
		pGraph->RemoveFilter(pSource);
		camInfo->setFree(true);
	}
	
	// Enumerate the filters in the graph.
	IEnumFilters *pEnum = NULL;
	int hr = pGraph->EnumFilters(&pEnum);
	if (SUCCEEDED(hr))
	{
		IBaseFilter *pFilter = NULL;
		while (S_OK == pEnum->Next(1, &pFilter, NULL))
		{
			CLSID filterId;
			pFilter->GetClassID(&filterId);
			if(filterId == CLSID_VideoRenderer ||
			   filterId == CLSID_VideoMixingRenderer)
			{
				IVideoWindow *pWindowInfo = NULL;
				pFilter->QueryInterface(IID_IVideoWindow, (void **)&pWindowInfo);
				pWindowInfo->get_Height(&windowInfo.heigth);
				pWindowInfo->get_Left(&windowInfo.left);
				pWindowInfo->get_Top(&windowInfo.top);
				pWindowInfo->get_Width(&windowInfo.width);
           		pWindowInfo->put_AutoShow(OAFALSE);
			    pWindowInfo->put_Visible(OAFALSE);
        	   	if (all)
				{
                   	pGraph->RemoveFilter(pFilter);
					pFilter->Release();
					pEnum->Reset();
					pWindowInfo->Release();
				}

			}else{
                
                pGraph->RemoveFilter(pFilter);    
                pFilter->Release();
                pEnum->Reset();
			}
		}
		pEnum->Release();
	}
	if (all)
	{
		pGraph->Release();
		hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, 
                          IID_IGraphBuilder, (void **)&pGraph);
		errorCheck(hr);
	}
	hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
	errorCheck(hr);

}