зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1301294 - Remove unnecessary nsresult return value from MediaDataDecoder interface. r=jya
This commit is contained in:
Родитель
069847c2be
Коммит
99bf9b18df
|
@ -908,18 +908,14 @@ MediaFormatReader::RequestDemuxSamples(TrackType aTrack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
MediaFormatReader::DecodeDemuxedSamples(TrackType aTrack,
|
MediaFormatReader::DecodeDemuxedSamples(TrackType aTrack,
|
||||||
MediaRawData* aSample)
|
MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(OnTaskQueue());
|
MOZ_ASSERT(OnTaskQueue());
|
||||||
auto& decoder = GetDecoderData(aTrack);
|
auto& decoder = GetDecoderData(aTrack);
|
||||||
if (NS_FAILED(decoder.mDecoder->Input(aSample))) {
|
decoder.mDecoder->Input(aSample);
|
||||||
LOG("Unable to pass frame to decoder");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
decoder.mDecodePending = true;
|
decoder.mDecodePending = true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1019,9 +1015,8 @@ MediaFormatReader::HandleDemuxedSamples(TrackType aTrack,
|
||||||
|
|
||||||
if (mDemuxOnly) {
|
if (mDemuxOnly) {
|
||||||
ReturnOutput(sample, aTrack);
|
ReturnOutput(sample, aTrack);
|
||||||
} else if (!DecodeDemuxedSamples(aTrack, sample)) {
|
} else {
|
||||||
NotifyError(aTrack);
|
DecodeDemuxedSamples(aTrack, sample);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
decoder.mQueuedSamples.RemoveElementAt(0);
|
decoder.mQueuedSamples.RemoveElementAt(0);
|
||||||
|
|
|
@ -133,7 +133,7 @@ private:
|
||||||
void HandleDemuxedSamples(TrackType aTrack,
|
void HandleDemuxedSamples(TrackType aTrack,
|
||||||
AbstractMediaDecoder::AutoNotifyDecoded& aA);
|
AbstractMediaDecoder::AutoNotifyDecoded& aA);
|
||||||
// Decode any pending already demuxed samples.
|
// Decode any pending already demuxed samples.
|
||||||
bool DecodeDemuxedSamples(TrackType aTrack,
|
void DecodeDemuxedSamples(TrackType aTrack,
|
||||||
MediaRawData* aSample);
|
MediaRawData* aSample);
|
||||||
|
|
||||||
struct InternalSeekTarget {
|
struct InternalSeekTarget {
|
||||||
|
|
|
@ -210,6 +210,10 @@ public:
|
||||||
// TaskQueue passed into the PlatformDecoderModules's Create*Decoder()
|
// TaskQueue passed into the PlatformDecoderModules's Create*Decoder()
|
||||||
// function. This may not be necessary for platforms with async APIs
|
// function. This may not be necessary for platforms with async APIs
|
||||||
// for decoding.
|
// for decoding.
|
||||||
|
//
|
||||||
|
// If an error occurs at any point after the Init promise has been
|
||||||
|
// completed, then Error() must be called on the associated
|
||||||
|
// MediaDataDecoderCallback.
|
||||||
class MediaDataDecoder {
|
class MediaDataDecoder {
|
||||||
protected:
|
protected:
|
||||||
virtual ~MediaDataDecoder() {};
|
virtual ~MediaDataDecoder() {};
|
||||||
|
@ -235,7 +239,7 @@ public:
|
||||||
virtual RefPtr<InitPromise> Init() = 0;
|
virtual RefPtr<InitPromise> Init() = 0;
|
||||||
|
|
||||||
// Inserts a sample into the decoder's decode pipeline.
|
// Inserts a sample into the decoder's decode pipeline.
|
||||||
virtual nsresult Input(MediaRawData* aSample) = 0;
|
virtual void Input(MediaRawData* aSample) = 0;
|
||||||
|
|
||||||
// Causes all samples in the decoding pipeline to be discarded. When
|
// Causes all samples in the decoding pipeline to be discarded. When
|
||||||
// this function returns, the decoder must be ready to accept new input
|
// this function returns, the decoder must be ready to accept new input
|
||||||
|
@ -244,7 +248,7 @@ public:
|
||||||
// While the reader calls Flush(), it ignores all output sent to it;
|
// While the reader calls Flush(), it ignores all output sent to it;
|
||||||
// it is safe (but pointless) to send output while Flush is called.
|
// it is safe (but pointless) to send output while Flush is called.
|
||||||
// The MediaFormatReader will not call Input() while it's calling Flush().
|
// The MediaFormatReader will not call Input() while it's calling Flush().
|
||||||
virtual nsresult Flush() = 0;
|
virtual void Flush() = 0;
|
||||||
|
|
||||||
// Causes all complete samples in the pipeline that can be decoded to be
|
// Causes all complete samples in the pipeline that can be decoded to be
|
||||||
// output. If the decoder can't produce samples from the current output,
|
// output. If the decoder can't produce samples from the current output,
|
||||||
|
@ -255,7 +259,7 @@ public:
|
||||||
// This function is asynchronous. The MediaDataDecoder must call
|
// This function is asynchronous. The MediaDataDecoder must call
|
||||||
// MediaDataDecoderCallback::DrainComplete() once all remaining
|
// MediaDataDecoderCallback::DrainComplete() once all remaining
|
||||||
// samples have been output.
|
// samples have been output.
|
||||||
virtual nsresult Drain() = 0;
|
virtual void Drain() = 0;
|
||||||
|
|
||||||
// Cancels all init/input/drain operations, and shuts down the
|
// Cancels all init/input/drain operations, and shuts down the
|
||||||
// decoder. The platform decoder should clean up any resources it's using
|
// decoder. The platform decoder should clean up any resources it's using
|
||||||
|
@ -264,7 +268,7 @@ public:
|
||||||
// The reader will delete the decoder once Shutdown() returns.
|
// The reader will delete the decoder once Shutdown() returns.
|
||||||
// The MediaDataDecoderCallback *must* not be called after Shutdown() has
|
// The MediaDataDecoderCallback *must* not be called after Shutdown() has
|
||||||
// returned.
|
// returned.
|
||||||
virtual nsresult Shutdown() = 0;
|
virtual void Shutdown() = 0;
|
||||||
|
|
||||||
// Called from the state machine task queue or main thread.
|
// Called from the state machine task queue or main thread.
|
||||||
// Decoder needs to decide whether or not hardware accelearation is supported
|
// Decoder needs to decide whether or not hardware accelearation is supported
|
||||||
|
@ -277,10 +281,7 @@ public:
|
||||||
// If audio decoder, aConfig will be a AudioInfo object.
|
// If audio decoder, aConfig will be a AudioInfo object.
|
||||||
// It is not safe to store a reference to this object and the decoder must
|
// It is not safe to store a reference to this object and the decoder must
|
||||||
// make a copy.
|
// make a copy.
|
||||||
virtual nsresult ConfigurationChanged(const TrackInfo& aConfig)
|
virtual void ConfigurationChanged(const TrackInfo& aConfig) {}
|
||||||
{
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the name of the MediaDataDecoder, only used for decoding.
|
// Return the name of the MediaDataDecoder, only used for decoding.
|
||||||
// Only return a static const string, as the information may be accessed
|
// Only return a static const string, as the information may be accessed
|
||||||
|
|
|
@ -44,11 +44,9 @@ public:
|
||||||
return InitPromise::CreateAndResolve(mType, __func__);
|
return InitPromise::CreateAndResolve(mType, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Shutdown() override {
|
void Shutdown() override {}
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult Input(MediaRawData* aSample) override
|
void Input(MediaRawData* aSample) override
|
||||||
{
|
{
|
||||||
RefPtr<MediaData> data =
|
RefPtr<MediaData> data =
|
||||||
mCreator->Create(media::TimeUnit::FromMicroseconds(aSample->mTime),
|
mCreator->Create(media::TimeUnit::FromMicroseconds(aSample->mTime),
|
||||||
|
@ -56,25 +54,20 @@ public:
|
||||||
aSample->mOffset);
|
aSample->mOffset);
|
||||||
|
|
||||||
OutputFrame(data);
|
OutputFrame(data);
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Flush() override
|
void Flush() override
|
||||||
{
|
{
|
||||||
mReorderQueue.Clear();
|
mReorderQueue.Clear();
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Drain() override
|
void Drain() override
|
||||||
{
|
{
|
||||||
while (!mReorderQueue.IsEmpty()) {
|
while (!mReorderQueue.IsEmpty()) {
|
||||||
mCallback->Output(mReorderQueue.Pop().get());
|
mCallback->Output(mReorderQueue.Pop().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
mCallback->DrainComplete();
|
mCallback->DrainComplete();
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
|
|
|
@ -41,10 +41,9 @@ OpusDataDecoder::~OpusDataDecoder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
OpusDataDecoder::Shutdown()
|
OpusDataDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -138,13 +137,11 @@ OpusDataDecoder::DecodeHeader(const unsigned char* aData, size_t aLength)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
OpusDataDecoder::Input(MediaRawData* aSample)
|
OpusDataDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>(
|
mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>(
|
||||||
this, &OpusDataDecoder::ProcessDecode, aSample));
|
this, &OpusDataDecoder::ProcessDecode, aSample));
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -323,18 +320,17 @@ OpusDataDecoder::ProcessDrain()
|
||||||
mCallback->DrainComplete();
|
mCallback->DrainComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
OpusDataDecoder::Drain()
|
OpusDataDecoder::Drain()
|
||||||
{
|
{
|
||||||
mTaskQueue->Dispatch(NewRunnableMethod(this, &OpusDataDecoder::ProcessDrain));
|
mTaskQueue->Dispatch(NewRunnableMethod(this, &OpusDataDecoder::ProcessDrain));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
OpusDataDecoder::Flush()
|
OpusDataDecoder::Flush()
|
||||||
{
|
{
|
||||||
if (!mOpusDecoder) {
|
if (!mOpusDecoder) {
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
mIsFlushing = true;
|
mIsFlushing = true;
|
||||||
nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([this] () {
|
nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([this] () {
|
||||||
|
@ -347,7 +343,6 @@ OpusDataDecoder::Flush()
|
||||||
});
|
});
|
||||||
SyncRunnable::DispatchToThread(mTaskQueue, runnable);
|
SyncRunnable::DispatchToThread(mTaskQueue, runnable);
|
||||||
mIsFlushing = false;
|
mIsFlushing = false;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
|
@ -21,10 +21,10 @@ public:
|
||||||
~OpusDataDecoder();
|
~OpusDataDecoder();
|
||||||
|
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
return "opus audio decoder";
|
return "opus audio decoder";
|
||||||
|
|
|
@ -58,14 +58,13 @@ TheoraDecoder::~TheoraDecoder()
|
||||||
th_info_clear(&mTheoraInfo);
|
th_info_clear(&mTheoraInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
TheoraDecoder::Shutdown()
|
TheoraDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
if (mTheoraDecoderContext) {
|
if (mTheoraDecoderContext) {
|
||||||
th_decode_free(mTheoraDecoderContext);
|
th_decode_free(mTheoraDecoderContext);
|
||||||
mTheoraDecoderContext = nullptr;
|
mTheoraDecoderContext = nullptr;
|
||||||
}
|
}
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<MediaDataDecoder::InitPromise>
|
RefPtr<MediaDataDecoder::InitPromise>
|
||||||
|
@ -99,7 +98,7 @@ TheoraDecoder::Init()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
TheoraDecoder::Flush()
|
TheoraDecoder::Flush()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
|
@ -109,7 +108,6 @@ TheoraDecoder::Flush()
|
||||||
});
|
});
|
||||||
SyncRunnable::DispatchToThread(mTaskQueue, r);
|
SyncRunnable::DispatchToThread(mTaskQueue, r);
|
||||||
mIsFlushing = false;
|
mIsFlushing = false;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -207,14 +205,12 @@ TheoraDecoder::ProcessDecode(MediaRawData* aSample)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
TheoraDecoder::Input(MediaRawData* aSample)
|
TheoraDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>(
|
mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>(
|
||||||
this, &TheoraDecoder::ProcessDecode, aSample));
|
this, &TheoraDecoder::ProcessDecode, aSample));
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -224,13 +220,11 @@ TheoraDecoder::ProcessDrain()
|
||||||
mCallback->DrainComplete();
|
mCallback->DrainComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
TheoraDecoder::Drain()
|
TheoraDecoder::Drain()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
mTaskQueue->Dispatch(NewRunnableMethod(this, &TheoraDecoder::ProcessDrain));
|
mTaskQueue->Dispatch(NewRunnableMethod(this, &TheoraDecoder::ProcessDrain));
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
|
@ -24,10 +24,10 @@ public:
|
||||||
~TheoraDecoder();
|
~TheoraDecoder();
|
||||||
|
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
|
|
||||||
// Return true if mimetype is a Theora codec
|
// Return true if mimetype is a Theora codec
|
||||||
static bool IsTheora(const nsACString& aMimeType);
|
static bool IsTheora(const nsACString& aMimeType);
|
||||||
|
|
|
@ -49,11 +49,10 @@ VPXDecoder::~VPXDecoder()
|
||||||
MOZ_COUNT_DTOR(VPXDecoder);
|
MOZ_COUNT_DTOR(VPXDecoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
VPXDecoder::Shutdown()
|
VPXDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
vpx_codec_destroy(&mVPX);
|
vpx_codec_destroy(&mVPX);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<MediaDataDecoder::InitPromise>
|
RefPtr<MediaDataDecoder::InitPromise>
|
||||||
|
@ -84,7 +83,7 @@ VPXDecoder::Init()
|
||||||
return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
|
return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
VPXDecoder::Flush()
|
VPXDecoder::Flush()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
|
@ -94,7 +93,6 @@ VPXDecoder::Flush()
|
||||||
});
|
});
|
||||||
SyncRunnable::DispatchToThread(mTaskQueue, r);
|
SyncRunnable::DispatchToThread(mTaskQueue, r);
|
||||||
mIsFlushing = false;
|
mIsFlushing = false;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -197,14 +195,12 @@ VPXDecoder::ProcessDecode(MediaRawData* aSample)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
VPXDecoder::Input(MediaRawData* aSample)
|
VPXDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>(
|
mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>(
|
||||||
this, &VPXDecoder::ProcessDecode, aSample));
|
this, &VPXDecoder::ProcessDecode, aSample));
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -214,13 +210,11 @@ VPXDecoder::ProcessDrain()
|
||||||
mCallback->DrainComplete();
|
mCallback->DrainComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
VPXDecoder::Drain()
|
VPXDecoder::Drain()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
mTaskQueue->Dispatch(NewRunnableMethod(this, &VPXDecoder::ProcessDrain));
|
mTaskQueue->Dispatch(NewRunnableMethod(this, &VPXDecoder::ProcessDrain));
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
|
@ -25,10 +25,10 @@ public:
|
||||||
~VPXDecoder();
|
~VPXDecoder();
|
||||||
|
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
return "libvpx video decoder";
|
return "libvpx video decoder";
|
||||||
|
|
|
@ -54,11 +54,9 @@ VorbisDataDecoder::~VorbisDataDecoder()
|
||||||
vorbis_comment_clear(&mVorbisComment);
|
vorbis_comment_clear(&mVorbisComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
VorbisDataDecoder::Shutdown()
|
VorbisDataDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
//mReader = nullptr;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<MediaDataDecoder::InitPromise>
|
RefPtr<MediaDataDecoder::InitPromise>
|
||||||
|
@ -124,14 +122,12 @@ VorbisDataDecoder::DecodeHeader(const unsigned char* aData, size_t aLength)
|
||||||
return r == 0 ? NS_OK : NS_ERROR_FAILURE;
|
return r == 0 ? NS_OK : NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
VorbisDataDecoder::Input(MediaRawData* aSample)
|
VorbisDataDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>(
|
mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>(
|
||||||
this, &VorbisDataDecoder::ProcessDecode, aSample));
|
this, &VorbisDataDecoder::ProcessDecode, aSample));
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -255,15 +251,14 @@ VorbisDataDecoder::ProcessDrain()
|
||||||
mCallback->DrainComplete();
|
mCallback->DrainComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
VorbisDataDecoder::Drain()
|
VorbisDataDecoder::Drain()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
mTaskQueue->Dispatch(NewRunnableMethod(this, &VorbisDataDecoder::ProcessDrain));
|
mTaskQueue->Dispatch(NewRunnableMethod(this, &VorbisDataDecoder::ProcessDrain));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
VorbisDataDecoder::Flush()
|
VorbisDataDecoder::Flush()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
|
@ -277,7 +272,6 @@ VorbisDataDecoder::Flush()
|
||||||
});
|
});
|
||||||
SyncRunnable::DispatchToThread(mTaskQueue, r);
|
SyncRunnable::DispatchToThread(mTaskQueue, r);
|
||||||
mIsFlushing = false;
|
mIsFlushing = false;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
|
@ -25,10 +25,10 @@ public:
|
||||||
~VorbisDataDecoder();
|
~VorbisDataDecoder();
|
||||||
|
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
return "vorbis audio decoder";
|
return "vorbis audio decoder";
|
||||||
|
|
|
@ -51,10 +51,9 @@ WaveDataDecoder::WaveDataDecoder(const CreateDecoderParams& aParams)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
WaveDataDecoder::Shutdown()
|
WaveDataDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<MediaDataDecoder::InitPromise>
|
RefPtr<MediaDataDecoder::InitPromise>
|
||||||
|
@ -63,7 +62,7 @@ WaveDataDecoder::Init()
|
||||||
return InitPromise::CreateAndResolve(TrackInfo::kAudioTrack, __func__);
|
return InitPromise::CreateAndResolve(TrackInfo::kAudioTrack, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
WaveDataDecoder::Input(MediaRawData* aSample)
|
WaveDataDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
if (!DoDecode(aSample)) {
|
if (!DoDecode(aSample)) {
|
||||||
|
@ -71,7 +70,6 @@ WaveDataDecoder::Input(MediaRawData* aSample)
|
||||||
} else {
|
} else {
|
||||||
mCallback->InputExhausted();
|
mCallback->InputExhausted();
|
||||||
}
|
}
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -131,17 +129,15 @@ WaveDataDecoder::DoDecode(MediaRawData* aSample)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
WaveDataDecoder::Drain()
|
WaveDataDecoder::Drain()
|
||||||
{
|
{
|
||||||
mCallback->DrainComplete();
|
mCallback->DrainComplete();
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
WaveDataDecoder::Flush()
|
WaveDataDecoder::Flush()
|
||||||
{
|
{
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
|
|
|
@ -21,10 +21,10 @@ public:
|
||||||
static bool IsWave(const nsACString& aMimeType);
|
static bool IsWave(const nsACString& aMimeType);
|
||||||
|
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
return "wave audio decoder";
|
return "wave audio decoder";
|
||||||
|
|
|
@ -45,14 +45,14 @@ public:
|
||||||
return mDecoder->Init();
|
return mDecoder->Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Input(MediaRawData* aSample) override {
|
void Input(MediaRawData* aSample) override {
|
||||||
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
||||||
if (mIsShutdown) {
|
if (mIsShutdown) {
|
||||||
NS_WARNING("EME encrypted sample arrived after shutdown");
|
NS_WARNING("EME encrypted sample arrived after shutdown");
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
if (mSamplesWaitingForKey->WaitIfKeyNotUsable(aSample)) {
|
if (mSamplesWaitingForKey->WaitIfKeyNotUsable(aSample)) {
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAutoPtr<MediaRawDataWriter> writer(aSample->CreateWriter());
|
nsAutoPtr<MediaRawDataWriter> writer(aSample->CreateWriter());
|
||||||
|
@ -64,7 +64,7 @@ public:
|
||||||
mTaskQueue, __func__, this,
|
mTaskQueue, __func__, this,
|
||||||
&EMEDecryptor::Decrypted,
|
&EMEDecryptor::Decrypted,
|
||||||
&EMEDecryptor::Decrypted));
|
&EMEDecryptor::Decrypted));
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Decrypted(const DecryptResult& aDecrypted) {
|
void Decrypted(const DecryptResult& aDecrypted) {
|
||||||
|
@ -104,12 +104,11 @@ public:
|
||||||
// by gmp-clearkey, decoding will fail.
|
// by gmp-clearkey, decoding will fail.
|
||||||
UniquePtr<MediaRawDataWriter> writer(aDecrypted.mSample->CreateWriter());
|
UniquePtr<MediaRawDataWriter> writer(aDecrypted.mSample->CreateWriter());
|
||||||
writer->mCrypto = CryptoSample();
|
writer->mCrypto = CryptoSample();
|
||||||
nsresult rv = mDecoder->Input(aDecrypted.mSample);
|
mDecoder->Input(aDecrypted.mSample);
|
||||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Flush() override {
|
void Flush() override {
|
||||||
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
||||||
MOZ_ASSERT(!mIsShutdown);
|
MOZ_ASSERT(!mIsShutdown);
|
||||||
for (auto iter = mDecrypts.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mDecrypts.Iter(); !iter.Done(); iter.Next()) {
|
||||||
|
@ -117,13 +116,11 @@ public:
|
||||||
holder->DisconnectIfExists();
|
holder->DisconnectIfExists();
|
||||||
iter.Remove();
|
iter.Remove();
|
||||||
}
|
}
|
||||||
nsresult rv = mDecoder->Flush();
|
mDecoder->Flush();
|
||||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
|
||||||
mSamplesWaitingForKey->Flush();
|
mSamplesWaitingForKey->Flush();
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Drain() override {
|
void Drain() override {
|
||||||
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
||||||
MOZ_ASSERT(!mIsShutdown);
|
MOZ_ASSERT(!mIsShutdown);
|
||||||
for (auto iter = mDecrypts.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mDecrypts.Iter(); !iter.Done(); iter.Next()) {
|
||||||
|
@ -131,23 +128,19 @@ public:
|
||||||
holder->DisconnectIfExists();
|
holder->DisconnectIfExists();
|
||||||
iter.Remove();
|
iter.Remove();
|
||||||
}
|
}
|
||||||
nsresult rv = mDecoder->Drain();
|
mDecoder->Drain();
|
||||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Shutdown() override {
|
void Shutdown() override {
|
||||||
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
||||||
MOZ_ASSERT(!mIsShutdown);
|
MOZ_ASSERT(!mIsShutdown);
|
||||||
mIsShutdown = true;
|
mIsShutdown = true;
|
||||||
nsresult rv = mDecoder->Shutdown();
|
mDecoder->Shutdown();
|
||||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
|
||||||
mSamplesWaitingForKey->BreakCycles();
|
mSamplesWaitingForKey->BreakCycles();
|
||||||
mSamplesWaitingForKey = nullptr;
|
mSamplesWaitingForKey = nullptr;
|
||||||
mDecoder = nullptr;
|
mDecoder = nullptr;
|
||||||
mProxy = nullptr;
|
mProxy = nullptr;
|
||||||
mCallback = nullptr;
|
mCallback = nullptr;
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GetDescriptionName() const override {
|
const char* GetDescriptionName() const override {
|
||||||
|
@ -178,38 +171,36 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RefPtr<SamplesWaitingForKey> mSamplesWaitingForKey;
|
RefPtr<SamplesWaitingForKey> mSamplesWaitingForKey;
|
||||||
RefPtr<CDMProxy> mProxy;
|
RefPtr<CDMProxy> mProxy;
|
||||||
};
|
};
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
EMEMediaDataDecoderProxy::Input(MediaRawData* aSample)
|
EMEMediaDataDecoderProxy::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
if (mSamplesWaitingForKey->WaitIfKeyNotUsable(aSample)) {
|
if (mSamplesWaitingForKey->WaitIfKeyNotUsable(aSample)) {
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAutoPtr<MediaRawDataWriter> writer(aSample->CreateWriter());
|
nsAutoPtr<MediaRawDataWriter> writer(aSample->CreateWriter());
|
||||||
mProxy->GetSessionIdsForKeyId(aSample->mCrypto.mKeyId,
|
mProxy->GetSessionIdsForKeyId(aSample->mCrypto.mKeyId,
|
||||||
writer->mCrypto.mSessionIds);
|
writer->mCrypto.mSessionIds);
|
||||||
|
|
||||||
return MediaDataDecoderProxy::Input(aSample);
|
MediaDataDecoderProxy::Input(aSample);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
EMEMediaDataDecoderProxy::Shutdown()
|
EMEMediaDataDecoderProxy::Shutdown()
|
||||||
{
|
{
|
||||||
nsresult rv = MediaDataDecoderProxy::Shutdown();
|
MediaDataDecoderProxy::Shutdown();
|
||||||
|
|
||||||
mSamplesWaitingForKey->BreakCycles();
|
mSamplesWaitingForKey->BreakCycles();
|
||||||
mSamplesWaitingForKey = nullptr;
|
mSamplesWaitingForKey = nullptr;
|
||||||
mProxy = nullptr;
|
mProxy = nullptr;
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EMEDecoderModule::EMEDecoderModule(CDMProxy* aProxy, PDMFactory* aPDM)
|
EMEDecoderModule::EMEDecoderModule(CDMProxy* aProxy, PDMFactory* aPDM)
|
||||||
|
|
|
@ -239,7 +239,7 @@ GMPAudioDecoder::Init()
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
GMPAudioDecoder::Input(MediaRawData* aSample)
|
GMPAudioDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(IsOnGMPThread());
|
MOZ_ASSERT(IsOnGMPThread());
|
||||||
|
@ -247,7 +247,7 @@ GMPAudioDecoder::Input(MediaRawData* aSample)
|
||||||
RefPtr<MediaRawData> sample(aSample);
|
RefPtr<MediaRawData> sample(aSample);
|
||||||
if (!mGMP) {
|
if (!mGMP) {
|
||||||
mCallback->Error(MediaDataDecoderError::FATAL_ERROR);
|
mCallback->Error(MediaDataDecoderError::FATAL_ERROR);
|
||||||
return NS_ERROR_FAILURE;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mAdapter->SetLastStreamOffset(sample->mOffset);
|
mAdapter->SetLastStreamOffset(sample->mOffset);
|
||||||
|
@ -256,13 +256,10 @@ GMPAudioDecoder::Input(MediaRawData* aSample)
|
||||||
nsresult rv = mGMP->Decode(samples);
|
nsresult rv = mGMP->Decode(samples);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
mCallback->Error(MediaDataDecoderError::DECODE_ERROR);
|
mCallback->Error(MediaDataDecoderError::DECODE_ERROR);
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
GMPAudioDecoder::Flush()
|
GMPAudioDecoder::Flush()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(IsOnGMPThread());
|
MOZ_ASSERT(IsOnGMPThread());
|
||||||
|
@ -271,11 +268,9 @@ GMPAudioDecoder::Flush()
|
||||||
// Abort the flush.
|
// Abort the flush.
|
||||||
mCallback->FlushComplete();
|
mCallback->FlushComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
GMPAudioDecoder::Drain()
|
GMPAudioDecoder::Drain()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(IsOnGMPThread());
|
MOZ_ASSERT(IsOnGMPThread());
|
||||||
|
@ -283,22 +278,18 @@ GMPAudioDecoder::Drain()
|
||||||
if (!mGMP || NS_FAILED(mGMP->Drain())) {
|
if (!mGMP || NS_FAILED(mGMP->Drain())) {
|
||||||
mCallback->DrainComplete();
|
mCallback->DrainComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
GMPAudioDecoder::Shutdown()
|
GMPAudioDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
mInitPromise.RejectIfExists(MediaDataDecoder::DecoderFailureReason::CANCELED, __func__);
|
mInitPromise.RejectIfExists(MediaDataDecoder::DecoderFailureReason::CANCELED, __func__);
|
||||||
if (!mGMP) {
|
if (!mGMP) {
|
||||||
return NS_ERROR_FAILURE;
|
return;
|
||||||
}
|
}
|
||||||
// Note this unblocks flush and drain operations waiting for callbacks.
|
// Note this unblocks flush and drain operations waiting for callbacks.
|
||||||
mGMP->Close();
|
mGMP->Close();
|
||||||
mGMP = nullptr;
|
mGMP = nullptr;
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -65,10 +65,10 @@ public:
|
||||||
explicit GMPAudioDecoder(const GMPAudioDecoderParams& aParams);
|
explicit GMPAudioDecoder(const GMPAudioDecoderParams& aParams);
|
||||||
|
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
return "GMP audio decoder";
|
return "GMP audio decoder";
|
||||||
|
|
|
@ -313,7 +313,7 @@ GMPVideoDecoder::Init()
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
GMPVideoDecoder::Input(MediaRawData* aSample)
|
GMPVideoDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(IsOnGMPThread());
|
MOZ_ASSERT(IsOnGMPThread());
|
||||||
|
@ -321,7 +321,7 @@ GMPVideoDecoder::Input(MediaRawData* aSample)
|
||||||
RefPtr<MediaRawData> sample(aSample);
|
RefPtr<MediaRawData> sample(aSample);
|
||||||
if (!mGMP) {
|
if (!mGMP) {
|
||||||
mCallback->Error(MediaDataDecoderError::FATAL_ERROR);
|
mCallback->Error(MediaDataDecoderError::FATAL_ERROR);
|
||||||
return NS_ERROR_FAILURE;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mAdapter->SetLastStreamOffset(sample->mOffset);
|
mAdapter->SetLastStreamOffset(sample->mOffset);
|
||||||
|
@ -329,19 +329,16 @@ GMPVideoDecoder::Input(MediaRawData* aSample)
|
||||||
GMPUniquePtr<GMPVideoEncodedFrame> frame = CreateFrame(sample);
|
GMPUniquePtr<GMPVideoEncodedFrame> frame = CreateFrame(sample);
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
mCallback->Error(MediaDataDecoderError::FATAL_ERROR);
|
mCallback->Error(MediaDataDecoderError::FATAL_ERROR);
|
||||||
return NS_ERROR_FAILURE;
|
return;
|
||||||
}
|
}
|
||||||
nsTArray<uint8_t> info; // No codec specific per-frame info to pass.
|
nsTArray<uint8_t> info; // No codec specific per-frame info to pass.
|
||||||
nsresult rv = mGMP->Decode(Move(frame), false, info, 0);
|
nsresult rv = mGMP->Decode(Move(frame), false, info, 0);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
mCallback->Error(MediaDataDecoderError::DECODE_ERROR);
|
mCallback->Error(MediaDataDecoderError::DECODE_ERROR);
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
GMPVideoDecoder::Flush()
|
GMPVideoDecoder::Flush()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(IsOnGMPThread());
|
MOZ_ASSERT(IsOnGMPThread());
|
||||||
|
@ -350,11 +347,9 @@ GMPVideoDecoder::Flush()
|
||||||
// Abort the flush.
|
// Abort the flush.
|
||||||
mCallback->FlushComplete();
|
mCallback->FlushComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
GMPVideoDecoder::Drain()
|
GMPVideoDecoder::Drain()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(IsOnGMPThread());
|
MOZ_ASSERT(IsOnGMPThread());
|
||||||
|
@ -362,23 +357,19 @@ GMPVideoDecoder::Drain()
|
||||||
if (!mGMP || NS_FAILED(mGMP->Drain())) {
|
if (!mGMP || NS_FAILED(mGMP->Drain())) {
|
||||||
mCallback->DrainComplete();
|
mCallback->DrainComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
GMPVideoDecoder::Shutdown()
|
GMPVideoDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
mInitPromise.RejectIfExists(MediaDataDecoder::DecoderFailureReason::CANCELED, __func__);
|
mInitPromise.RejectIfExists(MediaDataDecoder::DecoderFailureReason::CANCELED, __func__);
|
||||||
// Note that this *may* be called from the proxy thread also.
|
// Note that this *may* be called from the proxy thread also.
|
||||||
if (!mGMP) {
|
if (!mGMP) {
|
||||||
return NS_ERROR_FAILURE;
|
return;
|
||||||
}
|
}
|
||||||
// Note this unblocks flush and drain operations waiting for callbacks.
|
// Note this unblocks flush and drain operations waiting for callbacks.
|
||||||
mGMP->Close();
|
mGMP->Close();
|
||||||
mGMP = nullptr;
|
mGMP = nullptr;
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -70,10 +70,10 @@ public:
|
||||||
explicit GMPVideoDecoder(const GMPVideoDecoderParams& aParams);
|
explicit GMPVideoDecoder(const GMPVideoDecoderParams& aParams);
|
||||||
|
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
return "GMP video decoder";
|
return "GMP video decoder";
|
||||||
|
|
|
@ -38,7 +38,7 @@ MediaDataDecoderProxy::Init()
|
||||||
&MediaDataDecoderProxy::InternalInit);
|
&MediaDataDecoderProxy::InternalInit);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
MediaDataDecoderProxy::Input(MediaRawData* aSample)
|
MediaDataDecoderProxy::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(!IsOnProxyThread());
|
MOZ_ASSERT(!IsOnProxyThread());
|
||||||
|
@ -46,11 +46,9 @@ MediaDataDecoderProxy::Input(MediaRawData* aSample)
|
||||||
|
|
||||||
nsCOMPtr<nsIRunnable> task(new InputTask(mProxyDecoder, aSample));
|
nsCOMPtr<nsIRunnable> task(new InputTask(mProxyDecoder, aSample));
|
||||||
mProxyThread->Dispatch(task.forget());
|
mProxyThread->Dispatch(task.forget());
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
MediaDataDecoderProxy::Flush()
|
MediaDataDecoderProxy::Flush()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(!IsOnProxyThread());
|
MOZ_ASSERT(!IsOnProxyThread());
|
||||||
|
@ -61,21 +59,18 @@ MediaDataDecoderProxy::Flush()
|
||||||
mProxyThread->Dispatch(NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Flush));
|
mProxyThread->Dispatch(NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Flush));
|
||||||
|
|
||||||
mFlushComplete.WaitUntil(true);
|
mFlushComplete.WaitUntil(true);
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
MediaDataDecoderProxy::Drain()
|
MediaDataDecoderProxy::Drain()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(!IsOnProxyThread());
|
MOZ_ASSERT(!IsOnProxyThread());
|
||||||
MOZ_ASSERT(!mIsShutdown);
|
MOZ_ASSERT(!mIsShutdown);
|
||||||
|
|
||||||
mProxyThread->Dispatch(NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Drain));
|
mProxyThread->Dispatch(NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Drain));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
MediaDataDecoderProxy::Shutdown()
|
MediaDataDecoderProxy::Shutdown()
|
||||||
{
|
{
|
||||||
// Note that this *may* be called from the proxy thread also.
|
// Note that this *may* be called from the proxy thread also.
|
||||||
|
@ -83,11 +78,9 @@ MediaDataDecoderProxy::Shutdown()
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
mIsShutdown = true;
|
mIsShutdown = true;
|
||||||
#endif
|
#endif
|
||||||
nsresult rv = mProxyThread->AsXPCOMThread()->Dispatch(NewRunnableMethod(mProxyDecoder,
|
mProxyThread->AsXPCOMThread()->Dispatch(NewRunnableMethod(mProxyDecoder,
|
||||||
&MediaDataDecoder::Shutdown),
|
&MediaDataDecoder::Shutdown),
|
||||||
NS_DISPATCH_SYNC);
|
NS_DISPATCH_SYNC);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -140,10 +140,10 @@ public:
|
||||||
// asynchronously and responded to via the MediaDataDecoderCallback.
|
// asynchronously and responded to via the MediaDataDecoderCallback.
|
||||||
// Note: the nsresults returned by the proxied decoder are lost.
|
// Note: the nsresults returned by the proxied decoder are lost.
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
|
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,11 +89,6 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Input(MediaRawData* aSample) override
|
|
||||||
{
|
|
||||||
return MediaCodecDataDecoder::Input(aSample);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult PostOutput(BufferInfo::Param aInfo, MediaFormat::Param aFormat,
|
nsresult PostOutput(BufferInfo::Param aInfo, MediaFormat::Param aFormat,
|
||||||
const TimeUnit& aDuration) override
|
const TimeUnit& aDuration) override
|
||||||
{
|
{
|
||||||
|
@ -618,14 +613,12 @@ MediaCodecDataDecoder::ClearQueue()
|
||||||
mDurations.clear();
|
mDurations.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
MediaCodecDataDecoder::Input(MediaRawData* aSample)
|
MediaCodecDataDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
MonitorAutoLock lock(mMonitor);
|
MonitorAutoLock lock(mMonitor);
|
||||||
mQueue.push_back(aSample);
|
mQueue.push_back(aSample);
|
||||||
lock.NotifyAll();
|
lock.NotifyAll();
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -640,39 +633,35 @@ MediaCodecDataDecoder::ResetOutputBuffers()
|
||||||
return mDecoder->GetOutputBuffers(ReturnTo(&mOutputBuffers));
|
return mDecoder->GetOutputBuffers(ReturnTo(&mOutputBuffers));
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
MediaCodecDataDecoder::Flush()
|
MediaCodecDataDecoder::Flush()
|
||||||
{
|
{
|
||||||
MonitorAutoLock lock(mMonitor);
|
MonitorAutoLock lock(mMonitor);
|
||||||
if (!SetState(ModuleState::kFlushing)) {
|
if (!SetState(ModuleState::kFlushing)) {
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
lock.Notify();
|
lock.Notify();
|
||||||
|
|
||||||
while (mState == ModuleState::kFlushing) {
|
while (mState == ModuleState::kFlushing) {
|
||||||
lock.Wait();
|
lock.Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
MediaCodecDataDecoder::Drain()
|
MediaCodecDataDecoder::Drain()
|
||||||
{
|
{
|
||||||
MonitorAutoLock lock(mMonitor);
|
MonitorAutoLock lock(mMonitor);
|
||||||
if (mState == ModuleState::kDrainDecoder ||
|
if (mState == ModuleState::kDrainDecoder ||
|
||||||
mState == ModuleState::kDrainQueue) {
|
mState == ModuleState::kDrainQueue) {
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetState(ModuleState::kDrainQueue);
|
SetState(ModuleState::kDrainQueue);
|
||||||
lock.Notify();
|
lock.Notify();
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
MediaCodecDataDecoder::Shutdown()
|
MediaCodecDataDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
MonitorAutoLock lock(mMonitor);
|
MonitorAutoLock lock(mMonitor);
|
||||||
|
@ -694,8 +683,6 @@ MediaCodecDataDecoder::Shutdown()
|
||||||
mDecoder->Release();
|
mDecoder->Release();
|
||||||
mDecoder = nullptr;
|
mDecoder = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // mozilla
|
} // mozilla
|
||||||
|
|
|
@ -33,10 +33,10 @@ public:
|
||||||
virtual ~MediaCodecDataDecoder();
|
virtual ~MediaCodecDataDecoder();
|
||||||
|
|
||||||
RefPtr<MediaDataDecoder::InitPromise> Init() override;
|
RefPtr<MediaDataDecoder::InitPromise> Init() override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
return "Android MediaCodec decoder";
|
return "Android MediaCodec decoder";
|
||||||
|
|
|
@ -216,28 +216,22 @@ public:
|
||||||
return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
|
return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Flush() override
|
void Flush() override
|
||||||
{
|
{
|
||||||
mInputDurations.Clear();
|
mInputDurations.Clear();
|
||||||
return RemoteDataDecoder::Flush();
|
RemoteDataDecoder::Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Drain() override
|
void Drain() override
|
||||||
{
|
{
|
||||||
nsresult res = RemoteDataDecoder::Drain();
|
RemoteDataDecoder::Drain();
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
|
||||||
|
|
||||||
mInputDurations.Put(0);
|
mInputDurations.Put(0);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult Input(MediaRawData* aSample) override
|
void Input(MediaRawData* aSample) override
|
||||||
{
|
{
|
||||||
nsresult res = RemoteDataDecoder::Input(aSample);
|
RemoteDataDecoder::Input(aSample);
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
|
||||||
|
|
||||||
mInputDurations.Put(aSample->mDuration);
|
mInputDurations.Put(aSample->mDuration);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -432,26 +426,24 @@ RemoteDataDecoder::RemoteDataDecoder(MediaData::Type aType,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
RemoteDataDecoder::Flush()
|
RemoteDataDecoder::Flush()
|
||||||
{
|
{
|
||||||
mJavaDecoder->Flush();
|
mJavaDecoder->Flush();
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
RemoteDataDecoder::Drain()
|
RemoteDataDecoder::Drain()
|
||||||
{
|
{
|
||||||
BufferInfo::LocalRef bufferInfo;
|
BufferInfo::LocalRef bufferInfo;
|
||||||
nsresult rv = BufferInfo::New(&bufferInfo);
|
nsresult rv = BufferInfo::New(&bufferInfo);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS_VOID(rv);
|
||||||
bufferInfo->Set(0, 0, -1, MediaCodec::BUFFER_FLAG_END_OF_STREAM);
|
bufferInfo->Set(0, 0, -1, MediaCodec::BUFFER_FLAG_END_OF_STREAM);
|
||||||
|
|
||||||
mJavaDecoder->Input(nullptr, bufferInfo);
|
mJavaDecoder->Input(nullptr, bufferInfo);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
RemoteDataDecoder::Shutdown()
|
RemoteDataDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
LOG("");
|
LOG("");
|
||||||
|
@ -464,11 +456,9 @@ RemoteDataDecoder::Shutdown()
|
||||||
mJavaCallbacks = nullptr;
|
mJavaCallbacks = nullptr;
|
||||||
|
|
||||||
mFormat = nullptr;
|
mFormat = nullptr;
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
RemoteDataDecoder::Input(MediaRawData* aSample)
|
RemoteDataDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aSample != nullptr);
|
MOZ_ASSERT(aSample != nullptr);
|
||||||
|
@ -485,12 +475,13 @@ RemoteDataDecoder::Input(MediaRawData* aSample)
|
||||||
|
|
||||||
BufferInfo::LocalRef bufferInfo;
|
BufferInfo::LocalRef bufferInfo;
|
||||||
nsresult rv = BufferInfo::New(&bufferInfo);
|
nsresult rv = BufferInfo::New(&bufferInfo);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_FAILED(rv)) {
|
||||||
|
mCallback->Error(MediaDataDecoderError::FATAL_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
bufferInfo->Set(0, aSample->Size(), aSample->mTime, 0);
|
bufferInfo->Set(0, aSample->Size(), aSample->mTime, 0);
|
||||||
|
|
||||||
mJavaDecoder->Input(bytes, bufferInfo);
|
mJavaDecoder->Input(bytes, bufferInfo);
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // mozilla
|
} // mozilla
|
||||||
|
|
|
@ -31,10 +31,10 @@ public:
|
||||||
|
|
||||||
virtual ~RemoteDataDecoder() {}
|
virtual ~RemoteDataDecoder() {}
|
||||||
|
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
return "android remote decoder";
|
return "android remote decoder";
|
||||||
|
|
|
@ -63,7 +63,7 @@ AppleATDecoder::Init()
|
||||||
return InitPromise::CreateAndResolve(TrackType::kAudioTrack, __func__);
|
return InitPromise::CreateAndResolve(TrackType::kAudioTrack, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
AppleATDecoder::Input(MediaRawData* aSample)
|
AppleATDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
|
@ -81,8 +81,6 @@ AppleATDecoder::Input(MediaRawData* aSample)
|
||||||
&AppleATDecoder::SubmitSample,
|
&AppleATDecoder::SubmitSample,
|
||||||
RefPtr<MediaRawData>(aSample));
|
RefPtr<MediaRawData>(aSample));
|
||||||
mTaskQueue->Dispatch(runnable.forget());
|
mTaskQueue->Dispatch(runnable.forget());
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -96,7 +94,7 @@ AppleATDecoder::ProcessFlush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
AppleATDecoder::Flush()
|
AppleATDecoder::Flush()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
|
@ -106,20 +104,19 @@ AppleATDecoder::Flush()
|
||||||
NewRunnableMethod(this, &AppleATDecoder::ProcessFlush);
|
NewRunnableMethod(this, &AppleATDecoder::ProcessFlush);
|
||||||
SyncRunnable::DispatchToThread(mTaskQueue, runnable);
|
SyncRunnable::DispatchToThread(mTaskQueue, runnable);
|
||||||
mIsFlushing = false;
|
mIsFlushing = false;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
AppleATDecoder::Drain()
|
AppleATDecoder::Drain()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
LOG("Draining AudioToolbox AAC decoder");
|
LOG("Draining AudioToolbox AAC decoder");
|
||||||
mTaskQueue->AwaitIdle();
|
mTaskQueue->AwaitIdle();
|
||||||
mCallback->DrainComplete();
|
mCallback->DrainComplete();
|
||||||
return Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
AppleATDecoder::Shutdown()
|
AppleATDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
|
@ -129,7 +126,7 @@ AppleATDecoder::Shutdown()
|
||||||
OSStatus rv = AudioConverterDispose(mConverter);
|
OSStatus rv = AudioConverterDispose(mConverter);
|
||||||
if (rv) {
|
if (rv) {
|
||||||
LOG("error %d disposing of AudioConverter", rv);
|
LOG("error %d disposing of AudioConverter", rv);
|
||||||
return NS_ERROR_FAILURE;
|
return;
|
||||||
}
|
}
|
||||||
mConverter = nullptr;
|
mConverter = nullptr;
|
||||||
|
|
||||||
|
@ -137,11 +134,10 @@ AppleATDecoder::Shutdown()
|
||||||
rv = AudioFileStreamClose(mStream);
|
rv = AudioFileStreamClose(mStream);
|
||||||
if (rv) {
|
if (rv) {
|
||||||
LOG("error %d disposing of AudioFileStream", rv);
|
LOG("error %d disposing of AudioFileStream", rv);
|
||||||
return NS_ERROR_FAILURE;
|
return;
|
||||||
}
|
}
|
||||||
mStream = nullptr;
|
mStream = nullptr;
|
||||||
}
|
}
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PassthroughUserData {
|
struct PassthroughUserData {
|
||||||
|
|
|
@ -27,10 +27,10 @@ public:
|
||||||
virtual ~AppleATDecoder();
|
virtual ~AppleATDecoder();
|
||||||
|
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
|
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,7 +74,7 @@ AppleVTDecoder::Init()
|
||||||
return InitPromise::CreateAndReject(DecoderFailureReason::INIT_ERROR, __func__);
|
return InitPromise::CreateAndReject(DecoderFailureReason::INIT_ERROR, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
AppleVTDecoder::Input(MediaRawData* aSample)
|
AppleVTDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
|
@ -88,10 +88,9 @@ AppleVTDecoder::Input(MediaRawData* aSample)
|
||||||
|
|
||||||
mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>(
|
mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>(
|
||||||
this, &AppleVTDecoder::ProcessDecode, aSample));
|
this, &AppleVTDecoder::ProcessDecode, aSample));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
AppleVTDecoder::Flush()
|
AppleVTDecoder::Flush()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
|
@ -102,21 +101,18 @@ AppleVTDecoder::Flush()
|
||||||
mIsFlushing = false;
|
mIsFlushing = false;
|
||||||
|
|
||||||
mSeekTargetThreshold.reset();
|
mSeekTargetThreshold.reset();
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
AppleVTDecoder::Drain()
|
AppleVTDecoder::Drain()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
nsCOMPtr<nsIRunnable> runnable =
|
nsCOMPtr<nsIRunnable> runnable =
|
||||||
NewRunnableMethod(this, &AppleVTDecoder::ProcessDrain);
|
NewRunnableMethod(this, &AppleVTDecoder::ProcessDrain);
|
||||||
mTaskQueue->Dispatch(runnable.forget());
|
mTaskQueue->Dispatch(runnable.forget());
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
AppleVTDecoder::Shutdown()
|
AppleVTDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown);
|
MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown);
|
||||||
|
@ -128,7 +124,6 @@ AppleVTDecoder::Shutdown()
|
||||||
} else {
|
} else {
|
||||||
ProcessShutdown();
|
ProcessShutdown();
|
||||||
}
|
}
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|
|
@ -43,10 +43,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
void SetSeekThreshold(const media::TimeUnit& aTime) override;
|
void SetSeekThreshold(const media::TimeUnit& aTime) override;
|
||||||
|
|
||||||
bool IsHardwareAccelerated(nsACString& aFailureReason) const override
|
bool IsHardwareAccelerated(nsACString& aFailureReason) const override
|
||||||
|
|
|
@ -90,7 +90,7 @@ FFmpegDataDecoder<LIBAV_VER>::InitDecoder()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
FFmpegDataDecoder<LIBAV_VER>::Shutdown()
|
FFmpegDataDecoder<LIBAV_VER>::Shutdown()
|
||||||
{
|
{
|
||||||
if (mTaskQueue) {
|
if (mTaskQueue) {
|
||||||
|
@ -100,7 +100,6 @@ FFmpegDataDecoder<LIBAV_VER>::Shutdown()
|
||||||
} else {
|
} else {
|
||||||
ProcessShutdown();
|
ProcessShutdown();
|
||||||
}
|
}
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -126,15 +125,14 @@ FFmpegDataDecoder<LIBAV_VER>::ProcessDecode(MediaRawData* aSample)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
FFmpegDataDecoder<LIBAV_VER>::Input(MediaRawData* aSample)
|
FFmpegDataDecoder<LIBAV_VER>::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>(
|
mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>(
|
||||||
this, &FFmpegDataDecoder::ProcessDecode, aSample));
|
this, &FFmpegDataDecoder::ProcessDecode, aSample));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
FFmpegDataDecoder<LIBAV_VER>::Flush()
|
FFmpegDataDecoder<LIBAV_VER>::Flush()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
|
@ -143,17 +141,15 @@ FFmpegDataDecoder<LIBAV_VER>::Flush()
|
||||||
NewRunnableMethod(this, &FFmpegDataDecoder<LIBAV_VER>::ProcessFlush);
|
NewRunnableMethod(this, &FFmpegDataDecoder<LIBAV_VER>::ProcessFlush);
|
||||||
SyncRunnable::DispatchToThread(mTaskQueue, runnable);
|
SyncRunnable::DispatchToThread(mTaskQueue, runnable);
|
||||||
mIsFlushing = false;
|
mIsFlushing = false;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
FFmpegDataDecoder<LIBAV_VER>::Drain()
|
FFmpegDataDecoder<LIBAV_VER>::Drain()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
nsCOMPtr<nsIRunnable> runnable =
|
nsCOMPtr<nsIRunnable> runnable =
|
||||||
NewRunnableMethod(this, &FFmpegDataDecoder<LIBAV_VER>::ProcessDrain);
|
NewRunnableMethod(this, &FFmpegDataDecoder<LIBAV_VER>::ProcessDrain);
|
||||||
mTaskQueue->Dispatch(runnable.forget());
|
mTaskQueue->Dispatch(runnable.forget());
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -32,10 +32,10 @@ public:
|
||||||
static bool Link();
|
static bool Link();
|
||||||
|
|
||||||
RefPtr<InitPromise> Init() override = 0;
|
RefPtr<InitPromise> Init() override = 0;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
|
|
||||||
static AVCodec* FindAVCodec(FFmpegLibWrapper* aLib, AVCodecID aCodec);
|
static AVCodec* FindAVCodec(FFmpegLibWrapper* aLib, AVCodecID aCodec);
|
||||||
|
|
||||||
|
|
|
@ -348,36 +348,33 @@ GonkMediaDataDecoder::Init()
|
||||||
return mManager->Init();
|
return mManager->Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
GonkMediaDataDecoder::Shutdown()
|
GonkMediaDataDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
nsresult rv = mManager->Shutdown();
|
mManager->Shutdown();
|
||||||
|
|
||||||
// Because codec allocated runnable and init promise is at reader TaskQueue,
|
// Because codec allocated runnable and init promise is at reader TaskQueue,
|
||||||
// so manager needs to be destroyed at reader TaskQueue to prevent racing.
|
// so manager needs to be destroyed at reader TaskQueue to prevent racing.
|
||||||
mManager = nullptr;
|
mManager = nullptr;
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inserts data into the decoder's pipeline.
|
// Inserts data into the decoder's pipeline.
|
||||||
nsresult
|
void
|
||||||
GonkMediaDataDecoder::Input(MediaRawData* aSample)
|
GonkMediaDataDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
mManager->Input(aSample);
|
mManager->Input(aSample);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
GonkMediaDataDecoder::Flush()
|
GonkMediaDataDecoder::Flush()
|
||||||
{
|
{
|
||||||
return mManager->Flush();
|
mManager->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
GonkMediaDataDecoder::Drain()
|
GonkMediaDataDecoder::Drain()
|
||||||
{
|
{
|
||||||
mManager->Input(nullptr);
|
mManager->Input(nullptr);
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -192,13 +192,13 @@ public:
|
||||||
|
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
|
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
|
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
|
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
|
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
|
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
|
|
|
@ -175,7 +175,7 @@ OmxDataDecoder::Init()
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
OmxDataDecoder::Input(MediaRawData* aSample)
|
OmxDataDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
LOG("sample %p", aSample);
|
LOG("sample %p", aSample);
|
||||||
|
@ -195,11 +195,9 @@ OmxDataDecoder::Input(MediaRawData* aSample)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mOmxTaskQueue->Dispatch(r.forget());
|
mOmxTaskQueue->Dispatch(r.forget());
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
OmxDataDecoder::Flush()
|
OmxDataDecoder::Flush()
|
||||||
{
|
{
|
||||||
LOG("");
|
LOG("");
|
||||||
|
@ -215,21 +213,17 @@ OmxDataDecoder::Flush()
|
||||||
while (mFlushing) {
|
while (mFlushing) {
|
||||||
lock.Wait();
|
lock.Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
OmxDataDecoder::Drain()
|
OmxDataDecoder::Drain()
|
||||||
{
|
{
|
||||||
LOG("");
|
LOG("");
|
||||||
|
|
||||||
mOmxTaskQueue->Dispatch(NewRunnableMethod(this, &OmxDataDecoder::SendEosBuffer));
|
mOmxTaskQueue->Dispatch(NewRunnableMethod(this, &OmxDataDecoder::SendEosBuffer));
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
OmxDataDecoder::Shutdown()
|
OmxDataDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
LOG("");
|
LOG("");
|
||||||
|
@ -250,8 +244,6 @@ OmxDataDecoder::Shutdown()
|
||||||
|
|
||||||
mOmxTaskQueue->BeginShutdown();
|
mOmxTaskQueue->BeginShutdown();
|
||||||
mOmxTaskQueue->AwaitShutdownAndIdle();
|
mOmxTaskQueue->AwaitShutdownAndIdle();
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -66,13 +66,13 @@ public:
|
||||||
|
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
|
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
|
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
|
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
|
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
|
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,7 +72,7 @@ SendTelemetry(unsigned long hr)
|
||||||
NS_DispatchToMainThread(runnable);
|
NS_DispatchToMainThread(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
WMFMediaDataDecoder::Shutdown()
|
WMFMediaDataDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown);
|
MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown);
|
||||||
|
@ -83,7 +83,6 @@ WMFMediaDataDecoder::Shutdown()
|
||||||
ProcessShutdown();
|
ProcessShutdown();
|
||||||
}
|
}
|
||||||
mIsShutDown = true;
|
mIsShutDown = true;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -99,7 +98,7 @@ WMFMediaDataDecoder::ProcessShutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inserts data into the decoder's pipeline.
|
// Inserts data into the decoder's pipeline.
|
||||||
nsresult
|
void
|
||||||
WMFMediaDataDecoder::Input(MediaRawData* aSample)
|
WMFMediaDataDecoder::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
|
@ -111,7 +110,6 @@ WMFMediaDataDecoder::Input(MediaRawData* aSample)
|
||||||
&WMFMediaDataDecoder::ProcessDecode,
|
&WMFMediaDataDecoder::ProcessDecode,
|
||||||
RefPtr<MediaRawData>(aSample));
|
RefPtr<MediaRawData>(aSample));
|
||||||
mTaskQueue->Dispatch(runnable.forget());
|
mTaskQueue->Dispatch(runnable.forget());
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -168,7 +166,7 @@ WMFMediaDataDecoder::ProcessFlush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
WMFMediaDataDecoder::Flush()
|
WMFMediaDataDecoder::Flush()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
|
@ -179,7 +177,6 @@ WMFMediaDataDecoder::Flush()
|
||||||
NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessFlush);
|
NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessFlush);
|
||||||
SyncRunnable::DispatchToThread(mTaskQueue, runnable);
|
SyncRunnable::DispatchToThread(mTaskQueue, runnable);
|
||||||
mIsFlushing = false;
|
mIsFlushing = false;
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -194,14 +191,13 @@ WMFMediaDataDecoder::ProcessDrain()
|
||||||
mCallback->DrainComplete();
|
mCallback->DrainComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
WMFMediaDataDecoder::Drain()
|
WMFMediaDataDecoder::Drain()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown);
|
MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown);
|
||||||
|
|
||||||
mTaskQueue->Dispatch(NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessDrain));
|
mTaskQueue->Dispatch(NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessDrain));
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -211,7 +207,7 @@ WMFMediaDataDecoder::IsHardwareAccelerated(nsACString& aFailureReason) const {
|
||||||
return mMFTManager && mMFTManager->IsHardwareAccelerated(aFailureReason);
|
return mMFTManager && mMFTManager->IsHardwareAccelerated(aFailureReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
WMFMediaDataDecoder::ConfigurationChanged(const TrackInfo& aConfig)
|
WMFMediaDataDecoder::ConfigurationChanged(const TrackInfo& aConfig)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
|
@ -222,8 +218,6 @@ WMFMediaDataDecoder::ConfigurationChanged(const TrackInfo& aConfig)
|
||||||
&WMFMediaDataDecoder::ProcessConfigurationChanged,
|
&WMFMediaDataDecoder::ProcessConfigurationChanged,
|
||||||
aConfig.Clone());
|
aConfig.Clone());
|
||||||
mTaskQueue->Dispatch(runnable.forget());
|
mTaskQueue->Dispatch(runnable.forget());
|
||||||
return NS_OK;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -86,17 +86,17 @@ public:
|
||||||
|
|
||||||
RefPtr<MediaDataDecoder::InitPromise> Init() override;
|
RefPtr<MediaDataDecoder::InitPromise> Init() override;
|
||||||
|
|
||||||
nsresult Input(MediaRawData* aSample);
|
void Input(MediaRawData* aSample);
|
||||||
|
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
|
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
|
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
|
|
||||||
bool IsHardwareAccelerated(nsACString& aFailureReason) const override;
|
bool IsHardwareAccelerated(nsACString& aFailureReason) const override;
|
||||||
|
|
||||||
nsresult ConfigurationChanged(const TrackInfo& aConfig) override;
|
void ConfigurationChanged(const TrackInfo& aConfig) override;
|
||||||
|
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,47 +39,45 @@ DecoderFuzzingWrapper::Init()
|
||||||
return mDecoder->Init();
|
return mDecoder->Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
DecoderFuzzingWrapper::Input(MediaRawData* aData)
|
DecoderFuzzingWrapper::Input(MediaRawData* aData)
|
||||||
{
|
{
|
||||||
DFW_LOGV("aData.mTime=%lld", aData->mTime);
|
DFW_LOGV("aData.mTime=%lld", aData->mTime);
|
||||||
MOZ_ASSERT(mDecoder);
|
MOZ_ASSERT(mDecoder);
|
||||||
return mDecoder->Input(aData);
|
mDecoder->Input(aData);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
DecoderFuzzingWrapper::Flush()
|
DecoderFuzzingWrapper::Flush()
|
||||||
{
|
{
|
||||||
DFW_LOGV("Calling mDecoder[%p]->Flush()", mDecoder.get());
|
DFW_LOGV("Calling mDecoder[%p]->Flush()", mDecoder.get());
|
||||||
MOZ_ASSERT(mDecoder);
|
MOZ_ASSERT(mDecoder);
|
||||||
// Flush may output some frames (though unlikely).
|
// Flush may output some frames (though unlikely).
|
||||||
// Flush may block a bit, it's ok if we output some frames in the meantime.
|
// Flush may block a bit, it's ok if we output some frames in the meantime.
|
||||||
nsresult result = mDecoder->Flush();
|
mDecoder->Flush();
|
||||||
DFW_LOGV("mDecoder[%p]->Flush() -> result=%u", mDecoder.get(), uint32_t(result));
|
DFW_LOGV("mDecoder[%p]->Flush()", mDecoder.get());
|
||||||
// Clear any delayed output we may have.
|
// Clear any delayed output we may have.
|
||||||
mCallbackWrapper->ClearDelayedOutput();
|
mCallbackWrapper->ClearDelayedOutput();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
DecoderFuzzingWrapper::Drain()
|
DecoderFuzzingWrapper::Drain()
|
||||||
{
|
{
|
||||||
DFW_LOGV("");
|
DFW_LOGV("");
|
||||||
MOZ_ASSERT(mDecoder);
|
MOZ_ASSERT(mDecoder);
|
||||||
// Note: The decoder should callback DrainComplete(), we'll drain the
|
// Note: The decoder should callback DrainComplete(), we'll drain the
|
||||||
// delayed output (if any) then.
|
// delayed output (if any) then.
|
||||||
return mDecoder->Drain();
|
mDecoder->Drain();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
DecoderFuzzingWrapper::Shutdown()
|
DecoderFuzzingWrapper::Shutdown()
|
||||||
{
|
{
|
||||||
DFW_LOGV("");
|
DFW_LOGV("");
|
||||||
MOZ_ASSERT(mDecoder);
|
MOZ_ASSERT(mDecoder);
|
||||||
// Both shutdowns below may block a bit.
|
// Both shutdowns below may block a bit.
|
||||||
nsresult result = mDecoder->Shutdown();
|
mDecoder->Shutdown();
|
||||||
mCallbackWrapper->Shutdown();
|
mCallbackWrapper->Shutdown();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -90,12 +88,12 @@ DecoderFuzzingWrapper::IsHardwareAccelerated(nsACString& aFailureReason) const
|
||||||
return mDecoder->IsHardwareAccelerated(aFailureReason);
|
return mDecoder->IsHardwareAccelerated(aFailureReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
DecoderFuzzingWrapper::ConfigurationChanged(const TrackInfo& aConfig)
|
DecoderFuzzingWrapper::ConfigurationChanged(const TrackInfo& aConfig)
|
||||||
{
|
{
|
||||||
DFW_LOGV("");
|
DFW_LOGV("");
|
||||||
MOZ_ASSERT(mDecoder);
|
MOZ_ASSERT(mDecoder);
|
||||||
return mDecoder->ConfigurationChanged(aConfig);
|
mDecoder->ConfigurationChanged(aConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -103,12 +103,12 @@ public:
|
||||||
|
|
||||||
// MediaDataDecoder implementation.
|
// MediaDataDecoder implementation.
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
bool IsHardwareAccelerated(nsACString& aFailureReason) const override;
|
bool IsHardwareAccelerated(nsACString& aFailureReason) const override;
|
||||||
nsresult ConfigurationChanged(const TrackInfo& aConfig) override;
|
void ConfigurationChanged(const TrackInfo& aConfig) override;
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
return mDecoder->GetDescriptionName();
|
return mDecoder->GetDescriptionName();
|
||||||
|
|
|
@ -49,13 +49,14 @@ H264Converter::Init()
|
||||||
TrackType::kVideoTrack, __func__);
|
TrackType::kVideoTrack, __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
H264Converter::Input(MediaRawData* aSample)
|
H264Converter::Input(MediaRawData* aSample)
|
||||||
{
|
{
|
||||||
if (!mp4_demuxer::AnnexB::ConvertSampleToAVCC(aSample)) {
|
if (!mp4_demuxer::AnnexB::ConvertSampleToAVCC(aSample)) {
|
||||||
// We need AVCC content to be able to later parse the SPS.
|
// We need AVCC content to be able to later parse the SPS.
|
||||||
// This is a no-op if the data is already AVCC.
|
// This is a no-op if the data is already AVCC.
|
||||||
return NS_ERROR_FAILURE;
|
mCallback->Error(MediaDataDecoderError::DECODE_ERROR);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mInitPromiseRequest.Exists()) {
|
if (mInitPromiseRequest.Exists()) {
|
||||||
|
@ -63,12 +64,12 @@ H264Converter::Input(MediaRawData* aSample)
|
||||||
if (!aSample->mKeyframe) {
|
if (!aSample->mKeyframe) {
|
||||||
// Frames dropped, we need a new one.
|
// Frames dropped, we need a new one.
|
||||||
mCallback->InputExhausted();
|
mCallback->InputExhausted();
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
mNeedKeyframe = false;
|
mNeedKeyframe = false;
|
||||||
}
|
}
|
||||||
mMediaRawSamples.AppendElement(aSample);
|
mMediaRawSamples.AppendElement(aSample);
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
@ -81,61 +82,62 @@ H264Converter::Input(MediaRawData* aSample)
|
||||||
// We are missing the required SPS to create the decoder.
|
// We are missing the required SPS to create the decoder.
|
||||||
// Ignore for the time being, the MediaRawData will be dropped.
|
// Ignore for the time being, the MediaRawData will be dropped.
|
||||||
mCallback->InputExhausted();
|
mCallback->InputExhausted();
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rv = CheckForSPSChange(aSample);
|
rv = CheckForSPSChange(aSample);
|
||||||
}
|
}
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_FAILED(rv)) {
|
||||||
|
mCallback->Error(MediaDataDecoderError::DECODE_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mNeedKeyframe && !aSample->mKeyframe) {
|
if (mNeedKeyframe && !aSample->mKeyframe) {
|
||||||
mCallback->InputExhausted();
|
mCallback->InputExhausted();
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mNeedAVCC &&
|
if (!mNeedAVCC &&
|
||||||
!mp4_demuxer::AnnexB::ConvertSampleToAnnexB(aSample)) {
|
!mp4_demuxer::AnnexB::ConvertSampleToAnnexB(aSample)) {
|
||||||
return NS_ERROR_FAILURE;
|
mCallback->Error(MediaDataDecoderError::FATAL_ERROR);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mNeedKeyframe = false;
|
mNeedKeyframe = false;
|
||||||
|
|
||||||
aSample->mExtraData = mCurrentConfig.mExtraData;
|
aSample->mExtraData = mCurrentConfig.mExtraData;
|
||||||
|
|
||||||
return mDecoder->Input(aSample);
|
mDecoder->Input(aSample);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
H264Converter::Flush()
|
H264Converter::Flush()
|
||||||
{
|
{
|
||||||
mNeedKeyframe = true;
|
mNeedKeyframe = true;
|
||||||
if (mDecoder) {
|
if (mDecoder) {
|
||||||
return mDecoder->Flush();
|
mDecoder->Flush();
|
||||||
}
|
}
|
||||||
return mLastError;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
H264Converter::Drain()
|
H264Converter::Drain()
|
||||||
{
|
{
|
||||||
mNeedKeyframe = true;
|
mNeedKeyframe = true;
|
||||||
if (mDecoder) {
|
if (mDecoder) {
|
||||||
return mDecoder->Drain();
|
mDecoder->Drain();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
mCallback->DrainComplete();
|
mCallback->DrainComplete();
|
||||||
return mLastError;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
H264Converter::Shutdown()
|
H264Converter::Shutdown()
|
||||||
{
|
{
|
||||||
if (mDecoder) {
|
if (mDecoder) {
|
||||||
nsresult rv = mDecoder->Shutdown();
|
mDecoder->Shutdown();
|
||||||
mInitPromiseRequest.DisconnectIfExists();
|
mInitPromiseRequest.DisconnectIfExists();
|
||||||
mDecoder = nullptr;
|
mDecoder = nullptr;
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -238,9 +240,7 @@ H264Converter::OnDecoderInitDone(const TrackType aTrackType)
|
||||||
}
|
}
|
||||||
mNeedKeyframe = false;
|
mNeedKeyframe = false;
|
||||||
}
|
}
|
||||||
if (NS_FAILED(mDecoder->Input(sample))) {
|
mDecoder->Input(sample);
|
||||||
mCallback->Error(MediaDataDecoderError::FATAL_ERROR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!gotInput) {
|
if (!gotInput) {
|
||||||
mCallback->InputExhausted();
|
mCallback->InputExhausted();
|
||||||
|
|
|
@ -26,10 +26,10 @@ public:
|
||||||
virtual ~H264Converter();
|
virtual ~H264Converter();
|
||||||
|
|
||||||
RefPtr<InitPromise> Init() override;
|
RefPtr<InitPromise> Init() override;
|
||||||
nsresult Input(MediaRawData* aSample) override;
|
void Input(MediaRawData* aSample) override;
|
||||||
nsresult Flush() override;
|
void Flush() override;
|
||||||
nsresult Drain() override;
|
void Drain() override;
|
||||||
nsresult Shutdown() override;
|
void Shutdown() override;
|
||||||
bool IsHardwareAccelerated(nsACString& aFailureReason) const override;
|
bool IsHardwareAccelerated(nsACString& aFailureReason) const override;
|
||||||
const char* GetDescriptionName() const override
|
const char* GetDescriptionName() const override
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче