Title: [226629] trunk/Source/WebCore
Revision
226629
Author
[email protected]
Date
2018-01-09 05:59:47 -0800 (Tue, 09 Jan 2018)

Log Message

[GStreamer] Missing notifications to player client
https://bugs.webkit.org/show_bug.cgi?id=181432

Reviewed by Carlos Garcia Campos.

We now properly emit playback state changes and characteristic
updates to the client when the pipeline state changes and when
audio/video tracks changes are detected.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::playbackPosition const):
This debug message appears too often in logs. Demote.
(WebCore::MediaPlayerPrivateGStreamer::durationMediaTime const): Ditto.
(WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfVideo): Emit
charasteristicChanged notification.
(WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfAudio): Ditto.
(WebCore::MediaPlayerPrivateGStreamer::updateStates): Keep track
of old and current pipeline state.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (226628 => 226629)


--- trunk/Source/WebCore/ChangeLog	2018-01-09 13:57:25 UTC (rev 226628)
+++ trunk/Source/WebCore/ChangeLog	2018-01-09 13:59:47 UTC (rev 226629)
@@ -1,3 +1,26 @@
+2018-01-09  Philippe Normand  <[email protected]>
+
+        [GStreamer] Missing notifications to player client
+        https://bugs.webkit.org/show_bug.cgi?id=181432
+
+        Reviewed by Carlos Garcia Campos.
+
+        We now properly emit playback state changes and characteristic
+        updates to the client when the pipeline state changes and when
+        audio/video tracks changes are detected.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::playbackPosition const):
+        This debug message appears too often in logs. Demote.
+        (WebCore::MediaPlayerPrivateGStreamer::durationMediaTime const): Ditto.
+        (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfVideo): Emit
+        charasteristicChanged notification.
+        (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfAudio): Ditto.
+        (WebCore::MediaPlayerPrivateGStreamer::updateStates): Keep track
+        of old and current pipeline state.
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+
+
 2018-01-09  Youenn Fablet  <[email protected]>
 
         Add CSP support to service workers

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (226628 => 226629)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2018-01-09 13:57:25 UTC (rev 226628)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2018-01-09 13:59:47 UTC (rev 226629)
@@ -317,7 +317,7 @@
         gst_query_parse_position(query, 0, &position);
     gst_query_unref(query);
 
-    GST_DEBUG("Position %" GST_TIME_FORMAT, GST_TIME_ARGS(position));
+    GST_LOG("Position %" GST_TIME_FORMAT, GST_TIME_ARGS(position));
 
     MediaTime playbackPosition = MediaTime::zeroTime();
     GstClockTime gstreamerPosition = static_cast<GstClockTime>(position);
@@ -432,7 +432,7 @@
         return MediaTime::positiveInfiniteTime();
     }
 
-    GST_DEBUG("Duration: %" GST_TIME_FORMAT, GST_TIME_ARGS(timeLength));
+    GST_LOG("Duration: %" GST_TIME_FORMAT, GST_TIME_ARGS(timeLength));
 
     return MediaTime(timeLength, GST_SECOND);
     // FIXME: handle 3.14.9.5 properly
@@ -609,7 +609,11 @@
     GstElement* element = useMediaSource ? m_source.get() : m_pipeline.get();
     g_object_get(element, "n-video", &numTracks, nullptr);
 
+    bool oldHasVideo = m_hasVideo;
     m_hasVideo = numTracks > 0;
+    if (oldHasVideo != m_hasVideo)
+        m_player->characteristicChanged();
+
     if (m_hasVideo)
         m_player->sizeChanged();
 
@@ -674,7 +678,10 @@
     GstElement* element = useMediaSource ? m_source.get() : m_pipeline.get();
     g_object_get(element, "n-audio", &numTracks, nullptr);
 
+    bool oldHasAudio = m_hasAudio;
     m_hasAudio = numTracks > 0;
+    if (oldHasAudio != m_hasAudio)
+        m_player->characteristicChanged();
 
     if (useMediaSource) {
         GST_DEBUG("Tracks managed by source element. Bailing out now.");
@@ -1492,27 +1499,27 @@
 
     MediaPlayer::NetworkState oldNetworkState = m_networkState;
     MediaPlayer::ReadyState oldReadyState = m_readyState;
-    GstState state;
     GstState pending;
 
-    GstStateChangeReturn getStateResult = gst_element_get_state(m_pipeline.get(), &state, &pending, 250 * GST_NSECOND);
+    m_oldState = m_currentState;
+    GstStateChangeReturn getStateResult = gst_element_get_state(m_pipeline.get(), &m_currentState, &pending, 250 * GST_NSECOND);
 
     bool shouldUpdatePlaybackState = false;
     switch (getStateResult) {
     case GST_STATE_CHANGE_SUCCESS: {
-        GST_DEBUG("State: %s, pending: %s", gst_element_state_get_name(state), gst_element_state_get_name(pending));
+        GST_DEBUG("State: %s, pending: %s", gst_element_state_get_name(m_currentState), gst_element_state_get_name(pending));
 
         // Do nothing if on EOS and state changed to READY to avoid recreating the player
         // on HTMLMediaElement and properly generate the video 'ended' event.
-        if (m_isEndReached && state == GST_STATE_READY)
+        if (m_isEndReached && m_currentState == GST_STATE_READY)
             break;
 
-        m_resetPipeline = state <= GST_STATE_READY;
+        m_resetPipeline = m_currentState <= GST_STATE_READY;
 
         bool didBuffering = m_buffering;
 
         // Update ready and network states.
-        switch (state) {
+        switch (m_currentState) {
         case GST_STATE_NULL:
             m_readyState = MediaPlayer::HaveNothing;
             m_networkState = MediaPlayer::Empty;
@@ -1548,7 +1555,7 @@
         }
 
         // Sync states where needed.
-        if (state == GST_STATE_PAUSED) {
+        if (m_currentState == GST_STATE_PAUSED) {
             if (!m_volumeAndMuteInitialized) {
                 notifyPlayerOfVolumeChange();
                 notifyPlayerOfMute();
@@ -1559,7 +1566,7 @@
                 GST_DEBUG("[Buffering] Restarting playback.");
                 changePipelineState(GST_STATE_PLAYING);
             }
-        } else if (state == GST_STATE_PLAYING) {
+        } else if (m_currentState == GST_STATE_PLAYING) {
             m_paused = false;
 
             if ((m_buffering && !isLiveStream()) || !m_playbackRate) {
@@ -1569,34 +1576,40 @@
         } else
             m_paused = true;
 
-        if (m_requestedState == GST_STATE_PAUSED && state == GST_STATE_PAUSED) {
+        GST_DEBUG("Old state: %s, new state: %s (requested: %s)", gst_element_state_get_name(m_oldState), gst_element_state_get_name(m_currentState), gst_element_state_get_name(m_requestedState));
+        if (m_requestedState == GST_STATE_PAUSED && m_currentState == GST_STATE_PAUSED) {
             shouldUpdatePlaybackState = true;
-            GST_DEBUG("Requested state change to %s was completed", gst_element_state_get_name(state));
+            GST_INFO("Requested state change to %s was completed", gst_element_state_get_name(m_currentState));
         }
+        if ((m_oldState != m_currentState) && ((m_oldState > GST_STATE_READY && m_currentState > GST_STATE_READY)
+            || (m_currentState < GST_STATE_PLAYING && m_oldState > GST_STATE_READY))) {
+            GST_INFO("Playback state changed from %s to %s. Notifying the media player client", gst_element_state_get_name(m_oldState), gst_element_state_get_name(m_currentState));
+            shouldUpdatePlaybackState = true;
+        }
 
         break;
     }
     case GST_STATE_CHANGE_ASYNC:
-        GST_DEBUG("Async: State: %s, pending: %s", gst_element_state_get_name(state), gst_element_state_get_name(pending));
+        GST_DEBUG("Async: State: %s, pending: %s", gst_element_state_get_name(m_currentState), gst_element_state_get_name(pending));
         // Change in progress.
         break;
     case GST_STATE_CHANGE_FAILURE:
-        GST_DEBUG("Failure: State: %s, pending: %s", gst_element_state_get_name(state), gst_element_state_get_name(pending));
+        GST_DEBUG("Failure: State: %s, pending: %s", gst_element_state_get_name(m_currentState), gst_element_state_get_name(pending));
         // Change failed
         return;
     case GST_STATE_CHANGE_NO_PREROLL:
-        GST_DEBUG("No preroll: State: %s, pending: %s", gst_element_state_get_name(state), gst_element_state_get_name(pending));
+        GST_DEBUG("No preroll: State: %s, pending: %s", gst_element_state_get_name(m_currentState), gst_element_state_get_name(pending));
 
         // Live pipelines go in PAUSED without prerolling.
         m_isStreaming = true;
         setDownloadBuffering();
 
-        if (state == GST_STATE_READY)
+        if (m_currentState == GST_STATE_READY)
             m_readyState = MediaPlayer::HaveNothing;
-        else if (state == GST_STATE_PAUSED) {
+        else if (m_currentState == GST_STATE_PAUSED) {
             m_readyState = MediaPlayer::HaveEnoughData;
             m_paused = true;
-        } else if (state == GST_STATE_PLAYING)
+        } else if (m_currentState == GST_STATE_PLAYING)
             m_paused = false;
 
         if (!m_paused && m_playbackRate)
@@ -1623,7 +1636,7 @@
         m_player->readyStateChanged();
     }
 
-    if (getStateResult == GST_STATE_CHANGE_SUCCESS && state >= GST_STATE_PAUSED) {
+    if (getStateResult == GST_STATE_CHANGE_SUCCESS && m_currentState >= GST_STATE_PAUSED) {
         updatePlaybackRate();
         if (m_seekIsPending) {
             GST_DEBUG("[Seek] committing pending seek to %s", toString(m_seekTime).utf8().data());

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h (226628 => 226629)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2018-01-09 13:57:25 UTC (rev 226628)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2018-01-09 13:59:47 UTC (rev 226629)
@@ -190,6 +190,8 @@
     mutable MediaTime m_durationAtEOS;
     bool m_paused;
     float m_playbackRate;
+    GstState m_currentState;
+    GstState m_oldState;
     GstState m_requestedState;
     bool m_resetPipeline;
     bool m_seeking;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to