mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
sample: Add playback tutorial 7 sample
This commit is contained in:
parent
96d371480f
commit
06140ce808
2 changed files with 68 additions and 2 deletions
|
@ -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))
|
DEBUGS = $(addsuffix .mdb, $(TARGETS))
|
||||||
assemblies = \
|
assemblies = \
|
||||||
|
@ -66,6 +66,9 @@ playback-tutorial-5.exe: $(srcdir)/PlaybackTutorial5.cs $(assemblies)
|
||||||
playback-tutorial-6.exe: $(srcdir)/PlaybackTutorial6.cs $(assemblies)
|
playback-tutorial-6.exe: $(srcdir)/PlaybackTutorial6.cs $(assemblies)
|
||||||
$(CSC) $(CSFLAGS) -out:playback-tutorial-6.exe $(references) $(GLIB_SHARP_LIBS) $(srcdir)/PlaybackTutorial6.cs
|
$(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 = \
|
EXTRA_DIST = \
|
||||||
Playback.cs \
|
Playback.cs \
|
||||||
VideoOverlay.cs \
|
VideoOverlay.cs \
|
||||||
|
@ -85,4 +88,5 @@ EXTRA_DIST = \
|
||||||
PlaybackTutorial3.cs \
|
PlaybackTutorial3.cs \
|
||||||
PlaybackTutorial4.cs \
|
PlaybackTutorial4.cs \
|
||||||
PlaybackTutorial5.cs \
|
PlaybackTutorial5.cs \
|
||||||
PlaybackTutorial6.cs
|
PlaybackTutorial6.cs \
|
||||||
|
PlaybackTutorial7.cs
|
||||||
|
|
62
samples/PlaybackTutorial7.cs
Normal file
62
samples/PlaybackTutorial7.cs
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
// Authors
|
||||||
|
// Copyright (C) 2014 Stephan Sundermann <stephansundermann@gmail.com>
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue