public void TestGetAllowedCaps() { Caps caps; Pad sink = new Pad ("sink", PadDirection.Sink); caps = sink.AllowedCaps; Assert.IsNull (caps); Pad src = new Pad ("src", PadDirection.Src); caps = src.AllowedCaps; Assert.IsNull (caps); caps = Caps.FromString ("foo/bar"); src.SetCaps (caps); sink.SetCaps (caps); PadLinkReturn plr = src.Link (sink); Assert.AreEqual (plr, PadLinkReturn.Ok); Caps gotcaps = src.AllowedCaps; Assert.IsNotNull (gotcaps); Assert.IsTrue (gotcaps.IsEqual (caps)); }
public void TestLink() { Pad src = new Pad ("source", PadDirection.Src); Assert.IsNotNull (src, "Pad could not be created"); string name = src.Name; Assert.AreEqual (name, "source"); Pad sink = new Pad ("sink", PadDirection.Sink); Assert.IsNotNull (sink, "Pad could not be created"); Assert.AreEqual (src.Link (sink), PadLinkReturn.Noformat); }
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; }