public void Start(VideoChat videoChat, Action<string> callback) { // WebRTC audio and video streams require us to first get access to // the local media (microphone, camera, or both). UserMedia.GetMedia(new GetMediaArgs(Audio, Video) { // Specify an audio capture provider, a video // capture provider, an audio render provider, // and a video render provider. The IceLink // SDK comes bundled with video support for // WinForms and WPF, and uses NAudio for audio // support. For lower latency audio, use ASIO. AudioCaptureProvider = new NAudioCaptureProvider(), VideoCaptureProvider = new VideoCaptureProvider(), CreateAudioRenderProvider = (e) => { return new NAudioRenderProvider(); }, CreateVideoRenderProvider = (e) => { return new VideoRenderProvider(LayoutScale.Contain); }, VideoWidth = VideoWidth, // optional VideoHeight = VideoHeight, // optional VideoFrameRate = VideoFrameRate, // optional OnFailure = (e) => { callback(string.Format("Could not get media. {0}", e.Exception.Message)); }, OnSuccess = (e) => { // We have successfully acquired access to the local // audio/video device! Grab a reference to the media. // Internally, it maintains access to the local audio // and video feeds coming from the device hardware. LocalMediaStream = e.LocalStream; // Wire up the UI. VideoChat = videoChat; Win8LayoutManager.SafeInvoke(() => { VideoChat.GetAudioDevices().ItemsSource = LocalMediaStream.GetAudioDeviceNames(); VideoChat.GetVideoDevices().ItemsSource = LocalMediaStream.GetVideoDeviceNames(); VideoChat.GetAudioDevices().SelectionChanged += SwitchAudioDevice; VideoChat.GetVideoDevices().SelectionChanged += SwitchVideoDevice; VideoChat.GetAudioDevices().SelectedIndex = LocalMediaStream.GetAudioDeviceNumber(); VideoChat.GetVideoDevices().SelectedIndex = LocalMediaStream.GetVideoDeviceNumber(); }); // Keep the UI updated if devices are switched. LocalMediaStream.OnAudioDeviceNumberChanged += UpdateSelectedAudioDevice; LocalMediaStream.OnVideoDeviceNumberChanged += UpdateSelectedVideoDevice; // This is our local video control, a WinForms control // that displays video coming from the capture source. var localVideoControl = (FrameworkElement)e.LocalVideoControl; // Create an IceLink layout manager, which makes the task // of arranging video controls easy. Give it a reference // to a WinForms control that can be filled with video feeds. // Use WpfLayoutManager for WPF-based applications. LayoutManager = new Win8LayoutManager(VideoChat.GetContainer()); // Display the local video control. LayoutManager.SetLocalVideoControl(localVideoControl); callback(null); } }); }
public void Start(VideoChat videoChat, Action <string> callback) { // WebRTC audio and video streams require us to first get access to // the local media (microphone, camera, or both). UserMedia.GetMedia(new GetMediaArgs(Audio, Video) { // Specify an audio capture provider, a video // capture provider, an audio render provider, // and a video render provider. The IceLink // SDK comes bundled with video support for // WinForms and WPF, and uses NAudio for audio // support. For lower latency audio, use ASIO. AudioCaptureProvider = new NAudioCaptureProvider(), VideoCaptureProvider = new VideoCaptureProvider(), CreateAudioRenderProvider = (e) => { return(new NAudioRenderProvider()); }, CreateVideoRenderProvider = (e) => { return(new VideoRenderProvider(LayoutScale.Contain)); }, VideoWidth = VideoWidth, // optional VideoHeight = VideoHeight, // optional VideoFrameRate = VideoFrameRate, // optional OnFailure = (e) => { callback(string.Format("Could not get media. {0}", e.Exception.Message)); }, OnSuccess = (e) => { // We have successfully acquired access to the local // audio/video device! Grab a reference to the media. // Internally, it maintains access to the local audio // and video feeds coming from the device hardware. LocalMediaStream = e.LocalStream; // Wire up the UI. VideoChat = videoChat; Win8LayoutManager.SafeInvoke(() => { VideoChat.GetAudioDevices().ItemsSource = LocalMediaStream.GetAudioDeviceNames(); VideoChat.GetVideoDevices().ItemsSource = LocalMediaStream.GetVideoDeviceNames(); VideoChat.GetAudioDevices().SelectionChanged += SwitchAudioDevice; VideoChat.GetVideoDevices().SelectionChanged += SwitchVideoDevice; VideoChat.GetAudioDevices().SelectedIndex = LocalMediaStream.GetAudioDeviceNumber(); VideoChat.GetVideoDevices().SelectedIndex = LocalMediaStream.GetVideoDeviceNumber(); }); // Keep the UI updated if devices are switched. LocalMediaStream.OnAudioDeviceNumberChanged += UpdateSelectedAudioDevice; LocalMediaStream.OnVideoDeviceNumberChanged += UpdateSelectedVideoDevice; // This is our local video control, a WinForms control // that displays video coming from the capture source. var localVideoControl = (FrameworkElement)e.LocalVideoControl; // Create an IceLink layout manager, which makes the task // of arranging video controls easy. Give it a reference // to a WinForms control that can be filled with video feeds. // Use WpfLayoutManager for WPF-based applications. LayoutManager = new Win8LayoutManager(VideoChat.GetContainer()); // Display the local video control. LayoutManager.SetLocalVideoControl(localVideoControl); callback(null); } }); }