summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/gtkmain.c2
-rw-r--r--gtk/gtkmediafile.c109
-rw-r--r--gtk/gtkmediafile.h2
-rw-r--r--gtk/gtkmediafileprivate.h29
-rw-r--r--gtk/gtknomediafile.c63
-rw-r--r--gtk/gtknomediafileprivate.h33
-rw-r--r--gtk/meson.build1
-rw-r--r--meson.build2
-rw-r--r--meson_options.txt4
-rw-r--r--modules/media/meson.build23
-rw-r--r--modules/meson.build2
11 files changed, 267 insertions, 3 deletions
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 336c9363ae..bd0720d5c8 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -119,6 +119,7 @@
#include "gtkdebugupdatesprivate.h"
#include "gtkdndprivate.h"
#include "gtkmain.h"
+#include "gtkmediafileprivate.h"
#include "gtkmenu.h"
#include "gtkmodulesprivate.h"
#include "gtkprivate.h"
@@ -632,6 +633,7 @@ default_display_notify_cb (GdkDisplayManager *dm)
debug_flags[0].display = gdk_display_get_default ();
gtk_print_backends_init ();
gtk_im_modules_init ();
+ gtk_media_file_extension_init ();
_gtk_accessibility_init ();
}
diff --git a/gtk/gtkmediafile.c b/gtk/gtkmediafile.c
index edc121fe3e..e3b0e62756 100644
--- a/gtk/gtkmediafile.c
+++ b/gtk/gtkmediafile.c
@@ -19,9 +19,12 @@
#include "config.h"
-#include "gtkmediafile.h"
+#include "gtkmediafileprivate.h"
+#include "gtkdebug.h"
#include "gtkintl.h"
+#include "gtkmodulesprivate.h"
+#include "gtknomediafileprivate.h"
/**
* SECTION:gtkmediafile
@@ -179,8 +182,64 @@ gtk_media_file_init (GtkMediaFile *self)
static GType
gtk_media_file_get_impl_type (void)
{
- g_assert_not_reached ();
- return G_TYPE_INVALID;
+ static GType impl_type = G_TYPE_NONE;
+ const char *extension_name;
+ GIOExtension *e;
+ GIOExtensionPoint *ep;
+
+ if (G_LIKELY (impl_type != G_TYPE_NONE))
+ return impl_type;
+
+ GTK_NOTE (MODULES, g_print ("Looking up MediaFile extension\n"));
+
+ ep = g_io_extension_point_lookup (GTK_MEDIA_FILE_EXTENSION_POINT_NAME);
+ e = NULL;
+
+ extension_name = g_getenv ("GTK_MEDIA");
+ if (extension_name)
+ {
+ if (g_str_equal (extension_name, "help"))
+ {
+ GList *l;
+
+ g_print ("Supported arguments for GTK_MEDIA environment variable:\n");
+
+ for (l = g_io_extension_point_get_extensions (ep); l; l = l->next)
+ {
+ e = l->data;
+
+ g_print ("%10s - %d\n", g_io_extension_get_name (e), g_io_extension_get_priority (e));
+ }
+
+ e = NULL;
+ }
+ else
+ {
+ e = g_io_extension_point_get_extension_by_name (ep, extension_name);
+ if (e == NULL)
+ {
+ g_warning ("Media extension \"%s\" from GTK_MEDIA environment variable not found.", extension_name);
+ }
+ }
+ }
+
+ if (e == NULL)
+ {
+ GList *l = g_io_extension_point_get_extensions (ep);
+
+ if (l == NULL)
+ {
+ g_error ("GTK was run without any GtkMediaFile extension being present. This must not happen.");
+ }
+
+ e = l->data;
+ }
+
+ impl_type = g_io_extension_get_type (e);
+
+ GTK_NOTE (MODULES, g_print ("Using %s from \"%s\" extension\n", g_type_name (impl_type), g_io_extension_get_name (e)));
+
+ return impl_type;
}
/**
@@ -524,3 +583,47 @@ gtk_media_file_get_input_stream (GtkMediaFile *self)
return priv->input_stream;
}
+
+void
+gtk_media_file_extension_init (void)
+{
+ GIOExtensionPoint *ep;
+ GIOModuleScope *scope;
+ char **paths;
+ int i;
+
+ GTK_NOTE (MODULES,
+ g_print ("Registering extension point %s\n", GTK_MEDIA_FILE_EXTENSION_POINT_NAME));
+
+ ep = g_io_extension_point_register (GTK_MEDIA_FILE_EXTENSION_POINT_NAME);
+ g_io_extension_point_set_required_type (ep, GTK_TYPE_MEDIA_FILE);
+
+ g_type_ensure (GTK_TYPE_NO_MEDIA_FILE);
+
+ scope = g_io_module_scope_new (G_IO_MODULE_SCOPE_BLOCK_DUPLICATES);
+
+ paths = _gtk_get_module_path ("media");
+ for (i = 0; paths[i]; i++)
+ {
+ GTK_NOTE (MODULES,
+ g_print ("Scanning io modules in %s\n", paths[i]));
+ g_io_modules_scan_all_in_directory_with_scope (paths[i], scope);
+ }
+ g_strfreev (paths);
+
+ g_io_module_scope_free (scope);
+
+ if (GTK_DEBUG_CHECK (MODULES))
+ {
+ GList *list, *l;
+
+ list = g_io_extension_point_get_extensions (ep);
+ for (l = list; l; l = l->next)
+ {
+ GIOExtension *ext = l->data;
+ g_print ("extension: %s: type %s\n",
+ g_io_extension_get_name (ext),
+ g_type_name (g_io_extension_get_type (ext)));
+ }
+ }
+}
diff --git a/gtk/gtkmediafile.h b/gtk/gtkmediafile.h
index 20f38399a4..daa17d9aa8 100644
--- a/gtk/gtkmediafile.h
+++ b/gtk/gtkmediafile.h
@@ -28,6 +28,8 @@
G_BEGIN_DECLS
+#define GTK_MEDIA_FILE_EXTENSION_POINT_NAME "gtk-media-file"
+
#define GTK_TYPE_MEDIA_FILE (gtk_media_file_get_type ())
GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtkmediafileprivate.h b/gtk/gtkmediafileprivate.h
new file mode 100644
index 0000000000..b328183bef
--- /dev/null
+++ b/gtk/gtkmediafileprivate.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2018 Benjamin Otte
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Benjamin Otte <otte@gnome.org>
+ */
+
+#ifndef __GTK_MEDIA_FILE_PRIVATE_H__
+#define __GTK_MEDIA_FILE_PRIVATE_H__
+
+#include "gtkmediafile.h"
+
+
+void gtk_media_file_extension_init (void);
+
+
+#endif /* __GTK_MEDIA_FILE_PRIVATE_H__ */
diff --git a/gtk/gtknomediafile.c b/gtk/gtknomediafile.c
new file mode 100644
index 0000000000..18ac36b9cb
--- /dev/null
+++ b/gtk/gtknomediafile.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2018 Benjamin Otte
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Benjamin Otte <otte@gnome.org>
+ */
+
+#include "config.h"
+
+#include "gtknomediafileprivate.h"
+
+#include "gtkintl.h"
+
+struct _GtkNoMediaFile
+{
+ GtkMediaFile parent_instance;
+};
+
+struct _GtkNoMediaFileClass
+{
+ GtkMediaFileClass parent_class;
+};
+
+G_DEFINE_TYPE_WITH_CODE (GtkNoMediaFile, gtk_no_media_file, GTK_TYPE_MEDIA_FILE,
+ g_io_extension_point_implement (GTK_MEDIA_FILE_EXTENSION_POINT_NAME,
+ g_define_type_id,
+ "none",
+ G_MININT);)
+
+static void
+gtk_no_media_file_open (GtkMediaFile *file)
+{
+ gtk_media_stream_error (GTK_MEDIA_STREAM (file),
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ _("GTK has been compiled without media support."));
+}
+
+static void
+gtk_no_media_file_class_init (GtkNoMediaFileClass *klass)
+{
+ GtkMediaFileClass *file_class = GTK_MEDIA_FILE_CLASS (klass);
+
+ file_class->open = gtk_no_media_file_open;
+}
+
+static void
+gtk_no_media_file_init (GtkNoMediaFile *video)
+{
+}
+
diff --git a/gtk/gtknomediafileprivate.h b/gtk/gtknomediafileprivate.h
new file mode 100644
index 0000000000..0bb6f7375a
--- /dev/null
+++ b/gtk/gtknomediafileprivate.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2018 Benjamin Otte
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Benjamin Otte <otte@gnome.org>
+ */
+
+#ifndef __GTK_NO_MEDIA_FILE_H__
+#define __GTK_NO_MEDIA_FILE_H__
+
+#include <gtk/gtkmediafile.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_NO_MEDIA_FILE (gtk_no_media_file_get_type ())
+
+G_DECLARE_FINAL_TYPE (GtkNoMediaFile, gtk_no_media_file, GTK, NO_MEDIA_FILE, GtkMediaFile)
+
+G_END_DECLS
+
+#endif /* __GTK_NO_MEDIA_FILE_H__ */
diff --git a/gtk/meson.build b/gtk/meson.build
index 6ea234c1b5..f62afe4c3d 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -265,6 +265,7 @@ gtk_public_sources = files([
'gtkmodules.c',
'gtkmountoperation.c',
'gtknativedialog.c',
+ 'gtknomediafile.c',
'gtknotebook.c',
'gtkorientable.c',
'gtkoverlay.c',
diff --git a/meson.build b/meson.build
index 68fce04f46..c2d0e51338 100644
--- a/meson.build
+++ b/meson.build
@@ -589,6 +589,7 @@ if cloudproviders_enabled
endif
endif
+
subdir('gdk')
subdir('gsk')
subdir('gtk')
@@ -705,6 +706,7 @@ summary = [
' Enabled backends: @0@'.format(pkg_targets.strip()),
' Vulkan support: @0@'.format(have_vulkan),
' Print backends: @0@'.format(' '.join(print_backends)),
+ ' Media backends: @0@'.format(' '.join(media_backends)),
' Tests: @0@'.format(get_option('build-tests')),
' Documentation: @0@'.format(get_option('documentation')),
' Demos: @0@'.format(get_option('demos')),
diff --git a/meson_options.txt b/meson_options.txt
index 74e5f21b32..4a6e322c16 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -10,6 +10,10 @@ option('win32-backend', type: 'boolean', value: true,
option('quartz-backend', type: 'boolean', value: true,
description : 'Enable the macOS gdk backend (only when building on macOS)')
+# Media backends
+option('media', type: 'string', value: 'none',
+ description : 'Build the specified media engines (comma-separated list, "all", or "none")')
+
# Optional dependencies
option('vulkan', type: 'combo', choices : ['yes', 'no', 'auto'], value : 'auto',
description : 'Enable support for the Vulkan graphics API')
diff --git a/modules/media/meson.build b/modules/media/meson.build
new file mode 100644
index 0000000000..efab5a3b3e
--- /dev/null
+++ b/modules/media/meson.build
@@ -0,0 +1,23 @@
+all_media_backends = [
+]
+
+enabled_media_backends = get_option('media').split(',')
+
+if enabled_media_backends.contains('none')
+ media_backends = []
+elif enabled_media_backends.contains('all')
+ media_backends = all_media_backends
+else
+ media_backends = []
+ foreach b: enabled_media_backends
+ if all_media_backends.contains(b)
+ media_backends += b
+ else
+ error('No media backend named "@0@" exists.'.format (b))
+ endif
+ endforeach
+endif
+
+media_subdir = 'gtk-4.0/@0@/media'.format(gtk_binary_version)
+media_install_dir = join_paths(get_option('libdir'), media_subdir)
+
diff --git a/modules/meson.build b/modules/meson.build
index cde966a094..670f9fd96c 100644
--- a/modules/meson.build
+++ b/modules/meson.build
@@ -1,3 +1,5 @@
if os_unix
subdir('printbackends')
endif
+
+subdir('media')