Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
media
danimation.controls
danimation.programming
devices
drm
dshow.programming
dtransform
encoder
encoder.optimization
hometheaterpc
media
media.beta
media.beta.encoder
mediacenter
mediacenter.portable
mediaplayer
music.products
musicproducer
player
player.plugins
player.skins
player.solaris
player.visualizations
player.web
sdk
server
tools
  
 
date: Mon, 26 May 2008 08:15:00 -0700,    group: microsoft.public.windowsmedia.encoder        back       


Enumerate List Of Record Devices (Audio & Video)   
Anyone got a nice code snippet to list all the audio/video record devices.

The SDK has a nice code for getting all the PROFILES  but I cant find 
anything for Audio and Video devices.
date: Mon, 26 May 2008 08:15:00 -0700   author:   DaleG

Re: Enumerate List Of Record Devices (Audio & Video)   
On 26 Maig, 17:15, DaleG  wrote:
> Anyone got a nice code snippet to list all the audio/video record devices.> The SDK has a nice code for getting all the PROFILES  but I cant find
> anything for Audio and Video devices.

There is a sample for that in the SDK, but, anyway...

HRESULT WMEncApiWrapper::GetDevicePlugInList(PluginInfoArray
&piaPlugins)
{
	CComPtr<IWMEncSourcePluginInfoManager> pEncSrcPlugin;
	CComPtr<IWMEncPluginInfo> pEncPluginInfo;
	WMENC_SOURCE_TYPE srcType;
	VARIANT_BOOL bResources, bAux;
	CComBSTR bstr;
	PLUGIN_INFO Plugin;
	long lNumPlugs, lNumRes;
	short iFlags;
	int i, j;
	HRESULT hr=S_OK;

	if(m_pEncoder) {
		do {
			hr=m_pEncoder->get_SourcePluginInfoManager(&pEncSrcPlugin);
if(FAILED(hr)) break;
			hr=pEncSrcPlugin->get_Count(&lNumPlugs);
if(FAILED(hr)) break;
			for(i=0; i<lNumPlugs; i) {
				hr=pEncSrcPlugin->Item(i, &pEncPluginInfo);
if(FAILED(hr)) break;
				hr=pEncPluginInfo->get_SchemeType(&bstr);
if(FAILED(hr)) break;
				if(_tcsicmp(bstr, CComBSTR("DEVICE"))==0) {
					hr=pEncPluginInfo->get_Resources(&bResources);
if(FAILED(hr)) break;
					if(bResources==VARIANT_TRUE) {
						bstr.Empty();
						hr=pEncPluginInfo->get_Name(&bstr);
if(FAILED(hr)) break;
						Plugin.sPluginName=bstr;
						bstr.Empty();
						hr=pEncPluginInfo->get_CLSID(&bstr);
if(FAILED(hr)) break;
						Plugin.sCLSID=bstr;
						bstr.Empty();
						hr=pEncPluginInfo->get_Copyright(&bstr);
if(FAILED(hr)) break;
						Plugin.sCopyright=bstr;
						bstr.Empty();
						hr=pEncPluginInfo->get_InfoURL(&bstr);
if(FAILED(hr)) break;
						Plugin.sURL=bstr;
						hr=pEncPluginInfo->get_MediaType(&srcType);
if(FAILED(hr)) break;
						Plugin.MediaType=srcType;
						hr=pEncPluginInfo->get_Exclusive(&bAux);
if(FAILED(hr)) break;
						Plugin.bExclusive=(bAux==VARIANT_FALSE);
						hr=pEncPluginInfo->get_Hidden(&bAux);
if(FAILED(hr)) break;
						Plugin.bHidden=(bAux==VARIANT_TRUE);
						Plugin.SchemeType=WMEncApiWrapper::PS_DEVICE;
						hr=pEncPluginInfo->get_TransformFlags(&iFlags);
if(FAILED(hr)) break;
						Plugin.TransformFlags=(PLUGIN_TRANSFORMFLAGS)iFlags;
						hr=pEncPluginInfo->get_Count(&lNumRes);
if(FAILED(hr)) break;
						for(j=0; j<lNumRes; j) {
							bstr.Empty();
							hr=pEncPluginInfo->Item(j, &bstr);
if(FAILED(hr)) break;
							Plugin.sResourceName=bstr;
							piaPlugins.Add(Plugin);
						}
						if(FAILED(hr)) break;
					}
				}
				pEncPluginInfo.Release();
				if(FAILED(hr)) break;
			}
		}while(false);

		return hr;
	}
	else {
		return E_POINTER;
	}
}

I Hope this helps!

Vegethalia
----------------------------------------------
http://naturarea.pleyhades.com
date: Tue, 27 May 2008 02:34:33 -0700 (PDT)   author:   Vegethalia

Re: Enumerate List Of Record Devices (Audio & Video)   
DaleG wrote:
> Anyone got a nice code snippet to list all the audio/video record devices.
> 
> The SDK has a nice code for getting all the PROFILES  but I cant find 
> anything for Audio and Video devices.

Hi, Dale:

Look at the Examples section of the SDK, under "Listing all Devices"; I 
think that's what you're looking for.

I don't have a "nice" code snippet, but I have some C++ code that works, 
and populates 2 CComboBoxes (1 for audio & 1 for video) and initializes 
them to the DV device, if present.  It's part of a CDialog class, and 
uses various member variables, etc, so it won't just compile & run, and 
you'll have to figure out what the various parameters are, but it might 
give you an idea.  It also uses a template function, because you need to 
iterate through two essentially identical classes -- one that's for 
internal sources, and one that's for external DV devices.  The code 
follows below; I hope it helps.

Paul

--


//Template function to do same thing with both Digital Video srcs & 
//internal sources
template<class IWMEncPluginInfoManager>  HRESULT 
getSources(IWMEncPluginInfoManager * pPluginInfoManager, CComboBox * 
pCBSrcsVideo, CComboBox * pCBSrcsAudio, char devType)
{
     HRESULT hr = 0;
     int i;
     int j;
     int index;
     long lCount;
     long lResrcCount;
     CComBSTR sScheme;
     CComBSTR sName;
     CString cString;
     CString csTest, cMediaType;
     VARIANT_BOOL bResources;
     CString cType []={"BAD VALUE", "Source", "Transform", "Device 
Control"};
     CString csMediaType[]={"Media value out of range", "Audio", 
"Video", "Script", "File Transfer"};
     WMENC_PLUGIN_TYPE  enumType;//Device, Source, etc.
     WMENC_SOURCE_TYPE enumSrceType; //Audio, Video, etc
     char * dt = "BAD VALUE";

     if (devType == 'D') dt = "DEVICECONTROL";
     if (devType == 'S') dt = "DEVICE";
     IWMEncPluginInfo* pPlugInfo;

     hr = pPluginInfoManager->get_Count(&lCount);
     for (i = 0; i < lCount; i++)
     {
         // Set the IWMEncPluginInfo object to the current plug-in.
               if ( SUCCEEDED( hr ) )
         {
             hr = pPluginInfoManager->Item(i, &pPlugInfo);
         }
		// Get the plugin type.
         pPlugInfo->get_PluginType(&enumType);

	// Get the media type (audio, video, etc)
	pPlugInfo->get_MediaType(&enumSrceType);
         // Find the plug-ins that support resources.
         if ( SUCCEEDED( hr ) )
         {
             hr = pPlugInfo->get_SchemeType(&sScheme);
         }
         if (_wcsicmp(sScheme, CComBSTR(dt))==0)
         {
             // Find the devices.
             if ( SUCCEEDED( hr ) )
             {
                 hr = pPlugInfo->get_Resources(&bResources);
             }
             if ((bResources==VARIANT_TRUE) || devType == 'D')
             {
                 // Loop through the resources in the current plug-in.
                 if ( SUCCEEDED( hr) || devType == 'D' )
                 {
                     hr = pPlugInfo->get_Count(&lResrcCount);
                 }
                 for (j = 0; j < lResrcCount; j++)
                 {
                     // Display the name of the plug-in.
                     if ( SUCCEEDED( hr ) )
                     {
                         hr = pPlugInfo->Item(j, &sName);
			cString = sName;

			cMediaType.Format("MediaType: <%d> ", enumSrceType);
			csTest.Format(" Enum Media Type is: <%d> ",enumSrceType);
			if (enumSrceType & 1)
	                {
			  cMediaType=" Audio ";
			  index=pCBSrcsAudio->AddString(cType[enumType] + "  " +csTest+ 
cMediaType + "//"+cString);
			  pCBSrcsAudio->SetItemDataPtr( index, (void*)pPlugInfo  );
                           if (pCBSrcsAudio->GetCount()==1) 
pCBSrcsAudio->SetCurSel(0);
                           if (devType=='D') //It's a DV device; make 
default
                                pCBSrcsAudio->SetCurSel(index);
			}
			if (enumSrceType & 2)
                         {
			  cMediaType=" Video ";
			  index=pCBSrcsVideo->AddString(cType[enumType] + "  " +csTest+ 
cMediaType + "//"+cString);
			  pCBSrcsVideo->SetItemDataPtr( index, (void*)pPlugInfo  );
                           if (pCBSrcsVideo->GetCount()==1) 
pCBSrcsVideo->SetCurSel(0);
                           if (devType=='D') //It's a DV device; make 
default
                                pCBSrcsVideo->SetCurSel(index);
                         }
                     }
                     //wprintf(CComBSTR("%s\n"), sName);
                 }
             }
         }
     }

   return hr;
}


----------------------
//Get the list of input devices and fill the combo boxes.

int COneClickApp1Dlg::m_PopulateListDevices()
{

     IWMEncSourcePluginInfoManager* pSrcPlugMgr;
     IWMEncDeviceControlPluginInfoManager* pDCPlugMgr;
//    IWMEncPluginInfo* pPlugInfo;

	//Clear out the combo-boxes:

     mp_comboAudioDevices->ResetContent( );
     mp_comboVideoDevices->ResetContent( );

     // Retrieve source and device plug-in info manager objects from 
IWMEncoder.
     if ( SUCCEEDED( hr ) )
     {
         hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);
     }
     if ( SUCCEEDED( hr ) )
     {
         hr = pEncoder->get_DeviceControlPluginInfoManager(&pDCPlugMgr);
     }
     getSources (pSrcPlugMgr, mp_comboVideoDevices, 
mp_comboAudioDevices, 'S');
     getSources (pDCPlugMgr, mp_comboVideoDevices,mp_comboAudioDevices, 
'D');
     return 1;
}
date: Tue, 27 May 2008 12:30:34 +0200   author:   Paul Kirkaas

RE: Enumerate List Of Record Devices (Audio & Video)   
Any Chance I could get that convert to VB?  Not a C man at all.  Just a 
lowbie VB person.  Thank you.

"DaleG" wrote:

> Anyone got a nice code snippet to list all the audio/video record devices.
> 
> The SDK has a nice code for getting all the PROFILES  but I cant find 
> anything for Audio and Video devices.
date: Thu, 29 May 2008 15:11:39 -0700   author:   DaleG

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us