Bug 1385699. P3 - remove MediaDecoder::SetInfinite() and related code. r=cpearce

Since inf can be encoded in MDSM::mDuration, we don't need an additional flag
in MediaDecoder to indicate 'infinite' anymore. Note duration change from infinite
to finite is handled by MDSM, so we can remove the explicit calls to SetInfinite(false).

MozReview-Commit-ID: EoxwZJzPAJl

--HG--
extra : rebase_source : 669d7ed5b99a89b1827f60f89e0a21f08a18dedd
extra : source : a30b614784afe8772b2212728c1e4a2eac67f94b
This commit is contained in:
JW Wang 2017-08-01 14:15:29 +08:00
Родитель 42dab72def
Коммит 1ab15ede36
7 изменённых файлов: 8 добавлений и 75 удалений

Просмотреть файл

@ -5505,7 +5505,7 @@ void HTMLMediaElement::PlaybackEnded()
}
}
if (mSrcStream || (mDecoder && mDecoder->IsInfinite())) {
if (mSrcStream) {
LOG(LogLevel::Debug, ("%p, got duration by reaching the end of the resource", this));
DispatchAsyncEvent(NS_LITERAL_STRING("durationchange"));
}

Просмотреть файл

@ -47,15 +47,6 @@ ChannelMediaDecoder::ResourceCallback::GetMediaOwner() const
return mDecoder ? mDecoder->GetOwner() : nullptr;
}
void
ChannelMediaDecoder::ResourceCallback::SetInfinite(bool aInfinite)
{
MOZ_ASSERT(NS_IsMainThread());
if (mDecoder) {
mDecoder->SetInfinite(aInfinite);
}
}
void
ChannelMediaDecoder::ResourceCallback::NotifyNetworkError()
{

Просмотреть файл

@ -35,7 +35,6 @@ class ChannelMediaDecoder : public MediaDecoder
private:
/* MediaResourceCallback functions */
MediaDecoderOwner* GetMediaOwner() const override;
void SetInfinite(bool aInfinite) override;
void NotifyNetworkError() override;
void NotifyDataArrived() override;
void NotifyDataEnded(nsresult aStatus) override;

Просмотреть файл

@ -339,20 +339,11 @@ MediaDecoder::GetDuration()
return mDuration;
}
void
MediaDecoder::SetInfinite(bool aInfinite)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
mInfiniteStream = aInfinite;
DurationChanged();
}
bool
MediaDecoder::IsInfinite() const
{
MOZ_ASSERT(NS_IsMainThread());
return mInfiniteStream;
return mozilla::IsInfinite<double>(mDuration);
}
#define INIT_MIRROR(name, val) \
@ -366,7 +357,6 @@ MediaDecoder::MediaDecoder(MediaDecoderInit& aInit)
, mDuration(std::numeric_limits<double>::quiet_NaN())
, mCDMProxyPromise(mCDMProxyPromiseHolder.Ensure(__func__))
, mIgnoreProgressData(false)
, mInfiniteStream(false)
, mOwner(aInit.mOwner)
, mAbstractMainThread(aInit.mOwner->AbstractMainThread())
, mFrameStats(new FrameStatistics())
@ -762,11 +752,6 @@ MediaDecoder::MetadataLoaded(UniquePtr<MediaInfo> aInfo,
Invalidate();
EnsureTelemetryReported();
// The duration is no longer infinite when we get one from the metadata.
if (mInfo->mMetadataDuration && IsInfinite()) {
SetInfinite(false);
}
}
void
@ -918,12 +903,6 @@ MediaDecoder::PlaybackEnded()
ChangeState(PLAY_STATE_ENDED);
InvalidateWithFlags(VideoFrameContainer::INVALIDATE_FORCE);
GetOwner()->PlaybackEnded();
// This must be called after |GetOwner()->PlaybackEnded()| call above, in
// order to fire the required durationchange.
if (IsInfinite()) {
SetInfinite(false);
}
}
MediaStatistics
@ -1180,9 +1159,10 @@ MediaDecoder::DurationChanged()
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
double oldDuration = mDuration;
if (IsInfinite()) {
mDuration = std::numeric_limits<double>::infinity();
} else if (mExplicitDuration.Ref().isSome()) {
// Use the explicit duration if we have one.
// Otherwise use the duration mirrored from MDSM.
if (mExplicitDuration.Ref().isSome()) {
mDuration = mExplicitDuration.Ref().ref();
} else if (mStateMachineDuration.Ref().isSome()) {
mDuration = mStateMachineDuration.Ref().ref().ToSeconds();

Просмотреть файл

@ -190,7 +190,7 @@ public:
// Return the duration of the video in seconds.
virtual double GetDuration();
// Return true if the stream is infinite (see SetInfinite).
// Return true if the stream is infinite.
bool IsInfinite() const;
// Called as data arrives on the stream and is read into the cache. Called
@ -564,16 +564,6 @@ protected:
// Call on the main thread only.
void DownloadProgressed();
// A media stream is assumed to be infinite if the metadata doesn't
// contain the duration, and range requests are not supported, and
// no headers give a hint of a possible duration (Content-Length,
// Content-Duration, and variants), and we cannot seek in the media
// stream to determine the duration.
//
// When the media stream ends, we can know the duration, thus the stream is
// no longer considered to be infinite.
void SetInfinite(bool aInfinite);
// Called by MediaResource when the "cache suspended" status changes.
// If MediaResource::IsSuspendedByCache returns true, then the decoder
// should stop buffering or otherwise waiting for download progress and
@ -602,9 +592,6 @@ protected:
// from jumping around. Read/Write on the main thread only.
bool mIgnoreProgressData;
// True if the stream is infinite (e.g. a webradio).
bool mInfiniteStream;
// Ensures our media stream has been pinned.
void PinForSeek();

Просмотреть файл

@ -254,25 +254,13 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest)
Unused << hc->GetResponseHeader(NS_LITERAL_CSTRING("Accept-Ranges"),
ranges);
bool acceptsRanges = ranges.EqualsLiteral("bytes");
// True if this channel will not return an unbounded amount of data
bool dataIsBounded = false;
int64_t contentLength = -1;
const bool isCompressed = IsPayloadCompressed(hc);
if (!isCompressed) {
hc->GetContentLength(&contentLength);
}
if (contentLength >= 0 &&
(responseStatus == HTTP_OK_CODE ||
responseStatus == HTTP_PARTIAL_RESPONSE_CODE)) {
// "OK" status means Content-Length is for the whole resource.
// Since that's bounded, we know we have a finite-length resource.
dataIsBounded = true;
}
// Assume Range requests have a bounded upper limit unless the
// Content-Range header tells us otherwise.
bool boundedSeekLimit = true;
// Check response code for byte-range requests (seeking, chunk requests).
// We don't expect to get a 206 response for a compressed stream, but
// double check just to be sure.
@ -291,9 +279,7 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest)
// Notify media cache about the length and start offset of data received.
// Note: If aRangeTotal == -1, then the total bytes is unknown at this stage.
// For now, tell the decoder that the stream is infinite.
if (rangeTotal == -1) {
boundedSeekLimit = false;
} else {
if (rangeTotal != -1) {
contentLength = std::max(contentLength, rangeTotal);
}
// Give some warnings if the ranges are unexpected.
@ -327,13 +313,6 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest)
// and the server isn't sending Accept-Ranges:bytes then we don't
// support seeking. We also can't seek in compressed streams.
seekable = !isCompressed && acceptsRanges;
if (seekable && boundedSeekLimit) {
// If range requests are supported, and we did not see an unbounded
// upper range limit, we assume the resource is bounded.
dataIsBounded = true;
}
mCallback->SetInfinite(!dataIsBounded);
}
mCacheStream.SetTransportSeekable(seekable);

Просмотреть файл

@ -31,9 +31,6 @@ public:
// Returns a weak reference to the media decoder owner.
virtual MediaDecoderOwner* GetMediaOwner() const { return nullptr; }
// Notify is duration is known to this MediaResource.
virtual void SetInfinite(bool aInfinite) {}
// Notify that a network error is encountered.
virtual void NotifyNetworkError() {}