From a23154fc2fc47c6664b0981780ac4324098fb4f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 21 Apr 2009 14:31:29 +0200 Subject: [PATCH] Complete/fix bindings for Gst.Tag and Gst.TagList --- doc/en/Gst/Structure.xml | 2 +- doc/en/Gst/Tag.xml | 20 +- doc/en/Gst/TagForeachFunc.xml | 23 -- doc/en/Gst/TagList.xml | 220 +------------ doc/en/Gst/TagMergeFunc.xml | 6 +- doc/en/Gst/Tags.xml | 503 ----------------------------- doc/en/index.xml | 2 - gstreamer-sharp/Gstreamer.metadata | 51 ++- gstreamer-sharp/Makefile.am | 3 +- gstreamer-sharp/Tag.custom | 11 + gstreamer-sharp/TagList.custom | 112 +++++++ gstreamer-sharp/glue/Makefile.am | 1 + gstreamer-sharp/glue/taglist.c | 6 + source/Makefile.am | 5 + 14 files changed, 207 insertions(+), 758 deletions(-) delete mode 100644 doc/en/Gst/TagForeachFunc.xml delete mode 100644 doc/en/Gst/Tags.xml create mode 100644 gstreamer-sharp/TagList.custom create mode 100644 gstreamer-sharp/glue/taglist.c diff --git a/doc/en/Gst/Structure.xml b/doc/en/Gst/Structure.xml index 0ea00942e1..a4ab875d01 100644 --- a/doc/en/Gst/Structure.xml +++ b/doc/en/Gst/Structure.xml @@ -62,7 +62,7 @@ Gst.Structure To be added.To be added.To be added. - 0.9.5.99Property0.9.5.99System.Int32To be added.To be added.To be added.Property0.9.5.99System.Collections.IEnumerableTo be added.To be added.To be added. + 0.9.5.99Property0.9.5.99System.Int32To be added.To be added.To be added.Property0.9.5.99System.String[]To be added.To be added.To be added. Method System.Boolean diff --git a/doc/en/Gst/Tag.xml b/doc/en/Gst/Tag.xml index 27a36c0c57..909f9c3248 100644 --- a/doc/en/Gst/Tag.xml +++ b/doc/en/Gst/Tag.xml @@ -28,13 +28,13 @@ Constructor To be added.To be added. - 0.9.5.99 + 0.9.5.99Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added. Method System.Boolean To be added.To be added.To be added.To be added. - 0.9.5.99 + 0.9.5.99Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added. Method System.String @@ -52,23 +52,11 @@ System.String To be added.To be added.To be added.To be added. - 0.9.5.99 + 0.9.5.99Method0.9.5.99System.TypeTo be added.To be added.To be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added. Method System.Boolean To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Void - - To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Void - - To be added.To be added.To be added.To be added. - 0.9.5.99Method0.9.5.99System.VoidTo be added.To be added.To be added.To be added.To be added.To be added.To be added.To be added. + 0.9.5.99Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Method0.9.5.99System.VoidTo be added.To be added.To be added.To be added.Method0.9.5.99System.VoidTo be added.To be added.To be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Method0.9.5.99System.VoidTo be added.To be added.To be added.To be added.To be added.To be added.To be added.To be added.Method0.9.5.99System.VoidTo be added.To be added.To be added.To be added.To be added.To be added.To be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added.Field0.9.5.99System.StringTo be added.To be added. diff --git a/doc/en/Gst/TagForeachFunc.xml b/doc/en/Gst/TagForeachFunc.xml deleted file mode 100644 index 282f261666..0000000000 --- a/doc/en/Gst/TagForeachFunc.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - gstreamer-sharp - 0.9.5.99 - - - System.Delegate - - - - - - - System.Void - - - To be added. - To be added. - To be added. - To be added. - - diff --git a/doc/en/Gst/TagList.xml b/doc/en/Gst/TagList.xml index bf0d9bb46c..14eda60125 100644 --- a/doc/en/Gst/TagList.xml +++ b/doc/en/Gst/TagList.xml @@ -46,7 +46,14 @@ - + + + + + + + + Constructor @@ -56,204 +63,18 @@ Constructor To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Void - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Void - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 + 0.9.5.99Method0.9.5.99System.VoidSystem.ParamArrayTo be added.To be added.To be added.To be added.Method0.9.5.99System.VoidTo be added.To be added.To be added.To be added.To be added. Method Gst.TagList To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Void - - To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99Method0.9.5.99System.BooleanTo be added.To be added.To be added.To be added.To be added.Method0.9.5.99System.BooleanTo be added.To be added.To be added.To be added.To be added.To be added. - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 + 0.9.5.99Method0.9.5.99Gst.ListTo be added.To be added.To be added.To be added. Method System.UInt32 To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - System.Boolean - - To be added.To be added.To be added.To be added.To be added.To be added. - 0.9.5.99 - - Method - GLib.Value - - To be added.To be added.To be added.To be added.To be added. 0.9.5.99 Property @@ -265,7 +86,7 @@ System.Void To be added.To be added.To be added.To be added. - 0.9.5.99Property0.9.5.99System.BooleanTo be added.To be added.To be added. + 0.9.5.99Property0.9.5.99System.BooleanTo be added.To be added.To be added.Property0.9.5.99System.ObjectTo be added.To be added.To be added.To be added.Property0.9.5.99System.ObjectTo be added.To be added.To be added.To be added.To be added. Method Gst.TagList @@ -277,17 +98,10 @@ System.Void To be added.To be added.To be added. - 0.9.5.99 - - Property - GLib.GType - To be added.To be added.To be added. - 0.9.5.99 - - - - - - - + 0.9.5.99Property0.9.5.99System.Int32To be added.To be added.To be added.Property0.9.5.99System.String[]To be added.To be added.To be added. + + + System.Reflection.DefaultMember("Item") + + diff --git a/doc/en/Gst/TagMergeFunc.xml b/doc/en/Gst/TagMergeFunc.xml index add0ddf005..ad29cf6d13 100644 --- a/doc/en/Gst/TagMergeFunc.xml +++ b/doc/en/Gst/TagMergeFunc.xml @@ -1,5 +1,5 @@ - + gstreamer-sharp 0.9.5.99 @@ -8,8 +8,8 @@ System.Delegate - - + + System.Void diff --git a/doc/en/Gst/Tags.xml b/doc/en/Gst/Tags.xml deleted file mode 100644 index 6311f4a7b2..0000000000 --- a/doc/en/Gst/Tags.xml +++ /dev/null @@ -1,503 +0,0 @@ - - - - gstreamer-sharp - 0.9.5.99 - - - System.Object - - - - To be added. - To be added. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - Field - - 0.9.5.99 - - System.String - To be added.To be added. - - - diff --git a/doc/en/index.xml b/doc/en/index.xml index f4f1a40769..fe5aaab8a8 100644 --- a/doc/en/index.xml +++ b/doc/en/index.xml @@ -179,11 +179,9 @@ - - diff --git a/gstreamer-sharp/Gstreamer.metadata b/gstreamer-sharp/Gstreamer.metadata index f92421806c..3b649087d4 100644 --- a/gstreamer-sharp/Gstreamer.metadata +++ b/gstreamer-sharp/Gstreamer.metadata @@ -451,15 +451,54 @@ 1 1 + ref + ref + + 1 TagFlags - ref - out - out - out - out - out + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + true + + ref 1 diff --git a/gstreamer-sharp/Makefile.am b/gstreamer-sharp/Makefile.am index 21b178543d..ca6259ce8b 100644 --- a/gstreamer-sharp/Makefile.am +++ b/gstreamer-sharp/Makefile.am @@ -66,7 +66,8 @@ customs = \ MiniObject.custom \ Registry.custom \ Structure.custom \ - Tag.custom + Tag.custom \ + TagList.custom build_customs = $(addprefix $(srcdir)/, $(customs)) diff --git a/gstreamer-sharp/Tag.custom b/gstreamer-sharp/Tag.custom index 62c19c7856..08ae51d172 100644 --- a/gstreamer-sharp/Tag.custom +++ b/gstreamer-sharp/Tag.custom @@ -1,3 +1,14 @@ +public static System.Type GetType (string tag) { + GLib.GType gt = GetGType (tag); + return (Type) gt; +} + +public static void Register (string name, Gst.TagFlags flag, System.Type type, string nick, string blurb, Gst.TagMergeFunc func) { + GLib.GType gt = (GLib.GType) (type); + + Register (name, flag, gt, nick, blurb, func); +} + public const string Title = "title"; public const string TitleSortname = "title-sortname"; public const string Artist = "artist"; diff --git a/gstreamer-sharp/TagList.custom b/gstreamer-sharp/TagList.custom new file mode 100644 index 0000000000..7f1f0d2f0a --- /dev/null +++ b/gstreamer-sharp/TagList.custom @@ -0,0 +1,112 @@ +[DllImport ("gstreamer-0.10.dll") ] +static extern IntPtr gst_structure_to_string (IntPtr handle); + +public override string ToString () { + IntPtr raw_ret = gst_structure_to_string (Handle); + string ret = GLib.Marshaller.PtrToStringGFree (raw_ret); + return ret; +} + +[DllImport ("gstreamer-0.10.dll") ] +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 ("gstreamer-0.10.dll") ] +static extern bool gst_tag_list_copy_value (ref GLib.Value dest, IntPtr list, string tag); +[DllImport ("gstreamer-0.10.dll") ] +static extern IntPtr gst_tag_list_get_value_index (IntPtr raw, string tag, uint index); + +public object this[string tag, uint index] { + get { + IntPtr raw_ret = gst_tag_list_get_value_index (Handle, tag, index); + if (raw_ret == IntPtr.Zero) + return null; + + GLib.Value v = (GLib.Value) Marshal.PtrToStructure (raw_ret, typeof (GLib.Value)); + + return (object) v.Val; + } +} + +public object this[string tag] { + get { + GLib.Value v = GLib.Value.Empty; + bool success; + + success = gst_tag_list_copy_value (ref v, Handle, tag); + + if (!success) + return null; + + object ret = (object) v.Val; + v.Dispose (); + + return ret; + } +} + +[DllImport ("gstreamersharpglue-0.10") ] +static extern void gstsharp_gst_tag_list_add_value (IntPtr list, Gst.TagMergeMode mode, string tag, ref GLib.Value v); + +public void Add (Gst.TagMergeMode mode, string tag, object value) { + if (!Tag.Exists (tag)) + throw new ArgumentException (String.Format ("Invalid tag name '{0}'", tag)); + + GLib.Value v = new GLib.Value (value); + + gstsharp_gst_tag_list_add_value (Handle, mode, tag, ref v); +} + +public void Add (Gst.TagMergeMode mode, params object[] parameters) { + if (parameters.Length % 2 != 0) + throw new ArgumentException (); + + for (int i = 0; i < parameters.Length; i += 2) { + if (parameters[i].GetType () != typeof (string)) + throw new ArgumentException (); + + Add (mode, parameters[i] as string, parameters[i+1]); + } +} + +[DllImport ("gstreamer-0.10.dll") ] +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 ("gstreamer-0.10.dll") ] +static extern IntPtr gst_structure_get_value (IntPtr raw, string fieldname); + +public Gst.List GetTag (string tag) { + IntPtr raw_ret = gst_structure_get_value (Handle, tag); + GLib.Value ret = (GLib.Value) Marshal.PtrToStructure (raw_ret, typeof (GLib.Value)); + + object o = ret.Val; + + if (o.GetType () == typeof (Gst.List)) + return (Gst.List) o; + + return new Gst.List (new object[] { o }); +} + diff --git a/gstreamer-sharp/glue/Makefile.am b/gstreamer-sharp/glue/Makefile.am index 505c5487a9..776488bece 100644 --- a/gstreamer-sharp/glue/Makefile.am +++ b/gstreamer-sharp/glue/Makefile.am @@ -7,6 +7,7 @@ libgstreamersharpglue_0_10_la_SOURCES = \ message.c \ bin.c \ structure.c \ + taglist.c \ gobject.c nodist_libgstreamersharpglue_0_10_la_SOURCES = generated.c diff --git a/gstreamer-sharp/glue/taglist.c b/gstreamer-sharp/glue/taglist.c new file mode 100644 index 0000000000..db6aa603ce --- /dev/null +++ b/gstreamer-sharp/glue/taglist.c @@ -0,0 +1,6 @@ +#include + +void +gstsharp_gst_tag_list_add_value (GstTagList *list, GstTagMergeMode mode, const gchar * tag, const GValue *v) { + gst_tag_list_add_values (list, mode, tag, v, NULL); +} diff --git a/source/Makefile.am b/source/Makefile.am index 9944dbb672..4855603457 100644 --- a/source/Makefile.am +++ b/source/Makefile.am @@ -2,6 +2,11 @@ MAINTAINERCLEANFILES = Makefile.in api: $(GAPI_PARSER) gstreamer-sharp-source.xml + grep -v "public const string " \ + $(top_srcdir)/gstreamer-sharp/Tag.custom \ + > $(top_srcdir)/gstreamer-sharp/Tag.custom.tmp + mv $(top_srcdir)/gstreamer-sharp/Tag.custom.tmp \ + $(top_srcdir)/gstreamer-sharp/Tag.custom $(MONO) $(top_builddir)/parser/gst-generate-tags.exe \ --header=../../gstreamer/gst/gsttaglist.h \ --namespace=Gst \