bool ConstructPipeline() { Element queue; pipeline = new Gst.Pipeline("pipeline"); if (pipeline == null) { RaiseError(current_track, Catalog.GetString("Could not create pipeline")); return(false); } cddasrc = ElementFactory.MakeFromUri(URIType.Src, "cdda://1", "cddasrc"); if (cddasrc == null) { RaiseError(current_track, Catalog.GetString("Could not initialize element from cdda URI")); return(false); } cddasrc ["device"] = device; if (cddasrc.HasProperty("paranoia-mode")) { cddasrc ["paranoia-mode"] = paranoia_mode; } try { encoder = (Bin)Parse.BinFromDescription(encoder_pipeline, true); } catch (Exception e) { string err = Catalog.GetString("Could not create encoder pipeline : {0}"); RaiseError(current_track, String.Format(err, e.Message)); return(false); } queue = ElementFactory.Make("queue", "queue"); if (queue == null) { RaiseError(current_track, Catalog.GetString("Could not create queue plugin")); return(false); } queue ["max-size-time"] = 120 * Gst.Clock.Second; filesink = ElementFactory.Make("filesink", "filesink"); if (filesink == null) { RaiseError(current_track, Catalog.GetString("Could not create filesink plugin")); return(false); } pipeline.Add(cddasrc, queue, encoder, filesink); if (!Element.Link(cddasrc, queue, encoder, filesink)) { RaiseError(current_track, Catalog.GetString("Could not link pipeline elements")); } pipeline.Bus.AddWatch(OnBusMessage); return(true); }
/// <summary> /// Creates a new recoding pipeline with the best (by user preference) available encoder and attaches it /// to the audiotee /// </summary> /// <returns> /// A <see cref="System.Boolean"/>, true if the pipeline was successfully created, false otherwise. /// </returns> public bool Create() { string bin_description = BuildPipeline(); try { audiotee = new PlayerAudioTee(ServiceManager.PlayerEngine.ActiveEngine.GetBaseElements()[2]); if (bin_description.Equals("")) { return(false); } encoder_bin = Parse.BinFromDescription(bin_description, true); // Hyena.Log.Debug ("DEBUG bin to string: " + encoder_bin.ToString()); tagger = new TagSetter(encoder_bin.GetByInterface(TagSetter.GetType())); file_sink = encoder_bin.GetByName("file_sink").ToFileSink(); file_sink.Location = empty_file; file_sink.SetBooleanProperty("sync", true); file_sink.SetBooleanProperty("async", false); OldGLib.Object.GetObject(file_sink.ToIntPtr()).AddNotification("allow-overwrite", OnAllowOverwrite); ghost_pad = encoder_bin.GetStaticPad("sink").ToGhostPad(); outputselector = encoder_bin.GetByName("sel"); Pad filesinkpad = file_sink.GetStaticPad("sink"); selector_filepad = filesinkpad.GetPeer(); Element fake_sink = encoder_bin.GetByName("fake_sink"); Pad fakesinkpad = fake_sink.GetStaticPad("sink"); selector_fakepad = fakesinkpad.GetPeer(); audiotee.AddBin(encoder_bin, ServiceManager.PlayerEngine.CurrentState == PlayerState.Playing); Hyena.Log.Debug("[Recorder] Recorder attached"); } catch (Exception e) { Hyena.Log.InformationFormat("[Streamrecorder] An exception occurred during pipeline construction: {0}", bin_description); Hyena.Log.Debug(e.Message); Hyena.Log.Debug(e.StackTrace); return(false); } return(true); }
public AudioSinkBin(string elementName, string encoder_pipeline, string output_uri) : base(elementName) { Element encoder_elem = null; Element sink_elem; Element conv_elem; Element resample_elem; Pad encoder_pad; sink_elem = ElementFactory.MakeFromUri(URIType.Sink, output_uri, "sink"); if (sink_elem == null) { throw new Exception(Catalog.GetString("Could not create sink element")); } conv_elem = ElementFactory.Make("audioconvert", "audioconvert"); if (conv_elem == null) { throw new Exception(Catalog.GetString("Could not create audioconvert plugin")); } resample_elem = ElementFactory.Make("audioresample", "audioresample"); if (resample_elem == null) { throw new Exception(Catalog.GetString("Could not create audioresample plugin")); } try { encoder_elem = Parse.BinFromDescription(encoder_pipeline, true); } catch (Exception e) { string err = Catalog.GetString("Could not create encoding pipeline : {0}"); throw new Exception(String.Format(err, e.Message)); } encoder_pad = conv_elem.GetStaticPad("sink"); if (encoder_pad == null) { throw new Exception(Catalog.GetString("Could not get sink pad from encoder")); } Add(conv_elem, resample_elem, encoder_elem, sink_elem); Element.Link(conv_elem, resample_elem, encoder_elem, sink_elem); AddPad(new GhostPad("sink", encoder_pad)); }