mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-14 13:21:28 +00:00
73ed037fa4
* gstreamer-sharp/BindingHelper.cs: Static helper class to assist in making element bindings (delegate manipulation/invocation) * gstreamer-sharp/DynamicSignal.cs: Updated DynamicSignalArgs so they can more easily be derived * gstreamer-sharp/Makefile.am: Updated build * sample/HelloWorld.cs: More cleaning * sample/Makefile.am: * sample/TypeFind.cs: Added typefind sample * gstreamer-sharp.mdp: Updated MonoDevelop project * gstreamer-sharp/plugins-base/DecodeBin.cs: Signal support rewritten to use BindingHelper/DynamicSignal * gstreamer-sharp/plugins-base/TypeFindElement.cs: New typefind element wrapper using BindingHelper/DynamicSignal * gstreamer-sharp/Element.custom: Fixed property getter/setter methods and added indexer wrapper for property lookup for syntax convenience git-svn-id: svn://anonsvn.mono-project.com/source/branches/abock/gstreamer-sharp@62570 e3ebcda4-bce8-0310-ba0a-eca2169e7518
101 lines
2.9 KiB
C#
101 lines
2.9 KiB
C#
using System;
|
|
using Gst;
|
|
using GLib;
|
|
|
|
public class HelloWorld
|
|
{
|
|
private MainLoop loop;
|
|
private Element pipeline, source, parser, decoder, conv, identity, sink;
|
|
|
|
public static void Main(string [] args)
|
|
{
|
|
new HelloWorld(args);
|
|
}
|
|
|
|
public HelloWorld(string [] args)
|
|
{
|
|
Application.Init();
|
|
|
|
loop = new MainLoop();
|
|
pipeline = new Pipeline("audio-player");
|
|
|
|
if((source = ElementFactory.Make("filesrc", "file-source")) == null) {
|
|
Console.WriteLine("Could not create file-source");
|
|
}
|
|
|
|
parser = ElementFactory.Make("oggdemux", "ogg-parser");
|
|
decoder = ElementFactory.Make("vorbisdec", "vorbis-decoder");
|
|
conv = ElementFactory.Make("audioconvert", "converter");
|
|
identity = ElementFactory.Make("identity", "identitye");
|
|
sink = ElementFactory.Make("alsasink", "alsa-output");
|
|
|
|
source["location"] = args[0];
|
|
|
|
Bin bin = (Bin) pipeline;
|
|
bin.Bus.AddWatch(new BusFunc(BusCall));
|
|
|
|
bin.AddMany(source, parser, decoder, conv, identity, sink);
|
|
|
|
if(!source.Link(parser)) {
|
|
Console.WriteLine("link failed between source and parser");
|
|
}
|
|
|
|
if(!decoder.Link(conv)) {
|
|
Console.WriteLine("link failed between decoder and converter");
|
|
}
|
|
|
|
if(!conv.Link(identity)) {
|
|
Console.WriteLine("link failed between converter and identity");
|
|
}
|
|
|
|
if(!identity.Link(sink)) {
|
|
Console.Error.WriteLine("link failed between identity and sink");
|
|
}
|
|
|
|
parser.PadAdded += new PadAddedHandler(OnPadAdded);
|
|
identity.Connect("handoff", OnHandoff);
|
|
|
|
pipeline.SetState(State.Playing);
|
|
|
|
Console.WriteLine("Playing [" + args[0] + "]");
|
|
|
|
loop.Run();
|
|
|
|
pipeline.SetState(State.Null);
|
|
pipeline.Dispose();
|
|
}
|
|
|
|
private bool BusCall(Bus bus, Message message)
|
|
{
|
|
switch(message.Type) {
|
|
case MessageType.Error:
|
|
string err = String.Empty;
|
|
message.ParseError(out err);
|
|
Console.WriteLine ("Gstreamer error: {0}", err);
|
|
loop.Quit();
|
|
break;
|
|
case MessageType.Eos:
|
|
Console.WriteLine("End-of-stream");
|
|
loop.Quit();
|
|
break;
|
|
default:
|
|
Console.WriteLine("Entered BusCall:\t{0}", message.Type);
|
|
break;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private void OnHandoff(object o, DynamicSignalArgs args)
|
|
{
|
|
Gst.Buffer buffer = args[0] as Gst.Buffer;
|
|
Console.WriteLine(buffer.Duration + "\t" + buffer.Timestamp);
|
|
}
|
|
|
|
void OnPadAdded(object o, PadAddedArgs args)
|
|
{
|
|
Console.WriteLine("Entered OnPadAdded");
|
|
Pad sinkpad = decoder.GetPad("sink");
|
|
args.Pad.Link(sinkpad);
|
|
}
|
|
}
|