Exemple #1
0
//查找Filter上某一个接口,只要找到FilterGraph上某一个Filter有该接口即返回
BOOL FindFilterInterface(IGraphBuilder* pGraphBuilder, REFGUID iid, void** ppUnk)
{
	if(!pGraphBuilder || !ppUnk)
		return FALSE;

	IEnumFilters* pEnumFilter = NULL;
	IBaseFilter* pFilter = NULL;

	if(FAILED(pGraphBuilder->EnumFilters(&pEnumFilter)))
	{
		return FALSE;
	}

	HRESULT hr = E_FAIL;
	while(S_OK == pEnumFilter->Next(1,&pFilter,NULL))
	{
		hr = pFilter->QueryInterface(iid,ppUnk);
		pFilter->Release();
		if(SUCCEEDED(hr))
		{
			pEnumFilter->Release();
			return TRUE;
		}
	}

	pEnumFilter->Release();
	return FALSE;
}
Exemple #2
0
//
// The GraphBuilder interface provides a FindFilterByName() method,
// which provides similar functionality to the method below.
// This local method is provided for educational purposes.
//
IBaseFilter *FindFilterFromName(IGraphBuilder *pGB, LPTSTR szNameToFind)
{
    USES_CONVERSION;

    HRESULT hr;
    IEnumFilters *pEnum = NULL;
    IBaseFilter *pFilter = NULL;
    ULONG cFetched;
    BOOL bFound = FALSE;

    // Verify graph builder interface
    if (!pGB)
        return NULL;

    // Get filter enumerator
    hr = pGB->EnumFilters(&pEnum);
    if (FAILED(hr))
        return NULL;

    // Enumerate all filters in the graph
    while((pEnum->Next(1, &pFilter, &cFetched) == S_OK) && (!bFound))
    {
        FILTER_INFO FilterInfo;
        TCHAR szName[256];
        
        hr = pFilter->QueryFilterInfo(&FilterInfo);
        if (FAILED(hr))
        {
            pFilter->Release();
            pEnum->Release();
            return NULL;
        }

        // Compare this filter's name with the one we want
        lstrcpy(szName, W2T(FilterInfo.achName));
        if (! lstrcmp(szName, szNameToFind))
        {
            bFound = TRUE;
        }

        FilterInfo.pGraph->Release();

        // If we found the right filter, don't release its interface.
        // The caller will use it and release it later.
        if (!bFound)
            pFilter->Release();
        else
            break;
    }
    pEnum->Release();

    return (bFound ? pFilter : NULL);
}
HRESULT CDShowUtility::FindFilterInterface(IGraphBuilder *pGraph, REFGUID iid, void **ppUnk)
{
    if (!pGraph || !ppUnk) 
    {
        return E_POINTER;
    }

    HRESULT hr = E_FAIL;
    IEnumFilters *pEnum = NULL;
    IBaseFilter *pF = NULL;

    if (FAILED(pGraph->EnumFilters(&pEnum)))
    {
        return E_FAIL;
    }

    //分别调用 Queryinterface, 枚举filter Graph 中的所有Filter 
    while (S_OK == pEnum->Next(1, &pF, 0))
    {
        hr = pF->QueryInterface(iid, ppUnk);
        pF->Release();

        if (SUCCEEDED(hr))
        {
            break;
        }
    }

    pEnum->Release();
    return hr;    
}
Exemple #4
0
HRESULT FindFilterInterface(
	IGraphBuilder *pGraph, // Pointer to the Filter Graph Manager.
	REFGUID iid,           // IID of the interface to retrieve.
	void **ppUnk)          // Receives the interface pointer.
{
	if (!pGraph || !ppUnk) return E_POINTER;

	HRESULT hr = E_FAIL;
	IEnumFilters *pEnum = NULL;
	IBaseFilter *pF = NULL;
	if (FAILED(pGraph->EnumFilters(&pEnum)))
	{
		return E_FAIL;
	}
	// Query every filter for the interface.
	while (S_OK == pEnum->Next(1, &pF, 0))
	{
		hr = pF->QueryInterface(iid, ppUnk);
		pF->Release();
		if (SUCCEEDED(hr))
		{
			break;
		}
	}
	pEnum->Release();
	return hr;
}
Exemple #5
0
HRESULT FindInterfaceAnywhere(
	IGraphBuilder *pGraph, 
	REFGUID iid, 
	void **ppUnk)
{
	if (!pGraph || !ppUnk) return E_POINTER;
	HRESULT hr = E_FAIL;
	IEnumFilters *pEnum = 0;
	if (FAILED(pGraph->EnumFilters(&pEnum)))
	{
		return E_FAIL;
	}
	// Loop through every filter in the graph.
	IBaseFilter *pF = 0;
	while (S_OK == pEnum->Next(1, &pF, 0))
	{
		hr = pF->QueryInterface(iid, ppUnk);
		if (FAILED(hr))
		{
			// The filter does not expose the interface, but maybe
			// one of its pins does.
			hr = FindPinInterface(pF, iid, ppUnk);
		}
		pF->Release();
		if (SUCCEEDED(hr))
		{
			break;
		}
	}
	pEnum->Release();
	return hr;
}
/*****************************Public*Routine******************************\
* FindInterfaceFromFilterGraph
*
\**************************************************************************/
HRESULT
CMovie::FindInterfaceFromFilterGraph(
    REFIID iid, // interface to look for
    LPVOID *lp  // place to return interface pointer in
    )
{
    IEnumFilters* pEF;
    IBaseFilter*  pFilter;

    // Grab an enumerator for the filter graph.
    HRESULT hr = m_Fg->EnumFilters(&pEF);

    if(FAILED(hr))
    {
        return hr;
    }

    // Check out each filter.
    while(pEF->Next(1, &pFilter, NULL) == S_OK)
    {
        hr = pFilter->QueryInterface(iid, lp);
        pFilter->Release();

        if(SUCCEEDED(hr))
        {
            break;
        }
    }

    pEF->Release();

    return hr;
}
Exemple #7
0
//
//  Removes any filters in the audio graph - called before rebuilding the audio graph.
//
void CMediaPlayer::RemoveAllFilters()
{
    IEnumFilters *enumFilters;
    HRESULT hr = _GraphBuilder->EnumFilters(&enumFilters);

    if (SUCCEEDED(hr))
    {
        IBaseFilter *filter = NULL;
        hr = enumFilters->Next(1, &filter, NULL);
        while (hr == S_OK)
        {
            //
            //  Remove the filter from the graph.
            //
            _GraphBuilder->RemoveFilter(filter);
            filter->Release();

            //
            //  Reset the enumeration since we removed the filter (which invalidates the enumeration).
            //
            enumFilters->Reset();

            hr = enumFilters->Next(1, &filter, NULL);
        }
        enumFilters->Release();
    }
}
//
// FindSubtitleFilter
//
// be careful with this method, can cause deadlock with CSync::Stop, so should only be called in Run()
HRESULT CTsReaderFilter::FindSubtitleFilter()
{
  if( m_pDVBSubtitle )
  {
    return S_OK;
  }
  //LogDebug( "FindSubtitleFilter - start");

  IEnumFilters * piEnumFilters = NULL;
  if (GetFilterGraph() && SUCCEEDED(GetFilterGraph()->EnumFilters(&piEnumFilters)))
  {
    IBaseFilter * pFilter;
    while (piEnumFilters->Next(1, &pFilter, 0) == NOERROR )
    {
      FILTER_INFO filterInfo;
      if (pFilter->QueryFilterInfo(&filterInfo) == S_OK)
      {
        if (!wcsicmp(L"MediaPortal DVBSub2", filterInfo.achName))
        {
          HRESULT fhr = pFilter->QueryInterface( IID_IDVBSubtitle2, ( void**)&m_pDVBSubtitle );
          assert( fhr == S_OK);
          //LogDebug("Testing that DVBSub2 works");
          m_pDVBSubtitle->Test(1);
        }
        filterInfo.pGraph->Release();
      }
      pFilter->Release();
      pFilter = NULL;
    }
    piEnumFilters->Release();
  }
  //LogDebug( "FindSubtitleFilter - End");
  return S_OK;
}
Exemple #9
0
HRESULT CBDReaderFilter::FindSubtitleFilter()
{
  if (m_pDVBSubtitle)
    return S_OK;

  HRESULT hr = S_FALSE;
  ULONG fetched = 0;

  IEnumFilters * piEnumFilters = NULL;
  if (GetFilterGraph() && SUCCEEDED(GetFilterGraph()->EnumFilters(&piEnumFilters)))
  {
    IBaseFilter * pFilter;
    while (piEnumFilters->Next(1, &pFilter, &fetched) == NOERROR)
    {
      FILTER_INFO filterInfo;
      if (pFilter->QueryFilterInfo(&filterInfo) == S_OK)
      {
        if (!wcsicmp(L"MediaPortal DVBSub3", filterInfo.achName))
          hr = pFilter->QueryInterface(IID_IDVBSubtitle3, (void**)&m_pDVBSubtitle);

        filterInfo.pGraph->Release();
      }
      pFilter->Release();
      pFilter = NULL;
    }
    piEnumFilters->Release();
  }

  return hr;
}
Exemple #10
0
HRESULT CFilterProp::EnumFilters()
{
	if ( !pGB ) return E_FAIL;

    HRESULT hr;
    IEnumFilters *pEnum = NULL;
    IBaseFilter *pFilter = NULL;
    ULONG cFetched;

    // Clear filters list box
    m_ListFilters.ResetContent();
    
    // Get filter enumerator
    hr = pGB->EnumFilters(&pEnum);
    if (FAILED(hr))
    {
        m_ListFilters.AddString(TEXT("<ERROR>"));
        return hr;
    }

    // Enumerate all filters in the graph
    while(pEnum->Next(1, &pFilter, &cFetched) == S_OK)
    {
        FILTER_INFO FilterInfo;
        TCHAR szName[256];
        
        hr = pFilter->QueryFilterInfo(&FilterInfo);
        if (FAILED(hr))
        {
            m_ListFilters.AddString(TEXT("<ERROR>"));
        }
        else
        {
				ISpecifyPropertyPages *pSpecify;
				hr = pFilter->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pSpecify);
				if (SUCCEEDED(hr)) 
				{
	            pSpecify->Release();

					// Add the filter name to the filters listbox
					USES_CONVERSION;

					lstrcpy(szName, W2T(FilterInfo.achName));
					m_ListFilters.AddString(szName);

				}
				FilterInfo.pGraph->Release();
        }       
        pFilter->Release();
    }
    pEnum->Release();

    return hr;
}
Exemple #11
0
//Обновляет массив m_pFGBaseFilter[], хранящий список фильтров DirectShow в текущем Filter Graph
//Функция Open() вызывает эту функцию автоматически
//Однако, крайне желательно вызывать её повторно перед вызовом функций,
//работающих с m_pFGBaseFilter[] массивом
void CDirectShow::UpdateFGFiltersArray()
{
	IEnumFilters *pEnumFilters = NULL;
	if (FAILED(m_pGraphBuilder->EnumFilters(&pEnumFilters))) return;
	for (m_lCounter = 0; m_lCounter < E_MAX_ARR_SIZE; m_lCounter++)
	{
		SR(m_pFGBaseFilter[m_lCounter]);
		m_pFGBaseFilter[m_lCounter] = NULL;
	}
	pEnumFilters->Reset();
	pEnumFilters->Next(E_MAX_ARR_SIZE, &m_pFGBaseFilter[0], &m_lFGFilCount);
	pEnumFilters->Release();
}
Exemple #12
0
recChannel_t::~recChannel_t(void)
{
     __CONTEXT("recChannel_t::~recChannel_t");

	IBaseFilter * pFilter = NULL;
	if (camInfo->getKind() == TEST) 
	{
		looper->EndThread();
	}
	
	unmap();
	camList->lookUp(sourceId)->setFree(true);
	 
	pControl->Stop();
	
    looper->EndThread();
 
    delete looper;
    delete pSender;

    remap();
	
	int hr = 0;

	// Enumerate the filters in the graph.
	IEnumFilters *pEnum = NULL;
	hr = pGraph->EnumFilters(&pEnum);
	if (SUCCEEDED(hr))
	{
		IBaseFilter *pFilter = NULL;
		while (S_OK == pEnum->Next(1, &pFilter, NULL))
		{
				pGraph->RemoveFilter(pFilter);
				pFilter->Release();
				pEnum->Reset();
		}
		pEnum->Release();
	}
	pControl->Release();
	pEvent->Release();
	pGraph->Release();
	
	channelList->remove(getId());
	rtpSession->deleteSender (getId(), "Channel deleted");
#ifdef _WINDOWS
    EndThread();
    TerminateThread(hThread,0); 
#endif
    

}
Exemple #13
0
HRESULT AddGraphFiltersToList (IGraphBuilder *pGB, CListBox& m_ListFilters) 
{
    HRESULT hr;
    IEnumFilters *pEnum = NULL;
    IBaseFilter *pFilter = NULL;
    ULONG cFetched;

    // Clear filters list box
    m_ListFilters.ResetContent();
    
    // Verify graph builder interface
    if (!pGB)
        return E_NOINTERFACE;

    // Get filter enumerator
    hr = pGB->EnumFilters(&pEnum);
    if (FAILED(hr))
    {
        m_ListFilters.AddString(TEXT("<ERROR>"));
        return hr;
    }

    // Enumerate all filters in the graph
    while(pEnum->Next(1, &pFilter, &cFetched) == S_OK)
    {
        FILTER_INFO FilterInfo;
        TCHAR szName[256];
        
        hr = pFilter->QueryFilterInfo(&FilterInfo);
        if (FAILED(hr))
        {
            m_ListFilters.AddString(TEXT("<ERROR>"));
        }
        else
        {
            USES_CONVERSION;

            // Add the filter name to the filters listbox
            lstrcpy(szName, W2T(FilterInfo.achName));
            m_ListFilters.AddString(szName);

            // Must release filter graph reference
            FilterInfo.pGraph->Release();
        }       
        pFilter->Release();
    }
    pEnum->Release();

    return hr;
}
void videoInputCamera::destroyGraph(){
	HRESULT hr = NULL;
	int FuncRetval=0;
	int NumFilters=0;

	int i = 0;
	while (hr == NOERROR)
	{
		IEnumFilters * pEnum = 0;
		ULONG cFetched;

		// We must get the enumerator again every time because removing a filter from the graph
		// invalidates the enumerator. We always get only the first filter from each enumerator.
		hr = pGraphBuilder->EnumFilters(&pEnum);
		//if (FAILED(hr)) { printf("SETUP: pGraph->EnumFilters() failed. \n"); return; }

		IBaseFilter * pFilter = NULL;
		if (pEnum->Next(1, &pFilter, &cFetched) == S_OK)
		{
			FILTER_INFO FilterInfo={0};
			hr = pFilter->QueryFilterInfo(&FilterInfo);
			FilterInfo.pGraph->Release();

			int count = 0;
			char buffer[255];
			memset(buffer, 0, 255 * sizeof(char));

			while( FilterInfo.achName[count] != 0x00 )
			{
				buffer[count] = static_cast<char>(FilterInfo.achName[count]);
				count++;
			}

			//printf("SETUP: removing filter %s...\n", buffer);
			hr = pGraphBuilder->RemoveFilter(pFilter);
			//if (FAILED(hr)) { printf("SETUP: pGraph->RemoveFilter() failed. \n"); return; }
			//printf("SETUP: filter removed %s  \n",buffer);

			pFilter->Release();
			pFilter = NULL;
		}
		else hr = 1;
		pEnum->Release();
		pEnum = NULL;
		i++;
	}

	return;
}
void PlaybackControls::EmptyGraph()
{
	IEnumFilters *pEnum = NULL;
	if (mpGraph)
	{
		HRESULT hr = mpGraph->EnumFilters(&pEnum);
		if (SUCCEEDED(hr))
		{
			IBaseFilter *pFilter = NULL;
			while (S_OK == pEnum->Next(1, &pFilter, NULL))
			{
				mpGraph->RemoveFilter(pFilter);
				pEnum->Reset();
				pFilter->Release();
			}
			pEnum->Release();
		}
	}
	mGraphValid = false;
}
HRESULT __fastcall DemolishGraphFilters(IGraphBuilder *pFilterGraph)
{
HRESULT hr = S_OK;
IEnumFilters* pEnum = NULL;

    if(!pFilterGraph)
        return E_POINTER;

    hr = pFilterGraph->EnumFilters(&pEnum);
    if(SUCCEEDED(hr))
    {
		IBaseFilter *pFilter=NULL;
        while(S_OK == pEnum->Next(1, &pFilter, NULL))
        {
            RemoveAndDeleteFilter(pFilterGraph, &pFilter);
            pEnum->Reset(); //it is need because enumerator go confused 
                            //after any "RemoveAndDeleteFilter" call
        }
        pEnum->Release();
    }
    return hr;
}
Exemple #17
0
//查找FilterGraph上某一个接口,不管在Filter还是Pin上,找到即返回
BOOL FindInterface(IGraphBuilder* pGraphBuilder, REFGUID iid, void** ppUnk)
{
	if(!pGraphBuilder || !ppUnk)
		return FALSE;

	HRESULT hr = E_FAIL;
	IEnumFilters* pEnumFilter = NULL;
	if(FAILED(pGraphBuilder->QueryInterface(&pEnumFilter)))
		return FALSE;

	BOOL bRet = FALSE;
	IBaseFilter* pFilter = NULL;
	while(S_OK == pEnumFilter->Next(1,&pFilter,NULL))
	{
		hr = pFilter->QueryInterface(iid,ppUnk);
		if(SUCCEEDED(hr))
		{
			bRet = TRUE;
			pFilter->Release();
			break;
		}
		else
		{
			bRet = FindPinInterface(pFilter,iid,ppUnk);
			if(bRet)
			{
				pFilter->Release();
				break;
			}
		}

		pFilter->Release();
	}

	pEnumFilter->Release();

	return FALSE;
}
Exemple #18
0
void cleanUp(IGraphBuilder** pGraphBuilder)
{
	IMediaControl* pMediaControl;

	vector<IBaseFilter*> filts;
	IEnumFilters* filterList;
	IBaseFilter* filt;

	_RPT0(_CRT_WARN,"Releasing... \n");
	if (SUCCEEDED((*pGraphBuilder)->EnumFilters(&filterList)))
	{
		filterList->Reset();
		while (filterList->Next(1, &filt, NULL) == S_OK) filts.add(filt);
		filterList->Release();
	}
	
	for (int i=0;i<filts.size();i++)
	{
#ifdef _DEBUG
		FILTER_INFO info;
		filts.at(i)->QueryFilterInfo(&info);
		char str[100];
		WideCharToMultiByte( CP_ACP, 0, info.achName, -1, str, 100, NULL, NULL );
		_RPT1(_CRT_WARN,"Releasing: %s\n",str);
#endif
		(*pGraphBuilder)->RemoveFilter(filts.at(i));
		filts.at(i)->Release();
	}
	(*pGraphBuilder)->Release();
	(*pGraphBuilder) = NULL;

	for (int i=0;i<newlist.size();i++) if (newlist.at(i)) delete [] newlist.at(i);
	newlist.clear();

	_CrtDumpMemoryLeaks();
}
Exemple #19
0
void 
recChannel_t::refresh_channel(bool all)
{
     __CONTEXT("recChannel_t::refresh_channel");
    pControl->Stop();
#ifdef _WINDOWS
    if (fControl)
    {
        fControl->CWnd::ShowWindow(SW_HIDE);
    }
#endif
	
	if (pSource!=NULL)
    {
		pGraph->RemoveFilter(pSource);
		camInfo->setFree(true);
	}
	
	// Enumerate the filters in the graph.
	IEnumFilters *pEnum = NULL;
	int hr = pGraph->EnumFilters(&pEnum);
	if (SUCCEEDED(hr))
	{
		IBaseFilter *pFilter = NULL;
		while (S_OK == pEnum->Next(1, &pFilter, NULL))
		{
			CLSID filterId;
			pFilter->GetClassID(&filterId);
			if(filterId == CLSID_VideoRenderer ||
			   filterId == CLSID_VideoMixingRenderer)
			{
				IVideoWindow *pWindowInfo = NULL;
				pFilter->QueryInterface(IID_IVideoWindow, (void **)&pWindowInfo);
				pWindowInfo->get_Height(&windowInfo.heigth);
				pWindowInfo->get_Left(&windowInfo.left);
				pWindowInfo->get_Top(&windowInfo.top);
				pWindowInfo->get_Width(&windowInfo.width);
           		pWindowInfo->put_AutoShow(OAFALSE);
			    pWindowInfo->put_Visible(OAFALSE);
        	   	if (all)
				{
                   	pGraph->RemoveFilter(pFilter);
					pFilter->Release();
					pEnum->Reset();
					pWindowInfo->Release();
				}

			}else{
                
                pGraph->RemoveFilter(pFilter);    
                pFilter->Release();
                pEnum->Reset();
			}
		}
		pEnum->Release();
	}
	if (all)
	{
		pGraph->Release();
		hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, 
                          IID_IGraphBuilder, (void **)&pGraph);
		errorCheck(hr);
	}
	hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
	errorCheck(hr);

}
// Open multimedia stream.
BOOL CDShow::Open(ZString& pFileName, IDirectDraw7 *pDD)
{
	// Multimedia stream pointer
	IAMMultiMediaStream *pAMStream;
	IGraphBuilder *pGb; // 7/10 #110
	IEnumFilters *pEfs;
	IBasicAudio *pBa;

    
	//7/29/09 we can now do stuff while the video plays
	CoInitializeEx(NULL,COINIT_MULTITHREADED); 
	

    // Create Multimedia stream object
	if (FAILED(CoCreateInstance(CLSID_AMMultiMediaStream, NULL, CLSCTX_INPROC_SERVER,
				 IID_IAMMultiMediaStream, (void **)&pAMStream)))
	{		
		// Return FALSE to let caller know we failed.	
		return FALSE; 
	}
    
	// Initialize Multimedia stream object
	if (FAILED(pAMStream->Initialize(STREAMTYPE_READ, 0, NULL)))
	{	
		// There are alot of possiblities to fail.....		
		return FALSE; 
	}

    // Add primary video stream.
	if (FAILED((pAMStream->AddMediaStream(pDD, &MSPID_PrimaryVideo, 0, NULL))))
	{		
		return FALSE; 
	}

    // Add default sound render to primary video stream,
	// so sound will be played back automatically.
	if (FAILED(pAMStream->AddMediaStream(NULL, &MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL)))
	{
		// Return FALSE to let caller know we failed.		
		return FALSE; 
	}

    // Convert filename to UNICODE.
	// Notice the safe way to get the actual size of a string.
	WCHAR wPath[MAX_PATH];
    MultiByteToWideChar(CP_ACP, 0, pFileName, -1, wPath, sizeof(wPath)/sizeof(wPath[0]));   
    
	// Build the filter graph for our multimedia stream.
	if (FAILED((pAMStream->OpenFile(wPath, 0))))
	{	
		// Return FALSE to let caller know we failed.		
		return FALSE; 
	}

	//7/10 #110
	FILTER_INFO FilterInfo;
	pAMStream->GetFilterGraph(&pGb);
	pGb->EnumFilters(&pEfs);

    IBaseFilter *pFilter;
	unsigned long cFetched;
    while(pEfs->Next(1, &pFilter, &cFetched) == S_OK) {
		FILTER_INFO FilterInfo;
		pFilter->QueryFilterInfo(&FilterInfo);
		char szName[MAX_FILTER_NAME];
		long cch = WideCharToMultiByte(CP_ACP,0,FilterInfo.achName,MAX_FILTER_NAME,szName,MAX_FILTER_NAME,0,0);
		if (cch > 0) {
			if (!strcmp("WMAudio Decoder DMO",szName)) {
				// set the volume to music level
				FilterInfo.pGraph->QueryInterface(IID_IBasicAudio,(void**)&pBa);
				HKEY hKey;
				DWORD dwResult = 0;
				if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, ALLEGIANCE_REGISTRY_KEY_ROOT,0, KEY_READ, &hKey)) {
					DWORD dwSize = sizeof(dwResult);
					DWORD dwType = REG_DWORD;
					::RegQueryValueEx(hKey, "MusicGain", NULL, &dwType, (BYTE*)&dwResult, &dwSize);
					::RegCloseKey(hKey);
					if (dwType != REG_DWORD)
						dwResult = 0;
				}
				long vol = (dwResult * -1) * 100;
				if (vol < -5000) {
					vol = -10000;
				}
				pBa->put_Volume(vol);
				pBa->Release();
			}
           if (FilterInfo.pGraph != NULL)
               FilterInfo.pGraph->Release();
           pFilter->Release();
		}
	}
	pEfs->Release();
	pGb->Release();

    // Assign member to temperary stream pointer.
	m_pMMStream = pAMStream;
	
	// Add a reference to the file
	pAMStream->AddRef();
    	
	// Get media stream interface
	if (FAILED(m_pMMStream->GetMediaStream(MSPID_PrimaryVideo, &m_pPrimaryVideoStream)))
	{	
		return FALSE;
	}
	
	// Get DirectDraw media stream interface
	if (FAILED(m_pPrimaryVideoStream->QueryInterface(IID_IDirectDrawMediaStream,(void **)&m_pDDStream)))
	{				
		return FALSE;
	}	
	
	// Create stream sample
	if (FAILED(m_pDDStream->CreateSample(NULL,NULL,0,&m_pSample)))
	{			
		return FALSE;
	}	
	
	// Get DirectDraw surface interface from Sample.
	if (FAILED(m_pSample->GetSurface(&m_pDDSurface,&m_rSrcRect)))
	{			

		return FALSE;
	}	
	
	// Get DirectDraw surface7 interface
	if (FAILED(m_pDDSurface->QueryInterface(IID_IDirectDrawSurface7,(void**)&m_pDDSurface7)))
	{		
		return FALSE;
	}	
	
	// Ok. Media is open now.
	m_bMediaOpen=TRUE;
	
	// If we are here, everything turned out ok. Return TRUE.
	return TRUE;
}
Exemple #21
0
HRESULT FindRenderer(IGraphBuilder *pGB, const GUID *mediatype, IBaseFilter **ppFilter)
{
    HRESULT hr;
    IEnumFilters *pEnum = NULL;
    IBaseFilter *pFilter = NULL;
    IPin *pPin;
    ULONG ulFetched, ulInPins, ulOutPins;
    BOOL bFound=FALSE;

    // Verify graph builder interface
    if (!pGB)
        return E_NOINTERFACE;

    // Verify that a media type was passed
    if (!mediatype)
        return E_POINTER;

    // Clear the filter pointer in case there is no match
    if (ppFilter)
        *ppFilter = NULL;

    // Get filter enumerator
    hr = pGB->EnumFilters(&pEnum);
    if (FAILED(hr))
        return hr;

    pEnum->Reset();

    // Enumerate all filters in the graph
    while(!bFound && (pEnum->Next(1, &pFilter, &ulFetched) == S_OK))
    {
#ifdef DEBUG
        // Read filter name for debugging purposes
        FILTER_INFO FilterInfo;
        TCHAR szName[256];

        hr = pFilter->QueryFilterInfo(&FilterInfo);
        if (SUCCEEDED(hr))
        {
            // Show filter name in debugger
#ifdef UNICODE
            lstrcpy(szName, FilterInfo.achName);
#else
            WideCharToMultiByte(CP_ACP, 0, FilterInfo.achName, -1, szName, 256, 0, 0);
#endif
            FilterInfo.pGraph->Release();
        }
#endif

        // Find a filter with one input and no output pins
        hr = CountFilterPins(pFilter, &ulInPins, &ulOutPins);
        if (FAILED(hr))
            break;

        if ((ulInPins == 1) && (ulOutPins == 0))
        {
            // Get the first pin on the filter
            pPin=0;
            pPin = GetInPin(pFilter, 0);

            // Read this pin's major media type
            AM_MEDIA_TYPE type= {0};
            hr = pPin->ConnectionMediaType(&type);
            if (FAILED(hr))
                break;

            // Is this pin's media type the requested type?
            // If so, then this is the renderer for which we are searching.
            // Copy the interface pointer and return.
            if (type.majortype == *mediatype)
            {
                // Found our filter
                *ppFilter = pFilter;
                bFound = TRUE;;
            }
            // This is not the renderer, so release the interface.
            else
                pFilter->Release();

            // Delete memory allocated by ConnectionMediaType()
            FreeMediaType(type);
        }
        else
        {
            // No match, so release the interface
            pFilter->Release();
        }
    }

    pEnum->Release();
    return hr;
}
Exemple #22
0
HRESULT 
recChannel_t::map(void)
{

    __CONTEXT("recChannel_t::map");
       
	int hr = 0;
	IBaseFilter * pFilter = NULL;
	IBaseFilter * pFilter2 = NULL;
	IPin * pVideoInputPin = NULL;
	pControl->StopWhenReady();
	
	mapping = true;
	pOutput = camInfo->output;


	if (remaped){
		
	    //refresh Codec BW before creation
        pSender->sampleGrabber->BWController->refreshBW();
		pSender->rebind();
	
		hr = pGraph->Render(pOutput);
		{
				
				// Enumerate the filters in the graph.
				IEnumFilters *pEnum = NULL;
				int hr = pGraph->EnumFilters(&pEnum);
				if (SUCCEEDED(hr))
				{
					IBaseFilter *pFilter = NULL;
					pEnum->Reset();
					while (S_OK == pEnum->Next(1, &pFilter, NULL))
					{
						CLSID filterId;
						pFilter->GetClassID(&filterId);
						if(filterId == CLSID_AviSplitter)
			   			{

							IEnumPins * pEnumpin = NULL;
								
							hr = pFilter->EnumPins(&pEnumpin);
							if (!hr)
							{
								IPin * pPin = NULL;
								pEnumpin->Reset();
								while (pEnumpin->Next(1, &pPin, 0) == S_OK)
								{
									bool break_loop = false;
									AM_MEDIA_TYPE * mediaType;
									IEnumMediaTypes * enumMedia = NULL;
						
									hr = pPin->EnumMediaTypes(&enumMedia);
									if(!hr)
									{
										enumMedia->Reset();
										while(enumMedia->Next(1,&mediaType , NULL) == S_OK)
										{
											if (mediaType->majortype == MEDIATYPE_Audio)
											{
												pPin->Disconnect();
												pGraph->Render(pPin);
												pPin->Release();
												break_loop = true;
												break;
											}
										}
										enumMedia->Release();
										if (break_loop)
											break;
									}
								}
								pEnumpin->Release();
							}
							
						}
						pFilter->Release();
					}
					pEnum->Release();
				}
		}

		pipeCreated = true;
	
		if (hr)
		{
				errorCheck(hr);
				NOTIFY("[recChannel_t::map]WARNING :: Can't render actual format, restoring default settings...\r\n");
				capInfo.heigth = DEFAULT_CAPTURE_HEIGTH;
				capInfo.width = DEFAULT_CAPTURE_WIDTH;
				ql_t<AM_MEDIA_TYPE *> auxFormats = camInfo->getFormatList();
				pSender->SetActualCodec(DEFAULT_CODEC_STR);
		}
	}

	if (fullScreen){
		set_full_screen(true);
	}else{
		hr = setWindowGeometry(windowInfo);
		errorCheck(hr);
	}

//	IVideoWindow *pWindowInfo = NULL;
//	hr = pGraph->QueryInterface(IID_IVideoWindow, (void **)&pWindowInfo);
//	if (!hr)
//	{
//		wchar_t wtext[100];
//		long windowStyle,windowStyleEx;
//		lText(wtext,title);
//		pWindowInfo->get_WindowStyle(&windowStyle);
//        pWindowInfo->get_WindowStyleEx(&windowStyleEx);
//		windowStyle = windowStyle + DEFAULT_WINDOW_PROPS - DEFAULT_WINDOW_NON_PROPS;
//		windowStyleEx = windowStyleEx - WS_EX_APPWINDOW;
//		pWindowInfo->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
//        pWindowInfo->put_WindowStyleEx(WS_EX_TOOLWINDOW);
//		pWindowInfo->put_Caption(wtext);
//
//#ifdef _WINDOWS
//        if (camInfo->getKind() == MEDIA)
//        {
//            fControl->setGeometry(windowInfo);
//
//        }
//#endif  	
////Ares daemon don't show local windows on
////recChannels
//#ifndef __ARES		
//		if (camInfo->getKind() != SHARED)
//		{
//			pWindowInfo->put_Visible(OATRUE);
//			pWindowInfo->put_AutoShow(OATRUE);
//		}
//		else
//		{
//#endif
//			pWindowInfo->put_Visible(OAFALSE);
//			pWindowInfo->put_AutoShow(OAFALSE);
//#ifndef __ARES
//		}
//#endif
//
//		pWindowInfo->Release();
//		setOwner();
//	}
	
	IMediaSeeking * pSeek = NULL;
    pGraph->QueryInterface(IID_IMediaSeeking,(void **)&pSeek);
    if (pSeek)pSeek->SetRate(1);
        
	pControl->Run();

	if (camInfo->getKind() == SHARED)
    {
		camInfo->RunSource();
    }
		
	if (camInfo->getKind() == TEST) 
    {        
        if (pSeek) pSeek->SetRate(0.5);
        looper->Run();
    }
	
    remaped = false;
	return hr;
}
Exemple #23
0
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");
		pOutputPin->Release();
		pInputPin->Release();
		return;
	}
	// Now we need to find the pins on our speedup filter.
	IPin *pFilterInputPin = NULL;
	IPin *pFilterOutputPin = NULL;
	IEnumPins *pEnumPins;
	res = pNewFilter->EnumPins(&pEnumPins);
	IPin *pCurPin;
	while (res=pEnumPins->Next(1, &pCurPin, NULL) == S_OK) {
		PIN_DIRECTION pinDir;
		res = pCurPin->QueryDirection(&pinDir);
		//assert(res == S_OK);
		if (pinDir == PINDIR_INPUT) {
			if (pFilterInputPin) {
				traceX("dx_audio_filter: multiple input pins on filter");
				goto bad;
			}
			pFilterInputPin = pCurPin;
			pFilterInputPin->AddRef();
		} else {
			if (pFilterOutputPin) {
				traceX("dx_audio_filter: multiple output pins on filter");
				goto bad;
			}
			pFilterOutputPin = pCurPin;
			pFilterOutputPin->AddRef();
		}
	}
	if (!pFilterInputPin) {
		traceX("dx_audio_filter: no input pin on filter");
		goto bad;
	}
	if (!pFilterOutputPin) {
		traceX("dx_audio_filter: no output pin on filter");
		goto bad;
	}
	// We have everything. Sever the old connection and insert the filter.
	res = m_graph_builder->Disconnect(pOutputPin);
	if (res) {
		traceX("dx_audio_filter: Severing old connection: error 0x%x", res);
		goto bad;
	}
	res = m_graph_builder->Disconnect(pInputPin);
	if (res) {
		traceX("dx_audio_filter: Severing old connection: error 0x%x", res);
		goto bad;
	}
	res = m_graph_builder->Connect(pOutputPin, pFilterInputPin);
	if (res) {
		traceX("dx_audio_filter: Creating filter input connection: error 0x%x", res);
		goto bad;
	}
	res = m_graph_builder->Connect(pFilterOutputPin, pInputPin);
	if (res) {
		traceX("dx_audio_filter: Creating filter output connection: error 0x%x", res);
		goto bad;
	}
	// Finally remember the interface to set speedup/slowdown, and register ourselves
	// in the global pool (so Amis can change our speed).
	res = pNewFilter->QueryInterface(IID_IVuppInterface, (void**) &m_audio_speedup);
	if (res != S_OK) {
		traceX("dx_audio_filter: filter does not provide IVuppInterface");
		goto bad;
	}
	set_rate(s_current_playback_rate);

bad:
	if (pOutputPin) pOutputPin->Release();
	if (pInputPin) pInputPin->Release();
	if (pFilterOutputPin) pFilterOutputPin->Release();
	if (pFilterInputPin) pFilterInputPin->Release();
	return;

}
Exemple #24
0
void COggSplitter::ShowPopupMenu()
{
	int				groupID[16];
	HMENU			groupMenu[16];
	int				cGroups = 0;
	MENUITEMINFO	myItem;

	int				i = 0;

	AM_MEDIA_TYPE*	pmt;
	DWORD			dwGroup;
	DWORD			dwFlags;
	wchar_t*		pwzCaption;

	HMENU	hPopup = CreatePopupMenu();

	while (Info(i, &pmt, &dwFlags, NULL, &dwGroup, &pwzCaption, NULL, NULL) == NOERROR)
	{
		// Is there already a submenu for this group?
		int	j = 0;
		while ((j < cGroups) && (groupID[j] != dwGroup)) j++;

		if (j == cGroups)	// There is still no submenu ..
		{
            char*	pMenuType;

			if (!pmt)
				pMenuType = GetLocString(sidTypeOther);
			else if (pmt->majortype == MEDIATYPE_Audio)
				pMenuType = GetLocString(sidTypeAudio);
			else if (pmt->majortype == MEDIATYPE_Text)
				pMenuType = GetLocString(sidTypeSubtitle);
			else if (pmt->majortype == MEDIATYPE_Video)
			{			
				if (pmt->pbFormat)
					pMenuType = GetLocString(sidTypeVideo);
				else
					pMenuType = GetLocString(sidTypeChapter);
			}

			groupMenu[j] = CreatePopupMenu();
			groupID[j] = dwGroup;
			
			memset(&myItem, 0, sizeof(myItem));
			myItem.cbSize = sizeof(myItem);
			myItem.fMask = MIIM_TYPE | MIIM_SUBMENU;
			myItem.fType = MFT_STRING;
			myItem.hSubMenu = groupMenu[j];
			myItem.dwTypeData = pMenuType;
			myItem.cch = strlen(pMenuType);
			InsertMenuItem(hPopup, -1, TRUE, &myItem);
			cGroups++;
		}
		
		char		szItemText[128];
		wchar_t*	pwzItemText = pwzCaption;
		
		// Let´s skip the first word if not chapter
		if (pmt && ((pmt->majortype != MEDIATYPE_Video) || pmt->pbFormat))
		{
			pwzItemText = wcsstr(pwzItemText, L" ");
			pwzItemText++;
		}

		wsprintf(szItemText, "%S", pwzItemText);

		memset(&myItem, 0, sizeof(myItem));
		myItem.cbSize = sizeof(myItem);
		myItem.fMask = MIIM_TYPE | MIIM_ID | MIIM_STATE;
		myItem.fType = MFT_STRING | MFT_RADIOCHECK;
		myItem.fState = MFS_ENABLED;
		if (dwFlags == AMSTREAMSELECTINFO_ENABLED)
			myItem.fState |= MFS_CHECKED;
		myItem.wID = i;
		myItem.dwTypeData = szItemText;
		myItem.cch = strlen(myItem.dwTypeData);

		InsertMenuItem(groupMenu[j], -1, TRUE, &myItem);

		if (pmt)
			DeleteMediaType(pmt);
		CoTaskMemFree(pwzCaption);
		i++;
	}

	HMENU	hPropMenu = NULL;
	char	szName[MAX_FILTER_NAME];
	
	// If we are in the graph find all filters with property pages
	if (m_pGraph)
	{
		hPropMenu = CreatePopupMenu();

		// Insert the separator
		memset(&myItem, 0, sizeof(myItem));
		myItem.cbSize = sizeof(myItem);
		myItem.fMask = MIIM_TYPE;
		myItem.fType = MFT_SEPARATOR;
		InsertMenuItem(hPopup, -1, TRUE, &myItem);

		// Insert the properties item
		memset(&myItem, 0, sizeof(myItem));
		myItem.cbSize = sizeof(myItem);
		myItem.fMask = MIIM_TYPE | MIIM_SUBMENU;
		myItem.fType = MFT_STRING;
		myItem.hSubMenu = hPropMenu;
		myItem.dwTypeData = GetLocString(sidProperties);
		myItem.cch = strlen(myItem.dwTypeData);
		InsertMenuItem(hPopup, -1, TRUE, &myItem);

		IEnumFilters*			pEnum;
		IBaseFilter*			pFilter;
		ISpecifyPropertyPages*	pSPP;
		ULONG					cFetched;
		DWORD					dwID = ID_MENUITEM_PROPERTIES;

		m_pGraph->EnumFilters(&pEnum);

		do
		{
			if (FAILED(pEnum->Next(1, &pFilter, &cFetched)))
				cFetched = 0;

			if (cFetched)
			{
				if (SUCCEEDED(pFilter->QueryInterface(IID_ISpecifyPropertyPages,
														(void**)&pSPP)))
				{
					pSPP->Release();

					FILTER_INFO	Info;

					pFilter->QueryFilterInfo(&Info);
					wsprintf(szName, "%S", Info.achName);
					Info.pGraph->Release();

					memset(&myItem, 0, sizeof(myItem));
					myItem.cbSize = sizeof(myItem);
					myItem.fMask = MIIM_TYPE | MIIM_ID;
					myItem.fType = MFT_STRING;
					myItem.wID = dwID;
					myItem.dwTypeData = szName;
					myItem.cch = strlen(myItem.dwTypeData);
					InsertMenuItem(hPropMenu, -1, TRUE, &myItem);
					dwID++;
				}
				pFilter->Release();
			}
		} while (cFetched);
		pEnum->Release();
	}

	POINT	ptCursorPos;
	DWORD	dwSelection;

	GetCursorPos(&ptCursorPos);
	SetForegroundWindow(m_hTrayWnd);
	PostMessage(m_hTrayWnd, WM_NULL, 0, 0); 
	dwSelection = TrackPopupMenu(hPopup, TPM_NONOTIFY | TPM_RETURNCMD,
					ptCursorPos.x, ptCursorPos.y, 0, m_hTrayWnd, NULL);

	if (dwSelection <  ID_MENUITEM_PROPERTIES)
	{
		Enable(dwSelection, AMSTREAMSELECTENABLE_ENABLE);
		return;
	}

	GetMenuString(hPropMenu, dwSelection, szName, MAX_FILTER_NAME, MF_BYCOMMAND);
	if (m_pGraph)
	{
		wchar_t					wszName[MAX_FILTER_NAME];
		IBaseFilter*			pFilter;
		ISpecifyPropertyPages*	pSPP;
		
		wsprintfW(wszName, L"%s", szName);
		if (SUCCEEDED(m_pGraph->FindFilterByName(wszName, &pFilter)))
		{
			if (SUCCEEDED(pFilter->QueryInterface(IID_ISpecifyPropertyPages,
													(void**)&pSPP)))
			{
				IUnknown*	pFilterUnk;
				pFilter->QueryInterface(IID_IUnknown, (void **)&pFilterUnk);
				
				CAUUID caGUID;
				pSPP->GetPages(&caGUID);
				pSPP->Release();
			    OleCreatePropertyFrame(m_hTrayWnd, 0, 0, wszName, 1, &pFilterUnk,
										caGUID.cElems, caGUID.pElems, 0, 0, NULL);
				pFilterUnk->Release();
				CoTaskMemFree(caGUID.pElems);
			}
			pFilter->Release();
		}
	}

	DestroyMenu(hPopup);
}
Exemple #25
0
void WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel)
{
    if( !pGraph )
    {
        return;
    }

    IEnumFilters *pFilters;

    DbgLog((LOG_TRACE,dwLevel,TEXT("DumpGraph [%x]"), pGraph));

    if (FAILED(pGraph->EnumFilters(&pFilters))) {
	DbgLog((LOG_TRACE,dwLevel,TEXT("EnumFilters failed!")));
    }

    IBaseFilter *pFilter;
    ULONG	n;
    while (pFilters->Next(1, &pFilter, &n) == S_OK) {
	FILTER_INFO	info;

	if (FAILED(pFilter->QueryFilterInfo(&info))) {
	    DbgLog((LOG_TRACE,dwLevel,TEXT("    Filter [%x]  -- failed QueryFilterInfo"), pFilter));
	} else {
	    QueryFilterInfoReleaseGraph(info);

	    // !!! should QueryVendorInfo here!
	
	    DbgLog((LOG_TRACE,dwLevel,TEXT("    Filter [%x]  '%ls'"), pFilter, info.achName));

	    IEnumPins *pins;

	    if (FAILED(pFilter->EnumPins(&pins))) {
		DbgLog((LOG_TRACE,dwLevel,TEXT("EnumPins failed!")));
	    } else {

		IPin *pPin;
		while (pins->Next(1, &pPin, &n) == S_OK) {
		    PIN_INFO	info;

		    if (FAILED(pPin->QueryPinInfo(&info))) {
			DbgLog((LOG_TRACE,dwLevel,TEXT("          Pin [%x]  -- failed QueryPinInfo"), pPin));
		    } else {
			QueryPinInfoReleaseFilter(info);

			IPin *pPinConnected = NULL;

			HRESULT hr = pPin->ConnectedTo(&pPinConnected);

			if (pPinConnected) {
			    DbgLog((LOG_TRACE,dwLevel,TEXT("          Pin [%x]  '%ls' [%sput]")
							   TEXT("  Connected to pin [%x]"),
				    pPin, info.achName,
				    info.dir == PINDIR_INPUT ? TEXT("In") : TEXT("Out"),
				    pPinConnected));

			    pPinConnected->Release();

			    // perhaps we should really dump the type both ways as a sanity
			    // check?
			    if (info.dir == PINDIR_OUTPUT) {
				AM_MEDIA_TYPE mt;

				hr = pPin->ConnectionMediaType(&mt);

				if (SUCCEEDED(hr)) {
				    DisplayType(TEXT("Connection type"), &mt);

				    FreeMediaType(mt);
				}
			    }
			} else {
			    DbgLog((LOG_TRACE,dwLevel,
				    TEXT("          Pin [%x]  '%ls' [%sput]"),
				    pPin, info.achName,
				    info.dir == PINDIR_INPUT ? TEXT("In") : TEXT("Out")));

			}
		    }

		    pPin->Release();

		}

		pins->Release();
	    }

	}
	
	pFilter->Release();
    }

    pFilters->Release();

}
Exemple #26
0
bool CPlaylist::Load()
{
    IGraphBuilder * pGraph       = NULL;
    IAMPlayList   * pPlaylist    = NULL;
    HRESULT         hr;
    bool            bResult;

    if (NULL != m_pList || true == m_bTransient)
    {
        return true;
    }

    //
    // Make sure that this is one of our playlist read the last played element
    //
    bResult = LoadParam();

    hr = CoCreateInstance(CLSID_FilterGraph,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IGraphBuilder,
                          (void**) &pGraph);

    if (SUCCEEDED(hr))
    {
        hr = pGraph->RenderFile(m_pszPath, NULL);
    }

    if (SUCCEEDED(hr))
    {
        IEnumFilters * pEnum   = NULL;
        IBaseFilter  * pFilter = NULL;

        hr = pGraph->EnumFilters(&pEnum);

        if (pEnum)
        {
            while (!pPlaylist && pEnum->Next(1, &pFilter, NULL) == S_OK)
            {
                hr = pFilter->QueryInterface(IID_IAMPlayList, (void**)&pPlaylist);
                pFilter->Release();
            }

            if (!pPlaylist)
            {
                hr = E_NOINTERFACE;
            }

            pEnum->Release();
        }
    }

    if (SUCCEEDED(hr))
    {
        DWORD             dwCount;
        IAMPlayListItem * pItem   = NULL;

        if(pPlaylist)
            hr = pPlaylist->GetItemCount(&dwCount);
        else
            hr = E_FAIL;

        if (SUCCEEDED(hr))
        {
            for (DWORD i = 0; i < dwCount; i++)
            {
                hr = pPlaylist->GetItem(i, &pItem);

                if (SUCCEEDED(hr))
                {
                    BSTR pszSource = NULL;

                    hr = pItem->GetSourceURL(0, &pszSource);

                    if (SUCCEEDED(hr))
                    {
                        InsertTrack(i, pszSource);
                    }

                    pItem->Release();
                }
            }
        }
    }

    if (pPlaylist)
    {
        pPlaylist->Release();
    }

    if (pGraph)
    {
        pGraph->Release();
    }

    if (SUCCEEDED(hr))
    {
        return true;
    }
    else
    {
        return false;
    }
}