示例#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);
            }
        }
示例#2
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);
            }
        }
    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));
    }
示例#4
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();
    }
示例#5
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));
  }