зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1349145. P1 - revert the changes in bug 1203047 for MediaDecoderReader and its friends. r=jya
MozReview-Commit-ID: IghzDRwvd9S --HG-- extra : rebase_source : d686c3a13af56b508c14e81d59417b715ffdd940
This commit is contained in:
Родитель
de31f33e82
Коммит
4dde56f760
|
@ -153,11 +153,11 @@ nsresult MediaDecoderReader::ResetDecode(TrackSet aTracks)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
RefPtr<MediaDecoderReader::MediaDataPromise>
|
||||
RefPtr<MediaDecoderReader::VideoDataPromise>
|
||||
MediaDecoderReader::DecodeToFirstVideoData()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
typedef MediaDecoderReader::MediaDataPromise PromiseType;
|
||||
typedef VideoDataPromise PromiseType;
|
||||
RefPtr<PromiseType::Private> p = new PromiseType::Private(__func__);
|
||||
RefPtr<MediaDecoderReader> self = this;
|
||||
InvokeUntil([self] () -> bool {
|
||||
|
@ -285,11 +285,11 @@ private:
|
|||
RefPtr<MediaDecoderReader> mReader;
|
||||
};
|
||||
|
||||
RefPtr<MediaDecoderReader::MediaDataPromise>
|
||||
RefPtr<MediaDecoderReader::VideoDataPromise>
|
||||
MediaDecoderReader::RequestVideoData(bool aSkipToNextKeyframe,
|
||||
int64_t aTimeThreshold)
|
||||
{
|
||||
RefPtr<MediaDataPromise> p = mBaseVideoPromise.Ensure(__func__);
|
||||
RefPtr<VideoDataPromise> p = mBaseVideoPromise.Ensure(__func__);
|
||||
bool skip = aSkipToNextKeyframe;
|
||||
while (VideoQueue().GetSize() == 0 &&
|
||||
!VideoQueue().IsFinished()) {
|
||||
|
@ -317,10 +317,10 @@ MediaDecoderReader::RequestVideoData(bool aSkipToNextKeyframe,
|
|||
return p;
|
||||
}
|
||||
|
||||
RefPtr<MediaDecoderReader::MediaDataPromise>
|
||||
RefPtr<MediaDecoderReader::AudioDataPromise>
|
||||
MediaDecoderReader::RequestAudioData()
|
||||
{
|
||||
RefPtr<MediaDataPromise> p = mBaseAudioPromise.Ensure(__func__);
|
||||
RefPtr<AudioDataPromise> p = mBaseAudioPromise.Ensure(__func__);
|
||||
while (AudioQueue().GetSize() == 0 &&
|
||||
!AudioQueue().IsFinished()) {
|
||||
if (!DecodeAudioData()) {
|
||||
|
|
|
@ -84,8 +84,12 @@ public:
|
|||
|
||||
using MetadataPromise =
|
||||
MozPromise<RefPtr<MetadataHolder>, MediaResult, IsExclusive>;
|
||||
using MediaDataPromise =
|
||||
MozPromise<RefPtr<MediaData>, MediaResult, IsExclusive>;
|
||||
|
||||
template <typename Type>
|
||||
using DataPromise = MozPromise<RefPtr<Type>, MediaResult, IsExclusive>;
|
||||
using AudioDataPromise = DataPromise<AudioData>;
|
||||
using VideoDataPromise = DataPromise<VideoData>;
|
||||
|
||||
using SeekPromise = MozPromise<media::TimeUnit, SeekRejectValue, IsExclusive>;
|
||||
|
||||
// Note that, conceptually, WaitForData makes sense in a non-exclusive sense.
|
||||
|
@ -140,13 +144,13 @@ public:
|
|||
//
|
||||
// The decode should be performed asynchronously, and the promise should
|
||||
// be resolved when it is complete.
|
||||
virtual RefPtr<MediaDataPromise> RequestAudioData();
|
||||
virtual RefPtr<AudioDataPromise> RequestAudioData();
|
||||
|
||||
// Requests one video sample from the reader.
|
||||
//
|
||||
// If aSkipToKeyframe is true, the decode should skip ahead to the
|
||||
// the next keyframe at or after aTimeThreshold microseconds.
|
||||
virtual RefPtr<MediaDataPromise>
|
||||
virtual RefPtr<VideoDataPromise>
|
||||
RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold);
|
||||
|
||||
// By default, the state machine polls the reader once per second when it's
|
||||
|
@ -271,7 +275,7 @@ protected:
|
|||
// Recomputes mBuffered.
|
||||
virtual void UpdateBuffered();
|
||||
|
||||
RefPtr<MediaDataPromise> DecodeToFirstVideoData();
|
||||
RefPtr<VideoDataPromise> DecodeToFirstVideoData();
|
||||
|
||||
// Queue of audio frames. This queue is threadsafe, and is accessed from
|
||||
// the audio, decoder, state machine, and main threads.
|
||||
|
@ -377,8 +381,8 @@ private:
|
|||
|
||||
// Promises used only for the base-class (sync->async adapter) implementation
|
||||
// of Request{Audio,Video}Data.
|
||||
MozPromiseHolder<MediaDataPromise> mBaseAudioPromise;
|
||||
MozPromiseHolder<MediaDataPromise> mBaseVideoPromise;
|
||||
MozPromiseHolder<AudioDataPromise> mBaseAudioPromise;
|
||||
MozPromiseHolder<VideoDataPromise> mBaseVideoPromise;
|
||||
|
||||
MediaEventListener mDataArrivedListener;
|
||||
};
|
||||
|
|
|
@ -42,7 +42,7 @@ MediaDecoderReaderWrapper::ReadMetadata()
|
|||
&MediaDecoderReaderWrapper::OnMetadataNotRead);
|
||||
}
|
||||
|
||||
RefPtr<MediaDecoderReaderWrapper::MediaDataPromise>
|
||||
RefPtr<MediaDecoderReaderWrapper::AudioDataPromise>
|
||||
MediaDecoderReaderWrapper::RequestAudioData()
|
||||
{
|
||||
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
|
||||
|
@ -52,13 +52,13 @@ MediaDecoderReaderWrapper::RequestAudioData()
|
|||
return InvokeAsync(mReader->OwnerThread(), mReader.get(),
|
||||
__func__, &MediaDecoderReader::RequestAudioData)
|
||||
->Then(mOwnerThread, __func__,
|
||||
[startTime] (MediaData* aAudio) {
|
||||
[startTime] (AudioData* aAudio) {
|
||||
aAudio->AdjustForStartTime(startTime);
|
||||
},
|
||||
[] (const MediaResult& aError) {});
|
||||
}
|
||||
|
||||
RefPtr<MediaDecoderReaderWrapper::MediaDataPromise>
|
||||
RefPtr<MediaDecoderReaderWrapper::VideoDataPromise>
|
||||
MediaDecoderReaderWrapper::RequestVideoData(bool aSkipToNextKeyframe,
|
||||
media::TimeUnit aTimeThreshold)
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ MediaDecoderReaderWrapper::RequestVideoData(bool aSkipToNextKeyframe,
|
|||
&MediaDecoderReader::RequestVideoData,
|
||||
aSkipToNextKeyframe, aTimeThreshold.ToMicroseconds())
|
||||
->Then(mOwnerThread, __func__,
|
||||
[startTime] (MediaData* aVideo) {
|
||||
[startTime] (VideoData* aVideo) {
|
||||
aVideo->AdjustForStartTime(startTime);
|
||||
},
|
||||
[] (const MediaResult& aError) {});
|
||||
|
|
|
@ -25,7 +25,8 @@ namespace mozilla {
|
|||
*/
|
||||
class MediaDecoderReaderWrapper {
|
||||
typedef MediaDecoderReader::MetadataPromise MetadataPromise;
|
||||
typedef MediaDecoderReader::MediaDataPromise MediaDataPromise;
|
||||
typedef MediaDecoderReader::AudioDataPromise AudioDataPromise;
|
||||
typedef MediaDecoderReader::VideoDataPromise VideoDataPromise;
|
||||
typedef MediaDecoderReader::SeekPromise SeekPromise;
|
||||
typedef MediaDecoderReader::WaitForDataPromise WaitForDataPromise;
|
||||
typedef MediaDecoderReader::TrackSet TrackSet;
|
||||
|
@ -38,9 +39,9 @@ public:
|
|||
media::TimeUnit StartTime() const;
|
||||
RefPtr<MetadataPromise> ReadMetadata();
|
||||
|
||||
RefPtr<MediaDataPromise> RequestAudioData();
|
||||
RefPtr<AudioDataPromise> RequestAudioData();
|
||||
|
||||
RefPtr<MediaDataPromise>
|
||||
RefPtr<VideoDataPromise>
|
||||
RequestVideoData(bool aSkipToNextKeyframe, media::TimeUnit aTimeThreshold);
|
||||
|
||||
RefPtr<WaitForDataPromise> WaitForData(MediaData::Type aType);
|
||||
|
|
|
@ -613,10 +613,11 @@ private:
|
|||
|
||||
// Only one of a given pair of ({Audio,Video}DataPromise, WaitForDataPromise)
|
||||
// should exist at any given moment.
|
||||
using MediaDataPromise = MediaDecoderReader::MediaDataPromise;
|
||||
using AudioDataPromise = MediaDecoderReader::AudioDataPromise;
|
||||
using VideoDataPromise = MediaDecoderReader::VideoDataPromise;
|
||||
using WaitForDataPromise = MediaDecoderReader::WaitForDataPromise;
|
||||
MozPromiseRequestHolder<MediaDataPromise> mAudioDataRequest;
|
||||
MozPromiseRequestHolder<MediaDataPromise> mVideoDataRequest;
|
||||
MozPromiseRequestHolder<AudioDataPromise> mAudioDataRequest;
|
||||
MozPromiseRequestHolder<VideoDataPromise> mVideoDataRequest;
|
||||
MozPromiseRequestHolder<WaitForDataPromise> mAudioWaitRequest;
|
||||
MozPromiseRequestHolder<WaitForDataPromise> mVideoWaitRequest;
|
||||
|
||||
|
|
|
@ -1513,7 +1513,7 @@ MediaFormatReader::ShouldSkip(bool aSkipToNextKeyframe,
|
|||
&& !nextKeyframe.IsInfinite();
|
||||
}
|
||||
|
||||
RefPtr<MediaDecoderReader::MediaDataPromise>
|
||||
RefPtr<MediaDecoderReader::VideoDataPromise>
|
||||
MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe,
|
||||
int64_t aTimeThreshold)
|
||||
{
|
||||
|
@ -1528,19 +1528,19 @@ MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe,
|
|||
|
||||
if (!HasVideo()) {
|
||||
LOG("called with no video track");
|
||||
return MediaDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR,
|
||||
return VideoDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR,
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (IsSeeking()) {
|
||||
LOG("called mid-seek. Rejecting.");
|
||||
return MediaDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CANCELED,
|
||||
return VideoDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CANCELED,
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (mShutdown) {
|
||||
NS_WARNING("RequestVideoData on shutdown MediaFormatReader!");
|
||||
return MediaDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CANCELED,
|
||||
return VideoDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CANCELED,
|
||||
__func__);
|
||||
}
|
||||
|
||||
|
@ -1550,12 +1550,12 @@ MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe,
|
|||
// information.
|
||||
if (!mVideo.HasInternalSeekPending()
|
||||
&& ShouldSkip(aSkipToNextKeyframe, timeThreshold)) {
|
||||
RefPtr<MediaDataPromise> p = mVideo.EnsurePromise(__func__);
|
||||
RefPtr<VideoDataPromise> p = mVideo.EnsurePromise(__func__);
|
||||
SkipVideoDemuxToNextKeyFrame(timeThreshold);
|
||||
return p;
|
||||
}
|
||||
|
||||
RefPtr<MediaDataPromise> p = mVideo.EnsurePromise(__func__);
|
||||
RefPtr<VideoDataPromise> p = mVideo.EnsurePromise(__func__);
|
||||
ScheduleUpdate(TrackInfo::kVideoTrack);
|
||||
|
||||
return p;
|
||||
|
@ -1630,7 +1630,7 @@ MediaFormatReader::OnVideoDemuxCompleted(
|
|||
ScheduleUpdate(TrackInfo::kVideoTrack);
|
||||
}
|
||||
|
||||
RefPtr<MediaDecoderReader::MediaDataPromise>
|
||||
RefPtr<MediaDecoderReader::AudioDataPromise>
|
||||
MediaFormatReader::RequestAudioData()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
|
@ -1645,23 +1645,23 @@ MediaFormatReader::RequestAudioData()
|
|||
|
||||
if (!HasAudio()) {
|
||||
LOG("called with no audio track");
|
||||
return MediaDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR,
|
||||
return AudioDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR,
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (IsSeeking()) {
|
||||
LOG("called mid-seek. Rejecting.");
|
||||
return MediaDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CANCELED,
|
||||
return AudioDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CANCELED,
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (mShutdown) {
|
||||
NS_WARNING("RequestAudioData on shutdown MediaFormatReader!");
|
||||
return MediaDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CANCELED,
|
||||
return AudioDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CANCELED,
|
||||
__func__);
|
||||
}
|
||||
|
||||
RefPtr<MediaDataPromise> p = mAudio.EnsurePromise(__func__);
|
||||
RefPtr<AudioDataPromise> p = mAudio.EnsurePromise(__func__);
|
||||
ScheduleUpdate(TrackInfo::kAudioTrack);
|
||||
|
||||
return p;
|
||||
|
@ -2379,7 +2379,7 @@ MediaFormatReader::ReturnOutput(MediaData* aData, TrackType aTrack)
|
|||
mInfo.mAudio.mRate = audioData->mRate;
|
||||
mInfo.mAudio.mChannels = audioData->mChannels;
|
||||
}
|
||||
mAudio.ResolvePromise(aData, __func__);
|
||||
mAudio.ResolvePromise(audioData, __func__);
|
||||
} else if (aTrack == TrackInfo::kVideoTrack) {
|
||||
VideoData* videoData = static_cast<VideoData*>(aData);
|
||||
|
||||
|
@ -2389,7 +2389,7 @@ MediaFormatReader::ReturnOutput(MediaData* aData, TrackType aTrack)
|
|||
videoData->mDisplay.width, videoData->mDisplay.height);
|
||||
mInfo.mVideo.mDisplay = videoData->mDisplay;
|
||||
}
|
||||
mVideo.ResolvePromise(aData, __func__);
|
||||
mVideo.ResolvePromise(videoData, __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,10 +37,10 @@ public:
|
|||
size_t SizeOfVideoQueueInFrames() override;
|
||||
size_t SizeOfAudioQueueInFrames() override;
|
||||
|
||||
RefPtr<MediaDataPromise>
|
||||
RefPtr<VideoDataPromise>
|
||||
RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold) override;
|
||||
|
||||
RefPtr<MediaDataPromise> RequestAudioData() override;
|
||||
RefPtr<AudioDataPromise> RequestAudioData() override;
|
||||
|
||||
RefPtr<MetadataPromise> AsyncReadMetadata() override;
|
||||
|
||||
|
@ -316,8 +316,6 @@ private:
|
|||
// Indicate if we have a pending promise for decoded frame.
|
||||
// Rejecting the promise will stop the reader from decoding ahead.
|
||||
virtual bool HasPromise() const = 0;
|
||||
virtual RefPtr<MediaDataPromise> EnsurePromise(const char* aMethodName) = 0;
|
||||
virtual void ResolvePromise(MediaData* aData, const char* aMethodName) = 0;
|
||||
virtual void RejectPromise(const MediaResult& aError,
|
||||
const char* aMethodName) = 0;
|
||||
|
||||
|
@ -396,6 +394,7 @@ private:
|
|||
|
||||
};
|
||||
|
||||
template <typename Type>
|
||||
class DecoderDataWithPromise : public DecoderData
|
||||
{
|
||||
public:
|
||||
|
@ -412,14 +411,14 @@ private:
|
|||
return mHasPromise;
|
||||
}
|
||||
|
||||
RefPtr<MediaDataPromise> EnsurePromise(const char* aMethodName) override
|
||||
RefPtr<DataPromise<Type>> EnsurePromise(const char* aMethodName)
|
||||
{
|
||||
MOZ_ASSERT(mOwner->OnTaskQueue());
|
||||
mHasPromise = true;
|
||||
return mPromise.Ensure(aMethodName);
|
||||
}
|
||||
|
||||
void ResolvePromise(MediaData* aData, const char* aMethodName) override
|
||||
void ResolvePromise(Type* aData, const char* aMethodName)
|
||||
{
|
||||
MOZ_ASSERT(mOwner->OnTaskQueue());
|
||||
mPromise.Resolve(aData, aMethodName);
|
||||
|
@ -435,12 +434,12 @@ private:
|
|||
}
|
||||
|
||||
private:
|
||||
MozPromiseHolder<MediaDataPromise> mPromise;
|
||||
MozPromiseHolder<DataPromise<Type>> mPromise;
|
||||
Atomic<bool> mHasPromise;
|
||||
};
|
||||
|
||||
DecoderDataWithPromise mAudio;
|
||||
DecoderDataWithPromise mVideo;
|
||||
DecoderDataWithPromise<AudioData> mAudio;
|
||||
DecoderDataWithPromise<VideoData> mVideo;
|
||||
|
||||
// Returns true when the decoder for this track needs input.
|
||||
bool NeedInput(DecoderData& aDecoder);
|
||||
|
|
|
@ -35,7 +35,7 @@ class AndroidMediaReader : public MediaDecoderReader
|
|||
int64_t mAudioSeekTimeUs;
|
||||
RefPtr<VideoData> mLastVideoFrame;
|
||||
MozPromiseHolder<MediaDecoderReader::SeekPromise> mSeekPromise;
|
||||
MozPromiseRequestHolder<MediaDecoderReader::MediaDataPromise> mSeekRequest;
|
||||
MozPromiseRequestHolder<MediaDecoderReader::VideoDataPromise> mSeekRequest;
|
||||
public:
|
||||
AndroidMediaReader(AbstractMediaDecoder* aDecoder,
|
||||
const MediaContainerType& aContainerType);
|
||||
|
|
Загрузка…
Ссылка в новой задаче