Do not use glue anymore!
authorThibault Saunier <thibault.saunier@osg.samsung.com>
Thu, 31 Aug 2017 02:52:29 +0000 (23:52 -0300)
committerThibault Saunier <thibault.saunier@osg.samsung.com>
Wed, 6 Sep 2017 16:22:57 +0000 (13:22 -0300)
This is not needed anymore as ABI compatible structures are now generated
and used by the code generator.

15 files changed:
configure.ac
generate_code.py
ges/generated/meson.build
ges/meson.build
meson.build
out/gstreamer-sharp.dll.config
samples/BasicTutorial1.cs
sources/custom/DynamicSignal.cs
sources/custom/Message.cs
sources/custom/Object.cs
sources/generated/meson.build
sources/glue/Makefile.am [deleted file]
sources/glue/gobject.c [deleted file]
sources/gstreamer-sharp.metadata
sources/meson.build

index ee8155f..912cdf7 100644 (file)
@@ -183,7 +183,6 @@ AC_SUBST(GST_INCLUDEDIR)
 AC_CONFIG_FILES([
        Makefile
        sources/Makefile
-       sources/glue/Makefile
     samples/Makefile
        sources/AssemblyInfo.cs
        gstreamer-sharp-1.0.pc
index 34bfb91..c7ee779 100644 (file)
@@ -14,9 +14,9 @@ if __name__ == "__main__":
     parser.add_argument("--gapi-fixup")
     parser.add_argument("--metadata")
     parser.add_argument("--gapi-codegen")
-    parser.add_argument("--glue-file")
-    parser.add_argument("--glue-includes")
-    parser.add_argument("--glue-libname")
+    parser.add_argument("--glue-file", default='')
+    parser.add_argument("--glue-includes", default='')
+    parser.add_argument("--glue-libname", default='')
     parser.add_argument("--assembly-name")
     parser.add_argument("--extra-includes", action='append', default=[])
     parser.add_argument("--out")
index 487de28..5665bde 100644 (file)
@@ -123,12 +123,9 @@ source_gen = custom_target(pkg + '_codegen',
         '--extra-includes=' + glib_api_includes,
         '--extra-includes=' + gio_api_includes,
         '--extra-includes=' + gst_api_includes,
-        '--glue-file', gluefile,
-        '--glue-includes', glueincludes,
         '--out', meson.current_build_dir(),
         '--files', ';'.join(generated_sources),
         '--assembly-name', pkg,
-        '--glue-libname', 'libgessharpglue-' + apiversion + '.dll',
     ],
     depend_files: [raw_api_fname],
     depends: codegen_dependencies + [gst_source_gen])
index 166f710..e5a9bd3 100644 (file)
@@ -3,29 +3,14 @@ raw_api_fname = join_paths(meson.current_source_dir(), pkg + '-api.raw')
 metadata_fname = join_paths(meson.current_source_dir(), pkg + '.metadata')
 snk = join_paths(meson.current_source_dir(), '../', meson.project_name() + '.snk')
 
-glueincludes = 'ges/ges.h'
-gluefile = join_paths(meson.current_build_dir(), 'generate.c')
-
-sources = [
-        't.cs'
-]
-
 subdir('generated')
 
-ges_sharp = library(pkg + '-sharp', source_gen, sources,
+ges_sharp = library(pkg + '-sharp', source_gen,
         cs_args: ['-nowarn:169', '-nowarn:108', '-nowarn:114', '-unsafe',
             '-keyfile:' + snk],
         link_with: gst_sharp,
         dependencies: [glib_sharp_dep, gio_sharp_dep])
 
-gluegen = custom_target(pkg + 'gluegen',
-        input: raw_api_fname,
-        output: 'generate.c',
-        command: [generate_api, '--fakeglue'],
-        depends: [source_gen])
-
-library('gessharpglue-1.0.0', gluegen, dependencies: gst_deps + [ges_dep])
-
 ges_sharp_dep = declare_dependency(dependencies: [glib_sharp_dep, gio_sharp_dep, gst_sharp_dep,
     ges_dep], link_with: ges_sharp)
 
index f8ba34f..8e4063a 100644 (file)
@@ -19,7 +19,6 @@ glib_sharp = gtk_sharp.get_variable('glib_sharp')
 
 gio_sharp_dep = gtk_sharp.get_variable('gio_sharp_dep')
 gio_sharp = gtk_sharp.get_variable('gio_sharp')
-gio_glue = gtk_sharp.get_variable('gio_glue')
 
 gapi_fixup = gtk_sharp.get_variable('gapi_fixup')
 gapi_codegen = gtk_sharp.get_variable('gapi_codegen')
@@ -78,9 +77,7 @@ endif
 
 meson.add_install_script(nuget, '--package-name', 'GstSharp',
     '--assembly', gst_sharp.full_path(),
-    '--native', gst_glue.full_path(),
     '--assembly', gio_sharp.full_path(),
-    '--native', gio_glue.full_path(),
     '--assembly', glib_sharp.full_path(),
     '--project-url', 'https://gstreamer.freedesktop.org/modules/gstreamer-sharp.html',
     '--icon-url', 'https://gstreamer.freedesktop.org/images/header-logo-top.png',
index 262ebe0..abb719a 100644 (file)
@@ -1,6 +1,5 @@
 <configuration>
   <!-- Linux -->
-  <dllmap dll="libgstreamersharpglue-1.0.0.dll" target="libgstreamersharpglue-1.0.0.so" os="linux"/>
   <dllmap dll="libgstreamer-1.0-0.dll" target="libgstreamer-1.0.so" os="linux"/>
   <dllmap dll="libgstaudio-1.0-0.dll" target="libgstaudio-1.0.so" os="linux"/>
   <dllmap dll="libgstbase-1.0-0.dll" target="libgstbase-1.0.so" os="linux"/>
@@ -18,7 +17,6 @@
   <dllmap dll="libgobject-2.0-0.dll" target="libgobject-2.0.so" os="linux"/>
   <dllmap dll="libgthread-2.0-0.dll" target="libgthread-2.0.so" os="linux"/>
   <!-- Mac OS X -->
-  <dllmap dll="libgstreamersharpglue-1.0.0.dll" target="libgstreamersharpglue-1.0.0.so" os="osx"/>
   <dllmap dll="libgstreamer-1.0-0.dll" target="libgstreamer-1.0.dylib" os="osx"/>
   <dllmap dll="libgstaudio-1.0-0.dll" target="libgstaudio-1.0.dylib" os="osx"/>
   <dllmap dll="libgstbase-1.0-0.dll" target="libgstbase-1.0.dylib" os="osx"/>
index f7b8c00..1747d5a 100644 (file)
@@ -27,4 +27,4 @@ namespace GstreamerSharp
                        pipeline.SetState (State.Null);
                }
        }
-}
\ No newline at end of file
+}
index e73db1c..1ba5b73 100644 (file)
@@ -202,8 +202,6 @@ namespace Gst
                        Connect (o, name, false, handler);
                }
 
-               static int g_closure_sizeof = gstsharp_g_closure_sizeof ();
-
                public static void Connect (GLib.Object o, string name,
                                              bool after, Delegate handler)
                {
@@ -226,16 +224,14 @@ namespace Gst
                                if (!SignalInfo.IsValidDelegate (handler))
                                        throw new Exception ("Invalid delegate");
 
-                               IntPtr closure = g_closure_new_simple (g_closure_sizeof, IntPtr.Zero);
+                               // Let's allocate 64bytes for the GClosure, it should be more than necessary.
+                               IntPtr closure = g_closure_new_simple (64, IntPtr.Zero);
                                g_closure_set_meta_marshal (closure, (IntPtr)GCHandle.Alloc (k), marshalHandler);
                                uint signalId = g_signal_connect_closure (o.Handle, name, closure, after);
                                SignalHandlers.Add (k, new SignalInfo (signalId, closure, handler));
                        }
                }
 
-               [DllImport ("libgstreamersharpglue-1.0.0.dll", CallingConvention = CallingConvention.Cdecl)]
-               static extern int gstsharp_g_closure_sizeof ();
-
                public static void Disconnect (GLib.Object o, string name, Delegate handler)
                {
                        ObjectSignalKey k = new ObjectSignalKey (o, name);
@@ -333,7 +329,11 @@ namespace Gst
                public static object Emit (GLib.Object o, string name, params object[] parameters)
                {
                        SignalQuery query;
-                       IntPtr type = gstsharp_g_type_from_instance (o.Handle);
+                       IntPtr type;
+                       unsafe {
+                               // GType is the first field of GTypeInstance->g_class
+                               type = (*(IntPtr*) ((GLib.Object.GTypeInstance*) o.Handle)->g_class);
+                       }
                        GType gtype = new GType (type);
                        string signal_name, signal_detail;
                        uint signal_detail_quark = 0;
@@ -424,9 +424,6 @@ namespace Gst
                        return ret;
                }
 
-               [DllImport ("libgstreamersharpglue-1.0.0.dll", CallingConvention = CallingConvention.Cdecl)]
-               static extern IntPtr gstsharp_g_type_from_instance (IntPtr o);
-
                [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
                static extern int g_signal_handler_disconnect (IntPtr o, uint handler_id);
 
index f7193b2..089fa67 100644 (file)
@@ -26,8 +26,6 @@ namespace Gst {
                static extern void gst_message_parse_error (IntPtr msg, out IntPtr err, out IntPtr debug);
 
                public void ParseError (out GLib.GException error, out string debug) {
-                       if (Type != MessageType.Error)
-                               throw new ArgumentException ();
 
                        IntPtr err;
                        IntPtr dbg;
@@ -53,15 +51,11 @@ namespace Gst {
 
                public GLib.Value StreamStatusObject { 
                        get {
-                               if(Type != MessageType.StreamStatus)
-                                       throw new ArgumentException ();
                                IntPtr raw_ret = gst_message_get_stream_status_object(Handle);
                                GLib.Value ret = (GLib.Value) Marshal.PtrToStructure (raw_ret, typeof (GLib.Value));
                                return ret;
                        }
                        set {
-                               if(Type != MessageType.StreamStatus)
-                                       throw new ArgumentException ();
                                IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
                                gst_message_set_stream_status_object(Handle, native_value);
                                value = (GLib.Value) Marshal.PtrToStructure (native_value, typeof (GLib.Value));
index 8c51913..d428424 100644 (file)
@@ -31,6 +31,19 @@ namespace Gst {
 
        public class PropertyNotFoundException : Exception {}
        
+       [StructLayout (LayoutKind.Sequential)]
+    struct GstObject {
+        IntPtr _lock;
+        public string name;
+        public Object parent;
+        public uint flags;
+        IntPtr controlBindings;
+        public int control_rate;
+        public int last_sync;
+
+        private IntPtr[] _gstGstReserved;
+    }
+
        partial class Object 
        {
                private Dictionary <string, bool> PropertyNameCache = new Dictionary<string, bool> ();
index 4f89d8f..7b25533 100644 (file)
@@ -724,8 +724,6 @@ gst_source_gen = custom_target('gst_codegen',
         '--gapi-codegen', gapi_codegen,
         '--extra-includes=' + glib_api_includes,
         '--extra-includes=' + gio_api_includes,
-        '--glue-file', gluefile,
-        '--glue-includes', glueincludes,
         '--out', meson.current_build_dir(),
         '--files', ';'.join(generated_sources),
         '--assembly-name', meson.project_name(),
diff --git a/sources/glue/Makefile.am b/sources/glue/Makefile.am
deleted file mode 100644 (file)
index 72056fd..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-lib_LTLIBRARIES = libgstreamersharpglue-1.0.0.la
-
-libgstreamersharpglue_1_0_0_la_SOURCES = gobject.c
-
-nodist_libgstreamersharpglue_1_0_0_la_SOURCES = generated.c
-
-libgstreamersharpglue_1_0_0_la_LDFLAGS = -module -avoid-version -no-undefined
-
-libgstreamersharpglue_1_0_0_la_LIBADD = $(GST_LIBS)
-
-libgstreamersharpglue_1_0_0_la_CPPFLAGS = -DGST_USE_UNSTABLE_API
-
-INCLUDES = $(GST_CFLAGS) -I$(top_srcdir)
-
-libgstreamersharpglue.dll: $(libgstreamersharpglue_1_0_0_la_OBJECTS) libgstreamersharpglue.rc libgstreamersharpglue.def
-       ./build-dll libgstreamersharpglue $(VERSION)
-
-CLEANFILES = lib*.a lib*.dll generated.c
-
-MAINTAINERCLEANFILES = Makefile.in
-
-EXTRA_DIST =
diff --git a/sources/glue/gobject.c b/sources/glue/gobject.c
deleted file mode 100644 (file)
index e056f42..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-//
-// Authors:
-//   Sebastian Dröge <sebastian.droege@collabora.co.uk>
-//
-// Copyright (C) 2009 Sebastian Dröge
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-// 02110-1301  USA
-
-#include <glib-object.h>
-
-gint
-gstsharp_g_closure_sizeof (void)
-{
-  return sizeof (GClosure);
-}
-
-GType
-gstsharp_g_type_from_instance (GTypeInstance * instance)
-{
-  return G_TYPE_FROM_INSTANCE (instance);
-}
index a9b447e..1fe6f85 100644 (file)
@@ -139,6 +139,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
        <attr path="/api/namespace/boxed[@cname='GstVideoCodecState']/field[@cname='padding']" name="type">gpointer</attr>
        <attr path="/api/namespace/object[@cname='GstVideoDecoder']/field[@cname='padding']" name="type">gpointer</attr>
        <attr path="/api/namespace/object[@cname='GstVideoDecoder']/class_struct/field[@cname='padding']" name="type">gpointer</attr>
+       <attr path="/api/namespace/object[@cname='GstVideoEncoder']/field[@cname='padding']" name="type">gpointer</attr>
        <attr path="/api/namespace/struct[@cname='GstByteReader']" name="opaque">1</attr>
        <remove-node path="/api/namespace//struct[@cname='GstByteReader']//method"/>
        <attr path="//struct[@name='VideoGLTextureUploadMeta']//field[@cname='user_data_copy' or @cname='user_data_free']" name="hidden">true</attr>
index 18b4f98..a86389c 100644 (file)
@@ -41,13 +41,13 @@ gst_sharp = library('gstreamer-sharp', gst_source_gen, sources,
             '-keyfile:' + snk],
         dependencies: [glib_sharp_dep, gio_sharp_dep])
 
-gluegen = custom_target('gluegen',
-        input: raw_api_fname,
-        output: 'generate.c',
-        command: [generate_api, '--fakeglue'],
-        depends: [gst_source_gen])
+#gluegen = custom_target('gluegen',
+        #input: raw_api_fname,
+        #output: 'generate.c',
+        #command: [generate_api, '--fakeglue'],
+        #depends: [gst_source_gen])
 
-gst_glue = library('gstreamersharpglue-1.0.0', gluegen, 'glue/gobject.c', dependencies: gst_deps)
+#gst_glue = library('gstreamersharpglue-1.0.0', gluegen, 'glue/gobject.c', dependencies: gst_deps)
 
 gst_sharp_dep = declare_dependency(dependencies: [glib_sharp_dep, gio_sharp_dep],
         link_with: gst_sharp)