Add Gst.Interfaces.PropertyProbe bindings
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 13 May 2009 15:03:49 +0000 (17:03 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 13 May 2009 15:03:49 +0000 (17:03 +0200)
README
gstreamer-sharp/Gstreamer.metadata
gstreamer-sharp/Makefile.am
gstreamer-sharp/override/ProbeNeededHandler.cs [new file with mode: 0644]
gstreamer-sharp/override/PropertyProbe.cs [new file with mode: 0644]
gstreamer-sharp/override/PropertyProbeAdapter.cs [new file with mode: 0644]

diff --git a/README b/README
index a5a2a97..811b92a 100644 (file)
--- a/README
+++ b/README
@@ -5,6 +5,7 @@ http://bugzilla.novell.com/show_bug.cgi?id=497667
 http://bugzilla.novell.com/show_bug.cgi?id=503048
 http://bugzilla.novell.com/show_bug.cgi?id=503060
 http://bugzilla.novell.com/show_bug.cgi?id=499900
+http://bugzilla.novell.com/show_bug.cgi?id=503467
 
 If you're using Mono < 2.4 you also need to apply:
 http://bugzilla.novell.com/show_bug.cgi?id=477396
index 2f75772..0d0eabe 100644 (file)
   <move-node path="/api/namespace/object[@cname='GstMixerOptions']/method[@cname='gst_mixer_options_list_changed']">/api/namespace/interface[@cname='GstMixer']</move-node>
 
   <attr path="/api/namespace/interface[@cname='GstNavigation']" name="hidden">1</attr>
-  <attr path="/api/namespace/interface[@cname='GstPropertyProbe']" name="hidden">1</attr>
+  <attr path="/api/namespace/interface[@cname='GstPropertyProbe']" name="name">PropertyProbe</attr>
 
   <attr path="/api/namespace/interface[@cname='GstTuner']" name="name">Tuner</attr>
   <remove-node path="/api/namespace/interface[@cname='GstTuner']/method[@cname='gst_tuner_norm_changed']/parameters/parameter[@name='tuner']" />
index 78716fe..c8affea 100644 (file)
@@ -60,7 +60,10 @@ overrides = \
        override/ColorBalanceAdapter.cs \
        override/ColorBalance.cs  \
        override/Mixer.cs \
-       override/MixerAdapter.cs
+       override/MixerAdapter.cs \
+       override/PropertyProbe.cs \
+       override/PropertyProbeAdapter.cs \
+       override/ProbeNeededHandler.cs
 
 build_sources = $(addprefix $(srcdir)/, $(sources))
 
diff --git a/gstreamer-sharp/override/ProbeNeededHandler.cs b/gstreamer-sharp/override/ProbeNeededHandler.cs
new file mode 100644 (file)
index 0000000..a40b9bd
--- /dev/null
@@ -0,0 +1,21 @@
+// This file was generated by the Gtk# code generator.
+// Any changes made will be lost if regenerated.
+
+namespace Gst.Interfaces {
+
+       using System;
+
+       public delegate void ProbeNeededHandler(object o, ProbeNeededArgs args);
+
+       public class ProbeNeededArgs : GLib.SignalArgs {
+               public string Property {
+                       get {
+                               IntPtr pspec = (IntPtr) Args[0];
+                               Gst.PropertyInfo pi = new Gst.PropertyInfo (pspec);
+
+                               return pi.Name;
+                       }
+               }
+
+       }
+}
diff --git a/gstreamer-sharp/override/PropertyProbe.cs b/gstreamer-sharp/override/PropertyProbe.cs
new file mode 100644 (file)
index 0000000..14e655d
--- /dev/null
@@ -0,0 +1,26 @@
+// This file was generated by the Gtk# code generator.
+// Changed to take strings instead of GParamSpecs.
+
+namespace Gst.Interfaces {
+
+       using System;
+
+       public interface PropertyProbe : GLib.IWrapper {
+               event Gst.Interfaces.ProbeNeededHandler ProbeNeeded;
+
+               string[] Properties { get; }
+               object[] GetValues (string property);
+               bool NeedsProbe (string property);
+               void Probe (string property);
+
+               object[] ProbeAndGetValues (string property);
+       }
+
+       [GLib.GInterface (typeof (PropertyProbeAdapter))]
+       public interface PropertyProbeImplementor : GLib.IWrapper {
+               string[] Properties { get; }
+               bool NeedsProbe (string property);
+               void ProbeProperty (string property);
+               object[] GetValues (string property);
+       }
+}
diff --git a/gstreamer-sharp/override/PropertyProbeAdapter.cs b/gstreamer-sharp/override/PropertyProbeAdapter.cs
new file mode 100644 (file)
index 0000000..f9e7d1a
--- /dev/null
@@ -0,0 +1,291 @@
+// This file was generated by the Gtk# code generator.
+// Changed to use strings instead of GParamSpecs
+
+namespace Gst.Interfaces {
+
+       using System;
+       using System.Runtime.InteropServices;
+       using System.Collections;
+
+       public class PropertyProbeAdapter : GLib.GInterfaceAdapter, Gst.Interfaces.PropertyProbe {
+
+               [StructLayout (LayoutKind.Sequential)]
+               struct GstPropertyProbeInterface {
+                       IntPtr ProbeNeeded;
+                       public GetPropertiesNativeDelegate GetProperties;
+                       public NeedsProbeNativeDelegate NeedsProbe;
+                       public ProbePropertyNativeDelegate ProbeProperty;
+                       public GetValuesNativeDelegate GetValues;
+                       [MarshalAs (UnmanagedType.ByValArray, SizeConst=4)]
+                       public IntPtr[] GstReserved;
+               }
+
+               static GstPropertyProbeInterface iface;
+
+               static PropertyProbeAdapter ()
+               {
+                       GLib.GType.Register (_gtype, typeof(PropertyProbeAdapter));
+                       iface.GetProperties = new GetPropertiesNativeDelegate (GetProperties_cb);
+                       iface.NeedsProbe = new NeedsProbeNativeDelegate (NeedsProbe_cb);
+                       iface.ProbeProperty = new ProbePropertyNativeDelegate (ProbeProperty_cb);
+                       iface.GetValues = new GetValuesNativeDelegate (GetValues_cb);
+               }
+
+               [GLib.CDeclCallback]
+               delegate IntPtr GetPropertiesNativeDelegate (IntPtr inst);
+
+               [DllImport("libglib-2.0-0.dll")]
+               static extern IntPtr g_object_class_find_property (IntPtr gclass, IntPtr name);
+
+               static IntPtr GetProperties_cb (IntPtr inst)
+               {
+                       try {
+                               PropertyProbeImplementor __obj = GLib.Object.GetObject (inst, false) as PropertyProbeImplementor;
+
+                               string[] properties = __obj.Properties;
+                               GLib.List properties_list = new GLib.List (typeof (IntPtr));
+                               IntPtr gclass = Marshal.ReadIntPtr (inst);
+                               foreach (string prop in properties) {
+                                       IntPtr name = GLib.Marshaller.StringToPtrGStrdup (prop);
+                                       IntPtr pspec = g_object_class_find_property (gclass, name);
+                                       GLib.Marshaller.Free (name);
+                                       if (pspec != IntPtr.Zero)
+                                               properties_list.Prepend (pspec);
+                               }
+
+                               /* FIXME: We leak the list! */
+                               return properties_list.Handle;
+                       } catch (Exception e) {
+                               GLib.ExceptionManager.RaiseUnhandledException (e, true);
+                               // NOTREACHED: above call does not return.
+                               throw e;
+                       }
+               }
+
+               [GLib.CDeclCallback]
+               delegate bool NeedsProbeNativeDelegate (IntPtr inst, uint prop_id, IntPtr pspec);
+
+               static bool NeedsProbe_cb (IntPtr inst, uint prop_id, IntPtr pspec)
+               {
+                       try {
+                               PropertyProbeImplementor __obj = GLib.Object.GetObject (inst, false) as PropertyProbeImplementor;
+                               Gst.PropertyInfo pi = new Gst.PropertyInfo (pspec);
+                               bool __result = __obj.NeedsProbe (pi.Name);
+                               return __result;
+                       } catch (Exception e) {
+                               GLib.ExceptionManager.RaiseUnhandledException (e, true);
+                               // NOTREACHED: above call does not return.
+                               throw e;
+                       }
+               }
+
+               [GLib.CDeclCallback]
+               delegate void ProbePropertyNativeDelegate (IntPtr inst, uint prop_id, IntPtr pspec);
+
+               static void ProbeProperty_cb (IntPtr inst, uint prop_id, IntPtr pspec)
+               {
+                       try {
+                               PropertyProbeImplementor __obj = GLib.Object.GetObject (inst, false) as PropertyProbeImplementor;
+                               Gst.PropertyInfo pi = new Gst.PropertyInfo (pspec);
+                               __obj.ProbeProperty (pi.Name);
+                       } catch (Exception e) {
+                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
+                       }
+               }
+
+               [GLib.CDeclCallback]
+               delegate IntPtr GetValuesNativeDelegate (IntPtr inst, uint prop_id, IntPtr pspec);
+
+               static IntPtr GetValues_cb (IntPtr inst, uint prop_id, IntPtr pspec)
+               {
+                       try {
+                               PropertyProbeImplementor __obj = GLib.Object.GetObject (inst, false) as PropertyProbeImplementor;
+                               Gst.PropertyInfo pi = new Gst.PropertyInfo (pspec);
+                               object[] values = __obj.GetValues (pi.Name);
+                               GLib.ValueArray va = new GLib.ValueArray ((uint) values.Length);
+
+                               foreach (object v in values)
+                                       va.Append (new GLib.Value (v));
+                               return va.Handle;
+                       } catch (Exception e) {
+                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
+                               // NOTREACHED: above call does not return.
+                               throw e;
+                       }
+               }
+
+               static int class_offset = 2 * IntPtr.Size;
+
+               static void Initialize (IntPtr ptr, IntPtr data)
+               {
+                       IntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset);
+                       GstPropertyProbeInterface native_iface = (GstPropertyProbeInterface) Marshal.PtrToStructure (ifaceptr, typeof (GstPropertyProbeInterface));
+                       native_iface.GetProperties = iface.GetProperties;
+                       native_iface.NeedsProbe = iface.NeedsProbe;
+                       native_iface.ProbeProperty = iface.ProbeProperty;
+                       native_iface.GetValues = iface.GetValues;
+                       Marshal.StructureToPtr (native_iface, ifaceptr, false);
+                       GCHandle gch = (GCHandle) data;
+                       gch.Free ();
+               }
+
+               public PropertyProbeAdapter ()
+               {
+                       InitHandler = new GLib.GInterfaceInitHandler (Initialize);
+               }
+
+               PropertyProbeImplementor implementor;
+
+               public PropertyProbeAdapter (PropertyProbeImplementor implementor)
+               {
+                       if (implementor == null)
+                               throw new ArgumentNullException ("implementor");
+                       this.implementor = implementor;
+               }
+
+               public PropertyProbeAdapter (IntPtr handle)
+               {
+                       if (!_gtype.IsInstance (handle))
+                               throw new ArgumentException ("The gobject doesn't implement the GInterface of this adapter", "handle");
+                       this.handle = handle;
+               }
+
+               [DllImport("gstinterfaces-0.10.dll")]
+               static extern IntPtr gst_property_probe_get_type();
+
+               private static GLib.GType _gtype = new GLib.GType (gst_property_probe_get_type ());
+
+               public override GLib.GType GType {
+                       get {
+                               return _gtype;
+                       }
+               }
+
+               IntPtr handle;
+               public override IntPtr Handle {
+                       get {
+                               if (handle != IntPtr.Zero)
+                                       return handle;
+                               return implementor == null ? IntPtr.Zero : implementor.Handle;
+                       }
+               }
+
+               public static PropertyProbe GetObject (IntPtr handle, bool owned)
+               {
+                       GLib.Object obj = GLib.Object.GetObject (handle, owned);
+                       return GetObject (obj);
+               }
+
+               public static PropertyProbe GetObject (GLib.Object obj)
+               {
+                       if (obj == null)
+                               return null;
+                       else if (obj is PropertyProbeImplementor)
+                               return new PropertyProbeAdapter (obj as PropertyProbeImplementor);
+                       else if (obj as PropertyProbe == null)
+                               return new PropertyProbeAdapter (obj.Handle);
+                       else
+                               return obj as PropertyProbe;
+               }
+
+               public PropertyProbeImplementor Implementor {
+                       get {
+                               return implementor;
+                       }
+               }
+               
+
+               [GLib.Signal("probe-needed")]
+               public event Gst.Interfaces.ProbeNeededHandler ProbeNeeded {
+                       add {
+                               GLib.Signal sig = GLib.Signal.Lookup (GLib.Object.GetObject (Handle), "probe-needed", typeof (Gst.Interfaces.ProbeNeededArgs));
+                               sig.AddDelegate (value);
+                       }
+                       remove {
+                               GLib.Signal sig = GLib.Signal.Lookup (GLib.Object.GetObject (Handle), "probe-needed", typeof (Gst.Interfaces.ProbeNeededArgs));
+                               sig.RemoveDelegate (value);
+                       }
+               }
+
+               [DllImport("gstinterfaces-0.10.dll")]
+               static extern bool gst_property_probe_needs_probe_name(IntPtr raw, IntPtr name);
+
+               public bool NeedsProbe(string name) {
+                       IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
+                       bool raw_ret = gst_property_probe_needs_probe_name(Handle, native_name);
+                       bool ret = raw_ret;
+                       GLib.Marshaller.Free (native_name);
+                       return ret;
+               }
+
+               [DllImport("gstinterfaces-0.10.dll")]
+               static extern void gst_property_probe_probe_property_name(IntPtr raw, IntPtr name);
+
+               public void Probe(string name) {
+                       IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
+                       gst_property_probe_probe_property_name(Handle, native_name);
+                       GLib.Marshaller.Free (native_name);
+               }
+
+               [DllImport("gstinterfaces-0.10.dll")]
+               static extern IntPtr gst_property_probe_get_properties(IntPtr raw);
+
+               public string[] Properties { 
+                       get {
+                               IntPtr raw_ret = gst_property_probe_get_properties(Handle);
+                               if (raw_ret == IntPtr.Zero)
+                                       return new string[] {};
+
+                               GLib.List raw_ret_list = new GLib.List(raw_ret, typeof (IntPtr));
+                               ArrayList ret = new ArrayList ();
+
+                               foreach (IntPtr pspec in raw_ret_list) {
+                                       Gst.PropertyInfo pi = new Gst.PropertyInfo (pspec);
+                                       ret.Add (pi.Name);
+                               }
+
+                               return (string[]) ret.ToArray (typeof (string));
+                       }
+               }
+
+               [DllImport("gstinterfaces-0.10.dll")]
+               static extern IntPtr gst_property_probe_get_values_name (IntPtr raw, IntPtr name);
+
+               public object[] GetValues (string name) {
+                       IntPtr raw_name = GLib.Marshaller.StringToPtrGStrdup (name);
+                       IntPtr raw_ret = gst_property_probe_get_values_name (Handle, raw_name);
+                       GLib.Marshaller.Free (raw_name);
+                       if (raw_ret == IntPtr.Zero)
+                               return new object[] {};
+
+                       GLib.ValueArray va = new GLib.ValueArray (raw_ret);
+                       ArrayList ret = new ArrayList ();
+                       foreach (GLib.Value v in va)
+                         ret.Add ((object) v.Val);
+
+                       va.Dispose ();
+
+                       return (object[]) ret.ToArray (typeof (object));                
+               }
+
+               [DllImport("gstinterfaces-0.10.dll")]
+               static extern IntPtr gst_property_probe_probe_and_get_values_name (IntPtr raw, IntPtr name);
+
+               public object[] ProbeAndGetValues (string name) {
+                       IntPtr raw_name = GLib.Marshaller.StringToPtrGStrdup (name);
+                       IntPtr raw_ret = gst_property_probe_probe_and_get_values_name (Handle, raw_name);
+                       GLib.Marshaller.Free (raw_name);
+                       if (raw_ret == IntPtr.Zero)
+                               return new object[] {};
+
+                       GLib.ValueArray va = new GLib.ValueArray (raw_ret);
+                       ArrayList ret = new ArrayList ();
+                       foreach (GLib.Value v in va)
+                         ret.Add ((object) v.Val);
+
+                       va.Dispose ();
+
+                       return (object[]) ret.ToArray (typeof (object));                
+               }
+       }
+}