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


C++ IBaseFilter::EnumPins方法代码示例

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


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

示例1: GetPinCountForOneType

	HRESULT GetPinCountForOneType(IUnknown* pUnk, PIN_DIRECTION direction, LPDWORD pPinCount)
	{
		(*pPinCount) = 0;
		IBaseFilter* pBaseFilter = NULL;
		HRESULT hr = pUnk->QueryInterface(IID_IBaseFilter, (VOID**)&pBaseFilter);
		if (SUCCEEDED(hr))
		{
			IEnumPins* pEnumPins = NULL;
			hr = pBaseFilter->EnumPins(&pEnumPins);
			if (SUCCEEDED(hr))
			{
				pEnumPins->Reset();
				if (SUCCEEDED(hr))
				{
					IPin* pPin = NULL;
					BOOL bFound = FALSE;
					DWORD dwFetched = 0;
					while (((pEnumPins->Next(1, &pPin, &dwFetched)) == S_OK) && !bFound)
					{
						PIN_DIRECTION fetchedDir;
						hr = pPin->QueryDirection(&fetchedDir);
						if (SUCCEEDED(hr) && (fetchedDir == direction))
						{
							(*pPinCount)++;
						}
						pPin->Release();
					}
				}
				pEnumPins->Release();
			}
			pBaseFilter->Release();
		}
		return hr;
	}
开发者ID:wyrover,项目名称:HiVideo2,代码行数:34,代码来源:DShowUtils.cpp

示例2: GetAMConfigForSinglePin

	HRESULT GetAMConfigForSinglePin(IUnknown* pUnk, PIN_DIRECTION direction, IAMStreamConfig** ppConfig)
	{
		IBaseFilter* pBaseFilter = NULL;
		HRESULT hr = pUnk->QueryInterface(IID_IBaseFilter, (void**)&pBaseFilter);
		if (SUCCEEDED(hr))
		{
			IEnumPins* pEnumPins = NULL;
			hr = pBaseFilter->EnumPins(&pEnumPins);
			if (SUCCEEDED(hr))
			{
				pEnumPins->Reset();
				if (SUCCEEDED(hr))
				{
					IPin* pPin = NULL;
					BOOL bFound = FALSE;
					while (((pEnumPins->Next(1, &pPin, NULL)) == S_OK) && !bFound)
					{
						PIN_DIRECTION fetchedDir;
						hr = pPin->QueryDirection(&fetchedDir);
						if (SUCCEEDED(hr) && (fetchedDir == direction))
						{
							hr = pPin->QueryInterface(IID_IAMStreamConfig, (void**)ppConfig);
							bFound = SUCCEEDED(hr);
						}
						pPin->Release();
					}
				}
				pEnumPins->Release();
			}
			pBaseFilter->Release();
		}
		return hr;
	}
开发者ID:wyrover,项目名称:HiVideo2,代码行数:33,代码来源:DShowUtils.cpp

示例3: FindSourceFilter

HRESULT FindSourceFilter(IFilterGraph* filterGraph,IBaseFilter*& result)
{
	HRESULT hr;
	IEnumFilters *enumFilters;
	hr = filterGraph->EnumFilters(&enumFilters);
	if (FAILED(hr))
	{
		ErrorPrint("Get enum filters error",hr);
		return hr;
	}
	ComReleaser enumFilterReleaser(enumFilters);

	IBaseFilter* filter;
	while (S_OK == enumFilters->Next(1, &filter, NULL))
	{
		ComReleaser filterReleaser(filter);
		IEnumPins *enumPins;
		
		hr = filter->EnumPins(&enumPins);
		if (FAILED(hr))
		{
			ErrorPrint("Get enum pins error",hr);
			return hr;
		}
		ComReleaser enumPinsReleaser(enumPins);

		IPin* pin;
		bool isSourceFilter = true;
		while (S_OK == enumPins->Next(1, &pin, NULL))
		{
			ComReleaser pinReleaser(pin);
			PIN_INFO pinInfo;
			hr = pin->QueryPinInfo(&pinInfo);
			if (FAILED(hr))
			{
				ErrorPrint("Get pin info error",hr);
				continue;
			}
			if (pinInfo.dir == PINDIR_INPUT) //认为没有输入pin的就是source filter,这其实是有些问题的,特别是当捕获(如声卡的音频)的filter有时候有很多输入PIN
			{
				isSourceFilter = false;
				break;
			}
		}

		if (isSourceFilter)
		{
			filter->AddRef(); //存在一个资源管理的释放类,必须增加一个引用,否则会被释放掉
			result = filter;
			return S_OK;
		}
	}

	return E_FAIL;
}
开发者ID:dalinhuang,项目名称:networkprogram,代码行数:55,代码来源:FilterCommon.cpp

示例4: initialize

// Very basic setup of capture filter, we should do error checking
bool DsCaptureFilter::initialize()
{
    IBaseFilter* sourceFilter  = NULL;
	IPin* sourcePin = NULL;

	HRESULT hr = CoInitialize(0);

	hr = CoCreateInstance(CLSID_FilterGraph, 0, CLSCTX_INPROC,IID_IGraphBuilder, (void **)&graph);
 
	hr = graph->QueryInterface(IID_IMediaControl, (void **)&mediaControl);

    //sampler = new Sampler(0, &hr); 
    IPin* renderPin  = NULL; 
	hr = this->FindPin(L"In", &renderPin);
    hr = graph->AddFilter((IBaseFilter*)this, L"Sampler");

	if(strcmp(source, "cam") == 0) // Capture from camera
	{
		ICreateDevEnum* devs = NULL;
		hr = CoCreateInstance (CLSID_SystemDeviceEnum, 0, CLSCTX_INPROC, IID_ICreateDevEnum, (void **) &devs);

		IEnumMoniker* cams = NULL;
		hr = devs?devs->CreateClassEnumerator (CLSID_VideoInputDeviceCategory, &cams, 0):0;

		IMoniker* mon  = NULL;
		hr = cams?cams->Next (1, &mon, 0):0;

		hr = mon?mon->BindToObject(0,0,IID_IBaseFilter, (void**)&sourceFilter):0;
		hr = graph->AddFilter(sourceFilter, L"Capture Source");
	} 
	else // Capture from AVI
	{
		WCHAR filename[256];
		MultiByteToWideChar(0, 0, source, -1, filename, sizeof(filename));
		hr = graph->AddSourceFilter(filename, L"File Source", &sourceFilter);
		hr = sourceFilter?sourceFilter->FindPin(L"Output", &sourcePin):0;

		hr = graph?graph->QueryInterface(IID_IMediaEvent, (void **)&mediaEvent):0;
		hr = graph?graph->QueryInterface(IID_IMediaSeeking, (void **)&mediaSeek):0;
	}

	IEnumPins* pins = NULL;
	hr = sourceFilter?sourceFilter->EnumPins(&pins):0;
	hr = pins?pins->Next(1,&sourcePin, 0):0;

    hr = graph->Connect(sourcePin, renderPin);

	newFrameEvent = CreateEvent(0, FALSE, FALSE, "NewFrameEvent");

	return true;
}
开发者ID:AmitVashisht,项目名称:touchlib,代码行数:52,代码来源:DsCaptureFilter.cpp

示例5: DisconnectAllPins

//-----------------------------------------------------------------------------
// DisconnectAllPins
// Disconnect all the pins of the filters in a graph
HRESULT CDSUtils::DisconnectAllPins(IGraphBuilder* pGraph)
{
	HRESULT hr = S_OK;

	if (pGraph)
	{
		CComPtr<IEnumFilters> pIEnumFilters = NULL;
		hr = pGraph->EnumFilters(&pIEnumFilters);
		if (SUCCEEDED(hr))
		{
			IBaseFilter* pFilter = NULL;
			while (S_OK == pIEnumFilters->Next(1, &pFilter, NULL))
			{
				CComPtr<IEnumPins> pIEnumPins = NULL;
				hr = pFilter->EnumPins(&pIEnumPins);
				if (SUCCEEDED(hr))
				{
					IPin* pIPin = NULL;
					while (S_OK == pIEnumPins->Next(1, &pIPin, NULL))
					{
						IPin* pIPinConnection = NULL;
						if (S_OK == pIPin->ConnectedTo(&pIPinConnection))
						{
							// pins are connected, to disconnect filters, both pins must be disconnected
							hr = pGraph->Disconnect(pIPin);
							hr = pGraph->Disconnect(pIPinConnection);
							SAFE_RELEASE(pIPinConnection);
						}
						SAFE_RELEASE(pIPin);
					}
				}
				SAFE_RELEASE(pFilter);
			}
		}
	}
	else
	{
		hr = E_INVALIDARG;
	}

	return hr;
}
开发者ID:MattHung,项目名称:sage-graphics,代码行数:45,代码来源:Utils.cpp

示例6: eHandler

Camera::Camera(bool Show,bool Start) : eHandler(this),_realData(false),_UpdateWindow(Show),_LastData(0),_CurData(0) {
	DWORD no;
	IGraphBuilder *graph = 0;
	ctrl = 0;
	ICreateDevEnum *devs = 0;
	IEnumMoniker *cams = 0;
	IMoniker *mon = 0;
	IBaseFilter *cam = 0;
	IEnumPins *pins = 0;
	IPin *pin = 0;
	IEnumFilters *fil = 0;
	IBaseFilter *rnd = 0;
	IMemInputPin *mem = 0;
	curCamera = this;
	_isOn = Start;

	CoCreateInstance( CLSID_FilterGraph, 0, CLSCTX_INPROC,IID_IGraphBuilder, (void **)&graph );
	graph->QueryInterface( IID_IMediaControl, (void **)&ctrl );
	CoCreateInstance (CLSID_SystemDeviceEnum, 0, CLSCTX_INPROC, IID_ICreateDevEnum, (void **) &devs);
	devs->CreateClassEnumerator (CLSID_VideoInputDeviceCategory, &cams, 0);
	cams->Next (1,&mon,0);												// get first found capture device (webcam)    
	mon->BindToObject(0,0,IID_IBaseFilter, (void**)&cam);
	
	graph->AddFilter(cam, L"Capture Source");							// add web cam to graph as source
	cam->EnumPins(&pins);												// we need output pin to autogenerate rest of the graph
	pins->Next(1,&pin, 0);												// via graph->Render
	graph->Render(pin);													// graph builder now builds whole filter chain including MJPG decompression on some webcams
	graph->EnumFilters(&fil);											// from all newly added filters
	fil->Next(1,&rnd,0);												// we find last one (renderer)
	rnd->EnumPins(&pins);												// because data we are intersted in are pumped to renderers input pin 
	pins->Next(1,&pin, 0);												// via Receive member of IMemInputPin interface
	pin->QueryInterface(IID_IMemInputPin,(void**)&mem);

	DsHook(mem,6,Receive);												// so we redirect it to our own proc to grab image data

	if (Start) this->Start();
}
开发者ID:si2dharth,项目名称:Windows-Library,代码行数:37,代码来源:Camera.cpp

示例7: Destroy

HRESULT CTMReceiverGraph::Destroy()
{
	HRESULT hr = S_OK;

	m_pMediaEvent = NULL;
	m_pMeidaSeeking = NULL;
	m_pRecordStream = NULL;
	m_pSetCallBack = NULL;
	m_pVideoWindow = NULL;
	m_pBasicVideo = NULL;

	if(m_pGraphBuilder && m_pMediaControl)
	{
		m_pMediaControl->Stop();

		CComPtr<IEnumFilters> pEnum = NULL;
		hr = m_pGraphBuilder->EnumFilters(&pEnum);
		if(SUCCEEDED(hr))
		{
			IBaseFilter *pFilter = NULL;
			while(S_OK == pEnum->Next(1, &pFilter, NULL))
			{
				FILTER_INFO filterInfo;
				if(SUCCEEDED(pFilter->QueryFilterInfo(&filterInfo)))
				{
					SAFE_RELEASE(filterInfo.pGraph);
					CComPtr<IEnumPins> pIEnumPins = NULL;
					hr = pFilter->EnumPins(&pIEnumPins);
					if(SUCCEEDED(hr))
					{
						IPin *pIPin = NULL;
						while(S_OK == pIEnumPins->Next(1, &pIPin, NULL))
						{
							m_pGraphBuilder->Disconnect(pIPin);
							SAFE_RELEASE(pIPin);
						}
					}
				}
				SAFE_RELEASE(pFilter);
			}
		}
	}
	else
	{
		hr = S_FALSE;
	}
	return hr;
}
开发者ID:LeeBn,项目名称:Navigation,代码行数:48,代码来源:TMReceiverGraph.cpp

示例8: GetCrossbarIPinAtIndex

//
// Does not AddRef the returned *Pin 
//
HRESULT CCrossbar::GetCrossbarIPinAtIndex(
   IAMCrossbar *pXbar,
   LONG PinIndex,
   BOOL IsInputPin,
   IPin ** ppPin)
{
    LONG         cntInPins, cntOutPins;
    IPin        *pP = 0;
    IBaseFilter *pFilter = NULL;
    IEnumPins   *pins=0;
    ULONG        n;
    HRESULT      hr;

    if (!pXbar || !ppPin)
        return E_POINTER;

    *ppPin = 0;

    if(S_OK != pXbar->get_PinCounts(&cntOutPins, &cntInPins))
        return E_FAIL;

    LONG TrueIndex = IsInputPin ? PinIndex : PinIndex + cntInPins;

    hr = pXbar->QueryInterface(IID_IBaseFilter, (void **)&pFilter);

    if (hr == S_OK) 
    {
        if(SUCCEEDED(pFilter->EnumPins(&pins))) 
        {
            LONG i=0;
            while(pins->Next(1, &pP, &n) == S_OK) 
            {
                pP->Release();
                if (i == TrueIndex) 
                {
                    *ppPin = pP;
                    break;
                }
                i++;
            }
            pins->Release();
        }
        pFilter->Release();
    }
    
    return *ppPin ? S_OK : E_FAIL; 
}
开发者ID:LoveDuckie,项目名称:fwink,代码行数:50,代码来源:crossbar.cpp

示例9: GetCrossbarIndexFromIPin

//
// Find corresponding index of an IPin on a crossbar
//
HRESULT CCrossbar::GetCrossbarIndexFromIPin (
    IAMCrossbar * pXbar,
    LONG * PinIndex,
    BOOL IsInputPin,
    IPin * pPin)
{
    LONG         cntInPins, cntOutPins;
    IPin        *pP = 0;
    IBaseFilter *pFilter = NULL;
    IEnumPins   *pins = 0;
    ULONG        n;
    BOOL         fOK = FALSE;
    HRESULT      hr;

    if (!pXbar || !PinIndex || !pPin)
        return E_POINTER;

    if(S_OK != pXbar->get_PinCounts(&cntOutPins, &cntInPins))
        return E_FAIL;

    hr = pXbar->QueryInterface(IID_IBaseFilter, (void **)&pFilter);

    if (hr == S_OK) 
    {
        if(SUCCEEDED(pFilter->EnumPins(&pins))) 
        {
            LONG i=0;
        
            while(pins->Next(1, &pP, &n) == S_OK) 
            {
                pP->Release();
                if (pPin == pP) 
                {
                    *PinIndex = IsInputPin ? i : i - cntInPins;
                    fOK = TRUE;
                    break;
                }
                i++;
            }
            pins->Release();
        }
        pFilter->Release();
    }
    
    return fOK ? S_OK : E_FAIL; 
}
开发者ID:LoveDuckie,项目名称:fwink,代码行数:49,代码来源:crossbar.cpp

示例10: GetAMConfigForMultiPin

	HRESULT GetAMConfigForMultiPin(IUnknown* pUnk, PIN_DIRECTION direct, IAMStreamConfig** ppConfig)
	{
		IBaseFilter* pBaseFilter = NULL;
		HRESULT hr = pUnk->QueryInterface(IID_IBaseFilter, (void**)&pBaseFilter);
		if (SUCCEEDED(hr))
		{
			IEnumPins* pEnumPins = NULL;
			hr = pBaseFilter->EnumPins(&pEnumPins);
			if (SUCCEEDED(hr))
			{
				pEnumPins->Reset();
				if (SUCCEEDED(hr))
				{
					IPin* pPin = NULL;
					BOOL bFound = FALSE;
					while ((pEnumPins->Next(1, &pPin, NULL) == S_OK) && !bFound)
					{
						PIN_DIRECTION fetchedDir;
						hr = pPin->QueryDirection(&fetchedDir);
						if (SUCCEEDED(hr) && (fetchedDir == direct))
						{
							IKsPropertySet* pPS;
							hr = pPin->QueryInterface(IID_IKsPropertySet, (void**)&pPS);
							if (SUCCEEDED(hr))
							{
								GUID guid = { 0 };
								DWORD dwReturn = 0;
								hr = pPS->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, 0, 0, &guid, sizeof(guid), &dwReturn);
								if (SUCCEEDED(hr) && ::IsEqualGUID(guid, PIN_CATEGORY_CAPTURE))
								{
									hr = pPin->QueryInterface(IID_IAMStreamConfig, (void**)ppConfig);
									bFound = SUCCEEDED(hr);
								}
								pPS->Release();
							}
						}
						pPin->Release();
					}
				}
				pEnumPins->Release();
			}
			pBaseFilter->Release();
		}
		return hr;
	}
开发者ID:wyrover,项目名称:HiVideo2,代码行数:45,代码来源:DShowUtils.cpp

示例11: findStreamTypes

int DirectShowPlayerService::findStreamTypes(IBaseFilter *source) const
{
    QVarLengthArray<IBaseFilter *, 16> filters;
    source->AddRef();
    filters.append(source);

    int streamTypes = 0;

    while (!filters.isEmpty()) {
        IEnumPins *pins = 0;
        IBaseFilter *filter = filters[filters.size() - 1];
        filters.removeLast();

        if (SUCCEEDED(filter->EnumPins(&pins))) {
            for (IPin *pin = 0; pins->Next(1, &pin, 0) == S_OK; pin->Release()) {
                PIN_DIRECTION direction;
                if (pin->QueryDirection(&direction) == S_OK && direction == PINDIR_OUTPUT) {
                    AM_MEDIA_TYPE connectionType;
                    if (SUCCEEDED(pin->ConnectionMediaType(&connectionType))) {
                        IPin *peer = 0;

                        if (connectionType.majortype == MEDIATYPE_Audio) {
                            streamTypes |= AudioStream;
                        } else if (connectionType.majortype == MEDIATYPE_Video) {
                            streamTypes |= VideoStream;
                        } else if (SUCCEEDED(pin->ConnectedTo(&peer))) {
                            PIN_INFO peerInfo;
                            if (SUCCEEDED(peer->QueryPinInfo(&peerInfo)))
                                filters.append(peerInfo.pFilter);
                            peer->Release();
                        }
                    } else {
                        streamTypes |= findStreamType(pin);
                    }
                }
            }
        }
        filter->Release();
    }
    return streamTypes;
}
开发者ID:KDE,项目名称:android-qt-mobility,代码行数:41,代码来源:directshowplayerservice.cpp

示例12: _tmain

int _tmain(int argc, _TCHAR* argv[])
{

	int y;
	cin>>y;
	//
	IGraphBuilder* locGraphBuilder = NULL;
	IMediaControl* locMediaControl = NULL;
	IBaseFilter* locDemuxer = NULL;
	ICustomSource* locCustomSourceSetter = NULL;
	HRESULT locHR = S_FALSE;;
	CoInitialize(NULL);
	locHR = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&locGraphBuilder);

	locHR = CoCreateInstance(CLSID_OggDemuxPacketSourceFilter, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&locDemuxer);

	locGraphBuilder->AddFilter(locDemuxer, L"Custom Ogg Source");
	locDemuxer->QueryInterface(IID_ICustomSource, (void**)&locCustomSourceSetter);


	CustomSourceClass* locCustomFileSourceInterface = new CustomSourceClass;
	locCustomFileSourceInterface->open("D:\\testfile.ogg");
	
	locCustomSourceSetter->setCustomSourceAndLoad(locCustomFileSourceInterface);

	//Do not release, it's not really a COM interface
	//locCustomSourceSetter->Release();

	IEnumPins* locPinEnum = NULL;

	locDemuxer->EnumPins(&locPinEnum);

	

	IPin* locPin = NULL;
	ULONG locHowMany = 0;
	while (locPinEnum->Next(1, &locPin, &locHowMany) == S_OK) {
		locHR = locGraphBuilder->Render(locPin);
		locPin->Release();
		locPin = NULL;
	}






	//locHR = locGraphBuilder->RenderFile(L"g:\\a.ogg", NULL);

	locHR = locGraphBuilder->QueryInterface(IID_IMediaControl, (void**)&locMediaControl);


	locHR = locMediaControl->Run();

	IMediaEvent* locMediaEvent = NULL;
	locHR = locGraphBuilder->QueryInterface(IID_IMediaEvent, (void**)&locMediaEvent);
	
	HANDLE  hEvent; 
	long    evCode, param1, param2;
	BOOLEAN bDone = FALSE;
	HRESULT hr = S_OK;
	hr = locMediaEvent->GetEventHandle((OAEVENT*)&hEvent);
	if (FAILED(hr))
	{
	    /* Insert failure-handling code here. */
	}
	while(!bDone) 
	{
	    if (WAIT_OBJECT_0 == WaitForSingleObject(hEvent, 100))
	    { 
			while (hr = locMediaEvent->GetEvent(&evCode, &param1, &param2, 0), SUCCEEDED(hr)) 
			{
	            //printf("Event code: %#04x\n Params: %d, %d\n", evCode, param1, param2);
				cout<<"Event : "<<evCode<<" Params : "<<param1<<", "<<param2<<endl;
				locMediaEvent->FreeEventParams(evCode, param1, param2);
				bDone = (EC_COMPLETE == evCode);
			}
		}
	} 

	cout<<"Finished..."<<endl;
	int x;
	cin>>x;
	locMediaControl->Release();
	locGraphBuilder->Release();
	CoUninitialize();

	return 0;
}
开发者ID:kazutomi,项目名称:xiphqt,代码行数:89,代码来源:testCustomSource.cpp

示例13: CoCreateInstance

void gui::dx::audio_playerX::initialize_speedup_filter() {
	if (speedup_filter_available_valid && !speedup_filter_available) {
		// We don't seem to have the filter. Too bad.
		return;
	}
	// Either the filter exists or we haven't tried yet. Let's try to create
	// it and remember whether it worked.
	IBaseFilter *pNewFilter = NULL;

	HRESULT res;
	res = CoCreateInstance(CLSID_TPBVupp69, NULL, CLSCTX_INPROC_SERVER,
		IID_IBaseFilter, (void**)&pNewFilter);

	if (res != S_OK) {
		traceX("dx_audio_player: Speedup filter not available, error 0x%x", res);
		speedup_filter_available = false;
		speedup_filter_available_valid = true;
		return;
	}
	res = m_graph_builder->AddFilter(pNewFilter, NULL);
	if (res != S_OK) {
		traceX("dx_audio_player: AddFilter(Speedup filter): error 0x%x", res);
		pNewFilter->Release();
		return;
	}
	speedup_filter_available = true;
	speedup_filter_available_valid = true;
	//	AM_DBG lib::debugX("dx_audio_player: added speedup filter to graph");

	// Next step: find out where we want to add the filter to the graph.
	// We iterate over the filter graph, then for each item in the graph
	// we iterate over the connected output pins util we find one we like.
	IPin *pOutputPin = NULL;
	IPin *pInputPin = NULL;
	IEnumFilters *pEnumFilters = NULL;
	res = m_graph_builder->EnumFilters(&pEnumFilters);
	if (res != S_OK) {
		traceX("dx_audio_filter: EnumFilters: error 0x%x", res);
		return;
	}

	IBaseFilter *pCurFilter;
	while (pOutputPin == NULL && (res=pEnumFilters->Next(1, &pCurFilter, NULL)) == S_OK) {
		AM_DBG {
			FILTER_INFO info;
			LPWSTR vendorInfo;
			res = pCurFilter->QueryFilterInfo(&info);
			if (res != S_OK) info.achName[0] = 0;
			res = pCurFilter->QueryVendorInfo(&vendorInfo);
			if (res != S_OK) vendorInfo = L"";
			//ambulant::lib::textptr tInfo(info.achName);
			//ambulant::lib::textptr tVendorInfo(vendorInfo);
			//lib::debugX("dx_audio_filter: filter found: '%s' vendor '%s'", tInfo.c_str(), tVendorInfo.c_str());
		}
		IEnumPins *pEnumPins;
		res = pCurFilter->EnumPins(&pEnumPins);
		IPin *pCurPin;
		while (pOutputPin == NULL && (res=pEnumPins->Next(1, &pCurPin, NULL)) == S_OK) {
			AM_MEDIA_TYPE mediaType;
			PIN_DIRECTION curPinDir;
			res = pCurPin->QueryDirection(&curPinDir);
			HRESULT res2 = pCurPin->ConnectionMediaType(&mediaType);
			if (res == S_OK && 
				res2 == S_OK && 
				curPinDir == PINDIR_OUTPUT &&
				mediaType.majortype == MEDIATYPE_Audio&& 
				mediaType.subtype == MEDIASUBTYPE_PCM){
					pOutputPin = pCurPin;
					res = pOutputPin->ConnectedTo(&pInputPin);
					if (res != S_OK) {
						// This output pin was the correct type, but not connected.
						// So it cannot be the one we're looking for.
						pOutputPin = pInputPin = NULL;
					} else {
						// Found it!
						pOutputPin->AddRef();
						pInputPin->AddRef();
					}
				}
				if (res2 == S_OK) {
					if (mediaType.cbFormat != 0) {
						CoTaskMemFree((PVOID)mediaType.pbFormat);
					}
				}
				pCurPin->Release();
		}
		if (res != S_FALSE && res != S_OK) 
			traceX("dx_audio_filter: enumerating pins: error 0x%x", res);
		pEnumPins->Release();
		pCurFilter->Release();
	}
	if (res != S_FALSE && res != S_OK)
		traceX("dx_audio_filter: enumerating filters: error 0x%x", res);

	pEnumFilters->Release();
	// We have the correct pins now.
	if (pOutputPin) {
		traceX("dx_audio_filter: found the right pins!");
	} else {
		traceX("dx_audio_filter: could not find a good pin");
//.........这里部分代码省略.........
开发者ID:daisy,项目名称:amis,代码行数:101,代码来源:dx_audio_player.cpp

示例14: doRender

void DirectShowPlayerService::doRender(QMutexLocker *locker)
{
    m_pendingTasks |= m_executedTasks & (Play | Pause);

    if (IMediaControl *control = com_cast<IMediaControl>(m_graph, IID_IMediaControl)) {
        control->Stop();
        control->Release();
    }

    if (m_pendingTasks & SetAudioOutput) {
        m_graph->AddFilter(m_audioOutput, L"AudioOutput");

        m_pendingTasks ^= SetAudioOutput;
        m_executedTasks |= SetAudioOutput;
    }
    if (m_pendingTasks & SetVideoOutput) {
        m_graph->AddFilter(m_videoOutput, L"VideoOutput");

        m_pendingTasks ^= SetVideoOutput;
        m_executedTasks |= SetVideoOutput;
    }

    IFilterGraph2 *graph = m_graph;
    graph->AddRef();

    QVarLengthArray<IBaseFilter *, 16> filters;
    m_source->AddRef();
    filters.append(m_source);

    bool rendered = false;

    HRESULT renderHr = S_OK;

    while (!filters.isEmpty()) {
        IEnumPins *pins = 0;
        IBaseFilter *filter = filters[filters.size() - 1];
        filters.removeLast();

        if (!(m_pendingTasks & ReleaseFilters) && SUCCEEDED(filter->EnumPins(&pins))) {
            int outputs = 0;
            for (IPin *pin = 0; pins->Next(1, &pin, 0) == S_OK; pin->Release()) {
                PIN_DIRECTION direction;
                if (pin->QueryDirection(&direction) == S_OK && direction == PINDIR_OUTPUT) {
                    ++outputs;

                    IPin *peer = 0;
                    if (pin->ConnectedTo(&peer) == S_OK) {
                        PIN_INFO peerInfo;
                        if (SUCCEEDED(peer->QueryPinInfo(&peerInfo)))
                            filters.append(peerInfo.pFilter);
                        peer->Release();
                    } else {
                        locker->unlock();
                        HRESULT hr;
                        if (SUCCEEDED(hr = graph->RenderEx(
                                pin, /*AM_RENDEREX_RENDERTOEXISTINGRENDERERS*/ 1, 0))) {
                            rendered = true;
                        } else if (renderHr == S_OK || renderHr == VFW_E_NO_DECOMPRESSOR){
                            renderHr = hr;
                        }
                        locker->relock();
                    }
                }
            }

            pins->Release();

            if (outputs == 0)
                rendered = true;
        }
        filter->Release();
    }

    if (m_audioOutput && !isConnected(m_audioOutput, PINDIR_INPUT)) {
        graph->RemoveFilter(m_audioOutput);

        m_executedTasks &= ~SetAudioOutput;
    }

    if (m_videoOutput && !isConnected(m_videoOutput, PINDIR_INPUT)) {
        graph->RemoveFilter(m_videoOutput);

        m_executedTasks &= ~SetVideoOutput;
    }

    graph->Release();

    if (!(m_pendingTasks & ReleaseFilters)) {
        if (rendered) {
            if (!(m_executedTasks & FinalizeLoad))
                m_pendingTasks |= FinalizeLoad;
        } else {
            m_pendingTasks = 0;

            m_graphStatus = InvalidMedia;

            if (!m_audioOutput && !m_videoOutput) {
                m_error = QMediaPlayer::ResourceError;
                m_errorString = QString();
            } else {
//.........这里部分代码省略.........
开发者ID:KDE,项目名称:android-qt-mobility,代码行数:101,代码来源:directshowplayerservice.cpp

示例15: sizeof

/*
 * Class:     sage_DShowMediaPlayer
 * Method:    getColorKey0
 * Signature: (J)Ljava/awt/Color;
 */
JNIEXPORT jobject JNICALL Java_sage_DShowMediaPlayer_getColorKey0
  (JNIEnv *env, jobject jo, jlong dataPtr)
{
	if (!dataPtr) return 0;
	CPlayerData* playData = (CPlayerData*) dataPtr;
	IGraphBuilder* pGraph = playData->GetGraph();
	if (!pGraph) return 0;
	BOOL forceColorKey = FALSE;
	HRESULT hr;
	DWORD holder;
	HKEY myKey;
	DWORD readType;
	DWORD hsize = sizeof(holder);
	DWORD keyedColor = RGB(1,1,1);
	if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Frey Technologies\\Common\\DirectShow", 0, 0,
		REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &myKey, 0) == ERROR_SUCCESS)
	{
		if (RegQueryValueEx(myKey, "TransparentColorKey", 0, &readType, (LPBYTE) &holder, &hsize) == ERROR_SUCCESS)
		{
			keyedColor = holder;
			forceColorKey = TRUE;
		}
		RegCloseKey(myKey);
	}
	COLORKEY overlayKey;
	overlayKey.KeyType = CK_RGB;
	overlayKey.PaletteIndex = 0;
	overlayKey.LowColorValue = keyedColor;
	overlayKey.HighColorValue = keyedColor;

	COLORKEY defaultKey;

	BOOL overlayIsUsed = FALSE;
	IEnumFilters *pEnum = NULL;
	if (!forceColorKey)
	{
		// Find the default color key
		hr = pGraph->EnumFilters(&pEnum);
		if (SUCCEEDED(hr))
		{
			IBaseFilter *currFilt = NULL;
			while (pEnum->Next(1, &currFilt, NULL) == S_OK)
			{
				IPin *overlayPin = NULL;
				IEnumPins* pPinEnum = NULL;
				hr = currFilt->EnumPins(&pPinEnum);
				if (hr == NO_ERROR)
				{
					IPin *pPin = NULL;
					hr = E_FAIL;
					while(S_OK == pPinEnum->Next(1, &pPin, NULL))
					{
						IOverlay *pOverlayPin = NULL;
						hr = pPin->QueryInterface(IID_IOverlay, (void**)&pOverlayPin);
						if (SUCCEEDED(hr))
						{
							hr = pOverlayPin->GetDefaultColorKey(&defaultKey);
							if (!forceColorKey && SUCCEEDED(hr))
							{
								keyedColor = defaultKey.LowColorValue;
								slog((env, "Got the default color key 0x%x\r\n", keyedColor));
								//forceColorKey = TRUE;
							}
							SAFE_RELEASE(pOverlayPin);
						}
						SAFE_RELEASE(pPin);
					}
					SAFE_RELEASE(pPinEnum);
				}
				SAFE_RELEASE(currFilt);
			}
			SAFE_RELEASE(pEnum);
		}
	}
	pEnum = NULL;

	// Set the color key value
	hr = pGraph->EnumFilters(&pEnum);
	if (SUCCEEDED(hr))
	{
		IBaseFilter *currFilt = NULL;
		while (pEnum->Next(1, &currFilt, NULL) == S_OK)
		{
			IPin *overlayPin = NULL;
			IEnumPins* pPinEnum = NULL;
			currFilt->EnumPins(&pPinEnum);
			while (pPinEnum->Next(1, &overlayPin, NULL) == S_OK)
			{
				// let's see if it's overlay
				IMixerPinConfig *pOverlayMix = NULL;
				hr = overlayPin->QueryInterface(IID_IMixerPinConfig, (void**)&pOverlayMix);
				if (SUCCEEDED(hr))
				{
					if (!forceColorKey)
						keyedColor = overlayKey.LowColorValue;
//.........这里部分代码省略.........
开发者ID:bryanzim,项目名称:sagetv,代码行数:101,代码来源:PlaybackGraph.cpp


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