Changeset 252917 in webkit


Ignore:
Timestamp:
Nov 28, 2019 2:08:50 AM (4 years ago)
Author:
Philippe Normand
Message:

[GStreamer] Move GL video sink to its own GstBin sub-class
https://bugs.webkit.org/show_bug.cgi?id=204624

Reviewed by Xabier Rodriguez-Calvar.

Source/WebCore:

This reduces the MediaPlayerPrivate code-base and adds a good
separation of responsibility regarding GL video rendering. The
TextureCopier remains in the player because it's too specific.

  • platform/GStreamer.cmake:
  • platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp: Added.

(webkit_gl_video_sink_init):
(webKitGLVideoSinkFinalize):
(ensureGstGLContext):
(requestGLContext):
(webKitGLVideoSinkChangeState):
(webkit_gl_video_sink_class_init):
(webKitGLVideoSinkSetMediaPlayerPrivate):
(webKitGLVideoSinkProbePlatform):

  • platform/graphics/gstreamer/GLVideoSinkGStreamer.h: Added.
  • platform/graphics/gstreamer/GStreamerCommon.cpp:

(WebCore::initializeGStreamerAndRegisterWebKitElements):

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::MediaPlayerPrivateGStreamer::load):
(WebCore::MediaPlayerPrivateGStreamer::changePipelineState):
(WebCore::MediaPlayerPrivateGStreamer::handleSyncMessage):
(WebCore::MediaPlayerPrivateGStreamer::createVideoSinkGL):

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:

Tools:

  • Scripts/webkitpy/style/checker.py: White-list the new GLVideoSinkGStreamer GObject implementation.
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r252915 r252917  
     12019-11-28  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer] Move GL video sink to its own GstBin sub-class
     4        https://bugs.webkit.org/show_bug.cgi?id=204624
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        This reduces the MediaPlayerPrivate code-base and adds a good
     9        separation of responsibility regarding GL video rendering. The
     10        TextureCopier remains in the player because it's too specific.
     11
     12        * platform/GStreamer.cmake:
     13        * platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp: Added.
     14        (webkit_gl_video_sink_init):
     15        (webKitGLVideoSinkFinalize):
     16        (ensureGstGLContext):
     17        (requestGLContext):
     18        (webKitGLVideoSinkChangeState):
     19        (webkit_gl_video_sink_class_init):
     20        (webKitGLVideoSinkSetMediaPlayerPrivate):
     21        (webKitGLVideoSinkProbePlatform):
     22        * platform/graphics/gstreamer/GLVideoSinkGStreamer.h: Added.
     23        * platform/graphics/gstreamer/GStreamerCommon.cpp:
     24        (WebCore::initializeGStreamerAndRegisterWebKitElements):
     25        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     26        (WebCore::MediaPlayerPrivateGStreamer::load):
     27        (WebCore::MediaPlayerPrivateGStreamer::changePipelineState):
     28        (WebCore::MediaPlayerPrivateGStreamer::handleSyncMessage):
     29        (WebCore::MediaPlayerPrivateGStreamer::createVideoSinkGL):
     30        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
     31
    1322019-11-27  Zalan Bujtas  <zalan@apple.com>
    233
  • trunk/Source/WebCore/platform/GStreamer.cmake

    r252852 r252917  
    88    list(APPEND WebCore_SOURCES
    99        platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp
     10        platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp
    1011        platform/graphics/gstreamer/GRefPtrGStreamer.cpp
    1112        platform/graphics/gstreamer/GStreamerCommon.cpp
  • trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp

    r251365 r252917  
    4646}
    4747
     48
     49template <> GRefPtr<GstPlugin> adoptGRef(GstPlugin* ptr)
     50{
     51    ASSERT(!ptr || !g_object_is_floating(ptr));
     52    return GRefPtr<GstPlugin>(ptr, GRefPtrAdopt);
     53}
     54
     55template <> GstPlugin* refGPtr<GstPlugin>(GstPlugin* ptr)
     56{
     57    if (ptr)
     58        gst_object_ref_sink(GST_OBJECT(ptr));
     59
     60    return ptr;
     61}
     62
     63template <> void derefGPtr<GstPlugin>(GstPlugin* ptr)
     64{
     65    if (ptr)
     66        gst_object_unref(ptr);
     67}
     68
    4869template <> GRefPtr<GstPad> adoptGRef(GstPad* ptr)
    4970{
  • trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h

    r251365 r252917  
    3434
    3535namespace WTF {
     36
     37template<> GRefPtr<GstPlugin> adoptGRef(GstPlugin* ptr);
     38template<> GstPlugin* refGPtr<GstPlugin>(GstPlugin* ptr);
     39template<> void derefGPtr<GstPlugin>(GstPlugin* ptr);
    3640
    3741template<> GRefPtr<GstElement> adoptGRef(GstElement* ptr);
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp

    r249761 r252917  
    2424#if USE(GSTREAMER)
    2525
     26#include "GLVideoSinkGStreamer.h"
    2627#include "GstAllocatorFastMalloc.h"
    2728#include "IntSize.h"
     
    297298#if ENABLE(VIDEO)
    298299        gst_element_register(0, "webkitwebsrc", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_WEB_SRC);
     300#if USE(GSTREAMER_GL)
     301        gst_element_register(0, "webkitglvideosink", GST_RANK_PRIMARY, WEBKIT_TYPE_GL_VIDEO_SINK);
     302#endif
    299303#endif
    300304    });
     
    380384}
    381385
     386bool isGStreamerPluginAvailable(const char* name)
     387{
     388    GRefPtr<GstPlugin> plugin = adoptGRef(gst_registry_find_plugin(gst_registry_get(), name));
     389    if (!plugin)
     390        GST_WARNING("Plugin %s not found. Please check your GStreamer installation", name);
     391    return plugin;
     392}
     393
    382394}
    383395
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h

    r249568 r252917  
    222222enum class GstVideoDecoderPlatform { ImxVPU, Video4Linux };
    223223
     224bool isGStreamerPluginAvailable(const char* name);
     225
    224226}
    225227
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r252882 r252917  
    124124
    125125#if USE(GSTREAMER_GL)
     126#include "GLVideoSinkGStreamer.h"
     127#include "VideoTextureCopierGStreamer.h"
     128
    126129#define TEXTURE_COPIER_COLOR_CONVERT_FLAG VideoTextureCopierGStreamer::ColorConversion::NoConvert
    127 #define GST_GL_CAPS_FORMAT "{ RGBx, RGBA, I420, Y444, YV12, Y41B, Y42B, NV12, NV21, VUYA }"
    128 
    129 #include <gst/app/gstappsink.h>
    130 
    131 #include "GLContext.h"
    132 #if USE(GLX)
    133 #include "GLContextGLX.h"
    134 #include <gst/gl/x11/gstgldisplay_x11.h>
    135 #endif
    136 
    137 #if USE(EGL)
    138 #include "GLContextEGL.h"
    139 #include <gst/gl/egl/gstgldisplay_egl.h>
    140 #endif
    141 
    142 #if PLATFORM(X11)
    143 #include "PlatformDisplayX11.h"
    144 #endif
    145 
    146 #if PLATFORM(WAYLAND)
    147 #include "PlatformDisplayWayland.h"
    148 #endif
    149 
    150 #if USE(WPE_RENDERER)
    151 #include "PlatformDisplayLibWPE.h"
    152 #endif
    153 
    154 // gstglapi.h may include eglplatform.h and it includes X.h, which
    155 // defines None, breaking MediaPlayer::None enum
    156 #if PLATFORM(X11) && GST_GL_HAVE_PLATFORM_EGL
    157 #undef None
    158 #endif // PLATFORM(X11) && GST_GL_HAVE_PLATFORM_EGL
    159 #include "VideoTextureCopierGStreamer.h"
    160130#endif // USE(GSTREAMER_GL)
    161131
     
    460430    m_notifier->invalidate();
    461431
    462     if (m_videoSink) {
     432    if (m_videoSink)
    463433        g_signal_handlers_disconnect_matched(m_videoSink.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
    464 #if USE(GSTREAMER_GL)
    465         if (GST_IS_BIN(m_videoSink.get())) {
    466             GRefPtr<GstElement> appsink = adoptGRef(gst_bin_get_by_name(GST_BIN_CAST(m_videoSink.get()), "webkit-gl-video-sink"));
    467             g_signal_handlers_disconnect_by_data(appsink.get(), this);
    468         }
    469 #endif
    470     }
    471434
    472435    if (m_volumeElement)
     
    575538    syncOnClock(false);
    576539
    577 #if USE(GSTREAMER_GL)
    578     ensureGLVideoSinkContext();
    579 #endif
    580540    m_player->play();
    581541}
     
    11831143        gst_element_state_get_name(currentState), gst_element_state_get_name(pending));
    11841144
    1185 #if USE(GSTREAMER_GL)
    1186     if (currentState <= GST_STATE_READY && newState >= GST_STATE_PAUSED)
    1187         ensureGLVideoSinkContext();
    1188 #endif
    1189 
    11901145    GstStateChangeReturn setStateResult = gst_element_set_state(m_pipeline.get(), newState);
    11911146    GstState pausedOrPlaying = newState == GST_STATE_PLAYING ? GST_STATE_PAUSED : GST_STATE_PLAYING;
     
    17791734    }
    17801735
    1781 #if USE(GSTREAMER_GL)
    1782     GRefPtr<GstContext> elementContext = adoptGRef(requestGLContext(contextType));
    1783     if (elementContext) {
    1784         gst_element_set_context(GST_ELEMENT(message->src), elementContext.get());
    1785         return true;
    1786     }
    1787 #endif // USE(GSTREAMER_GL)
    1788 
    17891736#if ENABLE(ENCRYPTED_MEDIA)
    17901737    if (!g_strcmp0(contextType, "drm-preferred-decryption-system-id")) {
     
    18301777    }
    18311778#endif // ENABLE(ENCRYPTED_MEDIA)
     1779
     1780    GST_DEBUG_OBJECT(pipeline(), "Unhandled %s need-context message for %s", contextType, GST_MESSAGE_SRC_NAME(message));
    18321781    return false;
    18331782}
    1834 
    1835 #if USE(GSTREAMER_GL)
    1836 GstContext* MediaPlayerPrivateGStreamer::requestGLContext(const char* contextType)
    1837 {
    1838     if (!ensureGstGLContext())
    1839         return nullptr;
    1840 
    1841     if (!g_strcmp0(contextType, GST_GL_DISPLAY_CONTEXT_TYPE)) {
    1842         GstContext* displayContext = gst_context_new(GST_GL_DISPLAY_CONTEXT_TYPE, TRUE);
    1843         gst_context_set_gl_display(displayContext, gstGLDisplay());
    1844         return displayContext;
    1845     }
    1846 
    1847     if (!g_strcmp0(contextType, "gst.gl.app_context")) {
    1848         GstContext* appContext = gst_context_new("gst.gl.app_context", TRUE);
    1849         GstStructure* structure = gst_context_writable_structure(appContext);
    1850 #if GST_CHECK_VERSION(1, 12, 0)
    1851         gst_structure_set(structure, "context", GST_TYPE_GL_CONTEXT, gstGLContext(), nullptr);
    1852 #else
    1853         gst_structure_set(structure, "context", GST_GL_TYPE_CONTEXT, gstGLContext(), nullptr);
    1854 #endif
    1855         return appContext;
    1856     }
    1857 
    1858     return nullptr;
    1859 }
    1860 
    1861 bool MediaPlayerPrivateGStreamer::ensureGstGLContext()
    1862 {
    1863     if (m_glContext)
    1864         return true;
    1865 
    1866     auto& sharedDisplay = PlatformDisplay::sharedDisplayForCompositing();
    1867 
    1868     // The floating ref removal support was added in https://bugzilla.gnome.org/show_bug.cgi?id=743062.
    1869     bool shouldAdoptRef = webkitGstCheckVersion(1, 14, 0);
    1870     if (!m_glDisplay) {
    1871 #if PLATFORM(X11)
    1872 #if USE(GLX)
    1873         if (is<PlatformDisplayX11>(sharedDisplay)) {
    1874             GST_DEBUG_OBJECT(pipeline(), "Creating X11 shared GL display");
    1875             if (shouldAdoptRef)
    1876                 m_glDisplay = adoptGRef(GST_GL_DISPLAY(gst_gl_display_x11_new_with_display(downcast<PlatformDisplayX11>(sharedDisplay).native())));
    1877             else
    1878                 m_glDisplay = GST_GL_DISPLAY(gst_gl_display_x11_new_with_display(downcast<PlatformDisplayX11>(sharedDisplay).native()));
    1879         }
    1880 #elif USE(EGL)
    1881         if (is<PlatformDisplayX11>(sharedDisplay)) {
    1882             GST_DEBUG_OBJECT(pipeline(), "Creating X11 shared EGL display");
    1883             if (shouldAdoptRef)
    1884                 m_glDisplay = adoptGRef(GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(downcast<PlatformDisplayX11>(sharedDisplay).eglDisplay())));
    1885             else
    1886                 m_glDisplay = GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(downcast<PlatformDisplayX11>(sharedDisplay).eglDisplay()));
    1887         }
    1888 #endif
    1889 #endif
    1890 
    1891 #if PLATFORM(WAYLAND)
    1892         if (is<PlatformDisplayWayland>(sharedDisplay)) {
    1893             GST_DEBUG_OBJECT(pipeline(), "Creating Wayland shared display");
    1894             if (shouldAdoptRef)
    1895                 m_glDisplay = adoptGRef(GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(downcast<PlatformDisplayWayland>(sharedDisplay).eglDisplay())));
    1896             else
    1897                 m_glDisplay = GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(downcast<PlatformDisplayWayland>(sharedDisplay).eglDisplay()));
    1898         }
    1899 #endif
    1900 
    1901 #if USE(WPE_RENDERER)
    1902         if (is<PlatformDisplayLibWPE>(sharedDisplay)) {
    1903             GST_DEBUG_OBJECT(pipeline(), "Creating WPE shared EGL display");
    1904             if (shouldAdoptRef)
    1905                 m_glDisplay = adoptGRef(GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(downcast<PlatformDisplayLibWPE>(sharedDisplay).eglDisplay())));
    1906             else
    1907                 m_glDisplay = GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(downcast<PlatformDisplayLibWPE>(sharedDisplay).eglDisplay()));
    1908         }
    1909 #endif
    1910 
    1911         ASSERT(m_glDisplay);
    1912     }
    1913 
    1914     GLContext* webkitContext = sharedDisplay.sharingGLContext();
    1915     // EGL and GLX are mutually exclusive, no need for ifdefs here.
    1916     GstGLPlatform glPlatform = webkitContext->isEGLContext() ? GST_GL_PLATFORM_EGL : GST_GL_PLATFORM_GLX;
    1917 
    1918 #if USE(OPENGL_ES)
    1919     GstGLAPI glAPI = GST_GL_API_GLES2;
    1920 #elif USE(OPENGL)
    1921     GstGLAPI glAPI = GST_GL_API_OPENGL;
    1922 #else
    1923     ASSERT_NOT_REACHED();
    1924 #endif
    1925 
    1926     PlatformGraphicsContext3D contextHandle = webkitContext->platformContext();
    1927     if (!contextHandle)
    1928         return false;
    1929 
    1930     if (shouldAdoptRef)
    1931         m_glContext = adoptGRef(gst_gl_context_new_wrapped(m_glDisplay.get(), reinterpret_cast<guintptr>(contextHandle), glPlatform, glAPI));
    1932     else
    1933         m_glContext = gst_gl_context_new_wrapped(m_glDisplay.get(), reinterpret_cast<guintptr>(contextHandle), glPlatform, glAPI);
    1934 
    1935     // Activate and fill the GStreamer wrapped context with the Webkit's shared one.
    1936     auto previousActiveContext = GLContext::current();
    1937     webkitContext->makeContextCurrent();
    1938     if (gst_gl_context_activate(m_glContext.get(), TRUE)) {
    1939         GUniqueOutPtr<GError> error;
    1940         if (!gst_gl_context_fill_info(m_glContext.get(), &error.outPtr()))
    1941             GST_WARNING("Failed to fill in GStreamer context: %s", error->message);
    1942         gst_gl_context_activate(m_glContext.get(), FALSE);
    1943     } else
    1944         GST_WARNING("Failed to activate GStreamer context %" GST_PTR_FORMAT, m_glContext.get());
    1945     if (previousActiveContext)
    1946         previousActiveContext->makeContextCurrent();
    1947 
    1948     return true;
    1949 }
    1950 #endif // USE(GSTREAMER_GL)
    19511783
    19521784// Returns the size of the video
     
    33603192
    33613193#if USE(GSTREAMER_GL)
    3362 GstFlowReturn MediaPlayerPrivateGStreamer::newSampleCallback(GstElement* sink, MediaPlayerPrivateGStreamer* player)
    3363 {
    3364     GRefPtr<GstSample> sample = adoptGRef(gst_app_sink_pull_sample(GST_APP_SINK(sink)));
    3365     player->triggerRepaint(sample.get());
    3366     return GST_FLOW_OK;
    3367 }
    3368 
    3369 GstFlowReturn MediaPlayerPrivateGStreamer::newPrerollCallback(GstElement* sink, MediaPlayerPrivateGStreamer* player)
    3370 {
    3371     GRefPtr<GstSample> sample = adoptGRef(gst_app_sink_pull_preroll(GST_APP_SINK(sink)));
    3372     player->triggerRepaint(sample.get());
    3373     return GST_FLOW_OK;
    3374 }
    3375 
    33763194void MediaPlayerPrivateGStreamer::flushCurrentBuffer()
    33773195{
     
    35963414
    35973415#if USE(GSTREAMER_GL)
    3598 GstElement* MediaPlayerPrivateGStreamer::createGLAppSink()
    3599 {
    3600     GstElement* appsink = gst_element_factory_make("appsink", "webkit-gl-video-sink");
    3601     if (!appsink)
     3416GstElement* MediaPlayerPrivateGStreamer::createVideoSinkGL()
     3417{
     3418    if (!webKitGLVideoSinkProbePlatform()) {
     3419        g_warning("WebKit wasn't able to find the GL video sink dependencies. Hardware-accelerated zero-copy video rendering can't be enabled without this plugin.");
    36023420        return nullptr;
    3603 
    3604     g_object_set(appsink, "enable-last-sample", FALSE, "emit-signals", TRUE, "max-buffers", 1, nullptr);
    3605     g_signal_connect(appsink, "new-sample", G_CALLBACK(newSampleCallback), this);
    3606     g_signal_connect(appsink, "new-preroll", G_CALLBACK(newPrerollCallback), this);
    3607 
    3608     GRefPtr<GstPad> pad = adoptGRef(gst_element_get_static_pad(appsink, "sink"));
    3609     gst_pad_add_probe(pad.get(), static_cast<GstPadProbeType>(GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM | GST_PAD_PROBE_TYPE_EVENT_FLUSH), [] (GstPad*, GstPadProbeInfo* info,  gpointer userData) -> GstPadProbeReturn {
    3610         // In some platforms (e.g. OpenMAX on the Raspberry Pi) when a resolution change occurs the
    3611         // pipeline has to be drained before a frame with the new resolution can be decoded.
    3612         // In this context, it's important that we don't hold references to any previous frame
    3613         // (e.g. m_sample) so that decoding can continue.
    3614         // We are also not supposed to keep the original frame after a flush.
    3615         if (info->type & GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM) {
    3616             if (GST_QUERY_TYPE(GST_PAD_PROBE_INFO_QUERY(info)) != GST_QUERY_DRAIN)
    3617                 return GST_PAD_PROBE_OK;
    3618             GST_DEBUG("Acting upon DRAIN query");
    3619         }
    3620         if (info->type & GST_PAD_PROBE_TYPE_EVENT_FLUSH) {
    3621             if (GST_EVENT_TYPE(GST_PAD_PROBE_INFO_EVENT(info)) != GST_EVENT_FLUSH_START)
    3622                 return GST_PAD_PROBE_OK;
    3623             GST_DEBUG("Acting upon flush-start event");
    3624         }
    3625 
    3626         auto* player = static_cast<MediaPlayerPrivateGStreamer*>(userData);
    3627         player->flushCurrentBuffer();
    3628         return GST_PAD_PROBE_OK;
    3629     }, this, nullptr);
    3630 
    3631     return appsink;
    3632 }
    3633 
    3634 GstElement* MediaPlayerPrivateGStreamer::createVideoSinkGL()
    3635 {
    3636     gboolean result = TRUE;
    3637     GstElement* videoSink = gst_bin_new(nullptr);
    3638     GstElement* upload = gst_element_factory_make("glupload", nullptr);
    3639     GstElement* colorconvert = gst_element_factory_make("glcolorconvert", nullptr);
    3640     GstElement* appsink = createGLAppSink();
    3641 
    3642     // glsinkbin is not used because it includes glcolorconvert which only process RGBA,
    3643     // but we can display YUV formats too.
    3644 
    3645     if (!appsink || !upload || !colorconvert) {
    3646         GST_WARNING("Failed to create GstGL elements");
    3647         gst_object_unref(videoSink);
    3648 
    3649         if (upload)
    3650             gst_object_unref(upload);
    3651         if (colorconvert)
    3652             gst_object_unref(colorconvert);
    3653         if (appsink)
    3654             gst_object_unref(appsink);
    3655 
    3656         g_warning("WebKit wasn't able to find the GStreamer opengl plugin. Hardware-accelerated zero-copy video rendering can't be enabled without this plugin.");
    3657         return nullptr;
    3658     }
    3659 
    3660     gst_bin_add_many(GST_BIN(videoSink), upload, colorconvert, appsink, nullptr);
    3661 
    3662     // Workaround until we can depend on GStreamer 1.16.2.
    3663     // https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/commit/8d32de090554cf29fe359f83aa46000ba658a693
    3664     // Forcing a color conversion to RGBA here allows glupload to internally use
    3665     // an uploader that adds a VideoMeta, through the TextureUploadMeta caps
    3666     // feature, without needing the patch above. However this specific caps
    3667     // feature is going to be removed from GStreamer so it is considered a
    3668     // short-term workaround. This code path most likely will have a negative
    3669     // performance impact on embedded platforms as well. Downstream embedders
    3670     // are highly encouraged to cherry-pick the patch linked above in their BSP
    3671     // and set the WEBKIT_GST_NO_RGBA_CONVERSION environment variable until
    3672     // GStreamer 1.16.2 is released.
    3673     // See also https://bugs.webkit.org/show_bug.cgi?id=201422
    3674     GRefPtr<GstCaps> caps;
    3675     if (webkitGstCheckVersion(1, 16, 2) || getenv("WEBKIT_GST_NO_RGBA_CONVERSION"))
    3676         caps = adoptGRef(gst_caps_from_string("video/x-raw, format = (string) " GST_GL_CAPS_FORMAT));
    3677     else {
    3678         GST_INFO_OBJECT(pipeline(), "Forcing RGBA as GStreamer is not new enough.");
    3679         caps = adoptGRef(gst_caps_from_string("video/x-raw, format = (string) RGBA"));
    3680     }
    3681     gst_caps_set_features(caps.get(), 0, gst_caps_features_new(GST_CAPS_FEATURE_MEMORY_GL_MEMORY, nullptr));
    3682     g_object_set(appsink, "caps", caps.get(), nullptr);
    3683 
    3684     result &= gst_element_link_many(upload, colorconvert, appsink, nullptr);
    3685 
    3686     GRefPtr<GstPad> pad = adoptGRef(gst_element_get_static_pad(upload, "sink"));
    3687     gst_element_add_pad(videoSink, gst_ghost_pad_new("sink", pad.get()));
    3688 
    3689     if (!result) {
    3690         GST_WARNING("Failed to link GstGL elements");
    3691         gst_object_unref(videoSink);
    3692         videoSink = nullptr;
    3693     }
    3694     return videoSink;
    3695 }
    3696 
    3697 void MediaPlayerPrivateGStreamer::ensureGLVideoSinkContext()
    3698 {
    3699     if (!m_glDisplayElementContext)
    3700         m_glDisplayElementContext = adoptGRef(requestGLContext(GST_GL_DISPLAY_CONTEXT_TYPE));
    3701 
    3702     if (m_glDisplayElementContext)
    3703         gst_element_set_context(m_videoSink.get(), m_glDisplayElementContext.get());
    3704 
    3705     if (!m_glAppElementContext)
    3706         m_glAppElementContext = adoptGRef(requestGLContext("gst.gl.app_context"));
    3707 
    3708     if (m_glAppElementContext)
    3709         gst_element_set_context(m_videoSink.get(), m_glAppElementContext.get());
     3421    }
     3422
     3423    GstElement* sink = gst_element_factory_make("webkitglvideosink", nullptr);
     3424    ASSERT(sink);
     3425    webKitGLVideoSinkSetMediaPlayerPrivate(WEBKIT_GL_VIDEO_SINK(sink), this);
     3426    return sink;
    37103427}
    37113428#endif // USE(GSTREAMER_GL)
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h

    r252852 r252917  
    161161    float volume() const override;
    162162
    163 #if USE(GSTREAMER_GL)
    164     bool ensureGstGLContext();
    165     GstContext* requestGLContext(const char* contextType);
    166 #endif
    167163    void setMuted(bool) override;
    168164    bool muted() const;
     
    256252    void handleMessage(GstMessage*);
    257253
     254    void triggerRepaint(GstSample*);
     255#if USE(GSTREAMER_GL)
     256    void flushCurrentBuffer();
     257#endif
     258
    258259protected:
    259260    enum MainThreadNotification {
     
    286287
    287288#if USE(GSTREAMER_GL)
    288     static GstFlowReturn newSampleCallback(GstElement*, MediaPlayerPrivateGStreamer*);
    289     static GstFlowReturn newPrerollCallback(GstElement*, MediaPlayerPrivateGStreamer*);
    290     void flushCurrentBuffer();
    291     GstElement* createGLAppSink();
    292289    GstElement* createVideoSinkGL();
    293     GstGLContext* gstGLContext() const { return m_glContext.get(); }
    294     GstGLDisplay* gstGLDisplay() const { return m_glDisplay.get(); }
    295     void ensureGLVideoSinkContext();
    296290#endif
    297291
     
    312306    void setPipeline(GstElement*);
    313307
    314     void triggerRepaint(GstSample*);
    315308    void repaint();
    316309    void cancelRepaint(bool destroying = false);
     
    405398
    406399#if USE(GSTREAMER_GL)
    407     GRefPtr<GstGLContext> m_glContext;
    408     GRefPtr<GstGLDisplay> m_glDisplay;
    409     GRefPtr<GstContext> m_glDisplayElementContext;
    410     GRefPtr<GstContext> m_glAppElementContext;
    411400    std::unique_ptr<VideoTextureCopierGStreamer> m_videoTextureCopier;
    412 
    413401    GRefPtr<GstGLColorConvert> m_colorConvert;
    414402    GRefPtr<GstCaps> m_colorConvertInputCaps;
  • trunk/Tools/ChangeLog

    r252916 r252917  
     12019-11-28  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer] Move GL video sink to its own GstBin sub-class
     4        https://bugs.webkit.org/show_bug.cgi?id=204624
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        * Scripts/webkitpy/style/checker.py: White-list the new GLVideoSinkGStreamer GObject implementation.
     9
    1102019-11-27  Zalan Bujtas  <zalan@apple.com>
    211
  • trunk/Tools/Scripts/webkitpy/style/checker.py

    r252852 r252917  
    218218      # These files define GObjects, which implies some definitions of
    219219      # variables and functions containing underscores.
     220      os.path.join('Source', 'WebCore', 'platform', 'graphics', 'gstreamer', 'GLVideoSinkGStreamer.cpp'),
     221      os.path.join('Source', 'WebCore', 'platform', 'graphics', 'gstreamer', 'GLVideoSinkGStreamer.h'),
    220222      os.path.join('Source', 'WebCore', 'platform', 'graphics', 'gstreamer', 'VideoSinkGStreamer.cpp'),
    221223      os.path.join('Source', 'WebCore', 'platform', 'graphics', 'gstreamer', 'WebKitWebSourceGStreamer.cpp'),
Note: See TracChangeset for help on using the changeset viewer.