Changeset 181499 in webkit


Ignore:
Timestamp:
Mar 14, 2015 11:25:57 AM (9 years ago)
Author:
vjaquez@igalia.com
Message:

[GStreamer] share GL context in pipeline
https://bugs.webkit.org/show_bug.cgi?id=142693

Reviewed by Philippe Normand.

.:

Add search of gstreamer-gl library in the GStreamer installation. If
it is found, WTF_USE_GSTREAMER_GL macro is defined.

  • Source/cmake/FindGStreamer.cmake:
  • Source/cmake/OptionsGTK.cmake:

Source/WebCore:

GstGL elements in a pipeline need to be aware of the application's
display and its GL context. This information is shared through context
messages between the pipeline and the browser.

This patch shares this context through a GStreamer's synchronous
message, using the GL information held in the web process.

This patch is based on the work of Philippe Normand for Bug 138562.

No new tests because this is platform specific and it depends in the
run-time availability and configurations of GstGL elements.

  • PlatformGTK.cmake: appends the GstGL header files in the include

directories. Also its library directory is appended.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::mediaPlayerPrivateSyncMessageCallback): New callback function.
(WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer):
Initialize the new class attributes.
(WebCore::MediaPlayerPrivateGStreamer::handleSyncMessage): New method
for handling synchronous messages from the pipeline. This method
currently only handles the GL context sharing.
(WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): Configures
the pipeline's bus to handle the synchronous messages.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: Add new

class methods and attributes.

Source/WebKit2:

  • WebProcess/gtk/WebProcessMainGtk.cpp: Enable XInitThreads() if

GSTREAMER_GL is used, since GstGL elements use another thread for
queuing GL operations.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r181496 r181499  
     12015-03-14  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
     2
     3        [GStreamer] share GL context in pipeline
     4        https://bugs.webkit.org/show_bug.cgi?id=142693
     5
     6        Reviewed by Philippe Normand.
     7
     8        Add search of gstreamer-gl library in the GStreamer installation. If
     9        it is found, WTF_USE_GSTREAMER_GL macro is defined.
     10
     11        * Source/cmake/FindGStreamer.cmake:
     12        * Source/cmake/OptionsGTK.cmake:
     13
    1142015-03-13  Alex Christensen  <achristensen@webkit.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r181496 r181499  
     12015-03-14  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
     2
     3        [GStreamer] share GL context in pipeline
     4        https://bugs.webkit.org/show_bug.cgi?id=142693
     5
     6        Reviewed by Philippe Normand.
     7
     8        GstGL elements in a pipeline need to be aware of the application's
     9        display and its GL context. This information is shared through context
     10        messages between the pipeline and the browser.
     11
     12        This patch shares this context through a GStreamer's synchronous
     13        message, using the GL information held in the web process.
     14
     15        This patch is based on the work of Philippe Normand for Bug 138562.
     16
     17        No new tests because this is platform specific and it depends in the
     18        run-time availability and configurations of GstGL elements.
     19
     20        * PlatformGTK.cmake: appends the GstGL header files in the include
     21        directories. Also its library directory is appended.
     22        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     23        (WebCore::mediaPlayerPrivateSyncMessageCallback): New callback function.
     24        (WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer):
     25        Initialize the new class attributes.
     26        (WebCore::MediaPlayerPrivateGStreamer::handleSyncMessage): New method
     27        for handling synchronous messages from the pipeline. This method
     28        currently only handles the GL context sharing.
     29        (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): Configures
     30        the pipeline's bus to handle the synchronous messages.
     31        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: Add new
     32        class methods and attributes.
     33
    1342015-03-13  Alex Christensen  <achristensen@webkit.org>
    235
  • trunk/Source/WebCore/PlatformGTK.cmake

    r181468 r181499  
    344344        list(APPEND WebCore_LIBRARIES
    345345            ${GSTREAMER_MPEGTS_LIBRARIES}
     346        )
     347    endif ()
     348
     349    if (USE_GSTREAMER_GL)
     350        list(APPEND WebCore_INCLUDE_DIRECTORIES
     351            ${GSTREAMER_GL_INCLUDE_DIRS}
     352        )
     353
     354        list(APPEND WebCore_LIBRARIES
     355            ${GSTREAMER_GL_LIBRARIES}
    346356        )
    347357    endif ()
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r181274 r181499  
    6969#endif
    7070
     71#if USE(GSTREAMER_GL)
     72#include "GLContext.h"
     73
     74#define GST_USE_UNSTABLE_API
     75#include <gst/gl/gl.h>
     76#undef GST_USE_UNSTABLE_API
     77
     78#if USE(GLX)
     79#include "GLContextGLX.h"
     80#include <gst/gl/x11/gstgldisplay_x11.h>
     81#elif USE(EGL)
     82#include "GLContextEGL.h"
     83#include <gst/gl/egl/gstgldisplay_egl.h>
     84#endif
     85
     86// gstglapi.h may include eglplatform.h and it includes X.h, which
     87// defines None, breaking MediaPlayer::None enum
     88#if PLATFORM(X11) && GST_GL_HAVE_PLATFORM_EGL
     89#undef None
     90#endif
     91#endif // USE(GSTREAMER_GL)
     92
    7193// Max interval in seconds to stay in the READY state on manual
    7294// state change requests.
     
    83105{
    84106    return player->handleMessage(message);
     107}
     108
     109static gboolean mediaPlayerPrivateSyncMessageCallback(GstBus*, GstMessage* message, MediaPlayerPrivateGStreamer* player)
     110{
     111    return player->handleSyncMessage(message);
    85112}
    86113
     
    218245    , m_requestedState(GST_STATE_VOID_PENDING)
    219246    , m_missingPlugins(false)
     247#if USE(GSTREAMER_GL)
     248    , m_glContext(nullptr)
     249    , m_glDisplay(nullptr)
     250#endif
    220251{
    221252}
     
    903934
    904935    return timeRanges;
     936}
     937
     938gboolean MediaPlayerPrivateGStreamer::handleSyncMessage(GstMessage* message)
     939{
     940    switch (GST_MESSAGE_TYPE(message)) {
     941#if USE(GSTREAMER_GL)
     942    case GST_MESSAGE_NEED_CONTEXT: {
     943        const gchar* contextType;
     944        gst_message_parse_context_type(message, &contextType);
     945
     946        if (!m_glDisplay) {
     947#if PLATFORM(X11)
     948            Display* display = GLContext::sharedX11Display();
     949            GstGLDisplayX11* gstGLDisplay = gst_gl_display_x11_new_with_display(display);
     950#elif PLATFORM(WAYLAND)
     951            EGLDisplay display = WaylandDisplay::instance()->eglDisplay();
     952            GstGLDisplayEGL* gstGLDisplay = gst_gl_display_egl_new_with_egl_display(display);
     953#else
     954            return FALSE;
     955#endif
     956
     957            m_glDisplay = reinterpret_cast<GstGLDisplay*>(gstGLDisplay);
     958            GLContext* webkitContext = GLContext::sharingContext();
     959#if USE(GLX)
     960            GLXContext* glxSharingContext = reinterpret_cast<GLXContext*>(webkitContext->platformContext());
     961            if (glxSharingContext && !m_glContext)
     962                m_glContext = gst_gl_context_new_wrapped(GST_GL_DISPLAY(gstGLDisplay), reinterpret_cast<guintptr>(glxSharingContext), GST_GL_PLATFORM_GLX, GST_GL_API_OPENGL);
     963#elif USE(EGL)
     964            EGLContext* eglSharingContext = reinterpret_cast<EGLContext*>(webkitContext->platformContext());
     965            if (eglSharingContext && !m_glContext)
     966                m_glContext = gst_gl_context_new_wrapped(GST_GL_DISPLAY(gstGLDisplay), reinterpret_cast<guintptr>(eglSharingContext), GST_GL_PLATFORM_EGL, GST_GL_API_GLES2);
     967#endif
     968        }
     969
     970        if (!g_strcmp0(contextType, GST_GL_DISPLAY_CONTEXT_TYPE)) {
     971            GstContext* displayContext = gst_context_new(GST_GL_DISPLAY_CONTEXT_TYPE, TRUE);
     972            gst_context_set_gl_display(displayContext, m_glDisplay);
     973            gst_element_set_context(GST_ELEMENT(message->src), displayContext);
     974            return TRUE;
     975        }
     976        if (!g_strcmp0(contextType, "gst.gl.app_context")) {
     977            GstContext* appContext = gst_context_new("gst.gl.app_context", TRUE);
     978            GstStructure* structure = gst_context_writable_structure(appContext);
     979            gst_structure_set(structure, "context", GST_GL_TYPE_CONTEXT, m_glContext, nullptr);
     980            gst_element_set_context(GST_ELEMENT(message->src), appContext);
     981            return TRUE;
     982        }
     983        break;
     984    }
     985#endif // USE(GSTREAMER_GL)
     986    default:
     987        break;
     988    }
     989    return FALSE;
    905990}
    906991
     
    19362021    gst_bus_add_signal_watch(bus.get());
    19372022    g_signal_connect(bus.get(), "message", G_CALLBACK(mediaPlayerPrivateMessageCallback), this);
     2023    gst_bus_enable_sync_message_emission(bus.get());
     2024    g_signal_connect(bus.get(), "sync-message", G_CALLBACK(mediaPlayerPrivateSyncMessageCallback), this);
    19382025
    19392026    g_object_set(m_playBin.get(), "mute", m_player->muted(), NULL);
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h

    r181153 r181499  
    4848typedef struct _GstElement GstElement;
    4949typedef struct _GstMpegtsSection GstMpegtsSection;
     50typedef struct _GstGLContext GstGLContext;
     51typedef struct _GstGLDisplay GstGLDisplay;
    5052
    5153namespace WebCore {
     
    6769
    6870    static void registerMediaEngine(MediaEngineRegistrar);
     71    gboolean handleSyncMessage(GstMessage*);
    6972    gboolean handleMessage(GstMessage*);
    7073    void handlePluginInstallerResult(GstInstallPluginsReturn);
     
    252255    bool isMediaSource() const { return false; }
    253256#endif
     257#if USE(GSTREAMER_GL)
     258    GstGLContext* m_glContext;
     259    GstGLDisplay* m_glDisplay;
     260#endif
    254261};
    255262}
  • trunk/Source/WebKit2/ChangeLog

    r181496 r181499  
     12015-03-14  Víctor Manuel Jáquez Leal  <vjaquez@igalia.com>
     2
     3        [GStreamer] share GL context in pipeline
     4        https://bugs.webkit.org/show_bug.cgi?id=142693
     5
     6        Reviewed by Philippe Normand.
     7
     8        * WebProcess/gtk/WebProcessMainGtk.cpp: Enable XInitThreads() if
     9        GSTREAMER_GL is used, since GstGL elements use another thread for
     10        queuing GL operations.
     11
    1122015-03-13  Alex Christensen  <achristensen@webkit.org>
    213
  • trunk/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp

    r178095 r181499  
    5252#endif
    5353
    54 #if USE(COORDINATED_GRAPHICS_THREADED) && PLATFORM(X11)
     54#if (USE(COORDINATED_GRAPHICS_THREADED) || USE(GSTREAMER_GL)) && PLATFORM(X11)
    5555        XInitThreads();
    5656#endif
  • trunk/Source/cmake/FindGStreamer.cmake

    r176565 r181499  
    2020#  gstreamer-audio:      GSTREAMER_AUDIO_INCLUDE_DIRS and GSTREAMER_AUDIO_LIBRARIES
    2121#  gstreamer-fft:        GSTREAMER_FFT_INCLUDE_DIRS and GSTREAMER_FFT_LIBRARIES
     22#  gstreamer-gl:         GSTREAMER_GL_INCLUDE_DIRS and GSTREAMER_GL_LIBRARIES
    2223#  gstreamer-mpegts:     GSTREAMER_MPEGTS_INCLUDE_DIRS and GSTREAMER_MPEGTS_LIBRARIES
    2324#  gstreamer-pbutils:    GSTREAMER_PBUTILS_INCLUDE_DIRS and GSTREAMER_PBUTILS_LIBRARIES
     
    8586FIND_GSTREAMER_COMPONENT(GSTREAMER_AUDIO gstreamer-audio-1.0 gstaudio-1.0)
    8687FIND_GSTREAMER_COMPONENT(GSTREAMER_FFT gstreamer-fft-1.0 gstfft-1.0)
     88FIND_GSTREAMER_COMPONENT(GSTREAMER_GL gstreamer-gl-1.0>=1.5.0 gstgl-1.0)
    8789FIND_GSTREAMER_COMPONENT(GSTREAMER_MPEGTS gstreamer-mpegts-1.0>=1.4.0 gstmpegts-1.0)
    8890FIND_GSTREAMER_COMPONENT(GSTREAMER_PBUTILS gstreamer-pbutils-1.0 gstpbutils-1.0)
     
    115117    GSTREAMER_FFT_INCLUDE_DIRS
    116118    GSTREAMER_FFT_LIBRARIES
     119    GSTREAMER_GL_INCLUDE_DIRS
     120    GSTREAMER_GL_LIBRARIES
    117121    GSTREAMER_INCLUDE_DIRS
    118122    GSTREAMER_LIBRARIES
  • trunk/Source/cmake/OptionsGTK.cmake

    r181395 r181499  
    258258    add_definitions(-DWTF_USE_GSTREAMER)
    259259    if (ENABLE_VIDEO)
    260         list(APPEND GSTREAMER_COMPONENTS video mpegts tag)
     260        list(APPEND GSTREAMER_COMPONENTS video mpegts tag gl)
    261261    endif ()
    262262
     
    271271        add_definitions(-DWTF_USE_GSTREAMER_MPEGTS)
    272272        set(USE_GSTREAMER_MPEGTS TRUE)
     273    endif ()
     274
     275    if (PC_GSTREAMER_GL_FOUND)
     276        add_definitions(-DWTF_USE_GSTREAMER_GL)
     277        set(USE_GSTREAMER_GL TRUE)
    273278    endif ()
    274279endif ()
Note: See TracChangeset for help on using the changeset viewer.