void IDelayedInitializeService.DelayedInitialize()
        {
            if (!has_karaoke) return;

            playbin = new Bin (ServiceManager.PlayerEngine.ActiveEngine.GetBaseElements ()[0]);
            audiobin = new Bin (ServiceManager.PlayerEngine.ActiveEngine.GetBaseElements ()[1]);
            audiotee = new Bin (ServiceManager.PlayerEngine.ActiveEngine.GetBaseElements ()[2]);

            if (playbin.IsNull ()) {
                Hyena.Log.Debug ("[Karaoke] Playbin is not yet initialized, cannot start Karaoke Mode");
            }

            audiokaraoke = audiobin.GetByName ("karaoke");

            if (audiokaraoke.IsNull ()) {
                audiokaraoke = ElementFactory.Make ("audiokaraoke","karaoke");

                //add audiokaraoke to audiobin
                audiobin.Add (audiokaraoke);

                //setting new audiobin sink to audiokaraoke sink
                GhostPad teepad = new GhostPad (audiobin.GetStaticPad ("sink").ToIntPtr ());
                Pad audiokaraokepad = audiokaraoke.GetStaticPad ("sink");
                teepad.SetTarget (audiokaraokepad);

                //link audiokaraoke sink and audiotee sink
                audiokaraoke.Link (audiotee);
            }

            if (!karaoke_enabled) {
                audiokaraoke.SetFloatProperty ("level", 0);
                audiokaraoke.SetFloatProperty ("mono-level", 0);
            } else {
                audiokaraoke.SetFloatProperty ("level", effect_level);
                audiokaraoke.SetFloatProperty ("mono-level", effect_level);
            }
        }
Exemplo n.º 2
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 void ReallyAddBin (IntPtr pad, bool blocked, IntPtr user_data)
        {
            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;
            }

            /* 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).SetBlockedAsync (false, AddRemoveBinDone, ghost_pad.ToIntPtr ());
            } else {
                parent_bin.SetState (State.Paused);
                ghost_pad.Ref ();
                parent_bin.UnRef ();
                AddRemoveBinDone (IntPtr.Zero, false, ghost_pad.ToIntPtr ());
            }

        }