|
| 1 | +diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp |
| 2 | +index 0a875d2..12d474b 100644 |
| 3 | +--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp |
| 4 | ++++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp |
| 5 | +@@ -158,6 +158,7 @@ MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player) |
| 6 | + , m_totalBytes(0) |
| 7 | + , m_preservesPitch(false) |
| 8 | + , m_lastQuery(-1) |
| 9 | ++ , m_underflowCounter(0) |
| 10 | + { |
| 11 | + #if USE(GLIB) |
| 12 | + m_readyTimerHandler.setPriority(G_PRIORITY_DEFAULT_IDLE); |
| 13 | +@@ -306,8 +307,7 @@ void MediaPlayerPrivateGStreamer::commitLoad() |
| 14 | + } |
| 15 | + |
| 16 | + #if PLATFORM(BCM_NEXUS) |
| 17 | +-// utility function for bcm nexus seek functionality |
| 18 | +-static GstElement* findVideoDecoder(GstElement *element) |
| 19 | ++static GstElement* findElement(GstElement *element, const CString &search) |
| 20 | + { |
| 21 | + GstElement* re = nullptr; |
| 22 | + if (GST_IS_BIN(element)) { |
| 23 | +@@ -319,7 +319,7 @@ static GstElement* findVideoDecoder(GstElement *element) |
| 24 | + case GST_ITERATOR_OK: |
| 25 | + { |
| 26 | + GstElement *next = GST_ELEMENT(g_value_get_object(&item)); |
| 27 | +- done = (re = findVideoDecoder(next)); |
| 28 | ++ done = (re = findElement(next, search)); |
| 29 | + g_value_reset (&item); |
| 30 | + break; |
| 31 | + } |
| 32 | +@@ -334,8 +334,13 @@ static GstElement* findVideoDecoder(GstElement *element) |
| 33 | + } |
| 34 | + g_value_unset (&item); |
| 35 | + gst_iterator_free(it); |
| 36 | +- } else if (GST_IS_VIDEO_DECODER(element)) |
| 37 | ++ } else if (g_strstr_len(gst_element_get_name(element), search.length(), search.data())) { |
| 38 | ++ GST_DEBUG("Element: %s", gst_element_get_name(element)); |
| 39 | + re = element; |
| 40 | ++ } else { |
| 41 | ++ GST_DEBUG("Element: %s", gst_element_get_name(element)); |
| 42 | ++ } |
| 43 | ++ |
| 44 | + return re; |
| 45 | + } |
| 46 | + #endif |
| 47 | +@@ -389,7 +394,7 @@ MediaTime MediaPlayerPrivateGStreamer::playbackPosition() const |
| 48 | + #if PLATFORM(BCM_NEXUS) |
| 49 | + // implement getting pts time from broadcom decoder directly for seek functionality |
| 50 | + gint64 currentPts = -1; |
| 51 | +- /*GstElement**/ videoDec = findVideoDecoder(m_pipeline.get()); |
| 52 | ++ /*GstElement*/ videoDec = findElement(m_pipeline.get(), "brcmvideodecoder"); |
| 53 | + const char* videoPtsPropertyName = "video_pts"; |
| 54 | + if (videoDec) |
| 55 | + g_object_get(videoDec, videoPtsPropertyName, ¤tPts, nullptr); |
| 56 | +@@ -771,6 +776,25 @@ void MediaPlayerPrivateGStreamer::audioChangedCallback(MediaPlayerPrivateGStream |
| 57 | + player->m_notifier->notify(MainThreadNotification::AudioChanged, [player] { player->notifyPlayerOfAudio(); }); |
| 58 | + } |
| 59 | + |
| 60 | ++void MediaPlayerPrivateGStreamer::streamUnderflowCallback(MediaPlayerPrivateGStreamer* player) |
| 61 | ++{ |
| 62 | ++ player->streamUnderflow(); |
| 63 | ++ GST_DEBUG("Stream Underflow callback has been called"); |
| 64 | ++} |
| 65 | ++ |
| 66 | ++void MediaPlayerPrivateGStreamer::streamUnderflow() |
| 67 | ++{ |
| 68 | ++ //TODO: So far, raise the underflow if there are two consecutive signals |
| 69 | ++ // Reassure one from video decoder and the other from audio decoder! |
| 70 | ++ GstState state; |
| 71 | ++ gst_element_get_state(m_pipeline.get(), &state, nullptr, 0); |
| 72 | ++ if (state == GST_STATE_PLAYING && (++m_underflowCounter > 1)) { |
| 73 | ++ m_isEndReached = true; |
| 74 | ++ m_underflowCounter = 0; |
| 75 | ++ } |
| 76 | ++ GST_DEBUG("Stream Underflow has been called: m_underflowCounter :%d", m_underflowCounter); |
| 77 | ++} |
| 78 | ++ |
| 79 | + void MediaPlayerPrivateGStreamer::notifyPlayerOfAudio() |
| 80 | + { |
| 81 | + if (UNLIKELY(!m_pipeline || !m_source)) |
| 82 | +@@ -1074,6 +1098,15 @@ void MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message) |
| 83 | + } |
| 84 | + #endif |
| 85 | + |
| 86 | ++#if PLATFORM(BCM_NEXUS) |
| 87 | ++ if (g_strstr_len(GST_MESSAGE_SRC_NAME(message), 16, "brcmaudiodecoder") || g_strstr_len(GST_MESSAGE_SRC_NAME(message), 16, "brcmvideodecoder")) { |
| 88 | ++ if (currentState == GST_STATE_NULL && newState == GST_STATE_READY) { |
| 89 | ++ g_signal_connect_swapped(GST_MESSAGE_SRC(message), "buffer-underflow-callback", G_CALLBACK(streamUnderflowCallback), this); |
| 90 | ++ GST_DEBUG("It is %s !!! connect signal",GST_MESSAGE_SRC_NAME(message)); |
| 91 | ++ } |
| 92 | ++ } |
| 93 | ++#endif |
| 94 | ++ |
| 95 | + if (!messageSourceIsPlaybin || m_delayingLoad) |
| 96 | + break; |
| 97 | + updateStates(); |
| 98 | +@@ -1659,6 +1692,7 @@ void MediaPlayerPrivateGStreamer::updateStates() |
| 99 | + |
| 100 | + bool didBuffering = m_buffering; |
| 101 | + |
| 102 | ++ m_underflowCounter = 0; |
| 103 | + // Update ready and network states. |
| 104 | + switch (state) { |
| 105 | + case GST_STATE_NULL: |
| 106 | +diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h |
| 107 | +index 79e11bd..7de3f44 100644 |
| 108 | +--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h |
| 109 | ++++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h |
| 110 | +@@ -211,12 +211,15 @@ protected: |
| 111 | + void ensureAudioSourceProvider(); |
| 112 | + void setAudioStreamProperties(GObject*); |
| 113 | + |
| 114 | ++ virtual void streamUnderflow(); |
| 115 | ++ |
| 116 | + static void setAudioStreamPropertiesCallback(MediaPlayerPrivateGStreamer*, GObject*); |
| 117 | + |
| 118 | + static void sourceChangedCallback(MediaPlayerPrivateGStreamer*); |
| 119 | + static void videoChangedCallback(MediaPlayerPrivateGStreamer*); |
| 120 | + static void videoSinkCapsChangedCallback(MediaPlayerPrivateGStreamer*); |
| 121 | + static void audioChangedCallback(MediaPlayerPrivateGStreamer*); |
| 122 | ++ static void streamUnderflowCallback(MediaPlayerPrivateGStreamer*); |
| 123 | + #if ENABLE(VIDEO_TRACK) |
| 124 | + static void textChangedCallback(MediaPlayerPrivateGStreamer*); |
| 125 | + static GstFlowReturn newTextSampleCallback(MediaPlayerPrivateGStreamer*); |
| 126 | +@@ -247,6 +250,7 @@ private: |
| 127 | + URL m_url; |
| 128 | + bool m_preservesPitch; |
| 129 | + mutable double m_lastQuery; |
| 130 | ++ uint8_t m_underflowCounter; |
| 131 | + #if ENABLE(WEB_AUDIO) |
| 132 | + std::unique_ptr<AudioSourceProviderGStreamer> m_audioSourceProvider; |
| 133 | + #endif |
| 134 | +diff --git a/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp b/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp |
| 135 | +index a65bf63..1b2eef6 100644 |
| 136 | +--- a/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp |
| 137 | ++++ b/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp |
| 138 | +@@ -687,6 +689,16 @@ void MediaPlayerPrivateGStreamerMSE::asyncStateChangeDone() |
| 139 | + updateStates(); |
| 140 | + } |
| 141 | + |
| 142 | ++void MediaPlayerPrivateGStreamerMSE::streamUnderflow() |
| 143 | ++{ |
| 144 | ++ GST_DEBUG("Stream Underflow has been called"); |
| 145 | ++ MediaPlayerPrivateGStreamer::streamUnderflow(); |
| 146 | ++ |
| 147 | ++ m_cachedPosition = m_mediaTimeDuration; |
| 148 | ++ m_durationAtEOS = m_mediaTimeDuration; |
| 149 | ++} |
| 150 | ++ |
| 151 | ++ |
| 152 | + bool MediaPlayerPrivateGStreamerMSE::isTimeBuffered(const MediaTime &time) const |
| 153 | + { |
| 154 | + bool result = m_mediaSource && m_mediaSource->hasBufferedTime(time); |
| 155 | +diff --git a/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h b/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h |
| 156 | +index 4066db2..23d5876 100644 |
| 157 | +--- a/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h |
| 158 | ++++ b/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h |
| 159 | +@@ -105,6 +105,7 @@ private: |
| 160 | + |
| 161 | + // FIXME: Reduce code duplication. |
| 162 | + void updateStates() override; |
| 163 | ++ void streamUnderflow() override; |
| 164 | + |
| 165 | + bool doSeek(const MediaTime&, float, GstSeekFlags) override; |
| 166 | + bool doSeek(); |
0 commit comments