Esempio n. 1
0
    void OnPadAdded(object o, PadAddedArgs args)
    {
        Console.WriteLine("Entered OnPadAdded");
        Pad sinkpad = decoder.GetStaticPad("sink");

        args.Pad.Link(sinkpad);
    }
        static void PadAddedCb(object o, PadAddedArgs args)
        {
            if (_linked)
            {
                return;
            }
            var src = (Element)o;
            var pad = args.NewPad;

            var caps = pad.CurrentCaps;
            var s    = caps.GetStructure(0);
            var name = s.Name;

            if (name.StartsWith("video/x-raw"))
            {
                var sinkpad = _conv.GetStaticPad("sink");
                Console.WriteLine(String.Format("Received new pad '{0}' from '{1}':", pad.Name, src.Name));

                if (pad.Link(sinkpad) != PadLinkReturn.Ok)
                {
                    "Failed to link dbin with conb".PrintErr();
                    _loop.Quit();
                }
                sinkpad.Dispose();
                _dbinSrcpad = (Pad)pad.Ref();
                GLib.Timeout.AddSeconds(5, TimeoutCb);
                _linked = true;
            }
            caps.Dispose();
        }
Esempio n. 3
0
        private void OnPadAdded(object sender, PadAddedArgs args)
        {
            var src    = (Element)sender;
            var newPad = args.NewPad;

            var newPadCaps   = newPad.CurrentCaps;
            var newPadStruct = newPadCaps.GetStructure(0);
            var newPadType   = newPadStruct.Name;

            if (newPadType.StartsWith("audio/x-raw"))
            {
                Pad sinkPad = _audioConvert.GetStaticPad("sink");
                Log($"Received new pad '{newPad.Name}' from '{ src.Name}':", LogLevelFlags.Debug);

                if (sinkPad.IsLinked)
                {
                    Log("We are already linked, ignoring", LogLevelFlags.Warning);
                    return;
                }

                var ret = newPad.Link(sinkPad);

                if (ret != PadLinkReturn.Ok)
                {
                    Log($"Type is {newPadType} but link failed", LogLevelFlags.Error);
                }

                sinkPad.Dispose();
            }
            else if (newPadType.StartsWith("video/x-raw"))
            {
                Pad sinkPad = _videoConvert.GetStaticPad("sink");
                Log($"Received new pad '{newPad.Name}' from '{ src.Name}':", LogLevelFlags.Debug);

                if (sinkPad.IsLinked)
                {
                    Log("We are already linked, ignoring", LogLevelFlags.Warning);
                    return;
                }

                var ret = newPad.Link(sinkPad);

                if (ret != PadLinkReturn.Ok)
                {
                    Log($"Type is {newPadType} but link failed", LogLevelFlags.Error);
                }

                sinkPad.Dispose();
            }
            else
            {
                Log($"It has type '{newPadType}' which is not raw audio or video. Ignoring.", LogLevelFlags.Debug);
                return;
            }

            newPadCaps.Dispose();
            newPadStruct.Dispose();
            newPad.Dispose();
        }
Esempio n. 4
0
        static void OnPadAdded(object sender, PadAddedArgs args)
        {
            var src    = (Element)sender;
            var newPad = args.NewPad;

            var newPadCaps   = newPad.CurrentCaps;
            var newPadStruct = newPadCaps.GetStructure(0);
            var newPadType   = newPadStruct.Name;

            if (newPadType.StartsWith("audio/x-raw"))
            {
                Pad sinkPad = audioConvert.GetStaticPad("sink");
                Console.WriteLine(String.Format("Received new pad '{0}' from '{1}':", newPad.Name, src.Name));

                if (sinkPad.IsLinked)
                {
                    Console.WriteLine("We are already linked, ignoring");
                    return;
                }

                var ret = newPad.Link(sinkPad);
                if (ret == PadLinkReturn.Ok)
                {
                    Console.WriteLine($"Link succeeded type {newPadType}");
                }
                else
                {
                    Console.WriteLine($"Type is {newPadType} but link failed");
                }
            }
            else if (newPadType.StartsWith("video/x-raw"))
            {
                Pad sinkPad = videoConvert.GetStaticPad("sink");
                Console.WriteLine(String.Format("Received new pad '{0}' from '{1}':", newPad.Name, src.Name));
                if (sinkPad.IsLinked)
                {
                    Console.WriteLine("We are already linked, ignoring");
                    return;
                }
                var ret = newPad.Link(sinkPad);
                if (ret == PadLinkReturn.Ok)
                {
                    Console.WriteLine($"Link succeeded type {newPadType}");
                }
                else
                {
                    Console.WriteLine($"Type is {newPadType} but link failed");
                }
            }
            else
            {
                Console.WriteLine($"It has type '{newPadType}' which is not raw audio or video. Ignoring.");
                return;
            }
        }
Esempio n. 5
0
 private void uriDecodeBin_PadAdded(object o, PadAddedArgs args)
 {
     System.Diagnostics.Debug.WriteLine("uriDecodeBin_PadAdded: called with new pad named: " + args.NewPad.Name);
     
     // a pad has been added to the source so we need to link it to the rest of the pipeline to ultimately display it onscreen
     Pad sinkPad = videoSink.GetStaticPad("sink");   // get the pad for the one we have recieved  so we can link to the depayloader element
     System.Diagnostics.Debug.WriteLine("uriDecodeBin_PadAdded: queue pad returned: " + sinkPad.Name);
     PadLinkReturn ret = args.NewPad.Link(sinkPad);
     
     System.Diagnostics.Debug.WriteLine("uriDecodeBin_PadAdded: link attempt returned: " + ret.ToString());
 }
Esempio n. 6
0
        static void PadAddedCb(object o, PadAddedArgs args)
        {
            if (_linked)
            {
                return;
            }
            var src = (Element)o;
            var pad = args.NewPad;

            using (var caps = pad.CurrentCaps)
            {
                var s    = caps.GetStructure(0);
                var name = s.Name;
                if (!name.StartsWith("video/x-raw"))
                {
                    return;
                }

                using (var sinkPad = _conv.GetStaticPad("sink"))
                {
                    if (pad.Link(sinkPad) != PadLinkReturn.Ok)
                    {
                        "Failed to link dbin with conb".PrintErr();
                        _loop.Quit();
                        return;
                    }
                }

                PadTemplate templ  = _tee.GetPadTemplate("src_%u");
                Pad         teePad = _tee.RequestPad(templ);
                var         queue  = ElementFactory.Make("queue");
                var         sink   = ElementFactory.Make("fakesink");
                sink["sync"] = true;

                _pipeline.Add(queue, sink);
                Element.Link(queue, sink);

                using (var sinkPad = queue.GetStaticPad("sink"))
                {
                    teePad.Link(sinkPad);
                }
                GLib.Timeout.AddSeconds(3, TickCb);
                _linked = true;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Fired after data starts flowing through pipeline and stream type is detected.
        /// </summary>
        /// <param name="o"></param>
        /// <param name="args"></param>
        private void cb_binDecPadAdded(object o, PadAddedArgs args)
        {
            sysDbg.WriteLine("Decode bin pad added.");

            var newPad = args.NewPad;

            if (newPad.IsLinked)
            {
                return;
            }

            Pad nextPad;

            if (padOverlay0 == null)
            {
                nextPad = mTee?.GetStaticPad("sink");
            }
            else
            {
                nextPad = padOverlay0;
            }

            if (nextPad.IsLinked)
            {
                if (!nextPad.Peer.Unlink(nextPad))
                {
                    sysDbg.WriteLine("Failed to unlink.");
                }
            }

            var ret = newPad.Link(nextPad);

            if (ret != PadLinkReturn.Ok)
            {
                sysDbg.WriteLine("Error linking decode bin to tee: " + ret.ToString());
            }
            // Add overlay elements.
            padOverlay0 = nextPad;
        }
Esempio n. 8
0
        /// <summary>
        /// Fired after pipeline enters paused state for rtspsrc, or other sources where the codec/type isn't known until playing.
        /// Try to link to DecodeBin.
        /// </summary>
        /// <param name="o"></param>
        /// <param name="args"></param>
        private void cb_binSrcPadAdded(object o, PadAddedArgs args)
        {
            var src    = (Element)o;
            var newPad = args.NewPad;

            try
            {
                if (padSrcBinSource != null)
                {
                    if (!padSrcBinSource.Unlink(binDecode.GetStaticPad("sink")))
                    {
                        sysDbg.WriteLine("Failed to unlink decode bin.");
                    }
                    if (!binSource.RemovePad(padSrcBinSource))
                    {
                        sysDbg.WriteLine("failed to remove existing source pad.");
                    }
                    padSrcBinSource.Unref();
                }

                padSrcBinSource = new GhostPad("srcPad", newPad);
                binSource.AddPad(padSrcBinSource);
            }
            catch (Exception ex)
            {
                sysDbg.WriteLine("Failed adding a pad: " + ex.Message);
            }

            if (!padSrcBinSource.IsLinked)
            {
                Pad bindecpad = binDecode.GetStaticPad("sink");
                var ret       = padSrcBinSource.Link(binDecode.GetStaticPad("sink"));
                if (ret != PadLinkReturn.Ok)
                {
                    sysDbg.WriteLine("Error linking to decbin " + ret.ToString());
                }
            }
        }
        static void HandlePadAdded(object o, PadAddedArgs args)
        {
            var src     = (Element)o;
            var newPad  = args.NewPad;
            var sinkPad = convert.GetStaticPad("sink");

            Console.WriteLine(string.Format("Received new pad '{0}' from '{1}':", newPad.Name, src.Name));

            // If our converter is already linked, we have nothing to do here
            if (sinkPad.IsLinked)
            {
                Console.WriteLine("We are already linked. Ignoring.");
                return;
            }

            // Check the new pad's type
            var newPadCaps   = newPad.Caps;
            var newPadStruct = newPadCaps.GetStructure(0);
            var newPadType   = newPadStruct.Name;

            if (!newPadType.StartsWith("audio/x-raw"))
            {
                Console.WriteLine("It has type '{0}' which is not raw audio. Ignoring.", newPadType);
                return;
            }

            // Attempt the link
            var ret = newPad.Link(sinkPad);

            if (ret != PadLinkReturn.Ok)
            {
                Console.WriteLine("Type is '{0} but link failed.", newPadType);
            }
            else
            {
                Console.WriteLine("Link succeeded (type '{0}').", newPadType);
            }
        }
Esempio n. 10
0
        private void OnPadAdded(object sender, PadAddedArgs args)
        {
            Caps      caps;
            Structure str;
            Pad       audiopad;

            audiopad = sink_bin.GetStaticPad("sink");

            if (audiopad.IsLinked)
            {
                return;
            }

            caps = args.Pad.Caps;
            str  = caps [0];

            if (!str.Name.Contains("audio"))
            {
                return;
            }

            args.Pad.Link(audiopad);
        }
Esempio n. 11
0
        // Called after pipeline state is set to playing
        private void RTSPPadAdded(object o, PadAddedArgs args)
        {
            Pad Sink = runningPipeline.Depay.GetStaticPad("sink");

            args.NewPad.Link(Sink);
        }