diff --git a/ChangeLog b/ChangeLog index 6f21685451..4d6b269c4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-08-25 Khaled Mohammed + * sample/QueueExample.cs: a sample file showcasing + use of the queue element + * gstreamer-sharp/Element.custom: added static LinkMany and UnlinkMany + functions + 2006-08-20 Khaled Mohammed * gstreamer-sharp/Buffer.custom: added Ref(), Unref() and Refcount() functionality diff --git a/gstreamer-sharp/Element.custom b/gstreamer-sharp/Element.custom index 8bc5b5a732..d5bc8fe2d7 100644 --- a/gstreamer-sharp/Element.custom +++ b/gstreamer-sharp/Element.custom @@ -68,6 +68,26 @@ Gst.Object.Ref(p.Handle); return ret; } + + public static bool LinkMany(params Element [] elements) + { + for(int i=0; i < elements.Length - 1; i++) + { + if(!elements[i].Link(elements[i+1])) + return false; + } + + return true; + } + + public static void UnlinkMany(params Element [] elements) + { + for(int i=0; i < elements.Length - 1; i++) + { + elements[i].Unlink(elements[i+1]); + } + } + [DllImport("gstreamer-0.10.dll")] private static extern bool gst_element_query_position(IntPtr raw, ref Format format, out long cur); diff --git a/gstreamer-sharp/Gstreamer.metadata b/gstreamer-sharp/Gstreamer.metadata index f0a876b073..b83939db7a 100644 --- a/gstreamer-sharp/Gstreamer.metadata +++ b/gstreamer-sharp/Gstreamer.metadata @@ -14,6 +14,8 @@ 1 1 1 + 1 + 1 1 1 1 diff --git a/gstreamer-sharp/Pad.custom b/gstreamer-sharp/Pad.custom index 9f46ae6852..86f5daf417 100644 --- a/gstreamer-sharp/Pad.custom +++ b/gstreamer-sharp/Pad.custom @@ -53,7 +53,6 @@ PersistentData["AddBufferProbe"] = func_wrapper; } - //IntPtr data = (IntPtr) GCHandle.Alloc(func_wrapper); return gst_pad_add_buffer_probe(this.Handle, func_wrapper.NativeFunc, IntPtr.Zero); } diff --git a/gstreamer-sharp/gstreamer-api.raw b/gstreamer-sharp/gstreamer-api.raw index b940914ead..816930d664 100644 --- a/gstreamer-sharp/gstreamer-api.raw +++ b/gstreamer-sharp/gstreamer-api.raw @@ -1,12 +1,11 @@ - - - +--> @@ -5746,6 +5745,4 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/sample/Makefile.am b/sample/Makefile.am index ed8cd02eb7..a0c729d5fe 100644 --- a/sample/Makefile.am +++ b/sample/Makefile.am @@ -19,6 +19,9 @@ helloworld.exe: $(srcdir)/HelloWorld.cs $(assemblies) typefind.exe: $(srcdir)/TypeFind.cs $(assemblies) $(CSC) -out:$@ $(GLIBSHARP_LIBS) $(references) $(srcdir)/TypeFind.cs +queueexample.exe: $(srcdir)/QueueExample.cs $(assemblies) + $(CSC) -out:$@ $(GLIBSHARP_LIBS) $(references) $(srcdir)/QueueExample.cs + link: ln -sf $(top_builddir)/gstreamer-sharp/gstreamer-sharp.dll gstreamer-sharp.dll ln -sf $(top_builddir)/gstreamer-sharp/gstreamer-sharp.dll.config gstreamer-sharp.dll.config diff --git a/sample/QueueExample.cs b/sample/QueueExample.cs new file mode 100644 index 0000000000..80185741b7 --- /dev/null +++ b/sample/QueueExample.cs @@ -0,0 +1,59 @@ +// +// Authors: +// Khaled Mohammed (khaled.mohammed@gmail.com) +// +// + +using Gst; +using System; + +public class QueueExample { + public static void Main(string [] args) + { + Application.Init(); + + if(args.Length != 1) { + Console.Error.WriteLine("usage: mono queueexample.exe \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; + } + } + } + } +} diff --git a/sample/TypeFind.cs b/sample/TypeFind.cs index 5eb743aaca..6e13ae93e9 100644 --- a/sample/TypeFind.cs +++ b/sample/TypeFind.cs @@ -24,7 +24,10 @@ public static class GstTypefindTest pipeline.SetState(State.Paused); pipeline.SetState(State.Null); - + + source.Dispose(); + typefind.Dispose(); + sink.Dispose(); pipeline.Dispose(); } diff --git a/source/gstreamer-sharp-source.xml b/source/gstreamer-sharp-source.xml index ab51676694..6e0a64ebd1 100644 --- a/source/gstreamer-sharp-source.xml +++ b/source/gstreamer-sharp-source.xml @@ -6,13 +6,13 @@ gstreamer-0.10.3/gst/gstinterface.h gstreamer-0.10.3/gst/gsturi.h - +-->