Backed out changeset c405b4271e64 (bug 1097823)

This commit is contained in:
Bobby Holley 2014-12-07 17:09:12 -08:00
Родитель 4867c99ce8
Коммит aa27b00ccd
9 изменённых файлов: 40 добавлений и 39 удалений

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

@ -20,6 +20,8 @@ class MediaData;
template<class Target> template<class Target>
class MediaDataDecodedListener : public RequestSampleCallback { class MediaDataDecodedListener : public RequestSampleCallback {
public: public:
using RequestSampleCallback::NotDecodedReason;
MediaDataDecodedListener(Target* aTarget, MediaDataDecodedListener(Target* aTarget,
MediaTaskQueue* aTaskQueue) MediaTaskQueue* aTaskQueue)
: mMonitor("MediaDataDecodedListener") : mMonitor("MediaDataDecodedListener")
@ -50,8 +52,7 @@ public:
mTaskQueue->Dispatch(task); mTaskQueue->Dispatch(task);
} }
virtual void OnNotDecoded(MediaData::Type aType, virtual void OnNotDecoded(MediaData::Type aType, NotDecodedReason aReason) MOZ_OVERRIDE {
MediaDecoderReader::NotDecodedReason aReason) MOZ_OVERRIDE {
MonitorAutoLock lock(mMonitor); MonitorAutoLock lock(mMonitor);
if (!mTarget || !mTaskQueue) { if (!mTarget || !mTaskQueue) {
// We've been shutdown, abort. // We've been shutdown, abort.
@ -132,7 +133,7 @@ private:
class DeliverNotDecodedTask : public nsRunnable { class DeliverNotDecodedTask : public nsRunnable {
public: public:
DeliverNotDecodedTask(MediaData::Type aType, DeliverNotDecodedTask(MediaData::Type aType,
MediaDecoderReader::NotDecodedReason aReason, RequestSampleCallback::NotDecodedReason aReason,
Target* aTarget) Target* aTarget)
: mType(aType) : mType(aType)
, mReason(aReason) , mReason(aReason)
@ -152,7 +153,7 @@ private:
} }
private: private:
MediaData::Type mType; MediaData::Type mType;
MediaDecoderReader::NotDecodedReason mReason; RequestSampleCallback::NotDecodedReason mReason;
RefPtr<Target> mTarget; RefPtr<Target> mTarget;
}; };

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

@ -204,7 +204,7 @@ MediaDecoderReader::RequestVideoData(bool aSkipToNextKeyframe,
} }
GetCallback()->OnVideoDecoded(v); GetCallback()->OnVideoDecoded(v);
} else if (VideoQueue().IsFinished()) { } else if (VideoQueue().IsFinished()) {
GetCallback()->OnNotDecoded(MediaData::VIDEO_DATA, END_OF_STREAM); GetCallback()->OnNotDecoded(MediaData::VIDEO_DATA, RequestSampleCallback::END_OF_STREAM);
} }
} }
@ -237,7 +237,7 @@ MediaDecoderReader::RequestAudioData()
GetCallback()->OnAudioDecoded(a); GetCallback()->OnAudioDecoded(a);
return; return;
} else if (AudioQueue().IsFinished()) { } else if (AudioQueue().IsFinished()) {
GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, END_OF_STREAM); GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, RequestSampleCallback::END_OF_STREAM);
return; return;
} }
} }
@ -307,13 +307,12 @@ AudioDecodeRendezvous::OnAudioDecoded(AudioData* aSample)
} }
void void
AudioDecodeRendezvous::OnNotDecoded(MediaData::Type aType, AudioDecodeRendezvous::OnNotDecoded(MediaData::Type aType, NotDecodedReason aReason)
MediaDecoderReader::NotDecodedReason aReason)
{ {
MOZ_ASSERT(aType == MediaData::AUDIO_DATA); MOZ_ASSERT(aType == MediaData::AUDIO_DATA);
MonitorAutoLock mon(mMonitor); MonitorAutoLock mon(mMonitor);
mSample = nullptr; mSample = nullptr;
mStatus = aReason == MediaDecoderReader::DECODE_ERROR ? NS_ERROR_FAILURE : NS_OK; mStatus = aReason == DECODE_ERROR ? NS_ERROR_FAILURE : NS_OK;
mHaveResult = true; mHaveResult = true;
mon.NotifyAll(); mon.NotifyAll();
} }

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

@ -30,13 +30,6 @@ class SharedDecoderManager;
// be accessed on the decode task queue. // be accessed on the decode task queue.
class MediaDecoderReader { class MediaDecoderReader {
public: public:
enum NotDecodedReason {
END_OF_STREAM,
DECODE_ERROR,
WAITING_FOR_DATA,
CANCELED
};
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReader) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReader)
explicit MediaDecoderReader(AbstractMediaDecoder* aDecoder); explicit MediaDecoderReader(AbstractMediaDecoder* aDecoder);
@ -297,6 +290,13 @@ class RequestSampleCallback {
public: public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RequestSampleCallback) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RequestSampleCallback)
enum NotDecodedReason {
END_OF_STREAM,
DECODE_ERROR,
WAITING_FOR_DATA,
CANCELED
};
// Receives the result of a RequestAudioData() call. // Receives the result of a RequestAudioData() call.
virtual void OnAudioDecoded(AudioData* aSample) = 0; virtual void OnAudioDecoded(AudioData* aSample) = 0;
@ -305,8 +305,7 @@ public:
// Called when a RequestAudioData() or RequestVideoData() call can't be // Called when a RequestAudioData() or RequestVideoData() call can't be
// fulfiled. The reason is passed as aReason. // fulfiled. The reason is passed as aReason.
virtual void OnNotDecoded(MediaData::Type aType, virtual void OnNotDecoded(MediaData::Type aType, NotDecodedReason aReason) = 0;
MediaDecoderReader::NotDecodedReason aReason) = 0;
virtual void OnSeekCompleted(nsresult aResult) = 0; virtual void OnSeekCompleted(nsresult aResult) = 0;
@ -323,6 +322,8 @@ protected:
// model of the MediaDecoderReader to a synchronous model. // model of the MediaDecoderReader to a synchronous model.
class AudioDecodeRendezvous : public RequestSampleCallback { class AudioDecodeRendezvous : public RequestSampleCallback {
public: public:
using RequestSampleCallback::NotDecodedReason;
AudioDecodeRendezvous(); AudioDecodeRendezvous();
~AudioDecodeRendezvous(); ~AudioDecodeRendezvous();
@ -330,8 +331,7 @@ public:
// Note: aSample is null at end of stream. // Note: aSample is null at end of stream.
virtual void OnAudioDecoded(AudioData* aSample) MOZ_OVERRIDE; virtual void OnAudioDecoded(AudioData* aSample) MOZ_OVERRIDE;
virtual void OnVideoDecoded(VideoData* aSample) MOZ_OVERRIDE {} virtual void OnVideoDecoded(VideoData* aSample) MOZ_OVERRIDE {}
virtual void OnNotDecoded(MediaData::Type aType, virtual void OnNotDecoded(MediaData::Type aType, NotDecodedReason aReason) MOZ_OVERRIDE;
MediaDecoderReader::NotDecodedReason aReason) MOZ_OVERRIDE;
virtual void OnSeekCompleted(nsresult aResult) MOZ_OVERRIDE {}; virtual void OnSeekCompleted(nsresult aResult) MOZ_OVERRIDE {};
virtual void BreakCycles() MOZ_OVERRIDE {}; virtual void BreakCycles() MOZ_OVERRIDE {};
void Reset(); void Reset();

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

@ -805,7 +805,7 @@ MediaDecoderStateMachine::Push(VideoData* aSample)
void void
MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType, MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType,
MediaDecoderReader::NotDecodedReason aReason) RequestSampleCallback::NotDecodedReason aReason)
{ {
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
SAMPLE_LOG("OnNotDecoded (aType=%u, aReason=%u)", aType, aReason); SAMPLE_LOG("OnNotDecoded (aType=%u, aReason=%u)", aType, aReason);
@ -820,7 +820,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 (aReason == MediaDecoderReader::DECODE_ERROR) { if (aReason == RequestSampleCallback::DECODE_ERROR) {
DecodeError(); DecodeError();
return; return;
} }
@ -828,7 +828,7 @@ MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType,
// If the decoder is waiting for data, we need to make sure that the requests // If the decoder is waiting for data, we need to make sure that the requests
// are cleared, which happened above. Additionally, if we're out of decoded // are cleared, which happened above. Additionally, if we're out of decoded
// samples, we need to switch to buffering mode. // samples, we need to switch to buffering mode.
if (aReason == MediaDecoderReader::WAITING_FOR_DATA) { if (aReason == RequestSampleCallback::WAITING_FOR_DATA) {
bool outOfSamples = isAudio ? !AudioQueue().GetSize() : !VideoQueue().GetSize(); bool outOfSamples = isAudio ? !AudioQueue().GetSize() : !VideoQueue().GetSize();
if (outOfSamples) { if (outOfSamples) {
StartBuffering(); StartBuffering();
@ -837,14 +837,14 @@ MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType,
return; return;
} }
if (aReason == MediaDecoderReader::CANCELED) { if (aReason == RequestSampleCallback::CANCELED) {
DispatchDecodeTasksIfNeeded(); DispatchDecodeTasksIfNeeded();
return; return;
} }
// This is an EOS. Finish off the queue, and then handle things based on our // This is an EOS. Finish off the queue, and then handle things based on our
// state. // state.
MOZ_ASSERT(aReason == MediaDecoderReader::END_OF_STREAM); MOZ_ASSERT(aReason == RequestSampleCallback::END_OF_STREAM);
if (!isAudio && mState == DECODER_STATE_SEEKING && if (!isAudio && mState == DECODER_STATE_SEEKING &&
mCurrentSeekTarget.IsValid() && mFirstVideoFrameAfterSeek) { mCurrentSeekTarget.IsValid() && mFirstVideoFrameAfterSeek) {
// Null sample. Hit end of stream. If we have decoded a frame, // Null sample. Hit end of stream. If we have decoded a frame,

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

@ -368,7 +368,7 @@ public:
void OnAudioDecoded(AudioData* aSample); void OnAudioDecoded(AudioData* aSample);
void OnVideoDecoded(VideoData* aSample); void OnVideoDecoded(VideoData* aSample);
void OnNotDecoded(MediaData::Type aType, MediaDecoderReader::NotDecodedReason aReason); void OnNotDecoded(MediaData::Type aType, RequestSampleCallback::NotDecodedReason aReason);
void OnSeekCompleted(nsresult aResult); void OnSeekCompleted(nsresult aResult);
private: private:

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

@ -100,7 +100,7 @@ MediaSourceReader::RequestAudioData()
MSE_DEBUGV("MediaSourceReader(%p)::RequestAudioData", this); MSE_DEBUGV("MediaSourceReader(%p)::RequestAudioData", this);
if (!mAudioReader) { if (!mAudioReader) {
MSE_DEBUG("MediaSourceReader(%p)::RequestAudioData called with no audio reader", this); MSE_DEBUG("MediaSourceReader(%p)::RequestAudioData called with no audio reader", this);
GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, DECODE_ERROR); GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, RequestSampleCallback::DECODE_ERROR);
return; return;
} }
mAudioIsSeeking = false; mAudioIsSeeking = false;
@ -139,7 +139,7 @@ MediaSourceReader::RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThres
this, aSkipToNextKeyframe, aTimeThreshold); this, aSkipToNextKeyframe, aTimeThreshold);
if (!mVideoReader) { if (!mVideoReader) {
MSE_DEBUG("MediaSourceReader(%p)::RequestVideoData called with no video reader", this); MSE_DEBUG("MediaSourceReader(%p)::RequestVideoData called with no video reader", this);
GetCallback()->OnNotDecoded(MediaData::VIDEO_DATA, DECODE_ERROR); GetCallback()->OnNotDecoded(MediaData::VIDEO_DATA, RequestSampleCallback::DECODE_ERROR);
return; return;
} }
if (aSkipToNextKeyframe) { if (aSkipToNextKeyframe) {
@ -177,16 +177,17 @@ MediaSourceReader::OnVideoDecoded(VideoData* aSample)
} }
void void
MediaSourceReader::OnNotDecoded(MediaData::Type aType, NotDecodedReason aReason) MediaSourceReader::OnNotDecoded(MediaData::Type aType, RequestSampleCallback::NotDecodedReason aReason)
{ {
MSE_DEBUG("MediaSourceReader(%p)::OnNotDecoded aType=%u aReason=%u IsEnded: %d", this, aType, aReason, IsEnded()); MSE_DEBUG("MediaSourceReader(%p)::OnNotDecoded aType=%u aReason=%u IsEnded: %d", this, aType, aReason, IsEnded());
if (aReason == DECODE_ERROR || aReason == CANCELED) { if (aReason == RequestSampleCallback::DECODE_ERROR ||
aReason == RequestSampleCallback::CANCELED) {
GetCallback()->OnNotDecoded(aType, aReason); GetCallback()->OnNotDecoded(aType, aReason);
return; return;
} }
// End of stream. Force switching past this stream to another reader by // End of stream. Force switching past this stream to another reader by
// switching to the end of the buffered range. // switching to the end of the buffered range.
MOZ_ASSERT(aReason == END_OF_STREAM); MOZ_ASSERT(aReason == RequestSampleCallback::END_OF_STREAM);
nsRefPtr<MediaDecoderReader> reader = aType == MediaData::AUDIO_DATA ? nsRefPtr<MediaDecoderReader> reader = aType == MediaData::AUDIO_DATA ?
mAudioReader : mVideoReader; mAudioReader : mVideoReader;
@ -227,13 +228,13 @@ MediaSourceReader::OnNotDecoded(MediaData::Type aType, NotDecodedReason aReason)
// If the entire MediaSource is done, generate an EndOfStream. // If the entire MediaSource is done, generate an EndOfStream.
if (IsEnded()) { if (IsEnded()) {
GetCallback()->OnNotDecoded(aType, END_OF_STREAM); GetCallback()->OnNotDecoded(aType, RequestSampleCallback::END_OF_STREAM);
return; return;
} }
// We don't have the data the caller wants. Tell that we're waiting for JS to // We don't have the data the caller wants. Tell that we're waiting for JS to
// give us more data. // give us more data.
GetCallback()->OnNotDecoded(aType, WAITING_FOR_DATA); GetCallback()->OnNotDecoded(aType, RequestSampleCallback::WAITING_FOR_DATA);
} }
void void

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

@ -54,7 +54,7 @@ public:
void OnVideoDecoded(VideoData* aSample); void OnVideoDecoded(VideoData* aSample);
void OnNotDecoded(MediaData::Type aType, NotDecodedReason aReason); void OnNotDecoded(MediaData::Type aType, RequestSampleCallback::NotDecodedReason aReason);
void OnSeekCompleted(nsresult aResult); void OnSeekCompleted(nsresult aResult);

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

@ -488,7 +488,7 @@ MediaCodecReader::DecodeAudioDataTask()
} }
} }
if (AudioQueue().AtEndOfStream()) { if (AudioQueue().AtEndOfStream()) {
GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, END_OF_STREAM); GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, RequestSampleCallback::END_OF_STREAM);
} }
return result; return result;
} }
@ -508,7 +508,7 @@ MediaCodecReader::DecodeVideoFrameTask(int64_t aTimeThreshold)
} }
} }
if (VideoQueue().AtEndOfStream()) { if (VideoQueue().AtEndOfStream()) {
GetCallback()->OnNotDecoded(MediaData::VIDEO_DATA, END_OF_STREAM); GetCallback()->OnNotDecoded(MediaData::VIDEO_DATA, RequestSampleCallback::END_OF_STREAM);
} }
return result; return result;
} }

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

@ -743,7 +743,7 @@ bool WebMReader::DecodeOpus(const unsigned char* aData, size_t aLength,
// Discard padding should be used only on the final packet, so // Discard padding should be used only on the final packet, so
// decoding after a padding discard is invalid. // decoding after a padding discard is invalid.
LOG(PR_LOG_DEBUG, ("Opus error, discard padding on interstitial packet")); LOG(PR_LOG_DEBUG, ("Opus error, discard padding on interstitial packet"));
GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, DECODE_ERROR); GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, RequestSampleCallback::DECODE_ERROR);
return false; return false;
} }
@ -797,7 +797,7 @@ bool WebMReader::DecodeOpus(const unsigned char* aData, size_t aLength,
if (discardPadding < 0) { if (discardPadding < 0) {
// Negative discard padding is invalid. // Negative discard padding is invalid.
LOG(PR_LOG_DEBUG, ("Opus error, negative discard padding")); LOG(PR_LOG_DEBUG, ("Opus error, negative discard padding"));
GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, DECODE_ERROR); GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, RequestSampleCallback::DECODE_ERROR);
return false; return false;
} }
if (discardPadding > 0) { if (discardPadding > 0) {
@ -810,7 +810,7 @@ bool WebMReader::DecodeOpus(const unsigned char* aData, size_t aLength,
if (discardFrames.value() > frames) { if (discardFrames.value() > frames) {
// Discarding more than the entire packet is invalid. // Discarding more than the entire packet is invalid.
LOG(PR_LOG_DEBUG, ("Opus error, discard padding larger than packet")); LOG(PR_LOG_DEBUG, ("Opus error, discard padding larger than packet"));
GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, DECODE_ERROR); GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, RequestSampleCallback::DECODE_ERROR);
return false; return false;
} }
LOG(PR_LOG_DEBUG, ("Opus decoder discarding %d of %d frames", LOG(PR_LOG_DEBUG, ("Opus decoder discarding %d of %d frames",