private PadProbeReturn SetNewTrackLocationBlocked(IntPtr pad, IntPtr probe_info, IntPtr user_data)
 {
     Hyena.ThreadAssist.Spawn(delegate() {
         //Hyena.Log.Information ("[Streamrecorder] changing location blocked" + (Hyena.ThreadAssist.InMainThread ? " in main thread" : " in new thread"));
         GCHandle gch          = GCHandle.FromIntPtr(user_data);
         object[] user_objects = (object[])gch.Target;
         PadProbeInfo info     = (PadProbeInfo)Marshal.PtrToStructure(probe_info, typeof(PadProbeInfo));
         Pad teepad            = new Pad((IntPtr)user_objects[0]);
         string new_location   = (string)user_objects [1];
         IntPtr active_pad     = (IntPtr)user_objects [2];
         encoder_bin.SendEvent(Marshaller.NewEOSEvent());
         encoder_bin.SetState(State.Null);
         if (encoder_bin.GetState() == StateChangeReturn.Success)
         {
             //Hyena.Log.Information ("[Streamrecorder] setting new location: " + new_location);
             file_sink.Location = new_location;
         }
         else
         {
             Hyena.Log.Debug("[Streamrecorder] State change failed");
         }
         encoder_bin.SetState(State.Playing);
         teepad.RemoveProbe(info.id);
         if (active_pad != IntPtr.Zero)
         {
             outputselector.SetProperty("active-pad", new Element(active_pad));
         }
         if (!new_location.Equals(empty_file))
         {
             Hyena.Log.Debug("[Streamrecorder] <SetNewTrackLocationBlocked> Recording started");
             is_recording = true;
         }
     });
     return(PadProbeReturn.GST_PAD_PROBE_OK);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
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.º 4
0
        /// <summary>
        /// Helper function to really remove the bin from the audio player tee
        /// </summary>
        /// <param name="pad">
        /// A <see cref="IntPtr"/> referencing the pad that may need to be unblocked
        /// </param>
        /// <param name="blocked">
        /// A <see cref="System.Boolean"/> indicating if the pad is blocked
        /// </param>
        /// <param name="user_data">
        /// A <see cref="IntPtr"/> containing a reference to the bin
        /// </param>
        private PadProbeReturn ReallyRemoveBin(IntPtr pad, IntPtr probe_info, IntPtr user_data, bool blocked)
        {
            Bin element = new Bin(user_data);

            Bin bin;
            Bin parent_bin;

            string element_path = element.GetPathString();

            if (!element_path.Contains(":") && element_path.StartsWith("/0x"))
            {
                Hyena.Log.Debug("[Streamrecorder.PlayerAudioTee]<ReallyRemoveBin> element empty, assume disposed, exiting: " + element_path);
                return(PadProbeReturn.GST_PAD_PROBE_OK);
            }

            bin = new Bin(element.GetParent().ToIntPtr());
            bin.Ref();

            parent_bin = new Bin(bin.GetParent().ToIntPtr());
            parent_bin.Remove(bin);

            bin.SetState(State.Null);
            bin.Remove(element);
            bin.UnRef();

            attached = false;

            /* if we're supposed to be playing, unblock the sink */
            if (blocked)
            {
                Hyena.Log.Debug("[Streamrecorder.PlayerAudioTee]<ReallyRemoveBin> unblocking pad after removing tee");
//                new Pad (pad).AddProbe (PadProbeType.GST_PAD_PROBE_TYPE_BLOCK, AddRemoveBinDone, IntPtr.Zero, null);
                PadProbeInfo info = (PadProbeInfo)Marshal.PtrToStructure(probe_info, typeof(PadProbeInfo));
                new Pad(pad).RemoveProbe(info.id);
                AddRemoveBinDone(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
            }

            return(PadProbeReturn.GST_PAD_PROBE_OK);
        }
Ejemplo n.º 5
0
        PadProbeReturn EventProbe(Pad pad, PadProbeInfo info)
        {
            if (info.Type == PadProbeType.EventDownstream)
            {
                return(PadProbeReturn.Pass);
            }

            var padEvent = info.Event;

            switch (padEvent.Type)
            {
            case EventType.FlushStart:
            case EventType.FlushStop:
            case EventType.Seek:
            case EventType.Segment:
            case EventType.CustomDownstream:
                vis_thawing = true;
                break;
            }

            return(PadProbeReturn.Pass);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Helper function to really attach a bin to the audio player tee
        /// </summary>
        /// <param name="pad">
        /// A <see cref="IntPtr"/> referencing the pad that may need to be unblocked
        /// </param>
        /// <param name="blocked">
        /// A <see cref="System.Boolean"/> indicating if the pad is blocked
        /// </param>
        /// <param name="user_data">
        /// A <see cref="IntPtr"/> containing references to the bin and the audio tee
        /// </param>
        private PadProbeReturn ReallyAddBin(IntPtr pad, IntPtr probe_info, IntPtr user_data, bool blocked)
        {
            GCHandle gch = GCHandle.FromIntPtr(user_data);

            Bin[] user_bins = (Gst.Bin[])gch.Target;
            Bin   fixture   = user_bins[0];
            Bin   element   = user_bins[1];

            Element   queue;
            Element   audioconvert;
            Bin       bin;
            Bin       parent_bin;
            Pad       sink_pad;
            Pad       ghost_pad;
            GstObject element_parent;

            element_parent = element.GetParent();
            if (element_parent != null && !element_parent.IsNull())
            {
                Hyena.Log.Debug("[Streamrecorder.PlayerAudioTee]<ReallyAddBin>element already linked, exiting. assume double function call");
                element_parent.UnRef();
                return(PadProbeReturn.GST_PAD_PROBE_OK);
            }

            /* set up containing bin */
            bin          = new Bin();
            queue        = ElementFactory.Make("queue");
            audioconvert = ElementFactory.Make("audioconvert");

            bin.SetBooleanProperty("async-handling", true);
            queue.SetIntegerProperty("max-size-buffers", 10);

            bin.AddMany(new Element[3] {
                queue, audioconvert, element
            });
            queue.LinkMany(new Element[2] {
                audioconvert, element
            });

            sink_pad  = queue.GetStaticPad("sink");
            ghost_pad = new GhostPad("sink", sink_pad);
            bin.AddPad(ghost_pad);

            parent_bin = new Bin(fixture.GetParent().ToIntPtr());
            parent_bin.Add(bin);
            fixture.Link(bin);

            attached = true;

            if (blocked)
            {
                Hyena.Log.Debug("[Streamrecorder.PlayerAudioTee]<ReallyAddBin> unblocking pad after adding tee");

                parent_bin.SetState(State.Playing);
                ghost_pad.Ref();
                parent_bin.UnRef();
//                new Pad (pad).AddProbe (PadProbeType.GST_PAD_PROBE_TYPE_BLOCK, AddRemoveBinDone, ghost_pad.ToIntPtr (), null);
                PadProbeInfo info = (PadProbeInfo)Marshal.PtrToStructure(probe_info, typeof(PadProbeInfo));
                new Pad(pad).RemoveProbe(info.id);
                AddRemoveBinDone(IntPtr.Zero, IntPtr.Zero, ghost_pad.ToIntPtr());
            }
            else
            {
                parent_bin.SetState(State.Paused);
                ghost_pad.Ref();
                parent_bin.UnRef();
                AddRemoveBinDone(IntPtr.Zero, IntPtr.Zero, ghost_pad.ToIntPtr());
            }
            return(PadProbeReturn.GST_PAD_PROBE_OK);
        }
Ejemplo n.º 7
0
 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;
 }
Ejemplo n.º 8
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;
 }
        static PadProbeReturn PadProbeCb(Pad pad, PadProbeInfo info)
        {
            if (Interlocked.CompareExchange(ref _inIdleProbe, 0, 1) == 1)
            {
                return(PadProbeReturn.Ok);
            }

            // Insert or remove filter ?
            if (_conv2 == null)
            {
                _conv2 = ElementFactory.Make("videoconvert");
// circle all effectv filters
                _filtersEnumerator.MoveNext();
                var eff = _filtersEnumerator.Current;
                Console.WriteLine(eff);
                _filter = ElementFactory.Make(eff);

                _pipeline.Add(_conv2, _filter);
                _conv2.SyncStateWithParent();
                _filter.SyncStateWithParent();

                if (!Element.Link(_conv2, _filter))
                {
                    "Failed to link conv2 with filter".PrintErr();
                    _loop.Quit();
                }

                using (var sinkPad = _conv.GetStaticPad("sink"))
                {
                    _dbinSrcpad.Unlink(sinkPad);
                }

                using (var sinkPad = _conv2.GetStaticPad("sink"))
                {
                    if (_dbinSrcpad.Link(sinkPad) != PadLinkReturn.Ok)
                    {
                        "failed to link src with conv2".PrintErr();
                        _loop.Quit();
                    }
                }

                using (var srcPad = _filter.GetStaticPad("src"))
                {
                    using (var sinkPad = _conv.GetStaticPad("sink"))
                    {
                        if (srcPad.Link(sinkPad) != PadLinkReturn.Ok)
                        {
                            "Failed to link filter with conv".PrintErr();
                            _loop.Quit();
                        }
                    }
                }
            }
            else
            {
                using (var sinkPad1 = _conv2.GetStaticPad("sink"))
                {
                    _dbinSrcpad.Unlink(sinkPad1);
                }

                using (var sinkPad2 = _conv.GetStaticPad("sink"))
                {
                    var srcPad = _filter.GetStaticPad("src");

                    srcPad.Unlink(sinkPad2);
                    srcPad.Dispose();

                    _pipeline.Remove(_filter);
                    _pipeline.Remove(_conv2);
                    _filter.SetState(State.Null);
                    _conv2.SetState(State.Null);

                    _filter.Dispose();
                    _conv2.Dispose();
                    _filter = null;
                    _conv2  = null;

                    if (_dbinSrcpad.Link(sinkPad2) != PadLinkReturn.Ok)
                    {
                        "Failed to link src with conv".PrintErr();
                        _loop.Quit();
                    }
                }
            }
            return(PadProbeReturn.Remove);
        }