Untitled Document

RStreamer

GStreamer is a pipeline-based multimedia framework that connects together a wide variety of media processing components to provide audio and video playback, recording, streaming and editing.

RStreamer is a C# wrapper that provides the development tools to leverage this powerful framework in your .NET project.

Requirements:

Note: After installing GStreamer, make sure that your PATH variable contains the GStreamer bin folder, e.g.(C:\gstreamer\1.0\x86_64\bin)

Download version 1.0

Download RStreamer

* Please contact us to get the full version.

How to use it


////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Sample code 1: Video test
//
//               videotestsrc - d3dvideosink
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

using RStreamer;

namespace Test
{
    public partial class Window1 : Window
    {
        GstPipeline pipeline;
        GstElement videotestsrc;
        GstElement d3dvideosink;

        public Window1()
        {
            InitializeComponent();
            
            Gst.Init();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            bool b;
           
            uint major, minor, micro, nano;
            Gst.GetVersion(out major, out minor, out micro, out nano);

            string version = Gst.GetVersionString();
            
            pipeline = Gst.MakePipeline("pipeline");
            
            videotestsrc = Gst.MakeElement("videotestsrc", "videotestsrc");
            d3dvideosink = Gst.MakeElement("d3dvideosink", "d3dvideosink");

            videotestsrc.SetProperty("pattern", 0);

            pipeline.AddManyElements(videotestsrc, d3dvideosink);

            b = Gst.LinkElements(videotestsrc, d3dvideosink);

            IntPtr windowHandle = new System.Windows.Interop.WindowInteropHelper(this).Handle;
            d3dvideosink.SetVideoOverlayWindowHandle(windowHandle);

            pipeline.SetState(GstState.GST_STATE_PLAYING);
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            pipeline.SetState(GstState.GST_STATE_PAUSED);

            d3dvideosink.SetVideoOverlayWindowHandle(IntPtr.Zero);

            pipeline.SetState(GstState.GST_STATE_NULL);

            videotestsrc.Dispose();
            d3dvideosink.Dispose();
            pipeline.Dispose();
        }
    }
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Sample code 2: Playing back an MKV file
//
//                filesrc - matroskademux
//                                |
//                                |- videoQueue - videoDecodebin - videoConvert - videoScale - d3dvideosink
//                                |- audioQueue - audioDecodebin - audioConvert - audioResample - autoaudiosink
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

using RStreamer;

namespace Test
{
    public partial class Window2 : Window
    {
        GstPipeline pipeline;

        GstElement filesrc;
        GstElement matroskademux;

        GstElement videoQueue;
        GstElement videoDecodebin;
        GstElement videoConvert;
        GstElement videoScale;
        GstElement d3dvideosink;

        GstElement audioQueue;
        GstElement audioDecodebin;
        GstElement audioConvert;
        GstElement audioResample;
        GstElement autoaudiosink;

        public Window2()
        {
            InitializeComponent();
            
            Gst.Init();
        }
        
        public void cbPadAdded(GstElement source, GstPad pad)
        {
            if (source.Handle == audioDecodebin.Handle)
            {
                GstPad audioConvertSinkPad = audioConvert.GetStaticPad("sink");
                GstPadLinkReturn ret = Gst.LinkPads(pad, audioConvertSinkPad);
                audioConvertSinkPad.Dispose();
            }

            if (source.Handle == videoDecodebin.Handle)
            {
                GstPad videoConvertSinkPad = videoConvert.GetStaticPad("sink");
                GstPadLinkReturn ret = Gst.LinkPads(pad, videoConvertSinkPad);
                videoConvertSinkPad.Dispose();
            }            

            if (source.Handle == matroskademux.Handle)
            {
                GstCaps caps = pad.GetCaps();
                string sCaps = caps.ToString();

                if (sCaps.StartsWith("video"))
                {
                    Console.WriteLine("video pad found");

                    GstPad videoQueuePadSink = videoQueue.GetStaticPad("sink");

                    if (!videoQueuePadSink.IsLinked())
                    {
                        GstPadLinkReturn ret = Gst.LinkPads(pad, videoQueuePadSink);
                    }

                    videoQueuePadSink.Dispose();
                }
                else if (sCaps.StartsWith("audio"))
                {
                    Console.WriteLine("audio pad found");

                    GstPad audioQueuePadSink = audioQueue.GetStaticPad("sink");

                    if (!audioQueuePadSink.IsLinked())
                    {
                        GstPadLinkReturn ret = Gst.LinkPads(pad, audioQueuePadSink);
                    }

                    audioQueuePadSink.Dispose();
                }
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            bool b;

            pipeline = Gst.MakePipeline("pipeline");

            filesrc = Gst.MakeElement("filesrc", "filesrc");
            matroskademux = Gst.MakeElement("matroskademux", "matroskademux");

            videoQueue = Gst.MakeElement("queue", "videoQueue");
            videoDecodebin = Gst.MakeElement("decodebin", "videoDecodebin");
            videoConvert = Gst.MakeElement("videoconvert", "videoconvert");
            videoScale = Gst.MakeElement("videoscale", "videoscale");
            d3dvideosink = Gst.MakeElement("d3dvideosink", "d3dvideosink");

            audioQueue = Gst.MakeElement("queue", "audioQueue");
            audioDecodebin = Gst.MakeElement("decodebin", "audioDecodebin");
            audioConvert = Gst.MakeElement("audioconvert", "audioConvert");
            audioResample = Gst.MakeElement("audioresample", "audioResample");
            autoaudiosink = Gst.MakeElement("autoaudiosink", "autoaudiosink");

            filesrc.SetProperty("location", "C:/Videos/sample.mkv");

            pipeline.AddManyElements(filesrc, matroskademux, 
				videoQueue, videoDecodebin, videoConvert, videoScale, d3dvideosink,
				audioQueue, audioDecodebin, audioConvert, audioResample, autoaudiosink);

            matroskademux.OnPadAdded += cbPadAdded;
            videoDecodebin.OnPadAdded += cbPadAdded;
            audioDecodebin.OnPadAdded += cbPadAdded;
            
            b = Gst.LinkElements(filesrc, matroskademux);
            b = Gst.LinkElements(matroskademux, videoQueue);
            b = Gst.LinkElements(matroskademux, audioQueue);

            b = Gst.LinkManyElements(videoQueue, videoDecodebin, videoConvert, videoScale, d3dvideosink);
            b = Gst.LinkManyElements(audioQueue, audioDecodebin, audioConvert, audioResample, autoaudiosink);

            IntPtr windowHandle = new System.Windows.Interop.WindowInteropHelper(this).Handle;
            d3dvideosink.SetVideoOverlayWindowHandle(windowHandle);

            pipeline.SetState(GstState.GST_STATE_PLAYING);
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            pipeline.SetState(GstState.GST_STATE_PAUSED);

            matroskademux.OnPadAdded -= cbPadAdded;
            videoDecodebin.OnPadAdded -= cbPadAdded;
            audioDecodebin.OnPadAdded -= cbPadAdded;

            d3dvideosink.SetVideoOverlayWindowHandle(IntPtr.Zero);

            pipeline.SetState(GstState.GST_STATE_NULL);

            filesrc.Dispose();
            matroskademux.Dispose();
            videoQueue.Dispose();
            videoDecodebin.Dispose();
            videoConvert.Dispose();
            videoScale.Dispose();
            d3dvideosink.Dispose();
            audioQueue.Dispose();
            audioDecodebin.Dispose();
            audioConvert.Dispose();
            audioResample.Dispose();
            autoaudiosink.Dispose();
            pipeline.Dispose();
        }
    }
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Sample code 3: Playing back a MOV file
//
//                filesrc - qtdemux
//                             |
//                             |- videoQueue - videoDecodebin - videoConvert - videoScale - d3dvideosink
//                             |- audioQueue - audioDecodebin - audioConvert - audioResample - autoaudiosink
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

using RStreamer;

namespace Test
{
    public partial class Window3 : Window
    {
        GstPipeline pipeline;

        GstElement filesrc;
        GstElement qtdemux;

        GstElement videoQueue;
        GstElement videoDecodebin;
        GstElement videoConvert;
        GstElement videoScale;
        GstElement d3dvideosink;
        
        GstElement audioQueue;
        GstElement audioDecodebin;
        GstElement audioConvert;
        GstElement audioResample;
        GstElement autoaudiosink;

        public Window3()
        {
            InitializeComponent();
            
            Gst.Init();
        }

        public void cbPadAdded(GstElement source, GstPad pad)
        {
            if (source.Handle == videoDecodebin.Handle)
            {
                GstPad videoConvertSinkPad = videoConvert.GetStaticPad("sink");
                GstPadLinkReturn ret = Gst.LinkPads(pad, videoConvertSinkPad);
                videoConvertSinkPad.Dispose();
            }            

            if (source.Handle == audioDecodebin.Handle)
            {
                GstPad audioConvertSinkPad = audioConvert.GetStaticPad("sink");
                GstPadLinkReturn ret = Gst.LinkPads(pad, audioConvertSinkPad);
                audioConvertSinkPad.Dispose();
            }

            if (source.Handle == qtdemux.Handle)
            {
                GstCaps caps = pad.GetCaps();
                string sCaps = caps.ToString();

                if(sCaps.StartsWith("video"))
                {
                    Console.WriteLine("video pad found");

                    GstPad videoQueuePadSink = videoQueue.GetStaticPad("sink");

                    if (!videoQueuePadSink.IsLinked())
                    {
                        GstPadLinkReturn ret = Gst.LinkPads(pad, videoQueuePadSink);
                    }

                    videoQueuePadSink.Dispose();
                }
                else if (sCaps.StartsWith("audio"))
                {
                    Console.WriteLine("audio pad found");

                    GstPad audioQueuePadSink = audioQueue.GetStaticPad("sink");

                    if (!audioQueuePadSink.IsLinked())
                    {
                        GstPadLinkReturn ret = Gst.LinkPads(pad, audioQueuePadSink);
                    }

                    audioQueuePadSink.Dispose();
                }
            }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            bool b;

            pipeline = Gst.MakePipeline("pipeline");

            filesrc = Gst.MakeElement("filesrc", "filesrc");
            qtdemux = Gst.MakeElement("qtdemux", "qtdemux");

            videoQueue = Gst.MakeElement("queue", "videoQueue");
            videoDecodebin = Gst.MakeElement("decodebin", "videoDecodebin");
            videoConvert = Gst.MakeElement("videoconvert", "videoConvert");
            videoScale = Gst.MakeElement("videoscale", "videoScale");
            d3dvideosink = Gst.MakeElement("d3dvideosink", "d3dvideosink");

            audioQueue = Gst.MakeElement("queue", "audioQueue");
            audioDecodebin = Gst.MakeElement("decodebin", "audioDecodebin");
            audioConvert = Gst.MakeElement("audioconvert", "audioConvert");
            audioResample = Gst.MakeElement("audioresample", "audioResample");
            autoaudiosink = Gst.MakeElement("autoaudiosink", "autoaudiosink");

            filesrc.SetProperty("location", "C:/Videos/Sample_480p_h264.mov");

            qtdemux.OnPadAdded += cbPadAdded;

            videoDecodebin.OnPadAdded += cbPadAdded;
            audioDecodebin.OnPadAdded += cbPadAdded;

            b = pipeline.AddManyElements(filesrc, qtdemux, 
	            	videoQueue, videoDecodebin, videoConvert, videoScale, d3dvideosink,
					audioQueue, audioDecodebin, audioConvert, audioResample, autoaudiosink);

            b = Gst.LinkElements(filesrc, qtdemux);
            b = Gst.LinkElements(qtdemux, videoQueue);
            b = Gst.LinkElements(qtdemux, audioQueue);

            b = Gst.LinkManyElements(videoQueue, videoDecodebin, videoConvert, videoScale, d3dvideosink);
            b = Gst.LinkManyElements(audioQueue, audioDecodebin, audioConvert, audioResample, autoaudiosink);

            IntPtr windowHandle = new System.Windows.Interop.WindowInteropHelper(this).Handle;
            d3dvideosink.SetVideoOverlayWindowHandle(windowHandle);

            pipeline.SetState(GstState.GST_STATE_PLAYING);
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            pipeline.SetState(GstState.GST_STATE_PAUSED);

            qtdemux.OnPadAdded -= cbPadAdded;
            videoDecodebin.OnPadAdded -= cbPadAdded;
            audioDecodebin.OnPadAdded -= cbPadAdded;

            d3dvideosink.SetVideoOverlayWindowHandle(IntPtr.Zero);

            pipeline.SetState(GstState.GST_STATE_NULL);

            filesrc.Dispose();
            qtdemux.Dispose();
            audioQueue.Dispose();
            audioDecodebin.Dispose();
            audioConvert.Dispose();
            audioResample.Dispose();
            autoaudiosink.Dispose();
            videoQueue.Dispose();
            videoDecodebin.Dispose();
            videoConvert.Dispose();
            videoScale.Dispose();
            d3dvideosink.Dispose();

            pipeline.Dispose();
        }
    }
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Sample code 4: Playing back a MOV file while getting bus messages
//
//                filesrc - qtdemux
//                             |
//                             |- videoQueue - videoDecodebin - videoConvert - videoScale - d3dvideosink
//                             |- audioQueue - audioDecodebin - audioConvert - audioResample - autoaudiosink
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

using RStreamer;

namespace Test
{
    public partial class Window4 : Window
    {
        private readonly BackgroundWorker worker = new BackgroundWorker();

        GstPipeline pipeline;

        GstElement filesrc;
        GstElement qtdemux;

        GstElement audioQueue;
        GstElement audioDecodebin;
        GstElement audioConvert;
        GstElement audioResample;
        GstElement autoaudiosink;

        GstElement videoQueue;
        GstElement videoDecodebin;
        GstElement videoConvert;
        GstElement videoScale;
        GstElement d3dvideosink;

        GstBus bus;
        GstMainLoop loop;

        public Window4()
        {
            InitializeComponent();
            
            Gst.Init();

            worker.DoWork += worker_DoWork;
        }

        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            loop = Gst.MakeMainLoop(IntPtr.Zero, false);
            loop.Run();
        }

        void cbPadAdded(GstElement source, GstPad pad)
        {
            Console.WriteLine("cbPadAdded, source: {0}, handle: {1}", source.Name(), source.Handle);

            if (source.Handle == videoDecodebin.Handle)
            {
                GstPad videoConvertSinkPad = videoConvert.GetStaticPad("sink");
                GstPadLinkReturn ret = Gst.LinkPads(pad, videoConvertSinkPad);
                videoConvertSinkPad.Dispose();
            }

            if (source.Handle == audioDecodebin.Handle)
            {
                GstPad audioConvertSinkPad = audioConvert.GetStaticPad("sink");
                GstPadLinkReturn ret = Gst.LinkPads(pad, audioConvertSinkPad);
                audioConvertSinkPad.Dispose();
            }

            if (source.Handle == qtdemux.Handle)
            {
                GstCaps caps = pad.GetCaps();
                string sCaps = caps.ToString();

                if (sCaps.StartsWith("video"))
                {
                    Console.WriteLine("video pad found");

                    GstPad videoQueuePadSink = videoQueue.GetStaticPad("sink");

                    if (!videoQueuePadSink.IsLinked())
                    {
                        GstPadLinkReturn ret = Gst.LinkPads(pad, videoQueuePadSink);
                    }

                    videoQueuePadSink.Dispose();
                }
                else if (sCaps.StartsWith("audio"))
                {
                    Console.WriteLine("audio pad found");

                    GstPad audioQueuePadSink = audioQueue.GetStaticPad("sink");

                    if (!audioQueuePadSink.IsLinked())
                    {
                        GstPadLinkReturn ret = Gst.LinkPads(pad, audioQueuePadSink);
                    }

                    audioQueuePadSink.Dispose();
                }
            }
        }

        bool cbBusMessage(GstMessage msg)
        {
            GstClock time = new GstClock(msg.timeStamp);

            string sTimeStamp = "NONE";

            if (time.IsValid())
            {
                sTimeStamp = msg.timeStamp.ToString();
            }

            String s = String.Format("seqNum: {0}, type: {1}, timeStamp: {2}, srcHandle: {3}", 
            msg.seqNumber, msg.type, sTimeStamp, msg.srcHandle);

            return true;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            bool b;

            worker.RunWorkerAsync();

            pipeline = Gst.MakePipeline("pipeline");

            filesrc = Gst.MakeElement("filesrc", "filesrc");
            qtdemux = Gst.MakeElement("qtdemux", "qtdemux");

            videoQueue = Gst.MakeElement("queue", "videoQueue");
            videoDecodebin = Gst.MakeElement("decodebin", "videoDecodebin");
            videoConvert = Gst.MakeElement("videoconvert", "videoConvert");
            videoScale = Gst.MakeElement("videoscale", "videoScale");
            d3dvideosink = Gst.MakeElement("d3dvideosink", "d3dvideosink");

            audioQueue = Gst.MakeElement("queue", "audioQueue");
            audioDecodebin = Gst.MakeElement("decodebin", "audioDecodebin");
            audioConvert = Gst.MakeElement("audioconvert", "audioConvert");
            audioResample = Gst.MakeElement("audioresample", "audioResample");
            autoaudiosink = Gst.MakeElement("autoaudiosink", "autoaudiosink");

            filesrc.SetProperty("location", "C:/Videos/Sample_480p_h264.mov");

            qtdemux.OnPadAdded += cbPadAdded;
            videoDecodebin.OnPadAdded += cbPadAdded;
            audioDecodebin.OnPadAdded += cbPadAdded;

            b = pipeline.AddManyElements(filesrc, qtdemux, 
            		videoQueue, videoDecodebin, videoConvert, videoScale, d3dvideosink,
					audioQueue, audioDecodebin, audioConvert, audioResample, autoaudiosink);

            b = Gst.LinkElements(filesrc, qtdemux);
            b = Gst.LinkElements(qtdemux, videoQueue);
            b = Gst.LinkElements(qtdemux, audioQueue);

            b = Gst.LinkManyElements(videoQueue, videoDecodebin, videoConvert, videoScale, d3dvideosink);
            b = Gst.LinkManyElements(audioQueue, audioDecodebin, audioConvert, audioResample, autoaudiosink);

            IntPtr windowHandle = new System.Windows.Interop.WindowInteropHelper(this).Handle;
            d3dvideosink.SetVideoOverlayWindowHandle(windowHandle);

            bus = pipeline.GetBus();
            bus.OnBusMessage += cbBusMessage;

            pipeline.SetState(GstState.GST_STATE_PLAYING);
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            pipeline.SetState(GstState.GST_STATE_PAUSED);

            qtdemux.OnPadAdded -= cbPadAdded;
            videoDecodebin.OnPadAdded -= cbPadAdded;
            audioDecodebin.OnPadAdded -= cbPadAdded;

            bus.OnBusMessage -= cbBusMessage;
            bus.Dispose();

            pipeline.SetState(GstState.GST_STATE_NULL);

            filesrc.Dispose();
            qtdemux.Dispose();
            videoQueue.Dispose();
            videoDecodebin.Dispose();
            videoConvert.Dispose();
            videoScale.Dispose();
            d3dvideosink.Dispose();
            audioQueue.Dispose();
            audioDecodebin.Dispose();
            audioConvert.Dispose();
            audioResample.Dispose();
            autoaudiosink.Dispose();
            pipeline.Dispose();
        }
    }
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Sample code 5: Compressing a video with H.264 and saving it to a file
//
//                videotestsrc - x264enc - mp4mux - filesink
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

using RStreamer;

namespace Test
{
    public partial class Window5 : Window
    {
        GstPipeline pipeline;
        GstElement videotestsrc;
        GstElement x264enc;
        GstElement mp4mux;
        GstElement filesink;

        public Window5()
        {
            InitializeComponent();
            
            Gst.Init();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            bool b;

            pipeline = Gst.MakePipeline("pipeline");

            videotestsrc = Gst.MakeElement("videotestsrc", "videotestsrc");
            x264enc = Gst.MakeElement("x264enc", "x264enc");
            mp4mux = Gst.MakeElement("mp4mux", "mp4mux");
            filesink = Gst.MakeElement("filesink", "filesink");

            b = pipeline.AddManyElements(videotestsrc, x264enc, mp4mux, filesink);

            b = Gst.LinkManyElements(videotestsrc, x264enc, mp4mux, filesink);

            filesink.SetProperty("location", "C:/Videos/result.mp4");

            pipeline.SetState(GstState.GST_STATE_PLAYING);

            System.Threading.Thread.Sleep(3000);

            GstEvent evEOS = Gst.MakeEventEOS();
            pipeline.SendEvent(evEOS);
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            pipeline.SetState(GstState.GST_STATE_PAUSED);

            pipeline.SetState(GstState.GST_STATE_NULL);

            videotestsrc.Dispose();
            x264enc.Dispose();
            mp4mux.Dispose();
            filesink.Dispose();
            pipeline.Dispose();
        }
    }
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Sample code 6: Capturing a network RTSP H.264 video stream from an IP Camera and displaying it in a window
//
//                rtspsrc - rtph264depay - h264parse - decodebin - d3dvideosink
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

using RStreamer;

namespace Test
{
    public partial class Window6 : Window
    {
        GstPipeline pipeline;

        GstElement rtspsrc;
        GstElement rtph264depay;
        GstElement h264parse;
        GstElement decodebin;
        GstElement d3dvideosink;

        public Window6()
        {
            InitializeComponent();
            
            Gst.Init();
        }

        public void cbPadAdded(GstElement source, GstPad pad)
        {
            if (source.Handle == rtspsrc.Handle)
            {
                GstPad sinkPad = rtph264depay.GetStaticPad("sink");
                GstPadLinkReturn ret = Gst.LinkPads(pad, sinkPad);
                sinkPad.Dispose();
            }
            else if (source.Handle == decodebin.Handle)
            {
                GstPad sinkPad = d3dvideosink.GetStaticPad("sink");
                GstPadLinkReturn ret = Gst.LinkPads(pad, sinkPad);
                sinkPad.Dispose();
            }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            bool b;

            pipeline = Gst.MakePipeline("pipeline");

            rtspsrc = Gst.MakeElement("rtspsrc", "rtspsrc");
            rtph264depay = Gst.MakeElement("rtph264depay", "rtph264depay");
            h264parse = Gst.MakeElement("h264parse", "h264parse");
            decodebin = Gst.MakeElement("decodebin", "decodebin");
            d3dvideosink = Gst.MakeElement("d3dvideosink", "d3dvideosink");

            rtspsrc.SetProperty("location", 
            		"rtsp://login:password@192.168.2.10/onvif-media/media.amp?profile=profile_1_h264");
            rtspsrc.SetProperty("latency", 0);

            pipeline.AddManyElements(rtspsrc, rtph264depay, h264parse, decodebin, d3dvideosink);

            rtspsrc.OnPadAdded += cbPadAdded;
            decodebin.OnPadAdded += cbPadAdded;

            b = Gst.LinkManyElements(rtspsrc, rtph264depay, h264parse, decodebin, d3dvideosink);

            IntPtr windowHandle = new System.Windows.Interop.WindowInteropHelper(this).Handle;
            d3dvideosink.SetVideoOverlayWindowHandle(windowHandle);

            pipeline.SetState(GstState.GST_STATE_PLAYING);
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            pipeline.SetState(GstState.GST_STATE_PAUSED);

            rtspsrc.OnPadAdded -= cbPadAdded;
            decodebin.OnPadAdded -= cbPadAdded;

            d3dvideosink.SetVideoOverlayWindowHandle(IntPtr.Zero);

            pipeline.SetState(GstState.GST_STATE_NULL);

            rtspsrc.Dispose();
            rtph264depay.Dispose();
            h264parse.Dispose();
            decodebin.Dispose();
            d3dvideosink.Dispose();

            pipeline.Dispose();
        }
    }
}

Untitled Document
About Contact
© Rogue Stream