Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks>
        /// Indeed the application needs to set its Window identifier at the right time to avoid internal Window creation
        /// from the video sink element. To solve this issue a GstMessage is posted on the bus to inform the application
        /// that it should set the Window identifier immediately.
        ///
        /// API: http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gstvideooverlay.html
        /// </remarks>
        /// <param name="o"></param>
        /// <param name="args"></param>
        private void bus_SyncMessage(object o, SyncMessageArgs args)
        {
            //Convenience function to check if the given message is a "prepare-window-handle" message from a GstVideoOverlay.

            System.Diagnostics.Debug.WriteLine("bus_SyncMessage: " + args.Message.Type.ToString());
            if (Gst.Video.Global.IsVideoOverlayPrepareWindowHandleMessage(args.Message))
            {
                Element src = (Gst.Element)args.Message.Src;

#if DEBUG
                System.Diagnostics.Debug.WriteLine("Message'prepare-window-handle' received by: " + src.Name + " " + src.ToString());
#endif

                if (src != null && (src is Gst.Video.VideoSink | src is Gst.Bin))
                {
                    //    Try to set Aspect Ratio
                    try
                    {
                        src["force-aspect-ratio"] = true;
                    }
                    catch (PropertyNotFoundException) { }

                    //    Try to set Overlay
                    try
                    {
                        Gst.Video.VideoOverlayAdapter overlay_ = new Gst.Video.VideoOverlayAdapter(src.Handle);
                        overlay_.WindowHandle = (IntPtr)mHandle;
                        overlay_.HandleEvents(true);
                    }
                    catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception thrown: " + ex.Message); }
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Set the panel on which to display the video. This must be done at the right time and via this callback.
 /// </summary>
 /// <param name="o"></param>
 /// <param name="args"></param>
 private void cb_busSyncMessage(object o, SyncMessageArgs args)
 {
     if (Gst.Video.Global.IsVideoOverlayPrepareWindowHandleMessage(args.Message))
     {
         Element src = (Gst.Element)args.Message.Src;
         sysDbg.WriteLine("Message'prepare-window-handle' received by: " + src.Name + " " + src.ToString());
         {
             //    Try to set Overlay
             try
             {
                 Gst.Video.VideoOverlayAdapter overlay_ = new Gst.Video.VideoOverlayAdapter(src.Handle);
                 overlay_.WindowHandle = (IntPtr)HdlPreviewPanel;
                 overlay_.HandleEvents(true);
             }
             catch (Exception ex)
             {
                 sysDbg.WriteLine("Error setting overlay: " + ex.Message);
             }
         }
     }
     if (args.Message.Type == MessageType.Eos)
     {
         sysDbg.WriteLine("EOS sync message received...");
     }
 }
        private void bus_SyncMessage(object o, SyncMessageArgs args)
        {
            if (Gst.Video.Global.IsVideoOverlayPrepareWindowHandleMessage(args.Message))
            {
                Element src = (Gst.Element)args.Message.Src;

                if (src != null && (src is Gst.Video.VideoSink | src is Gst.Bin))
                {
                    // Try to set Aspect Ratio
                    try
                    {
                        src["force-aspect-ratio"] = true;
                    }
                    catch (PropertyNotFoundException) { }

                    // Try to set Overlay
                    try
                    {
                        Gst.Video.VideoOverlayAdapter overlay = new Gst.Video.VideoOverlayAdapter(src.Handle);
                        overlay.WindowHandle = mHandle;
                        overlay.HandleEvents(true);
                    }
                    catch (Exception ex) { }
                }
            }
        }