mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-21 05:26:23 +00:00
Make sure that the strings passed to native functions are UTF8
This commit is contained in:
parent
e1ea52daaf
commit
f7de461101
4 changed files with 41 additions and 25 deletions
|
@ -224,7 +224,9 @@ namespace Gst {
|
|||
GTypeSignalKey key = new GTypeSignalKey (gtype, signal_name);
|
||||
|
||||
if (SignalEmitInfo[key] == null) {
|
||||
uint signal_id = g_signal_lookup (signal_name, type);
|
||||
IntPtr native_string = GLib.Marshaller.StringToPtrGStrdup (signal_name);
|
||||
uint signal_id = g_signal_lookup (native_string, type);
|
||||
GLib.Marshaller.Free (native_string);
|
||||
|
||||
if (signal_id == 0)
|
||||
throw new NotSupportedException (String.Format ("{0} has no signal of name {1}", o, name));
|
||||
|
@ -275,8 +277,11 @@ namespace Gst {
|
|||
if (query.return_type != GType.Invalid && query.return_type != GType.None)
|
||||
return_value.Init (query.return_type);
|
||||
|
||||
if (signal_detail != String.Empty)
|
||||
signal_detail_quark = g_quark_from_string (signal_detail);
|
||||
if (signal_detail != String.Empty) {
|
||||
IntPtr native_string = GLib.Marshaller.StringToPtrGStrdup (signal_detail);
|
||||
signal_detail_quark = g_quark_from_string (native_string);
|
||||
GLib.Marshaller.Free (native_string);
|
||||
}
|
||||
|
||||
g_signal_emitv (signal_parameters, query.signal_id, signal_detail_quark, ref return_value);
|
||||
|
||||
|
@ -290,10 +295,10 @@ namespace Gst {
|
|||
static extern int g_signal_handler_disconnect (IntPtr o, uint handler_id);
|
||||
|
||||
[DllImport ("gobject-2.0.dll") ]
|
||||
static extern uint g_signal_lookup (string name, IntPtr itype);
|
||||
static extern uint g_signal_lookup (IntPtr name, IntPtr itype);
|
||||
|
||||
[DllImport ("glib-2.0.dll") ]
|
||||
static extern uint g_quark_from_string (string str);
|
||||
static extern uint g_quark_from_string (IntPtr str);
|
||||
|
||||
[DllImport ("gobject-2.0.dll") ]
|
||||
static extern void g_signal_emitv (GLib.Value[] parameters, uint signal_id, uint detail, ref GLib.Value return_value);
|
||||
|
|
|
@ -201,13 +201,15 @@ public string[] Fields {
|
|||
}
|
||||
|
||||
public static Structure NewFromString (string structure) {
|
||||
IntPtr raw_ret = gst_structure_from_string (structure, IntPtr.Zero);
|
||||
IntPtr raw_string = GLib.Marshaller.StringToPtrGStrdup (structure);
|
||||
IntPtr raw_ret = gst_structure_from_string (raw_string, IntPtr.Zero);
|
||||
GLib.Marshaller.Free (raw_string);
|
||||
Gst.Structure ret = raw_ret == IntPtr.Zero ? null : (Gst.Structure) GLib.Opaque.GetOpaque (raw_ret, typeof (Gst.Structure), true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport ("gstreamer-0.10.dll") ]
|
||||
private static extern IntPtr gst_structure_from_string (string structure, IntPtr end);
|
||||
private static extern IntPtr gst_structure_from_string (IntPtr structure, IntPtr end);
|
||||
|
||||
public bool FixateFieldNearestFraction (string field_name, Fraction target) {
|
||||
return FixateFieldNearestFraction (field_name, target.Numerator, target.Denominator);
|
||||
|
|
|
@ -9,19 +9,19 @@ public static void Register (string name, Gst.TagFlags flag, System.Type type, s
|
|||
Register (name, flag, gt, nick, blurb, func);
|
||||
}
|
||||
|
||||
[DllImport("gstreamer-0.10.dll")]
|
||||
static extern void gst_tag_merge_strings_with_comma(out GLib.Value dest, ref GLib.Value src);
|
||||
[DllImport ("gstreamer-0.10.dll") ]
|
||||
static extern void gst_tag_merge_strings_with_comma (out GLib.Value dest, ref GLib.Value src);
|
||||
|
||||
public static void MergeStringsWithComma(out GLib.Value dest, ref GLib.Value src) {
|
||||
gst_tag_merge_strings_with_comma(out dest, ref src);
|
||||
}
|
||||
public static void MergeStringsWithComma (out GLib.Value dest, ref GLib.Value src) {
|
||||
gst_tag_merge_strings_with_comma (out dest, ref src);
|
||||
}
|
||||
|
||||
[DllImport("gstreamer-0.10.dll")]
|
||||
static extern void gst_tag_merge_use_first(out GLib.Value dest, ref GLib.Value src);
|
||||
[DllImport ("gstreamer-0.10.dll") ]
|
||||
static extern void gst_tag_merge_use_first (out GLib.Value dest, ref GLib.Value src);
|
||||
|
||||
public static void MergeUseFirst(out GLib.Value dest, ref GLib.Value src) {
|
||||
gst_tag_merge_use_first(out dest, ref src);
|
||||
}
|
||||
public static void MergeUseFirst (out GLib.Value dest, ref GLib.Value src) {
|
||||
gst_tag_merge_use_first (out dest, ref src);
|
||||
}
|
||||
|
||||
public const string Title = "title";
|
||||
public const string TitleSortname = "title-sortname";
|
||||
|
|
|
@ -19,13 +19,16 @@ public int Size {
|
|||
}
|
||||
|
||||
[DllImport ("gstreamer-0.10.dll") ]
|
||||
static extern bool gst_tag_list_copy_value (ref GLib.Value dest, IntPtr list, string tag);
|
||||
static extern bool gst_tag_list_copy_value (ref GLib.Value dest, IntPtr list, IntPtr tag);
|
||||
[DllImport ("gstreamer-0.10.dll") ]
|
||||
static extern IntPtr gst_tag_list_get_value_index (IntPtr raw, string tag, uint index);
|
||||
static extern IntPtr gst_tag_list_get_value_index (IntPtr raw, IntPtr tag, uint index);
|
||||
|
||||
public object this[string tag, uint index] {
|
||||
get {
|
||||
IntPtr raw_ret = gst_tag_list_get_value_index (Handle, tag, index);
|
||||
IntPtr raw_string = GLib.Marshaller.StringToPtrGStrdup (tag);
|
||||
IntPtr raw_ret = gst_tag_list_get_value_index (Handle, raw_string, index);
|
||||
GLib.Marshaller.Free (raw_string);
|
||||
|
||||
if (raw_ret == IntPtr.Zero)
|
||||
return null;
|
||||
|
||||
|
@ -40,7 +43,9 @@ public object this[string tag] {
|
|||
GLib.Value v = GLib.Value.Empty;
|
||||
bool success;
|
||||
|
||||
success = gst_tag_list_copy_value (ref v, Handle, tag);
|
||||
IntPtr raw_string = GLib.Marshaller.StringToPtrGStrdup (tag);
|
||||
success = gst_tag_list_copy_value (ref v, Handle, raw_string);
|
||||
GLib.Marshaller.Free (raw_string);
|
||||
|
||||
if (!success)
|
||||
return null;
|
||||
|
@ -53,7 +58,7 @@ public object this[string tag] {
|
|||
}
|
||||
|
||||
[DllImport ("gstreamersharpglue-0.10") ]
|
||||
static extern void gstsharp_gst_tag_list_add_value (IntPtr list, Gst.TagMergeMode mode, string tag, ref GLib.Value v);
|
||||
static extern void gstsharp_gst_tag_list_add_value (IntPtr list, Gst.TagMergeMode mode, IntPtr tag, ref GLib.Value v);
|
||||
|
||||
public void Add (Gst.TagMergeMode mode, string tag, object value) {
|
||||
if (!Tag.Exists (tag))
|
||||
|
@ -61,7 +66,9 @@ public void Add (Gst.TagMergeMode mode, string tag, object value) {
|
|||
|
||||
GLib.Value v = new GLib.Value (value);
|
||||
|
||||
gstsharp_gst_tag_list_add_value (Handle, mode, tag, ref v);
|
||||
IntPtr raw_string = GLib.Marshaller.StringToPtrGStrdup (tag);
|
||||
gstsharp_gst_tag_list_add_value (Handle, mode, raw_string, ref v);
|
||||
GLib.Marshaller.Free (raw_string);
|
||||
}
|
||||
|
||||
public void Add (Gst.TagMergeMode mode, params object[] parameters) {
|
||||
|
@ -96,10 +103,12 @@ public string[] Tags {
|
|||
}
|
||||
|
||||
[DllImport ("gstreamer-0.10.dll") ]
|
||||
static extern IntPtr gst_structure_get_value (IntPtr raw, string fieldname);
|
||||
static extern IntPtr gst_structure_get_value (IntPtr raw, IntPtr fieldname);
|
||||
|
||||
public Gst.List GetTag (string tag) {
|
||||
IntPtr raw_ret = gst_structure_get_value (Handle, tag);
|
||||
IntPtr raw_string = GLib.Marshaller.StringToPtrGStrdup (tag);
|
||||
IntPtr raw_ret = gst_structure_get_value (Handle, raw_string);
|
||||
GLib.Marshaller.Free (raw_string);
|
||||
GLib.Value ret = (GLib.Value) Marshal.PtrToStructure (raw_ret, typeof (GLib.Value));
|
||||
|
||||
object o = ret.Val;
|
||||
|
|
Loading…
Reference in a new issue