HRESULT CSampleCGB::RenderStream( const GUID *pCategory, const GUID *pType, IUnknown *pSource, IBaseFilter *pIntermediate, IBaseFilter *pSink ) { if( !pType || !::IsEqualGUID( MEDIATYPE_Stream, *pType ) ) { return graphBuilder2_->RenderStream( pCategory, pType, pSource, pIntermediate, pSink ); } HRESULT hr; if(!graph_) { hr = GetFiltergraph(&graph_); if(FAILED(hr)) { return hr; } } // // try to build MPEG2 graph // SmartPtr< IBaseFilter > captureFilter; hr = pSource->QueryInterface(& captureFilter); if(FAILED(hr)) { return E_INVALIDARG; } return hr; }
HRESULT ISampleCaptureGraphBuilder::SetOutputFileName( const GUID *pType, LPCOLESTR lpwstrFile, IBaseFilter **ppf, IFileSinkFilter **pSink ) { if( ! pType || ! lpwstrFile || !ppf || !pSink ) { return E_INVALIDARG; } if( !::IsEqualGUID( *pType, MEDIASUBTYPE_Mpeg2 ) ) { return graphBuilder2_->SetOutputFileName(pType, lpwstrFile, ppf, pSink ); } HRESULT hr; if( !graph_ ) { hr = GetFiltergraph( &graph_ ); if( FAILED( hr ) ) { return hr; } } // // Configure the dump filter // SmartPtr< IFileSinkFilter > pDump; hr = CoCreateInstance(CLSID_Dump, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pDump); if( FAILED( hr ) ) { return hr; } hr = pDump->SetFileName( lpwstrFile, NULL ); if( FAILED( hr ) ) { return hr; } hr = pDump.QueryInterface( &pMPEG2Demux_ ); if( FAILED( hr ) ) { return hr; } hr = graph_->AddFilter( pMPEG2Demux_, L"Dump" ); if( FAILED( hr ) ) { pMPEG2Demux_ = NULL; return hr; } *pSink = pDump; return S_OK; }
HRESULT ISampleCaptureGraphBuilder::RenderStream( const GUID *pCategory, const GUID *pType, IUnknown *pSource, IBaseFilter *pIntermediate, IBaseFilter *pSink) { if( !pType || !::IsEqualGUID( MEDIATYPE_Stream, *pType ) ) { return graphBuilder2_->RenderStream( pCategory, pType, pSource, pIntermediate, pSink ); } HRESULT hr; if( !graph_ ) { hr = GetFiltergraph( &graph_ ); if( FAILED( hr ) ) { return hr; } } // // try to build MPEG2 graph // SmartPtr< IBaseFilter > captureFilter; hr = pSource->QueryInterface( & captureFilter ); if( FAILED( hr ) ) { return E_INVALIDARG; } hr = BuildMPEG2Segment( captureFilter); if( pSink || FAILED( hr ) ) { return hr; } hr = ConfigureMPEG2Demux( pMPEG2Demux_ ); if( FAILED( hr ) ) { return hr; } hr = RenderStream(NULL, &MEDIATYPE_Video, pMPEG2Demux_, NULL, NULL ); if( FAILED( hr ) ) { return hr; } hr = RenderStream(NULL, &MEDIATYPE_Audio, pMPEG2Demux_, NULL, NULL ); if( FAILED( hr ) ) { return hr; } return S_OK; }