Changeset 271396 in webkit


Ignore:
Timestamp:
Jan 12, 2021 2:55:16 AM (3 years ago)
Author:
Philippe Normand
Message:

[GStreamer] Lazy initialization support
https://bugs.webkit.org/show_bug.cgi?id=209332

Reviewed by Carlos Garcia Campos.

Source/WebCore:

The GStreamer library is now mostly used from the WebProcess only. The last remaining
GStreamer usage from the UIProcess is triggered by the webkit_web_view_can_show_mime_type()
API, which is acceptable for now.

GStreamer will now be initialized only if it is needed, so lazy initialization calls were
added in the various WebCore components relying on the library.

Based on preliminary patches by Charlie Turner <cturner@igalia.com> and Victor M Jaquez <vjaquez@igalia.com>.

  • platform/audio/gstreamer/AudioDestinationGStreamer.cpp:

(WebCore::initializeDebugCategory): Lazily initialize GStreamer and load our in-house
elements (webkitwebaudiosrc is needed by this module).

  • platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:

(WebCore::initializeDebugCategory): Lazily initialize GStreamer.

  • platform/graphics/gstreamer/GStreamerCommon.cpp:

(WebCore::addGStreamerOptionsFromUIProcess): Store command-line arguments from the UIProcess.
(WebCore::ensureGStreamerInitialized): Ooptionally use command-line arguments from the
UIProcess.
(WebCore::registerWebKitGStreamerElements): Decouple from initialization function.
(WebCore::initializeGStreamer): Deleted.
(WebCore::initializeGStreamerAndRegisterWebKitElements): Deleted.

  • platform/graphics/gstreamer/GStreamerCommon.h:
  • platform/graphics/gstreamer/GStreamerRegistryScanner.cpp:

(WebCore::GStreamerRegistryScanner::GStreamerRegistryScanner): Lazily initialize GStreamer.

  • platform/graphics/gstreamer/ImageDecoderGStreamer.cpp:

(WebCore::ImageDecoderGStreamer::supportsContainerType): Bail off on non-video mime-types
and call-sites outside of the WebProcess. We can't rely on gst_is_initialized() anymore
because it is lazily initialized.
(WebCore::ImageDecoderGStreamer::canDecodeType): Ditto.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::MediaPlayerPrivateGStreamer::isAvailable): This is a no-op now, no need to check
the playbin factory, we can fail from setPipeline().
(WebCore::MediaPlayerPrivateGStreamer::setPipeline): Bail off if playbin wasn't found.
(WebCore::MediaPlayerPrivateGStreamer::registerMediaEngine):
(WebCore::MediaPlayerPrivateGStreamer::loadFull): Remove now-useless gif hack, the player
discards all non-audio non-video mimetype.
(WebCore::MediaPlayerPrivateGStreamer::volumeChangedCallback): Prevent ghost volume notifications.
(WebCore::MediaPlayerPrivateGStreamer::supportsType): Bail off on image mime-types.

  • platform/graphics/gstreamer/MediaSampleGStreamer.cpp:

(WebCore::MediaSampleGStreamer::createImageSample): Lazily initialize GStreamer.

  • platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:

(WebCore::MediaPlayerPrivateGStreamerMSE::registerMediaEngine): Simplify, isAvailable() now no-op.

  • platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp: Lazily initialize GStreamer.

(WebCore::initializeDebugCategory):
(WebCore::m_capturer):
(WebCore::GStreamerAudioCaptureSource::GStreamerAudioCaptureSource):
(WebCore::initializeGStreamerDebug): Deleted.

  • platform/mediastream/gstreamer/GStreamerCaptureDeviceManager.cpp: Lazily initialize GStreamer.

(WebCore::GStreamerCaptureDeviceManager::captureDevices):

  • platform/mediastream/gstreamer/GStreamerCapturer.cpp: Ditto.

(WebCore::initializeDebugCategory):
(WebCore::GStreamerCapturer::GStreamerCapturer):
(WebCore::initializeGStreamerAndDebug): Deleted.

  • platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp: Ditto.

(WebCore::initializeDebugCategory):
(WebCore::GStreamerVideoCaptureSource::GStreamerVideoCaptureSource):
(WebCore::m_capturer):
(WebCore::initializeGStreamerDebug): Deleted.

  • platform/mediastream/gstreamer/MockRealtimeAudioSourceGStreamer.cpp: Ditto.

(WebCore::MockRealtimeAudioSourceGStreamer::MockRealtimeAudioSourceGStreamer):

  • platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp: Ditto.

(WebCore::MockRealtimeVideoSourceGStreamer::MockRealtimeVideoSourceGStreamer):

  • platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp: Ditto.

(WebCore::GStreamerVideoDecoderFactory::GStreamerVideoDecoderFactory):

  • platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp: Ditto.

(WebCore::GStreamerVideoEncoderFactory::GStreamerVideoEncoderFactory):

Source/WebKit:

Introduce a GTK/WPE UserMediaCaptureManager that relays permission requests to the
RealtimeMediaSourceCenter running in the WebProcess. We might move this to the GPUProcess at
some point but for the time being we only want to avoid initializing GStreamer from the
UIProcess.

  • PlatformGTK.cmake:
  • PlatformWPE.cmake:
  • UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
  • UIProcess/glib/UserMediaPermissionRequestManagerProxyGLib.cpp: Added.

(WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionRequest):

  • WebProcess/glib/UserMediaCaptureManager.cpp: Added.

(WebKit::UserMediaCaptureManager::UserMediaCaptureManager):
(WebKit::UserMediaCaptureManager::~UserMediaCaptureManager):
(WebKit::UserMediaCaptureManager::validateUserMediaRequestConstraints):

  • WebProcess/glib/UserMediaCaptureManager.h: Added.

(WebKit::UserMediaCaptureManager::supplementName):

  • WebProcess/glib/UserMediaCaptureManager.messages.in: Added.
  • WebProcess/glib/WebProcessGLib.cpp:

(WebKit::WebProcess::platformInitializeWebProcess):

Location:
trunk/Source
Files:
4 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r271394 r271396  
     12021-01-12  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer] Lazy initialization support
     4        https://bugs.webkit.org/show_bug.cgi?id=209332
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        The GStreamer library is now mostly used from the WebProcess only. The last remaining
     9        GStreamer usage from the UIProcess is triggered by the webkit_web_view_can_show_mime_type()
     10        API, which is acceptable for now.
     11
     12        GStreamer will now be initialized only if it is needed, so lazy initialization calls were
     13        added in the various WebCore components relying on the library.
     14
     15        Based on preliminary patches by Charlie Turner <cturner@igalia.com> and Victor M Jaquez <vjaquez@igalia.com>.
     16
     17        * platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
     18        (WebCore::initializeDebugCategory): Lazily initialize GStreamer and load our in-house
     19        elements (webkitwebaudiosrc is needed by this module).
     20        * platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:
     21        (WebCore::initializeDebugCategory): Lazily initialize GStreamer.
     22        * platform/graphics/gstreamer/GStreamerCommon.cpp:
     23        (WebCore::addGStreamerOptionsFromUIProcess): Store command-line arguments from the UIProcess.
     24        (WebCore::ensureGStreamerInitialized): Ooptionally use command-line arguments from the
     25        UIProcess.
     26        (WebCore::registerWebKitGStreamerElements): Decouple from initialization function.
     27        (WebCore::initializeGStreamer): Deleted.
     28        (WebCore::initializeGStreamerAndRegisterWebKitElements): Deleted.
     29        * platform/graphics/gstreamer/GStreamerCommon.h:
     30        * platform/graphics/gstreamer/GStreamerRegistryScanner.cpp:
     31        (WebCore::GStreamerRegistryScanner::GStreamerRegistryScanner): Lazily initialize GStreamer.
     32        * platform/graphics/gstreamer/ImageDecoderGStreamer.cpp:
     33        (WebCore::ImageDecoderGStreamer::supportsContainerType): Bail off on non-video mime-types
     34        and call-sites outside of the WebProcess. We can't rely on gst_is_initialized() anymore
     35        because it is lazily initialized.
     36        (WebCore::ImageDecoderGStreamer::canDecodeType): Ditto.
     37        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     38        (WebCore::MediaPlayerPrivateGStreamer::isAvailable): This is a no-op now, no need to check
     39        the playbin factory, we can fail from setPipeline().
     40        (WebCore::MediaPlayerPrivateGStreamer::setPipeline): Bail off if playbin wasn't found.
     41        (WebCore::MediaPlayerPrivateGStreamer::registerMediaEngine):
     42        (WebCore::MediaPlayerPrivateGStreamer::loadFull): Remove now-useless gif hack, the player
     43        discards all non-audio non-video mimetype.
     44        (WebCore::MediaPlayerPrivateGStreamer::volumeChangedCallback): Prevent ghost volume notifications.
     45        (WebCore::MediaPlayerPrivateGStreamer::supportsType): Bail off on image mime-types.
     46        * platform/graphics/gstreamer/MediaSampleGStreamer.cpp:
     47        (WebCore::MediaSampleGStreamer::createImageSample): Lazily initialize GStreamer.
     48        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
     49        (WebCore::MediaPlayerPrivateGStreamerMSE::registerMediaEngine): Simplify, isAvailable() now no-op.
     50        * platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp: Lazily initialize GStreamer.
     51        (WebCore::initializeDebugCategory):
     52        (WebCore::m_capturer):
     53        (WebCore::GStreamerAudioCaptureSource::GStreamerAudioCaptureSource):
     54        (WebCore::initializeGStreamerDebug): Deleted.
     55        * platform/mediastream/gstreamer/GStreamerCaptureDeviceManager.cpp: Lazily initialize GStreamer.
     56        (WebCore::GStreamerCaptureDeviceManager::captureDevices):
     57        * platform/mediastream/gstreamer/GStreamerCapturer.cpp: Ditto.
     58        (WebCore::initializeDebugCategory):
     59        (WebCore::GStreamerCapturer::GStreamerCapturer):
     60        (WebCore::initializeGStreamerAndDebug): Deleted.
     61        * platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp: Ditto.
     62        (WebCore::initializeDebugCategory):
     63        (WebCore::GStreamerVideoCaptureSource::GStreamerVideoCaptureSource):
     64        (WebCore::m_capturer):
     65        (WebCore::initializeGStreamerDebug): Deleted.
     66        * platform/mediastream/gstreamer/MockRealtimeAudioSourceGStreamer.cpp: Ditto.
     67        (WebCore::MockRealtimeAudioSourceGStreamer::MockRealtimeAudioSourceGStreamer):
     68        * platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp: Ditto.
     69        (WebCore::MockRealtimeVideoSourceGStreamer::MockRealtimeVideoSourceGStreamer):
     70        * platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp: Ditto.
     71        (WebCore::GStreamerVideoDecoderFactory::GStreamerVideoDecoderFactory):
     72        * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp: Ditto.
     73        (WebCore::GStreamerVideoEncoderFactory::GStreamerVideoEncoderFactory):
     74
    1752021-01-12  Zalan Bujtas  <zalan@apple.com>
    276
  • trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp

    r271197 r271396  
    4545static void initializeDebugCategory()
    4646{
     47    ensureGStreamerInitialized();
     48    registerWebKitGStreamerElements();
     49
    4750    static std::once_flag onceFlag;
    4851    std::call_once(onceFlag, [] {
  • trunk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp

    r269104 r271396  
    4444static void initializeDebugCategory()
    4545{
     46    ensureGStreamerInitialized();
    4647    static std::once_flag onceFlag;
    4748    std::call_once(onceFlag, [] {
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp

    r271290 r271396  
    2828#include "GstAllocatorFastMalloc.h"
    2929#include "IntSize.h"
     30#include "RuntimeApplicationChecks.h"
    3031#include "SharedBuffer.h"
    3132#include "WebKitAudioSinkGStreamer.h"
     
    215216}
    216217
     218static Optional<Vector<String>> s_UIProcessCommandLineOptions;
     219void setGStreamerOptionsFromUIProcess(Vector<String>&& options)
     220{
     221    s_UIProcessCommandLineOptions = WTFMove(options);
     222}
     223
    217224Vector<String> extractGStreamerOptionsFromCommandLine()
    218225{
     
    231238}
    232239
    233 bool initializeGStreamer(Optional<Vector<String>>&& options)
    234 {
     240bool ensureGStreamerInitialized()
     241{
     242    RELEASE_ASSERT(isInWebProcess());
    235243    static std::once_flag onceFlag;
    236244    static bool isGStreamerInitialized;
    237     std::call_once(onceFlag, [options = WTFMove(options)] {
     245    std::call_once(onceFlag, [] {
    238246        isGStreamerInitialized = false;
    239247
     
    246254
    247255#if ENABLE(VIDEO) || ENABLE(WEB_AUDIO)
    248         Vector<String> parameters = options.valueOr(extractGStreamerOptionsFromCommandLine());
     256        Vector<String> parameters = s_UIProcessCommandLineOptions.valueOr(extractGStreamerOptionsFromCommandLine());
     257        s_UIProcessCommandLineOptions.reset();
    249258        char** argv = g_new0(char*, parameters.size() + 2);
    250259        int argc = parameters.size() + 1;
     
    293302#endif
    294303
    295 bool initializeGStreamerAndRegisterWebKitElements()
    296 {
    297     if (!initializeGStreamer())
    298         return false;
    299 
     304void registerWebKitGStreamerElements()
     305{
    300306    static std::once_flag onceFlag;
    301307    std::call_once(onceFlag, [] {
     
    344350        }
    345351    });
    346     return true;
    347352}
    348353
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h

    r271197 r271396  
    7070bool areEncryptedCaps(const GstCaps*);
    7171Vector<String> extractGStreamerOptionsFromCommandLine();
    72 bool initializeGStreamer(Optional<Vector<String>>&& = WTF::nullopt);
    73 bool initializeGStreamerAndRegisterWebKitElements();
     72void setGStreamerOptionsFromUIProcess(Vector<String>&&);
     73bool ensureGStreamerInitialized();
     74void registerWebKitGStreamerElements();
    7475unsigned getGstPlayFlag(const char* nick);
    7576uint64_t toGstUnsigned64Time(const MediaTime&);
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp

    r271353 r271396  
    184184    : m_isMediaSource(isMediaSource)
    185185{
    186     if (!isInWebProcess())
     186    if (isInWebProcess())
     187        ensureGStreamerInitialized();
     188    else {
     189        // This is still needed, mostly because of the webkit_web_view_can_show_mime_type() public API (so
     190        // running from UIProcess).
    187191        gst_init(nullptr, nullptr);
     192    }
     193
    188194    GST_DEBUG_CATEGORY_INIT(webkit_media_gst_registry_scanner_debug, "webkitregistryscanner", 0, "WebKit GStreamer registry scanner");
    189195
  • trunk/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp

    r270845 r271396  
    2929#include "MediaSampleGStreamer.h"
    3030#include "NotImplemented.h"
     31#include "RuntimeApplicationChecks.h"
    3132#include <gst/app/gstappsink.h>
    3233#include <wtf/Lock.h>
     
    101102    // Ideally this decoder should operate only from the WebProcess (or from the GPUProcess) which
    102103    // should be the only process where GStreamer has been runtime initialized.
    103     if (!gst_is_initialized())
     104    if (!isInWebProcess())
    104105        return false;
    105106
     107    if (!type.startsWith("video/"_s))
     108        return false;
     109
    106110    return GStreamerRegistryScanner::singleton().isContainerTypeSupported(GStreamerRegistryScanner::Configuration::Decoding, type);
    107111}
     
    109113bool ImageDecoderGStreamer::canDecodeType(const String& mimeType)
    110114{
     115    if (mimeType.isEmpty())
     116        return false;
     117
     118    if (!mimeType.startsWith("video/"_s))
     119        return false;
     120
    111121    // Ideally this decoder should operate only from the WebProcess (or from the GPUProcess) which
    112122    // should be the only process where GStreamer has been runtime initialized.
    113     if (!gst_is_initialized())
    114         return false;
    115 
    116     if (mimeType.isEmpty())
     123    if (!isInWebProcess())
    117124        return false;
    118125
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r271355 r271396  
    304304bool MediaPlayerPrivateGStreamer::isAvailable()
    305305{
    306     if (!initializeGStreamerAndRegisterWebKitElements())
    307         return false;
    308 
    309     // FIXME: This has not been updated for the playbin3 switch.
    310     GRefPtr<GstElementFactory> factory = adoptGRef(gst_element_factory_find("playbin"));
    311     if (!factory)
    312         GST_WARNING("Couldn't find a factory for the playbin element. Media playback will be disabled.");
    313     return factory;
     306    return true;
    314307}
    315308
     
    342335{
    343336    initializeDebugCategory();
    344 
    345     if (isAvailable())
    346         registrar(makeUnique<MediaPlayerFactoryGStreamer>());
     337    registrar(makeUnique<MediaPlayerFactoryGStreamer>());
    347338}
    348339
    349340void MediaPlayerPrivateGStreamer::loadFull(const String& urlString, const String& pipelineName)
    350341{
    351     if (m_player->contentMIMEType() == "image/gif") {
    352         loadingFailed(MediaPlayer::NetworkState::FormatError, MediaPlayer::ReadyState::HaveNothing, true);
    353         return;
    354     }
    355 
    356342    URL url(URL(), urlString);
    357343    if (url.protocolIsAbout()) {
     
    359345        return;
    360346    }
     347
     348    if (!ensureGStreamerInitialized()) {
     349        loadingFailed(MediaPlayer::NetworkState::FormatError, MediaPlayer::ReadyState::HaveNothing, true);
     350        return;
     351    }
     352
     353    registerWebKitGStreamerElements();
    361354
    362355    if (!m_pipeline)
     
    16111604void MediaPlayerPrivateGStreamer::setPipeline(GstElement* pipeline)
    16121605{
     1606    if (!pipeline) {
     1607        GST_WARNING("Playbin not found, make sure to install gst-plugins-base");
     1608        loadingFailed(MediaPlayer::NetworkState::FormatError, MediaPlayer::ReadyState::HaveNothing, true);
     1609        return;
     1610    }
     1611
    16131612    m_pipeline = pipeline;
    16141613
     
    17611760void MediaPlayerPrivateGStreamer::volumeChangedCallback(MediaPlayerPrivateGStreamer* player)
    17621761{
     1762    if (player->isPlayerShuttingDown())
     1763        return;
     1764
    17631765    // This is called when m_volumeElement receives the notify::volume signal.
    17641766    GST_DEBUG_OBJECT(player->pipeline(), "Volume changed to: %f", player->volume());
     
    26362638#endif
    26372639
    2638 #if !ENABLE(MEDIA_STREAM)
    2639     if (parameters.isMediaStream)
     2640    if (parameters.isMediaStream) {
     2641#if ENABLE(MEDIA_STREAM)
     2642        return MediaPlayer::SupportsType::IsSupported;
     2643#else
    26402644        return result;
    26412645#endif
    2642 
     2646    }
     2647
     2648    GST_DEBUG("Checking mime-type \"%s\"", parameters.type.raw().utf8().data());
    26432649    if (parameters.type.isEmpty())
    26442650        return result;
    26452651
    2646     GST_DEBUG("Checking mime-type \"%s\"", parameters.type.raw().utf8().data());
     2652    // This player doesn't support pictures rendering.
     2653    if (parameters.type.raw().startsWith("image"_s))
     2654        return result;
     2655
    26472656    auto& gstRegistryScanner = GStreamerRegistryScanner::singleton();
    26482657    result = gstRegistryScanner.isContentTypeSupported(GStreamerRegistryScanner::Configuration::Decoding, parameters.type, parameters.contentTypesRequiringHardwareSupport);
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp

    r269101 r271396  
    100100Ref<MediaSampleGStreamer> MediaSampleGStreamer::createImageSample(Vector<uint8_t>&& bgraData, unsigned width, unsigned height, double frameRate)
    101101{
     102    ensureGStreamerInitialized();
     103
    102104    size_t size = bgraData.sizeInBytes();
    103105    auto* data = bgraData.releaseBuffer().leakPtr();
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp

    r271353 r271396  
    9999void MediaPlayerPrivateGStreamerMSE::registerMediaEngine(MediaEngineRegistrar registrar)
    100100{
    101     initializeGStreamerAndRegisterWebKitElements();
    102101    GST_DEBUG_CATEGORY_INIT(webkit_mse_debug, "webkitmse", 0, "WebKit MSE media player");
    103     if (isAvailable())
    104         registrar(makeUnique<MediaPlayerFactoryGStreamerMSE>());
     102    registrar(makeUnique<MediaPlayerFactoryGStreamerMSE>());
    105103}
    106104
  • trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp

    r269849 r271396  
    4545#define GST_CAT_DEFAULT webkit_audio_capture_source_debug
    4646
    47 static void initializeGStreamerDebug()
    48 {
     47static void initializeDebugCategory()
     48{
     49    ensureGStreamerInitialized();
     50
    4951    static std::once_flag debugRegisteredFlag;
    5052    std::call_once(debugRegisteredFlag, [] {
     
    98100    , m_capturer(makeUnique<GStreamerAudioCapturer>(device))
    99101{
    100     initializeGStreamerDebug();
     102    initializeDebugCategory();
    101103}
    102104
     
    105107    , m_capturer(makeUnique<GStreamerAudioCapturer>())
    106108{
    107     initializeGStreamerDebug();
     109    initializeDebugCategory();
    108110}
    109111
  • trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerCaptureDeviceManager.cpp

    r241587 r271396  
    8080const Vector<CaptureDevice>& GStreamerCaptureDeviceManager::captureDevices()
    8181{
    82     initializeGStreamer();
     82    ensureGStreamerInitialized();
    8383    if (m_devices.isEmpty())
    8484        refreshCaptureDevices();
  • trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerCapturer.cpp

    r267934 r271396  
    3535namespace WebCore {
    3636
    37 static void initializeGStreamerAndDebug()
     37static void initializeDebugCategory()
    3838{
    39     initializeGStreamer();
     39    ensureGStreamerInitialized();
    4040
    4141    static std::once_flag debugRegisteredFlag;
     
    5050    , m_sourceFactory(nullptr)
    5151{
    52     initializeGStreamerAndDebug();
     52    initializeDebugCategory();
    5353}
    5454
     
    5858    , m_sourceFactory(sourceFactory)
    5959{
    60     initializeGStreamerAndDebug();
     60    initializeDebugCategory();
    6161}
    6262
  • trunk/Source/WebCore/platform/mediastream/gstreamer/GStreamerVideoCaptureSource.cpp

    r267934 r271396  
    3636#define GST_CAT_DEFAULT webkit_video_capture_source_debug
    3737
    38 static void initializeGStreamerDebug()
    39 {
     38static void initializeDebugCategory()
     39{
     40    ensureGStreamerInitialized();
     41
    4042    static std::once_flag debugRegisteredFlag;
    4143    std::call_once(debugRegisteredFlag, [] {
     
    122124    , m_capturer(makeUnique<GStreamerVideoCapturer>(source_factory))
    123125{
    124     initializeGStreamerDebug();
     126    initializeDebugCategory();
    125127}
    126128
     
    129131    , m_capturer(makeUnique<GStreamerVideoCapturer>(device))
    130132{
    131     initializeGStreamerDebug();
     133    initializeDebugCategory();
    132134}
    133135
  • trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeAudioSourceGStreamer.cpp

    r269849 r271396  
    6666    : MockRealtimeAudioSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
    6767{
     68    ensureGStreamerInitialized();
    6869}
    6970
  • trunk/Source/WebCore/platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp

    r269101 r271396  
    5757    : MockRealtimeVideoSource(WTFMove(deviceID), WTFMove(name), WTFMove(hashSalt))
    5858{
     59    ensureGStreamerInitialized();
    5960}
    6061
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp

    r270190 r271396  
    414414GStreamerVideoDecoderFactory::GStreamerVideoDecoderFactory()
    415415{
     416    ensureGStreamerInitialized();
     417
    416418    static std::once_flag debugRegisteredFlag;
    417 
    418419    std::call_once(debugRegisteredFlag, [] {
    419420        GST_DEBUG_CATEGORY_INIT(webkit_webrtcdec_debug, "webkitlibwebrtcvideodecoder", 0, "WebKit WebRTC video decoder");
  • trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp

    r270190 r271396  
    459459GStreamerVideoEncoderFactory::GStreamerVideoEncoderFactory()
    460460{
     461    ensureGStreamerInitialized();
     462
    461463    static std::once_flag debugRegisteredFlag;
    462 
    463464    std::call_once(debugRegisteredFlag, [] {
    464465        GST_DEBUG_CATEGORY_INIT(webkit_webrtcenc_debug, "webkitlibwebrtcvideoencoder", 0, "WebKit WebRTC video encoder");
  • trunk/Source/WebKit/ChangeLog

    r271391 r271396  
     12021-01-12  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer] Lazy initialization support
     4        https://bugs.webkit.org/show_bug.cgi?id=209332
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Introduce a GTK/WPE UserMediaCaptureManager that relays permission requests to the
     9        RealtimeMediaSourceCenter running in the WebProcess. We might move this to the GPUProcess at
     10        some point but for the time being we only want to avoid initializing GStreamer from the
     11        UIProcess.
     12
     13        * PlatformGTK.cmake:
     14        * PlatformWPE.cmake:
     15        * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
     16        * UIProcess/glib/UserMediaPermissionRequestManagerProxyGLib.cpp: Added.
     17        (WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionRequest):
     18        * WebProcess/glib/UserMediaCaptureManager.cpp: Added.
     19        (WebKit::UserMediaCaptureManager::UserMediaCaptureManager):
     20        (WebKit::UserMediaCaptureManager::~UserMediaCaptureManager):
     21        (WebKit::UserMediaCaptureManager::validateUserMediaRequestConstraints):
     22        * WebProcess/glib/UserMediaCaptureManager.h: Added.
     23        (WebKit::UserMediaCaptureManager::supplementName):
     24        * WebProcess/glib/UserMediaCaptureManager.messages.in: Added.
     25        * WebProcess/glib/WebProcessGLib.cpp:
     26        (WebKit::WebProcess::platformInitializeWebProcess):
     27
    1282021-01-12  Carlos Garcia Campos  <cgarcia@igalia.com>
    229
  • trunk/Source/WebKit/PlatformGTK.cmake

    r270178 r271396  
    429429    "${WEBKIT_DIR}/WebProcess/InjectedBundle/API/gtk/DOM"
    430430    "${WEBKIT_DIR}/WebProcess/Inspector/gtk"
     431    "${WEBKIT_DIR}/WebProcess/glib"
    431432    "${WEBKIT_DIR}/WebProcess/gtk"
    432433    "${WEBKIT_DIR}/WebProcess/soup"
     
    500501        "${THIRDPARTY_DIR}/libwebrtc/Source/"
    501502        "${THIRDPARTY_DIR}/libwebrtc/Source/webrtc"
     503    )
     504endif ()
     505
     506if (ENABLE_MEDIA_STREAM)
     507    list(APPEND WebKit_SOURCES
     508        UIProcess/glib/UserMediaPermissionRequestManagerProxyGLib.cpp
     509
     510        WebProcess/glib/UserMediaCaptureManager.cpp
     511    )
     512    list(APPEND WebKit_MESSAGES_IN_FILES
     513        WebProcess/glib/UserMediaCaptureManager
    502514    )
    503515endif ()
  • trunk/Source/WebKit/PlatformWPE.cmake

    r270880 r271396  
    266266    "${WEBKIT_DIR}/WebProcess/InjectedBundle/API/wpe"
    267267    "${WEBKIT_DIR}/WebProcess/InjectedBundle/API/wpe/DOM"
     268    "${WEBKIT_DIR}/WebProcess/glib"
    268269    "${WEBKIT_DIR}/WebProcess/soup"
    269270    "${WEBKIT_DIR}/WebProcess/WebCoreSupport/soup"
     
    320321    list(APPEND WebKit_LIBRARIES
    321322        ${GSTREAMER_LIBRARIES}
     323    )
     324endif ()
     325
     326if (ENABLE_MEDIA_STREAM)
     327    list(APPEND WebKit_SOURCES
     328        UIProcess/glib/UserMediaPermissionRequestManagerProxyGLib.cpp
     329
     330        WebProcess/glib/UserMediaCaptureManager.cpp
     331    )
     332    list(APPEND WebKit_MESSAGES_IN_FILES
     333        WebProcess/glib/UserMediaCaptureManager
    322334    )
    323335endif ()
  • trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp

    r271049 r271396  
    505505        syncWithWebCorePrefs();
    506506
    507         RealtimeMediaSourceCenter::singleton().validateRequestConstraints(WTFMove(validHandler), WTFMove(invalidHandler), m_currentUserMediaRequest->userRequest(), WTFMove(deviceIDHashSalt));
     507        platformValidateUserMediaRequestConstraints(WTFMove(validHandler), WTFMove(invalidHandler), WTFMove(deviceIDHashSalt));
    508508    });
    509509}
    510 #endif
    511 
    512 #if ENABLE(MEDIA_STREAM)
     510
     511#if ENABLE(MEDIA_STREAM) && !USE(GLIB)
     512void UserMediaPermissionRequestManagerProxy::platformValidateUserMediaRequestConstraints(WebCore::RealtimeMediaSourceCenter::ValidConstraintsHandler&& validHandler, RealtimeMediaSourceCenter::InvalidConstraintsHandler&& invalidHandler, String&& deviceIDHashSalt)
     513{
     514    RealtimeMediaSourceCenter::singleton().validateRequestConstraints(WTFMove(validHandler), WTFMove(invalidHandler), m_currentUserMediaRequest->userRequest(), WTFMove(deviceIDHashSalt));
     515}
     516#endif
     517
    513518void UserMediaPermissionRequestManagerProxy::processUserMediaPermissionInvalidRequest(const String& invalidConstraint)
    514519{
  • trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.h

    r271049 r271396  
    2323#include "UserMediaPermissionRequestProxy.h"
    2424#include <WebCore/MediaProducer.h>
     25#include <WebCore/RealtimeMediaSourceCenter.h>
    2526#include <WebCore/RealtimeMediaSourceFactory.h>
    2627#include <WebCore/SecurityOrigin.h>
     
    130131#endif
    131132
     133#if ENABLE(MEDIA_STREAM)
     134    void platformValidateUserMediaRequestConstraints(WebCore::RealtimeMediaSourceCenter::ValidConstraintsHandler&& validHandler, WebCore::RealtimeMediaSourceCenter::InvalidConstraintsHandler&& invalidHandler, String&& deviceIDHashSalt);
     135#endif
     136
    132137    void watchdogTimerFired();
    133138
  • trunk/Source/WebKit/WebProcess/glib/WebProcessGLib.cpp

    r260065 r271396  
    5151#endif
    5252
     53#if ENABLE(MEDIA_STREAM)
     54#include "UserMediaCaptureManager.h"
     55#endif
     56
    5357namespace WebKit {
    5458
     
    6266void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
    6367{
     68#if ENABLE(MEDIA_STREAM)
     69    addSupplement<UserMediaCaptureManager>();
     70#endif
     71
    6472#if PLATFORM(WPE)
    6573    if (!parameters.isServiceWorkerProcess) {
     
    92100
    93101#if USE(GSTREAMER)
    94     WebCore::initializeGStreamer(WTFMove(parameters.gstreamerOptions));
     102    WebCore::setGStreamerOptionsFromUIProcess(WTFMove(parameters.gstreamerOptions));
    95103#endif
    96104
Note: See TracChangeset for help on using the changeset viewer.