Added Element.LinkMany and Element.UnlinkMany

git-svn-id: svn://anonsvn.mono-project.com/source/branches/abock/gstreamer-sharp@64347 e3ebcda4-bce8-0310-ba0a-eca2169e7518
This commit is contained in:
Khaled Mohammed 2006-08-25 09:49:52 +00:00
parent 9b5a54fe8d
commit 610da9b1d9
9 changed files with 103 additions and 14 deletions

View file

@ -1,3 +1,9 @@
2006-08-25 Khaled Mohammed <khaled.mohammed@gmail.com>
* 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 <khaled.mohammed@gmail.com>
* gstreamer-sharp/Buffer.custom: added Ref(), Unref() and Refcount()
functionality

View file

@ -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);

View file

@ -14,6 +14,8 @@
<attr path="/api/namespace/object[@name='Pad']/method[@name='AddDataProbe']" name="hidden">1</attr>
<attr path="/api/namespace/object[@name='Pad']/method[@name='RemoveDataProbe']" name="hidden">1</attr>
<attr path="/api/namespace/object[@name='Bin']/method[@name='AddMany']" name="hidden">1</attr>
<attr path="/api/namespace/object[@name='Element']/method[@name='LinkMany']" name="hidden">1</attr>
<attr path="/api/namespace/object[@name='Element']/method[@name='UnlinkMany']" name="hidden">1</attr>
<attr path="/api/namespace/object[@name='Bin']/method[@name='RemoveMany']" name="hidden">1</attr>
<attr path="/api/namespace/object[@name='Message']/method[@cname='gst_message_new_error']" name="hidden">1</attr>
<attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_add_pad']" name="hidden">1</attr>

View file

@ -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);
}

View file

@ -1,12 +1,11 @@
<?xml version="1.0"?>
<api>
<!--
<api
><!--
This file was automatically generated.
Please DO NOT MODIFY THIS FILE, modify .metadata files instead.
-->
<namespace name="Gst" library="gstreamer-0.10.dll">
--><namespace name="Gst" library="gstreamer-0.10.dll">
<enum name="ActivateMode" cname="GstActivateMode" type="enum">
<member cname="GST_ACTIVATE_NONE" name="None" />
<member cname="GST_ACTIVATE_PUSH" name="Push" />
@ -5746,6 +5745,4 @@
<parameter type="const-GValue*" name="value2" />
</parameters>
</method>
</class>
</namespace>
</api>
</class></namespace></api>

View file

@ -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

59
sample/QueueExample.cs Normal file
View file

@ -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 <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;
}
}
}
}
}

View file

@ -24,7 +24,10 @@ public static class GstTypefindTest
pipeline.SetState(State.Paused);
pipeline.SetState(State.Null);
source.Dispose();
typefind.Dispose();
sink.Dispose();
pipeline.Dispose();
}

View file

@ -6,13 +6,13 @@
<exclude>gstreamer-0.10.3/gst/gstinterface.h</exclude>
<exclude>gstreamer-0.10.3/gst/gsturi.h</exclude>
</namespace>
<!--
</library>
<!--
<library name="gstcontroller-0.10.dll">
<namespace name="Gst">
<file>gst-plugins-base-0.10.3/gst-libs/gst/interfaces/xoverlay.h</file>
<dir>gst-plugins-base-0.10.3/gst-libs/gst/video</dir>
<exclude>gst-plugins-base-0.10.3/gst-libs/gst/video/video.h</exclude>
<dir>gstreamer-0.10.3/libs/gst/controller</dir>
</namespace>
-->
</library>
-->
</api>
</gapi-parser-input>