Exemple #1
0
long VideoCapture::ShowPropertyPage(HWND hwndParent)
{

	HRESULT hr;
	ISpecifyPropertyPages *pSpecify=0;
	CAUUID cauuid;

	hr = pSource->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pSpecify);

	if (SUCCEEDED(hr)) 
	{
		do 
		{
			hr = pSpecify->GetPages(&cauuid);

			hr = OleCreatePropertyFrame(hwndParent, 0, 0, NULL, 1,
				(IUnknown **)&pSource, cauuid.cElems,
				(GUID *)cauuid.pElems, 0, 0, NULL);

			CoTaskMemFree(cauuid.pElems);
		} while(0);
	}

	// Release interfaces
	if (pSpecify)
		pSpecify->Release();

	return hr;
}
HRESULT videoInputCamera::ShowFilterPropertyPages(IBaseFilter *pFilter){

	ISpecifyPropertyPages *pProp;
	HRESULT hr = pFilter->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pProp);
	if (SUCCEEDED(hr))
	{
		// Get the filter's name and IUnknown pointer.
		FILTER_INFO FilterInfo;
		hr = pFilter->QueryFilterInfo(&FilterInfo);
		IUnknown *pFilterUnk;
		pFilter->QueryInterface(IID_IUnknown, (void **)&pFilterUnk);

		// Show the page.
		CAUUID caGUID;
		pProp->GetPages(&caGUID);
		pProp->Release();
		OleCreatePropertyFrame(
			NULL,                   // Parent window
			0, 0,                   // Reserved
			FilterInfo.achName,     // Caption for the dialog box
			1,                      // Number of objects (just the filter)
			&pFilterUnk,            // Array of object pointers.
			caGUID.cElems,          // Number of property pages
			caGUID.pElems,          // Array of property page CLSIDs
			0,                      // Locale identifier
			0, NULL                 // Reserved
			);

		// Clean up.
		if(pFilterUnk)pFilterUnk->Release();
		if(FilterInfo.pGraph)FilterInfo.pGraph->Release();
		CoTaskMemFree(caGUID.pElems);
	}
	return hr;
}
Exemple #3
0
gboolean
gst_dshow_show_propertypage (IBaseFilter * base_filter)
{
  gboolean ret = FALSE;
  ISpecifyPropertyPages *pProp = NULL;
  HRESULT hres =
      base_filter->QueryInterface (IID_ISpecifyPropertyPages, (void **) &pProp);
  if (SUCCEEDED (hres)) {
    /* Get the filter's name and IUnknown pointer. */
    FILTER_INFO FilterInfo;
    CAUUID caGUID;
    IUnknown *pFilterUnk = NULL;
    hres = base_filter->QueryFilterInfo (&FilterInfo);
    base_filter->QueryInterface (IID_IUnknown, (void **) &pFilterUnk);

    /* Show the page. */
    pProp->GetPages (&caGUID);
    pProp->Release ();
    OleCreatePropertyFrame (GetDesktopWindow (), 0, 0, FilterInfo.achName,
        1, &pFilterUnk, caGUID.cElems, caGUID.pElems, 0, 0, NULL);

    pFilterUnk->Release ();
    FilterInfo.pGraph->Release ();
    CoTaskMemFree (caGUID.pElems);
  }
  return ret;
}
Exemple #4
0
void CFilterProp::ShowProperties()
{
	if ( !pGB ) return;

    HRESULT hr;
    IBaseFilter *pFilter = NULL;
    TCHAR szNameToFind[128];
    ISpecifyPropertyPages *pSpecify;

    // Read the current filter name from the list box
    int nCurSel = m_ListFilters.GetCurSel();
    m_ListFilters.GetText(nCurSel, szNameToFind);

    // Read the current list box name and find it in the graph
    pFilter = FindFilterFromName(szNameToFind);
    if (!pFilter)
        return;

    // Discover if this filter contains a property page
    hr = pFilter->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pSpecify);
    if (SUCCEEDED(hr)) 
    {
        do 
        {
            FILTER_INFO FilterInfo;
            hr = pFilter->QueryFilterInfo(&FilterInfo);
            if (FAILED(hr))
                break;

            CAUUID caGUID;
            hr = pSpecify->GetPages(&caGUID);
            if (FAILED(hr))
                break;

            pSpecify->Release();
        
            // Display the filter's property page
            OleCreatePropertyFrame(
                m_hWnd,                 // Parent window
                0,                      // x (Reserved)
                0,                      // y (Reserved)
                FilterInfo.achName,     // Caption for the dialog box
                1,                      // Number of filters
                (IUnknown **)&pFilter,  // Pointer to the filter 
                caGUID.cElems,          // Number of property pages
                caGUID.pElems,          // Pointer to property page CLSIDs
                0,                      // Locale identifier
                0,                      // Reserved
                NULL                    // Reserved
            );
            CoTaskMemFree(caGUID.pElems);
            FilterInfo.pGraph->Release(); 

        } while(0);
    }

    pFilter->Release();

}
//Вызывает окно свойств фильтра lpwFGFilName
//Если параметр bCheck равен TRUE, функция лишь проверит наличие у фильтра окна свойств,
//и вернет значение больше нуля, если таковое окно имеется
//Перед вызовом этой функции желательно вызвать UpdateFGFiltersArray()
//В случае ошибки/отсутствия у фильтра окна свойств функция вернет значение меньше нуля
int CDirectShow::FGFiltersPropertyPages(LPCWSTR lpwFGFilName, BOOL bCheck)
{
	if (!m_lFGFilCount) return -1;
	ISpecifyPropertyPages *pSpecifyPP = NULL;
	FILTER_INFO FI = { 0 };
	for (m_lCounter = 0; m_lCounter < m_lFGFilCount; m_lCounter++)
	{
		if (m_pFGBaseFilter[m_lCounter] == NULL) return -1;
		if (FAILED(m_pFGBaseFilter[m_lCounter]->QueryFilterInfo(&FI)))
		{
			if (m_lCounter >= (m_lFGFilCount - 1))
				return -1; else continue;
		}
		else
		{
			SR(FI.pGraph);
			if (_wcsicmp(FI.achName, lpwFGFilName) == 0)
			{
				if (FAILED(m_pFGBaseFilter[m_lCounter]->QueryInterface(IID_ISpecifyPropertyPages,
					(LPVOID *)&pSpecifyPP)))
				{
					return -1;
				}
				else
				{
					if (bCheck)
					{
						pSpecifyPP->Release();
						return 1;
					}
					else
					{
						CAUUID caUUID = { 0 };
						pSpecifyPP->GetPages(&caUUID);
						pSpecifyPP->Release();
						HRESULT hRCPF = OleCreatePropertyFrame(m_hAppWnd, 0, 0, FI.achName, 1,
							(IUnknown **)&m_pFGBaseFilter[m_lCounter], caUUID.cElems, caUUID.pElems, 0, 0, NULL);
						CoTaskMemFree(caUUID.pElems);
						if (FAILED(hRCPF))
						{
							WCHAR lpwMsg[512] = { 0 };
							swprintf(lpwMsg, L"Unable to display '%s' properties.", FI.achName);
							DSErrorMsg(hRCPF, lpwMsg);
							return -1;
						}
						break;
					}
				}
			}
		}
	}
	return 0;
}
Exemple #6
0
HRESULT ShowFilterPropertyPage(IBaseFilter *pFilter, HWND hwndParent)
{
    HRESULT hr;
    ISpecifyPropertyPages *pSpecify=0;

    if (!pFilter)
        return E_NOINTERFACE;

    // Discover if this filter contains a property page
    hr = pFilter->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pSpecify);
    if (SUCCEEDED(hr))
    {
        do
        {
            FILTER_INFO FilterInfo;
            hr = pFilter->QueryFilterInfo(&FilterInfo);
            if (FAILED(hr))
                break;

            CAUUID caGUID;
            hr = pSpecify->GetPages(&caGUID);
            if (FAILED(hr))
                break;

            pSpecify->Release();

            // Display the filter's property page
            OleCreatePropertyFrame(
                hwndParent,             // Parent window
                0,                      // x (Reserved)
                0,                      // y (Reserved)
                FilterInfo.achName,     // Caption for the dialog box
                1,                      // Number of filters
                (IUnknown **)&pFilter,  // Pointer to the filter
                caGUID.cElems,          // Number of property pages
                caGUID.pElems,          // Pointer to property page CLSIDs
                0,                      // Locale identifier
                0,                      // Reserved
                NULL                    // Reserved
            );
            CoTaskMemFree(caGUID.pElems);
            FilterInfo.pGraph->Release();

        } while(0);
    }

    pFilter->Release();
    return hr;
}
extern "C" void config()
{
  ISpecifyPropertyPages *spp;
  CAUUID cauuid;
  HRESULT hr;

  CoInitialize(0);
  warning();
  hr = CoCreateInstance(CLSID_AC3Filter, NULL, CLSCTX_INPROC_SERVER, IID_ISpecifyPropertyPages, (LPVOID *)&spp);
  hr = spp->GetPages(&cauuid);
  hr = OleCreatePropertyFrame(0, 30, 30, NULL, 1, (IUnknown **)&spp, cauuid.cElems, (GUID *)cauuid.pElems, 0, 0, NULL);
  CoTaskMemFree(cauuid.pElems);
  spp->Release();
  CoUninitialize();
}
LONG CALLBACK CPlApplet(HWND hwndCPL, UINT uMsg, LPARAM lParam1, LPARAM lParam2) 
{ 
  ISpecifyPropertyPages *spp;
  CAUUID cauuid;
  HRESULT hr;
  LPCPLINFO lpCPlInfo; 
  
  switch (uMsg) 
  { 
  case CPL_INIT:      // first message, sent once 
    hinst = GetModuleHandle("ac3filter.ax");
    return TRUE; 
    
  case CPL_GETCOUNT:  // second message, sent once 
    return 1;
    break; 
    
  case CPL_INQUIRE:   // third message, sent once per application 
    lpCPlInfo = (LPCPLINFO) lParam2; 
    lpCPlInfo->lData = 0; 
    lpCPlInfo->idIcon = IDI_AC3FILTER;
    lpCPlInfo->idName = IDS_AC3FILTER;
    lpCPlInfo->idInfo = IDS_DESC;
    break; 
    
  case CPL_DBLCLK:    // application icon double-clicked 
    CoInitialize(0);
    warning();
    hr = CoCreateInstance(CLSID_AC3Filter, NULL, CLSCTX_INPROC_SERVER, IID_ISpecifyPropertyPages, (LPVOID *)&spp);
    hr = spp->GetPages(&cauuid);
    hr = OleCreatePropertyFrame(0, 30, 30, NULL, 1, (IUnknown **)&spp, cauuid.cElems, (GUID *)cauuid.pElems, 0, 0, NULL);
    CoTaskMemFree(cauuid.pElems);
    spp->Release();
    CoUninitialize();
    break; 
    
  case CPL_STOP:      // sent once per application before CPL_EXIT 
    break; 
    
  case CPL_EXIT:      // sent once before FreeLibrary is called 
    break; 
    
  default: 
    break; 
  } 
  return 0; 
} 
static void OpenPropertyPages(HWND hwnd, IUnknown *propertyObject)
{
	if (!propertyObject)
		return;

	ComQIPtr<ISpecifyPropertyPages> pages(propertyObject);
	CAUUID cauuid;

	if (pages != NULL) {
		if (SUCCEEDED(pages->GetPages(&cauuid)) && cauuid.cElems) {
			OleCreatePropertyFrame(hwnd, 0, 0, NULL, 1,
					(LPUNKNOWN*)&propertyObject,
					cauuid.cElems, cauuid.pElems,
					0, 0, NULL);
			CoTaskMemFree(cauuid.pElems);
		}
	}
}
Exemple #10
0
HRESULT CBaseDSPropPage::ShowPropPageDialog(IBaseFilter *pFilter, HWND hwndOwner)
{
  CheckPointer(pFilter, E_INVALIDARG);
  CoInitialize(nullptr);

  // Get PropertyPages interface
  ISpecifyPropertyPages *pProp = nullptr;
  HRESULT hr = pFilter->QueryInterface<ISpecifyPropertyPages>(&pProp);
  if (SUCCEEDED(hr) && pProp) {
    // Get the filter's name and IUnknown pointer.
    FILTER_INFO FilterInfo;
    hr = pFilter->QueryFilterInfo(&FilterInfo);
    // We don't need the graph, so don't sit on a ref to it
    if (FilterInfo.pGraph)
      FilterInfo.pGraph->Release();

    IUnknown *pFilterUnk = nullptr;
    pFilter->QueryInterface<IUnknown>(&pFilterUnk);

    // Show the page.
    CAUUID caGUID;
    pProp->GetPages(&caGUID);
    pProp->Release();
    hr = OleCreatePropertyFrame(
        hwndOwner,              // Parent window
        0, 0,                   // Reserved
        FilterInfo.achName,     // Caption for the dialog box
        1,                      // Number of objects (just the filter)
        &pFilterUnk,            // Array of object pointers.
        caGUID.cElems,          // Number of property pages
        caGUID.pElems,          // Array of property page CLSIDs
        0,                      // Locale identifier
        0, nullptr              // Reserved
    );

    // Clean up.
    pFilterUnk->Release();
    CoTaskMemFree(caGUID.pElems);

    hr = S_OK;
  }
  CoUninitialize();
  return hr;
}
Exemple #11
0
/**
 * Pops up a user dialog allowing them to adjust properties for the given filter, if possible.
 */
void
dshow_show_filter_properties(IBaseFilter *device_filter, AVFormatContext *avctx) {
    ISpecifyPropertyPages *property_pages = NULL;
    IUnknown *device_filter_iunknown = NULL;
    HRESULT hr;
    FILTER_INFO filter_info = {0}; /* a warning on this line is false positive GCC bug 53119 AFAICT */
    CAUUID ca_guid = {0};

    hr  = IBaseFilter_QueryInterface(device_filter, &IID_ISpecifyPropertyPages, (void **)&property_pages);
    if (hr != S_OK) {
        av_log(avctx, AV_LOG_WARNING, "requested filter does not have a property page to show");
        goto end;
    }
    hr = IBaseFilter_QueryFilterInfo(device_filter, &filter_info);
    if (hr != S_OK) {
        goto fail;
    }
    hr = IBaseFilter_QueryInterface(device_filter, &IID_IUnknown, (void **)&device_filter_iunknown);
    if (hr != S_OK) {
        goto fail;
    }
    hr = ISpecifyPropertyPages_GetPages(property_pages, &ca_guid);
    if (hr != S_OK) {
        goto fail;
    }
    hr = OleCreatePropertyFrame(NULL, 0, 0, filter_info.achName, 1, &device_filter_iunknown, ca_guid.cElems,
        ca_guid.pElems, 0, 0, NULL);
    if (hr != S_OK) {
        goto fail;
    }
    goto end;
fail:
    av_log(avctx, AV_LOG_ERROR, "Failure showing property pages for filter");
end:
    if (property_pages)
        ISpecifyPropertyPages_Release(property_pages);
    if (device_filter_iunknown)
        IUnknown_Release(device_filter_iunknown);
    if (filter_info.pGraph)
        IFilterGraph_Release(filter_info.pGraph);
    if (ca_guid.pElems)
        CoTaskMemFree(ca_guid.pElems);
}
Exemple #12
0
void CInMin::Setup()
{
	ISpecifyPropertyPages *pSpec = NULL;
	IBaseFilter* pBF = m_VideoCaptureDevice.GetIBaseFilter();
	if( pBF )
	{
		if( pBF->QueryInterface(IID_ISpecifyPropertyPages,(void **)&pSpec) == S_OK )
		{
			if( pSpec )
			{
				CAUUID cauuid;
				pSpec->GetPages(&cauuid);
				OleCreatePropertyFrame(0, 30, 30, NULL, 1, (IUnknown **)&pBF, cauuid.cElems, (GUID *)cauuid.pElems, 0, 0, NULL);
				CoTaskMemFree(cauuid.pElems);
				pSpec->Release();
			}
		}
	}
}
Exemple #13
0
    BOOL ShowPropertyPage(void)
    {
        if (!m_pFilter) return FALSE;
        ISpecifyPropertyPages *pProp;
        if ((m_res = m_pFilter->QueryInterface(IID_ISpecifyPropertyPages, (LPVOID *) &pProp)) == S_OK)
        {
            // Get the filter's name and IUnknown pointer.
            FILTER_INFO FilterInfo;
            m_res = m_pFilter->QueryFilterInfo(&FilterInfo);
            IUnknown *pFilterUnk;
            m_res = m_pFilter->QueryInterface(IID_IUnknown, (LPVOID *) &pFilterUnk);
            CAUUID caGUID;
            pProp->GetPages(&caGUID);
            pProp->Release();

            __try
            {
                m_res = OleCreatePropertyFrame(
                    NULL,                   // Parent window
                    0, 0,                   // Reserved
                    FilterInfo.achName,     // Caption for the dialog box
                    1,                      // Number of objects (just the filter)
                    &pFilterUnk,            // Array of object pointers.
                    caGUID.cElems,          // Number of property pages
                    caGUID.pElems,          // Array of property page CLSIDs
                    0,                      // Locale identifier
                    0, NULL                 // Reserved
                    );
            }
            __except(EXCEPTION_EXECUTE_HANDLER)
            {
            }
            // Clean up.
            pFilterUnk->Release();
            /* FIXME: it crashes (broken example on msdn?) */
            //FilterInfo.pGraph->Release();
            CoTaskMemFree(caGUID.pElems);
        }
Exemple #14
0
BOOL CDShowCtrl::SetMuxerProp()
{
	if( this->muxer == NULL ){
		return FALSE;
	}
	BOOL ret = TRUE;

	ISpecifyPropertyPages *prop = NULL;
	HRESULT hr = this->muxer->QueryInterface(IID_ISpecifyPropertyPages, (void**)&prop);
    if (FAILED(hr)){
		return FALSE;
	}

	FILTER_INFO FilterInfo;
	this->muxer->QueryFilterInfo(&FilterInfo);

	CAUUID caGUID;
	prop->GetPages(&caGUID);

	OleCreatePropertyFrame(
		NULL,                   // 親ウィンドウ
		0,                      // x (予約済み)
		0,                      // y (予約済み)
		FilterInfo.achName,     // ダイアログ ボックスのキャプション
		1,                      // フィルタの数
		(IUnknown **)&this->muxer,  // フィルタへのポインタ
		caGUID.cElems,          // プロパティ ページの数
		caGUID.pElems,          // プロパティ ページ CLSID へのポインタ
		0,                      // ロケール識別子
		0,                      // 予約済み
		NULL                    // 予約済み
	);
	CoTaskMemFree(caGUID.pElems);

	SAFE_RELEASE(prop);

	return ret;
}
Exemple #15
0
bool CCameraDS::OpenCamera(int nCamID, bool bDisplayProperties, int nWidth, int nHeight)
{
	
	HRESULT hr = S_OK;

	CoInitialize(NULL);
	// Create the Filter Graph Manager.
	hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
							IID_IGraphBuilder, (void **)&m_pGraph);

	hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, 
							IID_IBaseFilter, (LPVOID *)&m_pSampleGrabberFilter);

	hr = m_pGraph->QueryInterface(IID_IMediaControl, (void **) &m_pMediaControl);
	hr = m_pGraph->QueryInterface(IID_IMediaEvent, (void **) &m_pMediaEvent);

	hr = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER,
							IID_IBaseFilter, (LPVOID*) &m_pNullFilter);


	hr = m_pGraph->AddFilter(m_pNullFilter, L"NullRenderer");
	
	hr = m_pSampleGrabberFilter->QueryInterface(IID_ISampleGrabber, (void**)&m_pSampleGrabber);

	AM_MEDIA_TYPE   mt;
	ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
	mt.majortype = MEDIATYPE_Video;
	mt.subtype = MEDIASUBTYPE_RGB24;
	mt.formattype = FORMAT_VideoInfo; 
	hr = m_pSampleGrabber->SetMediaType(&mt);
	MYFREEMEDIATYPE(mt);

	m_pGraph->AddFilter(m_pSampleGrabberFilter, L"Grabber");
 
	// Bind Device Filter.  We know the device because the id was passed in
	BindFilter(nCamID, &m_pDeviceFilter);
	m_pGraph->AddFilter(m_pDeviceFilter, NULL);

	CComPtr<IEnumPins> pEnum;
	m_pDeviceFilter->EnumPins(&pEnum);
 
	hr = pEnum->Reset();
	hr = pEnum->Next(1, &m_pCameraOutput, NULL); 

	pEnum = NULL; 
	m_pSampleGrabberFilter->EnumPins(&pEnum);
	pEnum->Reset();
	hr = pEnum->Next(1, &m_pGrabberInput, NULL); 

	pEnum = NULL;
	m_pSampleGrabberFilter->EnumPins(&pEnum);
	pEnum->Reset();
	pEnum->Skip(1);
	hr = pEnum->Next(1, &m_pGrabberOutput, NULL); 

	pEnum = NULL;
	m_pNullFilter->EnumPins(&pEnum);
	pEnum->Reset();
	hr = pEnum->Next(1, &m_pNullInputPin, NULL);

	//SetCrossBar();

	if (bDisplayProperties) 
	{
		CComPtr<ISpecifyPropertyPages> pPages;

		HRESULT hr = m_pCameraOutput->QueryInterface(IID_ISpecifyPropertyPages, (void**)&pPages);
		if (SUCCEEDED(hr))
		{
			PIN_INFO PinInfo;
			m_pCameraOutput->QueryPinInfo(&PinInfo);

			CAUUID caGUID;
			pPages->GetPages(&caGUID);

			OleCreatePropertyFrame(NULL, 0, 0,
						L"Property Sheet", 1,
						(IUnknown **)&(m_pCameraOutput.p),
						caGUID.cElems,
						caGUID.pElems,
						0, 0, NULL);
			CoTaskMemFree(caGUID.pElems);
			PinInfo.pFilter->Release();
		}
		pPages = NULL;
	}
	else 
	{
		//////////////////////////////////////////////////////////////////////////////
		// 加入由 lWidth和lHeight设置的摄像头的宽和高 的功能,默认320*240
		// by flymanbox @2009-01-24
		//////////////////////////////////////////////////////////////////////////////
	   int _Width = nWidth, _Height = nHeight;
	   IAMStreamConfig*   iconfig; 
	   iconfig = NULL;
	   hr = m_pCameraOutput->QueryInterface(IID_IAMStreamConfig,   (void**)&iconfig);   
      
	   AM_MEDIA_TYPE* pmt;    
	   if(iconfig->GetFormat(&pmt) !=S_OK) 
	   {
		  //printf("GetFormat Failed ! \n");
		  return   false;   
	   }
      
	   VIDEOINFOHEADER*   phead;
	   if ( pmt->formattype == FORMAT_VideoInfo)   
	   {   
			phead=( VIDEOINFOHEADER*)pmt->pbFormat;   
			phead->bmiHeader.biWidth = _Width;   
			phead->bmiHeader.biHeight = _Height;   
			if(( hr=iconfig->SetFormat(pmt)) != S_OK )   
			{
				return   false;
			}

		}   
		iconfig->Release();   
		iconfig=NULL;   
		MYFREEMEDIATYPE(*pmt);
	}

	hr = m_pGraph->Connect(m_pCameraOutput, m_pGrabberInput);
	hr = m_pGraph->Connect(m_pGrabberOutput, m_pNullInputPin);

	if (FAILED(hr))
	{
		switch(hr)
		{
			case VFW_S_NOPREVIEWPIN :
				break;
			case E_FAIL :
				break;
			case E_INVALIDARG :
				break;
			case E_POINTER :
				break;
		}
	}

	m_pSampleGrabber->SetBufferSamples(TRUE);
	m_pSampleGrabber->SetOneShot(TRUE);
    
	hr = m_pSampleGrabber->GetConnectedMediaType(&mt);
	if(FAILED(hr))
		return false;

	VIDEOINFOHEADER *videoHeader;
	videoHeader = reinterpret_cast<VIDEOINFOHEADER*>(mt.pbFormat);
	m_nWidth = videoHeader->bmiHeader.biWidth;
	m_nHeight = videoHeader->bmiHeader.biHeight;
	m_bConnected = true;

	pEnum = NULL;
	return true;
}
Exemple #16
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 #17
0
void CVisualPage::OnCamSetupButton()
{
  CComboBox * box = (CComboBox*)(GetDlgItem(IDC_RECORDING_COMBO));
  int i = box->GetCurSel();
  int n = box->GetLBTextLen(i);
  CString s;
  box->GetLBText(i, s.GetBuffer(n));
  PString setupDeviceName = s;
  s.ReleaseBuffer();

  if (setupDeviceName.IsEmpty()) return;
  if (setupDeviceName.Find("fake") == 0) return;
  if (setupDeviceName.Find("monitor") == 0) return;
  if (setupDeviceName.Find("zmonitor") == 0) return;
  PTRACE(4,"PVidDirectShow\tCurrent device: " << setupDeviceName);

  HRESULT hr;
  IBaseFilter * pFilter = NULL;
  IMoniker *pMoniker =NULL;
  ICreateDevEnum *pDevEnum =NULL;
  IEnumMoniker *pClassEnum = NULL;
  ULONG cFetched;

  ::CoInitialize(NULL);

  // Create the system device enumerator
  hr = CoCreateInstance (CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, IID_ICreateDevEnum, (void **) &pDevEnum);
  if (FAILED(hr)) { ::CoUninitialize(); return; }

  // Create an enumerator for the video capture devices
  hr = pDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pClassEnum, 0);
  if (FAILED(hr)) { ::CoUninitialize(); return; }

  if (pClassEnum == NULL) { ::CoUninitialize(); return; }

  PTRACE(4,"PVidDirectShow\tEntering device enumeration loop...");
  while (1)
  { // Get the next device
    hr = pClassEnum->Next(1, &pMoniker, &cFetched);
    if (hr != S_OK) { PTRACE(4, "PVidDirectShow\tGetInputDeviceNames() No more video capture device"); break; }

    // Get the property bag
    IPropertyBag *pPropBag;

    hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)(&pPropBag));
    if (FAILED(hr))
    { PTRACE(4,"PVidDerectShow\tBindToStorage failed, continue");
      pMoniker->Release();
      continue;
    }

    // Find the description or friendly name.
    VARIANT DeviceName;
    DeviceName.vt = VT_BSTR;
    hr = pPropBag->Read(L"Description", &DeviceName, NULL);
    if (FAILED(hr)) hr = pPropBag->Read(L"FriendlyName", &DeviceName, NULL);
    if (SUCCEEDED(hr))
    { char *pDeviceName = BSTR_to_ANSI(DeviceName.bstrVal);
      if (pDeviceName)
      { PTRACE(4, "PVidDirectShow\tGetInputDeviceNames() Found this capture device '"<< pDeviceName <<"'");
        if(PString(pDeviceName) == setupDeviceName)
        {
          PTRACE(4, "PVidDirectShow\tCamera Setup: device found");
          pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**) &pFilter);
          ISpecifyPropertyPages *p_spec; CAUUID cauuid;
          HRESULT hr = pFilter->QueryInterface( IID_ISpecifyPropertyPages, (void **)&p_spec );
          if( !FAILED(hr) )
          if( SUCCEEDED(p_spec->GetPages( &cauuid )) )
          { if( cauuid.cElems > 0 )
            { HWND hwnd_desktop = ::GetDesktopWindow();
              OleCreatePropertyFrame( hwnd_desktop, 30, 30, NULL, 1, (LPUNKNOWN *)(&pFilter), cauuid.cElems, cauuid.pElems, 0, 0, NULL );
              CoTaskMemFree( cauuid.pElems );
            }
            p_spec->Release();
          }
        }
        free(pDeviceName);
      }
    }
    pPropBag->Release();
    pMoniker->Release();
  }

  ::CoUninitialize();
}
void DirectShowFrameGrabber::init() {
	InitializeDirectX();
	HRESULT hr = S_OK;
	mediaEvent = NULL;
	mediaControl = NULL;
	sampleGrabber = NULL;
	buffer = NULL;
	bufferLength = 0;
	width = 640; // just default, will be overriden
	height = 480;  // just default, will be overriden

	CComPtr<IBaseFilter> captureFilter = NULL;

	// choose video capture device
	hr = ChooseDirectXFilter(captureFilter, CLSID_VideoInputDeviceCategory);

	ASSERT(SUCCEEDED(hr));
	//ASSERT(captureFilter != NULL, "no capturing device available!");
	CComPtr<IBaseFilter> sampleGrabberFilter = NULL;
	hr = sampleGrabberFilter.CoCreateInstance(CLSID_SampleGrabber);
	ASSERT(SUCCEEDED(hr));
	CComPtr<IBaseFilter> nullRendererFilter = NULL;
	hr = nullRendererFilter.CoCreateInstance(CLSID_NullRenderer);
	ASSERT(SUCCEEDED(hr));
	graphBuilder = NULL;
	hr = graphBuilder.CoCreateInstance(CLSID_FilterGraph);


	ASSERT(SUCCEEDED(hr));
	IMediaFilter *mediaFilter = 0;
	graphBuilder->QueryInterface(IID_IMediaFilter, (void**)&mediaFilter);
	mediaFilter->SetSyncSource(NULL);	  
	mediaFilter->Release();
	

	hr = graphBuilder->AddFilter(captureFilter, NULL);	  
	ASSERT(SUCCEEDED(hr));

	// open ui with video capture device properties
	displayProperties( captureFilter );

	hr = graphBuilder->AddFilter(nullRendererFilter, L"NullRenderer");
	ASSERT(SUCCEEDED(hr));
	hr = graphBuilder->AddFilter(sampleGrabberFilter, L"Grabber");
	ASSERT(SUCCEEDED(hr));


	hr = sampleGrabberFilter->QueryInterface(IID_ISampleGrabber, (void**)&sampleGrabber);
	ASSERT(SUCCEEDED(hr));

	AM_MEDIA_TYPE mediaType;
	ZeroMemory(&mediaType, sizeof(AM_MEDIA_TYPE));
	mediaType.majortype = MEDIATYPE_Video;
	mediaType.subtype = MEDIASUBTYPE_RGB24;
	mediaType.formattype = FORMAT_VideoInfo; 
	hr = sampleGrabber->SetMediaType(&mediaType);
	ASSERT(SUCCEEDED(hr));

	CComPtr<IEnumPins> pins = NULL;
	CComPtr<IPin> cameraOutputPin = NULL;

	{
		hr = captureFilter->EnumPins(&pins);
		ASSERT(SUCCEEDED(hr));
		hr = pins->Reset();
		ASSERT(SUCCEEDED(hr));
		
		hr = pins->Next(1, &cameraOutputPin, NULL); 
		ASSERT(SUCCEEDED(hr));
		pins = NULL; 
	}


	hr = sampleGrabberFilter->EnumPins(&pins);
	ASSERT(SUCCEEDED(hr));
	hr = pins->Reset();
	ASSERT(SUCCEEDED(hr));
	CComPtr<IPin> grabberInputPin = NULL;
	hr = pins->Next(1, &grabberInputPin, NULL);
	ASSERT(SUCCEEDED(hr));
	CComPtr<IPin> grabberOutputPin = NULL;
	hr = pins->Next(1, &grabberOutputPin, NULL);
	ASSERT(SUCCEEDED(hr));
	pins = NULL;
	hr = nullRendererFilter->EnumPins(&pins);
	ASSERT(SUCCEEDED(hr));
	hr = pins->Reset();
	ASSERT(SUCCEEDED(hr));
	CComPtr<IPin> nullRendererInputPin = NULL;
	hr = pins->Next(1, &nullRendererInputPin, NULL);
	ASSERT(SUCCEEDED(hr));

	// show camera properties
		CComPtr<ISpecifyPropertyPages> propertyPages;
		hr = cameraOutputPin->QueryInterface(IID_ISpecifyPropertyPages, (void**)&propertyPages);
		if (SUCCEEDED(hr)) {
			PIN_INFO pinInfo;
			cameraOutputPin->QueryPinInfo(&pinInfo);
			CAUUID caGUID;
			propertyPages->GetPages(&caGUID);
			OleCreatePropertyFrame(NULL, 0, 0, L"Property Sheet", 1,
				(IUnknown **)&(cameraOutputPin.p), caGUID.cElems,
				caGUID.pElems, 0, 0, NULL);
			CoTaskMemFree(caGUID.pElems);
			pinInfo.pFilter->Release();
		}


	hr = graphBuilder->Connect(cameraOutputPin, grabberInputPin);
	ASSERT(SUCCEEDED(hr));
	hr = graphBuilder->Connect(grabberOutputPin, nullRendererInputPin);
	ASSERT(SUCCEEDED(hr));

	hr = graphBuilder->Render(grabberOutputPin);
	//      ASSERT(SUCCEEDED(hr)); // produces an error: "An invalid field name was used in a query string"

	hr = sampleGrabber->SetBufferSamples(TRUE);
	ASSERT(SUCCEEDED(hr));
	hr = sampleGrabber->SetOneShot(FALSE);
	ASSERT(SUCCEEDED(hr));
	hr = graphBuilder->QueryInterface(IID_IMediaControl, (void**)&mediaControl);
	ASSERT(SUCCEEDED(hr));
	hr = graphBuilder->QueryInterface(IID_IMediaEvent, (void**)&mediaEvent);
	ASSERT(SUCCEEDED(hr));
	AM_MEDIA_TYPE mt;
	hr = sampleGrabber->GetConnectedMediaType(&mt);
	ASSERT(SUCCEEDED(hr));
	ASSERT(mt.formattype == FORMAT_VideoInfo);
	VIDEOINFOHEADER *videoHeader;
	videoHeader = reinterpret_cast<VIDEOINFOHEADER*>(mt.pbFormat);
	width = videoHeader->bmiHeader.biWidth;
	height = videoHeader->bmiHeader.biHeight;
	bitmapFormat = 0;
	CComPtr<IAMVideoControl> videoControl;
	hr = captureFilter->QueryInterface(IID_IAMVideoControl, (void**)&videoControl);
	
	// run the graph!
	mediaControl->Run();
}
HRESULT CAMVfwCompressDialogs::GetPropertyWindow(VfwCompressDialogs iDialog, const ACamstudioFilter *pFilter)
{
	if(!pFilter)
		return E_FAIL;
	if(!pFilter->GetFilter())
		return E_FAIL;
	
	IAMVfwCompressDialogs *pCompDialog = NULL;
	HRESULT hr = pFilter->GetFilter()->QueryInterface(IID_IAMVfwCompressDialogs, (void**)& pCompDialog);
	if(SUCCEEDED(hr))
	{
		hr = pCompDialog->ShowDialog(iDialog, m_hWnd);
		return hr;
	}
	if(iDialog == VfwCompressDialog_QueryAbout || iDialog == VfwCompressDialog_About)
	{
		return E_FAIL;
	}

	ISpecifyPropertyPages *pProp;
	hr = pFilter->GetFilter()->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pProp);
	if (SUCCEEDED(hr)) 
	{
		if(VfwCompressDialog_QueryConfig == iDialog || VfwCompressDialog_QueryAbout == iDialog)
		{
			return hr;
		}
		// Get the filter's name and IUnknown pointer.
		FILTER_INFO FilterInfo;
		hr = pFilter->GetFilter()->QueryFilterInfo(&FilterInfo);
		if(FAILED(hr))
			return E_FAIL;
		IUnknown *pFilterUnk = 0;

		if(SUCCEEDED(pFilter->GetFilter()->QueryInterface(IID_IUnknown, (void **)&pFilterUnk)))
		{
			// Show the page. 
			CAUUID caGUID;
			pProp->GetPages(&caGUID);
			pProp->Release();
			OleCreatePropertyFrame(
				m_hWnd,                 // Parent window
				0, 0,                   // Reserved
				FilterInfo.achName,     // Caption for the dialog box
				1,                      // Number of objects (just the filter)
				&pFilterUnk,            // Array of object pointers. 
				caGUID.cElems,          // Number of property pages
				caGUID.pElems,          // Array of property page CLSIDs
				0,                      // Locale identifier
				0, NULL                 // Reserved
				);

			// Clean up.
			if(pFilterUnk)
				pFilterUnk->Release();
			if(FilterInfo.pGraph)
				FilterInfo.pGraph->Release(); 
			if(caGUID.pElems)
				CoTaskMemFree(caGUID.pElems);
		}
	}
	return hr;
}
Exemple #20
0
bool GSCaptureDlg::OnCommand(HWND hWnd, UINT id, UINT code)
{
	if(id == IDC_BROWSE && code == BN_CLICKED)
	{
		char buff[MAX_PATH] = {0};

		OPENFILENAME ofn;

		memset(&ofn, 0, sizeof(ofn));

		ofn.lStructSize = sizeof(ofn);
		ofn.hwndOwner = m_hWnd;
		ofn.lpstrFile = buff;
		ofn.nMaxFile = countof(buff);
		ofn.lpstrFilter = "Avi files (*.avi)\0*.avi\0";
		ofn.Flags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;

		strcpy(ofn.lpstrFile, m_filename.c_str());

		if(GetSaveFileName(&ofn))
		{
			m_filename = ofn.lpstrFile;

			SetText(IDC_FILENAME, m_filename.c_str());
		}

		return true;
	}
	else if(id == IDC_CONFIGURE && code == BN_CLICKED)
	{
		Codec c;

		if(GetSelCodec(c) == 1)
		{
			if(CComQIPtr<ISpecifyPropertyPages> pSPP = c.filter)
			{
				CAUUID caGUID;

				memset(&caGUID, 0, sizeof(caGUID));

				if(SUCCEEDED(pSPP->GetPages(&caGUID)))
				{
					IUnknown* lpUnk = NULL;
					pSPP.QueryInterface(&lpUnk);
					OleCreatePropertyFrame(m_hWnd, 0, 0, c.FriendlyName.c_str(), 1, (IUnknown**)&lpUnk, caGUID.cElems, caGUID.pElems, 0, 0, NULL);
					lpUnk->Release();

					if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
				}
			}
			else if(CComQIPtr<IAMVfwCompressDialogs> pAMVfWCD = c.filter)
			{
				if(pAMVfWCD->ShowDialog(VfwCompressDialog_QueryConfig, NULL) == S_OK)
				{
					pAMVfWCD->ShowDialog(VfwCompressDialog_Config, m_hWnd);
				}
			}
		}

		return true;
	}
	else if(id == IDOK)
	{
		m_width = GetTextAsInt(IDC_WIDTH);
		m_height = GetTextAsInt(IDC_HEIGHT);
		m_filename = GetText(IDC_FILENAME);

		Codec c;

		int ris = GetSelCodec(c);
		if(ris == 0)
		{
			return false;
		}

		m_enc = c.filter;

		theApp.SetConfig("CaptureWidth", m_width);
		theApp.SetConfig("CaptureHeight", m_height);
		theApp.SetConfig("CaptureFileName", m_filename.c_str());

		if (ris != 2)
		{
			wstring s = wstring(c.DisplayName.m_str);
			theApp.SetConfig("CaptureVideoCodecDisplayName", string(s.begin(), s.end()).c_str());
		}
		else
		{
			theApp.SetConfig("CaptureVideoCodecDisplayName", "");
		}
	}

	return __super::OnCommand(hWnd, id, code);
}