コード例 #1
0
        public void RipTrack(int trackIndex, TrackInfo track, SafeUri outputUri, out bool taggingSupported)
        {
            taggingSupported = false;
            TrackReset();
            current_track = track;

            using (TagList tags = MakeTagList(track)) {
                output_path = String.Format("{0}.{1}", outputUri.LocalPath, output_extension);

                // Avoid overwriting an existing file
                int i = 1;
                while (Banshee.IO.File.Exists(new SafeUri(output_path)))
                {
                    output_path = String.Format("{0} ({1}).{2}", outputUri.LocalPath, i++, output_extension);
                }

                Log.DebugFormat("GStreamer ripping track {0} to {1}", trackIndex, output_path);

                if (!ConstructPipeline())
                {
                    return;
                }

                // initialize the pipeline, set the sink output location
                filesink.SetState(State.Null);
                filesink ["location"] = output_path;

                var version = new System.Version(Banshee.ServiceStack.Application.Version);

                // find an element to do the tagging and set tag data
                foreach (Element element in encoder.GetAllByInterface(typeof(TagSetter)))
                {
                    TagSetter tag_setter = element as TagSetter;
                    if (tag_setter != null)
                    {
                        tag_setter.AddTag(TagMergeMode.ReplaceAll, Tag.Encoder,
                                          new Gst.GLib.Value(String.Format("Banshee {0}", Banshee.ServiceStack.Application.Version)));
                        tag_setter.AddTag(TagMergeMode.ReplaceAll, Tag.EncoderVersion,
                                          new Gst.GLib.Value((version.Major << 16) | (version.Minor << 8) | version.Build));

                        if (tags != null)
                        {
                            tag_setter.AddTag(tags, TagMergeMode.Append);
                        }

                        /*if (banshee_is_debugging ()) {
                         *  bt_tag_list_dump (gst_tag_setter_get_tag_list (tag_setter));
                         * }*/

                        // We'll warn the user in the UI if we can't tag the encoded audio files
                        taggingSupported = true;
                    }
                }

                // Begin the rip
                cddasrc ["track"] = trackIndex + 1;
                pipeline.SetState(State.Playing);
                timer.Start();
            }
        }
コード例 #2
0
    public static void DoSomething_WorksButNotIdeal()
    {
        MusicTrack   track1    = new MusicTrack();
        MusicTrack   track2    = new MusicTrack();
        TagSetter    setter    = new TagSetter();
        TagExtractor extractor = new TagExtractor();

        // Set some values on the tracks
        foreach (IExistsTag tag in track1.Tags.Values)
        {
            tag.Apply(setter);
            // do stuff using base interface if necessary
            ITag itag = tag.Apply(extractor);
        }
    }
コード例 #3
0
        /// <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);
        }