Exemplo n.º 1
0
        /// <summary>
        /// Attaches a pipeline/bin to the audio player tee, optionally using pad blocking
        /// </summary>
        /// <param name="bin">
        /// A <see cref="Bin"/> to attach to the player tee
        /// </param>
        /// <param name="use_pad_block">
        /// A <see cref="System.Boolean"/> indicating whether to use pad blocking or not
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/> -- always true
        /// </returns>
        public bool AddBin(Bin bin, bool use_pad_block)
        {
            Bin[] user_bins = new Bin[2] {
                new Bin(this.ToIntPtr()), bin
            };
            GCHandle gch       = GCHandle.Alloc(user_bins);
            IntPtr   user_data = GCHandle.ToIntPtr(gch);

            Pad fixture_pad = this.GetStaticPad("sink");
            Pad block_pad   = fixture_pad.GetPeer();

            fixture_pad.UnRef();

            if (use_pad_block)
            {
                ulong blocking_probe = block_pad.AddProbe(PadProbeType.GST_PAD_PROBE_TYPE_BLOCK, ReallyAddBinBlocked, user_data, null);
                Hyena.Log.DebugFormat("[Streamrecorder.PlayerAudioTee]<AddBin> blockin pad {0} to perform an operation ({1})", block_pad.GetPathString(), blocking_probe);
            }
            else
            {
                Hyena.Log.Debug("Streamrecorder.PlayerAudioTee]<AddBin> not using blockin pad, calling operation directly");
                ReallyAddBinUnblocked(block_pad.ToIntPtr(), IntPtr.Zero, user_data);
            }
            block_pad.UnRef();

            return(true);
        }
 /// <summary>
 /// Changes the location of the file being recorded while recording is in progress,
 /// splitting the file at the current stream location
 /// </summary>
 /// <param name="new_location">
 /// A <see cref="System.String"/> containing the full new filename and path
 /// </param>
 private void SetNewTrackLocation(string new_location, IntPtr active_pad)
 {
     try {
         Pad teepad = ghost_pad.GetPeer();
         if (encoder_bin.GetState() == StateChangeReturn.Success &&
             ServiceManager.PlayerEngine.CurrentState == PlayerState.Playing)
         {
             object[] user_objects = new object[3] {
                 teepad.ToIntPtr(), new_location, active_pad
             };
             GCHandle gch       = GCHandle.Alloc(user_objects);
             IntPtr   user_data = GCHandle.ToIntPtr(gch);
             ulong    probe_id  = teepad.AddProbe(PadProbeType.GST_PAD_PROBE_TYPE_BLOCK, SetNewTrackLocationBlocked, user_data, null);
             Hyena.Log.Information("[Streamrecorder] changing location during playing state (probe_id=" + probe_id + ")");
         }
         else
         {
             encoder_bin.SendEvent(Marshaller.NewEOSEvent());
             encoder_bin.SetState(State.Null);
             file_sink.Location = new_location;
             if (active_pad != IntPtr.Zero)
             {
                 outputselector.SetProperty("active-pad", new Element(active_pad));
             }
             encoder_bin.SetState(State.Ready);
         }
     } catch (Exception e) {
         Hyena.Log.Information("[Streamrecorder] An exception occurred during gstreamer operation");
         Hyena.Log.Debug(e.StackTrace);
     }
 }
 static bool TimeoutCb()
 {
     _inIdleProbe = 0;
     _dbinSrcpad.AddProbe(PadProbeType.Idle, PadProbeCb);
     return(true);
 }