summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorStephan Sundermann <ssundermann@gnome.org>2014-08-08 18:20:05 +0200
committerStephan Sundermann <ssundermann@gnome.org>2014-08-08 18:20:05 +0200
commit96d371480f8ff439b05c4452699d3aee36ba80d8 (patch)
tree3c88cf54f66fa9639018e4ac08dc41fdd3328bd8 /samples
parent41af361d8996cd1968e29ea8e7a0645af7c21534 (diff)
sample: Add playback tutorial 6 sample
Diffstat (limited to 'samples')
-rw-r--r--samples/Makefile.am8
-rw-r--r--samples/PlaybackTutorial6.cs91
2 files changed, 97 insertions, 2 deletions
diff --git a/samples/Makefile.am b/samples/Makefile.am
index 7eb4367..c00fe45 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
+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
DEBUGS = $(addsuffix .mdb, $(TARGETS))
assemblies = \
@@ -63,6 +63,9 @@ playback-tutorial-4.exe: $(srcdir)/PlaybackTutorial4.cs $(assemblies)
playback-tutorial-5.exe: $(srcdir)/PlaybackTutorial5.cs $(assemblies)
$(CSC) $(CSFLAGS) -out:playback-tutorial-5.exe $(references) $(GLIB_SHARP_LIBS) $(srcdir)/PlaybackTutorial5.cs
+playback-tutorial-6.exe: $(srcdir)/PlaybackTutorial6.cs $(assemblies)
+ $(CSC) $(CSFLAGS) -out:playback-tutorial-6.exe $(references) $(GLIB_SHARP_LIBS) $(srcdir)/PlaybackTutorial6.cs
+
EXTRA_DIST = \
Playback.cs \
VideoOverlay.cs \
@@ -81,4 +84,5 @@ EXTRA_DIST = \
PlaybackTutorial2.cs \
PlaybackTutorial3.cs \
PlaybackTutorial4.cs \
- PlaybackTutorial5.cs
+ PlaybackTutorial5.cs \
+ PlaybackTutorial6.cs
diff --git a/samples/PlaybackTutorial6.cs b/samples/PlaybackTutorial6.cs
new file mode 100644
index 0000000..1b74260
--- /dev/null
+++ b/samples/PlaybackTutorial6.cs
@@ -0,0 +1,91 @@
+// Authors
+// Copyright (C) 2014 Stephan Sundermann <stephansundermann@gmail.com>
+
+using System;
+using Gst;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace GstreamerSharp
+{
+ class Playback
+ {
+ const uint PlayFlagsVis = (1 << 3);
+
+ static Element Pipeline;
+
+ // Return TRUE if this is a Visualization element
+ static bool FilterVisFeatures (PluginFeature feature) {
+
+ if (!(feature is ElementFactory))
+ return false;
+ var factory = (ElementFactory)feature;
+ if (!factory.GetMetadata (Gst.Constants.ELEMENT_METADATA_KLASS).Contains ("Visualization"))
+ return false;
+
+ return true;
+ }
+
+ public static void Main (string[] args)
+ {
+ ElementFactory selectedFactory = null;
+
+ // Initialize GStreamer
+ Application.Init (ref args);
+
+ // Get a list of all visualization plugins
+ var list = Registry.Get().FeatureFilter (FilterVisFeatures, false);
+
+ // Print their names
+ Console.WriteLine ("Available visualization plugins:");
+ foreach (var walk in list) {
+ var factory = (ElementFactory)walk;
+ var name = factory.Name;
+ Console.WriteLine(" {0}", name);
+
+ if (selectedFactory == null && name.StartsWith ("goom")) {
+ selectedFactory = factory;
+ }
+ }
+
+ // Don't use the factory if it's still empty
+ // e.g. no visualization plugins found
+ if (selectedFactory == null) {
+ Console.WriteLine ("No visualization plugins found!");
+ return;
+ }
+
+ // We have now selected a factory for the visualization element
+ Console.WriteLine ("Selected '{0}'", selectedFactory.Name);
+ var visPlugin = selectedFactory.Create ();
+ if (visPlugin == null)
+ return;
+
+
+ // Build the pipeline
+ Pipeline = Parse.Launch ("playbin uri=http://1live.akacast.akamaistream.net/7/706/119434/v1/gnl.akacast.akamaistream.net/1live");
+
+ // Set the visualization flag
+ var flags = (uint)Pipeline ["flags"];
+ flags |= PlayFlagsVis;
+ Pipeline ["flags"] = flags;
+
+ // set vis plugin for playbin
+ Pipeline ["vis-plugin"] = visPlugin;
+
+ // Start playing
+ var ret = Pipeline.SetState (State.Playing);
+ if (ret == StateChangeReturn.Failure) {
+ Console.WriteLine ("Unable to set the pipeline to the playing state.");
+ return;
+ }
+
+ // 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