From 06140ce8080319d60224b1efb0b9e5fc03a59730 Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Fri, 8 Aug 2014 18:30:09 +0200 Subject: [PATCH] sample: Add playback tutorial 7 sample --- samples/Makefile.am | 8 +++-- samples/PlaybackTutorial7.cs | 62 ++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 samples/PlaybackTutorial7.cs diff --git a/samples/Makefile.am b/samples/Makefile.am index c00fe454cc..4fe13d5e05 100644 --- a/samples/Makefile.am +++ b/samples/Makefile.am @@ -1,4 +1,4 @@ -TARGETS = playback.exe video-overlay.exe basic-tutorial-1.exe basic-tutorial-2.exe basic-tutorial-3.exe basic-tutorial-4.exe basic-tutorial-5.exe basic-tutorial-6.exe basic-tutorial-7.exe basic-tutorial-8.exe basic-tutorial-9.exe basic-tutorial-12.exe basic-tutorial-13.exe playback-tutorial-1.exe playback-tutorial-2.exe playback-tutorial-3.exe playback-tutorial-4.exe playback-tutorial-5.exe playback-tutorial-6.exe +TARGETS = playback.exe video-overlay.exe basic-tutorial-1.exe basic-tutorial-2.exe basic-tutorial-3.exe basic-tutorial-4.exe basic-tutorial-5.exe basic-tutorial-6.exe basic-tutorial-7.exe basic-tutorial-8.exe basic-tutorial-9.exe basic-tutorial-12.exe basic-tutorial-13.exe playback-tutorial-1.exe playback-tutorial-2.exe playback-tutorial-3.exe playback-tutorial-4.exe playback-tutorial-5.exe playback-tutorial-6.exe playback-tutorial-7.exe DEBUGS = $(addsuffix .mdb, $(TARGETS)) assemblies = \ @@ -66,6 +66,9 @@ playback-tutorial-5.exe: $(srcdir)/PlaybackTutorial5.cs $(assemblies) playback-tutorial-6.exe: $(srcdir)/PlaybackTutorial6.cs $(assemblies) $(CSC) $(CSFLAGS) -out:playback-tutorial-6.exe $(references) $(GLIB_SHARP_LIBS) $(srcdir)/PlaybackTutorial6.cs +playback-tutorial-7.exe: $(srcdir)/PlaybackTutorial7.cs $(assemblies) + $(CSC) $(CSFLAGS) -out:playback-tutorial-7.exe $(references) $(GLIB_SHARP_LIBS) $(srcdir)/PlaybackTutorial7.cs + EXTRA_DIST = \ Playback.cs \ VideoOverlay.cs \ @@ -85,4 +88,5 @@ EXTRA_DIST = \ PlaybackTutorial3.cs \ PlaybackTutorial4.cs \ PlaybackTutorial5.cs \ - PlaybackTutorial6.cs + PlaybackTutorial6.cs \ + PlaybackTutorial7.cs diff --git a/samples/PlaybackTutorial7.cs b/samples/PlaybackTutorial7.cs new file mode 100644 index 0000000000..9de6532d21 --- /dev/null +++ b/samples/PlaybackTutorial7.cs @@ -0,0 +1,62 @@ +// Authors +// Copyright (C) 2014 Stephan Sundermann + +using System; +using Gst; +using System.Runtime.InteropServices; +using System.Text; + +namespace GstreamerSharp +{ + class Playback + { + public static void Main (string[] args) + { + // Initialize GStreamer + Application.Init (ref args); + + // Build the pipeline + var pipeline = Parse.Launch ("playbin uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm"); + + // Create the elements inside the sink bin + var equalizer = ElementFactory.Make ("equalizer-3bands", "equalizer"); + var convert = ElementFactory.Make ("audioconvert", "convert"); + var sink = ElementFactory.Make ("autoaudiosink", "audio_sink"); + if (equalizer == null || convert == null || sink == null) { + Console.WriteLine ("Not all elements could be created."); + return; + } + + // Create the sink bin, add the elements and link them + var bin = new Bin ("audio_sink_bin"); + bin.Add (equalizer, convert, sink); + Element.Link (equalizer, convert, sink); + var pad = equalizer.GetStaticPad ("sink"); + var ghostPad = new GhostPad ("sink", pad); + ghostPad.SetActive (true); + bin.AddPad (ghostPad); + + // Start playing + var ret = pipeline.SetState (State.Playing); + if (ret == StateChangeReturn.Failure) { + Console.WriteLine ("Unable to set the pipeline to the playing state."); + return; + } + + + // Configure the equalizer + equalizer ["band1"] = (double)-24.0; + equalizer ["band2"] = (double)-24.0; + + // Set playbin2's audio sink to be our sink bin + pipeline ["audio-sink"] = bin; + + // Wait until error or EOS + var bus = pipeline.Bus; + var msg = bus.TimedPopFiltered (Constants.CLOCK_TIME_NONE, MessageType.Error | MessageType.Eos); + + // Free resources + pipeline.SetState (State.Null); + } + } +} \ No newline at end of file