Exemplo n.º 1
0
        public BpmDetector()
        {
            try {
                pipeline = new Pipeline();
                filesrc  = new FileSrc();
                var decodebin    = new DecodeBin2();
                var audioconvert = Make("audioconvert");
                var bpmdetect    = Make("bpmdetect");
                fakesink = new FakeSink();

                pipeline.Add(filesrc, decodebin, audioconvert, bpmdetect, fakesink);

                if (!filesrc.Link(decodebin))
                {
                    Log.Error("Could not link pipeline elements");
                    throw new Exception();
                }

                // decodebin and audioconvert are linked dynamically when the decodebin creates a new pad
                decodebin.NewDecodedPad += delegate(object o, DecodeBin2.NewDecodedPadArgs args) {
                    var audiopad = audioconvert.GetStaticPad("sink");
                    if (audiopad.IsLinked)
                    {
                        return;
                    }

                    using (var caps = args.Pad.Caps) {
                        using (var str = caps[0]) {
                            if (!str.Name.Contains("audio"))
                            {
                                return;
                            }
                        }
                    }

                    args.Pad.Link(audiopad);
                };

                if (!Element.Link(audioconvert, bpmdetect, fakesink))
                {
                    Log.Error("Could not link pipeline elements");
                    throw new Exception();
                }

                pipeline.Bus.AddWatch(OnBusMessage);
                //gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (detector->pipeline)), bbd_pipeline_bus_callback, detector);
            } catch (Exception e) {
                Log.Exception(e);
                throw new ApplicationException(Catalog.GetString("Could not create BPM detection driver."), e);
            }
        }
Exemplo n.º 2
0
 public GStreamerPlayer()
 {
     Application.Init();
     loop = new MainLoop();
     pipeline = new Pipeline("audio-player");
     try {
         bin = (Bin)Parse.Launch("filesrc name=my_filesrc ! progressreport update-freq=1 ! flump3dec ! alsasink");
     } catch {
         bin = (Bin)Parse.Launch("filesrc name=my_filesrc ! progressreport update-freq=1 ! mad ! autoaudiosink");
     }
     if (bin == null)
         throw new Exception("Parse error.");
     filesrc = bin.GetByName("my_filesrc") as FileSrc;
     bin.Bus.AddWatch(new BusFunc(BusCb));
 }
Exemplo n.º 3
0
        public BpmDetector ()
        {
            try {
                pipeline = new Pipeline ();
                filesrc          = new FileSrc ();
                var decodebin    = new DecodeBin2 ();
                var audioconvert = Make ("audioconvert");
                var bpmdetect    = Make ("bpmdetect");
                fakesink         = new FakeSink ();

                pipeline.Add (filesrc, decodebin, audioconvert, bpmdetect, fakesink);

                if (!filesrc.Link (decodebin)) {
                    Log.Error ("Could not link pipeline elements");
                    throw new Exception ();
                }

                // decodebin and audioconvert are linked dynamically when the decodebin creates a new pad
                decodebin.NewDecodedPad += delegate(object o, DecodeBin2.NewDecodedPadArgs args) {
                    var audiopad = audioconvert.GetStaticPad ("sink");
                    if (audiopad.IsLinked) {
                        return;
                    }

                    using (var caps = args.Pad.Caps) {
                        using (var str = caps[0]) {
                            if (!str.Name.Contains ("audio"))
                                return;
                        }
                    }

                    args.Pad.Link (audiopad);
                };

                if (!Element.Link (audioconvert, bpmdetect, fakesink)) {
                    Log.Error ("Could not link pipeline elements");
                    throw new Exception ();
                }

                pipeline.Bus.AddWatch (OnBusMessage);
                //gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (detector->pipeline)), bbd_pipeline_bus_callback, detector);
            } catch (Exception e) {
                Log.Exception (e);
                throw new ApplicationException (Catalog.GetString ("Could not create BPM detection driver."), e);
            }
        }
Exemplo n.º 4
0
  private void ConstructPipeline() {
    pipeline = new Pipeline ("pipeline");

    filesrc = ElementFactory.Make ("filesrc", "filesrc") as FileSrc;
    filesink = ElementFactory.Make ("filesink", "filesink") as FileSink;
    audioconvert = ElementFactory.Make ("audioconvert", "audioconvert");
    encoder = ElementFactory.Make ("wavenc", "wavenc");
    decodebin = ElementFactory.Make ("decodebin2", "decodebin") as DecodeBin2;
    decodebin.NewDecodedPad += OnNewDecodedPad;

    pipeline.Add (filesrc, decodebin, audioconvert, encoder, filesink);

    filesrc.Link (decodebin);
    audioconvert.Link (encoder);
    encoder.Link (filesink);

    pipeline.Bus.AddWatch (new BusFunc (OnBusMessage));
  }
    private void ConstructPipeline()
    {
        pipeline = new Pipeline("pipeline");

        filesrc                  = ElementFactory.Make("filesrc", "filesrc") as FileSrc;
        filesink                 = ElementFactory.Make("filesink", "filesink") as FileSink;
        audioconvert             = ElementFactory.Make("audioconvert", "audioconvert");
        encoder                  = ElementFactory.Make("wavenc", "wavenc");
        decodebin                = ElementFactory.Make("decodebin2", "decodebin") as DecodeBin2;
        decodebin.NewDecodedPad += OnNewDecodedPad;

        pipeline.Add(filesrc, decodebin, audioconvert, encoder, filesink);

        filesrc.Link(decodebin);
        audioconvert.Link(encoder);
        encoder.Link(filesink);

        pipeline.Bus.AddWatch(new BusFunc(OnBusMessage));
    }
Exemplo n.º 6
0
        /// <summary>
        /// Recursively copies all of the files and directories that are inside <paramref name="SourceDirectory"/> into <paramref name="DestinationDirectory"/>.
        /// </summary>
        /// <param name="SourceDirectory">The directory whose contents should be copied.</param>
        /// <param name="DestinationDirectory">The directory into which the files should be copied.</param>
        private static void CopyAll(string SourceDirectory, string DestinationDirectory)
        {
            IEnumerable <string> Directories = Directory.EnumerateDirectories(SourceDirectory, "*", System.IO.SearchOption.AllDirectories);

            // Create all the directories
            foreach (string DirSrc in Directories)
            {
                string DirDst = DirSrc.ToString().Replace(SourceDirectory.ToString(), DestinationDirectory.ToString());
                Directory.CreateDirectory(DirDst);
            }

            IEnumerable <string> Files = Directory.EnumerateFiles(SourceDirectory, "*", System.IO.SearchOption.AllDirectories);

            // Copy all the files
            foreach (string FileSrc in Files)
            {
                string FileDst = FileSrc.ToString().Replace(SourceDirectory.ToString(), DestinationDirectory.ToString());
                if (!File.Exists(FileDst))
                {
                    File.Copy(FileSrc, FileDst);
                }
            }
        }
Exemplo n.º 7
0
    public static void Main(string [] args)
    {
        Application.Init();

        Pipeline pipeline = new Pipeline("pipeline");
        FileSrc  source   = FileSrc.Make("source");

        typefind = TypeFindElement.Make("typefind");
        FakeSink sink = FakeSink.Make("sink");

        source.Location = args[0];

        typefind.HaveType += OnHaveType;

        pipeline.Add(source, typefind, sink);
        source.Link(typefind);
        typefind.Link(sink);

        pipeline.SetState(State.Paused);
        pipeline.SetState(State.Null);

        pipeline.Dispose();
    }