1 /* Copyright (C) <2021> Thibault Saunier <tsaunier@igalia.com>
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Library General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Library General Public License for more details.
12 *
13 * You should have received a copy of the GNU Library General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18 #ifdef HAVE_CONFIG_H
19 #include <config.h>
20 #endif
21
22 #include "gstwpeextension.h"
23
24 #include <errno.h>
25 #include <fcntl.h>
26 #include <sys/socket.h>
27
28 #include <gst/gst.h>
29 #include <gmodule.h>
30 #include <gio/gunixfdlist.h>
31 #include <wpe/webkit-web-extension.h>
32
33 G_MODULE_EXPORT void webkit_web_extension_initialize (WebKitWebExtension *
34 extension);
35
36 static WebKitWebExtension *global_extension = NULL;
37
38 void
webkit_web_extension_initialize(WebKitWebExtension * extension)39 webkit_web_extension_initialize (WebKitWebExtension * extension)
40 {
41 g_return_if_fail (!global_extension);
42
43 gst_init (NULL, NULL);
44
45 /* Register our own audio sink to */
46 gst_element_register (NULL, "gstwpeaudiosink", GST_RANK_PRIMARY + 500,
47 gst_wpe_audio_sink_get_type ());
48 gst_object_unref (g_object_new (gst_wpe_bus_msg_forwarder_get_type (), NULL));
49
50 global_extension = extension;
51 GST_INFO_OBJECT (global_extension, "Setting as global extension.");
52 }
53
54 void
gst_wpe_extension_send_message(WebKitUserMessage * msg,GCancellable * cancellable,GAsyncReadyCallback cb,gpointer udata)55 gst_wpe_extension_send_message (WebKitUserMessage * msg,
56 GCancellable * cancellable, GAsyncReadyCallback cb, gpointer udata)
57 {
58 webkit_web_extension_send_message_to_context (global_extension, msg,
59 cancellable, cb, udata);
60 }
61