mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-20 06:08:14 +00:00
Fix Gst.Preset bindings
As C# interfaces don't allow a default implementation we add a static Gst.PresetDefault class that provides static methods for calling the default GstPreset method implementations.
This commit is contained in:
parent
71f1ba9080
commit
31797cf4e3
4 changed files with 243 additions and 1 deletions
|
@ -729,6 +729,18 @@
|
|||
<attr path="/api/namespace/object[@name='PluginFeature']/method[@cname='gst_plugin_feature_type_name_filter']" name="hidden">1</attr>
|
||||
|
||||
<attr path="/api/namespace/class[@name='Print']" name="hidden">1</attr>
|
||||
|
||||
<attr path="/api/namespace/interface[@name='Preset']/property" name="hidden">1</attr>
|
||||
<attr path="/api/namespace/interface[@name='Preset']/method[@cname='gst_preset_get_preset_names']/return-type" name="owned">true</attr>
|
||||
<attr path="/api/namespace/interface[@name='Preset']/method[@cname='gst_preset_get_preset_names']/return-type" name="null_term_array">true</attr>
|
||||
<attr path="/api/namespace/interface[@name='Preset']/virtual_method[@cname='get_preset_names']/return-type" name="owned">true</attr>
|
||||
<attr path="/api/namespace/interface[@name='Preset']/virtual_method[@cname='get_preset_names']/return-type" name="null_term_array">true</attr>
|
||||
<attr path="/api/namespace/interface[@name='Preset']/method[@cname='gst_preset_get_property_names']/return-type" name="owned">true</attr>
|
||||
<attr path="/api/namespace/interface[@name='Preset']/method[@cname='gst_preset_get_property_names']/return-type" name="null_term_array">true</attr>
|
||||
<attr path="/api/namespace/interface[@name='Preset']/virtual_method[@cname='get_property_names']/return-type" name="owned">true</attr>
|
||||
<attr path="/api/namespace/interface[@name='Preset']/virtual_method[@cname='get_property_names']/return-type" name="null_term_array">true</attr>
|
||||
<attr path="/api/namespace/interface[@name='Preset']/method[@cname='gst_preset_get_meta']/parameters/parameter[@name='value']" name="pass_as">out</attr>
|
||||
<attr path="/api/namespace/interface[@name='Preset']/virtual_method[@cname='get_meta']/parameters/parameter[@name='value']" name="pass_as">out</attr>
|
||||
|
||||
<change-node-type path="/api/namespace/object[@name='Query']">boxed</change-node-type>
|
||||
<attr path="/api/namespace/boxed[@name='Query']" name="opaque">true</attr>
|
||||
|
|
|
@ -49,7 +49,8 @@ sources = \
|
|||
plugins-base/TypeFindElement.cs \
|
||||
GstSharp.PadQueryTypeFunctionNative.cs \
|
||||
PadQueryTypeFunction.cs \
|
||||
TypeFindDelegates.cs
|
||||
TypeFindDelegates.cs \
|
||||
PresetDefault.cs
|
||||
|
||||
overrides = \
|
||||
override/URIHandlerAdapter.cs
|
||||
|
|
115
gstreamer-sharp/PresetDefault.cs
Normal file
115
gstreamer-sharp/PresetDefault.cs
Normal file
|
@ -0,0 +1,115 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Gst {
|
||||
public static class PresetDefault {
|
||||
[StructLayout (LayoutKind.Sequential) ]
|
||||
struct GstPresetInterface {
|
||||
public GetPresetNamesNativeDelegate GetPresetNames;
|
||||
public GetPropertyNamesNativeDelegate GetPropertyNames;
|
||||
public LoadPresetNativeDelegate LoadPreset;
|
||||
public SavePresetNativeDelegate SavePreset;
|
||||
public RenamePresetNativeDelegate RenamePreset;
|
||||
public DeletePresetNativeDelegate DeletePreset;
|
||||
public SetMetaNativeDelegate SetMeta;
|
||||
public GetMetaNativeDelegate GetMeta;
|
||||
[MarshalAs (UnmanagedType.ByValArray, SizeConst=4) ]
|
||||
public IntPtr[] GstReserved;
|
||||
}
|
||||
delegate IntPtr GetPresetNamesNativeDelegate (IntPtr inst);
|
||||
delegate IntPtr GetPropertyNamesNativeDelegate (IntPtr inst);
|
||||
delegate bool LoadPresetNativeDelegate (IntPtr inst, IntPtr name);
|
||||
delegate bool SavePresetNativeDelegate (IntPtr inst, IntPtr name);
|
||||
delegate bool RenamePresetNativeDelegate (IntPtr inst, IntPtr old_name, IntPtr new_name);
|
||||
delegate bool DeletePresetNativeDelegate (IntPtr inst, IntPtr name);
|
||||
delegate bool SetMetaNativeDelegate (IntPtr inst, IntPtr name, IntPtr tag, IntPtr value);
|
||||
delegate bool GetMetaNativeDelegate (IntPtr inst, IntPtr name, IntPtr tag, out IntPtr value);
|
||||
|
||||
static GstPresetInterface default_iface;
|
||||
|
||||
[DllImport ("libgobject-2.0-0.dll") ]
|
||||
static extern IntPtr g_type_default_interface_ref (IntPtr type);
|
||||
[DllImport ("gstreamer-0.10.dll") ]
|
||||
static extern IntPtr gst_preset_get_type();
|
||||
|
||||
static PresetDefault () {
|
||||
IntPtr type = gst_preset_get_type ();
|
||||
if (type == IntPtr.Zero)
|
||||
throw new Exception ("Can't get GstPreset interface type");
|
||||
IntPtr native_iface = g_type_default_interface_ref (type);
|
||||
if (native_iface == IntPtr.Zero)
|
||||
throw new Exception ("Can't get GstPreset default interface vtable");
|
||||
default_iface = (GstPresetInterface) Marshal.PtrToStructure (native_iface, typeof (GstPresetInterface));
|
||||
}
|
||||
|
||||
public static bool DeletePreset (GLib.Object o, string name) {
|
||||
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
|
||||
bool raw_ret = default_iface.DeletePreset (o.Handle, native_name);
|
||||
bool ret = raw_ret;
|
||||
GLib.Marshaller.Free (native_name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static string[] GetPropertyNames (GLib.Object o) {
|
||||
IntPtr raw_ret = default_iface.GetPropertyNames (o.Handle);
|
||||
string[] ret = GLib.Marshaller.NullTermPtrToStringArray (raw_ret, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static bool RenamePreset (GLib.Object o, string old_name, string new_name) {
|
||||
IntPtr native_old_name = GLib.Marshaller.StringToPtrGStrdup (old_name);
|
||||
IntPtr native_new_name = GLib.Marshaller.StringToPtrGStrdup (new_name);
|
||||
bool raw_ret = default_iface.RenamePreset (o.Handle, native_old_name, native_new_name);
|
||||
bool ret = raw_ret;
|
||||
GLib.Marshaller.Free (native_old_name);
|
||||
GLib.Marshaller.Free (native_new_name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static bool SetMeta (GLib.Object o, string name, string tag, string value) {
|
||||
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
|
||||
IntPtr native_tag = GLib.Marshaller.StringToPtrGStrdup (tag);
|
||||
IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value);
|
||||
bool raw_ret = default_iface.SetMeta (o.Handle, native_name, native_tag, native_value);
|
||||
bool ret = raw_ret;
|
||||
GLib.Marshaller.Free (native_name);
|
||||
GLib.Marshaller.Free (native_tag);
|
||||
GLib.Marshaller.Free (native_value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static bool LoadPreset (GLib.Object o, string name) {
|
||||
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
|
||||
bool raw_ret = default_iface.LoadPreset (o.Handle, native_name);
|
||||
bool ret = raw_ret;
|
||||
GLib.Marshaller.Free (native_name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static bool GetMeta (GLib.Object o, string name, string tag, out string value) {
|
||||
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
|
||||
IntPtr native_tag = GLib.Marshaller.StringToPtrGStrdup (tag);
|
||||
IntPtr native_value;
|
||||
bool raw_ret = default_iface.GetMeta (o.Handle, native_name, native_tag, out native_value);
|
||||
bool ret = raw_ret;
|
||||
GLib.Marshaller.Free (native_name);
|
||||
GLib.Marshaller.Free (native_tag);
|
||||
value = GLib.Marshaller.PtrToStringGFree (native_value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static string[] GetPresetNames (GLib.Object o) {
|
||||
IntPtr raw_ret = default_iface.GetPresetNames (o.Handle);
|
||||
string[] ret = GLib.Marshaller.NullTermPtrToStringArray (raw_ret, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static bool SavePreset (GLib.Object o, string name) {
|
||||
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
|
||||
bool raw_ret = default_iface.SavePreset (o.Handle, native_name);
|
||||
bool ret = raw_ret;
|
||||
GLib.Marshaller.Free (native_name);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -794,6 +794,120 @@
|
|||
</parameters>
|
||||
</method>
|
||||
</interface>
|
||||
<interface name="Preset" cname="GstPreset">
|
||||
<class_struct cname="GstPresetInterface">
|
||||
<field name="Parent" cname="parent" type="GTypeInterface" />
|
||||
<method vm="get_preset_names" />
|
||||
<method vm="get_property_names" />
|
||||
<method vm="load_preset" />
|
||||
<method vm="save_preset" />
|
||||
<method vm="rename_preset" />
|
||||
<method vm="delete_preset" />
|
||||
<method vm="set_meta" />
|
||||
<method vm="get_meta" />
|
||||
<field name="GstReserved" cname="_gst_reserved" type="gpointer" array_len="GST_PADDING" />
|
||||
</class_struct>
|
||||
<property name="PresetName" cname="preset-name" type="gchar*" writeable="true" />
|
||||
<virtual_method name="GetPresetNames" cname="get_preset_names">
|
||||
<return-type type="gchar**" />
|
||||
<parameters />
|
||||
</virtual_method>
|
||||
<virtual_method name="GetPropertyNames" cname="get_property_names">
|
||||
<return-type type="gchar**" />
|
||||
<parameters />
|
||||
</virtual_method>
|
||||
<virtual_method name="LoadPreset" cname="load_preset">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="const-gchar*" name="name" />
|
||||
</parameters>
|
||||
</virtual_method>
|
||||
<virtual_method name="SavePreset" cname="save_preset">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="const-gchar*" name="name" />
|
||||
</parameters>
|
||||
</virtual_method>
|
||||
<virtual_method name="RenamePreset" cname="rename_preset">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="const-gchar*" name="old_name" />
|
||||
<parameter type="const-gchar*" name="new_name" />
|
||||
</parameters>
|
||||
</virtual_method>
|
||||
<virtual_method name="DeletePreset" cname="delete_preset">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="const-gchar*" name="name" />
|
||||
</parameters>
|
||||
</virtual_method>
|
||||
<virtual_method name="SetMeta" cname="set_meta">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="const-gchar*" name="name" />
|
||||
<parameter type="const-gchar*" name="tag" />
|
||||
<parameter type="const-gchar*" name="value" />
|
||||
</parameters>
|
||||
</virtual_method>
|
||||
<virtual_method name="GetMeta" cname="get_meta">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="const-gchar*" name="name" />
|
||||
<parameter type="const-gchar*" name="tag" />
|
||||
<parameter type="gchar**" name="value" />
|
||||
</parameters>
|
||||
</virtual_method>
|
||||
<method name="DeletePreset" cname="gst_preset_delete_preset">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="const-gchar*" name="name" />
|
||||
</parameters>
|
||||
</method>
|
||||
<method name="GetMeta" cname="gst_preset_get_meta">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="const-gchar*" name="name" />
|
||||
<parameter type="const-gchar*" name="tag" />
|
||||
<parameter type="gchar**" name="value" />
|
||||
</parameters>
|
||||
</method>
|
||||
<method name="GetPresetNames" cname="gst_preset_get_preset_names">
|
||||
<return-type type="gchar**" />
|
||||
</method>
|
||||
<method name="GetPropertyNames" cname="gst_preset_get_property_names">
|
||||
<return-type type="gchar**" />
|
||||
</method>
|
||||
<method name="GetType" cname="gst_preset_get_type" shared="true">
|
||||
<return-type type="GType" />
|
||||
</method>
|
||||
<method name="LoadPreset" cname="gst_preset_load_preset">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="const-gchar*" name="name" />
|
||||
</parameters>
|
||||
</method>
|
||||
<method name="RenamePreset" cname="gst_preset_rename_preset">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="const-gchar*" name="old_name" />
|
||||
<parameter type="const-gchar*" name="new_name" />
|
||||
</parameters>
|
||||
</method>
|
||||
<method name="SavePreset" cname="gst_preset_save_preset">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="const-gchar*" name="name" />
|
||||
</parameters>
|
||||
</method>
|
||||
<method name="SetMeta" cname="gst_preset_set_meta">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="const-gchar*" name="name" />
|
||||
<parameter type="const-gchar*" name="tag" />
|
||||
<parameter type="const-gchar*" name="value" />
|
||||
</parameters>
|
||||
</method>
|
||||
</interface>
|
||||
<interface name="TagSetter" cname="GstTagSetter">
|
||||
<class_struct cname="GstTagSetterIFace">
|
||||
<field name="GIface" cname="g_iface" type="GTypeInterface" />
|
||||
|
|
Loading…
Reference in a new issue