зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1276570: Replace TargetQueues enum with bitwise-or flags. r=jwwang
MozReview-Commit-ID: 95rnjumeBf --HG-- extra : rebase_source : bffaaa632cbe2f9d27f82746a85f2089ede6301a
This commit is contained in:
Родитель
6ae7b28edc
Коммит
eaa1d08d90
|
@ -132,13 +132,15 @@ size_t MediaDecoderReader::SizeOfAudioQueueInFrames()
|
|||
return mAudioQueue.GetSize();
|
||||
}
|
||||
|
||||
nsresult MediaDecoderReader::ResetDecode(TargetQueues aQueues /*= AUDIO_VIDEO*/)
|
||||
nsresult MediaDecoderReader::ResetDecode(TrackSet aTracks)
|
||||
{
|
||||
VideoQueue().Reset();
|
||||
mVideoDiscontinuity = true;
|
||||
mBaseVideoPromise.RejectIfExists(CANCELED, __func__);
|
||||
if (aTracks.contains(TrackInfo::kVideoTrack)) {
|
||||
VideoQueue().Reset();
|
||||
mVideoDiscontinuity = true;
|
||||
mBaseVideoPromise.RejectIfExists(CANCELED, __func__);
|
||||
}
|
||||
|
||||
if (aQueues == AUDIO_VIDEO) {
|
||||
if (aTracks.contains(TrackInfo::kAudioTrack)) {
|
||||
AudioQueue().Reset();
|
||||
mAudioDiscontinuity = true;
|
||||
mBaseAudioPromise.RejectIfExists(CANCELED, __func__);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#if !defined(MediaDecoderReader_h_)
|
||||
#define MediaDecoderReader_h_
|
||||
|
||||
#include "mozilla/EnumSet.h"
|
||||
#include "mozilla/MozPromise.h"
|
||||
|
||||
#include "AbstractMediaDecoder.h"
|
||||
|
@ -73,10 +74,7 @@ public:
|
|||
CANCELED
|
||||
};
|
||||
|
||||
enum TargetQueues {
|
||||
VIDEO_ONLY,
|
||||
AUDIO_VIDEO
|
||||
};
|
||||
using TrackSet = EnumSet<TrackInfo::TrackType>;
|
||||
|
||||
using MetadataPromise =
|
||||
MozPromise<RefPtr<MetadataHolder>, ReadMetadataFailureReason, IsExclusive>;
|
||||
|
@ -130,7 +128,11 @@ public:
|
|||
// The first samples of every stream produced after a ResetDecode() call
|
||||
// *must* be marked as "discontinuities". If it's not, seeking work won't
|
||||
// properly!
|
||||
virtual nsresult ResetDecode(TargetQueues aQueues = AUDIO_VIDEO);
|
||||
//
|
||||
// aParam is a set of TrackInfo::TrackType enums specifying which
|
||||
// queues need to be reset, defaulting to both audio and video tracks.
|
||||
virtual nsresult ResetDecode(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack,
|
||||
TrackInfo::kVideoTrack));
|
||||
|
||||
// Requests one audio sample from the reader.
|
||||
//
|
||||
|
|
|
@ -393,21 +393,24 @@ MediaDecoderReaderWrapper::SetIdle()
|
|||
}
|
||||
|
||||
void
|
||||
MediaDecoderReaderWrapper::ResetDecode(TargetQueues aQueues)
|
||||
MediaDecoderReaderWrapper::ResetDecode(TrackSet aTracks)
|
||||
{
|
||||
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
|
||||
|
||||
if (aQueues == MediaDecoderReader::AUDIO_VIDEO) {
|
||||
if (aTracks.contains(TrackInfo::kAudioTrack)) {
|
||||
mAudioDataRequest.DisconnectIfExists();
|
||||
mAudioWaitRequest.DisconnectIfExists();
|
||||
}
|
||||
mVideoDataRequest.DisconnectIfExists();
|
||||
mVideoWaitRequest.DisconnectIfExists();
|
||||
|
||||
if (aTracks.contains(TrackInfo::kVideoTrack)) {
|
||||
mVideoDataRequest.DisconnectIfExists();
|
||||
mVideoWaitRequest.DisconnectIfExists();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> r =
|
||||
NewRunnableMethod<TargetQueues>(mReader,
|
||||
&MediaDecoderReader::ResetDecode,
|
||||
aQueues);
|
||||
NewRunnableMethod<TrackSet>(mReader,
|
||||
&MediaDecoderReader::ResetDecode,
|
||||
aTracks);
|
||||
mReader->OwnerThread()->Dispatch(r.forget());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class MediaDecoderReaderWrapper {
|
|||
typedef MediaDecoderReader::SeekPromise SeekPromise;
|
||||
typedef MediaDecoderReader::WaitForDataPromise WaitForDataPromise;
|
||||
typedef MediaDecoderReader::BufferedUpdatePromise BufferedUpdatePromise;
|
||||
typedef MediaDecoderReader::TargetQueues TargetQueues;
|
||||
typedef MediaDecoderReader::TrackSet TrackSet;
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReaderWrapper);
|
||||
|
||||
/*
|
||||
|
@ -380,7 +380,7 @@ public:
|
|||
|
||||
void ReleaseMediaResources();
|
||||
void SetIdle();
|
||||
void ResetDecode(TargetQueues aQueues);
|
||||
void ResetDecode(TrackSet aTracks);
|
||||
|
||||
nsresult Init() { return mReader->Init(); }
|
||||
bool IsWaitForDataSupported() const { return mReader->IsWaitForDataSupported(); }
|
||||
|
|
|
@ -1427,7 +1427,7 @@ void MediaDecoderStateMachine::InitiateVideoDecodeRecoverySeek()
|
|||
|
||||
// Reset our state machine and decoding pipeline before seeking.
|
||||
if (mSeekTask->NeedToResetMDSM()) {
|
||||
Reset(MediaDecoderReader::VIDEO_ONLY);
|
||||
Reset(TrackInfo::kVideoTrack);
|
||||
}
|
||||
|
||||
// Do the seek.
|
||||
|
@ -2395,7 +2395,7 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
|
|||
}
|
||||
|
||||
void
|
||||
MediaDecoderStateMachine::Reset(MediaDecoderReader::TargetQueues aQueues /*= AUDIO_VIDEO*/)
|
||||
MediaDecoderStateMachine::Reset(TrackSet aTracks)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
DECODER_LOG("MediaDecoderStateMachine::Reset");
|
||||
|
@ -2408,16 +2408,25 @@ MediaDecoderStateMachine::Reset(MediaDecoderReader::TargetQueues aQueues /*= AUD
|
|||
mState == DECODER_STATE_SEEKING ||
|
||||
mState == DECODER_STATE_DORMANT);
|
||||
|
||||
// Assert that aTracks specifies to reset the video track because we
|
||||
// don't currently support resetting just the audio track.
|
||||
MOZ_ASSERT(aTracks.contains(TrackInfo::kVideoTrack));
|
||||
|
||||
mDecodedVideoEndTime = 0;
|
||||
mVideoCompleted = false;
|
||||
VideoQueue().Reset();
|
||||
|
||||
if (aQueues == MediaDecoderReader::AUDIO_VIDEO) {
|
||||
if (aTracks.contains(TrackInfo::kAudioTrack) &&
|
||||
aTracks.contains(TrackInfo::kVideoTrack)) {
|
||||
// Stop the audio thread. Otherwise, MediaSink might be accessing AudioQueue
|
||||
// outside of the decoder monitor while we are clearing the queue and causes
|
||||
// crash for no samples to be popped.
|
||||
StopMediaSink();
|
||||
}
|
||||
|
||||
if (aTracks.contains(TrackInfo::kVideoTrack)) {
|
||||
mDecodedVideoEndTime = 0;
|
||||
mVideoCompleted = false;
|
||||
VideoQueue().Reset();
|
||||
}
|
||||
|
||||
if (aTracks.contains(TrackInfo::kAudioTrack)) {
|
||||
mDecodedAudioEndTime = 0;
|
||||
mAudioCompleted = false;
|
||||
AudioQueue().Reset();
|
||||
|
@ -2428,7 +2437,7 @@ MediaDecoderStateMachine::Reset(MediaDecoderReader::TargetQueues aQueues /*= AUD
|
|||
|
||||
mPlaybackOffset = 0;
|
||||
|
||||
mReader->ResetDecode(aQueues);
|
||||
mReader->ResetDecode(aTracks);
|
||||
}
|
||||
|
||||
int64_t
|
||||
|
|
|
@ -135,6 +135,9 @@ enum class MediaEventType : int8_t {
|
|||
class MediaDecoderStateMachine
|
||||
{
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderStateMachine)
|
||||
|
||||
using TrackSet = MediaDecoderReader::TrackSet;
|
||||
|
||||
public:
|
||||
typedef MediaDecoderOwner::NextFrameStatus NextFrameStatus;
|
||||
typedef mozilla::layers::ImageContainer::FrameID FrameID;
|
||||
|
@ -368,7 +371,8 @@ private:
|
|||
|
||||
// Resets all state related to decoding and playback, emptying all buffers
|
||||
// and aborting all pending operations on the decode task queue.
|
||||
void Reset(MediaDecoderReader::TargetQueues aQueues = MediaDecoderReader::AUDIO_VIDEO);
|
||||
void Reset(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack,
|
||||
TrackInfo::kVideoTrack));
|
||||
|
||||
protected:
|
||||
virtual ~MediaDecoderStateMachine();
|
||||
|
|
|
@ -1343,7 +1343,7 @@ MediaFormatReader::WaitForData(MediaData::Type aType)
|
|||
}
|
||||
|
||||
nsresult
|
||||
MediaFormatReader::ResetDecode(TargetQueues aQueues)
|
||||
MediaFormatReader::ResetDecode(TrackSet aTracks)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
LOGV("");
|
||||
|
@ -1352,15 +1352,22 @@ MediaFormatReader::ResetDecode(TargetQueues aQueues)
|
|||
mSkipRequest.DisconnectIfExists();
|
||||
|
||||
// Do the same for any data wait promises.
|
||||
if (aQueues == AUDIO_VIDEO) {
|
||||
mAudio.mWaitingPromise.RejectIfExists(WaitForDataRejectValue(MediaData::AUDIO_DATA, WaitForDataRejectValue::CANCELED), __func__);
|
||||
if (aTracks.contains(TrackInfo::kAudioTrack)) {
|
||||
mAudio.mWaitingPromise.RejectIfExists(
|
||||
WaitForDataRejectValue(MediaData::AUDIO_DATA,
|
||||
WaitForDataRejectValue::CANCELED), __func__);
|
||||
}
|
||||
|
||||
if (aTracks.contains(TrackInfo::kVideoTrack)) {
|
||||
mVideo.mWaitingPromise.RejectIfExists(
|
||||
WaitForDataRejectValue(MediaData::VIDEO_DATA,
|
||||
WaitForDataRejectValue::CANCELED), __func__);
|
||||
}
|
||||
mVideo.mWaitingPromise.RejectIfExists(WaitForDataRejectValue(MediaData::VIDEO_DATA, WaitForDataRejectValue::CANCELED), __func__);
|
||||
|
||||
// Reset miscellaneous seeking state.
|
||||
mPendingSeekTime.reset();
|
||||
|
||||
if (HasVideo()) {
|
||||
if (HasVideo() && aTracks.contains(TrackInfo::kVideoTrack)) {
|
||||
mVideo.ResetDemuxer();
|
||||
Reset(TrackInfo::kVideoTrack);
|
||||
if (mVideo.HasPromise()) {
|
||||
|
@ -1368,14 +1375,15 @@ MediaFormatReader::ResetDecode(TargetQueues aQueues)
|
|||
}
|
||||
}
|
||||
|
||||
if (HasAudio() && aQueues == AUDIO_VIDEO) {
|
||||
if (HasAudio() && aTracks.contains(TrackInfo::kAudioTrack)) {
|
||||
mAudio.ResetDemuxer();
|
||||
Reset(TrackInfo::kAudioTrack);
|
||||
if (mAudio.HasPromise()) {
|
||||
mAudio.RejectPromise(CANCELED, __func__);
|
||||
}
|
||||
}
|
||||
return MediaDecoderReader::ResetDecode(aQueues);
|
||||
|
||||
return MediaDecoderReader::ResetDecode(aTracks);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
// For Media Resource Management
|
||||
void ReleaseMediaResources() override;
|
||||
|
||||
nsresult ResetDecode(TargetQueues aQueues) override;
|
||||
nsresult ResetDecode(TrackSet aTracks) override;
|
||||
|
||||
RefPtr<ShutdownPromise> Shutdown() override;
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ nsresult AndroidMediaReader::ReadMetadata(MediaInfo* aInfo,
|
|||
RefPtr<ShutdownPromise>
|
||||
AndroidMediaReader::Shutdown()
|
||||
{
|
||||
ResetDecode(AUDIO_VIDEO);
|
||||
ResetDecode();
|
||||
if (mPlugin) {
|
||||
GetAndroidMediaPluginHost()->DestroyDecoder(mPlugin);
|
||||
mPlugin = nullptr;
|
||||
|
@ -104,14 +104,14 @@ AndroidMediaReader::Shutdown()
|
|||
}
|
||||
|
||||
// Resets all state related to decoding, emptying all buffers etc.
|
||||
nsresult AndroidMediaReader::ResetDecode(TargetQueues aQueues)
|
||||
nsresult AndroidMediaReader::ResetDecode(TrackSet aTracks)
|
||||
{
|
||||
if (mLastVideoFrame) {
|
||||
mLastVideoFrame = nullptr;
|
||||
}
|
||||
mSeekRequest.DisconnectIfExists();
|
||||
mSeekPromise.RejectIfExists(NS_OK, __func__);
|
||||
return MediaDecoderReader::ResetDecode(aQueues);
|
||||
return MediaDecoderReader::ResetDecode(aTracks);
|
||||
}
|
||||
|
||||
bool AndroidMediaReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
|
|
|
@ -42,7 +42,8 @@ public:
|
|||
AndroidMediaReader(AbstractMediaDecoder* aDecoder,
|
||||
const nsACString& aContentType);
|
||||
|
||||
nsresult ResetDecode(TargetQueues aQueues) override;
|
||||
nsresult ResetDecode(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack,
|
||||
TrackInfo::kVideoTrack)) override;
|
||||
|
||||
bool DecodeAudioData() override;
|
||||
bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) override;
|
||||
|
|
|
@ -169,17 +169,17 @@ nsresult OggReader::Init() {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult OggReader::ResetDecode(TargetQueues aQueues)
|
||||
nsresult OggReader::ResetDecode(TrackSet aTracks)
|
||||
{
|
||||
return ResetDecode(false, aQueues);
|
||||
return ResetDecode(false, aTracks);
|
||||
}
|
||||
|
||||
nsresult OggReader::ResetDecode(bool start, TargetQueues aQueues)
|
||||
nsresult OggReader::ResetDecode(bool start, TrackSet aTracks)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (NS_FAILED(MediaDecoderReader::ResetDecode(aQueues))) {
|
||||
if (NS_FAILED(MediaDecoderReader::ResetDecode(aTracks))) {
|
||||
res = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,8 @@ protected:
|
|||
|
||||
public:
|
||||
nsresult Init() override;
|
||||
nsresult ResetDecode(TargetQueues aQueues = AUDIO_VIDEO) override;
|
||||
nsresult ResetDecode(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack,
|
||||
TrackInfo::kVideoTrack)) override;
|
||||
bool DecodeAudioData() override;
|
||||
|
||||
// If the Theora granulepos has not been captured, it may read several packets
|
||||
|
@ -86,7 +87,9 @@ private:
|
|||
|
||||
// Specialized Reset() method to signal if the seek is
|
||||
// to the start of the stream.
|
||||
nsresult ResetDecode(bool start, TargetQueues aQueues = AUDIO_VIDEO);
|
||||
nsresult ResetDecode(bool start,
|
||||
TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack,
|
||||
TrackInfo::kVideoTrack));
|
||||
|
||||
nsresult SeekInternal(int64_t aTime, int64_t aEndTime);
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ void MediaOmxReader::ReleaseMediaResources()
|
|||
mMediaResourceRequest.DisconnectIfExists();
|
||||
mMetadataPromise.RejectIfExists(ReadMetadataFailureReason::METADATA_ERROR, __func__);
|
||||
|
||||
ResetDecode(AUDIO_VIDEO);
|
||||
ResetDecode();
|
||||
// Before freeing a video codec, all video buffers needed to be released
|
||||
// even from graphics pipeline.
|
||||
VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
|
||||
|
|
|
@ -74,11 +74,11 @@ protected:
|
|||
void NotifyDataArrivedInternal() override;
|
||||
public:
|
||||
|
||||
nsresult ResetDecode(TargetQueues aQueues) override
|
||||
nsresult ResetDecoder(TrackSet aTracks) override;
|
||||
{
|
||||
mSeekRequest.DisconnectIfExists();
|
||||
mSeekPromise.RejectIfExists(NS_OK, __func__);
|
||||
return MediaDecoderReader::ResetDecode(aQueues);
|
||||
return MediaDecoderReader::ResetDecode(aTracks);
|
||||
}
|
||||
|
||||
bool DecodeAudioData() override;
|
||||
|
|
|
@ -27,10 +27,10 @@ RawReader::~RawReader()
|
|||
MOZ_COUNT_DTOR(RawReader);
|
||||
}
|
||||
|
||||
nsresult RawReader::ResetDecode(TargetQueues aQueues)
|
||||
nsresult RawReader::ResetDecode(TrackSet aTracks)
|
||||
{
|
||||
mCurrentFrame = 0;
|
||||
return MediaDecoderReader::ResetDecode(aQueues);
|
||||
return MediaDecoderReader::ResetDecode(aTracks);
|
||||
}
|
||||
|
||||
nsresult RawReader::ReadMetadata(MediaInfo* aInfo,
|
||||
|
|
|
@ -20,7 +20,7 @@ protected:
|
|||
~RawReader();
|
||||
|
||||
public:
|
||||
nsresult ResetDecode(TargetQueues aQueues) override;
|
||||
nsresult ResetDecode(TrackSet aTracks) override;
|
||||
bool DecodeAudioData() override;
|
||||
|
||||
bool DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
|
|
Загрузка…
Ссылка в новой задаче