Get and Set the Selected Device for a Media Type
For local machines configured with more than one media device that can provide needed functionality for a given category, media type, and direction, the API provides a method to discover which media device is currently selected for the task. Likewise, you can select one of those devices for that task. Selecting a device is analogous to making the device the default device for the category, type, and direction.
Getting the media device configured for audio or video I/O involves calling the GetSelectedDevice method. The three arguments for this method are required and should be filled using enumerations created for the purpose. To set a selected media device, call SetSelectedDevice.
|Integer values cannot be substituted for the enumerations specified as arguments to these methods.|
The method arguments specify the role that a media device plays in a conference session:
The device category describes the public nature of the device. For example, a telephone handset has a speaker that can only be heard by the handset user. Likewise, the microphone in the handset typically picks up only the users voice. The telephone handset is then considered a private audio media device. To set or get a handset device, use UCC_AUDIO_VIDEO_DEVICE_CATEGORY.UCCAVDC_AUDIO_VIDEO_CALL_DEVICE for this argument.
If a webcam device incorporates a microphone that picks up environmental sound in addition to the speakers voice, the webcam device is considered a non-private audio device. Use UCC_AUDIO_VIDEO_DEVICE_CATEGORY.UCCAVDC_AUDIO_VIDEO_CALL_NONPRIVATE_DEVICE to set the device as the selected media device. If you are getting or setting a video device, you can only specify the media direction UCC_MEDIA_DIRECTIONS.UCCMD_SEND. It is assumed that any video received as part of a conference session is displayed on the workstation console.
Two additional category types are UCCAVDC_NOTIFICATION_DEVICE and UCCAVDC_NONE. The notification device is that audio speaker that is capable of rendering a notification sound. For this reason, you can only use the media direction: UCC_MEDIA_DIRECTIONS.UCCMD_SEND. If a media device is installed on a local workstation that is not to be used by a Unified Communications Client API enabled application, the enumeration UCCAVDC_NONE should be used.
The media type argument refers to the type of information the device renders or captures. A camera is capable of video while a microphone is capable of audio. To configure a webcam for video capture, use UCC_MEDIA_TYPES.UCCMT_VIDEO. The microphone component of the device is configured separately. Use UCC_MEDIA_TYPES.UCCMT_AUDIO for this purpose.
Media direction refers to the ability of a media device to capture or render information. For example, a microphone is capable of capturing information while a speaker can render it. To select or get a microphone device, use UCC_MEDIA_DIRECTIONS.UCCMD_SEND. To select a speaker, use UCC_MEDIA_DIRECTIONS.UCCMD_RECEIVE.
The following example illustrates getting an IUccMediaDevice interface based on the arguments described previously.
IUccMediaDevice sendPublicAudioDevice = dm.GetSelectedDevice( UCC_AUDIO_VIDEO_DEVICE_CATEGORY.UCCAVDC_AUDIO_VIDEO_CALL_NONPRIVATE_DEVICE, UCC_MEDIA_TYPES.UCCMT_AUDIO, UCC_MEDIA_DIRECTIONS.UCCMD_SEND);
To set a selected media device, call SetSelectedDevice. The following example demonstrates setting the non-private video capture device where
d is an object implementing the IUccMediaDevice interface and
dm is an object implementing the IUccMediaDeviceManager interface.