/// <summary> /// Create a pipeline use gstreamer /// </summary> /// <returns> /// A <see cref="System.Boolean"/> /// </returns> private bool Make_Pipeline() { try{ pipeline = new Pipeline("pipeline"); // crear un elemento filesrc para leer el Archivo MP3 filesrc = ElementFactory.Make("filesrc", "filesrc"); // Crear un Mad Decodificador mad = ElementFactory.Make("mad", "mad"); // Crear el Audio Sink osssink = ElementFactory.Make("alsasink", "alsasink"); // Agregar los elementos al pipeline principal pipeline.Add(filesrc); pipeline.Add(mad); pipeline.Add(osssink); // Conectar los elementos filesrc.Link(mad); mad.Link(osssink); }catch (Exception e) { Console.WriteLine(e); } return(true); }
public void TestGetByName() { Bin bin = new Bin ("test-bin"); Element e1 = ElementFactory.Make ("fakesrc", "element-name"); bin.Add (e1); e1 = bin.GetByName ("element-name"); Assert.IsNotNull (e1); Assert.AreEqual (e1.Name, "element-name"); }
public void TestAdd() { Bin bin = new Bin ("test-bin"); Element e1 = new FakeSrc ("fakesrc"); Element e2 = new FakeSink ("fakesink"); Assert.IsNotNull (bin, "Could not create bin"); Assert.IsNotNull (e1, "Could not create fakesrc"); Assert.IsNotNull (e2, "Could not create fakesink"); bin.Add (e1, e2); Assert.AreEqual (bin.ChildrenCount, 2); }
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); }
public Visualization (Bin audiobin, Pad teepad) { // The basic pipeline we're constructing is: // .audiotee ! queue ! audioresample ! audioconvert ! fakesink Element converter, resampler; Queue audiosinkqueue; Pad pad; vis_buffer = null; vis_fft = gst_fft_f32_new (SLICE_SIZE * 2, false); vis_fft_buffer = new GstFFTF32Complex [SLICE_SIZE + 1]; vis_fft_sample_buffer = new float [SLICE_SIZE]; // Core elements, if something fails here, it's the end of the world audiosinkqueue = (Queue)ElementFactory.Make ("queue", "vis-queue"); pad = audiosinkqueue.GetStaticPad ("sink"); pad.AddEventProbe (new PadEventProbeCallback (EventProbe)); resampler = ElementFactory.Make ("audioresample", "vis-resample"); converter = ElementFactory.Make ("audioconvert", "vis-convert"); FakeSink fakesink = ElementFactory.Make ("fakesink", "vis-sink") as FakeSink; // channels * slice size * float size = size of chunks we want wanted_size = (uint)(2 * SLICE_SIZE * sizeof(float)); if (audiosinkqueue == null || resampler == null || converter == null || fakesink == null) { Log.Debug ("Could not construct visualization pipeline, a fundamental element could not be created"); return; } // Keep around the 5 most recent seconds of audio so that when resuming // visualization we have something to show right away. audiosinkqueue.Leaky = Queue.LeakyType.Downstream; audiosinkqueue.MaxSizeBuffers = 0; audiosinkqueue.MaxSizeBytes = 0; audiosinkqueue.MaxSizeTime = Clock.Second * 5; fakesink.Handoff += PCMHandoff; // This enables the handoff signal. fakesink.SignalHandoffs = true; // Synchronize so we see vis at the same time as we hear it. fakesink.Sync = true; // Drop buffers if they come in too late. This is mainly used when // thawing the vis pipeline. fakesink.MaxLateness = (long)(Clock.Second / 120); // Deliver buffers one frame early. This allows for rendering // time. (TODO: It would be great to calculate this on-the-fly so // we match the rendering time. fakesink.TsOffset = -(long)(Clock.Second / 60); // Don't go to PAUSED when we freeze the pipeline. fakesink.Async = false; audiobin.Add (audiosinkqueue, resampler, converter, fakesink); pad = audiosinkqueue.GetStaticPad ("sink"); teepad.Link (pad); Element.Link (audiosinkqueue, resampler, converter); converter.LinkFiltered (fakesink, caps); vis_buffer = new Adapter (); vis_resampler = resampler; vis_thawing = false; active = false; // Disable the pipeline till we hear otherwise from managed land. Blocked = true; }
public void TestElements() { Bin bin = new Bin ("test-bin"); Element [] elements = new Element [] { new CapsFilter(), new MultiQueue(), new Queue(), new Tee(), new TypeFindElement() }; bin.Add (elements); CollectionAssert.AreEquivalent (elements, bin.Elements); CollectionAssert.AreEquivalent (elements, bin.ElementsRecurse); CollectionAssert.AreEquivalent (elements, bin.ElementsSorted); }
public void TestGetChildByIndex() { Bin bin = new Bin ("test-bin"); Element [] elements = new Element [] { ElementFactory.Make ("fakesrc", "fakesrc"), ElementFactory.Make ("audioconvert", "audioconvert"), ElementFactory.Make ("wavenc", "wavenc"), ElementFactory.Make ("fakesink", "fakesink") }; foreach (Element element in elements) { bin.Add (element); } Assert.AreEqual (elements.Length, bin.ChildrenCount); for (uint i = 0; i < elements.Length; i++) { Assert.AreEqual (elements[elements.Length - i - 1], bin.GetChildByIndex (i)); } }