mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-20 06:08:14 +00:00
2006/08/20 Khaled Mohammed (khaled.mohammed@gmail.com)
git-svn-id: svn://anonsvn.mono-project.com/source/branches/abock/gstreamer-sharp@64117 e3ebcda4-bce8-0310-ba0a-eca2169e7518
This commit is contained in:
parent
3df192045a
commit
9b5a54fe8d
10 changed files with 273 additions and 19 deletions
|
@ -1,3 +1,11 @@
|
|||
2006-08-20 Khaled Mohammed <khaled.mohammed@gmail.com>
|
||||
* gstreamer-sharp/Buffer.custom: added Ref(), Unref() and Refcount()
|
||||
functionality
|
||||
* gstreamer-sharp/Gstreamer.metadata: suppressed auto generation of
|
||||
few functions to remove build warnings.
|
||||
* gstreamer-sharp/Pad.custom: added AddBufferProbe() and AddDataProbe()
|
||||
* tests: Added few more tests.
|
||||
|
||||
2006-08-11 Khaled Mohammed <khaled.mohammed@gmail.com>
|
||||
* gstreamer-sharp/Object.custom: overriden Dispose() function.
|
||||
* gstreamer-sharp/tests: added more tests
|
||||
|
|
|
@ -51,5 +51,18 @@
|
|||
return true;
|
||||
}
|
||||
|
||||
public bool RemoveMany(params Element[] elements)
|
||||
{
|
||||
if(elements == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach(Element element in elements) {
|
||||
if(element == null || !Remove(element)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,17 @@
|
|||
<attr path="/api/namespace/object[@name='Pipeline']" name="disable_gtype_ctor">1</attr>
|
||||
<attr path="/api/namespace/object[@cname='GstPipeline']/method[@name='GetBus']/return-type" name="owned">true</attr>
|
||||
<attr path="/api/namespace/object[@name='ElementFactory']/method[@name='Make']/return-type" name="owned">true</attr>
|
||||
|
||||
<attr path="/api/namespace/boxed[@name='Caps']/method[@name='FromString']/return-type" name="owned">true</attr>
|
||||
<attr path="/api/namespace/object[@name='Buffer']/method[@name='GetCaps']/return-type" name="owned">true</attr>
|
||||
<attr path="/api/namespace/object[@name='Object']/field[@name='Refcount']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@name='Pad']/method[@name='GetAllowedCaps']/return-type" name="owned">true</attr>
|
||||
<attr path="/api/namespace/object[@name='Pad']/method[@name='RemoveBufferProbe']" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/object[@name='Pad']/method[@name='AddBufferProbe']" name="hidden">1</attr>
|
||||
<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='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>
|
||||
<attr path="/api/namespace/object[@name='Bin']/field[@name='Children']" name="hidden">1</attr>
|
||||
|
|
|
@ -51,13 +51,16 @@ build_sources = $(addprefix $(srcdir)/, $(sources))
|
|||
|
||||
customs = \
|
||||
Bin.custom \
|
||||
Buffer.custom \
|
||||
Bus.custom \
|
||||
Caps.custom \
|
||||
Clock.custom \
|
||||
Debug.custom \
|
||||
Element.custom \
|
||||
Message.custom \
|
||||
Pad.custom \
|
||||
Object.custom
|
||||
|
||||
|
||||
build_customs = $(addprefix $(srcdir)/, $(customs))
|
||||
|
||||
|
|
|
@ -14,3 +14,101 @@
|
|||
{
|
||||
return gst_pad_query_duration(Handle, ref format, out duration);
|
||||
}
|
||||
|
||||
|
||||
public delegate bool BufferProbeDelegate(Pad pad, Gst.Buffer buffer);
|
||||
internal delegate bool BufferProbeNativeDelegate(IntPtr pad, IntPtr buf, IntPtr data);
|
||||
|
||||
internal class BufferProbeWrapper {
|
||||
internal BufferProbeNativeDelegate NativeFunc;
|
||||
BufferProbeDelegate managedFunc;
|
||||
|
||||
public BufferProbeWrapper(BufferProbeDelegate func)
|
||||
{
|
||||
managedFunc = func;
|
||||
if(func != null)
|
||||
NativeFunc = new BufferProbeNativeDelegate(BufferProbeMarshaller);
|
||||
}
|
||||
|
||||
public bool BufferProbeMarshaller(IntPtr raw_pad, IntPtr buf, IntPtr data)
|
||||
{
|
||||
Pad pad = GLib.Object.GetObject(raw_pad) as Pad;
|
||||
Gst.Buffer buffer = GLib.Opaque.GetOpaque(buf, typeof(Gst.Buffer), false) as Gst.Buffer;
|
||||
return (bool) (managedFunc (pad, buffer));
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("gstreamer-0.10.dll")]
|
||||
private static extern ulong gst_pad_add_buffer_probe(IntPtr pad, BufferProbeNativeDelegate func, IntPtr data);
|
||||
|
||||
public ulong AddBufferProbe(BufferProbeDelegate func)
|
||||
{
|
||||
BufferProbeWrapper func_wrapper;
|
||||
if(PersistentData["AddBufferProbe"] != null) {
|
||||
func_wrapper = PersistentData["AddBufferProbe"] as BufferProbeWrapper;
|
||||
}
|
||||
else
|
||||
{
|
||||
func_wrapper = new BufferProbeWrapper(func);
|
||||
PersistentData["AddBufferProbe"] = func_wrapper;
|
||||
}
|
||||
|
||||
//IntPtr data = (IntPtr) GCHandle.Alloc(func_wrapper);
|
||||
return gst_pad_add_buffer_probe(this.Handle, func_wrapper.NativeFunc, IntPtr.Zero);
|
||||
}
|
||||
|
||||
[DllImport("gstreamer-0.10.dll")]
|
||||
private static extern void gst_pad_remove_buffer_probe(IntPtr pad, uint handler_id);
|
||||
|
||||
public void RemoveBufferProbe(uint handler_id)
|
||||
{
|
||||
gst_pad_remove_buffer_probe(this.Handle, handler_id);
|
||||
PersistentData["AddBufferProbe"] = null;
|
||||
}
|
||||
|
||||
public delegate bool DataProbeDelegate (Pad pad, GLib.Opaque miniobject);
|
||||
internal delegate bool DataProbeNativeDelegate(IntPtr pad, IntPtr miniobj, IntPtr data);
|
||||
|
||||
internal class DataProbeWrapper {
|
||||
internal DataProbeNativeDelegate NativeFunc;
|
||||
DataProbeDelegate ManagedFunc;
|
||||
|
||||
public DataProbeWrapper(DataProbeDelegate func)
|
||||
{
|
||||
ManagedFunc = func;
|
||||
if(func != null)
|
||||
NativeFunc = new DataProbeNativeDelegate(DataProbeMarshaller);
|
||||
}
|
||||
|
||||
public bool DataProbeMarshaller (IntPtr raw_pad, IntPtr miniobj, IntPtr data)
|
||||
{
|
||||
Pad pad = GLib.Object.GetObject(raw_pad) as Pad;
|
||||
GLib.Opaque opaque = GLib.Opaque.GetOpaque(miniobj, typeof(GLib.Opaque), true);
|
||||
return ManagedFunc(pad, opaque);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("gstreamer-0.10.dll")]
|
||||
static extern uint gst_pad_add_data_probe(IntPtr pad, DataProbeNativeDelegate func, IntPtr data);
|
||||
|
||||
public uint AddDataProbe(DataProbeDelegate func)
|
||||
{
|
||||
DataProbeWrapper func_wrapper;
|
||||
if(PersistentData["AddDataProbe"] != null) {
|
||||
func_wrapper = PersistentData["AddDataProbe"] as DataProbeWrapper;
|
||||
} else {
|
||||
func_wrapper = new DataProbeWrapper(func);
|
||||
PersistentData["AddDataProbe"] = func_wrapper;
|
||||
}
|
||||
|
||||
return gst_pad_add_data_probe(this.Handle, func_wrapper.NativeFunc, IntPtr.Zero);
|
||||
}
|
||||
|
||||
[DllImport("gstreamer-0.10.dll")]
|
||||
static extern void gst_pad_remove_data_probe(IntPtr pad, uint handler_id);
|
||||
|
||||
public void RemoveDataProbe(uint handler_id)
|
||||
{
|
||||
gst_pad_remove_data_probe(this.Handle, handler_id);
|
||||
PersistentData["AddDataProbe"] = null;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
lib_LTLIBRARIES = libgstreamersharpglue-0.10.la
|
||||
|
||||
libgstreamersharpglue_0_10_la_SOURCES = \
|
||||
buffer.c \
|
||||
clock.c \
|
||||
message.c \
|
||||
miniobject.c \
|
||||
|
|
|
@ -48,7 +48,7 @@ public class BinTest
|
|||
bin.Dispose();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
[Test]
|
||||
public void TestGetByName()
|
||||
{
|
||||
|
@ -61,8 +61,8 @@ public class BinTest
|
|||
Assert.IsNotNull(e1);
|
||||
Assert.AreEqual(e1.Name, "element-name");
|
||||
|
||||
bin.Dispose();
|
||||
e1.Dispose();
|
||||
bin.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -71,7 +71,7 @@ public class BinTest
|
|||
Bin bin = new Bin("test-bin");
|
||||
|
||||
Element [] elements = new Element [] {
|
||||
ElementFactory.Make("fakesrc", "fakesrc"),
|
||||
ElementFactory.Make("fakesrc", "fakesrc"),
|
||||
ElementFactory.Make("audioconvert", "audioconvert"),
|
||||
ElementFactory.Make("wavenc", "wavenc"),
|
||||
ElementFactory.Make("fakesink", "fakesink")
|
||||
|
@ -82,30 +82,32 @@ public class BinTest
|
|||
}
|
||||
|
||||
Assert.AreEqual(elements.Length, bin.ChildrenCount);
|
||||
Element [] children = bin.Children;
|
||||
Element [] children = bin.Children;
|
||||
|
||||
for(int i = 0; i < elements.Length; i++) {
|
||||
for(int i = 0; i < elements.Length; i++) {
|
||||
Assert.AreEqual(elements[elements.Length - i - 1], children[i]);
|
||||
}
|
||||
|
||||
bin.Dispose();
|
||||
|
||||
foreach(Element e in elements)
|
||||
e.Dispose();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestInterface()
|
||||
{
|
||||
Bin bin = new Bin(String.Empty);
|
||||
Assert.IsNotNull(bin, "Could not create bin");
|
||||
|
||||
Element filesrc = ElementFactory.Make("filesrc", String.Empty);
|
||||
Element filesrc = ElementFactory.Make("filesrc", null);
|
||||
Assert.IsNotNull(filesrc, "Could not create filesrc");
|
||||
|
||||
bin.Add(filesrc);
|
||||
|
||||
bin.Dispose();
|
||||
filesrc.Dispose();
|
||||
|
||||
bin.Dispose();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -29,14 +29,11 @@ public class BufferTest {
|
|||
Gst.Buffer buffer = new Gst.Buffer(4);
|
||||
Caps caps = Caps.FromString("audio/x-raw-int");
|
||||
Assert.AreEqual(caps.Refcount, 1, "caps");
|
||||
Assert.IsNull(buffer.Caps);
|
||||
Assert.IsNull(buffer.Caps, "buffer.Caps is null???");
|
||||
|
||||
buffer.Caps = caps;
|
||||
Assert.AreEqual(caps.Refcount, 2, "caps");
|
||||
|
||||
Assert.AreEqual(caps, buffer.Caps);
|
||||
Assert.AreEqual(caps.Refcount, 2, "caps");
|
||||
|
||||
Caps caps2 = Caps.FromString("audio/x-raw-float");
|
||||
Assert.AreEqual(caps2.Refcount, 1, "caps2");
|
||||
|
||||
|
@ -55,7 +52,7 @@ public class BufferTest {
|
|||
caps.Dispose();
|
||||
caps2.Dispose();
|
||||
}
|
||||
|
||||
*/
|
||||
[Test]
|
||||
public void TestSubbuffer()
|
||||
{
|
||||
|
@ -87,6 +84,6 @@ public class BufferTest {
|
|||
|
||||
buffer.Dispose();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
|
127
tests/PadTest.cs
127
tests/PadTest.cs
|
@ -27,7 +27,7 @@ public class PadTest
|
|||
{
|
||||
Application.Deinit();
|
||||
}
|
||||
/*
|
||||
|
||||
[Test]
|
||||
public void TestPlainCreation()
|
||||
{
|
||||
|
@ -145,5 +145,130 @@ public class PadTest
|
|||
sink.Dispose();
|
||||
src.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRefcount()
|
||||
{
|
||||
Pad sink = new Pad("sink", PadDirection.Sink);
|
||||
Assert.IsNotNull(sink, "Pad could not be created");
|
||||
|
||||
Pad src = new Pad("src", PadDirection.Src);
|
||||
Assert.IsNotNull(src, "Pad could not be created");
|
||||
|
||||
Caps caps = Caps.FromString("foo/bar");
|
||||
|
||||
Assert.AreEqual(caps.Refcount, 1, "caps");
|
||||
|
||||
src.SetCaps(caps);
|
||||
sink.SetCaps(caps);
|
||||
|
||||
Assert.AreEqual(caps.Refcount, 3, "caps");
|
||||
|
||||
PadLinkReturn plr = src.Link(sink);
|
||||
Assert.AreEqual(plr, PadLinkReturn.Ok, "Pad link failed");
|
||||
|
||||
Assert.AreEqual(caps.Refcount, 3, "caps");
|
||||
|
||||
src.Unlink(sink);
|
||||
Assert.AreEqual(caps.Refcount, 3, "caps");
|
||||
|
||||
src.Dispose();
|
||||
sink.Dispose();
|
||||
Assert.AreEqual(caps.Refcount, 1, "caps");
|
||||
|
||||
caps.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetAllowedCaps()
|
||||
{
|
||||
/*
|
||||
Gst.Buffer buffer = new Gst.Buffer();
|
||||
|
||||
try {
|
||||
Pad pbuffer = (Pad) buffer;
|
||||
Caps pcaps = pbuffer.AllowedCaps;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Assert.Fail("buffer.AllowedCaps failed");
|
||||
}
|
||||
|
||||
buffer.Dispose();
|
||||
*/
|
||||
Pad sink = new Pad("sink", PadDirection.Sink);
|
||||
// try { Caps tcaps = sink.AllowedCaps; }
|
||||
// catch (Exception) { Assert.Fail("sink.AllowedCaps failed"); }
|
||||
|
||||
Pad src = new Pad("src", PadDirection.Src);
|
||||
Assert.IsNotNull(src);
|
||||
Caps caps = src.AllowedCaps;
|
||||
Assert.IsNull(caps);
|
||||
|
||||
caps = Caps.FromString("foo/bar");
|
||||
|
||||
src.SetCaps(caps);
|
||||
sink.SetCaps(caps);
|
||||
Assert.AreEqual(caps.Refcount, 3, "caps");
|
||||
|
||||
PadLinkReturn plr = src.Link(sink);
|
||||
Assert.AreEqual(plr, PadLinkReturn.Ok);
|
||||
|
||||
Caps gotcaps = src.AllowedCaps;
|
||||
Assert.IsNotNull(gotcaps);
|
||||
Assert.IsTrue(gotcaps.IsEqual(caps));
|
||||
|
||||
Assert.AreEqual(gotcaps.Refcount, 1, "gotcaps");
|
||||
gotcaps.Dispose();
|
||||
|
||||
src.Unlink(sink);
|
||||
Assert.AreEqual(caps.Refcount, 3, "caps");
|
||||
Assert.AreEqual(src.Refcount, 1, "src");
|
||||
Assert.AreEqual(sink.Refcount, 1, "sink");
|
||||
|
||||
src.Dispose();
|
||||
sink.Dispose();
|
||||
|
||||
Assert.AreEqual(caps.Refcount, 1, "caps");
|
||||
caps.Dispose();
|
||||
}
|
||||
|
||||
bool ProbeHandler(Pad pad, Gst.Buffer buffer)
|
||||
{
|
||||
//Assert.Fail("event worked");
|
||||
return false;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPushUnlinked()
|
||||
{
|
||||
Pad src = new Pad("src", PadDirection.Src);
|
||||
Assert.IsNotNull(src, "Could not create src");
|
||||
Caps caps = src.AllowedCaps;
|
||||
Assert.IsNull(caps);
|
||||
|
||||
caps = Caps.FromString("foo/bar");
|
||||
src.SetCaps(caps);
|
||||
Assert.AreEqual(caps.Refcount, 2, "caps");
|
||||
|
||||
Gst.Buffer buffer = new Gst.Buffer();
|
||||
buffer.Ref();
|
||||
Assert.AreEqual(src.Push(buffer), FlowReturn.NotLinked);
|
||||
Assert.AreEqual(buffer.Refcount, 1, "buffer");
|
||||
buffer.Dispose();
|
||||
|
||||
ulong handler_id = src.AddBufferProbe(new Pad.BufferProbeDelegate(ProbeHandler));
|
||||
buffer = new Gst.Buffer();
|
||||
buffer.Ref();
|
||||
Assert.AreEqual(src.Push(buffer), FlowReturn.Ok);
|
||||
buffer.Dispose();
|
||||
src.RemoveBufferProbe((uint)handler_id);
|
||||
|
||||
Assert.AreEqual(caps.Refcount, 2, "caps");
|
||||
Assert.AreEqual(src.Refcount, 1, "src");
|
||||
|
||||
src.Dispose();
|
||||
|
||||
Assert.AreEqual(caps.Refcount, 1, "caps");
|
||||
caps.Dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class PipelineTest
|
|||
{
|
||||
Application.Deinit();
|
||||
}
|
||||
/*
|
||||
|
||||
[Test]
|
||||
public void TestAsyncStateChangeEmpty()
|
||||
{
|
||||
|
@ -195,5 +195,4 @@ public class PipelineTest
|
|||
fakesrc.Dispose();
|
||||
fakesink.Dispose();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue