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

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

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

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

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

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

@ -805,7 +805,7 @@ MediaDecoderStateMachine::Push(VideoData* aSample)
void
MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType,
MediaDecoderReader::NotDecodedReason aReason)
RequestSampleCallback::NotDecodedReason aReason)
{
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
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 (aReason == MediaDecoderReader::DECODE_ERROR) {
if (aReason == RequestSampleCallback::DECODE_ERROR) {
DecodeError();
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
// are cleared, which happened above. Additionally, if we're out of decoded
// 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();
if (outOfSamples) {
StartBuffering();
@ -837,14 +837,14 @@ MediaDecoderStateMachine::OnNotDecoded(MediaData::Type aType,
return;
}
if (aReason == MediaDecoderReader::CANCELED) {
if (aReason == RequestSampleCallback::CANCELED) {
DispatchDecodeTasksIfNeeded();
return;
}
// This is an EOS. Finish off the queue, and then handle things based on our
// state.
MOZ_ASSERT(aReason == MediaDecoderReader::END_OF_STREAM);
MOZ_ASSERT(aReason == RequestSampleCallback::END_OF_STREAM);
if (!isAudio && mState == DECODER_STATE_SEEKING &&
mCurrentSeekTarget.IsValid() && mFirstVideoFrameAfterSeek) {
// Null sample. Hit end of stream. If we have decoded a frame,

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

@ -368,7 +368,7 @@ public:
void OnAudioDecoded(AudioData* 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);
private:

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

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

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

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

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

@ -488,7 +488,7 @@ MediaCodecReader::DecodeAudioDataTask()
}
}
if (AudioQueue().AtEndOfStream()) {
GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, END_OF_STREAM);
GetCallback()->OnNotDecoded(MediaData::AUDIO_DATA, RequestSampleCallback::END_OF_STREAM);
}
return result;
}
@ -508,7 +508,7 @@ MediaCodecReader::DecodeVideoFrameTask(int64_t aTimeThreshold)
}
}
if (VideoQueue().AtEndOfStream()) {
GetCallback()->OnNotDecoded(MediaData::VIDEO_DATA, END_OF_STREAM);
GetCallback()->OnNotDecoded(MediaData::VIDEO_DATA, RequestSampleCallback::END_OF_STREAM);
}
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
// decoding after a padding discard is invalid.
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;
}
@ -797,7 +797,7 @@ bool WebMReader::DecodeOpus(const unsigned char* aData, size_t aLength,
if (discardPadding < 0) {
// Negative discard padding is invalid.
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;
}
if (discardPadding > 0) {
@ -810,7 +810,7 @@ bool WebMReader::DecodeOpus(const unsigned char* aData, size_t aLength,
if (discardFrames.value() > frames) {
// Discarding more than the entire packet is invalid.
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;
}
LOG(PR_LOG_DEBUG, ("Opus decoder discarding %d of %d frames",