summaryrefslogtreecommitdiff
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2009-04-30 14:54:39 (GMT)
committer Sebastian Dröge <sebastian.droege@collabora.co.uk>2009-04-30 14:54:39 (GMT)
commit15ae032d0a83301bf19a456693a76b9820fb371e (patch) (side-by-side diff)
tree7d3eabfd55e830cd970c6d30bcec783dc781ab0d
parentf536534214f2cdc17f253af3e42854986393d56e (diff)
downloadgstreamer-sharp-15ae032d0a83301bf19a456693a76b9820fb371e.zip
gstreamer-sharp-15ae032d0a83301bf19a456693a76b9820fb371e.tar.gz
Fix Gst.Element bindings
Still missing: Support for creating new element subclasses and adding pad templates/setting details on them.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gstreamer-sharp/Element.custom215
-rw-r--r--gstreamer-sharp/Gstreamer.metadata29
-rw-r--r--gstreamer-sharp/Object.custom21
3 files changed, 203 insertions, 62 deletions
diff --git a/gstreamer-sharp/Element.custom b/gstreamer-sharp/Element.custom
index 8a0e7c0..9ab37ec 100644
--- a/gstreamer-sharp/Element.custom
+++ b/gstreamer-sharp/Element.custom
@@ -1,94 +1,193 @@
+[DllImport ("gobject-2.0-0.dll") ]
+static extern IntPtr g_object_ref (IntPtr raw);
+[DllImport ("gstreamer-0.10.dll") ]
+static extern bool gst_element_add_pad (IntPtr raw, IntPtr pad);
-public object this[string property] {
- get {
- return GetProperty (property).Val;
- }
- set {
- SetProperty (property, value);
- }
+public bool AddPad (Pad p) {
+ bool ret = gst_element_add_pad (this.Handle, p == null ? IntPtr.Zero : p.Handle);
+ if (ret)
+ g_object_ref (p.Handle);
+ return ret;
}
-public new GLib.Value GetProperty (string propertyName) {
- return base.GetProperty (propertyName);
-}
+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;
+ }
-public new void SetProperty (string propertyName, GLib.Value value) {
- base.SetProperty (propertyName, value);
+ return true;
}
-public void SetProperty (string propertyName, object value) {
- base.SetProperty (propertyName, new GLib.Value (value));
+public static void UnlinkMany (params Element [] elements) {
+ for (int i = 0; i < elements.Length - 1; i++) {
+ elements[i].Unlink (elements[i+1]);
+ }
}
-public void SetProperty (string propertyName, string value) {
- base.SetProperty (propertyName, new GLib.Value (value));
-}
+[DllImport ("gstreamer-0.10.dll") ]
+static extern int gst_iterator_next (IntPtr iterator, out IntPtr elem);
+[DllImport ("gstreamer-0.10.dll") ]
+static extern void gst_iterator_resync (IntPtr iterator);
+[DllImport ("gstreamer-0.10.dll") ]
+static extern void gst_iterator_free (IntPtr iterator);
+[DllImport ("gstreamer-0.10.dll") ]
+static extern IntPtr gst_element_iterate_pads (IntPtr element);
+[DllImport ("gstreamer-0.10.dll") ]
+static extern IntPtr gst_element_iterate_src_pads (IntPtr element);
+[DllImport ("gstreamer-0.10.dll") ]
+static extern IntPtr gst_element_iterate_sink_pads (IntPtr element);
+
+private class PadEnumerable : IEnumerable {
+ private class PadEnumerator : IEnumerator {
+ Hashtable seen = new Hashtable ();
+ IntPtr iterator;
+
+ private object current = null;
+ public object Current {
+ get {
+ return current;
+ }
+ }
+
+ public bool MoveNext () {
+ IntPtr raw_ret;
+ bool retry = false;
+
+ do {
+ int ret = gst_iterator_next (iterator, out raw_ret);
+ switch (ret) {
+ case 0:
+ return false;
+ case 1:
+ if (seen.Contains (raw_ret)) {
+ retry = true;
+ break;
+ }
+
+ seen.Add (raw_ret, null);
+ current = GLib.Object.GetObject (raw_ret, true);
+ return true;
+ case 2:
+ gst_iterator_resync (iterator);
+ break;
+ default:
+ case 3:
+ throw new Exception ("Error while iterating pads");
+ }
+ } while (retry);
-public void SetProperty (string propertyName, int value) {
- base.SetProperty (propertyName, new GLib.Value (value));
-}
+ return false;
+ }
-public void SetProperty (string propertyName, double value) {
- base.SetProperty (propertyName, new GLib.Value (value));
-}
+ public void Reset () {
+ seen.Clear ();
+ gst_iterator_resync (iterator);
+ }
-public void SetProperty (string propertyName, bool value) {
- base.SetProperty (propertyName, new GLib.Value (value));
-}
+ public PadEnumerator (IntPtr iterator) {
+ this.iterator = iterator;
+ }
+ }
+
+ private IntPtr iterator;
+ private PadEnumerator enumerator;
+
+ public PadEnumerable (IntPtr iterator) {
+ this.iterator = iterator;
+ this.enumerator = new PadEnumerator (iterator);
+ }
+ public IEnumerator GetEnumerator () {
+ return enumerator;
+ }
-public bool QueryPosition (Gst.Format format, out long current) {
- return gst_element_query_position (Handle, ref format, out current);
+ ~PadEnumerable () {
+ gst_iterator_free (iterator);
+ }
}
+public IEnumerable Pads {
+ get {
+ return new PadEnumerable (gst_element_iterate_pads (Handle));
+ }
+}
-public bool QueryDuration (Gst.Format format, out long duration) {
- return gst_element_query_duration (Handle, ref format, out duration);
+public IEnumerable SinkPads {
+ get {
+ return new PadEnumerable (gst_element_iterate_sink_pads (Handle));
+ }
}
-public void Connect (string signal, DynamicSignalHandler handler) {
- DynamicSignal.Connect (this, signal, handler);
+public IEnumerable SrcPads {
+ get {
+ return new PadEnumerable (gst_element_iterate_src_pads (Handle));
+ }
}
-public void Disconnect (string signal, DynamicSignalHandler handler) {
- DynamicSignal.Disconnect (this, signal, handler);
+public Gst.StateChangeReturn GetState (out Gst.State state, ulong timeout) {
+ Gst.State pending;
+ return GetState (out state, out pending, timeout);
}
-public object Emit (string signal, params object[] parameters) {
- return DynamicSignal.Emit (this, signal, parameters);
+[DllImport ("gstreamer-0.10.dll") ]
+static extern void gst_element_found_tags (IntPtr raw, IntPtr list);
+[DllImport ("gstreamer-0.10.dll") ]
+static extern IntPtr gst_tag_list_copy (IntPtr raw);
+
+public void FoundTags (Gst.TagList list) {
+ gst_element_found_tags (Handle, list == null ? IntPtr.Zero : gst_tag_list_copy (list.Handle));
}
-[DllImport ("gobject-2.0-0.dll") ]
-static extern IntPtr g_object_ref (IntPtr raw);
+[DllImport ("gstreamer-0.10.dll") ]
+static extern void gst_element_found_tags_for_pad (IntPtr raw, IntPtr pad, IntPtr list);
-public bool AddPad (Pad p) {
- bool ret = gst_element_add_pad (this.Handle, p == null ? IntPtr.Zero : p.Handle);
- if (ret)
- g_object_ref (p.Handle);
- return ret;
+public void FoundTagsForPad (Gst.Pad pad, Gst.TagList list) {
+ gst_element_found_tags_for_pad (Handle, pad == null ? IntPtr.Zero : pad.Handle, list == null ? IntPtr.Zero : gst_tag_list_copy (list.Handle));
}
-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;
- }
+[DllImport ("gstreamer-0.10.dll") ]
+static extern bool gst_element_post_message (IntPtr raw, IntPtr message);
+[DllImport ("gstreamer-0.10.dll") ]
+static extern IntPtr gst_mini_object_ref (IntPtr raw);
- return true;
+public bool PostMessage (Gst.Message message) {
+ bool raw_ret = gst_element_post_message (Handle, message == null ? IntPtr.Zero : gst_mini_object_ref (message.Handle));
+ bool ret = raw_ret;
+ return ret;
}
-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") ]
+static extern IntPtr gst_element_get_query_types (IntPtr raw);
+
+public Gst.QueryType[] GetQueryTypes () {
+ IntPtr raw_ret = gst_element_get_query_types (Handle);
+ if (raw_ret == IntPtr.Zero)
+ return new Gst.QueryType[] {};
+
+ ArrayList result = new ArrayList ();
+ bool term = false;
+ int ofs = 0;
+ while (!term) {
+ Gst.QueryType t = (Gst.QueryType) Marshal.ReadInt32 (raw_ret, ofs);
+ if (t == Gst.QueryType.None) {
+ term = true;
+ } else {
+ result.Add (t);
+ ofs += 4;
+ }
}
+
+ return (Gst.QueryType[]) result.ToArray (typeof (Gst.QueryType));
}
-[DllImport ("gstreamer-0.10.dll") ]
-private static extern bool gst_element_query_position (IntPtr raw, ref Format format, out long cur);
+ [DllImport("gstreamer-0.10.dll")]
+ static extern bool gst_element_send_event(IntPtr raw, IntPtr evnt);
-[DllImport ("gstreamer-0.10.dll") ]
-private static extern bool gst_element_query_duration (IntPtr raw, ref Format format, out long duration);
+ public bool SendEvent(Gst.Event evnt) {
+ bool raw_ret = gst_element_send_event(Handle, evnt == null ? IntPtr.Zero : gst_mini_object_ref (evnt.Handle));
+ bool ret = raw_ret;
+ return ret;
+ }
-[DllImport ("gstreamer-0.10.dll") ]
-static extern bool gst_element_add_pad (IntPtr raw, IntPtr pad);
diff --git a/gstreamer-sharp/Gstreamer.metadata b/gstreamer-sharp/Gstreamer.metadata
index 458fe9f..f2a1c73 100644
--- a/gstreamer-sharp/Gstreamer.metadata
+++ b/gstreamer-sharp/Gstreamer.metadata
@@ -249,13 +249,34 @@
<attr path="/api/namespace/class[@name='Debug']" 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='Element']/method[@cname='gst_element_link_many']" name="hidden">1</attr>
+ <attr path="/api/namespace/object[@name='Element']/field" name="hidden">1</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_unlink_many']" 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='Element']/method[@cname='gst_element_get_pad']" name="hidden">1</attr>
<attr path="/api/namespace/object[@name='Element']/signal[@name='NoMorePads']" name="name">HasNoMorePads</attr>
<attr path="/api/namespace/object[@name='Element']/method[@name='ContinueState']/parameters/*[@name='ret']" name="name">state_change_ret</attr>
- <attr path="/api/namespace/object[@name='Element']/method[@name='QueryPosition']" name="hidden">1</attr>
- <attr path="/api/namespace/object[@name='Element']/method[@name='QueryDuration']" name="hidden">1</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_query_position']/parameters/parameter[@name='format']" name="pass_as">ref</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_query_duration']/parameters/parameter[@name='format']" name="pass_as">ref</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_query_convert']/parameters/parameter[@name='dest_format']" name="pass_as">ref</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_get_compatible_pad']/return-type" name="owned">true</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_get_request_pad']/return-type" name="owned">true</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_get_static_pad']/return-type" name="owned">true</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_get_bus']/return-type" name="owned">true</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_get_clock']/return-type" name="owned">true</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_get_index']/return-type" name="owned">true</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_provide_clock']/return-type" name="owned">true</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_requires_clock']" name="name">GetRequiresClock</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_provides_clock']" name="name">GetProvidesClock</attr>
+ <move-node path="/api/namespace/object[@name='Element']/method[@cname='gst_element_state_get_name']">/api/namespace/class[@name='Util']</move-node>
+ <move-node path="/api/namespace/object[@name='Element']/method[@cname='gst_element_state_change_return_get_name']">/api/namespace/class[@name='Util']</move-node>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_found_tags']" name="hidden">1</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_found_tags_for_pad']" name="hidden">1</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_message_full']" name="hidden">1</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_post_message']" name="hidden">1</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_send_event']" name="hidden">1</attr>
+ <attr path="/api/namespace/object[@name='Element']/method[@cname='gst_element_seek_simple']" name="name">Seek</attr>
+ <remove-attr path="/api/namespace/object[@name='Element']/field[@name='CurrentState']" name="hidden"/>
<attr path="/api/namespace/object[@name='ElementFactory']/method[@name='Make']/return-type" name="owned">true</attr>
<attr path="/api/namespace/object[@name='ElementFactory']/method[@name='Create']/return-type" name="owned">true</attr>
diff --git a/gstreamer-sharp/Object.custom b/gstreamer-sharp/Object.custom
index b1e76e2..ccd5fd0 100644
--- a/gstreamer-sharp/Object.custom
+++ b/gstreamer-sharp/Object.custom
@@ -1,3 +1,24 @@
+public object this[string property] {
+ get {
+ return GetProperty (property).Val;
+ }
+ set {
+ SetProperty (property, new GLib.Value (value));
+ }
+}
+
+public void Connect (string signal, DynamicSignalHandler handler) {
+ DynamicSignal.Connect (this, signal, handler);
+}
+
+public void Disconnect (string signal, DynamicSignalHandler handler) {
+ DynamicSignal.Disconnect (this, signal, handler);
+}
+
+public object Emit (string signal, params object[] parameters) {
+ return DynamicSignal.Emit (this, signal, parameters);
+}
+
[DllImport ("gstreamer-0.10.dll") ]
static extern void gst_object_sink (IntPtr raw);
[DllImport ("gstreamer-0.10.dll") ]