summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorStephan Sundermann <stephansundermann@gmail.com>2013-10-21 12:49:17 +0200
committerStephan Sundermann <stephansundermann@gmail.com>2013-12-21 16:52:27 +0100
commit2099af9b0939b17722480d06568a783dd50e57cb (patch)
treea6e1b3934d313ba67d4e3d9ce7f5a8dc5cb9cc74 /sources
parent6bb1013e27340b9fb2189eebc1d0490d9ee44466 (diff)
TagList: Port custom code to 1.0
Diffstat (limited to 'sources')
-rw-r--r--sources/custom/TagList.cs77
1 files changed, 4 insertions, 73 deletions
diff --git a/sources/custom/TagList.cs b/sources/custom/TagList.cs
index e3cc2ec..6003b57 100644
--- a/sources/custom/TagList.cs
+++ b/sources/custom/TagList.cs
@@ -20,43 +20,16 @@ namespace Gst
public partial class TagList
{
- [DllImport("libgstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
- static extern int gst_structure_n_fields (IntPtr raw);
-
- public int Size {
- get {
- int raw_ret = gst_structure_n_fields (Handle);
- int ret = raw_ret;
- return ret;
- }
- }
-
- [DllImport("libgstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
- static extern bool gst_tag_list_copy_value (ref GLib.Value dest, IntPtr list, IntPtr tag);
-
public object this [string tag, uint index] {
- get {
- 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;
-
- GLib.Value v = (GLib.Value)Marshal.PtrToStructure (raw_ret, typeof(GLib.Value));
-
- return (object)v.Val;
- }
+ get { return GetValueIndex (tag, index).Val; }
}
public object this [string tag] {
get {
- GLib.Value v = GLib.Value.Empty;
+ GLib.Value v;
bool success;
- IntPtr raw_string = GLib.Marshaller.StringToPtrGStrdup (tag);
- success = gst_tag_list_copy_value (ref v, Handle, raw_string);
- GLib.Marshaller.Free (raw_string);
+ success = CopyValue (out v, this, tag);
if (!success)
return null;
@@ -74,51 +47,9 @@ namespace Gst
throw new ArgumentException (String.Format ("Invalid tag name '{0}'", tag));
GLib.Value v = new GLib.Value (value);
- IntPtr raw_v = GLib.Marshaller.StructureToPtrAlloc (v);
- IntPtr raw_string = GLib.Marshaller.StringToPtrGStrdup (tag);
- gst_tag_list_add_value (Handle, (int)mode, raw_string, raw_v);
- Marshal.FreeHGlobal (raw_v);
+ AddValue (mode, tag, v);
v.Dispose ();
- GLib.Marshaller.Free (raw_string);
- }
-
- [DllImport("libgstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
- static extern IntPtr gst_structure_nth_field_name (IntPtr raw, uint index);
-
- private string NthFieldName (uint index)
- {
- IntPtr raw_ret = gst_structure_nth_field_name (Handle, index);
- string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
- return ret;
- }
-
- public string[] Tags {
- get {
- string[] tags = new string[Size];
- for (uint i = 0; i < Size; i++)
- tags [i] = NthFieldName (i);
-
- return tags;
- }
- }
-
- [DllImport("libgstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
- static extern IntPtr gst_structure_get_value (IntPtr raw, IntPtr fieldname);
-
- public GLib.List GetTag (string 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;
-
- if (o.GetType () == typeof(GLib.List))
- return (GLib.List)o;
-
- return new GLib.List (new object[] { o }, o.GetType(), true, true);
}
}
} \ No newline at end of file