Changeset 228946 in webkit
- Timestamp:
- Feb 23, 2018 4:53:04 AM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r228945 r228946 1 2018-02-23 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GStreamer][MiniBrowser] Honor GStreamer command line parameters in MiniBrowser 4 https://bugs.webkit.org/show_bug.cgi?id=173655 5 <rdar://problem/37706341> 6 7 Reviewed by Philippe Normand. 8 9 Do not assume gst is only used in the WebProcess, the MIMETypeRegistry also uses gst to get the list of 10 supported media types. Move the code to extract gst options from the process command line to a helper function 11 and use it in the UI process to pass the options to the WebProcess, but also in the current process when gst is 12 initialized without providing options. 13 14 Fixes several unit tests that use MIMETypeRegistry in the UI process. 15 16 * platform/graphics/gstreamer/GStreamerUtilities.cpp: 17 (WebCore::extractGStreamerOptionsFromCommandLine): Helper to get the gst options from the current process 18 command line. 19 (WebCore::initializeGStreamer): Ensure this is called once. Get the gst options from the given vector or extract 20 it from the command line if not provided. 21 * platform/graphics/gstreamer/GStreamerUtilities.h: 22 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp: 23 (WebCore::MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements): Bring back the gst 24 initialization here. 25 1 26 2018-02-23 Philippe Normand <pnormand@igalia.com> 2 27 -
trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp
r228818 r228946 27 27 #include "GstAllocatorFastMalloc.h" 28 28 #include "IntSize.h" 29 30 29 #include <gst/audio/audio-info.h> 31 30 #include <gst/gst.h> 31 #include <mutex> 32 #include <wtf/glib/GLibUtilities.h> 32 33 #include <wtf/glib/GUniquePtr.h> 33 34 … … 237 238 } 238 239 239 bool initializeGStreamer(Vector<String>& parameters) 240 { 241 GUniqueOutPtr<GError> error; 242 bool isGStreamerInitialized = false; 240 Vector<String> extractGStreamerOptionsFromCommandLine() 241 { 242 GUniqueOutPtr<char> contents; 243 gsize length; 244 if (!g_file_get_contents("/proc/self/cmdline", &contents.outPtr(), &length, nullptr)) 245 return { }; 246 247 Vector<String> options; 248 auto optionsString = String::fromUTF8(contents.get(), length); 249 optionsString.split('\0', false, [&options](StringView item) { 250 if (item.startsWith("--gst")) 251 options.append(item.toString()); 252 }); 253 return options; 254 } 255 256 bool initializeGStreamer(std::optional<Vector<String>>&& options) 257 { 258 static std::once_flag onceFlag; 259 static bool isGStreamerInitialized; 260 std::call_once(onceFlag, [options = WTFMove(options)] { 261 isGStreamerInitialized = false; 243 262 244 263 #if ENABLE(VIDEO) || ENABLE(WEB_AUDIO) 245 char** argv = g_new0(char*, parameters.size() + 2); 246 argv[0] = g_strdup("WebProcess"); 247 for (unsigned i = 1; i < parameters.size(); i++) 248 argv[i] = g_strdup(parameters[i].utf8().data()); 249 250 int size = g_strv_length(argv); 251 isGStreamerInitialized = gst_init_check(&size, &argv, &error.outPtr()); 252 g_strfreev(argv); 253 ASSERT_WITH_MESSAGE(isGStreamerInitialized, "GStreamer initialization failed: %s", error ? error->message : "unknown error occurred"); 254 255 if (isFastMallocEnabled()) { 256 const char* disableFastMalloc = getenv("WEBKIT_GST_DISABLE_FAST_MALLOC"); 257 if (!disableFastMalloc || !strcmp(disableFastMalloc, "0")) 258 gst_allocator_set_default(GST_ALLOCATOR(g_object_new(gst_allocator_fast_malloc_get_type(), nullptr))); 259 } 264 Vector<String> parameters = options.value_or(extractGStreamerOptionsFromCommandLine()); 265 char** argv = g_new0(char*, parameters.size() + 2); 266 int argc = parameters.size() + 1; 267 argv[0] = g_strdup(g_get_prgname()); 268 for (unsigned i = 0; i < parameters.size(); i++) 269 argv[i + 1] = g_strdup(parameters[i].utf8().data()); 270 271 GUniqueOutPtr<GError> error; 272 isGStreamerInitialized = gst_init_check(&argc, &argv, &error.outPtr()); 273 ASSERT_WITH_MESSAGE(isGStreamerInitialized, "GStreamer initialization failed: %s", error ? error->message : "unknown error occurred"); 274 g_strfreev(argv); 275 276 if (isFastMallocEnabled()) { 277 const char* disableFastMalloc = getenv("WEBKIT_GST_DISABLE_FAST_MALLOC"); 278 if (!disableFastMalloc || !strcmp(disableFastMalloc, "0")) 279 gst_allocator_set_default(GST_ALLOCATOR(g_object_new(gst_allocator_fast_malloc_get_type(), nullptr))); 280 } 260 281 261 282 #if ENABLE(VIDEO_TRACK) && USE(GSTREAMER_MPEGTS) 262 if (isGStreamerInitialized)263 gst_mpegts_initialize();264 #endif 265 #endif 266 283 if (isGStreamerInitialized) 284 gst_mpegts_initialize(); 285 #endif 286 #endif 287 }); 267 288 return isGStreamerInitialized; 268 289 } -
trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h
r228818 r228946 70 70 void mapGstBuffer(GstBuffer*, uint32_t); 71 71 void unmapGstBuffer(GstBuffer*); 72 bool initializeGStreamer(Vector<String>& parameters); 72 Vector<String> extractGStreamerOptionsFromCommandLine(); 73 bool initializeGStreamer(std::optional<Vector<String>>&& = std::nullopt); 73 74 unsigned getGstPlayFlag(const char* nick); 74 75 uint64_t toGstUnsigned64Time(const MediaTime&); -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
r228869 r228946 140 140 bool MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements() 141 141 { 142 if (!initializeGStreamer()) 143 return false; 144 142 145 registerWebKitGStreamerElements(); 143 146 -
trunk/Source/WebKit/ChangeLog
r228942 r228946 1 2018-02-23 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GStreamer][MiniBrowser] Honor GStreamer command line parameters in MiniBrowser 4 https://bugs.webkit.org/show_bug.cgi?id=173655 5 <rdar://problem/37706341> 6 7 Reviewed by Philippe Normand. 8 9 Actually pass the gst command line options to the WebProcess. The options in /proc/self/cmdline are separated by 10 null characters, so we are effectively passing always the first option only, which is the program name. Then, in 11 the web process we always ignore the first option and providing WebProcess unconditionally, so we were doing 12 nothing. 13 14 * UIProcess/gtk/WebProcessPoolGtk.cpp: 15 (WebKit::WebProcessPool::platformInitializeWebProcess): Use WebCore::extractGStreamerOptionsFromCommandLine() 16 * UIProcess/wpe/WebProcessPoolWPE.cpp: 17 (WebKit::WebProcessPool::platformInitializeWebProcess): Ditto. 18 * WebProcess/soup/WebProcessSoup.cpp: 19 (WebKit::WebProcess::platformInitializeWebProcess): Move the vector. 20 1 21 2018-02-22 Yusuke Suzuki <utatane.tea@gmail.com> 2 22 -
trunk/Source/WebKit/UIProcess/gtk/WebProcessPoolGtk.cpp
r228818 r228946 36 36 #include <JavaScriptCore/RemoteInspectorServer.h> 37 37 #include <WebCore/FileSystem.h> 38 #include <WebCore/GStreamerUtilities.h> 38 39 #include <WebCore/NotImplemented.h> 39 40 #include <WebCore/SchemeRegistry.h> … … 93 94 94 95 #if USE(GSTREAMER) 95 GUniqueOutPtr<gchar> contents; 96 gsize length; 97 if (g_file_get_contents("/proc/self/cmdline", &contents.outPtr(), &length, nullptr)) 98 parameters.gstreamerOptions.append(String::fromUTF8(contents.get())); 96 parameters.gstreamerOptions = WebCore::extractGStreamerOptionsFromCommandLine(); 99 97 #endif 100 98 } -
trunk/Source/WebKit/UIProcess/wpe/WebProcessPoolWPE.cpp
r228019 r228946 37 37 #include <JavaScriptCore/RemoteInspectorServer.h> 38 38 #include <WebCore/FileSystem.h> 39 #include <WebCore/GStreamerUtilities.h> 39 40 #include <WebCore/NotImplemented.h> 40 41 #include <WebCore/SchemeRegistry.h> … … 93 94 { 94 95 parameters.memoryCacheDisabled = m_memoryCacheDisabled || cacheModel() == CacheModelDocumentViewer; 96 #if USE(GSTREAMER) 97 parameters.gstreamerOptions = WebCore::extractGStreamerOptionsFromCommandLine(); 98 #endif 99 95 100 } 96 101 -
trunk/Source/WebKit/WebProcess/soup/WebProcessSoup.cpp
r228818 r228946 54 54 #endif 55 55 #if USE(GSTREAMER) 56 WebCore::initializeGStreamer( parameters.gstreamerOptions);56 WebCore::initializeGStreamer(WTFMove(parameters.gstreamerOptions)); 57 57 #endif 58 58 }
Note: See TracChangeset
for help on using the changeset viewer.