sample: Add playback tutorial 6 sample
This commit is contained in:
parent
41af361d89
commit
96d371480f
@ -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))
|
DEBUGS = $(addsuffix .mdb, $(TARGETS))
|
||||||
assemblies = \
|
assemblies = \
|
||||||
@ -63,6 +63,9 @@ playback-tutorial-4.exe: $(srcdir)/PlaybackTutorial4.cs $(assemblies)
|
|||||||
playback-tutorial-5.exe: $(srcdir)/PlaybackTutorial5.cs $(assemblies)
|
playback-tutorial-5.exe: $(srcdir)/PlaybackTutorial5.cs $(assemblies)
|
||||||
$(CSC) $(CSFLAGS) -out:playback-tutorial-5.exe $(references) $(GLIB_SHARP_LIBS) $(srcdir)/PlaybackTutorial5.cs
|
$(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 = \
|
EXTRA_DIST = \
|
||||||
Playback.cs \
|
Playback.cs \
|
||||||
VideoOverlay.cs \
|
VideoOverlay.cs \
|
||||||
@ -81,4 +84,5 @@ EXTRA_DIST = \
|
|||||||
PlaybackTutorial2.cs \
|
PlaybackTutorial2.cs \
|
||||||
PlaybackTutorial3.cs \
|
PlaybackTutorial3.cs \
|
||||||
PlaybackTutorial4.cs \
|
PlaybackTutorial4.cs \
|
||||||
PlaybackTutorial5.cs
|
PlaybackTutorial5.cs \
|
||||||
|
PlaybackTutorial6.cs
|
||||||
|
91
samples/PlaybackTutorial6.cs
Normal file
91
samples/PlaybackTutorial6.cs
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user