Bug 1299072: P9. Pass decoding error details to MediaDecoder. r=jwwang

MozReview-Commit-ID: uXWHhTozon

--HG--
extra : rebase_source : 7736b9d969dc680b08bffbc7610271d5cc0272be
This commit is contained in:
Jean-Yves Avenard 2016-09-11 00:51:13 +10:00
Родитель f9b88ac91f
Коммит 00e8a7dabc
4 изменённых файлов: 24 добавлений и 14 удалений

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

@ -198,7 +198,7 @@ MediaDecoder::ResourceCallback::NotifyDecodeError()
RefPtr<ResourceCallback> self = this; RefPtr<ResourceCallback> self = this;
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([=] () { nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([=] () {
if (self->mDecoder) { if (self->mDecoder) {
self->mDecoder->DecodeError(); self->mDecoder->DecodeError(NS_ERROR_DOM_MEDIA_FATAL_ERR);
} }
}); });
AbstractThread::MainThread()->Dispatch(r.forget()); AbstractThread::MainThread()->Dispatch(r.forget());
@ -607,6 +607,7 @@ MediaDecoder::Shutdown()
mMetadataLoadedListener.Disconnect(); mMetadataLoadedListener.Disconnect();
mFirstFrameLoadedListener.Disconnect(); mFirstFrameLoadedListener.Disconnect();
mOnPlaybackEvent.Disconnect(); mOnPlaybackEvent.Disconnect();
mOnPlaybackErrorEvent.Disconnect();
mOnMediaNotSeekable.Disconnect(); mOnMediaNotSeekable.Disconnect();
mDecoderStateMachine->BeginShutdown() mDecoderStateMachine->BeginShutdown()
@ -661,9 +662,6 @@ MediaDecoder::OnPlaybackEvent(MediaEventType aEvent)
case MediaEventType::SeekStarted: case MediaEventType::SeekStarted:
SeekingStarted(); SeekingStarted();
break; break;
case MediaEventType::DecodeError:
DecodeError();
break;
case MediaEventType::Invalidate: case MediaEventType::Invalidate:
Invalidate(); Invalidate();
break; break;
@ -676,6 +674,12 @@ MediaDecoder::OnPlaybackEvent(MediaEventType aEvent)
} }
} }
void
MediaDecoder::OnPlaybackErrorEvent(const MediaResult& aError)
{
DecodeError(aError);
}
void void
MediaDecoder::FinishShutdown() MediaDecoder::FinishShutdown()
{ {
@ -749,6 +753,8 @@ MediaDecoder::SetStateMachineParameters()
mOnPlaybackEvent = mDecoderStateMachine->OnPlaybackEvent().Connect( mOnPlaybackEvent = mDecoderStateMachine->OnPlaybackEvent().Connect(
AbstractThread::MainThread(), this, &MediaDecoder::OnPlaybackEvent); AbstractThread::MainThread(), this, &MediaDecoder::OnPlaybackEvent);
mOnPlaybackErrorEvent = mDecoderStateMachine->OnPlaybackErrorEvent().Connect(
AbstractThread::MainThread(), this, &MediaDecoder::OnPlaybackErrorEvent);
mOnMediaNotSeekable = mDecoderStateMachine->OnMediaNotSeekable().Connect( mOnMediaNotSeekable = mDecoderStateMachine->OnMediaNotSeekable().Connect(
AbstractThread::MainThread(), this, &MediaDecoder::OnMediaNotSeekable); AbstractThread::MainThread(), this, &MediaDecoder::OnMediaNotSeekable);
} }
@ -1006,7 +1012,7 @@ MediaDecoder::NetworkError()
} }
void void
MediaDecoder::DecodeError() MediaDecoder::DecodeError(const MediaResult& aError)
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!IsShutdown()); MOZ_ASSERT(!IsShutdown());

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

@ -436,7 +436,7 @@ private:
int64_t GetDownloadPosition(); int64_t GetDownloadPosition();
// Notifies the element that decoding has failed. // Notifies the element that decoding has failed.
void DecodeError(); void DecodeError(const MediaResult& aError);
// Indicate whether the media is same-origin with the element. // Indicate whether the media is same-origin with the element.
void UpdateSameOriginStatus(bool aSameOrigin); void UpdateSameOriginStatus(bool aSameOrigin);
@ -592,6 +592,7 @@ private:
DataArrivedEvent() override { return &mDataArrivedEvent; } DataArrivedEvent() override { return &mDataArrivedEvent; }
void OnPlaybackEvent(MediaEventType aEvent); void OnPlaybackEvent(MediaEventType aEvent);
void OnPlaybackErrorEvent(const MediaResult& aError);
void OnMediaNotSeekable() void OnMediaNotSeekable()
{ {
@ -731,6 +732,7 @@ protected:
MediaEventListener mFirstFrameLoadedListener; MediaEventListener mFirstFrameLoadedListener;
MediaEventListener mOnPlaybackEvent; MediaEventListener mOnPlaybackEvent;
MediaEventListener mOnPlaybackErrorEvent;
MediaEventListener mOnMediaNotSeekable; MediaEventListener mOnMediaNotSeekable;
protected: protected:

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

@ -1022,7 +1022,7 @@ MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType,
// If this is a decode error, delegate to the generic error path. // If this is a decode error, delegate to the generic error path.
if (aError != NS_ERROR_DOM_MEDIA_END_OF_STREAM) { if (aError != NS_ERROR_DOM_MEDIA_END_OF_STREAM) {
DecodeError(); DecodeError(aError);
return; return;
} }
@ -2082,7 +2082,7 @@ MediaDecoderStateMachine::OnSeekTaskRejected(SeekTaskRejectValue aValue)
StopPrerollingVideo(); StopPrerollingVideo();
} }
DecodeError(); DecodeError(aValue.mError);
DiscardSeekTaskIfExist(); DiscardSeekTaskIfExist();
} }
@ -2291,13 +2291,13 @@ bool MediaDecoderStateMachine::HasLowUndecodedData(int64_t aUsecs)
} }
void void
MediaDecoderStateMachine::DecodeError() MediaDecoderStateMachine::DecodeError(const MediaResult& aError)
{ {
MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(!IsShutdown()); MOZ_ASSERT(!IsShutdown());
DECODER_WARN("Decode error"); DECODER_WARN("Decode error");
// Notify the decode error and MediaDecoder will shut down MDSM. // Notify the decode error and MediaDecoder will shut down MDSM.
mOnPlaybackEvent.Notify(MediaEventType::DecodeError); mOnPlaybackErrorEvent.Notify(aError);
} }
void void
@ -2918,7 +2918,7 @@ MediaDecoderStateMachine::OnMediaSinkVideoError()
if (HasAudio()) { if (HasAudio()) {
return; return;
} }
DecodeError(); DecodeError(MediaResult(NS_ERROR_DOM_MEDIA_MEDIASINK_ERR, __func__));
} }
void MediaDecoderStateMachine::OnMediaSinkAudioComplete() void MediaDecoderStateMachine::OnMediaSinkAudioComplete()
@ -2949,7 +2949,7 @@ void MediaDecoderStateMachine::OnMediaSinkAudioError()
// Otherwise notify media decoder/element about this error for it makes // Otherwise notify media decoder/element about this error for it makes
// no sense to play an audio-only file without sound output. // no sense to play an audio-only file without sound output.
DecodeError(); DecodeError(MediaResult(NS_ERROR_DOM_MEDIA_MEDIASINK_ERR, __func__));
} }
#ifdef MOZ_EME #ifdef MOZ_EME

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

@ -119,7 +119,6 @@ enum class MediaEventType : int8_t {
PlaybackStopped, PlaybackStopped,
PlaybackEnded, PlaybackEnded,
SeekStarted, SeekStarted,
DecodeError,
Invalidate, Invalidate,
EnterVideoSuspend, EnterVideoSuspend,
ExitVideoSuspend ExitVideoSuspend
@ -245,6 +244,8 @@ public:
MediaEventSource<MediaEventType>& MediaEventSource<MediaEventType>&
OnPlaybackEvent() { return mOnPlaybackEvent; } OnPlaybackEvent() { return mOnPlaybackEvent; }
MediaEventSource<MediaResult>&
OnPlaybackErrorEvent() { return mOnPlaybackErrorEvent; }
size_t SizeOfVideoQueue() const; size_t SizeOfVideoQueue() const;
@ -481,7 +482,7 @@ protected:
// event to the media element. This begins shutting down the decoder. // event to the media element. This begins shutting down the decoder.
// The decoder monitor must be held. This is only called on the // The decoder monitor must be held. This is only called on the
// decode thread. // decode thread.
void DecodeError(); void DecodeError(const MediaResult& aError);
// Dispatches a LoadedMetadataEvent. // Dispatches a LoadedMetadataEvent.
// This is threadsafe and can be called on any thread. // This is threadsafe and can be called on any thread.
@ -892,6 +893,7 @@ private:
MediaDecoderEventVisibility> mFirstFrameLoadedEvent; MediaDecoderEventVisibility> mFirstFrameLoadedEvent;
MediaEventProducer<MediaEventType> mOnPlaybackEvent; MediaEventProducer<MediaEventType> mOnPlaybackEvent;
MediaEventProducer<MediaResult> mOnPlaybackErrorEvent;
// True if audio is offloading. // True if audio is offloading.
// Playback will not start when audio is offloading. // Playback will not start when audio is offloading.