Esempio n. 1
0
HRESULT CSampleCGB::BuildMPEG2Segment( IBaseFilter *pFilter )
{
	if(!pFilter)return E_POINTER;

	HRESULT hr = AddMPEG2Demux();
	if(FAILED(hr))return hr;

	//在filter上查找MPEG2 pin
	SmartPtr<IPin> pPin;
	hr = FindMPEG2Pin(pFilter,&pPin);
	if(SUCCEEDED(hr))
	{
		hr = ConnectPin(pPin,pMPEG2Demux_);
		if(FAILED(hr))
		{
			graph_->RemoveFilter(pMPEG2Demux_);
			return E_FAIL;
		}
		return S_OK;
	}
	//
	//  no pins that streams directly MPEG2 stream
	//
	hr = FindVideoPin(pFilter,&pPin);
	if(FAILED(hr))
	{
		graph_->RemoveFilter(pMPEG2Demux_);
		return hr;// no video pin
	}


	return hr;
}
Esempio n. 2
0
HRESULT 
ISampleCaptureGraphBuilder::BuildMPEG2Segment(IBaseFilter *pFilter)
{

    if( ! pFilter )
    {
        return E_FAIL;
    }

    
    HRESULT hr = AddMPEG2Demux( );
    if( FAILED( hr ) )
    {
        return hr;
    }

    //
    //  Search a MPEG2 pin on the 
    //  filter
    //
    SmartPtr<IPin> pPin;
    hr = FindMPEG2Pin( pFilter, &pPin );
    if( SUCCEEDED( hr ) )
    {
        hr = ConnectPin( pPin, pMPEG2Demux_ );
        if( FAILED( hr ) )
        {
            graph_->RemoveFilter( pMPEG2Demux_ );
            return E_FAIL;
        }
        return S_OK;
    }

    //
    //  no pins that streams directly MPEG2 stream
    //
    hr = FindVideoPin( pFilter, &pPin );
    if( FAILED( hr ) )
    {
        graph_->RemoveFilter( pMPEG2Demux_ );
        return hr; // no video pin
    }

    hr = RenderToMPEG2Demux( pPin );
    if( FAILED( hr ) )
    {
        graph_->RemoveFilter( pMPEG2Demux_ );
        return hr;
    }

    SmartPtr<IPin> pAudioPin;
    hr = FindAudioPin( pFilter, &pAudioPin );
    if( FAILED( hr ) )
    {
        //
        //  don't bother with audio
        //
        return S_OK;
    }

    //
    //  try to connect the audio pin directly to encoder
    //  if this is not possible, then try to find an encoder
    //  and connect it to the multiplexer
    //
    ASSERT( pEncoder_ );
    hr = ConnectPin( pAudioPin, pEncoder_ );
    if( FAILED( hr ) )
    {
        hr = ConnectAudioPinToMultiplexer( pAudioPin, pMultiplexer_ );
    }

    return S_OK;
}