Files
firefox/dom/media/platforms/android/RemoteDataDecoder.h
T
John Lin d01dd00203 Bug 1394239 - don't return video frames that MDSM won't show. r=jya
In some Android ROMs, MediaCodec doesn't allocate additional buffers to reduce
consumer starvation and will not work when MDSM grips most recently returned
frame before rearching seek target. Implement SetSeekThreshold() to get actual
seek target to check if video buffers can be released back to remote decoder
immediately.

MozReview-Commit-ID: 7IetuVxCXc0
2017-09-11 12:50:48 +08:00

89 lines
2.6 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef RemoteDataDecoder_h_
#define RemoteDataDecoder_h_
#include "AndroidDecoderModule.h"
#include "FennecJNIWrappers.h"
#include "SurfaceTexture.h"
#include "TimeUnits.h"
#include "mozilla/Maybe.h"
#include "mozilla/Monitor.h"
namespace mozilla {
class RemoteDataDecoder : public MediaDataDecoder
{
public:
static already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const CreateDecoderParams& aParams,
const nsString& aDrmStubId,
CDMProxy* aProxy);
static already_AddRefed<MediaDataDecoder>
CreateVideoDecoder(const CreateDecoderParams& aParams,
const nsString& aDrmStubId,
CDMProxy* aProxy);
RefPtr<DecodePromise> Decode(MediaRawData* aSample) override;
RefPtr<DecodePromise> Drain() override;
RefPtr<FlushPromise> Flush() override;
RefPtr<ShutdownPromise> Shutdown() override;
nsCString GetDescriptionName() const override
{
return NS_LITERAL_CSTRING("android decoder (remote)");
}
protected:
virtual ~RemoteDataDecoder() { }
RemoteDataDecoder(MediaData::Type aType,
const nsACString& aMimeType,
java::sdk::MediaFormat::Param aFormat,
const nsString& aDrmStubId, TaskQueue* aTaskQueue);
// Methods only called on mTaskQueue.
RefPtr<ShutdownPromise> ProcessShutdown();
void UpdateInputStatus(int64_t aTimestamp, bool aProcessed);
void UpdateOutputStatus(RefPtr<MediaData>&& aSample);
void ReturnDecodedData();
void DrainComplete();
void Error(const MediaResult& aError);
void AssertOnTaskQueue()
{
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
}
// Whether the sample will be used.
virtual bool IsUsefulData(const RefPtr<MediaData>& aSample) { return true; }
MediaData::Type mType;
nsAutoCString mMimeType;
java::sdk::MediaFormat::GlobalRef mFormat;
java::CodecProxy::GlobalRef mJavaDecoder;
java::CodecProxy::NativeCallbacks::GlobalRef mJavaCallbacks;
nsString mDrmStubId;
RefPtr<TaskQueue> mTaskQueue;
// Only ever accessed on mTaskqueue.
bool mShutdown = false;
MozPromiseHolder<DecodePromise> mDecodePromise;
MozPromiseHolder<DecodePromise> mDrainPromise;
enum class DrainStatus
{
DRAINED,
DRAINABLE,
DRAINING,
};
DrainStatus mDrainStatus = DrainStatus::DRAINED;
DecodedData mDecodedData;
size_t mNumPendingInputs;
};
} // namespace mozilla
#endif