private void ConfigureVideoCaptureDevice(VideoCaptureDevice device) { // Configure the video capture device. // The weird thing about this is that sometimes (at least on a Macintosh), a video capture device // can have an empty device.SupportedFormats collection, but still be able to capture video. // Generally that format seems to work, but I don't think we can guarantee that. if (device != null) { MediaDeviceConfig.SelectBestVideoFormat(device); if (device.DesiredFormat == null) { ClientLogger.Debug("No appropriate video format was found; current format = {0}.", device.DesiredFormat); // ks 12/13/10 - Since limited testing has shown that some cameras on the Mac that work fine have an empty SupportedFormats collection, // we'd rather not show this error on Mac platforms. There may be other instances where we don't want to show an error, // and there may also be a better way of handling this situation in general. But good enough for now. if (Environment.OSVersion.Platform != PlatformID.MacOSX) { ClientLogger.Error(CommonStrings.Media_NoVideoFormat); MessageService.ShowErrorHint(CommonStrings.Media_NoVideoFormat); } } } else { // Only show an error if there really is no webcam attached. var videoDevices = CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices(); if (videoDevices.Count == 0) { ClientLogger.Debug(CommonStrings.Media_NoVideoDevice); MessageService.ShowErrorHint(CommonStrings.Media_NoVideoDevice); } } }
private void ConfigureAudioCaptureDevice(AudioCaptureDevice device) { // Set the audio properties. if (device != null) { MediaDeviceConfig.SelectBestAudioFormat(device); device.AudioFrameSize = AudioConstants.MillisecondsPerFrame; // 20 milliseconds if (device.DesiredFormat == null) { ClientLogger.Error(CommonStrings.Media_NoAudioFormat); MessageService.ShowErrorHint(CommonStrings.Media_NoAudioFormat); } } else { // Only show an error if there really is no microphone attached. var audioDevices = CaptureDeviceConfiguration.GetAvailableAudioCaptureDevices(); if (audioDevices.Count == 0) { ClientLogger.Debug(CommonStrings.Media_NoAudioDevice); MessageService.ShowErrorHint(CommonStrings.Media_NoAudioDevice); } } }