<!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>[182229] 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/182229">182229</a></dd>
<dt>Author</dt> <dd>philn@webkit.org</dd>
<dt>Date</dt> <dd>2015-04-01 03:46:19 -0700 (Wed, 01 Apr 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GStreamer] Move synchronous message handler to MediaPlayerPrivateGStreamerBase
https://bugs.webkit.org/show_bug.cgi?id=143218

Reviewed by Carlos Garcia Campos.

Moved the pipeline pointer to the base class, sub-classes should
now invoke setPipeline() when loading a resource. The base class
now takes care of configuring the GL shared context, this is more
logical because video rendering is also managed by this class.

No new tests, this is only a code refactoring.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
(WebCore::MediaPlayerPrivateGStreamer::load):
(WebCore::MediaPlayerPrivateGStreamer::playbackPosition):
(WebCore::MediaPlayerPrivateGStreamer::changePipelineState):
(WebCore::MediaPlayerPrivateGStreamer::pause):
(WebCore::MediaPlayerPrivateGStreamer::duration):
(WebCore::MediaPlayerPrivateGStreamer::currentTime):
(WebCore::MediaPlayerPrivateGStreamer::seek):
(WebCore::MediaPlayerPrivateGStreamer::doSeek):
(WebCore::MediaPlayerPrivateGStreamer::updatePlaybackRate):
(WebCore::MediaPlayerPrivateGStreamer::paused):
(WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfVideo):
(WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfAudio):
(WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfText):
(WebCore::MediaPlayerPrivateGStreamer::setRate):
(WebCore::MediaPlayerPrivateGStreamer::buffered):
(WebCore::MediaPlayerPrivateGStreamer::handleMessage):
(WebCore::MediaPlayerPrivateGStreamer::fillTimerFired):
(WebCore::MediaPlayerPrivateGStreamer::didLoadingProgress):
(WebCore::MediaPlayerPrivateGStreamer::sourceChanged):
(WebCore::MediaPlayerPrivateGStreamer::cancelLoad):
(WebCore::MediaPlayerPrivateGStreamer::asyncStateChangeDone):
(WebCore::MediaPlayerPrivateGStreamer::updateStates):
(WebCore::MediaPlayerPrivateGStreamer::loadNextLocation):
(WebCore::MediaPlayerPrivateGStreamer::cacheDuration):
(WebCore::MediaPlayerPrivateGStreamer::setDownloadBuffering):
(WebCore::MediaPlayerPrivateGStreamer::audioSink):
(WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
(WebCore::MediaPlayerPrivateGStreamer::simulateAudioInterruption):
(WebCore::mediaPlayerPrivateSyncMessageCallback): Deleted.
(WebCore::MediaPlayerPrivateGStreamer::handleSyncMessage): Deleted.
(WebCore::MediaPlayerPrivateGStreamer::ensureGstGLContext): Deleted.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::mediaPlayerPrivateNeedContextMessageCallback):
(WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
(WebCore::MediaPlayerPrivateGStreamerBase::setPipeline):
(WebCore::MediaPlayerPrivateGStreamerBase::handleNeedContextMessage):
(WebCore::MediaPlayerPrivateGStreamerBase::ensureGstGLContext):
* 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="#trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerh">trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h</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 (182228 => 182229)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-04-01 10:38:06 UTC (rev 182228)
+++ trunk/Source/WebCore/ChangeLog        2015-04-01 10:46:19 UTC (rev 182229)
</span><span class="lines">@@ -1,3 +1,59 @@
</span><ins>+2015-03-30  Philippe Normand  &lt;pnormand@igalia.com&gt;
+
+        [GStreamer] Move synchronous message handler to MediaPlayerPrivateGStreamerBase
+        https://bugs.webkit.org/show_bug.cgi?id=143218
+
+        Reviewed by Carlos Garcia Campos.
+
+        Moved the pipeline pointer to the base class, sub-classes should
+        now invoke setPipeline() when loading a resource. The base class
+        now takes care of configuring the GL shared context, this is more
+        logical because video rendering is also managed by this class.
+
+        No new tests, this is only a code refactoring.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
+        (WebCore::MediaPlayerPrivateGStreamer::load):
+        (WebCore::MediaPlayerPrivateGStreamer::playbackPosition):
+        (WebCore::MediaPlayerPrivateGStreamer::changePipelineState):
+        (WebCore::MediaPlayerPrivateGStreamer::pause):
+        (WebCore::MediaPlayerPrivateGStreamer::duration):
+        (WebCore::MediaPlayerPrivateGStreamer::currentTime):
+        (WebCore::MediaPlayerPrivateGStreamer::seek):
+        (WebCore::MediaPlayerPrivateGStreamer::doSeek):
+        (WebCore::MediaPlayerPrivateGStreamer::updatePlaybackRate):
+        (WebCore::MediaPlayerPrivateGStreamer::paused):
+        (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfVideo):
+        (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfAudio):
+        (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfText):
+        (WebCore::MediaPlayerPrivateGStreamer::setRate):
+        (WebCore::MediaPlayerPrivateGStreamer::buffered):
+        (WebCore::MediaPlayerPrivateGStreamer::handleMessage):
+        (WebCore::MediaPlayerPrivateGStreamer::fillTimerFired):
+        (WebCore::MediaPlayerPrivateGStreamer::didLoadingProgress):
+        (WebCore::MediaPlayerPrivateGStreamer::sourceChanged):
+        (WebCore::MediaPlayerPrivateGStreamer::cancelLoad):
+        (WebCore::MediaPlayerPrivateGStreamer::asyncStateChangeDone):
+        (WebCore::MediaPlayerPrivateGStreamer::updateStates):
+        (WebCore::MediaPlayerPrivateGStreamer::loadNextLocation):
+        (WebCore::MediaPlayerPrivateGStreamer::cacheDuration):
+        (WebCore::MediaPlayerPrivateGStreamer::setDownloadBuffering):
+        (WebCore::MediaPlayerPrivateGStreamer::audioSink):
+        (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
+        (WebCore::MediaPlayerPrivateGStreamer::simulateAudioInterruption):
+        (WebCore::mediaPlayerPrivateSyncMessageCallback): Deleted.
+        (WebCore::MediaPlayerPrivateGStreamer::handleSyncMessage): Deleted.
+        (WebCore::MediaPlayerPrivateGStreamer::ensureGstGLContext): Deleted.
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::mediaPlayerPrivateNeedContextMessageCallback):
+        (WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
+        (WebCore::MediaPlayerPrivateGStreamerBase::setPipeline):
+        (WebCore::MediaPlayerPrivateGStreamerBase::handleNeedContextMessage):
+        (WebCore::MediaPlayerPrivateGStreamerBase::ensureGstGLContext):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
+
</ins><span class="cx"> 2015-03-24  Philippe Normand  &lt;philn@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GStreamer] GstGL support in the video sink
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (182228 => 182229)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp        2015-04-01 10:38:06 UTC (rev 182228)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp        2015-04-01 10:46:19 UTC (rev 182229)
</span><span class="lines">@@ -68,28 +68,6 @@
</span><span class="cx"> #include &quot;AudioSourceProviderGStreamer.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if USE(GSTREAMER_GL)
-#include &quot;GLContext.h&quot;
-
-#define GST_USE_UNSTABLE_API
-#include &lt;gst/gl/gl.h&gt;
-#undef GST_USE_UNSTABLE_API
-
-#if USE(GLX)
-#include &quot;GLContextGLX.h&quot;
-#include &lt;gst/gl/x11/gstgldisplay_x11.h&gt;
-#elif USE(EGL)
-#include &quot;GLContextEGL.h&quot;
-#include &lt;gst/gl/egl/gstgldisplay_egl.h&gt;
-#endif
-
-// gstglapi.h may include eglplatform.h and it includes X.h, which
-// defines None, breaking MediaPlayer::None enum
-#if PLATFORM(X11) &amp;&amp; GST_GL_HAVE_PLATFORM_EGL
-#undef None
-#endif
-#endif // USE(GSTREAMER_GL)
-
</del><span class="cx"> // Max interval in seconds to stay in the READY state on manual
</span><span class="cx"> // state change requests.
</span><span class="cx"> static const unsigned gReadyStateTimerInterval = 60;
</span><span class="lines">@@ -106,11 +84,6 @@
</span><span class="cx">     return player-&gt;handleMessage(message);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void mediaPlayerPrivateSyncMessageCallback(GstBus*, GstMessage* message, MediaPlayerPrivateGStreamer* player)
-{
-    player-&gt;handleSyncMessage(message);
-}
-
</del><span class="cx"> static void mediaPlayerPrivateSourceChangedCallback(GObject*, GParamSpec*, MediaPlayerPrivateGStreamer* player)
</span><span class="cx"> {
</span><span class="cx">     player-&gt;sourceChanged();
</span><span class="lines">@@ -273,22 +246,21 @@
</span><span class="cx"> 
</span><span class="cx">     m_readyTimerHandler.cancel();
</span><span class="cx"> 
</span><del>-    if (m_playBin) {
-        GRefPtr&lt;GstBus&gt; bus = adoptGRef(gst_pipeline_get_bus(GST_PIPELINE(m_playBin.get())));
</del><ins>+    if (m_pipeline) {
+        GRefPtr&lt;GstBus&gt; bus = adoptGRef(gst_pipeline_get_bus(GST_PIPELINE(m_pipeline.get())));
</ins><span class="cx">         ASSERT(bus);
</span><span class="cx">         g_signal_handlers_disconnect_by_func(bus.get(), reinterpret_cast&lt;gpointer&gt;(mediaPlayerPrivateMessageCallback), this);
</span><span class="cx">         gst_bus_remove_signal_watch(bus.get());
</span><span class="cx"> 
</span><del>-        g_signal_handlers_disconnect_by_func(m_playBin.get(), reinterpret_cast&lt;gpointer&gt;(mediaPlayerPrivateSourceChangedCallback), this);
-        g_signal_handlers_disconnect_by_func(m_playBin.get(), reinterpret_cast&lt;gpointer&gt;(mediaPlayerPrivateVideoChangedCallback), this);
-        g_signal_handlers_disconnect_by_func(m_playBin.get(), reinterpret_cast&lt;gpointer&gt;(mediaPlayerPrivateAudioChangedCallback), this);
</del><ins>+        g_signal_handlers_disconnect_by_func(m_pipeline.get(), reinterpret_cast&lt;gpointer&gt;(mediaPlayerPrivateSourceChangedCallback), this);
+        g_signal_handlers_disconnect_by_func(m_pipeline.get(), reinterpret_cast&lt;gpointer&gt;(mediaPlayerPrivateVideoChangedCallback), this);
+        g_signal_handlers_disconnect_by_func(m_pipeline.get(), reinterpret_cast&lt;gpointer&gt;(mediaPlayerPrivateAudioChangedCallback), this);
</ins><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><del>-        g_signal_handlers_disconnect_by_func(m_playBin.get(), reinterpret_cast&lt;gpointer&gt;(mediaPlayerPrivateNewTextSampleCallback), this);
-        g_signal_handlers_disconnect_by_func(m_playBin.get(), reinterpret_cast&lt;gpointer&gt;(mediaPlayerPrivateTextChangedCallback), this);
</del><ins>+        g_signal_handlers_disconnect_by_func(m_pipeline.get(), reinterpret_cast&lt;gpointer&gt;(mediaPlayerPrivateNewTextSampleCallback), this);
+        g_signal_handlers_disconnect_by_func(m_pipeline.get(), reinterpret_cast&lt;gpointer&gt;(mediaPlayerPrivateTextChangedCallback), this);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-        gst_element_set_state(m_playBin.get(), GST_STATE_NULL);
-        m_playBin.clear();
</del><ins>+        gst_element_set_state(m_pipeline.get(), GST_STATE_NULL);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (m_videoSink) {
</span><span class="lines">@@ -311,13 +283,13 @@
</span><span class="cx">     if (url.isLocalFile())
</span><span class="cx">         cleanURL = cleanURL.substring(0, url.pathEnd());
</span><span class="cx"> 
</span><del>-    if (!m_playBin)
</del><ins>+    if (!m_pipeline)
</ins><span class="cx">         createGSTPlayBin();
</span><span class="cx"> 
</span><del>-    ASSERT(m_playBin);
</del><ins>+    ASSERT(m_pipeline);
</ins><span class="cx"> 
</span><span class="cx">     m_url = URL(URL(), cleanURL);
</span><del>-    g_object_set(m_playBin.get(), &quot;uri&quot;, cleanURL.utf8().data(), NULL);
</del><ins>+    g_object_set(m_pipeline.get(), &quot;uri&quot;, cleanURL.utf8().data(), nullptr);
</ins><span class="cx"> 
</span><span class="cx">     INFO_MEDIA_MESSAGE(&quot;Load %s&quot;, cleanURL.utf8().data());
</span><span class="cx"> 
</span><span class="lines">@@ -384,7 +356,7 @@
</span><span class="cx">     // Position is only available if no async state change is going on and the state is either paused or playing.
</span><span class="cx">     gint64 position = GST_CLOCK_TIME_NONE;
</span><span class="cx">     GstQuery* query= gst_query_new_position(GST_FORMAT_TIME);
</span><del>-    if (gst_element_query(m_playBin.get(), query))
</del><ins>+    if (gst_element_query(m_pipeline.get(), query))
</ins><span class="cx">         gst_query_parse_position(query, 0, &amp;position);
</span><span class="cx"> 
</span><span class="cx">     float result = 0.0f;
</span><span class="lines">@@ -402,12 +374,12 @@
</span><span class="cx"> 
</span><span class="cx"> bool MediaPlayerPrivateGStreamer::changePipelineState(GstState newState)
</span><span class="cx"> {
</span><del>-    ASSERT(m_playBin);
</del><ins>+    ASSERT(m_pipeline);
</ins><span class="cx"> 
</span><span class="cx">     GstState currentState;
</span><span class="cx">     GstState pending;
</span><span class="cx"> 
</span><del>-    gst_element_get_state(m_playBin.get(), &amp;currentState, &amp;pending, 0);
</del><ins>+    gst_element_get_state(m_pipeline.get(), &amp;currentState, &amp;pending, 0);
</ins><span class="cx">     if (currentState == newState || pending == newState) {
</span><span class="cx">         LOG_MEDIA_MESSAGE(&quot;Rejected state change to %s from %s with %s pending&quot;, gst_element_state_get_name(newState),
</span><span class="cx">             gst_element_state_get_name(currentState), gst_element_state_get_name(pending));
</span><span class="lines">@@ -417,7 +389,7 @@
</span><span class="cx">     LOG_MEDIA_MESSAGE(&quot;Changing state change to %s from %s with %s pending&quot;, gst_element_state_get_name(newState),
</span><span class="cx">         gst_element_state_get_name(currentState), gst_element_state_get_name(pending));
</span><span class="cx"> 
</span><del>-    GstStateChangeReturn setStateResult = gst_element_set_state(m_playBin.get(), newState);
</del><ins>+    GstStateChangeReturn setStateResult = gst_element_set_state(m_pipeline.get(), newState);
</ins><span class="cx">     GstState pausedOrPlaying = newState == GST_STATE_PLAYING ? GST_STATE_PAUSED : GST_STATE_PLAYING;
</span><span class="cx">     if (currentState != pausedOrPlaying &amp;&amp; setStateResult == GST_STATE_CHANGE_FAILURE) {
</span><span class="cx">         return false;
</span><span class="lines">@@ -468,7 +440,7 @@
</span><span class="cx"> {
</span><span class="cx">     m_playbackRatePause = false;
</span><span class="cx">     GstState currentState, pendingState;
</span><del>-    gst_element_get_state(m_playBin.get(), &amp;currentState, &amp;pendingState, 0);
</del><ins>+    gst_element_get_state(m_pipeline.get(), &amp;currentState, &amp;pendingState, 0);
</ins><span class="cx">     if (currentState &lt; GST_STATE_PAUSED &amp;&amp; pendingState &lt;= GST_STATE_PAUSED)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -480,7 +452,7 @@
</span><span class="cx"> 
</span><span class="cx"> float MediaPlayerPrivateGStreamer::duration() const
</span><span class="cx"> {
</span><del>-    if (!m_playBin)
</del><ins>+    if (!m_pipeline)
</ins><span class="cx">         return 0.0f;
</span><span class="cx"> 
</span><span class="cx">     if (m_errorOccured)
</span><span class="lines">@@ -496,7 +468,7 @@
</span><span class="cx">     GstFormat timeFormat = GST_FORMAT_TIME;
</span><span class="cx">     gint64 timeLength = 0;
</span><span class="cx"> 
</span><del>-    bool failure = !gst_element_query_duration(m_playBin.get(), timeFormat, &amp;timeLength) || static_cast&lt;guint64&gt;(timeLength) == GST_CLOCK_TIME_NONE;
</del><ins>+    bool failure = !gst_element_query_duration(m_pipeline.get(), timeFormat, &amp;timeLength) || static_cast&lt;guint64&gt;(timeLength) == GST_CLOCK_TIME_NONE;
</ins><span class="cx">     if (failure) {
</span><span class="cx">         LOG_MEDIA_MESSAGE(&quot;Time duration query failed for %s&quot;, m_url.string().utf8().data());
</span><span class="cx">         return numeric_limits&lt;float&gt;::infinity();
</span><span class="lines">@@ -511,7 +483,7 @@
</span><span class="cx"> 
</span><span class="cx"> float MediaPlayerPrivateGStreamer::currentTime() const
</span><span class="cx"> {
</span><del>-    if (!m_playBin)
</del><ins>+    if (!m_pipeline)
</ins><span class="cx">         return 0.0f;
</span><span class="cx"> 
</span><span class="cx">     if (m_errorOccured)
</span><span class="lines">@@ -533,7 +505,7 @@
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateGStreamer::seek(float time)
</span><span class="cx"> {
</span><del>-    if (!m_playBin)
</del><ins>+    if (!m_pipeline)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (m_errorOccured)
</span><span class="lines">@@ -560,7 +532,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     GstState state;
</span><del>-    GstStateChangeReturn getStateResult = gst_element_get_state(m_playBin.get(), &amp;state, 0, 0);
</del><ins>+    GstStateChangeReturn getStateResult = gst_element_get_state(m_pipeline.get(), &amp;state, nullptr, 0);
</ins><span class="cx">     if (getStateResult == GST_STATE_CHANGE_FAILURE || getStateResult == GST_STATE_CHANGE_NO_PREROLL) {
</span><span class="cx">         LOG_MEDIA_MESSAGE(&quot;[Seek] cannot seek, current state change is %s&quot;, gst_element_state_change_return_get_name(getStateResult));
</span><span class="cx">         return;
</span><span class="lines">@@ -611,7 +583,7 @@
</span><span class="cx">     if (!rate)
</span><span class="cx">         rate = 1.0;
</span><span class="cx"> 
</span><del>-    return gst_element_seek(m_playBin.get(), rate, GST_FORMAT_TIME, seekType,
</del><ins>+    return gst_element_seek(m_pipeline.get(), rate, GST_FORMAT_TIME, seekType,
</ins><span class="cx">         GST_SEEK_TYPE_SET, startTime, GST_SEEK_TYPE_SET, endTime);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -637,7 +609,7 @@
</span><span class="cx"> 
</span><span class="cx">     INFO_MEDIA_MESSAGE(&quot;Need to mute audio?: %d&quot;, (int) mute);
</span><span class="cx">     if (doSeek(currentPosition, m_playbackRate, static_cast&lt;GstSeekFlags&gt;(GST_SEEK_FLAG_FLUSH))) {
</span><del>-        g_object_set(m_playBin.get(), &quot;mute&quot;, mute, NULL);
</del><ins>+        g_object_set(m_pipeline.get(), &quot;mute&quot;, mute, nullptr);
</ins><span class="cx">         m_lastPlaybackRate = m_playbackRate;
</span><span class="cx">     } else {
</span><span class="cx">         m_playbackRate = m_lastPlaybackRate;
</span><span class="lines">@@ -648,7 +620,7 @@
</span><span class="cx">         GstState state;
</span><span class="cx">         GstState pending;
</span><span class="cx"> 
</span><del>-        gst_element_get_state(m_playBin.get(), &amp;state, &amp;pending, 0);
</del><ins>+        gst_element_get_state(m_pipeline.get(), &amp;state, &amp;pending, 0);
</ins><span class="cx">         if (state != GST_STATE_PLAYING &amp;&amp; pending != GST_STATE_PLAYING)
</span><span class="cx">             changePipelineState(GST_STATE_PLAYING);
</span><span class="cx">         m_playbackRatePause = false;
</span><span class="lines">@@ -669,7 +641,7 @@
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     GstState state;
</span><del>-    gst_element_get_state(m_playBin.get(), &amp;state, 0, 0);
</del><ins>+    gst_element_get_state(m_pipeline.get(), &amp;state, nullptr, 0);
</ins><span class="cx">     return state == GST_STATE_PAUSED;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -691,15 +663,15 @@
</span><span class="cx"> void MediaPlayerPrivateGStreamer::notifyPlayerOfVideo()
</span><span class="cx"> {
</span><span class="cx">     gint numTracks = 0;
</span><del>-    if (m_playBin)
-        g_object_get(m_playBin.get(), &quot;n-video&quot;, &amp;numTracks, NULL);
</del><ins>+    if (m_pipeline)
+        g_object_get(m_pipeline.get(), &quot;n-video&quot;, &amp;numTracks, nullptr);
</ins><span class="cx"> 
</span><span class="cx">     m_hasVideo = numTracks &gt; 0;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     for (gint i = 0; i &lt; numTracks; ++i) {
</span><span class="cx">         GRefPtr&lt;GstPad&gt; pad;
</span><del>-        g_signal_emit_by_name(m_playBin.get(), &quot;get-video-pad&quot;, i, &amp;pad.outPtr(), NULL);
</del><ins>+        g_signal_emit_by_name(m_pipeline.get(), &quot;get-video-pad&quot;, i, &amp;pad.outPtr(), nullptr);
</ins><span class="cx">         ASSERT(pad);
</span><span class="cx"> 
</span><span class="cx">         if (i &lt; static_cast&lt;gint&gt;(m_videoTracks.size())) {
</span><span class="lines">@@ -709,7 +681,7 @@
</span><span class="cx">                 continue;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        RefPtr&lt;VideoTrackPrivateGStreamer&gt; track = VideoTrackPrivateGStreamer::create(m_playBin, i, pad);
</del><ins>+        RefPtr&lt;VideoTrackPrivateGStreamer&gt; track = VideoTrackPrivateGStreamer::create(m_pipeline, i, pad);
</ins><span class="cx">         m_videoTracks.append(track);
</span><span class="cx">         m_player-&gt;addVideoTrack(track.release());
</span><span class="cx">     }
</span><span class="lines">@@ -739,15 +711,15 @@
</span><span class="cx"> void MediaPlayerPrivateGStreamer::notifyPlayerOfAudio()
</span><span class="cx"> {
</span><span class="cx">     gint numTracks = 0;
</span><del>-    if (m_playBin)
-        g_object_get(m_playBin.get(), &quot;n-audio&quot;, &amp;numTracks, NULL);
</del><ins>+    if (m_pipeline)
+        g_object_get(m_pipeline.get(), &quot;n-audio&quot;, &amp;numTracks, nullptr);
</ins><span class="cx"> 
</span><span class="cx">     m_hasAudio = numTracks &gt; 0;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     for (gint i = 0; i &lt; numTracks; ++i) {
</span><span class="cx">         GRefPtr&lt;GstPad&gt; pad;
</span><del>-        g_signal_emit_by_name(m_playBin.get(), &quot;get-audio-pad&quot;, i, &amp;pad.outPtr(), NULL);
</del><ins>+        g_signal_emit_by_name(m_pipeline.get(), &quot;get-audio-pad&quot;, i, &amp;pad.outPtr(), nullptr);
</ins><span class="cx">         ASSERT(pad);
</span><span class="cx"> 
</span><span class="cx">         if (i &lt; static_cast&lt;gint&gt;(m_audioTracks.size())) {
</span><span class="lines">@@ -757,7 +729,7 @@
</span><span class="cx">                 continue;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        RefPtr&lt;AudioTrackPrivateGStreamer&gt; track = AudioTrackPrivateGStreamer::create(m_playBin, i, pad);
</del><ins>+        RefPtr&lt;AudioTrackPrivateGStreamer&gt; track = AudioTrackPrivateGStreamer::create(m_pipeline, i, pad);
</ins><span class="cx">         m_audioTracks.insert(i, track);
</span><span class="cx">         m_player-&gt;addAudioTrack(track.release());
</span><span class="cx">     }
</span><span class="lines">@@ -782,12 +754,12 @@
</span><span class="cx"> void MediaPlayerPrivateGStreamer::notifyPlayerOfText()
</span><span class="cx"> {
</span><span class="cx">     gint numTracks = 0;
</span><del>-    if (m_playBin)
-        g_object_get(m_playBin.get(), &quot;n-text&quot;, &amp;numTracks, NULL);
</del><ins>+    if (m_pipeline)
+        g_object_get(m_pipeline.get(), &quot;n-text&quot;, &amp;numTracks, nullptr);
</ins><span class="cx"> 
</span><span class="cx">     for (gint i = 0; i &lt; numTracks; ++i) {
</span><span class="cx">         GRefPtr&lt;GstPad&gt; pad;
</span><del>-        g_signal_emit_by_name(m_playBin.get(), &quot;get-text-pad&quot;, i, &amp;pad.outPtr(), NULL);
</del><ins>+        g_signal_emit_by_name(m_pipeline.get(), &quot;get-text-pad&quot;, i, &amp;pad.outPtr(), nullptr);
</ins><span class="cx">         ASSERT(pad);
</span><span class="cx"> 
</span><span class="cx">         if (i &lt; static_cast&lt;gint&gt;(m_textTracks.size())) {
</span><span class="lines">@@ -868,7 +840,7 @@
</span><span class="cx">     m_playbackRate = rate;
</span><span class="cx">     m_changingRate = true;
</span><span class="cx"> 
</span><del>-    gst_element_get_state(m_playBin.get(), &amp;state, &amp;pending, 0);
</del><ins>+    gst_element_get_state(m_pipeline.get(), &amp;state, &amp;pending, 0);
</ins><span class="cx"> 
</span><span class="cx">     if (!rate) {
</span><span class="cx">         m_changingRate = false;
</span><span class="lines">@@ -907,7 +879,7 @@
</span><span class="cx"> 
</span><span class="cx">     GstQuery* query = gst_query_new_buffering(GST_FORMAT_PERCENT);
</span><span class="cx"> 
</span><del>-    if (!gst_element_query(m_playBin.get(), query)) {
</del><ins>+    if (!gst_element_query(m_pipeline.get(), query)) {
</ins><span class="cx">         gst_query_unref(query);
</span><span class="cx">         return timeRanges;
</span><span class="cx">     }
</span><span class="lines">@@ -931,77 +903,6 @@
</span><span class="cx">     return timeRanges;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void MediaPlayerPrivateGStreamer::handleSyncMessage(GstMessage* message)
-{
-    switch (GST_MESSAGE_TYPE(message)) {
-#if USE(GSTREAMER_GL)
-    case GST_MESSAGE_NEED_CONTEXT: {
-        const gchar* contextType;
-        gst_message_parse_context_type(message, &amp;contextType);
-
-        if (!ensureGstGLContext())
-            return;
-
-        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.get());
-            gst_element_set_context(GST_ELEMENT(message-&gt;src), displayContext);
-            return;
-        }
-
-        if (!g_strcmp0(contextType, &quot;gst.gl.app_context&quot;)) {
-            GstContext* appContext = gst_context_new(&quot;gst.gl.app_context&quot;, TRUE);
-            GstStructure* structure = gst_context_writable_structure(appContext);
-            gst_structure_set(structure, &quot;context&quot;, GST_GL_TYPE_CONTEXT, m_glContext.get(), nullptr);
-            gst_element_set_context(GST_ELEMENT(message-&gt;src), appContext);
-            return;
-        }
-        break;
-    }
-#endif // USE(GSTREAMER_GL)
-    default:
-        break;
-    }
-}
-
-#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()-&gt;eglDisplay();
-        m_glDisplay = GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(display));
-#endif
-    }
-
-    GLContext* webkitContext = GLContext::sharingContext();
-    // EGL and GLX are mutually exclusive, no need for ifdefs here.
-    GstGLPlatform glPlatform = webkitContext-&gt;isEGLContext() ? GST_GL_PLATFORM_EGL : GST_GL_PLATFORM_GLX;
-
-#if USE(OPENGL_ES_2)
-    GstGLAPI glAPI = GST_GL_API_GLES2;
-#elif USE(OPENGL)
-    GstGLAPI glAPI = GST_GL_API_OPENGL;
-#else
-    ASSERT_NOT_REACHED();
-#endif
-
-    PlatformGraphicsContext3D contextHandle = webkitContext-&gt;platformContext();
-    if (!contextHandle)
-        return false;
-
-    m_glContext = gst_gl_context_new_wrapped(m_glDisplay.get(), reinterpret_cast&lt;guintptr&gt;(contextHandle), glPlatform, glAPI);
-
-    return true;
-}
-#endif // USE(GSTREAMER_GL)
-
</del><span class="cx"> gboolean MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
</span><span class="cx"> {
</span><span class="cx">     GUniqueOutPtr&lt;GError&gt; err;
</span><span class="lines">@@ -1026,7 +927,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // We ignore state changes from internal elements. They are forwarded to playbin2 anyway.
</span><del>-    bool messageSourceIsPlaybin = GST_MESSAGE_SRC(message) == reinterpret_cast&lt;GstObject*&gt;(m_playBin.get());
</del><ins>+    bool messageSourceIsPlaybin = GST_MESSAGE_SRC(message) == reinterpret_cast&lt;GstObject*&gt;(m_pipeline.get());
</ins><span class="cx"> 
</span><span class="cx">     LOG_MEDIA_MESSAGE(&quot;Message %s received from element %s&quot;, GST_MESSAGE_TYPE_NAME(message), GST_MESSAGE_SRC_NAME(message));
</span><span class="cx">     switch (GST_MESSAGE_TYPE(message)) {
</span><span class="lines">@@ -1038,7 +939,7 @@
</span><span class="cx">         gst_message_parse_error(message, &amp;err.outPtr(), &amp;debug.outPtr());
</span><span class="cx">         ERROR_MEDIA_MESSAGE(&quot;Error %d: %s (url=%s)&quot;, err-&gt;code, err-&gt;message, m_url.string().utf8().data());
</span><span class="cx"> 
</span><del>-        GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(m_playBin.get()), GST_DEBUG_GRAPH_SHOW_ALL, &quot;webkit-video.error&quot;);
</del><ins>+        GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(m_pipeline.get()), GST_DEBUG_GRAPH_SHOW_ALL, &quot;webkit-video.error&quot;);
</ins><span class="cx"> 
</span><span class="cx">         error = MediaPlayer::Empty;
</span><span class="cx">         if (err-&gt;code == GST_STREAM_ERROR_CODEC_NOT_FOUND
</span><span class="lines">@@ -1082,7 +983,7 @@
</span><span class="cx">         GstState newState;
</span><span class="cx">         gst_message_parse_state_changed(message, &amp;currentState, &amp;newState, 0);
</span><span class="cx">         CString dotFileName = String::format(&quot;webkit-video.%s_%s&quot;, gst_element_state_get_name(currentState), gst_element_state_get_name(newState)).utf8();
</span><del>-        GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(m_playBin.get()), GST_DEBUG_GRAPH_SHOW_ALL, dotFileName.data());
</del><ins>+        GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(m_pipeline.get()), GST_DEBUG_GRAPH_SHOW_ALL, dotFileName.data());
</ins><span class="cx"> 
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="lines">@@ -1095,7 +996,7 @@
</span><span class="cx">         break;
</span><span class="cx">     case GST_MESSAGE_REQUEST_STATE:
</span><span class="cx">         gst_message_parse_request_state(message, &amp;requestedState);
</span><del>-        gst_element_get_state(m_playBin.get(), &amp;currentState, NULL, 250);
</del><ins>+        gst_element_get_state(m_pipeline.get(), &amp;currentState, nullptr, 250 * GST_NSECOND);
</ins><span class="cx">         if (requestedState &lt; currentState) {
</span><span class="cx">             GUniquePtr&lt;gchar&gt; elementName(gst_element_get_name(GST_ELEMENT(message)));
</span><span class="cx">             INFO_MEDIA_MESSAGE(&quot;Element %s requested state change to %s&quot;, elementName.get(),
</span><span class="lines">@@ -1115,8 +1016,8 @@
</span><span class="cx">         // is disabled. It also happens relatively often with
</span><span class="cx">         // HTTP adaptive streams when switching between different
</span><span class="cx">         // variants of a stream.
</span><del>-        gst_element_set_state(m_playBin.get(), GST_STATE_PAUSED);
-        gst_element_set_state(m_playBin.get(), GST_STATE_PLAYING);
</del><ins>+        gst_element_set_state(m_pipeline.get(), GST_STATE_PAUSED);
+        gst_element_set_state(m_pipeline.get(), GST_STATE_PLAYING);
</ins><span class="cx">         break;
</span><span class="cx">     case GST_MESSAGE_LATENCY:
</span><span class="cx">         // Recalculate the latency, we don't need any special handling
</span><span class="lines">@@ -1124,7 +1025,7 @@
</span><span class="cx">         // This can happen if the latency of live elements changes, or
</span><span class="cx">         // for one reason or another a new live element is added or
</span><span class="cx">         // removed from the pipeline.
</span><del>-        gst_bin_recalculate_latency(GST_BIN(m_playBin.get()));
</del><ins>+        gst_bin_recalculate_latency(GST_BIN(m_pipeline.get()));
</ins><span class="cx">         break;
</span><span class="cx">     case GST_MESSAGE_ELEMENT:
</span><span class="cx">         if (gst_is_missing_plugin_message(message)) {
</span><span class="lines">@@ -1282,7 +1183,7 @@
</span><span class="cx"> {
</span><span class="cx">     GstQuery* query = gst_query_new_buffering(GST_FORMAT_PERCENT);
</span><span class="cx"> 
</span><del>-    if (!gst_element_query(m_playBin.get(), query)) {
</del><ins>+    if (!gst_element_query(m_pipeline.get(), query)) {
</ins><span class="cx">         gst_query_unref(query);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -1351,7 +1252,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool MediaPlayerPrivateGStreamer::didLoadingProgress() const
</span><span class="cx"> {
</span><del>-    if (!m_playBin || !m_mediaDuration || (!isMediaSource() &amp;&amp; !totalBytes()))
</del><ins>+    if (!m_pipeline || !m_mediaDuration || (!isMediaSource() &amp;&amp; !totalBytes()))
</ins><span class="cx">         return false;
</span><span class="cx">     float currentMaxTimeLoaded = maxTimeLoaded();
</span><span class="cx">     bool didLoadingProgress = currentMaxTimeLoaded != m_maxTimeLoadedAtLastDidLoadingProgress;
</span><span class="lines">@@ -1418,7 +1319,7 @@
</span><span class="cx"> void MediaPlayerPrivateGStreamer::sourceChanged()
</span><span class="cx"> {
</span><span class="cx">     m_source.clear();
</span><del>-    g_object_get(m_playBin.get(), &quot;source&quot;, &amp;m_source.outPtr(), NULL);
</del><ins>+    g_object_get(m_pipeline.get(), &quot;source&quot;, &amp;m_source.outPtr(), nullptr);
</ins><span class="cx"> 
</span><span class="cx">     if (WEBKIT_IS_WEB_SRC(m_source.get()))
</span><span class="cx">         webKitWebSrcSetMediaPlayer(WEBKIT_WEB_SRC(m_source.get()), m_player);
</span><span class="lines">@@ -1434,13 +1335,13 @@
</span><span class="cx">     if (m_networkState &lt; MediaPlayer::Loading || m_networkState == MediaPlayer::Loaded)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (m_playBin)
</del><ins>+    if (m_pipeline)
</ins><span class="cx">         changePipelineState(GST_STATE_READY);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateGStreamer::asyncStateChangeDone()
</span><span class="cx"> {
</span><del>-    if (!m_playBin || m_errorOccured)
</del><ins>+    if (!m_pipeline || m_errorOccured)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (m_seeking) {
</span><span class="lines">@@ -1467,7 +1368,7 @@
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateGStreamer::updateStates()
</span><span class="cx"> {
</span><del>-    if (!m_playBin)
</del><ins>+    if (!m_pipeline)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (m_errorOccured)
</span><span class="lines">@@ -1478,7 +1379,7 @@
</span><span class="cx">     GstState state;
</span><span class="cx">     GstState pending;
</span><span class="cx"> 
</span><del>-    GstStateChangeReturn getStateResult = gst_element_get_state(m_playBin.get(), &amp;state, &amp;pending, 250 * GST_NSECOND);
</del><ins>+    GstStateChangeReturn getStateResult = gst_element_get_state(m_pipeline.get(), &amp;state, &amp;pending, 250 * GST_NSECOND);
</ins><span class="cx"> 
</span><span class="cx">     bool shouldUpdatePlaybackState = false;
</span><span class="cx">     switch (getStateResult) {
</span><span class="lines">@@ -1699,10 +1600,10 @@
</span><span class="cx">             changePipelineState(GST_STATE_READY);
</span><span class="cx"> 
</span><span class="cx">             GstState state;
</span><del>-            gst_element_get_state(m_playBin.get(), &amp;state, 0, 0);
</del><ins>+            gst_element_get_state(m_pipeline.get(), &amp;state, nullptr, 0);
</ins><span class="cx">             if (state &lt;= GST_STATE_READY) {
</span><span class="cx">                 // Set the new uri and start playing.
</span><del>-                g_object_set(m_playBin.get(), &quot;uri&quot;, newUrl.string().utf8().data(), NULL);
</del><ins>+                g_object_set(m_pipeline.get(), &quot;uri&quot;, newUrl.string().utf8().data(), nullptr);
</ins><span class="cx">                 m_url = newUrl;
</span><span class="cx">                 changePipelineState(GST_STATE_PLAYING);
</span><span class="cx">                 return true;
</span><span class="lines">@@ -1756,7 +1657,7 @@
</span><span class="cx">     if (std::isinf(newDuration)) {
</span><span class="cx">         // Only pretend that duration is not available if the the query failed in a stable pipeline state.
</span><span class="cx">         GstState state;
</span><del>-        if (gst_element_get_state(m_playBin.get(), &amp;state, 0, 0) == GST_STATE_CHANGE_SUCCESS &amp;&amp; state &gt; GST_STATE_READY)
</del><ins>+        if (gst_element_get_state(m_pipeline.get(), &amp;state, nullptr, 0) == GST_STATE_CHANGE_SUCCESS &amp;&amp; state &gt; GST_STATE_READY)
</ins><span class="cx">             m_mediaDurationKnown = false;
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -1919,11 +1820,11 @@
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateGStreamer::setDownloadBuffering()
</span><span class="cx"> {
</span><del>-    if (!m_playBin)
</del><ins>+    if (!m_pipeline)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     unsigned flags;
</span><del>-    g_object_get(m_playBin.get(), &quot;flags&quot;, &amp;flags, NULL);
</del><ins>+    g_object_get(m_pipeline.get(), &quot;flags&quot;, &amp;flags, nullptr);
</ins><span class="cx"> 
</span><span class="cx">     unsigned flagDownload = getGstPlayFlag(&quot;download&quot;);
</span><span class="cx"> 
</span><span class="lines">@@ -1934,11 +1835,11 @@
</span><span class="cx">     bool shouldDownload = !isLiveStream() &amp;&amp; m_preload == MediaPlayer::Auto;
</span><span class="cx">     if (shouldDownload) {
</span><span class="cx">         LOG_MEDIA_MESSAGE(&quot;Enabling on-disk buffering&quot;);
</span><del>-        g_object_set(m_playBin.get(), &quot;flags&quot;, flags | flagDownload, NULL);
</del><ins>+        g_object_set(m_pipeline.get(), &quot;flags&quot;, flags | flagDownload, nullptr);
</ins><span class="cx">         m_fillTimer.startRepeating(0.2);
</span><span class="cx">     } else {
</span><span class="cx">         LOG_MEDIA_MESSAGE(&quot;Disabling on-disk buffering&quot;);
</span><del>-        g_object_set(m_playBin.get(), &quot;flags&quot;, flags &amp; ~flagDownload, NULL);
</del><ins>+        g_object_set(m_pipeline.get(), &quot;flags&quot;, flags &amp; ~flagDownload, nullptr);
</ins><span class="cx">         m_fillTimer.stop();
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -2017,37 +1918,35 @@
</span><span class="cx"> GstElement* MediaPlayerPrivateGStreamer::audioSink() const
</span><span class="cx"> {
</span><span class="cx">     GstElement* sink;
</span><del>-    g_object_get(m_playBin.get(), &quot;audio-sink&quot;, &amp;sink, nullptr);
</del><ins>+    g_object_get(m_pipeline.get(), &quot;audio-sink&quot;, &amp;sink, nullptr);
</ins><span class="cx">     return sink;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateGStreamer::createGSTPlayBin()
</span><span class="cx"> {
</span><del>-    ASSERT(!m_playBin);
</del><ins>+    ASSERT(!m_pipeline);
</ins><span class="cx"> 
</span><span class="cx">     // gst_element_factory_make() returns a floating reference so
</span><span class="cx">     // we should not adopt.
</span><del>-    m_playBin = gst_element_factory_make(&quot;playbin&quot;, &quot;play&quot;);
-    setStreamVolumeElement(GST_STREAM_VOLUME(m_playBin.get()));
</del><ins>+    setPipeline(gst_element_factory_make(&quot;playbin&quot;, &quot;play&quot;));
+    setStreamVolumeElement(GST_STREAM_VOLUME(m_pipeline.get()));
</ins><span class="cx"> 
</span><del>-    GRefPtr&lt;GstBus&gt; bus = adoptGRef(gst_pipeline_get_bus(GST_PIPELINE(m_playBin.get())));
</del><ins>+    GRefPtr&lt;GstBus&gt; bus = adoptGRef(gst_pipeline_get_bus(GST_PIPELINE(m_pipeline.get())));
</ins><span class="cx">     gst_bus_add_signal_watch(bus.get());
</span><span class="cx">     g_signal_connect(bus.get(), &quot;message&quot;, G_CALLBACK(mediaPlayerPrivateMessageCallback), this);
</span><del>-    gst_bus_enable_sync_message_emission(bus.get());
-    g_signal_connect(bus.get(), &quot;sync-message&quot;, G_CALLBACK(mediaPlayerPrivateSyncMessageCallback), this);
</del><span class="cx"> 
</span><del>-    g_object_set(m_playBin.get(), &quot;mute&quot;, m_player-&gt;muted(), NULL);
</del><ins>+    g_object_set(m_pipeline.get(), &quot;mute&quot;, m_player-&gt;muted(), nullptr);
</ins><span class="cx"> 
</span><del>-    g_signal_connect(m_playBin.get(), &quot;notify::source&quot;, G_CALLBACK(mediaPlayerPrivateSourceChangedCallback), this);
-    g_signal_connect(m_playBin.get(), &quot;video-changed&quot;, G_CALLBACK(mediaPlayerPrivateVideoChangedCallback), this);
-    g_signal_connect(m_playBin.get(), &quot;audio-changed&quot;, G_CALLBACK(mediaPlayerPrivateAudioChangedCallback), this);
</del><ins>+    g_signal_connect(m_pipeline.get(), &quot;notify::source&quot;, G_CALLBACK(mediaPlayerPrivateSourceChangedCallback), this);
+    g_signal_connect(m_pipeline.get(), &quot;video-changed&quot;, G_CALLBACK(mediaPlayerPrivateVideoChangedCallback), this);
+    g_signal_connect(m_pipeline.get(), &quot;audio-changed&quot;, G_CALLBACK(mediaPlayerPrivateAudioChangedCallback), this);
</ins><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     if (webkitGstCheckVersion(1, 1, 2)) {
</span><del>-        g_signal_connect(m_playBin.get(), &quot;text-changed&quot;, G_CALLBACK(mediaPlayerPrivateTextChangedCallback), this);
</del><ins>+        g_signal_connect(m_pipeline.get(), &quot;text-changed&quot;, G_CALLBACK(mediaPlayerPrivateTextChangedCallback), this);
</ins><span class="cx"> 
</span><span class="cx">         GstElement* textCombiner = webkitTextCombinerNew();
</span><span class="cx">         ASSERT(textCombiner);
</span><del>-        g_object_set(m_playBin.get(), &quot;text-stream-combiner&quot;, textCombiner, NULL);
</del><ins>+        g_object_set(m_pipeline.get(), &quot;text-stream-combiner&quot;, textCombiner, nullptr);
</ins><span class="cx"> 
</span><span class="cx">         m_textAppSink = webkitTextSinkNew();
</span><span class="cx">         ASSERT(m_textAppSink);
</span><span class="lines">@@ -2058,11 +1957,11 @@
</span><span class="cx">         g_object_set(m_textAppSink.get(), &quot;emit-signals&quot;, true, &quot;enable-last-sample&quot;, false, &quot;caps&quot;, gst_caps_new_empty_simple(&quot;text/vtt&quot;), NULL);
</span><span class="cx">         g_signal_connect(m_textAppSink.get(), &quot;new-sample&quot;, G_CALLBACK(mediaPlayerPrivateNewTextSampleCallback), this);
</span><span class="cx"> 
</span><del>-        g_object_set(m_playBin.get(), &quot;text-sink&quot;, m_textAppSink.get(), NULL);
</del><ins>+        g_object_set(m_pipeline.get(), &quot;text-sink&quot;, m_textAppSink.get(), NULL);
</ins><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    g_object_set(m_playBin.get(), &quot;video-sink&quot;, createVideoSink(), &quot;audio-sink&quot;, createAudioSink(), nullptr);
</del><ins>+    g_object_set(m_pipeline.get(), &quot;video-sink&quot;, createVideoSink(), &quot;audio-sink&quot;, createAudioSink(), nullptr);
</ins><span class="cx"> 
</span><span class="cx">     // On 1.4.2 and newer we use the audio-filter property instead.
</span><span class="cx">     // See https://bugzilla.gnome.org/show_bug.cgi?id=735748 for
</span><span class="lines">@@ -2073,7 +1972,7 @@
</span><span class="cx">         if (!scale)
</span><span class="cx">             GST_WARNING(&quot;Failed to create scaletempo&quot;);
</span><span class="cx">         else
</span><del>-            g_object_set(m_playBin.get(), &quot;audio-filter&quot;, scale, nullptr);
</del><ins>+            g_object_set(m_pipeline.get(), &quot;audio-filter&quot;, scale, nullptr);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     GRefPtr&lt;GstPad&gt; videoSinkPad = adoptGRef(gst_element_get_static_pad(m_videoSink.get(), &quot;sink&quot;));
</span><span class="lines">@@ -2083,8 +1982,8 @@
</span><span class="cx"> 
</span><span class="cx"> void MediaPlayerPrivateGStreamer::simulateAudioInterruption()
</span><span class="cx"> {
</span><del>-    GstMessage* message = gst_message_new_request_state(GST_OBJECT(m_playBin.get()), GST_STATE_PAUSED);
-    gst_element_post_message(m_playBin.get(), message);
</del><ins>+    GstMessage* message = gst_message_new_request_state(GST_OBJECT(m_pipeline.get()), GST_STATE_PAUSED);
+    gst_element_post_message(m_pipeline.get(), message);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool MediaPlayerPrivateGStreamer::didPassCORSAccessCheck() const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h (182228 => 182229)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h        2015-04-01 10:38:06 UTC (rev 182228)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h        2015-04-01 10:46:19 UTC (rev 182229)
</span><span class="lines">@@ -47,8 +47,6 @@
</span><span class="cx"> typedef struct _GstMessage GstMessage;
</span><span class="cx"> typedef struct _GstElement GstElement;
</span><span class="cx"> typedef struct _GstMpegtsSection GstMpegtsSection;
</span><del>-typedef struct _GstGLContext GstGLContext;
-typedef struct _GstGLDisplay GstGLDisplay;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -68,7 +66,6 @@
</span><span class="cx">     ~MediaPlayerPrivateGStreamer();
</span><span class="cx"> 
</span><span class="cx">     static void registerMediaEngine(MediaEngineRegistrar);
</span><del>-    void handleSyncMessage(GstMessage*);
</del><span class="cx">     gboolean handleMessage(GstMessage*);
</span><span class="cx">     void handlePluginInstallerResult(GstInstallPluginsReturn);
</span><span class="cx"> 
</span><span class="lines">@@ -159,10 +156,6 @@
</span><span class="cx"> 
</span><span class="cx">     void createGSTPlayBin();
</span><span class="cx"> 
</span><del>-#if USE(GSTREAMER_GL)
-    bool ensureGstGLContext();
-#endif
-
</del><span class="cx">     bool loadNextLocation();
</span><span class="cx">     void mediaLocationChanged(GstMessage*);
</span><span class="cx"> 
</span><span class="lines">@@ -193,7 +186,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    GRefPtr&lt;GstElement&gt; m_playBin;
</del><span class="cx">     GRefPtr&lt;GstElement&gt; m_source;
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     GRefPtr&lt;GstElement&gt; m_textAppSink;
</span><span class="lines">@@ -258,10 +250,6 @@
</span><span class="cx"> #else
</span><span class="cx">     bool isMediaSource() const { return false; }
</span><span class="cx"> #endif
</span><del>-#if USE(GSTREAMER_GL)
-    GRefPtr&lt;GstGLContext&gt; m_glContext;
-    GRefPtr&lt;GstGLDisplay&gt; m_glDisplay;
-#endif
</del><span class="cx"> };
</span><span class="cx"> }
</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 (182228 => 182229)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp        2015-04-01 10:38:06 UTC (rev 182228)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp        2015-04-01 10:46:19 UTC (rev 182229)
</span><span class="lines">@@ -56,6 +56,28 @@
</span><span class="cx"> #include &quot;TextureMapperGL.h&quot;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if USE(GSTREAMER_GL)
+#include &quot;GLContext.h&quot;
+
+#define GST_USE_UNSTABLE_API
+#include &lt;gst/gl/gl.h&gt;
+#undef GST_USE_UNSTABLE_API
+
+#if USE(GLX)
+#include &quot;GLContextGLX.h&quot;
+#include &lt;gst/gl/x11/gstgldisplay_x11.h&gt;
+#elif USE(EGL)
+#include &quot;GLContextEGL.h&quot;
+#include &lt;gst/gl/egl/gstgldisplay_egl.h&gt;
+#endif
+
+// gstglapi.h may include eglplatform.h and it includes X.h, which
+// defines None, breaking MediaPlayer::None enum
+#if PLATFORM(X11) &amp;&amp; GST_GL_HAVE_PLATFORM_EGL
+#undef None
+#endif
+#endif // USE(GSTREAMER_GL)
+
</ins><span class="cx"> GST_DEBUG_CATEGORY(webkit_media_player_debug);
</span><span class="cx"> #define GST_CAT_DEFAULT webkit_media_player_debug
</span><span class="cx"> 
</span><span class="lines">@@ -100,6 +122,11 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+static void mediaPlayerPrivateNeedContextMessageCallback(GstBus*, GstMessage* message, MediaPlayerPrivateGStreamerBase* player)
+{
+    player-&gt;handleNeedContextMessage(message);
+}
+
</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="lines">@@ -143,12 +170,95 @@
</span><span class="cx">     g_mutex_clear(&amp;m_drawMutex);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    if (m_pipeline) {
+        GRefPtr&lt;GstBus&gt; bus = adoptGRef(gst_pipeline_get_bus(GST_PIPELINE(m_pipeline.get())));
+        ASSERT(bus);
+        g_signal_handlers_disconnect_by_func(bus.get(), reinterpret_cast&lt;gpointer&gt;(mediaPlayerPrivateNeedContextMessageCallback), this);
+        gst_bus_disable_sync_message_emission(bus.get());
+        m_pipeline.clear();
+    }
+
</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="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void MediaPlayerPrivateGStreamerBase::setPipeline(GstElement* pipeline)
+{
+    m_pipeline = pipeline;
+
+    GRefPtr&lt;GstBus&gt; bus = adoptGRef(gst_pipeline_get_bus(GST_PIPELINE(m_pipeline.get())));
+    gst_bus_enable_sync_message_emission(bus.get());
+    g_signal_connect(bus.get(), &quot;sync-message::need-context&quot;, G_CALLBACK(mediaPlayerPrivateNeedContextMessageCallback), this);
+}
+
+void MediaPlayerPrivateGStreamerBase::handleNeedContextMessage(GstMessage* message)
+{
+#if USE(GSTREAMER_GL)
+    const gchar* contextType;
+    gst_message_parse_context_type(message, &amp;contextType);
+
+    if (!ensureGstGLContext())
+        return;
+
+    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.get());
+        gst_element_set_context(GST_ELEMENT(message-&gt;src), displayContext);
+        return;
+    }
+
+    if (!g_strcmp0(contextType, &quot;gst.gl.app_context&quot;)) {
+        GstContext* appContext = gst_context_new(&quot;gst.gl.app_context&quot;, TRUE);
+        GstStructure* structure = gst_context_writable_structure(appContext);
+        gst_structure_set(structure, &quot;context&quot;, GST_GL_TYPE_CONTEXT, m_glContext.get(), nullptr);
+        gst_element_set_context(GST_ELEMENT(message-&gt;src), appContext);
+        return;
+    }
+#else
+    UNUSED_PARAM(message);
+#endif // USE(GSTREAMER_GL)
+}
+
+#if USE(GSTREAMER_GL)
+bool MediaPlayerPrivateGStreamerBase::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()-&gt;eglDisplay();
+        m_glDisplay = GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(display));
+#endif
+    }
+
+    GLContext* webkitContext = GLContext::sharingContext();
+    // EGL and GLX are mutually exclusive, no need for ifdefs here.
+    GstGLPlatform glPlatform = webkitContext-&gt;isEGLContext() ? GST_GL_PLATFORM_EGL : GST_GL_PLATFORM_GLX;
+
+#if USE(OPENGL_ES_2)
+    GstGLAPI glAPI = GST_GL_API_GLES2;
+#elif USE(OPENGL)
+    GstGLAPI glAPI = GST_GL_API_OPENGL;
+#else
+    ASSERT_NOT_REACHED();
+#endif
+
+    PlatformGraphicsContext3D contextHandle = webkitContext-&gt;platformContext();
+    if (!contextHandle)
+        return false;
+
+    m_glContext = gst_gl_context_new_wrapped(m_glDisplay.get(), reinterpret_cast&lt;guintptr&gt;(contextHandle), glPlatform, glAPI);
+
+    return true;
+}
+#endif // USE(GSTREAMER_GL)
+
</ins><span class="cx"> // Returns the size of the video
</span><span class="cx"> FloatSize MediaPlayerPrivateGStreamerBase::naturalSize() const
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerMediaPlayerPrivateGStreamerBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h (182228 => 182229)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h        2015-04-01 10:38:06 UTC (rev 182228)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h        2015-04-01 10:46:19 UTC (rev 182229)
</span><span class="lines">@@ -38,6 +38,8 @@
</span><span class="cx"> 
</span><span class="cx"> typedef struct _GstMessage GstMessage;
</span><span class="cx"> typedef struct _GstStreamVolume GstStreamVolume;
</span><ins>+typedef struct _GstGLContext GstGLContext;
+typedef struct _GstGLDisplay GstGLDisplay;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -61,6 +63,11 @@
</span><span class="cx">     void volumeChanged();
</span><span class="cx">     void notifyPlayerOfVolumeChange();
</span><span class="cx"> 
</span><ins>+#if USE(GSTREAMER_GL)
+    bool ensureGstGLContext();
+#endif
+    void handleNeedContextMessage(GstMessage*);
+
</ins><span class="cx">     bool supportsMuting() const { return true; }
</span><span class="cx">     void setMuted(bool);
</span><span class="cx">     bool muted() const;
</span><span class="lines">@@ -112,7 +119,10 @@
</span><span class="cx">     virtual GstElement* createAudioSink() { return 0; }
</span><span class="cx">     virtual GstElement* audioSink() const { return 0; }
</span><span class="cx"> 
</span><ins>+    void setPipeline(GstElement*);
+
</ins><span class="cx">     MediaPlayer* m_player;
</span><ins>+    GRefPtr&lt;GstElement&gt; m_pipeline;
</ins><span class="cx">     GRefPtr&lt;GstStreamVolume&gt; m_volumeElement;
</span><span class="cx">     GRefPtr&lt;GstElement&gt; m_videoSink;
</span><span class="cx">     GRefPtr&lt;GstElement&gt; m_fpsSink;
</span><span class="lines">@@ -136,6 +146,10 @@
</span><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><ins>+#if USE(GSTREAMER_GL)
+    GRefPtr&lt;GstGLContext&gt; m_glContext;
+    GRefPtr&lt;GstGLDisplay&gt; m_glDisplay;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>