Beispiel #1
0
void ContextPrivate::unregisterPin( const QUuid &pUUID )
{
	QSharedPointer<fugio::PinInterface>		PinInt = findPin( pUUID );

	if( PinInt )
	{
		mUpdatePinMapMutex.lock();

		for( int i = 0 ; i < mUpdatePinMap.size() ; )
		{
			QSharedPointer<fugio::PinInterface>		DstPin = mUpdatePinMap.at( i ).first;

			if( DstPin && DstPin->globalId() == pUUID )
			{
				mUpdatePinMap.removeAt( i );
			}
			else
			{
				i++;
			}
		}

		mUpdatePinMapMutex.unlock();
	}

	if( mPinHash.contains( pUUID ) )
	{
		mPinHash.remove( pUUID );
	}

	disconnectPin( pUUID );
}
Beispiel #2
0
void MiniPlayer::init()
{
	HRESULT hr = S_OK;

	hr = CoInitializeEx(NULL, COINIT_MULTITHREADED | COINIT_SPEED_OVER_MEMORY);

	hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&_filterGraph);
	IF_CHK(hr, "Unable to create Filter Graph.");

	hr = CoCreateInstance(CLSID_VideoMixingRenderer9, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&_videoRenderer);
	IF_CHK(hr, "Unable to create Video Mixing Renderer 9.");

	hr = CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&_audioRenderer);
	IF_CHK(hr, "Unable to create DirectSound Renderer.");

	hr = CoCreateInstanceAx(_T("lav\\LAVSplitter.ax"), CLSID_LAVSplitter, NULL, IID_IBaseFilter, (void **)&_splitter);
	IF_CHK(hr, "Unable to create LAV Splitter.");

	hr = CoCreateInstanceAx(_T("lav\\LAVVideo.ax"), CLSID_LAVVideo, NULL, IID_IBaseFilter, (void **)&_videoDecoder);
	IF_CHK(hr, "Unable to create LAV Video Decoder.");

	hr = CoCreateInstanceAx(_T("lav\\LAVAudio.ax"), CLSID_LAVAudio, NULL, IID_IBaseFilter, (void **)&_audioDecoder);
	IF_CHK(hr, "Unable to create LAV Audio Decoder.");

	hr = _filterGraph->AddFilter(_videoRenderer, L"Video Renderer");
	IF_CHK(hr, "Unable to add Video Mixing Renderer 9 to Filter Graph.");

	hr = _filterGraph->AddFilter(_audioRenderer, L"Audio Renderer");
	IF_CHK(hr, "Unable to add DirectSound Renderer to Filter Graph.");

	hr = _filterGraph->AddFilter(_splitter, L"Splitter");
	IF_CHK(hr, "Unable to add LAV Splitter to Filter Graph.");

	hr = _filterGraph->AddFilter(_videoDecoder, L"Video Decoder");
	IF_CHK(hr, "Unable to add Video Decoder to Filter Graph.");

	hr = _filterGraph->AddFilter(_audioDecoder, L"Audio Decoder");
	IF_CHK(hr, "Unable to add Audio Decoder to Filter Graph.");

	hr = findPin(_splitter, PINDIR_INPUT, &_splitterInputPin);
	IF_CHK(hr, "Unable to find the input pin of LAV Splitter.");

	hr = findPin(_videoDecoder, PINDIR_INPUT, &_videoDecoderInputPin);
	IF_CHK(hr, "Unable to find the input pin of LAV Video Decoder.");

	hr = findPin(_audioDecoder, PINDIR_INPUT, &_audioDecoderInputPin);
	IF_CHK(hr, "Unable to find the input pin of LAV Audio Decoder.");

	hr = _filterGraph->QueryInterface(IID_IMediaControl, (void **)&_mediaCtrl);
	IF_CHK(hr, "Unable to find Media Control Interface");

	hr = _filterGraph->QueryInterface(IID_IMediaSeeking, (void **)&_mediaSeeking);
	hr = _filterGraph->QueryInterface(IID_IMediaEventEx, (void **)&_mediaEvent);

	hr = _filterGraph->QueryInterface(IID_IBasicAudio, (void **)&_audioCtrl);

	_fail = false;

	return;

Cleanup:
	_fail = true;
	release();
}
Beispiel #3
0
bool MiniPlayer::prepare(LPCTSTR filename)
{
	if(fail()) return false;

	HRESULT hr = _mediaCtrl->Stop();

	IBaseFilter *pFileSrc = NULL;
	
	hr = _filterGraph->FindFilterByName(L"Media File", &pFileSrc);
	if(hr == S_OK)
	{
		hr = _filterGraph->RemoveFilter(pFileSrc);
		IF_REL(pFileSrc);
	}

	hr = _filterGraph->AddSourceFilter(filename, L"Media File", &pFileSrc);
	IF_CHK(hr, _T("Unable to add Source Filter for file: %s"), filename);

	IPin *pFileOutputPin = NULL;

	hr = findPin(pFileSrc, PINDIR_OUTPUT, &pFileOutputPin);
	IF_CHK(hr, "Unable to find output pin of File Source Filter.");

	hr = _filterGraph->Connect(pFileOutputPin, _splitterInputPin);
	IF_CHK(hr, "Unable to connect File Source Output Pin & Splitter Input Pin");

	IPin *pSplitterVideoOutputPin = NULL;
	IPin *pSplitterAudioOutputPin = NULL;
	IPin *pVideoDecoderOutputPin = NULL;
	IPin *pAudioDecoderOutputPin = NULL;

	//listAllPins(_splitter);
	hr = findPin(_splitter, PINDIR_OUTPUT, MEDIATYPE_Video, &pSplitterVideoOutputPin);
	if(hr == S_OK)
	{
		hr = _filterGraph->Connect(pSplitterVideoOutputPin, _videoDecoderInputPin);
	}

	hr = findPin(_splitter, PINDIR_OUTPUT, MEDIATYPE_Audio, &pSplitterAudioOutputPin);
	if(hr == S_OK)
	{
		hr = _filterGraph->Connect(pSplitterAudioOutputPin, _audioDecoderInputPin);
	}

	//listAllPins(_videoDecoder);
	hr = findPin(_videoDecoder, PINDIR_OUTPUT, &pVideoDecoderOutputPin);
	if(hr == S_OK)
	{
		hr = _filterGraph->Render(pVideoDecoderOutputPin);
	}

	//listAllPins(_audioDecoder);
	hr = findPin(_audioDecoder, PINDIR_OUTPUT, &pAudioDecoderOutputPin);
	if(hr == S_OK)
	{
		hr = _filterGraph->Render(pAudioDecoderOutputPin);
	}

	IID IID_ITrackInfo;
	IIDFromString(L"{03E98D51-DDE7-43aa-B70C-42EF84A3A23D}", &IID_ITrackInfo);
	ITrackInfo *pTrackInfo;
	hr = _splitter->QueryInterface(IID_ITrackInfo, (void **)&pTrackInfo);

	IAMStreamSelect *pAudioSel;
	hr = _splitter->QueryInterface(IID_IAMStreamSelect, (void **)&pAudioSel);

	hr = pAudioSel->Enable(2, AMSTREAMSELECTENABLE_ENABLE);

	ctrace("Track Info:\n");
	ctrace("  Track Count: %d\n", pTrackInfo->GetTrackCount());
	for(UINT i = 0; i < pTrackInfo->GetTrackCount(); i++)
	{
		TrackElement elem;
		TrackExtendedInfoVideo videoInfo;
		TrackExtendedInfoAudio audioInfo;
		pTrackInfo->GetTrackInfo(i, &elem);
		ctrace("\t [%d] ", i);
		switch(elem.Type)
		{
		case TypeVideo:
			pTrackInfo->GetTrackExtendedInfo(i, &videoInfo);
			ctrace("Video %dx%d", videoInfo.PixelWidth, videoInfo.PixelHeight);
			break;
		case TypeAudio:
			pTrackInfo->GetTrackExtendedInfo(i, &audioInfo);
			ctrace("Audio %d Channels", audioInfo.Channels);
			break;
		case TypeSubtitle:
			ctrace("Subtitle ");
			break;
		}
		ctrace("\n");
	}

	_fail = false;
	return true;

Cleanup:

	return (_fail = true);
}