public static void Main(string[] args)
        {
            // Initialize GStreamer
            Application.Init (ref args);

            // Build the pipeline
            var pipeline = Parse.Launch ("playbin uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm");

            // Create the elements inside the sink bin
            var equalizer = ElementFactory.Make ("equalizer-3bands", "equalizer");
            var convert = ElementFactory.Make ("audioconvert", "convert");
            var sink = ElementFactory.Make ("autoaudiosink", "audio_sink");
            if (equalizer == null || convert == null || sink == null) {
                Console.WriteLine ("Not all elements could be created.");
                return;
            }

            // Create the sink bin, add the elements and link them
            var bin = new Bin ("audio_sink_bin");
            bin.Add (equalizer, convert, sink);
            Element.Link (equalizer, convert, sink);
            var pad = equalizer.GetStaticPad ("sink");
            var ghostPad = new GhostPad ("sink", pad);
            ghostPad.SetActive (true);
            bin.AddPad (ghostPad);

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

            // Configure the equalizer
            equalizer ["band1"] = (double)-24.0;
            equalizer ["band2"] = (double)-24.0;

            // Set playbin2's audio sink to be our sink bin
            pipeline ["audio-sink"] = bin;

            // Wait until error or EOS
            var bus = pipeline.Bus;
            var msg = bus.TimedPopFiltered (Constants.CLOCK_TIME_NONE, MessageType.Error | MessageType.Eos);

            // Free resources
            pipeline.SetState (State.Null);
        }
Beispiel #2
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);
            }
Beispiel #3
0
    public MyBin () : base () {
      Element filesrc = ElementFactory.Make ("filesrc");
      Add (filesrc);
      CollectionAssert.IsEmpty (Pads);

      GhostPad pad1 = new GhostPad ("ghost-sink", PadDirection.Sink);
      GhostPad pad2 = new GhostPad ("ghost-src", new PadTemplate ("src-template", PadDirection.Src, PadPresence.Request, Caps.NewAny()));

      Assert.IsFalse (pad1.SetTarget (filesrc.GetStaticPad ("src")));
      Assert.IsTrue (pad2.SetTarget (filesrc.GetStaticPad ("src")));

      AddPad (pad1);
      AddPad (pad2);

      CollectionAssert.Contains (Pads, pad1);
      CollectionAssert.Contains (Pads, pad2);
      CollectionAssert.Contains (SinkPads, pad1);
      CollectionAssert.Contains (SrcPads, pad2);
    }