Link() public static method

public static Link ( ) : bool
return bool
Ejemplo n.º 1
1
 void InsertReplayGain (Pad pad, bool blocked)
 {
     lock (pipeline_lock) {
         if (rgvolume == null) {
             rgvolume = ElementFactory.Make ("rgvolume", "rgvolume");
             Add (rgvolume);
             rgvolume.SyncStateWithParent ();
             visible_sink.SetTarget (rgvolume.GetStaticPad ("sink"));
             rgvolume.Link (first);
             first = rgvolume;
         }
     }
     visible_sink.SetBlocked (false, (_, __) => { });
 }
Ejemplo n.º 2
0
        public BpmDetector()
        {
            try {
                pipeline = new Pipeline ("the pipeline");
                filesrc          = ElementFactory.Make ("filesrc", "the filesrc");
                var decodebin    = ElementFactory.Make ("decodebin", "the decodebin");
                var audioconvert = Make ("audioconvert");
                var bpmdetect    = Make ("bpmdetect");
                fakesink         = ElementFactory.Make ("fakesink", "the fakesink");

                pipeline.Add (filesrc, decodebin, audioconvert, bpmdetect, fakesink);

                if (!filesrc.Link (decodebin)) {
                    Log.Error ("Could not link pipeline elements");
                    throw new Exception ();
                }

                // decodebin and audioconvert are linked dynamically when the decodebin creates a new pad
                decodebin.PadAdded += (o,args) => {
                    var audiopad = audioconvert.GetStaticPad ("sink");
                    if (audiopad.IsLinked) {
                        return;
                    }

                    var caps = args.NewPad.QueryCaps ();
                    if (caps == null)
                        return;

                    var str = caps[0];
                    if (!str.Name.Contains ("audio"))
                        return;

                    args.NewPad.Link (audiopad);
                };

                if (!Element.Link (audioconvert, bpmdetect, fakesink)) {
                    Log.Error ("Could not link pipeline elements");
                    throw new Exception ();
                }
                pipeline.Bus.AddWatch (OnBusMessage);
            } catch (Exception e) {
                Log.Exception (e);
                throw new ApplicationException (Catalog.GetString ("Could not create BPM detection driver."), e);
            }
        }
Ejemplo n.º 3
0
        private void SetupRecordingPipeline()
        {
            // set up pipeline and elements
            // gst-launch-0.10 autoaudiosrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=dump.ogg
            // Create new pipeline.

            _pipeline = new Gst.Pipeline();

            //Pipeline pipeline = new Pipeline("pipeline");

            // Construct pipeline filesrc -> avidemux -> mpeg4 -> directdrawsink

            //_eleAudioSource = ElementFactory.Make("autoaudiosrc", "autoaudiosrc");
            _eleAudioSource  = ElementFactory.Make("pulsesrc");
            _eleAudioConvert = ElementFactory.Make("audioconvert");
            if (_recordOgg)
            {
                _eleVorbisEnc = ElementFactory.Make("vorbisenc");
                _eleOggMux    = ElementFactory.Make("oggmux");
            }
            else
            {
                _eleWavPack = ElementFactory.Make("wavpackenc");
            }
            _eleFileSink = new Gst.CorePlugins.FileSink();
            //_eleFileSink = ElementFactory.Make("filesink", "filesink");
            _eleFileSink ["location"] = _path;

            // Add and link pipeline.
            if (_recordOgg)
            {
                _pipeline.Add(_eleAudioSource, _eleAudioConvert, _eleVorbisEnc, _eleOggMux, _eleFileSink);
            }
            else
            {
                _pipeline.Add(_eleAudioSource, _eleAudioConvert, _eleWavPack, _eleFileSink);
            }

            // Play video.
            _pipeline.SetState(Gst.State.Ready);
            _pipeline.SetState(Gst.State.Paused);

            if (!_eleAudioSource.Link(_eleAudioConvert))
            {
                Console.WriteLine("link failed between source and converter");
            }
            if (_recordOgg)
            {
                if (!_eleAudioConvert.Link(_eleVorbisEnc))
                {
                    Console.WriteLine("link failed between converter and encoder");
                }

                if (!_eleVorbisEnc.Link(_eleOggMux))
                {
                    Console.WriteLine("link failed between e and parser");
                }

                if (!_eleOggMux.Link(_eleFileSink))
                {
                    Console.Error.WriteLine("link failed between parser and sink");
                }
            }
            else
            {
                if (!_eleAudioConvert.Link(_eleWavPack))
                {
                    Console.WriteLine("link failed between converter and encoder");
                }

                if (!_eleWavPack.Link(_eleFileSink))
                {
                    Console.Error.WriteLine("link failed between encoder and sink");
                }
            }

            _recordInit = true;
        }
Ejemplo n.º 4
0
            public AudioSinkBin (string elementName) : base(elementName)
            {
                hw_audio_sink = SelectAudioSink ();
                Add (hw_audio_sink);
                first = hw_audio_sink;

                // Our audio sink is a tee, so plugins can attach their own pipelines
                audiotee = ElementFactory.Make ("tee", "audiotee") as Tee;
                if (audiotee == null) {
                    Log.Error ("Can not create audio tee!");
                } else {
                    Add (audiotee);
                }

                volume = FindVolumeProvider (hw_audio_sink);
                if (volume != null) {
                    // If the sink provides its own volume property we assume that it will
                    // also save that value across program runs.  Pulsesink has this behaviour.
                    VolumeNeedsSaving = false;
                } else {
                    volume = ElementFactory.Make ("volume", "volume");
                    VolumeNeedsSaving = true;
                    Add (volume);
                    volume.Link (hw_audio_sink);
                    first = volume;
                }

                equalizer = ElementFactory.Make ("equalizer-10bands", "equalizer-10bands");
                if (equalizer != null) {
                    Element eq_audioconvert = ElementFactory.Make ("audioconvert", "audioconvert");
                    Element eq_audioconvert2 = ElementFactory.Make ("audioconvert", "audioconvert2");
                    preamp = ElementFactory.Make ("volume", "preamp");

                    Add (eq_audioconvert, preamp, equalizer, eq_audioconvert2);
                    Element.Link (eq_audioconvert, preamp, equalizer, eq_audioconvert2, first);

                    first = eq_audioconvert;
                    Log.Debug ("Built and linked Equalizer");
                }

                // Link the first tee pad to the primary audio sink queue
                Pad sinkpad = first.GetStaticPad ("sink");
                Pad pad = audiotee.GetRequestPad ("src%d");
                audiotee.AllocPad = pad;
                pad.Link (sinkpad);
                first = audiotee;

                visible_sink = new GhostPad ("sink", first.GetStaticPad ("sink"));
                AddPad (visible_sink);
            }
Ejemplo n.º 5
0
 PadProbeReturn InsertReplayGain(Pad pad, PadProbeInfo info)
 {
     lock (pipeline_lock) {
         if (rgvolume == null) {
             rgvolume = ElementFactory.Make ("rgvolume", "rgvolume");
             Add (rgvolume);
             rgvolume.SyncStateWithParent ();
             visible_sink.SetTarget (rgvolume.GetStaticPad ("sink"));
             rgvolume.Link (first);
             first = rgvolume;
         }
     }
     return PadProbeReturn.Remove;
 }
Ejemplo n.º 6
0
    static void MakePipeline()
    {
        Element decodebin;

        if (pipeline != null)
            pipeline.Dispose ();

        pipeline = new Pipeline (String.Empty);
        source = ElementFactory.Make ("filesrc", "source");
        decodebin = ElementFactory.Make ("decodebin", "decodebin");

        if (pipeline == null)
            Console.WriteLine ("Pipeline could not be created");
        if (source == null)
            Console.WriteLine ("Element filesrc could not be created");
        if (decodebin == null)
            Console.WriteLine ("Element decodebin could not be created");

        Bin bin = (Bin) pipeline;
        bin.AddMany (source, decodebin);

        if (!source.Link (decodebin))
            Console.WriteLine ("filesrc could not be linked with decodebin");

        //decodebin.Dispose ();
    }
Ejemplo n.º 7
0
  private void ConstructPipeline() {
    pipeline = new Pipeline ("pipeline");

    filesrc = ElementFactory.Make ("filesrc", "filesrc") as FileSrc;
    filesink = ElementFactory.Make ("filesink", "filesink") as FileSink;
    audioconvert = ElementFactory.Make ("audioconvert", "audioconvert");
    encoder = ElementFactory.Make ("wavenc", "wavenc");
    decodebin = ElementFactory.Make ("decodebin2", "decodebin") as DecodeBin2;
    decodebin.NewDecodedPad += OnNewDecodedPad;

    pipeline.Add (filesrc, decodebin, audioconvert, encoder, filesink);

    filesrc.Link (decodebin);
    audioconvert.Link (encoder);
    encoder.Link (filesink);

    pipeline.Bus.AddWatch (new BusFunc (OnBusMessage));
  }
Ejemplo n.º 8
0
		private void SetupRecordingPipeline ()
		{
			// set up pipeline and elements
			// gst-launch-0.10 autoaudiosrc ! audioconvert ! vorbisenc ! oggmux ! filesink location=dump.ogg
			// Create new pipeline.

			_pipeline = new Gst.Pipeline ();

			//Pipeline pipeline = new Pipeline("pipeline");

			// Construct pipeline filesrc -> avidemux -> mpeg4 -> directdrawsink

			//_eleAudioSource = ElementFactory.Make("autoaudiosrc", "autoaudiosrc");
			_eleAudioSource = ElementFactory.Make ("pulsesrc");
			_eleAudioConvert = ElementFactory.Make ("audioconvert");
			if (_recordOgg) {
				_eleVorbisEnc = ElementFactory.Make ("vorbisenc");
				_eleOggMux = ElementFactory.Make ("oggmux");
			} else {
				_eleWavPack = ElementFactory.Make ("wavpackenc");
			}
			_eleFileSink = new Gst.CorePlugins.FileSink ();
			//_eleFileSink = ElementFactory.Make("filesink", "filesink");
			_eleFileSink ["location"] = _path;

			// Add and link pipeline.
			if (_recordOgg) {
				_pipeline.Add (_eleAudioSource, _eleAudioConvert, _eleVorbisEnc, _eleOggMux, _eleFileSink);
			} else {
				_pipeline.Add (_eleAudioSource, _eleAudioConvert, _eleWavPack, _eleFileSink);
			}

			// Play video.
			_pipeline.SetState (Gst.State.Ready);
			_pipeline.SetState (Gst.State.Paused);

			if (!_eleAudioSource.Link (_eleAudioConvert)) {
				Console.WriteLine ("link failed between source and converter");
			}
			if (_recordOgg) {
				if (!_eleAudioConvert.Link (_eleVorbisEnc)) {
					Console.WriteLine ("link failed between converter and encoder");
				}

				if (!_eleVorbisEnc.Link (_eleOggMux)) {
					Console.WriteLine ("link failed between e and parser");
				}

				if (!_eleOggMux.Link (_eleFileSink)) {
					Console.Error.WriteLine ("link failed between parser and sink");
				}
			} else {

				if (!_eleAudioConvert.Link (_eleWavPack)) {
					Console.WriteLine ("link failed between converter and encoder");
				}

				if (!_eleWavPack.Link (_eleFileSink)) {
					Console.Error.WriteLine ("link failed between encoder and sink");
				}
			}

			_recordInit = true;
		}
Ejemplo n.º 9
0
        private void CreatePipeline()
        {

            m_Pipeline = new Pipeline("test-pipeline");

            //m_Source = Gst.Parse.Launch("playbin uri=http://ftp.nluug.nl/ftp/graphics/blender/apricot/trailer/Sintel_Trailer1.1080p.DivX_Plus_HD.mkv"); 



            m_Source = Gst.ElementFactory.Make("videotestsrc","source");

            m_Source["pattern"] = 18; // Example of setting element properties



            m_Sink = Gst.ElementFactory.Make("autovideosink", "sink");



            m_Pipeline.Add(m_Source, m_Sink);

            m_Source.Link(m_Sink);

        }
Ejemplo n.º 10
0
        public static void Main(string[] args)
        {
            // Initialize Gstreamer
            Application.Init(ref args);

            // Create the elements
            source = ElementFactory.Make ("uridecodebin", "source");
            convert = ElementFactory.Make ("audioconvert", "convert");
            sink = ElementFactory.Make ("autoaudiosink", "sink");

            // Create the empty pipeline
            pipeline = new Pipeline ("test-pipeline");

            if (source == null || convert == null || sink == null || pipeline == null) {
                Console.WriteLine ("Not all elements could be created");
                return;
            }

            // Build the pipeline. Note that we are NOT linking the source at this point.
            // We will do it later.
            pipeline.Add (source, convert, sink);
            if (!convert.Link (sink)) {
                Console.WriteLine ("Elements could not be linked");
                return;
            }

            // Set the URI to play
            source ["uri"] = "http://download.blender.org/durian/trailer/sintel_trailer-1080p.mp4";

            // Connect to the pad-added signal
            source.PadAdded += HandlePadAdded;

            // Start playing
            var ret = pipeline.SetState (State.Playing);
            if (ret == StateChangeReturn.Failure) {
                Console.WriteLine ("Unable to set the pipeline to the playing state.");
                return;
            }

            // Listen to the bus
            var bus = pipeline.Bus;
            bool terminated = false;
            do {
                var msg = bus.TimedPopFiltered (Constants.CLOCK_TIME_NONE, MessageType.StateChanged | MessageType.Error | MessageType.Eos);

                if (msg != null) {
                    switch (msg.Type) {
                    case MessageType.Error:
                        string debug;
                        GLib.GException exc;
                        msg.ParseError (out exc, out debug);
                        Console.WriteLine (string.Format ("Error received from element {0}: {1}", msg.Src.Name, exc.Message));
                        Console.WriteLine ("Debugging information: {0}", debug);
                        terminated = true;
                        break;
                    case MessageType.Eos:
                        Console.WriteLine("End-Of-Stream reached.");
                        terminated = true;
                        break;
                    case MessageType.StateChanged:
                        // We are only interested in state-changed messages from the pipeline
                        if (msg.Src == pipeline) {
                            State oldState, newState, pendingState;
                            msg.ParseStateChanged(out oldState, out newState, out pendingState);
                            Console.WriteLine ("Pipeline state changed from {0} to {1}:", Element.StateGetName(oldState), Element.StateGetName(newState));
                        }
                        break;
                    default:
                        // We should not reach here
                        Console.WriteLine ("Unexpected message received.");
                        break;
                    }
                }
            } while (!terminated);

            pipeline.SetState (State.Null);
        }