<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[182227] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/182227">182227</a></dd>
<dt>Author</dt> <dd>philn@webkit.org</dd>
<dt>Date</dt> <dd>2015-04-01 03:19:03 -0700 (Wed, 01 Apr 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GStreamer] GstGL support in the video sink
https://bugs.webkit.org/show_bug.cgi?id=138562

Use GStreamer's glimagesink for video rendering instead of our
custom video sink if a recent-enough version of GstGL is found
during the build. When glimagesink is used it passes a texture to
the media player which then wraps it inside a TextureMapper
texture later used for actual rendering.

Using this new code path will allow us to remove our custom sink
entirely in the long term.

Patch by Philippe Normand &lt;philn@igalia.com&gt; on 2015-03-24
Reviewed by Carlos Garcia Campos.

No new test, existing media tests cover video rendering already.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::mediaPlayerPrivateDrawCallback): client-draw signal callback.
(WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
(WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
(WebCore::MediaPlayerPrivateGStreamerBase::naturalSize): Better
check for sample validity.
(WebCore::MediaPlayerPrivateGStreamerBase::updateTexture): Ditto.
(WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint): Trigger a
repaint and wait its completion.
(WebCore::MediaPlayerPrivateGStreamerBase::paintToTextureMapper):
Extract texture ID and video dimensions from the sample and do actual paint.
(WebCore::MediaPlayerPrivateGStreamerBase::createVideoSink): Use
glimagesink if GstGL is available.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamercpp">trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBasecpp">trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBaseh">trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (182226 => 182227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-04-01 09:36:15 UTC (rev 182226)
+++ trunk/Source/WebCore/ChangeLog        2015-04-01 10:19:03 UTC (rev 182227)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2015-03-24  Philippe Normand  &lt;philn@igalia.com&gt;
+
+        [GStreamer] GstGL support in the video sink
+        https://bugs.webkit.org/show_bug.cgi?id=138562
+
+        Use GStreamer's glimagesink for video rendering instead of our
+        custom video sink if a recent-enough version of GstGL is found
+        during the build. When glimagesink is used it passes a texture to
+        the media player which then wraps it inside a TextureMapper
+        texture later used for actual rendering.
+
+        Using this new code path will allow us to remove our custom sink
+        entirely in the long term.
+
+        Reviewed by Carlos Garcia Campos.
+
+        No new test, existing media tests cover video rendering already.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::mediaPlayerPrivateDrawCallback): client-draw signal callback.
+        (WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
+        (WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
+        (WebCore::MediaPlayerPrivateGStreamerBase::naturalSize): Better
+        check for sample validity.
+        (WebCore::MediaPlayerPrivateGStreamerBase::updateTexture): Ditto.
+        (WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint): Trigger a
+        repaint and wait its completion.
+        (WebCore::MediaPlayerPrivateGStreamerBase::paintToTextureMapper):
+        Extract texture ID and video dimensions from the sample and do actual paint.
+        (WebCore::MediaPlayerPrivateGStreamerBase::createVideoSink): Use
+        glimagesink if GstGL is available.
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
+
</ins><span class="cx"> 2015-04-01  Joonghun Park  &lt;jh718.park@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         nullptr cleanup in StyleResolver
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (182226 => 182227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp        2015-04-01 09:36:15 UTC (rev 182226)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp        2015-04-01 10:19:03 UTC (rev 182227)
</span><span class="lines">@@ -291,8 +291,8 @@
</span><span class="cx">         m_playBin.clear();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (m_webkitVideoSink) {
-        GRefPtr&lt;GstPad&gt; videoSinkPad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink.get(), &quot;sink&quot;));
</del><ins>+    if (m_videoSink) {
+        GRefPtr&lt;GstPad&gt; videoSinkPad = adoptGRef(gst_element_get_static_pad(m_videoSink.get(), &quot;sink&quot;));
</ins><span class="cx">         g_signal_handlers_disconnect_by_func(videoSinkPad.get(), reinterpret_cast&lt;gpointer&gt;(mediaPlayerPrivateVideoSinkCapsChangedCallback), this);
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -2076,7 +2076,7 @@
</span><span class="cx">             g_object_set(m_playBin.get(), &quot;audio-filter&quot;, scale, nullptr);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    GRefPtr&lt;GstPad&gt; videoSinkPad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink.get(), &quot;sink&quot;));
</del><ins>+    GRefPtr&lt;GstPad&gt; videoSinkPad = adoptGRef(gst_element_get_static_pad(m_videoSink.get(), &quot;sink&quot;));
</ins><span class="cx">     if (videoSinkPad)
</span><span class="cx">         g_signal_connect(videoSinkPad.get(), &quot;notify::caps&quot;, G_CALLBACK(mediaPlayerPrivateVideoSinkCapsChangedCallback), this);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (182226 => 182227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp        2015-04-01 09:36:15 UTC (rev 182226)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp        2015-04-01 10:19:03 UTC (rev 182227)
</span><span class="lines">@@ -44,6 +44,12 @@
</span><span class="cx"> #include &lt;gst/audio/streamvolume.h&gt;
</span><span class="cx"> #include &lt;gst/video/gstvideometa.h&gt;
</span><span class="cx"> 
</span><ins>+#if USE(GSTREAMER_GL)
+#define GST_USE_UNSTABLE_API
+#include &lt;gst/gl/gstglmemory.h&gt;
+#undef GST_USE_UNSTABLE_API
+#endif
+
</ins><span class="cx"> #if GST_CHECK_VERSION(1, 1, 0) &amp;&amp; USE(TEXTURE_MAPPER_GL)
</span><span class="cx"> #include &quot;BitmapTextureGL.h&quot;
</span><span class="cx"> #include &quot;BitmapTexturePool.h&quot;
</span><span class="lines">@@ -86,32 +92,40 @@
</span><span class="cx">     playerPrivate-&gt;triggerRepaint(sample);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if USE(GSTREAMER_GL)
+static gboolean mediaPlayerPrivateDrawCallback(GstElement*, GstContext*, GstSample* sample, MediaPlayerPrivateGStreamerBase* playerPrivate)
+{
+    playerPrivate-&gt;triggerRepaint(sample);
+    return TRUE;
+}
+#endif
+
</ins><span class="cx"> MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase(MediaPlayer* player)
</span><span class="cx">     : m_player(player)
</span><span class="cx">     , m_fpsSink(0)
</span><span class="cx">     , m_readyState(MediaPlayer::HaveNothing)
</span><span class="cx">     , m_networkState(MediaPlayer::Empty)
</span><del>-    , m_sample(0)
</del><span class="cx">     , m_repaintHandler(0)
</span><span class="cx">     , m_volumeSignalHandler(0)
</span><span class="cx">     , m_muteSignalHandler(0)
</span><ins>+    , m_usingFallbackVideoSink(false)
</ins><span class="cx"> {
</span><span class="cx">     g_mutex_init(&amp;m_sampleMutex);
</span><ins>+#if USE(GSTREAMER_GL)
+    g_cond_init(&amp;m_drawCondition);
+    g_mutex_init(&amp;m_drawMutex);
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase()
</span><span class="cx"> {
</span><span class="cx">     if (m_repaintHandler) {
</span><del>-        g_signal_handler_disconnect(m_webkitVideoSink.get(), m_repaintHandler);
</del><ins>+        g_signal_handler_disconnect(m_videoSink.get(), m_repaintHandler);
</ins><span class="cx">         m_repaintHandler = 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     g_mutex_clear(&amp;m_sampleMutex);
</span><span class="cx"> 
</span><del>-    if (m_sample)
-        gst_sample_unref(m_sample);
-    m_sample = 0;
-
</del><span class="cx">     m_player = 0;
</span><span class="cx"> 
</span><span class="cx">     if (m_volumeSignalHandler) {
</span><span class="lines">@@ -124,6 +138,11 @@
</span><span class="cx">         m_muteSignalHandler = 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+#if USE(GSTREAMER_GL)
+    g_cond_clear(&amp;m_drawCondition);
+    g_mutex_clear(&amp;m_drawMutex);
+#endif
+
</ins><span class="cx"> #if USE(TEXTURE_MAPPER_GL) &amp;&amp; !USE(COORDINATED_GRAPHICS)
</span><span class="cx">     if (client())
</span><span class="cx">         client()-&gt;platformLayerWillBeDestroyed();
</span><span class="lines">@@ -140,10 +159,10 @@
</span><span class="cx">         return m_videoSize;
</span><span class="cx"> 
</span><span class="cx">     WTF::GMutexLocker&lt;GMutex&gt; lock(m_sampleMutex);
</span><del>-    if (!m_sample)
</del><ins>+    if (!GST_IS_SAMPLE(m_sample.get()))
</ins><span class="cx">         return FloatSize();
</span><span class="cx"> 
</span><del>-    GstCaps* caps = gst_sample_get_caps(m_sample);
</del><ins>+    GstCaps* caps = gst_sample_get_caps(m_sample.get());
</ins><span class="cx">     if (!caps)
</span><span class="cx">         return FloatSize();
</span><span class="cx"> 
</span><span class="lines">@@ -282,10 +301,10 @@
</span><span class="cx"> PassRefPtr&lt;BitmapTexture&gt; MediaPlayerPrivateGStreamerBase::updateTexture(TextureMapper* textureMapper)
</span><span class="cx"> {
</span><span class="cx">     WTF::GMutexLocker&lt;GMutex&gt; lock(m_sampleMutex);
</span><del>-    if (!m_sample)
</del><ins>+    if (!GST_IS_SAMPLE(m_sample.get()))
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    GstCaps* caps = gst_sample_get_caps(m_sample);
</del><ins>+    GstCaps* caps = gst_sample_get_caps(m_sample.get());
</ins><span class="cx">     if (!caps)
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="lines">@@ -296,7 +315,7 @@
</span><span class="cx"> 
</span><span class="cx">     IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&amp;videoInfo), GST_VIDEO_INFO_HEIGHT(&amp;videoInfo));
</span><span class="cx">     RefPtr&lt;BitmapTexture&gt; texture = textureMapper-&gt;acquireTextureFromPool(size, GST_VIDEO_INFO_HAS_ALPHA(&amp;videoInfo) ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag);
</span><del>-    GstBuffer* buffer = gst_sample_get_buffer(m_sample);
</del><ins>+    GstBuffer* buffer = gst_sample_get_buffer(m_sample.get());
</ins><span class="cx"> 
</span><span class="cx"> #if GST_CHECK_VERSION(1, 1, 0)
</span><span class="cx">     GstVideoGLTextureUploadMeta* meta;
</span><span class="lines">@@ -329,16 +348,31 @@
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateGStreamerBase::triggerRepaint(GstSample* sample)
</span><span class="cx"> {
</span><del>-    g_return_if_fail(GST_IS_SAMPLE(sample));
-
</del><span class="cx">     {
</span><span class="cx">         WTF::GMutexLocker&lt;GMutex&gt; lock(m_sampleMutex);
</span><del>-        if (m_sample)
-            gst_sample_unref(m_sample);
-        m_sample = gst_sample_ref(sample);
</del><ins>+        m_sample = sample;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+#if USE(GSTREAMER_GL)
+    {
+        ASSERT(!isMainThread());
+
+        WTF::GMutexLocker&lt;GMutex&gt; lock(m_drawMutex);
+
+        m_drawTimerHandler.schedule(&quot;[WebKit] video render&quot;, [this] {
+            // Rendering should be done from the main thread
+            // because this is where the GL APIs were initialized.
+            WTF::GMutexLocker&lt;GMutex&gt; lock(m_drawMutex);
</ins><span class="cx"> #if USE(TEXTURE_MAPPER_GL) &amp;&amp; !USE(COORDINATED_GRAPHICS)
</span><ins>+            if (supportsAcceleratedRendering() &amp;&amp; m_player-&gt;client().mediaPlayerRenderingCanBeAccelerated(m_player) &amp;&amp; client())
+                client()-&gt;setPlatformLayerNeedsDisplay();
+            g_cond_signal(&amp;m_drawCondition);
+#endif
+        });
+        g_cond_wait(&amp;m_drawCondition, &amp;m_drawMutex);
+    }
+
+#elif USE(TEXTURE_MAPPER_GL) &amp;&amp; !USE(COORDINATED_GRAPHICS)
</ins><span class="cx">     if (supportsAcceleratedRendering() &amp;&amp; m_player-&gt;client().mediaPlayerRenderingCanBeAccelerated(m_player) &amp;&amp; client()) {
</span><span class="cx">         client()-&gt;setPlatformLayerNeedsDisplay();
</span><span class="cx">         return;
</span><span class="lines">@@ -367,10 +401,10 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     WTF::GMutexLocker&lt;GMutex&gt; lock(m_sampleMutex);
</span><del>-    if (!m_sample)
</del><ins>+    if (!GST_IS_SAMPLE(m_sample.get()))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    RefPtr&lt;ImageGStreamer&gt; gstImage = ImageGStreamer::createImage(m_sample);
</del><ins>+    RefPtr&lt;ImageGStreamer&gt; gstImage = ImageGStreamer::createImage(m_sample.get());
</ins><span class="cx">     if (!gstImage)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -387,9 +421,40 @@
</span><span class="cx">     if (!m_player-&gt;visible())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    RefPtr&lt;BitmapTexture&gt; texture = updateTexture(textureMapper);
-    if (texture)
-        textureMapper-&gt;drawTexture(*texture.get(), targetRect, matrix, opacity);
</del><ins>+    if (m_usingFallbackVideoSink) {
+        if (RefPtr&lt;BitmapTexture&gt; texture = updateTexture(textureMapper))
+            textureMapper-&gt;drawTexture(*texture.get(), targetRect, matrix, opacity);
+        return;
+    }
+
+#if USE(GSTREAMER_GL)
+    if (!GST_IS_SAMPLE(m_sample.get()))
+        return;
+
+    GstCaps* caps = gst_sample_get_caps(m_sample.get());
+    if (!caps)
+        return;
+
+    GstVideoInfo videoInfo;
+    gst_video_info_init(&amp;videoInfo);
+    if (!gst_video_info_from_caps(&amp;videoInfo, caps))
+        return;
+
+    GstBuffer* buffer = gst_sample_get_buffer(m_sample.get());
+    GstVideoFrame videoFrame;
+    if (!gst_video_frame_map(&amp;videoFrame, &amp;videoInfo, buffer, static_cast&lt;GstMapFlags&gt;(GST_MAP_READ | GST_MAP_GL)))
+        return;
+
+    unsigned textureID = *reinterpret_cast&lt;unsigned*&gt;(videoFrame.data[0]);
+    BitmapTexture::Flags flags = BitmapTexture::NoFlag;
+    if (GST_VIDEO_INFO_HAS_ALPHA(&amp;videoInfo))
+        flags |= BitmapTexture::SupportsAlpha;
+
+    IntSize size = IntSize(GST_VIDEO_INFO_WIDTH(&amp;videoInfo), GST_VIDEO_INFO_HEIGHT(&amp;videoInfo));
+    TextureMapperGL* textureMapperGL = reinterpret_cast&lt;TextureMapperGL*&gt;(textureMapper);
+    textureMapperGL-&gt;drawTexture(textureID, flags, size, targetRect, matrix, opacity);
+    gst_video_frame_unmap(&amp;videoFrame);
+#endif
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -416,12 +481,22 @@
</span><span class="cx"> 
</span><span class="cx"> GstElement* MediaPlayerPrivateGStreamerBase::createVideoSink()
</span><span class="cx"> {
</span><del>-    ASSERT(initializeGStreamer());
-
</del><span class="cx">     GstElement* videoSink = nullptr;
</span><del>-    m_webkitVideoSink = webkitVideoSinkNew();
</del><ins>+#if USE(GSTREAMER_GL)
+    if (webkitGstCheckVersion(1, 5, 0)) {
+        m_videoSink = gst_element_factory_make(&quot;glimagesink&quot;, nullptr);
+        if (m_videoSink) {
+            m_repaintHandler = g_signal_connect(m_videoSink.get(), &quot;client-draw&quot;, G_CALLBACK(mediaPlayerPrivateDrawCallback), this);
+            videoSink = m_videoSink.get();
+        }
+    }
+#endif
</ins><span class="cx"> 
</span><del>-    m_repaintHandler = g_signal_connect(m_webkitVideoSink.get(), &quot;repaint-requested&quot;, G_CALLBACK(mediaPlayerPrivateRepaintCallback), this);
</del><ins>+    if (!m_videoSink) {
+        m_usingFallbackVideoSink = true;
+        m_videoSink = webkitVideoSinkNew();
+        m_repaintHandler = g_signal_connect(m_videoSink.get(), &quot;repaint-requested&quot;, G_CALLBACK(mediaPlayerPrivateRepaintCallback), this);
+    }
</ins><span class="cx"> 
</span><span class="cx">     m_fpsSink = gst_element_factory_make(&quot;fpsdisplaysink&quot;, &quot;sink&quot;);
</span><span class="cx">     if (m_fpsSink) {
</span><span class="lines">@@ -436,14 +511,14 @@
</span><span class="cx"> #endif // LOG_DISABLED
</span><span class="cx"> 
</span><span class="cx">         if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_fpsSink.get()), &quot;video-sink&quot;)) {
</span><del>-            g_object_set(m_fpsSink.get(), &quot;video-sink&quot;, m_webkitVideoSink.get(), nullptr);
</del><ins>+            g_object_set(m_fpsSink.get(), &quot;video-sink&quot;, m_videoSink.get(), nullptr);
</ins><span class="cx">             videoSink = m_fpsSink.get();
</span><span class="cx">         } else
</span><span class="cx">             m_fpsSink = nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!m_fpsSink)
</span><del>-        videoSink = m_webkitVideoSink.get();
</del><ins>+        videoSink = m_videoSink.get();
</ins><span class="cx"> 
</span><span class="cx">     ASSERT(videoSink);
</span><span class="cx"> 
</span><span class="lines">@@ -503,7 +578,7 @@
</span><span class="cx">     GstQuery* query = gst_query_new_position(GST_FORMAT_BYTES);
</span><span class="cx">     gint64 position = 0;
</span><span class="cx"> 
</span><del>-    if (gst_element_query(m_webkitVideoSink.get(), query))
</del><ins>+    if (gst_element_query(m_videoSink.get(), query))
</ins><span class="cx">         gst_query_parse_position(query, 0, &amp;position);
</span><span class="cx"> 
</span><span class="cx">     gst_query_unref(query);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h (182226 => 182227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h        2015-04-01 09:36:15 UTC (rev 182226)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h        2015-04-01 10:19:03 UTC (rev 182227)
</span><span class="lines">@@ -36,11 +36,8 @@
</span><span class="cx"> #include &quot;TextureMapperPlatformLayer.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-typedef struct _GstSample GstSample;
-typedef struct _GstElement GstElement;
</del><span class="cx"> typedef struct _GstMessage GstMessage;
</span><span class="cx"> typedef struct _GstStreamVolume GstStreamVolume;
</span><del>-typedef struct _WebKitVideoSink WebKitVideoSink;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -117,19 +114,25 @@
</span><span class="cx"> 
</span><span class="cx">     MediaPlayer* m_player;
</span><span class="cx">     GRefPtr&lt;GstStreamVolume&gt; m_volumeElement;
</span><del>-    GRefPtr&lt;GstElement&gt; m_webkitVideoSink;
</del><ins>+    GRefPtr&lt;GstElement&gt; m_videoSink;
</ins><span class="cx">     GRefPtr&lt;GstElement&gt; m_fpsSink;
</span><span class="cx">     MediaPlayer::ReadyState m_readyState;
</span><span class="cx">     MediaPlayer::NetworkState m_networkState;
</span><span class="cx">     IntSize m_size;
</span><span class="cx">     mutable GMutex m_sampleMutex;
</span><del>-    GstSample* m_sample;
</del><ins>+    GRefPtr&lt;GstSample&gt; m_sample;
</ins><span class="cx">     GThreadSafeMainLoopSource m_volumeTimerHandler;
</span><span class="cx">     GThreadSafeMainLoopSource m_muteTimerHandler;
</span><ins>+#if USE(GSTREAMER_GL)
+    GThreadSafeMainLoopSource m_drawTimerHandler;
+    GCond m_drawCondition;
+    GMutex m_drawMutex;
+#endif
</ins><span class="cx">     unsigned long m_repaintHandler;
</span><span class="cx">     unsigned long m_volumeSignalHandler;
</span><span class="cx">     unsigned long m_muteSignalHandler;
</span><span class="cx">     mutable FloatSize m_videoSize;
</span><ins>+    bool m_usingFallbackVideoSink;
</ins><span class="cx"> #if USE(TEXTURE_MAPPER_GL) &amp;&amp; !USE(COORDINATED_GRAPHICS)
</span><span class="cx">     PassRefPtr&lt;BitmapTexture&gt; updateTexture(TextureMapper*);
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>