private void SwitchVideoDevice(object sender, SelectionChangedEventArgs e) { if (VideoChat.GetVideoDevices().SelectedIndex >= 0) { LocalMediaStream.SetVideoDeviceNumber(VideoChat.GetVideoDevices().SelectedIndex); } }
public void Stop(Action <string> callback) { // Clear out the layout manager. if (LayoutManager != null) { LayoutManager.RemoveRemoteVideoControls(); LayoutManager.UnsetLocalVideoControl(); LayoutManager = null; } if (LocalMediaStream != null) { LocalMediaStream.OnAudioDeviceNumberChanged -= UpdateSelectedAudioDevice; LocalMediaStream.OnVideoDeviceNumberChanged -= UpdateSelectedVideoDevice; } if (VideoChat != null) { VideoChat.GetAudioDevices().SelectionChanged -= SwitchAudioDevice; VideoChat.GetVideoDevices().SelectionChanged -= SwitchVideoDevice; VideoChat = null; } // Stop the local media stream. if (LocalMediaStream != null) { LocalMediaStream.Stop(); LocalMediaStream = null; } callback(null); }
public bool ResumeVideo() { if (LocalMediaStream != null) { return(LocalMediaStream.ResumeVideo()); } return(false); }
public bool PauseVideo() { if (LocalMediaStream != null) { return(LocalMediaStream.PauseVideo()); } return(false); }
public void Stop(Action <string> callback) { LayoutManager.UnsetLocalVideoControl(); LayoutManager.RemoveRemoteVideoControls(); LayoutManager = null; LocalMediaStream.Stop(); LocalMediaStream = null; LocalVideoControl = null; callback(null); }
public void Stop(Action <string> callback) { // Clear out the layout manager. if (LayoutManager != null) { LayoutManager.UnsetLocalVideoControl(); LayoutManager.RemoveRemoteVideoControls(); LayoutManager = null; } // Stop the local media stream. if (LocalMediaStream != null) { LocalMediaStream.Stop(); LocalMediaStream = null; } callback(null); }
public void GetUserMedia(Context context, ViewGroup videoContainer) { DefaultProviders.AndroidContext = context; UserMedia.GetMedia(new GetMediaArgs(true, true) { DefaultVideoPreviewScale = LayoutScale.Contain, DefaultVideoScale = LayoutScale.Contain, VideoWidth = 640, VideoHeight = 480, VideoFrameRate = 15, OnSuccess = (result) => { _localMedia = result.LocalStream; _layoutManager = new AndroidLayoutManager(videoContainer); _senderLocalVideoControl = (View)result.LocalVideoControl; var localVideoStream = new VideoStream(result.LocalStream); _conference = new Conference(STUN_TURN_URL, new Stream[] { new AudioStream(result.LocalStream), localVideoStream }); _conference.RelayUsername = "******"; _conference.RelayPassword = "******"; _conference.DtlsCertificate = Certificate.GenerateCertificate(); _conference.OnLinkCandidate += Conference_OnLinkCandidate; _conference.OnLinkOfferAnswer += Conference_OnLinkOfferAnswer; localVideoStream.OnLinkInit += LocalVideoStream_OnLinkInit; localVideoStream.OnLinkDown += LocalVideoStream_OnLinkDown; _layoutManager.SetLocalVideoControl(_senderLocalVideoControl); _opusEchoCanceller = new OpusEchoCanceller(4800, 2); _opusEchoCanceller.Start(); }, OnFailure = (error) => { Console.WriteLine(error); } }); }
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); } }); }
private void StartMedia() { // Get a video-based local media stream. This // conference will be send-only. // ทำการ Get user media ของเครื่อง (Audio and Video Device) UserMedia.GetMedia(new GetMediaArgs(true, true) { AudioCaptureProvider = new NAudioCaptureProvider(), VideoCaptureProvider = new WpfAForgeVideoCaptureProvider(Dispatcher), CreateAudioRenderProvider = (e) => { return(new NAudioRenderProvider()); }, CreateVideoRenderProvider = (e) => { return(new ImageVideoRenderProvider(Dispatcher, LayoutScale.Contain)); }, // กำหนดขนาด Video ที่จะแสดงพร้อมทั้ง Frame rate ของ Video VideoWidth = 352, // optional VideoHeight = 288, // optional VideoFrameRate = 30, // optional // เมื่อไม่สามารถ Access user media ของเครื่องได้ จะแสดง message error OnFailure = (e) => { Alert("Could not get media. {0}", e.Exception.Message); }, // เมื่อสามารถ Access user media ของเครื่องได้ OnSuccess = (e) => { // พิมพ์แสดงผลลัพธ์ว่าสามารถ Access user media ของเครื่องได้ Console.WriteLine("Get User media ok..."); // กำหนด localmedia audio and video ที่ใช้งาน LocalMediaReceiver = e.LocalStream; // Create a WebRTC audio stream description (requires a // reference to the local audio feed). // กำหนด Audio ในการสนทนา audioStream_Receiver = new AudioStream(LocalMediaReceiver); // Create a WebRTC video stream description (requires a // reference to the local video feed). Whenever a P2P link // initializes using this description, position and display // the remote video control on-screen by passing it to the // layout manager created above. Whenever a P2P link goes // down, remove it. // กำหนด Video ในการสนทนา videoStream_Receiver = new VideoStream(LocalMediaReceiver); // กำหนดแสดง Video เมื่อมีการสนทนากับเลิกสนทนา videoStream_Receiver.OnLinkInit += AddRemoteVideoControl; videoStream_Receiver.OnLinkDown += RemoveRemoteVideoControl; // แสดงรายชื่อ Audio และ Video Device ที่สามารถ Access ได้โดยแสดงใน ComboBox AudioDevices.ItemsSource = LocalMediaReceiver.GetAudioDeviceNames(); VideoDevices.ItemsSource = LocalMediaReceiver.GetVideoDeviceNames(); // เลือก Audio and Video อันแรกของอุปกรณ์เพื่อใช้งาน AudioDevices.SelectedIndex = LocalMediaReceiver.GetAudioDeviceNumber(); VideoDevices.SelectedIndex = LocalMediaReceiver.GetVideoDeviceNumber(); // เปลี่ยน Localmedia เมื่อมีการเปลี่ยน Audio and Video Device AudioDevices.SelectionChanged += SwitchAudioDevice; VideoDevices.SelectionChanged += SwitchVideoDevice; // อัพเดตแสดง Video Device เมื่อมีการเลือกหรือเปลี่ยนอุปกรณ์การใช้งาน LocalMediaReceiver.OnAudioDeviceNumberChanged += UpdateSelectedAudioDevice; LocalMediaReceiver.OnVideoDeviceNumberChanged += UpdateSelectedVideoDevice; // This is our local video control, a WinForms control // that displays video coming from the capture source. // กำหนดการ capture source ของ Video device 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. // กำหนดให้ Video แสดงผลที่ canvas ใน UI ของ Sender LayoutManager = new WpfLayoutManager(containerLocal); // แสดงผล Video ที่ได้จากการ capture source LayoutManager.SetLocalVideoControl(localVideoControl); // เริ่มทำการ Conference StartConference(); } }); }
public void Start(VideoPage videoPage, 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 AudioCaptureProvider(), VideoCaptureProvider = new VideoCaptureProvider(videoPage), CreateAudioRenderProvider = (e) => { return(new AudioRenderProvider()); }, CreateVideoRenderProvider = (e) => { return(new Direct3DRenderProvider()); }, VideoWidth = VideoWidth, // optional VideoHeight = VideoHeight, // optional VideoFrameRate = VideoFrameRate, // optional OnFailure = (e) => { callback(string.Format("Could not get media. {0}", e.Exception.Message)); }, OnSuccess = (ea) => { // 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 = ea.LocalStream; // This is our local video control, a WinForms Control or // WPF FrameworkElement. It is constantly updated with // our live video feed since we requested video above. // Add it directly to the UI or use the IceLink layout // manager, which we do below. LocalVideoControl = (FrameworkElement)ea.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. // For WPF users, the WebRTC extension includes // WpfLayoutManager, which accepts a Canvas. LayoutManager = new WpfLayoutManager(videoPage.Container); // Position and display the local video control on-screen // by passing it to the layout manager created above. LayoutManager.SetLocalVideoControl(LocalVideoControl); // When double-clicked, mute/unmute the local video. videoPage.Dispatcher.BeginInvoke(() => { LocalVideoControl.DoubleTap += (sender, ce) => { LocalMediaStream.ToggleVideoMute(); }; }); //call back of null will let the app know to continue on to the signalling stage callback(null); } }); }
public void Start(ViewGroup videoContainer, Action<string> callback) { /* * Demonstration of how to record local audio/video to disk while the media stream is active. * OpusCodec opus = new OpusCodec(); Vp8Codec vp8 = new Vp8Codec(); opus.Initialize(CodecUsage.Encoder, "opus", 48000, 2); vp8.Initialize(CodecUsage.Encoder, "VP8"); var oggPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "audio.ogg"); var ivfPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "video.ivf"); var audioCaptureProvider = new OggAudioCaptureProvider(oggPath, opus); var videoCaptureProvider = new IvfVideoCaptureProvider(ivfPath, vp8); */ UserMedia.GetMedia(new GetMediaArgs(Audio, Video) { // Uncomment this line to do in-app screen capture. //VideoCaptureProvider = new AndroidVideoCaptureProvider(videoContainer.RootView), VideoWidth = VideoWidth, // optional VideoHeight = VideoHeight, // optional VideoFrameRate = VideoFrameRate, // optional DefaultVideoPreviewScale = LayoutScale.Contain, // optional DefaultVideoScale = LayoutScale.Contain, // 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; // This is our local video control, a View. It is // constantly updated with our live video feed since // we requested video above. Add it directly to the UI // or use the IceLink layout manager, which we do below. var localVideoControl = (View)e.LocalVideoControl; // Create an IceLink layout manager, which makes the task // of arranging video controls easy. Give it a reference // to a View that can be filled with video feeds. LayoutManager = new AndroidLayoutManager(videoContainer); // Position and display the local video control on-screen // by passing it to the layout manager created above. LayoutManager.SetLocalVideoControl(localVideoControl); callback(null); } }); }
public void Stop(Action<string> callback) { // Clear out the layout manager. if (LayoutManager != null) { LayoutManager.RemoveRemoteVideoControls(); LayoutManager.UnsetLocalVideoControl(); LayoutManager = null; } // Stop the local media stream. if (LocalMediaStream != null) { LocalMediaStream.Stop(); LocalMediaStream = null; } callback(null); }