2006-08-25 09:49:52 +00:00
|
|
|
//
|
|
|
|
// Authors:
|
|
|
|
// Khaled Mohammed (khaled.mohammed@gmail.com)
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
using Gst;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
public class QueueExample {
|
2009-09-20 08:19:49 +00:00
|
|
|
public static void Main (string [] args) {
|
|
|
|
Application.Init();
|
|
|
|
|
|
|
|
if (args.Length != 1) {
|
|
|
|
Console.Error.WriteLine ("usage: mono queueexample.exe <filename>\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Element pipeline = new Pipeline ("pipeline");
|
|
|
|
|
|
|
|
Element filesrc = ElementFactory.Make ("filesrc", "disk_source");
|
|
|
|
filesrc.SetProperty ("location", args[0]);
|
|
|
|
Element decode = ElementFactory.Make ("mad", "decode");
|
|
|
|
Element queue = ElementFactory.Make ("queue", "queue");
|
|
|
|
|
|
|
|
Element audiosink = ElementFactory.Make ("alsasink", "play_audio");
|
|
|
|
|
|
|
|
Bin bin = (Bin) pipeline;
|
|
|
|
bin.AddMany (filesrc, decode, queue, audiosink);
|
|
|
|
|
|
|
|
Element.LinkMany (filesrc, decode, queue, audiosink);
|
|
|
|
|
|
|
|
pipeline.SetState (State.Playing);
|
|
|
|
|
|
|
|
EventLoop (pipeline);
|
|
|
|
|
|
|
|
pipeline.SetState (State.Null);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void EventLoop (Element pipe) {
|
|
|
|
Bus bus = pipe.Bus;
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
Message message = bus.Poll (MessageType.Any, -1);
|
|
|
|
|
|
|
|
switch (message.Type) {
|
|
|
|
case MessageType.Eos: {
|
|
|
|
message.Dispose();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case MessageType.Error: {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-08-25 09:49:52 +00:00
|
|
|
}
|