Modified: trunk/ChangeLog (182055 => 182056)
--- trunk/ChangeLog 2015-03-27 07:26:35 UTC (rev 182055)
+++ trunk/ChangeLog 2015-03-27 10:31:00 UTC (rev 182056)
@@ -1,3 +1,13 @@
+2015-03-27 Víctor Manuel Jáquez Leal <[email protected]>
+
+ [GStreamer] share GL context in pipeline, part 2
+ https://bugs.webkit.org/show_bug.cgi?id=143049
+
+ Reviewed by Carlos Garcia Campos.
+
+ * Source/cmake/OptionsGTK.cmake: USE_GSTREAMER_GL is set only if
+ OpenGL/ES2 is found and GLX/EGL is found too.
+
2015-03-26 Alex Christensen <[email protected]>
Progress towards CMake on Mac.
Modified: trunk/Source/WebCore/ChangeLog (182055 => 182056)
--- trunk/Source/WebCore/ChangeLog 2015-03-27 07:26:35 UTC (rev 182055)
+++ trunk/Source/WebCore/ChangeLog 2015-03-27 10:31:00 UTC (rev 182056)
@@ -1,3 +1,34 @@
+2015-03-27 Víctor Manuel Jáquez Leal <[email protected]>
+
+ [GStreamer] share GL context in pipeline, part 2
+ https://bugs.webkit.org/show_bug.cgi?id=143049
+
+ Reviewed by Carlos Garcia Campos.
+
+ This patch, instead of cluttering the GstGL attributes creation in
+ ::handleSyncMessage(), creates a new method ::ensureGstGLContext(),
+ where those attributes are defined. This method is guarded by
+ USE(GSTREAMER_GL)
+
+ ::handlSyncMessage() shall return nothing, according to GStreamer
+ documentation, not a boolean.
+
+ The GstGL attributes are now GRefPtr<> to avoid memory leaks.
+
+ The GstGLAPI and GstGLPlatform are now set given by the pre-processor
+ directives, and the code in ::ensureGstGLContext() is simpler.
+
+ No new tests because this is platform specific and it depends in the
+ run-time availability and configurations of GstGL elements.
+
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+ (WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer):
+ Don't initialise the GstGL attributes since are GRefPtr<>
+ (WebCore::MediaPlayerPrivateGStreamer::handleSyncMessage): Changed the
+ signature to use void instead of gboolean.
+ (WebCore::MediaPlayerPrivateGStreamer::ensureGstGLContext): New method.
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+
2015-03-26 Jeremy Jones <[email protected]>
Optimized Fullscreen fails to cleanup because of no longer necessary release of m_playerController in exitFullscreen()
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (182055 => 182056)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2015-03-27 07:26:35 UTC (rev 182055)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2015-03-27 10:31:00 UTC (rev 182056)
@@ -106,9 +106,9 @@
return player->handleMessage(message);
}
-static gboolean mediaPlayerPrivateSyncMessageCallback(GstBus*, GstMessage* message, MediaPlayerPrivateGStreamer* player)
+static void mediaPlayerPrivateSyncMessageCallback(GstBus*, GstMessage* message, MediaPlayerPrivateGStreamer* player)
{
- return player->handleSyncMessage(message);
+ player->handleSyncMessage(message);
}
static void mediaPlayerPrivateSourceChangedCallback(GObject*, GParamSpec*, MediaPlayerPrivateGStreamer* player)
@@ -244,10 +244,6 @@
#endif
, m_requestedState(GST_STATE_VOID_PENDING)
, m_missingPlugins(false)
-#if USE(GSTREAMER_GL)
- , m_glContext(nullptr)
- , m_glDisplay(nullptr)
-#endif
{
}
@@ -935,7 +931,7 @@
return timeRanges;
}
-gboolean MediaPlayerPrivateGStreamer::handleSyncMessage(GstMessage* message)
+void MediaPlayerPrivateGStreamer::handleSyncMessage(GstMessage* message)
{
switch (GST_MESSAGE_TYPE(message)) {
#if USE(GSTREAMER_GL)
@@ -943,42 +939,22 @@
const gchar* contextType;
gst_message_parse_context_type(message, &contextType);
- if (!m_glDisplay) {
-#if PLATFORM(X11)
- Display* display = GLContext::sharedX11Display();
- GstGLDisplayX11* gstGLDisplay = gst_gl_display_x11_new_with_display(display);
-#elif PLATFORM(WAYLAND)
- EGLDisplay display = WaylandDisplay::instance()->eglDisplay();
- GstGLDisplayEGL* gstGLDisplay = gst_gl_display_egl_new_with_egl_display(display);
-#else
- return FALSE;
-#endif
+ if (!ensureGstGLContext())
+ return;
- m_glDisplay = reinterpret_cast<GstGLDisplay*>(gstGLDisplay);
- GLContext* webkitContext = GLContext::sharingContext();
-#if USE(GLX)
- GLXContext* glxSharingContext = reinterpret_cast<GLXContext*>(webkitContext->platformContext());
- if (glxSharingContext && !m_glContext)
- m_glContext = gst_gl_context_new_wrapped(GST_GL_DISPLAY(gstGLDisplay), reinterpret_cast<guintptr>(glxSharingContext), GST_GL_PLATFORM_GLX, GST_GL_API_OPENGL);
-#elif USE(EGL)
- EGLContext* eglSharingContext = reinterpret_cast<EGLContext*>(webkitContext->platformContext());
- if (eglSharingContext && !m_glContext)
- m_glContext = gst_gl_context_new_wrapped(GST_GL_DISPLAY(gstGLDisplay), reinterpret_cast<guintptr>(eglSharingContext), GST_GL_PLATFORM_EGL, GST_GL_API_GLES2);
-#endif
- }
-
if (!g_strcmp0(contextType, GST_GL_DISPLAY_CONTEXT_TYPE)) {
GstContext* displayContext = gst_context_new(GST_GL_DISPLAY_CONTEXT_TYPE, TRUE);
- gst_context_set_gl_display(displayContext, m_glDisplay);
+ gst_context_set_gl_display(displayContext, m_glDisplay.get());
gst_element_set_context(GST_ELEMENT(message->src), displayContext);
- return TRUE;
+ return;
}
+
if (!g_strcmp0(contextType, "gst.gl.app_context")) {
GstContext* appContext = gst_context_new("gst.gl.app_context", TRUE);
GstStructure* structure = gst_context_writable_structure(appContext);
- gst_structure_set(structure, "context", GST_GL_TYPE_CONTEXT, m_glContext, nullptr);
+ gst_structure_set(structure, "context", GST_GL_TYPE_CONTEXT, m_glContext.get(), nullptr);
gst_element_set_context(GST_ELEMENT(message->src), appContext);
- return TRUE;
+ return;
}
break;
}
@@ -986,9 +962,43 @@
default:
break;
}
- return FALSE;
}
+#if USE(GSTREAMER_GL)
+bool MediaPlayerPrivateGStreamer::ensureGstGLContext()
+{
+ if (m_glContext)
+ return true;
+
+ if (!m_glDisplay) {
+#if PLATFORM(X11)
+ Display* display = GLContext::sharedX11Display();
+ m_glDisplay = GST_GL_DISPLAY(gst_gl_display_x11_new_with_display(display));
+#elif PLATFORM(WAYLAND)
+ EGLDisplay display = WaylandDisplay::instance()->eglDisplay();
+ m_glDisplay = GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(display));
+#endif
+ }
+
+ PlatformGraphicsContext3D contextHandle = GLContext::sharingContext()->platformContext();
+ if (!contextHandle)
+ return false;
+#if USE(EGL)
+ GstGLPlatform glPlatform = GST_GL_PLATFORM_EGL;
+#else
+ GstGLPlatform glPlatform = GST_GL_PLATFORM_GLX;
+#endif
+#if USE(GLES2)
+ GstGLAPI glAPI = GST_GL_API_GLES2;
+#else
+ GstGLAPI glAPI = GST_GL_API_OPENGL;
+#endif
+ m_glContext = gst_gl_context_new_wrapped(m_glDisplay.get(), reinterpret_cast<guintptr>(contextHandle), glPlatform, glAPI);
+
+ return true;
+}
+#endif // USE(GSTREAMER_GL)
+
gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
{
GUniqueOutPtr<GError> err;
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h (182055 => 182056)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h 2015-03-27 07:26:35 UTC (rev 182055)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h 2015-03-27 10:31:00 UTC (rev 182056)
@@ -68,7 +68,7 @@
~MediaPlayerPrivateGStreamer();
static void registerMediaEngine(MediaEngineRegistrar);
- gboolean handleSyncMessage(GstMessage*);
+ void handleSyncMessage(GstMessage*);
gboolean handleMessage(GstMessage*);
void handlePluginInstallerResult(GstInstallPluginsReturn);
@@ -159,6 +159,10 @@
void createGSTPlayBin();
+#if USE(GSTREAMER_GL)
+ bool ensureGstGLContext();
+#endif
+
bool loadNextLocation();
void mediaLocationChanged(GstMessage*);
@@ -255,8 +259,8 @@
bool isMediaSource() const { return false; }
#endif
#if USE(GSTREAMER_GL)
- GstGLContext* m_glContext;
- GstGLDisplay* m_glDisplay;
+ GRefPtr<GstGLContext> m_glContext;
+ GRefPtr<GstGLDisplay> m_glDisplay;
#endif
};
}
Modified: trunk/Source/cmake/OptionsGTK.cmake (182055 => 182056)
--- trunk/Source/cmake/OptionsGTK.cmake 2015-03-27 07:26:35 UTC (rev 182055)
+++ trunk/Source/cmake/OptionsGTK.cmake 2015-03-27 10:31:00 UTC (rev 182056)
@@ -282,11 +282,6 @@
add_definitions(-DWTF_USE_GSTREAMER_MPEGTS)
set(USE_GSTREAMER_MPEGTS TRUE)
endif ()
-
- if (PC_GSTREAMER_GL_FOUND)
- add_definitions(-DWTF_USE_GSTREAMER_GL)
- set(USE_GSTREAMER_GL TRUE)
- endif ()
endif ()
if (ENABLE_WAYLAND_TARGET)
@@ -393,6 +388,11 @@
add_definitions(-DWTF_USE_COORDINATED_GRAPHICS=1)
add_definitions(-DWTF_USE_COORDINATED_GRAPHICS_THREADED=1)
endif ()
+
+ if (PC_GSTREAMER_GL_FOUND)
+ add_definitions(-DWTF_USE_GSTREAMER_GL)
+ set(USE_GSTREAMER_GL TRUE)
+ endif ()
endif ()
if (ENABLE_GAMEPAD_DEPRECATED)