[GStreamer][MiniBrowser] Honor GStreamer command line parameters in MiniBrowser
authorphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Feb 2018 14:16:00 +0000 (14:16 +0000)
committerphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Feb 2018 14:16:00 +0000 (14:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173655

Reviewed by Xabier Rodriguez-Calvar.

The FIXME in GStreamerUtilities.cpp asks to pass the command line
parameters to the GStreamer initialization function.

Based on initial patch by: Vanessa Chipirrás Navalón  <vchipirras@igalia.com>

Source/WebCore:

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::constructCommon): Removes the call to the method
that GStreamer initializes. It is no longer necessary.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements): Ditto
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::initializeGStreamerAndRegisterWebKitMSEElement): Ditto
* platform/graphics/gstreamer/GStreamerUtilities.cpp:
(WebCore::initializeGStreamer): Receive the GStreamer options and initialize GStreamer.
* platform/graphics/gstreamer/GStreamerUtilities.h: Add vector which contains
GStreamer options as the input parameter of the initializeGStreamer() method.

Source/WebKit:

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h: Define the vector which contains the GStreamer options.
* UIProcess/gtk/WebProcessPoolGtk.cpp:
(WebKit::WebProcessPool::platformInitializeWebProcess): Read from cmdline file
the GStreamer options written by console.
* WebProcess/soup/WebProcessSoup.cpp:
(WebKit::WebProcess::platformInitializeWebProcess): Call initializeGStreamer() method passing
the vector which contains the options.

Tools:

* MiniBrowser/gtk/main.c:
(main): Add the group containing the Gstreamer options that the console displays.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228818 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp
Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebProcessCreationParameters.cpp
Source/WebKit/Shared/WebProcessCreationParameters.h
Source/WebKit/UIProcess/gtk/WebProcessPoolGtk.cpp
Source/WebKit/WebProcess/soup/WebProcessSoup.cpp
Tools/ChangeLog
Tools/MiniBrowser/gtk/CMakeLists.txt
Tools/MiniBrowser/gtk/main.c

index 4cb2b53..b048e0e 100644 (file)
@@ -1,3 +1,27 @@
+2018-02-20  Philippe Normand  <pnormand@igalia.com>
+
+        [GStreamer][MiniBrowser] Honor GStreamer command line parameters in MiniBrowser
+        https://bugs.webkit.org/show_bug.cgi?id=173655
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        The FIXME in GStreamerUtilities.cpp asks to pass the command line
+        parameters to the GStreamer initialization function.
+
+        Based on initial patch by: Vanessa Chipirrás Navalón  <vchipirras@igalia.com>
+
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::constructCommon): Removes the call to the method
+        that GStreamer initializes. It is no longer necessary.
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements): Ditto
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
+        (WebCore::initializeGStreamerAndRegisterWebKitMSEElement): Ditto
+        * platform/graphics/gstreamer/GStreamerUtilities.cpp:
+        (WebCore::initializeGStreamer): Receive the GStreamer options and initialize GStreamer.
+        * platform/graphics/gstreamer/GStreamerUtilities.h: Add vector which contains
+        GStreamer options as the input parameter of the initializeGStreamer() method.
+
 2018-02-20  Miguel Gomez  <magomez@igalia.com>
 
         [GTK] whatsapp web blurry in some parts, sharp on others
index 091b0d1..dc6462b 100644 (file)
@@ -162,10 +162,6 @@ void AudioContext::constructCommon()
     // Lets mark it as ActiveDOMObject with pending activity and unmark it in clear method.
     setPendingActivity(this);
 
-#if USE(GSTREAMER)
-    initializeGStreamer();
-#endif
-
     FFTFrame::initialize();
     
     m_listener = AudioListener::create();
index 8c2e0c2..ea20229 100644 (file)
@@ -236,15 +236,21 @@ void unmapGstBuffer(GstBuffer* buffer)
     fastFree(mapInfo);
 }
 
-bool initializeGStreamer()
+bool initializeGStreamer(Vector<String>& parameters)
 {
-    if (gst_is_initialized())
-        return true;
-
     GUniqueOutPtr<GError> error;
-    // FIXME: We should probably pass the arguments from the command line.
-    bool gstInitialized = gst_init_check(nullptr, nullptr, &error.outPtr());
-    ASSERT_WITH_MESSAGE(gstInitialized, "GStreamer initialization failed: %s", error ? error->message : "unknown error occurred");
+    bool isGStreamerInitialized = false;
+
+#if ENABLE(VIDEO) || ENABLE(WEB_AUDIO)
+    char** argv = g_new0(char*, parameters.size() + 2);
+    argv[0] = g_strdup("WebProcess");
+    for (unsigned i = 1; i < parameters.size(); i++)
+        argv[i] = g_strdup(parameters[i].utf8().data());
+
+    int size = g_strv_length(argv);
+    isGStreamerInitialized = gst_init_check(&size, &argv, &error.outPtr());
+    g_strfreev(argv);
+    ASSERT_WITH_MESSAGE(isGStreamerInitialized, "GStreamer initialization failed: %s", error ? error->message : "unknown error occurred");
 
     if (isFastMallocEnabled()) {
         const char* disableFastMalloc = getenv("WEBKIT_GST_DISABLE_FAST_MALLOC");
@@ -253,11 +259,12 @@ bool initializeGStreamer()
     }
 
 #if ENABLE(VIDEO_TRACK) && USE(GSTREAMER_MPEGTS)
-    if (gstInitialized)
+    if (isGStreamerInitialized)
         gst_mpegts_initialize();
 #endif
+#endif
 
-    return gstInitialized;
+    return isGStreamerInitialized;
 }
 
 unsigned getGstPlayFlag(const char* nick)
index 8472d78..0362b73 100644 (file)
@@ -69,7 +69,7 @@ bool doCapsHaveType(const GstCaps*, const char*);
 bool areEncryptedCaps(const GstCaps*);
 void mapGstBuffer(GstBuffer*, uint32_t);
 void unmapGstBuffer(GstBuffer*);
-bool initializeGStreamer();
+bool initializeGStreamer(Vector<String>& parameters);
 unsigned getGstPlayFlag(const char* nick);
 uint64_t toGstUnsigned64Time(const MediaTime&);
 
index 87ab481..04bb00d 100644 (file)
@@ -138,9 +138,6 @@ void registerWebKitGStreamerElements()
 
 bool MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements()
 {
-    if (!initializeGStreamer())
-        return false;
-
     registerWebKitGStreamerElements();
 
     GRefPtr<GstElementFactory> srcFactory = adoptGRef(gst_element_factory_find("webkitwebsrc"));
index 40eae9a..275bc2d 100644 (file)
@@ -86,9 +86,6 @@ void MediaPlayerPrivateGStreamerMSE::registerMediaEngine(MediaEngineRegistrar re
 
 bool initializeGStreamerAndRegisterWebKitMSEElement()
 {
-    if (UNLIKELY(!initializeGStreamer()))
-        return false;
-
     registerWebKitGStreamerElements();
 
     GST_DEBUG_CATEGORY_INIT(webkit_mse_debug, "webkitmse", 0, "WebKit MSE media player");
index 7badf2d..eccfdb3 100644 (file)
@@ -1,3 +1,26 @@
+2018-02-20  Philippe Normand  <pnormand@igalia.com>
+
+        [GStreamer][MiniBrowser] Honor GStreamer command line parameters in MiniBrowser
+        https://bugs.webkit.org/show_bug.cgi?id=173655
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        The FIXME in GStreamerUtilities.cpp asks to pass the command line
+        parameters to the GStreamer initialization function.
+
+        Based on initial patch by: Vanessa Chipirrás Navalón  <vchipirras@igalia.com>
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode const):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h: Define the vector which contains the GStreamer options.
+        * UIProcess/gtk/WebProcessPoolGtk.cpp:
+        (WebKit::WebProcessPool::platformInitializeWebProcess): Read from cmdline file
+        the GStreamer options written by console.
+        * WebProcess/soup/WebProcessSoup.cpp:
+        (WebKit::WebProcess::platformInitializeWebProcess): Call initializeGStreamer() method passing
+        the vector which contains the options.
+
 2018-02-20  Yousuke Kimoto  <yousuke.kimoto@sony.com>
 
         [Win] Fix MSVC's treating __attribute__((warn_unused_result))
index 9bc6c37..747b84a 100644 (file)
@@ -94,6 +94,9 @@ void WebProcessCreationParameters::encode(IPC::Encoder& encoder) const
     encoder << fontWhitelist;
     encoder << terminationTimeout;
     encoder << languages;
+#if USE(GSTREAMER)
+    encoder << gstreamerOptions;
+#endif
     encoder << textCheckerState;
     encoder << fullKeyboardAccessEnabled;
     encoder << defaultRequestTimeoutInterval;
@@ -296,6 +299,10 @@ bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreat
         return false;
     if (!decoder.decode(parameters.languages))
         return false;
+#if USE(GSTREAMER)
+    if (!decoder.decode(parameters.gstreamerOptions))
+        return false;
+#endif
     if (!decoder.decode(parameters.textCheckerState))
         return false;
     if (!decoder.decode(parameters.fullKeyboardAccessEnabled))
index 72e9274..3d0813f 100644 (file)
@@ -111,6 +111,9 @@ struct WebProcessCreationParameters {
 
     Vector<String> fontWhitelist;
     Vector<String> languages;
+#if USE(GSTREAMER)
+    Vector<String> gstreamerOptions;
+#endif
 
     CacheModel cacheModel;
 
index b4a1723..ede4106 100644 (file)
@@ -90,6 +90,13 @@ void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters&
 {
     parameters.memoryCacheDisabled = m_memoryCacheDisabled || cacheModel() == CacheModelDocumentViewer;
     parameters.proxySettings = m_networkProxySettings;
+
+#if USE(GSTREAMER)
+    GUniqueOutPtr<gchar> contents;
+    gsize length;
+    if (g_file_get_contents("/proc/self/cmdline", &contents.outPtr(), &length, nullptr))
+        parameters.gstreamerOptions.append(String::fromUTF8(contents.get()));
+#endif
 }
 
 void WebProcessPool::platformInvalidateContext()
index 07104be..5c99a3c 100644 (file)
@@ -28,6 +28,7 @@
 #include "WebProcess.h"
 
 #include "WebProcessCreationParameters.h"
+#include <WebCore/GStreamerUtilities.h>
 #include <WebCore/MemoryCache.h>
 #include <WebCore/NetworkStorageSession.h>
 #include <WebCore/SoupNetworkSession.h>
@@ -51,6 +52,9 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& par
 #if PLATFORM(WAYLAND)
     m_waylandCompositorDisplay = WaylandCompositorDisplay::create(parameters.waylandCompositorDisplayName);
 #endif
+#if USE(GSTREAMER)
+    WebCore::initializeGStreamer(parameters.gstreamerOptions);
+#endif
 }
 
 void WebProcess::platformTerminate()
index a1de027..06231ac 100644 (file)
@@ -1,3 +1,17 @@
+2018-02-20  Philippe Normand  <pnormand@igalia.com>
+
+        [GStreamer][MiniBrowser] Honor GStreamer command line parameters in MiniBrowser
+        https://bugs.webkit.org/show_bug.cgi?id=173655
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        The FIXME in GStreamerUtilities.cpp asks to pass the command line
+        parameters to the GStreamer initialization function.
+
+        Based on initial patch by: Vanessa Chipirrás Navalón  <vchipirras@igalia.com>
+
+        * MiniBrowser/gtk/main.c:
+        (main): Add the group containing the Gstreamer options that the console displays.
 2018-02-19  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         [WTR][GTK] crash log backtrace doesn't show symbol names for DatabaseProcess and NetworkProcess
index dc2b61e..a0d3205 100644 (file)
@@ -32,6 +32,7 @@ set(MiniBrowser_SYSTEM_INCLUDE_DIRECTORIES
     ${GTK3_INCLUDE_DIRS}
     ${GLIB_INCLUDE_DIRS}
     ${LIBSOUP_INCLUDE_DIRS}
+    ${GSTREAMER_INCLUDE_DIRS}
 )
 
 set(MiniBrowser_LIBRARIES
@@ -40,6 +41,7 @@ set(MiniBrowser_LIBRARIES
     ${GTK3_LIBRARIES}
     ${GLIB_LIBRARIES}
     ${LIBSOUP_LIBRARIES}
+    ${GSTREAMER_LIBRARIES}
 )
 
 add_custom_command(
index c5b8a4e..f5da6ed 100644 (file)
@@ -30,6 +30,7 @@
 #include "BrowserWindow.h"
 #include <JavaScriptCore/JavaScript.h>
 #include <errno.h>
+#include <gst/gst.h>
 #include <gtk/gtk.h>
 #include <string.h>
 #include <webkit2/webkit2.h>
@@ -484,6 +485,7 @@ int main(int argc, char *argv[])
     GOptionContext *context = g_option_context_new(NULL);
     g_option_context_add_main_entries(context, commandLineOptions, 0);
     g_option_context_add_group(context, gtk_get_option_group(TRUE));
+    g_option_context_add_group(context, gst_init_get_option_group());
 
     WebKitSettings *webkitSettings = webkit_settings_new();
     webkit_settings_set_enable_developer_extras(webkitSettings, TRUE);