int TffDecoder::loadAVInameAndPreset(void)
{
 IEnumFilters *eff=NULL;
 int cnt=0;
 if (m_pGraph->EnumFilters(&eff)==S_OK)
  {
   eff->Reset();
   IBaseFilter *bff;
   while (eff->Next(1,&bff,NULL)==S_OK)
    {
     CLSID iffclsid;
     bff->GetClassID(&iffclsid);
     if (iffclsid==CLSID_FFDSHOW) cnt++;
     if (AVIname[0]=='\0')
      {
       FILTER_INFO iff;
       bff->QueryFilterInfo(&iff);
       IFileSourceFilter *ifsf=NULL;
       bff->QueryInterface(IID_IFileSourceFilter,(void**)&ifsf);
       if (ifsf)
        {
         LPOLESTR aviNameL;
         ifsf->GetCurFile(&aviNameL,NULL);
         ifsf->Release();
         WideCharToMultiByte(CP_ACP,0,aviNameL,-1,AVIname,511, NULL, NULL );
         if (globalSettings.autoPreset)
          {
           TpresetSettings *preset=presets.getAutoPreset(AVIname,globalSettings.autoPresetFileFirst);
           if (preset)
            setPresetPtr(preset);
          }
        }
       if (iff.pGraph) iff.pGraph->Release();
      }
     bff->Release();
    }
   eff->Release();
  }
 return cnt;
}
Exemple #2
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);

}
Exemple #3
0
HRESULT 
recChannel_t::map(void)
{

    __CONTEXT("recChannel_t::map");
       
	int hr = 0;
	IBaseFilter * pFilter = NULL;
	IBaseFilter * pFilter2 = NULL;
	IPin * pVideoInputPin = NULL;
	pControl->StopWhenReady();
	
	mapping = true;
	pOutput = camInfo->output;


	if (remaped){
		
	    //refresh Codec BW before creation
        pSender->sampleGrabber->BWController->refreshBW();
		pSender->rebind();
	
		hr = pGraph->Render(pOutput);
		{
				
				// Enumerate the filters in the graph.
				IEnumFilters *pEnum = NULL;
				int hr = pGraph->EnumFilters(&pEnum);
				if (SUCCEEDED(hr))
				{
					IBaseFilter *pFilter = NULL;
					pEnum->Reset();
					while (S_OK == pEnum->Next(1, &pFilter, NULL))
					{
						CLSID filterId;
						pFilter->GetClassID(&filterId);
						if(filterId == CLSID_AviSplitter)
			   			{

							IEnumPins * pEnumpin = NULL;
								
							hr = pFilter->EnumPins(&pEnumpin);
							if (!hr)
							{
								IPin * pPin = NULL;
								pEnumpin->Reset();
								while (pEnumpin->Next(1, &pPin, 0) == S_OK)
								{
									bool break_loop = false;
									AM_MEDIA_TYPE * mediaType;
									IEnumMediaTypes * enumMedia = NULL;
						
									hr = pPin->EnumMediaTypes(&enumMedia);
									if(!hr)
									{
										enumMedia->Reset();
										while(enumMedia->Next(1,&mediaType , NULL) == S_OK)
										{
											if (mediaType->majortype == MEDIATYPE_Audio)
											{
												pPin->Disconnect();
												pGraph->Render(pPin);
												pPin->Release();
												break_loop = true;
												break;
											}
										}
										enumMedia->Release();
										if (break_loop)
											break;
									}
								}
								pEnumpin->Release();
							}
							
						}
						pFilter->Release();
					}
					pEnum->Release();
				}
		}

		pipeCreated = true;
	
		if (hr)
		{
				errorCheck(hr);
				NOTIFY("[recChannel_t::map]WARNING :: Can't render actual format, restoring default settings...\r\n");
				capInfo.heigth = DEFAULT_CAPTURE_HEIGTH;
				capInfo.width = DEFAULT_CAPTURE_WIDTH;
				ql_t<AM_MEDIA_TYPE *> auxFormats = camInfo->getFormatList();
				pSender->SetActualCodec(DEFAULT_CODEC_STR);
		}
	}

	if (fullScreen){
		set_full_screen(true);
	}else{
		hr = setWindowGeometry(windowInfo);
		errorCheck(hr);
	}

//	IVideoWindow *pWindowInfo = NULL;
//	hr = pGraph->QueryInterface(IID_IVideoWindow, (void **)&pWindowInfo);
//	if (!hr)
//	{
//		wchar_t wtext[100];
//		long windowStyle,windowStyleEx;
//		lText(wtext,title);
//		pWindowInfo->get_WindowStyle(&windowStyle);
//        pWindowInfo->get_WindowStyleEx(&windowStyleEx);
//		windowStyle = windowStyle + DEFAULT_WINDOW_PROPS - DEFAULT_WINDOW_NON_PROPS;
//		windowStyleEx = windowStyleEx - WS_EX_APPWINDOW;
//		pWindowInfo->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
//        pWindowInfo->put_WindowStyleEx(WS_EX_TOOLWINDOW);
//		pWindowInfo->put_Caption(wtext);
//
//#ifdef _WINDOWS
//        if (camInfo->getKind() == MEDIA)
//        {
//            fControl->setGeometry(windowInfo);
//
//        }
//#endif  	
////Ares daemon don't show local windows on
////recChannels
//#ifndef __ARES		
//		if (camInfo->getKind() != SHARED)
//		{
//			pWindowInfo->put_Visible(OATRUE);
//			pWindowInfo->put_AutoShow(OATRUE);
//		}
//		else
//		{
//#endif
//			pWindowInfo->put_Visible(OAFALSE);
//			pWindowInfo->put_AutoShow(OAFALSE);
//#ifndef __ARES
//		}
//#endif
//
//		pWindowInfo->Release();
//		setOwner();
//	}
	
	IMediaSeeking * pSeek = NULL;
    pGraph->QueryInterface(IID_IMediaSeeking,(void **)&pSeek);
    if (pSeek)pSeek->SetRate(1);
        
	pControl->Run();

	if (camInfo->getKind() == SHARED)
    {
		camInfo->RunSource();
    }
		
	if (camInfo->getKind() == TEST) 
    {        
        if (pSeek) pSeek->SetRate(0.5);
        looper->Run();
    }
	
    remaped = false;
	return hr;
}