Beispiel #1
0
        /// <summary>
        /// Create the elements for rendering preview.
        /// </summary>
        /// <returns>true on success</returns>
        protected bool CreateElements()
        {
            sysDbg.WriteLine("Creating elements...");

            try
            {
                if (mDispSink == null)
                {
                    mDispSink = ElementFactory.Make("autovideosink", "videosink0");
                }
                GstUtilities.CheckError(mDispSink);

                mDispSink["sync"] = false;

                if (mQueueDisp == null)
                {
                    mQueueDisp = ElementFactory.Make("queue", "qDisp");
                }
                GstUtilities.CheckError(mQueueDisp);

                if (mTee == null)
                {
                    mTee = ElementFactory.Make("tee", "tee0");
                }
                GstUtilities.CheckError(mTee);
            }
            catch (Exception ex)
            {
                sysDbg.WriteLine("Error creating elements: " + ex.Message);
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes the Gstreamer pipeline and Glib loop.
        /// </summary>
        /// <returns></returns>
        public bool Connect()
        {
            GstUtilities.DetectGstPath();
            bool r = false;

            glibLoop   = new GLib.MainLoop();
            glibThread = new sysThread.Thread(glibLoop.Run)
            {
                IsBackground = true
            };

            if (pipeline == null)
            {
                pipelineCreated = this.SetupPipeline();
            }
            if (!pipelineCreated)
            {
                sysDbg.WriteLine("Error creating pipeline.");
            }
            StateChangeReturn ret = pipeline.SetState(State.Ready);

            r = pipelineCreated && (ret != StateChangeReturn.Failure);

            return(r);
        }
Beispiel #3
0
        /// <summary>
        /// Setup the source bin. This method can be overridden by inheriting classes for different sources.
        /// </summary>
        /// <returns>true on success</returns>
        protected virtual bool SetupSourceBin()
        {
            bool ret = true;

            CreateElements();

            // Empty the bin to start fresh.
            foreach (Element e in binSource.IterateElements())
            {
                binSource.Remove(e);
                e.Dispose();
                e.Unref();
            }

            if (padSrcBinSource != null)
            {
                padSrcBinSource.Unlink(binDecode.GetStaticPad("sink"));
                padSrcBinSource = null;
            }

            sysDbg.WriteLine("Creating rtsp source.");
            srcElt = ElementFactory.Make("rtspsrc", "rtspsrc");
            if (srcElt == null)
            {
                throw new YascElementNullException("failed to create rtspsrc.");
            }

            //srcElt["location"] = "rtsp://*****:*****@cameraxuanthuy.dyndns.org:30553/onvifStreaming?video=0&meta=0";
            srcElt["location"]        = "rtsp://*****:*****@localhost:8554/test";
            srcElt["drop-on-latency"] = true;
            srcElt["latency"]         = 0;

            srcElt.PadAdded += cb_binSrcPadAdded;
            ret             &= binSource.Add(srcElt);

            mTee = ElementFactory.Make("tee", "tee0");
            GstUtilities.CheckError(mTee);

            return(ret);
        }