Skip to content

Commit 69f968c

Browse files
committed
[MSE][GStreamer] refactored backend
Samples are now appended/parsed in a separate pipeline. Playback is handled in a separate MediaPlayerPrivate Patch by Enrique Ocaña <eocanha@igalia.com> and Philippe Normand <pnormand@igalia.com>
1 parent 4c4fc38 commit 69f968c

18 files changed

+3079
-1906
lines changed

Source/WebCore/Modules/mediasource/MediaSource.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ void MediaSource::seekToTime(const MediaTime& time)
188188

189189
m_pendingSeekTime = time;
190190

191+
LOG(MediaSource, "MediaSource::seekToTime(%p, %f): %lu active source buffers", this, time.toDouble(), m_activeSourceBuffers->length());
191192
// Run the following steps as part of the "Wait until the user agent has established whether or not the
192193
// media data for the new playback position is available, and, if it is, until it has decoded enough data
193194
// to play back that position" step of the seek algorithm:
@@ -206,7 +207,8 @@ void MediaSource::seekToTime(const MediaTime& time)
206207
LOG(MediaSource, "MediaSource::seekToTime(%p) - waitForSeekCompleted()", this);
207208
m_private->waitForSeekCompleted();
208209
return;
209-
}
210+
} else
211+
LOG(MediaSource, "MediaSource::seekToTime(%p) - seek time buffered already.", this);
210212
// ↳ Otherwise
211213
// Continue
212214
}

Source/WebCore/PlatformWPE.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ list(APPEND WebCore_SOURCES
117117
platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp
118118
platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
119119
platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
120+
platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.cpp
120121
platform/graphics/gstreamer/MediaSourceGStreamer.cpp
121122
platform/graphics/gstreamer/SourceBufferPrivateGStreamer.cpp
122123
platform/graphics/gstreamer/TextCombinerGStreamer.cpp

Source/WebCore/html/track/InbandGenericTextTrack.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ void InbandGenericTextTrack::addGenericCue(InbandTextTrackPrivate* trackPrivate,
154154
RefPtr<TextTrackCueGeneric> cue = TextTrackCueGeneric::create(*scriptExecutionContext(), cueData->startTime(), cueData->endTime(), cueData->content());
155155
updateCueFromCueData(cue.get(), cueData.get());
156156
if (hasCue(cue.get(), TextTrackCue::IgnoreDuration)) {
157-
LOG(Media, "InbandGenericTextTrack::addGenericCue ignoring already added cue: start=%s, end=%s, content=\"%s\"\n", toString(cueData->startTime()).utf8().data(), toString(cueData->endTime()).utf8().data(), cueData->content().utf8().data());
157+
LOG(Media, "InbandGenericTextTrack::addGenericCue ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"", cueData->startTime().toDouble(), cueData->endTime().toDouble(), cueData->content().utf8().data());
158158
return;
159159
}
160160

161-
LOG(Media, "InbandGenericTextTrack::addGenericCue added cue: start=%.2f, end=%.2f, content=\"%s\"\n", cueData->startTime().toDouble(), cueData->endTime().toDouble(), cueData->content().utf8().data());
161+
LOG(Media, "InbandGenericTextTrack::addGenericCue added cue: start=%.2f, end=%.2f, content=\"%s\"", cueData->startTime().toDouble(), cueData->endTime().toDouble(), cueData->content().utf8().data());
162162

163163
if (cueData->status() != GenericCueData::Complete)
164164
m_cueMap.add(cueData.get(), cue.get());
@@ -182,10 +182,10 @@ void InbandGenericTextTrack::removeGenericCue(InbandTextTrackPrivate*, GenericCu
182182
{
183183
RefPtr<TextTrackCueGeneric> cue = m_cueMap.find(cueData);
184184
if (cue) {
185-
LOG(Media, "InbandGenericTextTrack::removeGenericCue removing cue: start=%s, end=%s, content=\"%s\"\n", toString(cueData->startTime()).utf8().data(), toString(cueData->endTime()).utf8().data(), cueData->content().utf8().data());
185+
LOG(Media, "InbandGenericTextTrack::removeGenericCue removing cue: start=%.2f, end=%.2f, content=\"%s\"", cueData->startTime().toDouble(), cueData->endTime().toDouble(), cueData->content().utf8().data());
186186
removeCue(cue.get(), IGNORE_EXCEPTION);
187187
} else {
188-
LOG(Media, "InbandGenericTextTrack::removeGenericCue UNABLE to find cue: start=%.2f, end=%.2f, content=\"%s\"\n", cueData->startTime().toDouble(), cueData->endTime().toDouble(), cueData->content().utf8().data());
188+
LOG(Media, "InbandGenericTextTrack::removeGenericCue UNABLE to find cue: start=%.2f, end=%.2f, content=\"%s\"", cueData->startTime().toDouble(), cueData->endTime().toDouble(), cueData->content().utf8().data());
189189
m_cueMap.remove(cueData);
190190
}
191191
}
@@ -224,7 +224,7 @@ void InbandGenericTextTrack::newCuesParsed()
224224
RefPtr<VTTCue> vttCue = VTTCue::create(*scriptExecutionContext(), *cueData);
225225

226226
if (hasCue(vttCue.get(), TextTrackCue::IgnoreDuration)) {
227-
LOG(Media, "InbandGenericTextTrack::newCuesParsed ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"\n", vttCue->startTime(), vttCue->endTime(), vttCue->text().utf8().data());
227+
LOG(Media, "InbandGenericTextTrack::newCuesParsed ignoring already added cue: start=%.2f, end=%.2f, content=\"%s\"", vttCue->startTime(), vttCue->endTime(), vttCue->text().utf8().data());
228228
return;
229229
}
230230
addCue(vttCue.release(), ASSERT_NO_EXCEPTION);

Source/WebCore/platform/graphics/MediaPlayer.cpp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@
5454
#if USE(GSTREAMER)
5555
#include "MediaPlayerPrivateGStreamer.h"
5656
#define PlatformMediaEngineClassName MediaPlayerPrivateGStreamer
57+
#if ENABLE(VIDEO) && ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK)
58+
#include "MediaPlayerPrivateGStreamerMSE.h"
5759
#endif
60+
#endif // USE(GSTREAMER)
5861

5962
#if USE(MEDIA_FOUNDATION)
6063
#include "MediaPlayerPrivateMediaFoundation.h"
@@ -205,6 +208,10 @@ static void buildMediaEnginesVector()
205208
PlatformMediaEngineClassName::registerMediaEngine(addMediaEngine);
206209
#endif
207210

211+
#if ENABLE(VIDEO) && USE(GSTREAMER) && ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK)
212+
MediaPlayerPrivateGStreamerMSE::registerMediaEngine(addMediaEngine);
213+
#endif
214+
208215
haveMediaEnginesVector = true;
209216
}
210217

@@ -245,15 +252,17 @@ static const AtomicString& codecs()
245252

246253
static const MediaPlayerFactory* bestMediaEngineForSupportParameters(const MediaEngineSupportParameters& parameters, const MediaPlayerFactory* current = nullptr)
247254
{
248-
if (parameters.type.isEmpty() && !parameters.isMediaSource && !parameters.isMediaStream)
249-
return nullptr;
250-
251-
// 4.8.10.3 MIME types - In the absence of a specification to the contrary, the MIME type "application/octet-stream"
252-
// when used with parameters, e.g. "application/octet-stream;codecs=theora", is a type that the user agent knows
253-
// it cannot render.
254-
if (parameters.type == applicationOctetStream()) {
255-
if (!parameters.codecs.isEmpty())
255+
if (!parameters.isMediaSource && !parameters.isMediaStream) {
256+
if (parameters.type.isEmpty())
256257
return nullptr;
258+
259+
// 4.8.10.3 MIME types - In the absence of a specification to the contrary, the MIME type "application/octet-stream"
260+
// when used with parameters, e.g. "application/octet-stream;codecs=theora", is a type that the user agent knows
261+
// it cannot render.
262+
if (parameters.type == applicationOctetStream()) {
263+
if (!parameters.codecs.isEmpty())
264+
return nullptr;
265+
}
257266
}
258267

259268
const MediaPlayerFactory* foundEngine = nullptr;
@@ -421,6 +430,11 @@ void MediaPlayer::loadWithNextMediaEngine(const MediaPlayerFactory* current)
421430
if (!m_contentMIMEType.isEmpty() || MEDIASTREAM || MEDIASOURCE)
422431
engine = nextBestMediaEngine(current);
423432

433+
#if ENABLE(MEDIA_SOURCE)
434+
if (m_mediaSource)
435+
engine = nextBestMediaEngine(current);
436+
#endif
437+
424438
// If no MIME type is specified or the type was inferred from the file extension, just use the next engine.
425439
if (!engine && (m_contentMIMEType.isEmpty() || m_contentMIMETypeWasInferredFromExtension))
426440
engine = nextMediaEngine(current);

Source/WebCore/platform/graphics/SourceBufferPrivate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#if ENABLE(MEDIA_SOURCE)
3535

3636
#include "MediaPlayer.h"
37+
#include "SourceBufferPrivateClient.h"
3738
#include <wtf/RefCounted.h>
3839
#include <wtf/Vector.h>
3940

@@ -49,6 +50,7 @@ class SourceBufferPrivate : public RefCounted<SourceBufferPrivate> {
4950
virtual void setClient(SourceBufferPrivateClient*) = 0;
5051

5152
virtual void append(const unsigned char* data, unsigned length) = 0;
53+
virtual void appendComplete(SourceBufferPrivateClient::AppendResult) { };
5254
virtual void abort() = 0;
5355
virtual void removedFromMediaSource() = 0;
5456

0 commit comments

Comments
 (0)