Пример #1
0
HRESULT CSampleCGB::CreateVideoPin( IMpeg2Demultiplexer *pIMpeg2Demux )
{
	if(!pIMpeg2Demux)return E_INVALIDARG;

	AM_MEDIA_TYPE amTypeVideo;
	amTypeVideo.majortype = MEDIATYPE_Video;
	amTypeVideo.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
	amTypeVideo.bFixedSizeSamples = TRUE;
	amTypeVideo.bTemporalCompression = 0;
	amTypeVideo.formattype = FORMAT_MPEG2_VIDEO;
	amTypeVideo.pUnk = NULL;
	amTypeVideo.cbFormat = sizeof(Mpeg2ProgramVideo);
	amTypeVideo.pbFormat = Mpeg2ProgramVideo;

	//
	// Create video pin
	//

	SmartPtr<IPin> pVideoOutPin;
	HRESULT hr = pIMpeg2Demux->CreateOutputPin(&amTypeVideo,L"MpegVideo",&pVideoOutPin);
	if(FAILED(hr))return hr;

	SmartPtr<IMPEG2StreamIdMap> pIVideoPIDMap;
	hr = pVideoOutPin->QueryInterface(&pIVideoPIDMap);
	if(FAILED(hr))return hr;


	hr = pIVideoPIDMap->MapStreamId(VidPID_,MPEG2_PROGRAM_ELEMENTARY_STREAM,0,0);
	if(FAILED(hr))return hr;
	return hr;
}
Пример #2
0
HRESULT CSampleCGB::CreateAudioPin( IMpeg2Demultiplexer *pIMpeg2Demux )
{
	if(!pIMpeg2Demux)return E_INVALIDARG;

	//
	// for audio: could be Mpeg1, Mpeg2, AC3: if Mpeg1 failed (connect failed) try Mpeg2.if failed tried AC3
	// Audio struct of AC3 can be copied from dev code.
	//
	AM_MEDIA_TYPE amTypeAudio;
	amTypeAudio.majortype = MEDIATYPE_Audio;
	amTypeAudio.subtype = MEDIASUBTYPE_MPEG2_AUDIO;
	amTypeAudio.bFixedSizeSamples = TRUE;
	amTypeAudio.bTemporalCompression = 0;
	amTypeAudio.formattype = FORMAT_WaveFormatEx;
	amTypeAudio.pUnk = NULL;
	amTypeAudio.cbFormat = sizeof( MPEG1AudioFormat );
	amTypeAudio.pbFormat = MPEG1AudioFormat;

	SmartPtr<IPin> pAudioOutPin;
	HRESULT hr = pIMpeg2Demux->CreateOutputPin(&amTypeAudio,L"MpegAudio",&pAudioOutPin);
	if(FAILED(hr))return hr;

	SmartPtr<IMPEG2StreamIdMap> pIAudioPIDMap;
	hr = pAudioOutPin->QueryInterface(&pIAudioPIDMap);
	if(FAILED(hr))return hr;

	hr = pIAudioPIDMap->MapStreamId(AudPID_,MPEG2_PROGRAM_ELEMENTARY_STREAM,0,0);
	if(FAILED(hr))return hr;
	return hr;
}
Пример #3
0
HRESULT 
ISampleCaptureGraphBuilder::CreateVideoPin(
        IMpeg2Demultiplexer *pIMpeg2Demux )
{
    if( !pIMpeg2Demux )
    {
        return E_INVALIDARG;
    }

    AM_MEDIA_TYPE amTypeVideo;
    amTypeVideo.majortype = MEDIATYPE_Video;
    amTypeVideo.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
    amTypeVideo.bFixedSizeSamples = TRUE;
    amTypeVideo.bTemporalCompression = 0;
    amTypeVideo.formattype = FORMAT_MPEG2Video;
    amTypeVideo.pUnk = NULL;
    amTypeVideo.cbFormat = sizeof( Mpeg2ProgramVideo );
    amTypeVideo.pbFormat = Mpeg2ProgramVideo;

    //
    // Create video pin
    //

    SmartPtr<IPin> pVideoOutPin;
    HRESULT hr = pIMpeg2Demux->CreateOutputPin( &amTypeVideo, L"MpegVideo", &pVideoOutPin );
    if( FAILED( hr ) )
    {
        return hr;
    }


    SmartPtr<IMPEG2StreamIdMap> pIVideoPIDMap;
    hr = pVideoOutPin->QueryInterface( &pIVideoPIDMap );
    if( FAILED( hr ) )
    {
        return hr;
    }

    hr = pIVideoPIDMap->MapStreamId(VidPID_, MPEG2_PROGRAM_ELEMENTARY_STREAM , 0, 0);
    if( FAILED( hr ) )
    {
        return hr;
    }


#ifdef USE_VMR
    //
    //  Get the VMR interface and add it to the graph
    //
    SmartPtr<IBaseFilter> pVMR;
    hr = pVMR.CoCreateInstance( CLSID_VideoMixingRenderer );
    if( FAILED( hr ) )
    {
        return hr;
    }

    hr = graph_->AddFilter( pVMR, L"VMR" );
    if( FAILED( hr ) )
    {
        return hr;
    }

    //
    //before rendering the VMR, make the number of streams 1
    //
    SmartPtr<IVMRFilterConfig> pConfig;
    hr = pVMR.QueryInterface( &pConfig );
    if( FAILED( hr ) )
    {
        return hr;
    }
    hr = pConfig->SetNumberOfStreams( 1 );
    if( FAILED( hr ) )
    {
        return hr;
    }


    //
    //  Get the input pin from the VMR
    //
    SmartPtr<IPin> pInputPin;
    hr = graphBuilder2_->FindPin(
            static_cast<IBaseFilter *>( pVMR ),  
            PINDIR_INPUT, 
            NULL, 
            NULL, 
            TRUE, 
            0, 
            &pInputPin
        );
    if( FAILED( hr ) )
    {

        hr = pIMpeg2Demux->DeleteOutputPin(L"MpegVideo");
        graph_->RemoveFilter( pVMR );
        return hr;
    }

    return graph_->Connect( pVideoOutPin, pInputPin );
#endif

    return hr;
}