Value: Register with type system
authorStephan Sundermann <ssundermann@gnome.org>
Tue, 5 Aug 2014 21:05:20 +0000 (23:05 +0200)
committerStephan Sundermann <ssundermann@gnome.org>
Tue, 5 Aug 2014 21:05:20 +0000 (23:05 +0200)
samples/Makefile.am
sources/custom/Application.cs
sources/custom/Value.cs

index 06df1e8..090543c 100644 (file)
@@ -1,4 +1,4 @@
-TARGETS = playback.exe video-overlay.exe basic-tutorial-1.exe basic-tutorial-2.exe basic-tutorial-3.exe basic-tutorial-4.exe basic-tutorial-5.exe
+TARGETS = playback.exe video-overlay.exe basic-tutorial-1.exe basic-tutorial-2.exe basic-tutorial-3.exe basic-tutorial-4.exe basic-tutorial-5.exe basic-tutorial-6.exe
 
 DEBUGS = $(addsuffix .mdb, $(TARGETS))
 assemblies =                                   \
@@ -30,6 +30,9 @@ basic-tutorial-4.exe: $(srcdir)/BasicTutorial4.cs $(assemblies)
 basic-tutorial-5.exe: $(srcdir)/BasicTutorial5.cs $(assemblies)
        $(CSC) $(CSFLAGS) -out:basic-tutorial-5.exe $(references) $(GTK_SHARP_LIBS) $(srcdir)/BasicTutorial5.cs
 
+basic-tutorial-6.exe: $(srcdir)/BasicTutorial6.cs $(assemblies)
+       $(CSC) $(CSFLAGS) -out:basic-tutorial-6.exe $(references) $(GLIB_SHARP_LIBS) $(srcdir)/BasicTutorial6.cs
+
 EXTRA_DIST =                           \
        Playback.cs \
     VideoOverlay.cs \
@@ -37,4 +40,5 @@ EXTRA_DIST =                          \
     BasicTutorial2.cs \
     BasicTutorial3.cs \
     BasicTutorial4.cs \
-    BasicTutorial4.cs
+    BasicTutorial5.cs \
+    BasicTutorial6.cs
index 60d29db..ea71cc4 100644 (file)
@@ -21,6 +21,17 @@ namespace Gst {
 
        partial class Application 
        {
+               static Application () {
+                       GLib.GType.Register (List.GType, typeof(List));
+                       GLib.GType.Register (Fraction.GType, typeof(Fraction));
+                       GLib.GType.Register (DoubleRange.GType, typeof(DoubleRange));
+                       GLib.GType.Register (IntRange.GType, typeof(IntRange));
+                       GLib.GType.Register (FractionRange.GType, typeof(FractionRange));
+                       GLib.GType.Register (DateTime.GType, typeof(DateTime));
+                       GLib.GType.Register (Gst.Array.GType, typeof(Gst.Array));
+
+               }
+
                public static void Init() {
                        gst_init (0, null);
                }
index 1345244..4a13adf 100644 (file)
@@ -362,95 +362,6 @@ namespace Gst
                private static extern IntPtr gst_value_get_fraction_range_max (ref GLib.Value v);
        }
 
-       public struct Fourcc
-       {
-               public uint Val;
-
-               public static GLib.GType GType {
-                       get {
-                               return new GType (gst_fourcc_get_type ());
-                       }
-               }
-
-               public Fourcc (uint fourcc)
-               {
-                       this.Val = fourcc;
-               }
-
-               public Fourcc (char[] fourcc)
-               {
-                       if (fourcc.Length != 4)
-                               throw new ArgumentException ();
-
-                       this.Val = (uint)((((byte)fourcc [0]) << 24) |
-                               (((byte)fourcc [1]) << 16) |
-                               (((byte)fourcc [2]) << 8) |
-                               (((byte)fourcc [3]) << 0));
-               }
-
-               public Fourcc (string fourcc)
-               {
-                       if (fourcc.Length != 4)
-                               throw new ArgumentException ();
-
-                       this.Val = (uint)((((byte)fourcc [0]) << 24) |
-                               (((byte)fourcc [1]) << 16) |
-                               (((byte)fourcc [2]) << 8) |
-                               (((byte)fourcc [3]) << 0));
-               }
-
-               public Fourcc (GLib.Value val) : this (gst_value_get_fourcc (ref val))
-               {
-               }
-
-               public void SetGValue (ref GLib.Value val)
-               {
-                       gst_value_set_fourcc (ref val, Val);
-               }
-
-               public override string ToString ()
-               {
-                       return String.Format ("{0}{1}{2}{3}", (char)((Val >> 24) & 0xff),
-                                             (char)((Val >> 16) & 0xff),
-                                             (char)((Val >> 8) & 0xff),
-                                             (char)((Val >> 0) & 0xff));
-               }
-
-               public static explicit operator GLib.Value (Fourcc fourcc)
-               {
-                       GLib.Value val = new GLib.Value (Fourcc.GType);
-
-                       gst_value_set_fourcc (ref val, fourcc.Val);
-                       return val;
-               }
-
-               public static explicit operator char[] (Fourcc fourcc)
-               {
-                       return new char[] { (char) ( (fourcc.Val >> 24) & 0xff),
-                               (char) ( (fourcc.Val >> 16) & 0xff),
-                               (char) ( (fourcc.Val >> 8) & 0xff),
-                               (char) ( (fourcc.Val >> 0) & 0xff)
-                       };
-               }
-
-               public static explicit operator string (Fourcc fourcc)
-               {
-                       return fourcc.ToString ();
-               }
-
-               [DllImport("libgstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
-
-               private static extern IntPtr gst_fourcc_get_type ();
-
-               [DllImport("libgstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
-
-               private static extern void gst_value_set_fourcc (ref GLib.Value v, uint fourcc);
-
-               [DllImport("libgstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
-
-               private static extern uint gst_value_get_fourcc (ref GLib.Value v);
-       }
-
        public class Date : IWrapper
        {
                public DateTime Val;