diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2009-05-31 21:10:45 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2009-05-31 21:10:45 +0200 |
commit | d17ba74fdc2867e5c1e5c15a3f5dc6fa22bba67d (patch) | |
tree | 09cf5d8cee60267d74fe2280ff701058f63dd8d0 | |
parent | 49607d317ab73b485565c8672ad3207b7413279e (diff) |
Add libgstcontroller bindings
-rw-r--r-- | gstreamer-sharp/Application.cs | 6 | ||||
-rw-r--r-- | gstreamer-sharp/ControlSource.custom | 338 | ||||
-rw-r--r-- | gstreamer-sharp/Controller.custom | 187 | ||||
-rw-r--r-- | gstreamer-sharp/Gstreamer.metadata | 53 | ||||
-rw-r--r-- | gstreamer-sharp/Makefile.am | 4 | ||||
-rw-r--r-- | gstreamer-sharp/glue/Makefile.am | 4 | ||||
-rw-r--r-- | gstreamer-sharp/glue/controller.c | 14 | ||||
-rw-r--r-- | gstreamer-sharp/glue/controlsource.c | 41 | ||||
-rw-r--r-- | gstreamer-sharp/gstreamer-api.raw | 304 | ||||
-rw-r--r-- | gstreamer-sharp/gstreamer-sharp.dll.config.in | 1 | ||||
-rw-r--r-- | source/gstreamer-sharp-source.xml | 9 |
11 files changed, 959 insertions, 2 deletions
diff --git a/gstreamer-sharp/Application.cs b/gstreamer-sharp/Application.cs index 1bd1408..80da1fc 100644 --- a/gstreamer-sharp/Application.cs +++ b/gstreamer-sharp/Application.cs @@ -43,2 +43,3 @@ namespace Gst { gst_init (ref argc, ref argv); + gst_controller_init (ref argc, ref argv); RegisterManagedTypes (); @@ -149,2 +150,4 @@ namespace Gst { + gst_controller_init (ref argc, ref argv_ptr); + if (argc <= 1) { @@ -165,2 +168,5 @@ namespace Gst { + [DllImport("libgstcontroller-0.10.dll") ] + private static extern void gst_controller_init (ref int argc, ref IntPtr argv); + [DllImport("libgstreamer-0.10.dll") ] diff --git a/gstreamer-sharp/ControlSource.custom b/gstreamer-sharp/ControlSource.custom new file mode 100644 index 0000000..d3cdc9a --- /dev/null +++ b/gstreamer-sharp/ControlSource.custom @@ -0,0 +1,338 @@ + +[DllImport ("gstreamersharpglue-0.10.dll") ] +static extern uint gst__controllersharp_gst__controller_controlsource_get_get_value_offset (); + +static uint get_value_offset = gst__controllersharp_gst__controller_controlsource_get_get_value_offset (); + +[StructLayout (LayoutKind.Sequential) ] +struct GstValueArray { + public IntPtr property_name; + public int nbsamples; + public ulong sample_interval; + public IntPtr values; +} + +[StructLayout (LayoutKind.Sequential) ] +struct GstControlSourceCallbacks { + public GetValueCallbackNative get_value; + public GetValueArrayCallbackNative get_value_array; +} + +delegate bool GetValueCallbackNative (IntPtr raw, ulong timestamp, ref GLib.Value val); +delegate bool GetValueArrayCallbackNative (IntPtr raw, ulong timestamp, ref GstValueArray va); + +public delegate bool GetValueCallback (ulong timestamp, ref GLib.Value value); +public delegate System.Array GetValueArrayCallback (ulong timestamp, int nsamples, ulong interval); + +private GetValueCallbackWrapper GetValue_cb_wrapper; +private GetValueArrayCallbackWrapper GetValueArray_cb_wrapper; + +private class GetValueCallbackWrapper { + public bool NativeCallback (IntPtr raw, ulong timestamp, ref GLib.Value val) { + try { + bool __ret = managed (timestamp, ref val); + + return __ret; + } catch (Exception e) { + GLib.ExceptionManager.RaiseUnhandledException (e, true); + // NOTREACHED: Above call does not return. + throw e; + } + } + + internal GetValueCallbackNative NativeDelegate; + GetValueCallback managed; + + public GetValueCallbackWrapper (GetValueCallback managed) { + this.managed = managed; + if (managed != null) + NativeDelegate = new GetValueCallbackNative (NativeCallback); + } + + public static GetValueCallback GetManagedDelegate (GetValueCallbackNative native) { + if (native == null) + return null; + GetValueCallbackWrapper wrapper = (GetValueCallbackWrapper) native.Target; + if (wrapper == null) + return null; + return wrapper.managed; + } +} + +private class GetValueArrayCallbackWrapper { + public bool NativeCallback (IntPtr raw, ulong timestamp, ref GstValueArray va) { + try { + System.Array values = managed (timestamp, va.nbsamples, va.sample_interval); + if (values == null) + return false; + + System.Type t = values.GetType (); + if (t == typeof (string[])) { + string[] ret = (string[]) values; + + for (int i = 0; i < va.nbsamples; i++) { + Marshal.WriteIntPtr (va.values, i * IntPtr.Size, GLib.Marshaller.StringToPtrGStrdup (ret[i])); + } + } else if (t == typeof (short[])) { + short[] ret = (short[]) values; + + for (int i = 0; i < va.nbsamples; i++) { + Marshal.WriteInt16 (va.values, i * 2, ret[i]); + } + } else if (t == typeof (ushort[])) { + ushort[] ret = (ushort[]) values; + + for (int i = 0; i < va.nbsamples; i++) { + Marshal.WriteInt16 (va.values, i * 2, (short) ret[i]); + } + } else if (t == typeof (int[])) { + int[] ret = (int[]) values; + + for (int i = 0; i < va.nbsamples; i++) { + Marshal.WriteInt32 (va.values, i * 4, ret[i]); + } + } else if (t == typeof (uint[])) { + uint[] ret = (uint[]) values; + + for (int i = 0; i < va.nbsamples; i++) { + Marshal.WriteInt32 (va.values, i * 4, (int) ret[i]); + } + } else if (t == typeof (long[])) { + long[] ret = (long[]) values; + + for (int i = 0; i < va.nbsamples; i++) { + Marshal.WriteInt64 (va.values, i * 8, ret[i]); + } + } else if (t == typeof (ulong[])) { + ulong[] ret = (ulong[]) values; + + for (int i = 0; i < va.nbsamples; i++) { + Marshal.WriteInt64 (va.values, i * 8, (long) ret[i]); + } + } else if (t == typeof (float[])) { + float[] ret = (float[]) values; + Marshal.Copy (ret, 0, va.values, va.nbsamples); + } else if (t == typeof (double[])) { + double[] ret = (double[]) values; + Marshal.Copy (ret, 0, va.values, va.nbsamples); + } else if (t == typeof (bool[])) { + bool[] ret = (bool[]) values; + + for (int i = 0; i < va.nbsamples; i++) { + Marshal.WriteInt32 (va.values, i * 4, ret[i] == false ? 0 : 1); + } + } + + return true; + } catch (Exception e) { + GLib.ExceptionManager.RaiseUnhandledException (e, true); + // NOTREACHED: Above call does not return. + throw e; + } + } + + internal GetValueArrayCallbackNative NativeDelegate; + GetValueArrayCallback managed; + + public GetValueArrayCallbackWrapper (GetValueArrayCallback managed) { + this.managed = managed; + if (managed != null) + NativeDelegate = new GetValueArrayCallbackNative (NativeCallback); + } + + public static GetValueArrayCallback GetManagedDelegate (GetValueArrayCallbackNative native) { + if (native == null) + return null; + GetValueArrayCallbackWrapper wrapper = (GetValueArrayCallbackWrapper) native.Target; + if (wrapper == null) + return null; + return wrapper.managed; + } +} + +public void SetCallbacks (GetValueCallback get_value, GetValueArrayCallback get_value_array) { + IntPtr off = new IntPtr (Handle.ToInt64 () + get_value_offset); + + GstControlSourceCallbacks cbs = (GstControlSourceCallbacks) Marshal.PtrToStructure (new IntPtr (Handle.ToInt64 () + get_value_offset), typeof (GstControlSourceCallbacks)); + + GetValueCallbackWrapper gv_wr = new GetValueCallbackWrapper (get_value); + GetValueArrayCallbackWrapper gva_wr = new GetValueArrayCallbackWrapper (get_value_array); + + GetValue_cb_wrapper = gv_wr; + GetValueArray_cb_wrapper = gva_wr; + + cbs.get_value = gv_wr.NativeCallback; + cbs.get_value_array = gva_wr.NativeCallback; + + Marshal.StructureToPtr (cbs, off, false); +} + +[DllImport ("gstreamersharpglue-0.10.dll") ] +static extern bool gst__controllersharp_gst__controller_controlsource_base_bind (IntPtr handle, IntPtr pspec); + +[DllImport ("gstreamersharpglue-0.10.dll") ] +static extern void gst__controllersharp_gst__controller_controlsource_override_bind (IntPtr gtype, BindNativeDelegate cb); + +[GLib.CDeclCallback] +delegate bool BindNativeDelegate (IntPtr handler, IntPtr pspec); + +static BindNativeDelegate Bind_cb_delegate; + +static BindNativeDelegate BindVMCallback { + get { + if (Bind_cb_delegate == null) + Bind_cb_delegate = new BindNativeDelegate (Bind_cb); + return Bind_cb_delegate; + } +} + +static void OverrideBind (GLib.GType gtype) { + OverrideBind (gtype, BindVMCallback); +} + +static void OverrideBind (GLib.GType gtype, BindNativeDelegate callback) { + gst__controllersharp_gst__controller_controlsource_override_bind (gtype.Val, callback); +} + +static bool Bind_cb (IntPtr inst, IntPtr pspec) { + try { + ControlSource __obj = GLib.Object.GetObject (inst, false) as ControlSource; + Gst.PropertyInfo pinfo = new Gst.PropertyInfo (pspec); + return __obj.OnBind (pinfo); + } catch (Exception e) { + GLib.ExceptionManager.RaiseUnhandledException (e, false); + return false; + } +} + +[DllImport ("libgobject-2.0-0.dll") ] +static extern IntPtr g_object_class_find_property (IntPtr klass, IntPtr property); + +[GLib.DefaultSignalHandler (Type=typeof (Gst.Controller.ControlSource), ConnectionMethod="OverrideBind") ] +protected virtual bool OnBind (Gst.PropertyInfo pinfo) { + IntPtr klass = Marshal.ReadIntPtr (Handle); + IntPtr native_property = GLib.Marshaller.StringToPtrGStrdup (pinfo.Name); + IntPtr pspec = g_object_class_find_property (klass, native_property); + GLib.Marshaller.Free (native_property); + + if (pspec == IntPtr.Zero) + return false; + + return gst__controllersharp_gst__controller_controlsource_base_bind (this.Handle, pspec); +} + +[DllImport ("libgstcontroller-0.10.dll") ] +static extern bool gst_control_source_get_value_array (IntPtr raw, ulong timestamp, ref GstValueArray value_array); + +[DllImport ("libglib-2.0-0.dll") ] +static extern IntPtr g_try_malloc (int size); + +static readonly Type[] supported_types = new Type[] { + typeof (string), + typeof (short), + typeof (ushort), + typeof (int), + typeof (uint), + typeof (long), + typeof (ulong), + typeof (float), + typeof (double), + typeof (bool) +}; + +public System.Array GetValueArray (ulong timestamp, int nsamples, ulong interval) { + GstValueArray va = new GstValueArray (); + GLib.Value v = GLib.Value.Empty; + + if (!GetValue (0, ref v)) + return null; + + System.Type t = v.Val.GetType (); + v.Dispose (); + + bool supported = false; + foreach (System.Type tmp in supported_types) + if (tmp == t) + supported = true; + if (!supported) + throw new Exception ("Unsupported type '" + t + "'"); + + int eltsize = Marshal.SizeOf (t); + va.values = g_try_malloc (eltsize * nsamples); + if (va.values == IntPtr.Zero) + throw new OutOfMemoryException (); + + va.nbsamples = nsamples; + va.sample_interval = interval; + + bool raw_ret = gst_control_source_get_value_array (Handle, timestamp, ref va); + + if (!raw_ret) { + GLib.Marshaller.Free (va.values); + return null; + } + + System.Array values = Array.CreateInstance (t, nsamples); + + if (t == typeof (string)) { + string[] ret = (string[]) values; + + for (int i = 0; i < nsamples; i++) { + IntPtr str = Marshal.ReadIntPtr (va.values, i * IntPtr.Size); + ret[i] = GLib.Marshaller.PtrToStringGFree (str); + } + } else if (t == typeof (short)) { + short[] ret = (short[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = Marshal.ReadInt16 (va.values, i * 2); + } + } else if (t == typeof (ushort)) { + ushort[] ret = (ushort[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = (ushort) Marshal.ReadInt16 (va.values, i * 2); + } + } else if (t == typeof (int)) { + int[] ret = (int[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = Marshal.ReadInt32 (va.values, i * 4); + } + } else if (t == typeof (uint)) { + uint[] ret = (uint[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = (uint) Marshal.ReadInt32 (va.values, i * 4); + } + } else if (t == typeof (long)) { + long[] ret = (long[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = Marshal.ReadInt64 (va.values, i * 8); + } + } else if (t == typeof (ulong)) { + ulong[] ret = (ulong[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = (ulong) Marshal.ReadInt64 (va.values, i * 8); + } + } else if (t == typeof (float)) { + float[] ret = (float[]) values; + Marshal.Copy (va.values, ret, 0, nsamples); + } else if (t == typeof (double)) { + double[] ret = (double[]) values; + Marshal.Copy (va.values, ret, 0, nsamples); + } else if (t == typeof (bool)) { + bool[] ret = (bool[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = Marshal.ReadInt32 (va.values, i * 4) != 0; + } + } + + GLib.Marshaller.Free (va.values); + + return values; +} + diff --git a/gstreamer-sharp/Controller.custom b/gstreamer-sharp/Controller.custom new file mode 100644 index 0000000..3613b1e --- /dev/null +++ b/gstreamer-sharp/Controller.custom @@ -0,0 +1,187 @@ +[DllImport ("libgstcontroller-0.10.dll") ] +static extern IntPtr gst_controller_new_list (IntPtr objekt, IntPtr list); + +public Controller (GLib.Object objekt, string[] properties) : base (IntPtr.Zero) { + if (GetType () != typeof (Controller)) { + throw new InvalidOperationException ("Can't override this constructor."); + } + GLib.List list = new GLib.List (properties, typeof (string), true, true); + + Raw = gst_controller_new_list (objekt == null ? IntPtr.Zero : objekt.Handle, list == null ? IntPtr.Zero : list.Handle); +} + +public Controller (GLib.Object objekt, string property) : this (objekt, new string[] {property}) { } + +[DllImport ("libgstcontroller-0.10.dll") ] +static extern bool gst_controller_remove_properties_list (IntPtr raw, IntPtr list); + +public bool RemoveProperties (string[] properties) { + GLib.List list = new GLib.List (properties, typeof (string), true, true); + + bool raw_ret = gst_controller_remove_properties_list (Handle, list == null ? IntPtr.Zero : list.Handle); + bool ret = raw_ret; + return ret; +} + +public bool RemoveProperty (string property) { + return RemoveProperties (new string[] {property}); +} + + +[DllImport ("gstreamersharpglue-0.10.dll") ] +extern static uint gst__controllersharp_gst__controller_controller_get_properties_offset (); + +static uint properties_offset = gst__controllersharp_gst__controller_controller_get_properties_offset (); +public string[] Properties { + get { + GLib.List properties_list; + + unsafe { + IntPtr* raw_ptr = (IntPtr*) ( ( (byte*) Handle) + properties_offset); + properties_list = new GLib.List ( (*raw_ptr), typeof (string)); + } + + string[] properties = new string[properties_list.Count]; + for (int i = 0; i < properties_list.Count; i++) + properties[i] = (string) properties_list[i]; + + return properties; + } +} + +[DllImport ("gstreamersharpglue-0.10.dll") ] +extern static uint gst__controllersharp_gst__controller_controller_get_object_offset (); + +static uint object_offset = gst__controllersharp_gst__controller_controller_get_object_offset (); +public GLib.Object Object { + get { + unsafe { + IntPtr* raw_ptr = (IntPtr*) ( ( (byte*) Handle) + object_offset); + return GLib.Object.GetObject ( (*raw_ptr)); + } + } +} + +[StructLayout (LayoutKind.Sequential) ] +struct GstValueArray { + public IntPtr property_name; + public int nbsamples; + public ulong sample_interval; + public IntPtr values; +} + +[DllImport ("libgstcontroller-0.10.dll") ] +static extern bool gst_controller_get_value_array (IntPtr raw, ulong timestamp, ref GstValueArray value_array); + +[DllImport ("libglib-2.0-0.dll") ] +static extern IntPtr g_try_malloc (int size); + +static readonly Type[] supported_types = new Type[] { + typeof (string), + typeof (short), + typeof (ushort), + typeof (int), + typeof (uint), + typeof (long), + typeof (ulong), + typeof (float), + typeof (double), + typeof (bool) +}; + +public System.Array GetValueArray (string property, ulong timestamp, int nsamples, ulong interval) { + GstValueArray va = new GstValueArray (); + + Gst.Object ob = (Gst.Object) this.Object; + Gst.PropertyInfo pi = ob.GetPropertyInfo (property); + System.Type t = (System.Type) pi.GType; + + bool supported = false; + foreach (System.Type tmp in supported_types) + if (tmp == t) + supported = true; + if (!supported) + throw new Exception ("Unsupported type '" + t + "'"); + + int eltsize = Marshal.SizeOf (t); + va.values = g_try_malloc (eltsize * nsamples); + if (va.values == IntPtr.Zero) + throw new OutOfMemoryException (); + + va.property_name = GLib.Marshaller.StringToPtrGStrdup (property); + va.nbsamples = nsamples; + va.sample_interval = interval; + + bool raw_ret = gst_controller_get_value_array (Handle, timestamp, ref va); + + if (!raw_ret) { + GLib.Marshaller.Free (va.property_name); + GLib.Marshaller.Free (va.values); + return null; + } + + System.Array values = Array.CreateInstance (t, nsamples); + + if (t == typeof (string)) { + string[] ret = (string[]) values; + + for (int i = 0; i < nsamples; i++) { + IntPtr str = Marshal.ReadIntPtr (va.values, i * IntPtr.Size); + ret[i] = GLib.Marshaller.PtrToStringGFree (str); + } + } else if (t == typeof (short)) { + short[] ret = (short[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = Marshal.ReadInt16 (va.values, i * 2); + } + } else if (t == typeof (ushort)) { + ushort[] ret = (ushort[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = (ushort) Marshal.ReadInt16 (va.values, i * 2); + } + } else if (t == typeof (int)) { + int[] ret = (int[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = Marshal.ReadInt32 (va.values, i * 4); + } + } else if (t == typeof (uint)) { + uint[] ret = (uint[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = (uint) Marshal.ReadInt32 (va.values, i * 4); + } + } else if (t == typeof (long)) { + long[] ret = (long[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = Marshal.ReadInt64 (va.values, i * 8); + } + } else if (t == typeof (ulong)) { + ulong[] ret = (ulong[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = (ulong) Marshal.ReadInt64 (va.values, i * 8); + } + } else if (t == typeof (float)) { + float[] ret = (float[]) values; + Marshal.Copy (va.values, ret, 0, nsamples); + } else if (t == typeof (double)) { + double[] ret = (double[]) values; + Marshal.Copy (va.values, ret, 0, nsamples); + } else if (t == typeof (bool)) { + bool[] ret = (bool[]) values; + + for (int i = 0; i < nsamples; i++) { + ret[i] = Marshal.ReadInt32 (va.values, i * 4) != 0; + } + } + + GLib.Marshaller.Free (va.property_name); + GLib.Marshaller.Free (va.values); + + return values; +} + diff --git a/gstreamer-sharp/Gstreamer.metadata b/gstreamer-sharp/Gstreamer.metadata index 0e051f6..2595784 100644 --- a/gstreamer-sharp/Gstreamer.metadata +++ b/gstreamer-sharp/Gstreamer.metadata @@ -1059,2 +1059,55 @@ + <!-- GStreamer Controller library --> + <attr path="/api/namespace/enum[@cname='GstInterpolateMode']" name="name">InterpolateMode</attr> + <attr path="/api/namespace/enum[@cname='GstLFOWaveform']" name="name">LFOWaveform</attr> + <attr path="/api/namespace/callback[@cname='GstControlSourceBind']" name="hidden">1</attr> + <attr path="/api/namespace/callback[@cname='GstControlSourceGetValue']" name="hidden">1</attr> + <attr path="/api/namespace/callback[@cname='GstControlSourceGetValueArray']" name="hidden">1</attr> + + <attr path="/api/namespace/object[@cname='GstController']" name="name">Controller</attr> + <attr path="/api/namespace/object[@cname='GstController']/property" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/method[@cname='gst_controller_get_all']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/method[@cname='gst_controller_get_control_source']/return-type" name="owned">true</attr> + <attr path="/api/namespace/object[@cname='GstController']/method[@cname='gst_controller_get_value_array']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/method[@cname='gst_controller_get_value_arrays']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/method[@cname='gst_controller_init']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/constructor[@cname='gst_controller_new']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/constructor[@cname='gst_controller_new_valist']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/constructor[@cname='gst_controller_new_list']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/method[@cname='gst_controller_remove_properties']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/method[@cname='gst_controller_remove_properties_list']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/method[@cname='gst_controller_remove_properties_valist']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/method[@cname='gst_controller_set']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/method[@cname='gst_controller_set_from_list']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/method[@cname='gst_controller_set_interpolation_mode']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/method[@cname='gst_controller_unset']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstController']/method[@cname='gst_controller_unset_all']" name="hidden">1</attr> + + <attr path="/api/namespace/object[@cname='GstControlSource']" name="name">ControlSource</attr> + <remove-node path="/api/namespace/object[@cname='GstControlSource']/class_struct" /> + <add-node path="/api/namespace/object[@cname='GstControlSource']"> + <class_struct cname="GstControlSourceClass"> + <field name="ParentClass" cname="parent_class" type="GObjectClass" /> + <method vm="bind" /> + <field name="GstReserved" cname="_gst_reserved" type="gpointer" array_len="4" /> + </class_struct> + <virtual_method name="Bind" cname="bind" hidden="1"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GstControlSource*" name="self" /> + <parameter type="GParamSpec*" name="pspec" /> + </parameters> + </virtual_method> + </add-node> + <attr path="/api/namespace/object[@cname='GstControlSource']/method[@cname='gst_control_source_get_value']/parameters/parameter[@name='value']" name="pass_as">ref</attr> + + <attr path="/api/namespace/object[@cname='GstInterpolationControlSource']" name="name">InterpolationControlSource</attr> + <attr path="/api/namespace/object[@cname='GstInterpolationControlSource']/method[@cname='gst_interpolation_control_source_set']/parameters/parameter[@name='value']" name="pass_as">ref</attr> + <attr path="/api/namespace/object[@cname='GstInterpolationControlSource']/method[@cname='gst_interpolation_control_source_set_from_list']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstInterpolationControlSource']/method[@cname='gst_interpolation_control_source_get_all']" name="hidden">1</attr> + <attr path="/api/namespace/object[@cname='GstLFOControlSource']" name="name">LFOControlSource</attr> + <attr path="/api/namespace/struct[@cname='GstTimedValue']" name="hidden">1</attr> + <attr path="/api/namespace/struct[@cname='GstValueArray']" name="hidden">1</attr> + + <!-- GStreamer Interfaces library --> diff --git a/gstreamer-sharp/Makefile.am b/gstreamer-sharp/Makefile.am index 57632ea..e363df6 100644 --- a/gstreamer-sharp/Makefile.am +++ b/gstreamer-sharp/Makefile.am @@ -111,3 +111,5 @@ customs = \ TunerChannel.custom \ - Adapter.custom + Adapter.custom \ + Controller.custom \ + ControlSource.custom diff --git a/gstreamer-sharp/glue/Makefile.am b/gstreamer-sharp/glue/Makefile.am index d7963eb..d35bf82 100644 --- a/gstreamer-sharp/glue/Makefile.am +++ b/gstreamer-sharp/glue/Makefile.am @@ -20,3 +20,5 @@ libgstreamersharpglue_0_10_la_SOURCES = \ tunernorm.c \ - adapter.c + adapter.c \ + controller.c \ + controlsource.c diff --git a/gstreamer-sharp/glue/controller.c b/gstreamer-sharp/glue/controller.c new file mode 100644 index 0000000..a540871 --- /dev/null +++ b/gstreamer-sharp/glue/controller.c @@ -0,0 +1,14 @@ +#include <gst/controller/gstcontroller.h> + +guint +gst__controllersharp_gst__controller_controller_get_properties_offset (void) +{ + return (guint)G_STRUCT_OFFSET (GstController, properties); +} + +guint +gst__controllersharp_gst__controller_controller_get_object_offset (void) +{ + return (guint)G_STRUCT_OFFSET (GstController, object); +} + diff --git a/gstreamer-sharp/glue/controlsource.c b/gstreamer-sharp/glue/controlsource.c new file mode 100644 index 0000000..173a09e --- /dev/null +++ b/gstreamer-sharp/glue/controlsource.c @@ -0,0 +1,41 @@ +#include <gst/gst.h> +#include <gst/controller/gstcontrolsource.h> + +guint +gst__controllersharp_gst__controller_controlsource_get_get_value_offset (void) +{ + return (guint)G_STRUCT_OFFSET (GstControlSource, get_value); +} + +const gchar *__gtype_prefix = "__gtksharp_"; +#define HAS_PREFIX(a) (*((guint64 *)(a)) == *((guint64 *) __gtype_prefix)) + +static GObjectClass * +get_threshold_class (GObject *obj) +{ + GType gtype = G_TYPE_FROM_INSTANCE (obj); + while (HAS_PREFIX (g_type_name (gtype))) + gtype = g_type_parent (gtype); + GObjectClass *klass = g_type_class_peek (gtype); + if (klass == NULL) klass = g_type_class_ref (gtype); + return klass; +} + +gboolean +gst__controllersharp_gst__controller_controlsource_base_bind (GstControlSource *csource, GParamSpec *pspec) +{ + GstControlSourceClass *parent = (GstControlSourceClass *) get_threshold_class (G_OBJECT (csource)); + if (parent->bind) + return parent->bind (csource, pspec); + return FALSE; +} + +void +gst__controllersharp_gst__controller_controlsource_override_bind (GType gtype, gpointer cb) +{ + GstControlSourceClass *klass = g_type_class_peek (gtype); + if (!klass) + klass = g_type_class_ref (gtype); + ((GstControlSourceClass *) klass)->bind = cb; +} + diff --git a/gstreamer-sharp/gstreamer-api.raw b/gstreamer-sharp/gstreamer-api.raw index e938735..fbf4af3 100644 --- a/gstreamer-sharp/gstreamer-api.raw +++ b/gstreamer-sharp/gstreamer-api.raw @@ -6875,2 +6875,306 @@ </namespace> + <namespace name="Gst.Controller" library="libgstcontroller-0.10.dll"> + <enum name="GstInterpolateMode" cname="GstInterpolateMode" type="enum"> + <member cname="GST_INTERPOLATE_NONE" name="None" /> + <member cname="GST_INTERPOLATE_TRIGGER" name="Trigger" /> + <member cname="GST_INTERPOLATE_LINEAR" name="Linear" /> + <member cname="GST_INTERPOLATE_QUADRATIC" name="Quadratic" /> + <member cname="GST_INTERPOLATE_CUBIC" name="Cubic" /> + <member cname="GST_INTERPOLATE_USER" name="User" /> + </enum> + <enum name="GstLFOWaveform" cname="GstLFOWaveform" type="enum"> + <member cname="GST_LFO_WAVEFORM_SINE" name="Sine" /> + <member cname="GST_LFO_WAVEFORM_SQUARE" name="Square" /> + <member cname="GST_LFO_WAVEFORM_SAW" name="Saw" /> + <member cname="GST_LFO_WAVEFORM_REVERSE_SAW" name="ReverseSaw" /> + <member cname="GST_LFO_WAVEFORM_TRIANGLE" name="Triangle" /> + </enum> + <callback name="GstControlSourceBind" cname="GstControlSourceBind"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GstControlSource*" name="self" /> + <parameter type="GParamSpec*" name="pspec" /> + </parameters> + </callback> + <callback name="GstControlSourceGetValue" cname="GstControlSourceGetValue"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GstControlSource*" name="self" /> + <parameter type="GstClockTime" name="timestamp" /> + <parameter type="GValue*" name="value" /> + </parameters> + </callback> + <callback name="GstControlSourceGetValueArray" cname="GstControlSourceGetValueArray"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GstControlSource*" name="self" /> + <parameter type="GstClockTime" name="timestamp" /> + <parameter type="GstValueArray*" name="value_array" /> + </parameters> + </callback> + <object name="GstController" cname="GstController" parent="GObject"> + <class_struct cname="GstControllerClass"> + <field name="ParentClass" cname="parent_class" type="GObjectClass" /> + <field name="GstReserved" cname="_gst_reserved" type="gpointer" array_len="GST_PADDING" /> + </class_struct> + <field name="Properties" cname="properties" type="GList*" /> + <field name="Lock" cname="lock" type="GMutex*" /> + <field name="Object" cname="object" type="GObject*" /> + <field name="Priv" cname="priv" type="GstControllerPrivate*" /> + <field name="GstReserved" cname="_gst_reserved" array_len="GST_PADDING - 1" type="gpointer" /> + <property name="ControlRate" cname="control-rate" type="guint64" readable="true" writeable="true" /> + <method name="Get" cname="gst_controller_get"> + <return-type type="GValue*" /> + <parameters> + <parameter type="gchar*" name="property_name" /> + <parameter type="GstClockTime" name="timestamp" /> + </parameters> + </method> + <method name="GetAll" cname="gst_controller_get_all" deprecated="1"> + <return-type type="const-GList*" /> + <parameters> + <parameter type="gchar*" name="property_name" /> + </parameters> + </method> + <method name="GetControlSource" cname="gst_controller_get_control_source"> + <return-type type="GstControlSource*" /> + <parameters> + <parameter type="gchar*" name="property_name" /> + </parameters> + </method> + <method name="GetType" cname="gst_controller_get_type" shared="true"> + <return-type type="GType" /> + </method> + <method name="GetValueArray" cname="gst_controller_get_value_array"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GstClockTime" name="timestamp" /> + <parameter type="GstValueArray*" name="value_array" /> + </parameters> + </method> + <method name="GetValueArrays" cname="gst_controller_get_value_arrays"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GstClockTime" name="timestamp" /> + <parameter type="GSList*" name="value_arrays" /> + </parameters> + </method> + <method name="Init" cname="gst_controller_init" shared="true"> + <return-type type="gboolean" /> + <parameters> + <parameter type="int*" name="argc" /> + <parameter type="char***" name="argv" /> + </parameters> + </method> + <constructor cname="gst_controller_new"> + <parameters> + <parameter type="GObject*" name="object" /> + <parameter ellipsis="true" /> + </parameters> + </constructor> + <constructor cname="gst_controller_new_list"> + <parameters> + <parameter type="GObject*" name="object" /> + <parameter type="GList*" name="list" /> + </parameters> + </constructor> + <constructor cname="gst_controller_new_valist"> + <parameters> + <parameter type="GObject*" name="object" /> + <parameter type="va_list" name="var_args" /> + </parameters> + </constructor> + <method name="RemoveProperties" cname="gst_controller_remove_properties"> + <return-type type="gboolean" /> + <parameters> + <parameter ellipsis="true" /> + </parameters> + </method> + <method name="RemovePropertiesList" cname="gst_controller_remove_properties_list"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GList*" name="list" /> + </parameters> + </method> + <method name="RemovePropertiesValist" cname="gst_controller_remove_properties_valist"> + <return-type type="gboolean" /> + <parameters> + <parameter type="va_list" name="var_args" /> + </parameters> + </method> + <method name="Set" cname="gst_controller_set" deprecated="1"> + <return-type type="gboolean" /> + <parameters> + <parameter type="gchar*" name="property_name" /> + <parameter type="GstClockTime" name="timestamp" /> + <parameter type="GValue*" name="value" /> + </parameters> + </method> + <method name="SetControlSource" cname="gst_controller_set_control_source"> + <return-type type="gboolean" /> + <parameters> + <parameter type="gchar*" name="property_name" /> + <parameter type="GstControlSource*" name="csource" /> + </parameters> + </method> + <method name="SetDisabled" cname="gst_controller_set_disabled"> + <return-type type="void" /> + <parameters> + <parameter type="gboolean" name="disabled" /> + </parameters> + </method> + <method name="SetFromList" cname="gst_controller_set_from_list" deprecated="1"> + <return-type type="gboolean" /> + <parameters> + <parameter type="gchar*" name="property_name" /> + <parameter type="GSList*" name="timedvalues" /> + </parameters> + </method> + <method name="SetInterpolationMode" cname="gst_controller_set_interpolation_mode" deprecated="1"> + <return-type type="gboolean" /> + <parameters> + <parameter type="gchar*" name="property_name" /> + <parameter type="GstInterpolateMode" name="mode" /> + </parameters> + </method> + <method name="SetPropertyDisabled" cname="gst_controller_set_property_disabled"> + <return-type type="void" /> + <parameters> + <parameter type="gchar*" name="property_name" /> + <parameter type="gboolean" name="disabled" /> + </parameters> + </method> + <method name="SuggestNextSync" cname="gst_controller_suggest_next_sync"> + <return-type type="GstClockTime" /> + </method> + <method name="SyncValues" cname="gst_controller_sync_values"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GstClockTime" name="timestamp" /> + </parameters> + </method> + <method name="Unset" cname="gst_controller_unset" deprecated="1"> + <return-type type="gboolean" /> + <parameters> + <parameter type="gchar*" name="property_name" /> + <parameter type="GstClockTime" name="timestamp" /> + </parameters> + </method> + <method name="UnsetAll" cname="gst_controller_unset_all" deprecated="1"> + <return-type type="gboolean" /> + <parameters> + <parameter type="gchar*" name="property_name" /> + </parameters> + </method> + </object> + <object name="GstControlSource" cname="GstControlSource" parent="GObject"> + <class_struct cname="GstControlSourceClass"> + <field name="ParentClass" cname="parent_class" type="GObjectClass" /> + <field name="Bind" cname="bind" type="GstControlSourceBind" /> + <field name="GstReserved" cname="_gst_reserved" type="gpointer" array_len="GST_PADDING" /> + </class_struct> + <field name="GetValue" cname="get_value" type="GstControlSourceGetValue" access="public" /> + <field name="GetValueArray" cname="get_value_array" type="GstControlSourceGetValueArray" access="public" /> + <field name="Bound" cname="bound" type="gboolean" /> + <field name="GstReserved" cname="_gst_reserved" array_len="GST_PADDING" type="gpointer" /> + <method name="Bind" cname="gst_control_source_bind"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GParamSpec*" name="pspec" /> + </parameters> + </method> + <method name="GetType" cname="gst_control_source_get_type" shared="true"> + <return-type type="GType" /> + </method> + <method name="GetValue" cname="gst_control_source_get_value"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GstClockTime" name="timestamp" /> + <parameter type="GValue*" name="value" /> + </parameters> + </method> + <method name="GetValueArray" cname="gst_control_source_get_value_array"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GstClockTime" name="timestamp" /> + <parameter type="GstValueArray*" name="value_array" /> + </parameters> + </method> + </object> + <object name="GstInterpolationControlSource" cname="GstInterpolationControlSource" parent="GstControlSource"> + <class_struct cname="GstInterpolationControlSourceClass"> + <field name="ParentClass" cname="parent_class" type="GstControlSourceClass" /> + <field name="GstReserved" cname="_gst_reserved" type="gpointer" array_len="GST_PADDING" /> + </class_struct> + <field name="Lock" cname="lock" type="GMutex*" /> + <field name="Priv" cname="priv" type="GstInterpolationControlSourcePrivate*" /> + <field name="GstReserved" cname="_gst_reserved" array_len="GST_PADDING" type="gpointer" /> + <method name="GetAll" cname="gst_interpolation_control_source_get_all"> + <return-type type="GList*" /> + </method> + <method name="GetCount" cname="gst_interpolation_control_source_get_count"> + <return-type type="gint" /> + </method> + <method name="GetType" cname="gst_interpolation_control_source_get_type" shared="true"> + <return-type type="GType" /> + </method> + <constructor cname="gst_interpolation_control_source_new" /> + <method name="Set" cname="gst_interpolation_control_source_set"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GstClockTime" name="timestamp" /> + <parameter type="GValue*" name="value" /> + </parameters> + </method> + <method name="SetFromList" cname="gst_interpolation_control_source_set_from_list"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GSList*" name="timedvalues" /> + </parameters> + </method> + <method name="SetInterpolationMode" cname="gst_interpolation_control_source_set_interpolation_mode"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GstInterpolateMode" name="mode" /> + </parameters> + </method> + <method name="Unset" cname="gst_interpolation_control_source_unset"> + <return-type type="gboolean" /> + <parameters> + <parameter type="GstClockTime" name="timestamp" /> + </parameters> + </method> + <method name="UnsetAll" cname="gst_interpolation_control_source_unset_all"> + <return-type type="void" /> + </method> + </object> + <object name="GstLFOControlSource" cname="GstLFOControlSource" parent="GstControlSource"> + <class_struct cname="GstLFOControlSourceClass"> + <field name="ParentClass" cname="parent_class" type="GstControlSourceClass" /> + <field name="GstReserved" cname="_gst_reserved" type="gpointer" array_len="GST_PADDING" /> + </class_struct> + <field name="Priv" cname="priv" type="GstLFOControlSourcePrivate*" /> + <field name="Lock" cname="lock" type="GMutex*" /> + <field name="GstReserved" cname="_gst_reserved" array_len="GST_PADDING" type="gpointer" /> + <property name="Waveform" cname="waveform" type="GstLfoWaveform" readable="true" writeable="true" /> + <property name="Frequency" cname="frequency" type="gdouble" readable="true" writeable="true" /> + <property name="Timeshift" cname="timeshift" type="guint64" readable="true" writeable="true" /> + <property name="Amplitude" cname="amplitude" type="GValue" readable="true" writeable="true" /> + <property name="Offset" cname="offset" type="GValue" readable="true" writeable="true" /> + <method name="GetType" cname="gst_lfo_control_source_get_type" shared="true"> + <return-type type="GType" /> + </method> + <constructor cname="gst_lfo_control_source_new" /> + </object> + <struct name="GstTimedValue" cname="GstTimedValue"> + <field name="Timestamp" cname="timestamp" type="GstClockTime" /> + <field name="Value" cname="value" type="GValue" /> + </struct> + <struct name="GstValueArray" cname="GstValueArray"> + <field name="PropertyName" cname="property_name" type="gchar*" /> + <field name="Nbsamples" cname="nbsamples" type="gint" /> + <field name="SampleInterval" cname="sample_interval" type="GstClockTime" /> + <field name="Values" cname="values" type="gpointer*" /> + </struct> + </namespace> <namespace name="Gst.Interfaces" library="libgstinterfaces-0.10.dll"> diff --git a/gstreamer-sharp/gstreamer-sharp.dll.config.in b/gstreamer-sharp/gstreamer-sharp.dll.config.in index 4a168ed..f4e440f 100644 --- a/gstreamer-sharp/gstreamer-sharp.dll.config.in +++ b/gstreamer-sharp/gstreamer-sharp.dll.config.in @@ -5,2 +5,3 @@ <dllmap dll="libgstbase-0.10.dll" target="libgstbase-0.10@LIB_PREFIX@.0@LIB_SUFFIX@/> + <dllmap dll="libgstcontroller-0.10.dll" target="libgstcontroller-0.10@LIB_PREFIX@.0@LIB_SUFFIX@/> <dllmap dll="libgstinterfaces-0.10.dll" target="libgstinterfaces-0.10@LIB_PREFIX@.0@LIB_SUFFIX@/> diff --git a/source/gstreamer-sharp-source.xml b/source/gstreamer-sharp-source.xml index 0ba19d1..34891f2 100644 --- a/source/gstreamer-sharp-source.xml +++ b/source/gstreamer-sharp-source.xml @@ -41,2 +41,11 @@ </library> + <library name="libgstcontroller-0.10.dll"> + <namespace name="Gst.Controller"> + <dir>../../gstreamer/libs/gst/controller</dir> + <!-- Needs to be bound --> + <exclude>../../gstreamer/libs/gst/controller/gstcontrollerprivate.h</exclude> + <exclude>../../gstreamer/libs/gst/controller/gstinterpolationcontrolsourceprivate.h</exclude> + <exclude>../../gstreamer/libs/gst/controller/gstlfocontrolsourceprivate.h</exclude> + </namespace> + </library> <library name="libgstinterfaces-0.10.dll"> |