зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1422657) for browser chrome failures on browser_cache.js r=backout on a CLOSED TREE
Backed out changeset 7267883c2b72 (bug 1422657) Backed out changeset 9c77dddb2fac (bug 1422657)
This commit is contained in:
Родитель
dfd58840d1
Коммит
bc723a6e7e
|
@ -159,4 +159,13 @@ BaseMediaResource::ModifyLoadFlags(nsLoadFlags aFlags)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
BaseMediaResource::DispatchBytesConsumed(int64_t aNumBytes, int64_t aOffset)
|
||||
{
|
||||
if (aNumBytes <= 0) {
|
||||
return;
|
||||
}
|
||||
mCallback->NotifyBytesConsumed(aNumBytes, aOffset);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -129,6 +129,10 @@ protected:
|
|||
// then the request is added back to the load group.
|
||||
void ModifyLoadFlags(nsLoadFlags aFlags);
|
||||
|
||||
// Dispatches an event to call MediaDecoder::NotifyBytesConsumed(aNumBytes, aOffset)
|
||||
// on the main thread. This is called automatically after every read.
|
||||
void DispatchBytesConsumed(int64_t aNumBytes, int64_t aOffset);
|
||||
|
||||
RefPtr<MediaResourceCallback> mCallback;
|
||||
|
||||
// Channel used to download the media data. Must be accessed
|
||||
|
|
|
@ -131,11 +131,30 @@ ChannelMediaDecoder::ResourceCallback::NotifySuspendedStatusChanged(
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
ChannelMediaDecoder::ResourceCallback::NotifyBytesConsumed(int64_t aBytes,
|
||||
int64_t aOffset)
|
||||
{
|
||||
RefPtr<ResourceCallback> self = this;
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
|
||||
"ChannelMediaDecoder::ResourceCallback::NotifyBytesConsumed",
|
||||
[=]() {
|
||||
if (self->mDecoder) {
|
||||
self->mDecoder->NotifyBytesConsumed(aBytes, aOffset);
|
||||
}
|
||||
});
|
||||
mAbstractMainThread->Dispatch(r.forget());
|
||||
}
|
||||
|
||||
ChannelMediaDecoder::ChannelMediaDecoder(MediaDecoderInit& aInit)
|
||||
: MediaDecoder(aInit)
|
||||
, mResourceCallback(new ResourceCallback(aInit.mOwner->AbstractMainThread()))
|
||||
, mWatchManager(this, aInit.mOwner->AbstractMainThread())
|
||||
{
|
||||
mResourceCallback->Connect(this);
|
||||
|
||||
// mIgnoreProgressData
|
||||
mWatchManager.Watch(mLogicallySeeking, &ChannelMediaDecoder::SeekingChanged);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -202,6 +221,7 @@ MediaDecoderStateMachine* ChannelMediaDecoder::CreateStateMachine()
|
|||
void
|
||||
ChannelMediaDecoder::Shutdown()
|
||||
{
|
||||
mWatchManager.Shutdown();
|
||||
mResourceCallback->Disconnect();
|
||||
MediaDecoder::Shutdown();
|
||||
|
||||
|
@ -288,6 +308,30 @@ ChannelMediaDecoder::NotifyDownloadEnded(nsresult aStatus)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
ChannelMediaDecoder::NotifyBytesConsumed(int64_t aBytes, int64_t aOffset)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
|
||||
AbstractThread::AutoEnter context(AbstractMainThread());
|
||||
|
||||
if (mIgnoreProgressData) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(GetStateMachine());
|
||||
mDecoderPosition = aOffset + aBytes;
|
||||
}
|
||||
|
||||
void
|
||||
ChannelMediaDecoder::SeekingChanged()
|
||||
{
|
||||
// Stop updating the bytes downloaded for progress notifications when
|
||||
// seeking to prevent wild changes to the progress notification.
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mIgnoreProgressData = mLogicallySeeking;
|
||||
}
|
||||
|
||||
bool
|
||||
ChannelMediaDecoder::CanPlayThroughImpl()
|
||||
{
|
||||
|
@ -400,7 +444,7 @@ ChannelMediaDecoder::GetStatistics(const PlaybackRateInfo& aInfo)
|
|||
MediaStatistics result;
|
||||
result.mDownloadRate =
|
||||
mResource->GetDownloadRate(&result.mDownloadRateReliable);
|
||||
result.mDownloadPosition = mResource->GetCachedDataEnd(mPlaybackPosition);
|
||||
result.mDownloadPosition = mResource->GetCachedDataEnd(mDecoderPosition);
|
||||
result.mTotalBytes = mResource->GetLength();
|
||||
result.mPlaybackRate = aInfo.mRate;
|
||||
result.mPlaybackRateReliable = aInfo.mReliable;
|
||||
|
|
|
@ -44,6 +44,7 @@ class ChannelMediaDecoder : public MediaDecoder
|
|||
void NotifyDataEnded(nsresult aStatus) override;
|
||||
void NotifyPrincipalChanged() override;
|
||||
void NotifySuspendedStatusChanged(bool aSuspendedByCache) override;
|
||||
void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) override;
|
||||
|
||||
static void TimerCallback(nsITimer* aTimer, void* aClosure);
|
||||
|
||||
|
@ -114,6 +115,8 @@ private:
|
|||
// by the MediaResource read functions.
|
||||
void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset);
|
||||
|
||||
void SeekingChanged();
|
||||
|
||||
bool CanPlayThroughImpl() override final;
|
||||
|
||||
bool IsLiveStream() override final;
|
||||
|
@ -138,6 +141,14 @@ private:
|
|||
|
||||
bool ShouldThrottleDownload(const MediaStatistics& aStats);
|
||||
|
||||
WatchManager<ChannelMediaDecoder> mWatchManager;
|
||||
|
||||
// True when seeking or otherwise moving the play position around in
|
||||
// such a manner that progress event data is inaccurate. This is set
|
||||
// during seek and duration operations to prevent the progress indicator
|
||||
// from jumping around. Read/Write on the main thread only.
|
||||
bool mIgnoreProgressData = false;
|
||||
|
||||
// Data needed to estimate playback data rate. The timeline used for
|
||||
// this estimate is "decode time" (where the "current time" is the
|
||||
// time of the last decoded video frame).
|
||||
|
|
|
@ -621,7 +621,12 @@ nsresult ChannelMediaResource::ReadAt(int64_t aOffset,
|
|||
uint32_t* aBytes)
|
||||
{
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
|
||||
return mCacheStream.ReadAt(aOffset, aBuffer, aCount, aBytes);
|
||||
|
||||
nsresult rv = mCacheStream.ReadAt(aOffset, aBuffer, aCount, aBytes);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
DispatchBytesConsumed(*aBytes, aOffset);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -171,6 +171,9 @@ FileMediaResource::ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount,
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
rv = UnsafeRead(aBuffer, aCount, aBytes);
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
DispatchBytesConsumed(*aBytes, aOffset);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -648,6 +648,12 @@ protected:
|
|||
// background.
|
||||
bool mIsBackgroundVideoDecodingAllowed;
|
||||
|
||||
// Current decoding position in the stream. This is where the decoder
|
||||
// is up to consuming the stream. This is not adjusted during decoder
|
||||
// seek operations, but it's updated at the end when we start playing
|
||||
// back again.
|
||||
int64_t mDecoderPosition = 0;
|
||||
|
||||
public:
|
||||
AbstractCanonical<double>* CanonicalVolume() { return &mVolume; }
|
||||
AbstractCanonical<bool>* CanonicalPreservesPitch()
|
||||
|
|
|
@ -53,6 +53,9 @@ public:
|
|||
// Notify that the "cache suspended" status of MediaResource changes.
|
||||
virtual void NotifySuspendedStatusChanged(bool aSuspendedByCache) {}
|
||||
|
||||
// Notify the number of bytes read from the resource.
|
||||
virtual void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) {}
|
||||
|
||||
protected:
|
||||
virtual ~MediaResourceCallback() {}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче