Diff
Modified: trunk/Source/WebCore/ChangeLog (264210 => 264211)
--- trunk/Source/WebCore/ChangeLog 2020-07-10 07:02:30 UTC (rev 264210)
+++ trunk/Source/WebCore/ChangeLog 2020-07-10 08:01:07 UTC (rev 264211)
@@ -1,3 +1,51 @@
+2020-07-10 Alicia Boya GarcĂa <[email protected]>
+
+ [MSE][GStreamer] Inline MediaSourceClientGStreamerMSE away
+ https://bugs.webkit.org/show_bug.cgi?id=214140
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ MediaSourceClientGStreamerMSE is a superfluous class that adds
+ a layer of indirection and complexity to the GStreamer MSE codebase
+ for no gain. This patch gets rid of it.
+
+ This also gets rid of the friend access layer violations that
+ MediaSourceClientGStreamerMSE relied upon.
+
+ This patch is a refactor that doesn't introduce behavior changes and
+ it's covered by existing tests.
+
+ * platform/GStreamer.cmake:
+ * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
+ (WebCore::AppendPipeline::AppendPipeline):
+ * platform/graphics/gstreamer/mse/AppendPipeline.h:
+ * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
+ (WebCore::MediaPlayerPrivateGStreamerMSE::durationChanged):
+ (WebCore::MediaPlayerPrivateGStreamerMSE::setMediaSourceClient): Deleted.
+ (WebCore::MediaPlayerPrivateGStreamerMSE::mediaSourceClient): Deleted.
+ * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:
+ (WebCore::MediaPlayerPrivateGStreamerMSE::playbackPipeline const):
+ * platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.cpp: Removed.
+ * platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.h: Removed.
+ * platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.cpp:
+ (WebCore::MediaSourcePrivateGStreamer::MediaSourcePrivateGStreamer):
+ (WebCore::MediaSourcePrivateGStreamer::addSourceBuffer):
+ (WebCore::MediaSourcePrivateGStreamer::durationChanged):
+ (WebCore::MediaSourcePrivateGStreamer::markEndOfStream):
+ * platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.h:
+ * platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp:
+ (WebCore::SourceBufferPrivateGStreamer::create):
+ (WebCore::SourceBufferPrivateGStreamer::SourceBufferPrivateGStreamer):
+ (WebCore::SourceBufferPrivateGStreamer::finishCreation):
+ (WebCore::SourceBufferPrivateGStreamer::append):
+ (WebCore::SourceBufferPrivateGStreamer::abort):
+ (WebCore::SourceBufferPrivateGStreamer::resetParserState):
+ (WebCore::SourceBufferPrivateGStreamer::removedFromMediaSource):
+ (WebCore::SourceBufferPrivateGStreamer::flush):
+ (WebCore::SourceBufferPrivateGStreamer::enqueueSample):
+ (WebCore::SourceBufferPrivateGStreamer::allSamplesInTrackEnqueued):
+ * platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h:
+
2020-07-09 Brady Eidson <[email protected]>
Multiplex the HID and GameController gamepad providers on Mac.
Modified: trunk/Source/WebCore/platform/GStreamer.cmake (264210 => 264211)
--- trunk/Source/WebCore/platform/GStreamer.cmake 2020-07-10 07:02:30 UTC (rev 264210)
+++ trunk/Source/WebCore/platform/GStreamer.cmake 2020-07-10 08:01:07 UTC (rev 264211)
@@ -32,7 +32,6 @@
platform/graphics/gstreamer/mse/GStreamerMediaDescription.cpp
platform/graphics/gstreamer/mse/GStreamerRegistryScannerMSE.cpp
platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp
- platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.cpp
platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.cpp
platform/graphics/gstreamer/mse/PlaybackPipeline.cpp
platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp (264210 => 264211)
--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp 2020-07-10 07:02:30 UTC (rev 264210)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp 2020-07-10 08:01:07 UTC (rev 264211)
@@ -99,9 +99,8 @@
}
}
-AppendPipeline::AppendPipeline(Ref<MediaSourceClientGStreamerMSE> mediaSourceClient, Ref<SourceBufferPrivateGStreamer> sourceBufferPrivate, MediaPlayerPrivateGStreamerMSE& playerPrivate)
- : m_mediaSourceClient(mediaSourceClient.get())
- , m_sourceBufferPrivate(sourceBufferPrivate.get())
+AppendPipeline::AppendPipeline(Ref<SourceBufferPrivateGStreamer> sourceBufferPrivate, MediaPlayerPrivateGStreamerMSE& playerPrivate)
+ : m_sourceBufferPrivate(sourceBufferPrivate.get())
, m_playerPrivate(&playerPrivate)
, m_id(0)
, m_wasBusAlreadyNotifiedOfAvailableSamples(false)
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h (264210 => 264211)
--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h 2020-07-10 07:02:30 UTC (rev 264210)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h 2020-07-10 08:01:07 UTC (rev 264211)
@@ -25,7 +25,6 @@
#include "AbortableTaskQueue.h"
#include "GStreamerCommon.h"
#include "MediaPlayerPrivateGStreamerMSE.h"
-#include "MediaSourceClientGStreamerMSE.h"
#include "SourceBufferPrivateGStreamer.h"
#include <atomic>
@@ -47,7 +46,7 @@
class AppendPipeline {
WTF_MAKE_FAST_ALLOCATED;
public:
- AppendPipeline(Ref<MediaSourceClientGStreamerMSE>, Ref<SourceBufferPrivateGStreamer>, MediaPlayerPrivateGStreamerMSE&);
+ AppendPipeline(Ref<SourceBufferPrivateGStreamer>, MediaPlayerPrivateGStreamerMSE&);
virtual ~AppendPipeline();
void pushNewBuffer(GRefPtr<GstBuffer>&&);
@@ -107,7 +106,6 @@
// Used only for asserting EOS events are only caused by demuxing errors.
bool m_errorReceived { false };
- Ref<MediaSourceClientGStreamerMSE> m_mediaSourceClient;
Ref<SourceBufferPrivateGStreamer> m_sourceBufferPrivate;
MediaPlayerPrivateGStreamerMSE* m_playerPrivate;
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp (264210 => 264211)
--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp 2020-07-10 07:02:30 UTC (rev 264210)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp 2020-07-10 08:01:07 UTC (rev 264211)
@@ -649,16 +649,6 @@
return result;
}
-void MediaPlayerPrivateGStreamerMSE::setMediaSourceClient(Ref<MediaSourceClientGStreamerMSE> client)
-{
- m_mediaSourceClient = client.ptr();
-}
-
-RefPtr<MediaSourceClientGStreamerMSE> MediaPlayerPrivateGStreamerMSE::mediaSourceClient()
-{
- return m_mediaSourceClient;
-}
-
void MediaPlayerPrivateGStreamerMSE::blockDurationChanges()
{
ASSERT(isMainThread());
@@ -681,13 +671,9 @@
void MediaPlayerPrivateGStreamerMSE::durationChanged()
{
ASSERT(isMainThread());
- if (!m_mediaSourceClient) {
- GST_DEBUG("m_mediaSourceClient is null, doing nothing");
- return;
- }
MediaTime previousDuration = m_mediaTimeDuration;
- m_mediaTimeDuration = m_mediaSourceClient->duration();
+ m_mediaTimeDuration = m_mediaSource->duration();
GST_TRACE("previous=%s, new=%s", toString(previousDuration).utf8().data(), toString(m_mediaTimeDuration).utf8().data());
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h (264210 => 264211)
--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h 2020-07-10 07:02:30 UTC (rev 264210)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h 2020-07-10 08:01:07 UTC (rev 264211)
@@ -34,7 +34,6 @@
namespace WebCore {
-class MediaSourceClientGStreamerMSE;
class AppendPipeline;
class PlaybackPipeline;
@@ -41,8 +40,6 @@
class MediaPlayerPrivateGStreamerMSE : public MediaPlayerPrivateGStreamer {
WTF_MAKE_NONCOPYABLE(MediaPlayerPrivateGStreamerMSE); WTF_MAKE_FAST_ALLOCATED;
- friend class MediaSourceClientGStreamerMSE;
-
public:
explicit MediaPlayerPrivateGStreamerMSE(MediaPlayer*);
virtual ~MediaPlayerPrivateGStreamerMSE();
@@ -83,6 +80,8 @@
void blockDurationChanges();
void unblockDurationChanges();
+ PlaybackPipeline* playbackPipeline() const { return m_playbackPipeline.get(); }
+
#if !RELEASE_LOG_DISABLED
WTFLogChannel& logChannel() const final { return WebCore::LogMediaSource; }
#endif
@@ -105,14 +104,10 @@
bool isMediaSource() const override { return true; }
- void setMediaSourceClient(Ref<MediaSourceClientGStreamerMSE>);
- RefPtr<MediaSourceClientGStreamerMSE> mediaSourceClient();
-
bool m_eosMarked = false;
mutable bool m_eosPending = false;
bool m_gstSeekCompleted = true;
RefPtr<MediaSourcePrivateClient> m_mediaSource;
- RefPtr<MediaSourceClientGStreamerMSE> m_mediaSourceClient;
MediaTime m_mediaTimeDuration;
bool m_mseSeekCompleted = true;
bool m_areDurationChangesBlocked = false;
Deleted: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.cpp (264210 => 264211)
--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.cpp 2020-07-10 07:02:30 UTC (rev 264210)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.cpp 2020-07-10 08:01:07 UTC (rev 264211)
@@ -1,175 +0,0 @@
-/*
- * Copyright (C) 2016 Metrological Group B.V.
- * Copyright (C) 2016 Igalia S.L
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * aint with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "MediaSourceClientGStreamerMSE.h"
-
-#include "AppendPipeline.h"
-#include "MediaPlayerPrivateGStreamerMSE.h"
-#include "PlaybackPipeline.h"
-#include "WebKitMediaSourceGStreamer.h"
-#include <gst/gst.h>
-
-GST_DEBUG_CATEGORY_EXTERN(webkit_mse_debug);
-#define GST_CAT_DEFAULT webkit_mse_debug
-
-#if ENABLE(VIDEO) && USE(GSTREAMER) && ENABLE(MEDIA_SOURCE)
-
-namespace WebCore {
-
-Ref<MediaSourceClientGStreamerMSE> MediaSourceClientGStreamerMSE::create(MediaPlayerPrivateGStreamerMSE& playerPrivate)
-{
- ASSERT(WTF::isMainThread());
-
- // No return adoptRef(new MediaSourceClientGStreamerMSE(playerPrivate)) because the ownership has already been transferred to MediaPlayerPrivateGStreamerMSE.
- Ref<MediaSourceClientGStreamerMSE> client(adoptRef(*new MediaSourceClientGStreamerMSE(playerPrivate)));
- playerPrivate.setMediaSourceClient(client.get());
- return client;
-}
-
-MediaSourceClientGStreamerMSE::MediaSourceClientGStreamerMSE(MediaPlayerPrivateGStreamerMSE& playerPrivate)
- : m_playerPrivate(playerPrivate)
-{
- ASSERT(WTF::isMainThread());
-}
-
-MediaSourceClientGStreamerMSE::~MediaSourceClientGStreamerMSE()
-{
- ASSERT(WTF::isMainThread());
-}
-
-MediaSourcePrivate::AddStatus MediaSourceClientGStreamerMSE::addSourceBuffer(RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivate, const ContentType&)
-{
- ASSERT(WTF::isMainThread());
-
- ASSERT(m_playerPrivate.m_playbackPipeline);
- ASSERT(sourceBufferPrivate);
-
- return m_playerPrivate.m_playbackPipeline->addSourceBuffer(sourceBufferPrivate);
-}
-
-MediaTime MediaSourceClientGStreamerMSE::duration()
-{
- ASSERT(WTF::isMainThread());
-
- return m_playerPrivate.mediaSourcePrivateClient()->duration();
-}
-
-void MediaSourceClientGStreamerMSE::durationChanged(const MediaTime& duration)
-{
- ASSERT(WTF::isMainThread());
-
- GST_TRACE("duration: %f", duration.toFloat());
- if (!duration.isValid() || duration.isPositiveInfinite() || duration.isNegativeInfinite())
- return;
-
- m_playerPrivate.durationChanged();
-}
-
-void MediaSourceClientGStreamerMSE::abort(RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivate)
-{
- ASSERT(WTF::isMainThread());
-
- GST_DEBUG("aborting");
-
- sourceBufferPrivate->appendPipeline().resetParserState();
-}
-
-void MediaSourceClientGStreamerMSE::resetParserState(RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivate)
-{
- ASSERT(WTF::isMainThread());
-
- GST_DEBUG("resetting parser state");
-
- sourceBufferPrivate->appendPipeline().resetParserState();
-}
-
-void MediaSourceClientGStreamerMSE::append(RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivate, Vector<unsigned char>&& data)
-{
- ASSERT(WTF::isMainThread());
-
- GST_DEBUG("Appending %zu bytes", data.size());
-
- // Wrap the whole Vector object in case the data is stored in the inlined buffer.
- auto* bufferData = data.data();
- auto bufferLength = data.size();
- GRefPtr<GstBuffer> buffer = adoptGRef(gst_buffer_new_wrapped_full(static_cast<GstMemoryFlags>(0), bufferData, bufferLength, 0, bufferLength, new Vector<unsigned char>(WTFMove(data)),
- [](gpointer data)
- {
- delete static_cast<Vector<unsigned char>*>(data);
- }));
-
- sourceBufferPrivate->appendPipeline().pushNewBuffer(WTFMove(buffer));
-}
-
-void MediaSourceClientGStreamerMSE::markEndOfStream(MediaSourcePrivate::EndOfStreamStatus status)
-{
- ASSERT(WTF::isMainThread());
-
- m_playerPrivate.markEndOfStream(status);
-}
-
-void MediaSourceClientGStreamerMSE::removedFromMediaSource(RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivate)
-{
- ASSERT(WTF::isMainThread());
-
- ASSERT(m_playerPrivate.m_playbackPipeline);
-
- m_playerPrivate.m_playbackPipeline->removeSourceBuffer(sourceBufferPrivate);
-}
-
-void MediaSourceClientGStreamerMSE::flush(AtomString trackId)
-{
- ASSERT(WTF::isMainThread());
-
- // This is only for on-the-fly reenqueues after appends. When seeking, the seek will do its own flush.
- // FIXME: Should not be touching private parts.
- if (!m_playerPrivate.m_isSeeking)
- m_playerPrivate.m_playbackPipeline->flush(trackId);
-}
-
-void MediaSourceClientGStreamerMSE::enqueueSample(Ref<MediaSample>&& sample)
-{
- ASSERT(WTF::isMainThread());
-
- m_playerPrivate.m_playbackPipeline->enqueueSample(WTFMove(sample));
-}
-
-void MediaSourceClientGStreamerMSE::allSamplesInTrackEnqueued(const AtomString& trackId)
-{
- ASSERT(WTF::isMainThread());
-
- m_playerPrivate.m_playbackPipeline->allSamplesInTrackEnqueued(trackId);
-}
-
-GRefPtr<WebKitMediaSrc> MediaSourceClientGStreamerMSE::webKitMediaSrc()
-{
- ASSERT(WTF::isMainThread());
-
- WebKitMediaSrc* source = WEBKIT_MEDIA_SRC(m_playerPrivate.m_source.get());
-
- ASSERT(WEBKIT_IS_MEDIA_SRC(source));
-
- return source;
-}
-
-} // namespace WebCore.
-
-#endif // USE(GSTREAMER)
Deleted: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.h (264210 => 264211)
--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.h 2020-07-10 07:02:30 UTC (rev 264210)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.h 2020-07-10 08:01:07 UTC (rev 264211)
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2016 Metrological Group B.V.
- * Copyright (C) 2016 Igalia S.L
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * aint with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#pragma once
-
-#if ENABLE(VIDEO) && USE(GSTREAMER) && ENABLE(MEDIA_SOURCE)
-
-#include "GStreamerCommon.h"
-#include "MediaSourcePrivate.h"
-#include "MediaSourcePrivateClient.h"
-#include "WebKitMediaSourceGStreamer.h"
-#include <wtf/MediaTime.h>
-
-namespace WebCore {
-
-class ContentType;
-class MediaPlayerPrivateGStreamerMSE;
-class MediaSample;
-class SourceBufferPrivateGStreamer;
-
-class MediaSourceClientGStreamerMSE : public RefCounted<MediaSourceClientGStreamerMSE> {
-public:
- static Ref<MediaSourceClientGStreamerMSE> create(MediaPlayerPrivateGStreamerMSE&);
- virtual ~MediaSourceClientGStreamerMSE();
-
- // From MediaSourcePrivateGStreamer.
- MediaSourcePrivate::AddStatus addSourceBuffer(RefPtr<SourceBufferPrivateGStreamer>, const ContentType&);
- void durationChanged(const MediaTime&);
- void markEndOfStream(MediaSourcePrivate::EndOfStreamStatus);
-
- // From SourceBufferPrivateGStreamer.
- void abort(RefPtr<SourceBufferPrivateGStreamer>);
- void resetParserState(RefPtr<SourceBufferPrivateGStreamer>);
- void append(RefPtr<SourceBufferPrivateGStreamer>, Vector<unsigned char>&&);
- void removedFromMediaSource(RefPtr<SourceBufferPrivateGStreamer>);
- void flush(AtomString);
- void enqueueSample(Ref<MediaSample>&&);
- void allSamplesInTrackEnqueued(const AtomString&);
-
- MediaTime duration();
- GRefPtr<WebKitMediaSrc> webKitMediaSrc();
-
-private:
- MediaSourceClientGStreamerMSE(MediaPlayerPrivateGStreamerMSE&);
-
- MediaPlayerPrivateGStreamerMSE& m_playerPrivate;
-};
-
-} // namespace WebCore.
-
-#endif // USE(GSTREAMER)
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.cpp (264210 => 264211)
--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.cpp 2020-07-10 07:02:30 UTC (rev 264210)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.cpp 2020-07-10 08:01:07 UTC (rev 264211)
@@ -41,8 +41,8 @@
#include "Logging.h"
#include "MediaPlayerPrivateGStreamer.h"
#include "MediaPlayerPrivateGStreamerMSE.h"
-#include "MediaSourceClientGStreamerMSE.h"
#include "NotImplemented.h"
+#include "PlaybackPipeline.h"
#include "SourceBufferPrivateGStreamer.h"
#include "TimeRanges.h"
#include "WebKitMediaSourceGStreamer.h"
@@ -58,7 +58,6 @@
MediaSourcePrivateGStreamer::MediaSourcePrivateGStreamer(MediaSourcePrivateClient& mediaSource, MediaPlayerPrivateGStreamerMSE& playerPrivate)
: MediaSourcePrivate()
- , m_client(MediaSourceClientGStreamerMSE::create(playerPrivate))
, m_mediaSource(mediaSource)
, m_playerPrivate(playerPrivate)
#if !RELEASE_LOG_DISABLED
@@ -78,10 +77,10 @@
MediaSourcePrivateGStreamer::AddStatus MediaSourcePrivateGStreamer::addSourceBuffer(const ContentType& contentType, RefPtr<SourceBufferPrivate>& sourceBufferPrivate)
{
DEBUG_LOG(LOGIDENTIFIER, contentType);
- sourceBufferPrivate = SourceBufferPrivateGStreamer::create(this, m_client.get(), contentType, m_playerPrivate);
+ sourceBufferPrivate = SourceBufferPrivateGStreamer::create(this, contentType, m_playerPrivate);
RefPtr<SourceBufferPrivateGStreamer> sourceBufferPrivateGStreamer = static_cast<SourceBufferPrivateGStreamer*>(sourceBufferPrivate.get());
m_sourceBuffers.add(sourceBufferPrivateGStreamer);
- return m_client->addSourceBuffer(sourceBufferPrivateGStreamer, contentType);
+ return m_playerPrivate.playbackPipeline()->addSourceBuffer(sourceBufferPrivateGStreamer);
}
void MediaSourcePrivateGStreamer::removeSourceBuffer(SourceBufferPrivate* sourceBufferPrivate)
@@ -96,12 +95,20 @@
void MediaSourcePrivateGStreamer::durationChanged()
{
- m_client->durationChanged(m_mediaSource->duration());
+ ASSERT(isMainThread());
+
+ MediaTime duration = m_mediaSource->duration();
+ GST_TRACE("duration: %f", duration.toFloat());
+ if (!duration.isValid() || duration.isPositiveInfinite() || duration.isNegativeInfinite())
+ return;
+
+ m_playerPrivate.durationChanged();
}
void MediaSourcePrivateGStreamer::markEndOfStream(EndOfStreamStatus status)
{
- m_client->markEndOfStream(status);
+ ASSERT(isMainThread());
+ m_playerPrivate.markEndOfStream(status);
}
void MediaSourcePrivateGStreamer::unmarkEndOfStream()
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.h (264210 => 264211)
--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.h 2020-07-10 07:02:30 UTC (rev 264210)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.h 2020-07-10 08:01:07 UTC (rev 264211)
@@ -46,7 +46,6 @@
namespace WebCore {
class SourceBufferPrivateGStreamer;
-class MediaSourceClientGStreamerMSE;
class MediaPlayerPrivateGStreamerMSE;
class PlatformTimeRanges;
@@ -59,7 +58,6 @@
static void open(MediaSourcePrivateClient&, MediaPlayerPrivateGStreamerMSE&);
virtual ~MediaSourcePrivateGStreamer();
- MediaSourceClientGStreamerMSE& client() { return m_client.get(); }
AddStatus addSourceBuffer(const ContentType&, RefPtr<SourceBufferPrivate>&) override;
void removeSourceBuffer(SourceBufferPrivate*);
@@ -91,7 +89,6 @@
HashSet<RefPtr<SourceBufferPrivateGStreamer>> m_sourceBuffers;
HashSet<SourceBufferPrivateGStreamer*> m_activeSourceBuffers;
- Ref<MediaSourceClientGStreamerMSE> m_client;
Ref<MediaSourcePrivateClient> m_mediaSource;
MediaPlayerPrivateGStreamerMSE& m_playerPrivate;
#if !RELEASE_LOG_DISABLED
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp (264210 => 264211)
--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp 2020-07-10 07:02:30 UTC (rev 264210)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp 2020-07-10 08:01:07 UTC (rev 264211)
@@ -42,23 +42,22 @@
#include "GStreamerCommon.h"
#include "MediaPlayerPrivateGStreamerMSE.h"
#include "MediaSample.h"
-#include "MediaSourceClientGStreamerMSE.h"
#include "MediaSourcePrivateGStreamer.h"
#include "NotImplemented.h"
+#include "PlaybackPipeline.h"
#include "WebKitMediaSourceGStreamer.h"
namespace WebCore {
-Ref<SourceBufferPrivateGStreamer> SourceBufferPrivateGStreamer::create(MediaSourcePrivateGStreamer* mediaSource, Ref<MediaSourceClientGStreamerMSE> client, const ContentType& contentType, MediaPlayerPrivateGStreamerMSE& playerPrivate)
+Ref<SourceBufferPrivateGStreamer> SourceBufferPrivateGStreamer::create(MediaSourcePrivateGStreamer* mediaSource, const ContentType& contentType, MediaPlayerPrivateGStreamerMSE& playerPrivate)
{
- return adoptRef(*new SourceBufferPrivateGStreamer(mediaSource, client.get(), contentType, playerPrivate));
+ return adoptRef(*new SourceBufferPrivateGStreamer(mediaSource, contentType, playerPrivate));
}
-SourceBufferPrivateGStreamer::SourceBufferPrivateGStreamer(MediaSourcePrivateGStreamer* mediaSource, Ref<MediaSourceClientGStreamerMSE> client, const ContentType& contentType, MediaPlayerPrivateGStreamerMSE& playerPrivate)
+SourceBufferPrivateGStreamer::SourceBufferPrivateGStreamer(MediaSourcePrivateGStreamer* mediaSource, const ContentType& contentType, MediaPlayerPrivateGStreamerMSE& playerPrivate)
: SourceBufferPrivate()
, m_mediaSource(mediaSource)
, m_type(contentType)
- , m_client(client.get())
, m_playerPrivate(playerPrivate)
#if !RELEASE_LOG_DISABLED
, m_logger(mediaSource->logger())
@@ -66,7 +65,7 @@
#endif
{
relaxAdoptionRequirement();
- m_appendPipeline = WTF::makeUnique<AppendPipeline>(m_client, makeRef(*this), m_playerPrivate);
+ m_appendPipeline = WTF::makeUnique<AppendPipeline>(makeRef(*this), m_playerPrivate);
}
void SourceBufferPrivateGStreamer::setClient(SourceBufferPrivateClient* client)
@@ -76,29 +75,43 @@
void SourceBufferPrivateGStreamer::append(Vector<unsigned char>&& data)
{
+ ASSERT(isMainThread());
ASSERT(m_mediaSource);
+ ASSERT(m_sourceBufferPrivateClient);
- if (!m_sourceBufferPrivateClient)
- return;
+ GST_DEBUG("Appending %zu bytes", data.size());
+ // Wrap the whole Vector object in case the data is stored in the inlined buffer.
+ auto* bufferData = data.data();
+ auto bufferLength = data.size();
+ GRefPtr<GstBuffer> buffer = adoptGRef(gst_buffer_new_wrapped_full(static_cast<GstMemoryFlags>(0), bufferData, bufferLength, 0, bufferLength, new Vector<unsigned char>(WTFMove(data)),
+ [](gpointer data)
+ {
+ delete static_cast<Vector<unsigned char>*>(data);
+ }));
- m_client->append(this, WTFMove(data));
+ m_appendPipeline->pushNewBuffer(WTFMove(buffer));
}
void SourceBufferPrivateGStreamer::abort()
{
- m_client->abort(this);
+ ASSERT(isMainThread());
+ GST_DEBUG("aborting");
+ m_appendPipeline->resetParserState();
}
void SourceBufferPrivateGStreamer::resetParserState()
{
- m_client->resetParserState(this);
+ ASSERT(isMainThread());
+ GST_DEBUG("resetting parser state");
+ m_appendPipeline->resetParserState();
}
void SourceBufferPrivateGStreamer::removedFromMediaSource()
{
+ ASSERT(isMainThread());
if (m_mediaSource)
m_mediaSource->removeSourceBuffer(this);
- m_client->removedFromMediaSource(this);
+ m_playerPrivate.playbackPipeline()->removeSourceBuffer(this);
}
MediaPlayer::ReadyState SourceBufferPrivateGStreamer::readyState() const
@@ -113,19 +126,25 @@
void SourceBufferPrivateGStreamer::flush(const AtomString& trackId)
{
- m_client->flush(trackId);
+ ASSERT(isMainThread());
+
+ // This is only for on-the-fly reenqueues after appends. When seeking, the seek will do its own flush.
+ if (!m_playerPrivate.seeking())
+ m_playerPrivate.playbackPipeline()->flush(trackId);
}
void SourceBufferPrivateGStreamer::enqueueSample(Ref<MediaSample>&& sample, const AtomString&)
{
+ ASSERT(isMainThread());
m_notifyWhenReadyForMoreSamples = false;
- m_client->enqueueSample(WTFMove(sample));
+ m_playerPrivate.playbackPipeline()->enqueueSample(WTFMove(sample));
}
void SourceBufferPrivateGStreamer::allSamplesInTrackEnqueued(const AtomString& trackId)
{
- m_client->allSamplesInTrackEnqueued(trackId);
+ ASSERT(isMainThread());
+ m_playerPrivate.playbackPipeline()->allSamplesInTrackEnqueued(trackId);
}
bool SourceBufferPrivateGStreamer::isReadyForMoreSamples(const AtomString&)
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h (264210 => 264211)
--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h 2020-07-10 07:02:30 UTC (rev 264210)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h 2020-07-10 08:01:07 UTC (rev 264211)
@@ -54,7 +54,7 @@
{
public:
- static Ref<SourceBufferPrivateGStreamer> create(MediaSourcePrivateGStreamer*, Ref<MediaSourceClientGStreamerMSE>, const ContentType&, MediaPlayerPrivateGStreamerMSE&);
+ static Ref<SourceBufferPrivateGStreamer> create(MediaSourcePrivateGStreamer*, const ContentType&, MediaPlayerPrivateGStreamerMSE&);
virtual ~SourceBufferPrivateGStreamer() = default;
void clearMediaSource() { m_mediaSource = nullptr; }
@@ -84,8 +84,6 @@
ContentType type() const { return m_type; }
- AppendPipeline& appendPipeline() { return *m_appendPipeline; }
-
#if !RELEASE_LOG_DISABLED
const Logger& logger() const final { return m_logger.get(); }
const char* logClassName() const override { return "SourceBufferPrivateGStreamer"; }
@@ -96,12 +94,10 @@
#endif
private:
- SourceBufferPrivateGStreamer(MediaSourcePrivateGStreamer*, Ref<MediaSourceClientGStreamerMSE>, const ContentType&, MediaPlayerPrivateGStreamerMSE&);
- friend class MediaSourceClientGStreamerMSE;
+ SourceBufferPrivateGStreamer(MediaSourcePrivateGStreamer*, const ContentType&, MediaPlayerPrivateGStreamerMSE&);
MediaSourcePrivateGStreamer* m_mediaSource;
ContentType m_type;
- Ref<MediaSourceClientGStreamerMSE> m_client;
MediaPlayerPrivateGStreamerMSE& m_playerPrivate;
std::unique_ptr<AppendPipeline> m_appendPipeline;
SourceBufferPrivateClient* m_sourceBufferPrivateClient { nullptr };