Exemple #1
0
 private void UpdateSelectedVideoDevice(VideoDeviceNumberChangedArgs e)
 {
     Win8LayoutManager.SafeInvoke(() =>
     {
         VideoChat.GetVideoDevices().SelectedIndex = e.DeviceNumber;
     });
 }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageVideoRenderProvider"/> class.
 /// </summary>
 /// <param name="image">The Image to target.</param>
 /// <param name="disableContextMenu">Whether or not to disable the context menu.</param>
 /// <param name="scale">The scaling algorithm to use.</param>
 public VideoRenderProvider(Image image, bool disableContextMenu, LayoutScale scale)
 {
     Win8LayoutManager.SafeInvoke(() =>
     {
         Image = image;
         Initialize(disableContextMenu, scale);
     }, true);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageVideoRenderProvider"/> class.
 /// </summary>
 /// <param name="disableContextMenu">Whether or not to disable the context menu.</param>
 /// <param name="scale">The scaling algorithm to use.</param>
 public VideoRenderProvider(bool disableContextMenu, LayoutScale scale)
 {
     Win8LayoutManager.SafeInvoke(() =>
     {
         Image = new Windows.UI.Xaml.Controls.Image();
         Initialize(disableContextMenu, scale);
     }, true);
 }
Exemple #4
0
 public override void Destroy()
 {
     Win8LayoutManager.SafeInvoke(() =>
     {
         if (ContextMenu != null)
         {
             ContextMenu.Detach();
         }
     }, true);
 }
Exemple #5
0
 public override void Initialize(VideoRenderInitializeArgs renderArgs)
 {
     Win8LayoutManager.SafeInvoke(() =>
     {
         if (ContextMenu != null)
         {
             var mediaStream = renderArgs.RemoteStream == null ? renderArgs.LocalStream : renderArgs.RemoteStream;
             ContextMenu.Attach(Image, mediaStream);
         }
     }, true);
 }
Exemple #6
0
        public override async void Render(VideoBuffer frame)
        {
            if (!Rendering)
            {
                Rendering = true;
                var stream  = new InMemoryRandomAccessStream();
                var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.BmpEncoderId, stream);

                encoder.SetPixelData(BitmapPixelFormat.Rgba8, BitmapAlphaMode.Ignore, (uint)frame.Width, (uint)frame.Height, 96, 96, frame.Plane.Data);
                await encoder.FlushAsync();

                stream.Seek(0);

                Win8LayoutManager.SafeInvoke(async() =>
                {
                    await Bitmap.SetSourceAsync(stream);
                    Rendering = false;
                });
            }
        }
Exemple #7
0
        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);
                }
            });
        }