[gtk/wip/otte/no-media-modules: 1/2] media: Don't build media modules as modules




commit bd7ad38b40f3133cb5c56f6a619b5fd272def1bb
Author: Benjamin Otte <otte redhat com>
Date:   Tue Aug 10 23:03:28 2021 +0200

    media: Don't build media modules as modules
    
    Instead, include them in libgtk.

 gtk/gtkmediafile.c              | 20 ++++++++++++++++++++
 gtk/meson.build                 |  4 ++--
 meson.build                     |  1 +
 modules/media/gtkffmediafile.c  | 40 ++++------------------------------------
 modules/media/gtkgstmediafile.c | 29 -----------------------------
 modules/media/gtkgstpaintable.c |  2 +-
 modules/media/meson.build       | 20 ++++++++------------
 modules/meson.build             |  2 --
 8 files changed, 36 insertions(+), 82 deletions(-)
---
diff --git a/gtk/gtkmediafile.c b/gtk/gtkmediafile.c
index 33b56a2cf5..0c856e80fd 100644
--- a/gtk/gtkmediafile.c
+++ b/gtk/gtkmediafile.c
@@ -26,6 +26,13 @@
 #include "gtkmodulesprivate.h"
 #include "gtknomediafileprivate.h"
 
+#ifdef HAVE_FFMPEG
+#include "modules/media/gtkffmediafileprivate.h"
+#endif
+#ifdef HAVE_GSTREAMER
+#include "modules/media/gtkgstmediafileprivate.h"
+#endif
+
 /**
  * GtkMediaFile:
  *
@@ -621,6 +628,19 @@ gtk_media_file_extension_init (void)
 
   g_type_ensure (GTK_TYPE_NO_MEDIA_FILE);
 
+#ifdef HAVE_FFMPEG
+  g_io_extension_point_implement (GTK_MEDIA_FILE_EXTENSION_POINT_NAME,
+                                  GTK_TYPE_FF_MEDIA_FILE,
+                                  "ffmpeg",
+                                  0);
+#endif
+#ifdef HAVE_GSTREAMER
+  g_io_extension_point_implement (GTK_MEDIA_FILE_EXTENSION_POINT_NAME,
+                                  GTK_TYPE_GST_MEDIA_FILE,
+                                  "gstreamer",
+                                  10);
+#endif
+
   scope = g_io_module_scope_new (G_IO_MODULE_SCOPE_BLOCK_DUPLICATES);
 
   paths = _gtk_get_module_path ("media");
diff --git a/gtk/meson.build b/gtk/meson.build
index 18fbe6ac61..178531722a 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -1114,7 +1114,7 @@ libgtk_static = static_library('gtk',
   c_args: gtk_cargs + common_cflags,
   include_directories: [confinc, gdkinc, gskinc, gtkinc],
   dependencies: gtk_deps + [libgtk_css_dep, libgdk_dep, libgsk_dep],
-  link_with: [libgtk_css, libgdk, libgsk ],
+  link_with: [libgtk_css, libgdk, libgsk ] + media_modules
 )
 
 # `link_whole:` is actually only supported on Visual Studio 2015 Update 2
@@ -1126,7 +1126,7 @@ whole_archives = []
 gtk4_objs = []
 
 if cc.get_id() == 'msvc' and cc.version().split('.').get(0) < '19'
-  foreach target : [ libgtk_static, libgtk_css, libgdk, libgdk_win32, libgsk, libgsk_f16c ]
+  foreach target : [ libgtk_static, libgtk_css, libgdk, libgdk_win32, libgsk, libgsk_f16c, media_ffmpeg, 
media_gstreamer ]
     gtk4_objs += target.extract_all_objects(recursive: false)
   endforeach
 else
diff --git a/meson.build b/meson.build
index f2aef2f646..c51bc6af8c 100644
--- a/meson.build
+++ b/meson.build
@@ -732,6 +732,7 @@ project_build_root = meson.current_build_dir()
 subdir('gtk/css')
 subdir('gdk')
 subdir('gsk')
+subdir('modules/media')
 subdir('gtk')
 subdir('modules')
 if get_option('demos')
diff --git a/modules/media/gtkffmediafile.c b/modules/media/gtkffmediafile.c
index ff5225e845..c659e49c7b 100644
--- a/modules/media/gtkffmediafile.c
+++ b/modules/media/gtkffmediafile.c
@@ -171,42 +171,6 @@ G_DEFINE_TYPE_EXTENDED (GtkFfMediaFile, gtk_ff_media_file, GTK_TYPE_MEDIA_FILE,
                         G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
                                                gtk_ff_media_file_paintable_init))
 
-G_MODULE_EXPORT
-void
-g_io_module_load (GIOModule *module)
-{
-  g_type_module_use (G_TYPE_MODULE (module));
-
-#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT (58, 9, 100)
-  av_register_all ();
-#endif
-
-  g_io_extension_point_implement (GTK_MEDIA_FILE_EXTENSION_POINT_NAME,
-                                  GTK_TYPE_FF_MEDIA_FILE,
-                                  "ffmpeg",
-                                  0);
-}
-
-G_MODULE_EXPORT
-G_GNUC_NORETURN
-void
-g_io_module_unload (GIOModule *module)
-{
-  g_assert_not_reached ();
-}
-
-G_MODULE_EXPORT
-char **
-g_io_module_query (void)
-{
-  char *eps[] = {
-    (char *) GTK_MEDIA_FILE_EXTENSION_POINT_NAME,
-    NULL
-  };
-
-  return g_strdupv (eps);
-}
-
 static void
 gtk_ff_media_file_set_ffmpeg_error (GtkFfMediaFile *video,
                                     int           av_errnum)
@@ -762,6 +726,10 @@ gtk_ff_media_file_class_init (GtkFfMediaFileClass *klass)
   stream_class->seek = gtk_ff_media_file_seek;
 
   gobject_class->dispose = gtk_ff_media_file_dispose;
+
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT (58, 9, 100)
+  av_register_all ();
+#endif
 }
 
 static void
diff --git a/modules/media/gtkgstmediafile.c b/modules/media/gtkgstmediafile.c
index 6f09d1dbc8..74ccb789d0 100644
--- a/modules/media/gtkgstmediafile.c
+++ b/modules/media/gtkgstmediafile.c
@@ -97,35 +97,6 @@ G_DEFINE_TYPE_EXTENDED (GtkGstMediaFile, gtk_gst_media_file, GTK_TYPE_MEDIA_FILE
                         G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
                                                gtk_gst_media_file_paintable_init))
 
-void
-g_io_module_load (GIOModule *module)
-{
-  g_type_module_use (G_TYPE_MODULE (module));
-
-  g_io_extension_point_implement (GTK_MEDIA_FILE_EXTENSION_POINT_NAME,
-                                  GTK_TYPE_GST_MEDIA_FILE,
-                                  "gstreamer",
-                                  10);
-}
-
-G_GNUC_NORETURN
-void
-g_io_module_unload (GIOModule *module)
-{
-  g_assert_not_reached ();
-}
-
-char **
-g_io_module_query (void)
-{
-  char *eps[] = {
-    (char *) GTK_MEDIA_FILE_EXTENSION_POINT_NAME,
-    NULL
-  };
-
-  return g_strdupv (eps);
-}
-
 static void
 gtk_gst_media_file_ensure_prepared (GtkGstMediaFile *self)
 {
diff --git a/modules/media/gtkgstpaintable.c b/modules/media/gtkgstpaintable.c
index 06abcd7583..9a753124dc 100644
--- a/modules/media/gtkgstpaintable.c
+++ b/modules/media/gtkgstpaintable.c
@@ -22,7 +22,7 @@
 #include "gtkgstpaintableprivate.h"
 #include "gtkgstsinkprivate.h"
 
-#include <gtk/gtk.h>
+#include <gdk/gdk.h>
 #include <gst/player/gstplayer-video-renderer.h>
 #include <gsk/gl/gskglrenderer.h>
 
diff --git a/modules/media/meson.build b/modules/media/meson.build
index 1bd91821d8..3bcf2f7b48 100644
--- a/modules/media/meson.build
+++ b/modules/media/meson.build
@@ -1,6 +1,5 @@
-media_subdir = 'gtk-4.0/@0@/media'.format(gtk_binary_version)
-media_install_dir = join_paths(get_option('libdir'), media_subdir)
 media_backends = []
+media_modules = []
 
 extra_c_args = [
   '-DGTK_COMPILATION',
@@ -31,13 +30,11 @@ endforeach
 if ffmpeg_found
   media_backends += 'ffmpeg'
   cdata.set('HAVE_FFMPEG', 1)
-  shared_module('media-ffmpeg',
+  media_modules += static_library('media-ffmpeg',
     sources: 'gtkffmediafile.c',
+    include_directories: [ confinc, gtkinc ],
     c_args: extra_c_args,
-    dependencies: [ libgtk_dep, ffmpeg_deps ],
-    name_suffix: module_suffix,
-    install_dir: media_install_dir,
-    install: true,
+    dependencies: [ libgdk_dep, ffmpeg_deps ],
   )
 endif
 
@@ -64,16 +61,15 @@ if gstplayer_dep.found() and gstgl_dep.found()
 
   media_backends += 'gstreamer'
   cdata.set('HAVE_GSTREAMER', 1)
-  shared_module('media-gstreamer',
+
+  media_modules += static_library('media-gstreamer',
     sources: [
       'gtkgstmediafile.c',
       'gtkgstpaintable.c',
       'gtkgstsink.c',
     ],
+    include_directories: [ confinc, gtkinc ],
     c_args: extra_c_args + extra_win_cflags,
-    dependencies: [ libm, libgtk_dep, gstplayer_dep, gstgl_dep ],
-    name_suffix: module_suffix,
-    install_dir: media_install_dir,
-    install: true,
+    dependencies: [ libm, libgdk_dep, gstplayer_dep, gstgl_dep ],
   )
 endif
diff --git a/modules/meson.build b/modules/meson.build
index 4bd67114f8..ba02d2e72d 100644
--- a/modules/meson.build
+++ b/modules/meson.build
@@ -4,5 +4,3 @@ if os_unix
 else
   print_backends = []
 endif
-
-subdir('media')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]