当前位置: 首页>>代码示例>>C++>>正文


C++ CComPtr::AddFilter方法代码示例

本文整理汇总了C++中CComPtr::AddFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ CComPtr::AddFilter方法的具体用法?C++ CComPtr::AddFilter怎么用?C++ CComPtr::AddFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CComPtr的用法示例。


在下文中一共展示了CComPtr::AddFilter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnDoubleClickFilter

void CPPageExternalFilters::OnDoubleClickFilter()
{
    if (FilterOverride* f = GetCurFilter()) {
        CComPtr<IBaseFilter> pBF;
        CString name;

        if (f->type == FilterOverride::REGISTERED) {
            CStringW namew;
            if (CreateFilter(f->dispname, &pBF, namew)) {
                name = namew;
            }
        } else if (f->type == FilterOverride::EXTERNAL) {
            if (SUCCEEDED(LoadExternalFilter(f->path, f->clsid, &pBF))) {
                name = f->name;
            }
        }

        if (CComQIPtr<ISpecifyPropertyPages> pSPP = pBF) {
            CComPropertySheet ps(name, this);
            if (ps.AddPages(pSPP) > 0) {
                CComPtr<IFilterGraph> pFG;
                if (SUCCEEDED(pFG.CoCreateInstance(CLSID_FilterGraph))) {
                    pFG->AddFilter(pBF, L"");
                }

                ps.DoModal();
            }
        }
    }
}
开发者ID:JanChou,项目名称:mpc-hc,代码行数:30,代码来源:PPageExternalFilters.cpp

示例2: CHK

HRESULT
CGraphManager::CreateCaptureGraphInternal()
{
    HRESULT       hr = S_OK;
    CComVariant   varCamName;
    CPropertyBag  PropBag;
    OAEVENT       oaEvent;
	WCHAR	      wzDeviceName[ MAX_PATH + 1 ];

    CComPtr<IMediaEvent>            pMediaEvent;
    CComPtr<IGraphBuilder>          pFilterGraph;
    CComPtr<IPersistPropertyBag>    pPropertyBag;
    CComPtr<IDMOWrapperFilter>      pWrapperFilter;
    CComPtr<IBaseFilter>			pImageSinkFilter;


    //
    // Create the capture graph builder and register the filtergraph manager. 
    //
    CHK( m_pCaptureGraphBuilder.CoCreateInstance( CLSID_CaptureGraphBuilder ));
    CHK( pFilterGraph.CoCreateInstance( CLSID_FilterGraph ));
	
    CHK( m_pCaptureGraphBuilder->SetFiltergraph( pFilterGraph ));


    //
    // Create and initialize the video capture filter
    //
    CHK( m_pVideoCaptureFilter.CoCreateInstance( CLSID_VideoCapture ));
    CHK( m_pVideoCaptureFilter.QueryInterface( &pPropertyBag ));

    // We are loading the driver CAM1 in the video capture filter. 
	CHK( GetFirstCameraDriver( wzDeviceName ));
    varCamName = wzDeviceName;
    if( varCamName.vt != VT_BSTR )
    {
        ERR( E_OUTOFMEMORY );
    }

    CHK( PropBag.Write( L"VCapName", &varCamName ));   
    CHK( pPropertyBag->Load( &PropBag, NULL ));

    // Everything succeeded, the video capture filter is added to the filtergraph
    CHK( pFilterGraph->AddFilter( m_pVideoCaptureFilter, L"Video Capture Filter Source" ));

	//
	// Create the still image filter, and connect it to the video capture filter
	//
	CHK( pImageSinkFilter.CoCreateInstance( CLSID_IMGSinkFilter ));
    CHK( pFilterGraph->AddFilter( pImageSinkFilter, L"Still image filter" ));
	CHK( m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_STILL, &MEDIATYPE_Video, m_pVideoCaptureFilter, NULL, pImageSinkFilter ));
	CHK( pImageSinkFilter.QueryInterface( &m_pImageSinkFilter ));

    //
    // Prevent the data from flowing into the capture stream
    //
 //   CHK( m_pCaptureGraphBuilder->ControlStream( &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pVideoCaptureFilter, 0, 0 ,0,0 ));

    //
    // Let's get the handle for DShow events. The main loop will listen to both notifications from 
    // the UI thread and for DShow notifications
    //
    CHK( pFilterGraph->QueryInterface( IID_IMediaEvent, (void**) &pMediaEvent ));
    CHK( pMediaEvent->GetEventHandle( &oaEvent ));
    m_handle[1] = (HANDLE) oaEvent;

    m_fGraphBuilt = TRUE;
	NotifyMessage( MESSAGE_INFO, L"Builing the graph completed" );

Cleanup:
	if( FAILED( hr ))
	{
		NotifyMessage( MESSAGE_ERROR, L"Builing the graph failed" );
	}
    return hr;
}
开发者ID:makerere-compute,项目名称:ocula,代码行数:76,代码来源:graphmanager.cpp

示例3: load

bool DShowAudioSource::load(const RString& path)
{
	mPath = path;
	HRESULT hr = S_OK;

	// Create the graph builder
	CComPtr<IGraphBuilder> pGraphBuilder;
	hr = pGraphBuilder.CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER);
    if(FAILED(hr)) 
		return false;

	// Create the sample grabber filter
	CComPtr<IBaseFilter> pSampleGrabberBaseFilter;
	hr = pSampleGrabberBaseFilter.CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER);
	if(FAILED(hr))
		return false;

	// Add the sample grabber filter to the graph
	hr = pGraphBuilder->AddFilter(pSampleGrabberBaseFilter, L"Sample Grabber");
	if(FAILED(hr))
		return false;

	// Get the Sample Grabber interface
	CComQIPtr<ISampleGrabber> pSampleGrabberFilter(pSampleGrabberBaseFilter);
	if(pSampleGrabberFilter == 0)
		return false;

	// Set the sample grabber's media type
	AM_MEDIA_TYPE mt;
	ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
	mt.majortype	= MEDIATYPE_Audio;
	mt.subtype = MEDIASUBTYPE_PCM;
	mt.formattype = FORMAT_WaveFormatEx;
	hr = pSampleGrabberFilter->SetMediaType(&mt);        
	if(FAILED(hr))
		return false;

	// Create the sample grabber callback
	mpSampleGrabberCallback.Attach(new SampleGrabberCallback(this));
	hr = pSampleGrabberFilter->SetCallback(mpSampleGrabberCallback, 1);
	if(FAILED(hr))
		return false;

	// Add the source filter to the graph
	WCHAR filename[MAX_PATH];
    MultiByteToWideChar(CP_ACP, 0,mPath.c_str(), -1, filename, MAX_PATH);
	CComPtr<IBaseFilter> pSourceFilter;
	hr = pGraphBuilder->AddSourceFilter(filename, L"Audio Source", &pSourceFilter);
	if(FAILED(hr)) 
		return false;

	// Create the NULL renderer.  We are only decoding
	CComPtr<IBaseFilter> pNullRenderer;
	hr = pNullRenderer.CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER);
	hr = pGraphBuilder->AddFilter(pNullRenderer, L"NULL Renderer");

	// Connect input to sample grabber
	hr = ConnectFilters(pGraphBuilder, pSourceFilter, pSampleGrabberBaseFilter);
	if(FAILED(hr))
		return false;

	// Connect sample grabber to NULL renderer
	hr = ConnectFilters(pGraphBuilder, pSampleGrabberBaseFilter, pNullRenderer);
	if(FAILED(hr))
		return false;

	// Get some useful interfaces
	mpMediaControl = pGraphBuilder;
	if(mpMediaControl == 0)
		return false;

	mpMediaEvent = pGraphBuilder;
	if(mpMediaEvent == 0)
		return false;

	mpMediaSeeking = pGraphBuilder;
	if(mpMediaSeeking == 0)
		return false;

	// Get the waveformatex structure
	pSampleGrabberFilter->GetConnectedMediaType(&mt);
    mpWaveFormatEx = reinterpret_cast<WAVEFORMATEX*>(mt.pbFormat);

	hr = mpMediaSeeking->SetTimeFormat(&TIME_FORMAT_MEDIA_TIME);
	if(FAILED(hr)) 
		return false;

	CComQIPtr<IMediaFilter> pMediaFilter(pGraphBuilder);
	pMediaFilter->SetSyncSource(0);

	mCurrentPosition = 0;
	mEOF = false;

	printf("# channels = %d\n", mpWaveFormatEx->nChannels);
	printf("Sample rate = %d\n", mpWaveFormatEx->nSamplesPerSec);

	return true;
}
开发者ID:mobilehub,项目名称:moai-beta,代码行数:98,代码来源:DShowAudioSource.cpp


注:本文中的CComPtr::AddFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。