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, (_, __) => { }); }
bool on_event(Gst.Pad pad, Gst.Event evnt) { if (evnt.Type == Gst.EventType.Eos) { this.PostMessage(Message.NewEos(this)); } return(true); }
public ExampleVolume() { Volume = 0.5; _sink = new Pad(__sinkTemplate, "sink"); _sink.ChainFunctionFull = Chain; _sink.Flags |= PadFlags.ProxyCaps; AddPad(_sink); _src = new Pad(__srcTemplate, "src"); _src.Flags |= PadFlags.ProxyCaps; AddPad(_src); }
FlowReturn Chain(Pad pad, Gst.Object parent, Gst.Buffer buffer) { if (Volume == 1.0) { return _src.Push(buffer); } buffer.MakeWritable(); MapInfo mapInfo; buffer.Map(out mapInfo, MapFlags.Read | MapFlags.Write); ScaleInt16(mapInfo.DataPtr, mapInfo.Size / 2, Volume); buffer.Unmap(mapInfo); return _src.Push(buffer); }
private void HandleTag (Pad pad, TagList tag_list) { foreach (string tag in tag_list.Tags) { if (String.IsNullOrEmpty (tag)) { continue; } if (tag_list.GetTagSize (tag) < 1) { continue; } List tags = tag_list.GetTag (tag); foreach (object o in tags) { OnTagFound (new StreamTag () { Name = tag, Value = o }); } } }
void RemoveReplayGain (Pad pad, bool blocked) { lock (pipeline_lock) { if (rgvolume != null) { first = rgvolume.GetStaticPad ("src").Peer.Parent as Element; rgvolume.Unlink (first); rgvolume.SetState (State.Null); Remove (rgvolume); rgvolume = null; visible_sink.SetTarget (first.GetStaticPad ("sink")); } } visible_sink.SetBlocked (false, (_, __) => { }); }
PadProbeReturn RemoveReplayGain(Pad pad, PadProbeInfo info) { lock (pipeline_lock) { if (rgvolume != null) { first = rgvolume.GetStaticPad ("src").Peer.Parent as Element; rgvolume.Unlink (first); rgvolume.SetState (State.Null); Remove (rgvolume); rgvolume = null; visible_sink.SetTarget (first.GetStaticPad ("sink")); } } return PadProbeReturn.Remove; }
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; }
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; }
bool EventProbe (Pad pad, Event padEvent) { switch (padEvent.Type) { case EventType.FlushStart: case EventType.FlushStop: case EventType.Seek: case EventType.NewSegment: case EventType.CustomDownstream: vis_thawing = true; break; } if (active) return true; switch (padEvent.Type) { case EventType.Eos: case EventType.CustomDownstreamOob: Blocked = false; break; case EventType.NewSegment: case EventType.CustomDownstream: Blocked = true; break; } return true; }
private void BlockCallback (Pad pad, bool blocked) { if (!blocked) { // Set thawing mode (discards buffers that are too old from the queue). vis_thawing = true; } }
Gst.FlowReturn on_chain(Gst.Pad pad, Gst.Buffer buffer) { Assert.IsNotNull(buffer); return(Gst.FlowReturn.Ok); }
protected bool AddPad (Pad p) { bool ret = gst_element_add_pad (this.Handle, p == null ? IntPtr.Zero : p.Handle); if (ret) g_object_ref (p.Handle); return ret; }