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)); }