зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1299072: P7. Use MediaResult with MetadataPromise. r=jwwang
MozReview-Commit-ID: KrRr8wDuPNT --HG-- extra : rebase_source : 3df3763890a55c898ca3f00dd914e3c78fe714b1
This commit is contained in:
Родитель
c590867926
Коммит
a3d152a719
|
@ -360,8 +360,6 @@ MediaDecoderReader::GetBuffered()
|
|||
RefPtr<MediaDecoderReader::MetadataPromise>
|
||||
MediaDecoderReader::AsyncReadMetadata()
|
||||
{
|
||||
typedef ReadMetadataFailureReason Reason;
|
||||
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
DECODER_LOG("MediaDecoderReader::AsyncReadMetadata");
|
||||
|
||||
|
@ -374,7 +372,7 @@ MediaDecoderReader::AsyncReadMetadata()
|
|||
// error.
|
||||
if (NS_FAILED(rv) || !metadata->mInfo.HasValidMedia()) {
|
||||
DECODER_WARN("ReadMetadata failed, rv=%x HasValidMedia=%d", rv, metadata->mInfo.HasValidMedia());
|
||||
return MetadataPromise::CreateAndReject(Reason::METADATA_ERROR, __func__);
|
||||
return MetadataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
|
||||
}
|
||||
|
||||
// Success!
|
||||
|
|
|
@ -51,11 +51,6 @@ private:
|
|||
virtual ~MetadataHolder() {}
|
||||
};
|
||||
|
||||
enum class ReadMetadataFailureReason : int8_t
|
||||
{
|
||||
METADATA_ERROR
|
||||
};
|
||||
|
||||
// Encapsulates the decoding and reading of media data. Reading can either
|
||||
// synchronous and done on the calling "decode" thread, or asynchronous and
|
||||
// performed on a background thread, with the result being returned by
|
||||
|
@ -72,7 +67,7 @@ public:
|
|||
using TrackSet = EnumSet<TrackInfo::TrackType>;
|
||||
|
||||
using MetadataPromise =
|
||||
MozPromise<RefPtr<MetadataHolder>, ReadMetadataFailureReason, IsExclusive>;
|
||||
MozPromise<RefPtr<MetadataHolder>, MediaResult, IsExclusive>;
|
||||
using MediaDataPromise =
|
||||
MozPromise<RefPtr<MediaData>, MediaResult, IsExclusive>;
|
||||
using SeekPromise = MozPromise<media::TimeUnit, nsresult, IsExclusive>;
|
||||
|
|
|
@ -263,8 +263,8 @@ public:
|
|||
[this] (MetadataHolder* aMetadata) {
|
||||
OnMetadataRead(aMetadata);
|
||||
},
|
||||
[this] (ReadMetadataFailureReason aReason) {
|
||||
OnMetadataNotRead(aReason);
|
||||
[this] (const MediaResult& aError) {
|
||||
OnMetadataNotRead(aError);
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -355,11 +355,11 @@ private:
|
|||
SetState(DECODER_STATE_DECODING_FIRSTFRAME);
|
||||
}
|
||||
|
||||
void OnMetadataNotRead(ReadMetadataFailureReason aReason)
|
||||
void OnMetadataNotRead(const MediaResult& aError)
|
||||
{
|
||||
mMetadataRequest.Complete();
|
||||
SWARN("Decode metadata failed, shutting down decoder");
|
||||
mMaster->DecodeError();
|
||||
mMaster->DecodeError(aError);
|
||||
}
|
||||
|
||||
MozPromiseRequestHolder<MediaDecoderReader::MetadataPromise> mMetadataRequest;
|
||||
|
|
|
@ -93,7 +93,7 @@ MediaFormatReader::Shutdown()
|
|||
MOZ_ASSERT(OnTaskQueue());
|
||||
|
||||
mDemuxerInitRequest.DisconnectIfExists();
|
||||
mMetadataPromise.RejectIfExists(ReadMetadataFailureReason::METADATA_ERROR, __func__);
|
||||
mMetadataPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
|
||||
mSeekPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
|
||||
mSkipRequest.DisconnectIfExists();
|
||||
|
||||
|
@ -283,7 +283,7 @@ MediaFormatReader::OnDemuxerInitDone(nsresult)
|
|||
// We currently only handle the first video track.
|
||||
mVideo.mTrackDemuxer = mDemuxer->GetTrackDemuxer(TrackInfo::kVideoTrack, 0);
|
||||
if (!mVideo.mTrackDemuxer) {
|
||||
mMetadataPromise.Reject(ReadMetadataFailureReason::METADATA_ERROR, __func__);
|
||||
mMetadataPromise.Reject(NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ MediaFormatReader::OnDemuxerInitDone(nsresult)
|
|||
if (videoActive) {
|
||||
if (platform && !platform->SupportsMimeType(videoInfo->mMimeType, nullptr)) {
|
||||
// We have no decoder for this track. Error.
|
||||
mMetadataPromise.Reject(ReadMetadataFailureReason::METADATA_ERROR, __func__);
|
||||
mMetadataPromise.Reject(NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
|
||||
return;
|
||||
}
|
||||
mInfo.mVideo = *videoInfo->GetAsVideoInfo();
|
||||
|
@ -312,7 +312,7 @@ MediaFormatReader::OnDemuxerInitDone(nsresult)
|
|||
if (audioActive) {
|
||||
mAudio.mTrackDemuxer = mDemuxer->GetTrackDemuxer(TrackInfo::kAudioTrack, 0);
|
||||
if (!mAudio.mTrackDemuxer) {
|
||||
mMetadataPromise.Reject(ReadMetadataFailureReason::METADATA_ERROR, __func__);
|
||||
mMetadataPromise.Reject(NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@ MediaFormatReader::OnDemuxerInitDone(nsresult)
|
|||
mDemuxer->IsSeekableOnlyInBufferedRanges();
|
||||
|
||||
if (!videoActive && !audioActive) {
|
||||
mMetadataPromise.Reject(ReadMetadataFailureReason::METADATA_ERROR, __func__);
|
||||
mMetadataPromise.Reject(NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -379,7 +379,7 @@ void
|
|||
MediaFormatReader::OnDemuxerInitFailed(DemuxerFailureReason aFailure)
|
||||
{
|
||||
mDemuxerInitRequest.Complete();
|
||||
mMetadataPromise.Reject(ReadMetadataFailureReason::METADATA_ERROR, __func__);
|
||||
mMetadataPromise.Reject(NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
&MediaFormatReaderBinding::OnNotDemuxed);
|
||||
}
|
||||
|
||||
void OnMetadataNotRead(ReadMetadataFailureReason aReason) {
|
||||
void OnMetadataNotRead(const MediaResult& aError) {
|
||||
EXPECT_TRUE(false);
|
||||
ReaderShutdown();
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ MediaOmxReader::Shutdown()
|
|||
void MediaOmxReader::ReleaseResources()
|
||||
{
|
||||
mMediaResourceRequest.DisconnectIfExists();
|
||||
mMetadataPromise.RejectIfExists(ReadMetadataFailureReason::METADATA_ERROR, __func__);
|
||||
mMetadataPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
|
||||
|
||||
ResetDecode();
|
||||
// Before freeing a video codec, all video buffers needed to be released
|
||||
|
@ -221,7 +221,7 @@ MediaOmxReader::AsyncReadMetadata()
|
|||
nsresult rv = InitOmxDecoder();
|
||||
if (NS_FAILED(rv)) {
|
||||
return MediaDecoderReader::MetadataPromise::CreateAndReject(
|
||||
ReadMetadataFailureReason::METADATA_ERROR, __func__);
|
||||
NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
|
||||
}
|
||||
|
||||
bool isMP3 = mDecoder->GetResource()->GetContentType().EqualsASCII(AUDIO_MP3);
|
||||
|
@ -243,7 +243,7 @@ MediaOmxReader::AsyncReadMetadata()
|
|||
self->HandleResourceAllocated();
|
||||
}, [self] (bool) -> void {
|
||||
self->mMediaResourceRequest.Complete();
|
||||
self->mMetadataPromise.Reject(ReadMetadataFailureReason::METADATA_ERROR, __func__);
|
||||
self->mMetadataPromise.Reject(NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
|
||||
}));
|
||||
|
||||
return p;
|
||||
|
@ -255,7 +255,7 @@ void MediaOmxReader::HandleResourceAllocated()
|
|||
|
||||
// After resources are available, set the metadata.
|
||||
if (!mOmxDecoder->EnsureMetadata()) {
|
||||
mMetadataPromise.Reject(ReadMetadataFailureReason::METADATA_ERROR, __func__);
|
||||
mMetadataPromise.Reject(NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ void MediaOmxReader::HandleResourceAllocated()
|
|||
nsIntSize displaySize(displayWidth, displayHeight);
|
||||
nsIntSize frameSize(width, height);
|
||||
if (!IsValidVideoRegion(frameSize, pictureRect, displaySize)) {
|
||||
mMetadataPromise.Reject(ReadMetadataFailureReason::METADATA_ERROR, __func__);
|
||||
mMetadataPromise.RejectNS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ private:
|
|||
|
||||
void Decode();
|
||||
void OnMetadataRead(MetadataHolder* aMetadata);
|
||||
void OnMetadataNotRead(ReadMetadataFailureReason aReason);
|
||||
void OnMetadataNotRead(const MediaResult& aError);
|
||||
void RequestSample();
|
||||
void SampleDecoded(MediaData* aData);
|
||||
void SampleNotDecoded(const MediaResult& aError);
|
||||
|
@ -310,7 +310,7 @@ MediaDecodeTask::OnMetadataRead(MetadataHolder* aMetadata)
|
|||
}
|
||||
|
||||
void
|
||||
MediaDecodeTask::OnMetadataNotRead(ReadMetadataFailureReason aReason)
|
||||
MediaDecodeTask::OnMetadataNotRead(const MediaResult& aReason)
|
||||
{
|
||||
mDecoderReader->Shutdown();
|
||||
ReportFailureOnMainThread(WebAudioDecodeJob::InvalidContent);
|
||||
|
|
Загрузка…
Ссылка в новой задаче