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