From 8076872e0e5f7eb6343af23e0b2024c9edd273fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 11 Apr 2009 20:07:03 +0200 Subject: [PATCH] Fix Gst.Structure bindings --- gstreamer-sharp/Gstreamer.metadata | 39 +++++++++++++++++++++++ gstreamer-sharp/Makefile.am | 3 +- gstreamer-sharp/Structure.custom | 65 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 gstreamer-sharp/Structure.custom diff --git a/gstreamer-sharp/Gstreamer.metadata b/gstreamer-sharp/Gstreamer.metadata index 51009c8..c6344d1 100644 --- a/gstreamer-sharp/Gstreamer.metadata +++ b/gstreamer-sharp/Gstreamer.metadata @@ -294,6 +294,45 @@ 1 1 1 + 1 + constructor + + + 1 + 1 + 1 + true + SetValue + GetValue + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + GetCount + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + private + + 1 + + 1 1 diff --git a/gstreamer-sharp/Makefile.am b/gstreamer-sharp/Makefile.am index cc08953..5c7db40 100644 --- a/gstreamer-sharp/Makefile.am +++ b/gstreamer-sharp/Makefile.am @@ -64,7 +64,8 @@ customs = \ Parse.custom \ Object.custom \ MiniObject.custom \ - Registry.custom + Registry.custom \ + Structure.custom diff --git a/gstreamer-sharp/Structure.custom b/gstreamer-sharp/Structure.custom new file mode 100644 index 0000000..9ecdbd1 --- /dev/null +++ b/gstreamer-sharp/Structure.custom @@ -0,0 +1,65 @@ +public Structure (string name, params object[] fields) : this (name) +{ + Set (fields); +} + +public object Get (string field) { + GLib.Value v; + + v = GetValue (field); + return Gst.Value.GetValue (v); +} + +public void Set (string field, object value) { + SetValue (field, Gst.Value.CreateValue (value)); +} + +public void Set (params object[] fields) { + int i, length = fields.Length; + + if (length % 2 != 0) + throw new ArgumentException (); + + for (i = 0; i < length; i += 2) { + SetValue (fields[i] as string, Gst.Value.CreateValue (fields[i+1])); + } +} + +public object this [string field] { + set { + GLib.Value v; + + if (field == null) + throw new ArgumentNullException (); + + v = Gst.Value.CreateValue (value); + + Set (field, value); + } + get { + if (field == null) + throw new ArgumentNullException (); + + return Get (field); + } +} + +public IEnumerable Fields { + get { + ArrayList fields = new ArrayList (); + for (uint i = 0; i < Count; i++) + fields.Add (NthFieldName (i)); + + return fields; + } +} + +public static Structure NewFromString (string structure) { + IntPtr raw_ret = gst_structure_from_string (structure, IntPtr.Zero); + Gst.Structure ret = raw_ret == IntPtr.Zero ? null : (Gst.Structure) GLib.Opaque.GetOpaque (raw_ret, typeof (Gst.Structure), false); + return ret; +} + +[DllImport ("gstreamer-0.10.dll") ] +private static extern IntPtr gst_structure_from_string (string structure, IntPtr end); + -- 2.7.4