Files
palemoon27/dom/media/platforms/android/AndroidDecoderModule.h
T
roytam1 f12a92a2ed import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1202351 - Remove MDSM::mPlayDuration. r=cpearce. (c982bcf84d)
- Bug 1202540 - Remove MDSM::mPlayStartTime. r=kinetik. (462de866a4)
- Bug 1203047 - Make MediaDecoderReader know less about AudioData/VideoData by using MediaData instead. r=jya (3b8cda73da)
- Bug 1172830 - Move buffering check out of MediaDecoderStateMachine::UpdateRenderedVideoFrames(). r=cpearce. (c4a174745f)
- Bug 1206578 - Group public and private functions respectively for MDSM. r=gsquelart. (59008c04f6)
- Bug 1206607 - Remove some dead code from MDSM. r=kinetik. (252e4af765)
- Bug 1208932 - Remove ReadMetadataFailureReason::WAITING_FOR_RESOURCES. r=jya. (622e18eef0)
- Bug 1208931 - Remove MediaDecoderReader::IsWaitingMediaResources(). r#=ya. (31cb8c85af)
- Bug 1183888: Report empty buffered ranges unless we have a start time. r=bholley (9a32ffa1eb)
- Bug 1208933 - Remove AbstractMediaDecoder::NotifyWaitingForResourcesSatusChanged(). r=jya. (b1870471ba)
- Bug 1164697 - Fix time unit of AudioOffloadPlayer r=bholley (e36a51ca44)
- Bug 1208930 - Remove usage of decoder monitor from MediaDecoder. r=jya. (8b3d93c3a3)
- Bug 1209864. Part 1 - make all methods run on the main thread and remove usage of the decoder monitor. r=roc. (6d8b607236)
- Bug 1209864. Part 2 - remove unused code. r=sotaro. (c69b8440ee)
- Bug 1188643. Buffer more audio in audio capture mode to avoid glitches. r=cpearce. (11fc554d30)
- Bug 1208934 - Remove usage of decoder monitor from MDSM. r=kinetik. (a67b4d9d01)
- Bug 1211364 - Check frame validity earlier when decoded frames arrive in MDSM. r=jwwang (e6c35f6d49)
- Bug 1212701. Part 1 - remove AbstractMediaDecoder::OnDecodeTaskQueue(). r=jya. (f1f840ebe9)
- Bug 1212701. Part 2 - remove MediaDecoderStateMachine::OnDecodeTaskQueue() which is unused. r=jya. (2c51be5749)
- Bug 1213897 - Extract DelayedScheduler out of MDSM to a common class.r=jwwang (4bfc24688a)
- Bug 1206568: P1. Ensure FFmpeg decoder is only accessed through the decoder's task queue. r=cpearce (39ed961411)
- Bug 1179667 - Use MozPromise to initialize Gonk PlatformDecodeModule. r=jya (86da0475fb)
- Bug 1206568: P2. Clean up header declarations. r=cpearce (2d1aa1bdaa)
- missing bits Bug 1206568: P1. (511c1ee0ef)
2022-10-12 17:17:27 +08:00

105 lines
3.1 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 AndroidDecoderModule_h_
#define AndroidDecoderModule_h_
#include "PlatformDecoderModule.h"
#include "AndroidSurfaceTexture.h"
#include "MediaCodec.h"
#include "TimeUnits.h"
#include "mozilla/Monitor.h"
#include <queue>
namespace mozilla {
typedef std::queue<nsRefPtr<MediaRawData>> SampleQueue;
class AndroidDecoderModule : public PlatformDecoderModule {
public:
already_AddRefed<MediaDataDecoder>
CreateVideoDecoder(const VideoInfo& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
FlushableTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback) override;
already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const AudioInfo& aConfig,
FlushableTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) override;
AndroidDecoderModule() {}
virtual ~AndroidDecoderModule() {}
bool SupportsMimeType(const nsACString& aMimeType) override;
ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
};
class MediaCodecDataDecoder : public MediaDataDecoder {
public:
MediaCodecDataDecoder(MediaData::Type aType,
const nsACString& aMimeType,
widget::sdk::MediaFormat::Param aFormat,
MediaDataDecoderCallback* aCallback);
virtual ~MediaCodecDataDecoder();
nsRefPtr<MediaDataDecoder::InitPromise> Init() override;
nsresult Flush() override;
nsresult Drain() override;
nsresult Shutdown() override;
nsresult Input(MediaRawData* aSample) override;
protected:
friend class AndroidDecoderModule;
MediaData::Type mType;
nsAutoCString mMimeType;
widget::sdk::MediaFormat::GlobalRef mFormat;
MediaDataDecoderCallback* mCallback;
widget::sdk::MediaCodec::GlobalRef mDecoder;
jni::ObjectArray::GlobalRef mInputBuffers;
jni::ObjectArray::GlobalRef mOutputBuffers;
nsCOMPtr<nsIThread> mThread;
// Only these members are protected by mMonitor.
Monitor mMonitor;
bool mFlushing;
bool mDraining;
bool mStopping;
SampleQueue mQueue;
// Durations are stored in microseconds.
std::queue<media::TimeUnit> mDurations;
virtual nsresult InitDecoder(widget::sdk::Surface::Param aSurface);
virtual nsresult Output(widget::sdk::BufferInfo::Param aInfo, void* aBuffer, widget::sdk::MediaFormat::Param aFormat, const media::TimeUnit& aDuration) { return NS_OK; }
virtual nsresult PostOutput(widget::sdk::BufferInfo::Param aInfo, widget::sdk::MediaFormat::Param aFormat, const media::TimeUnit& aDuration) { return NS_OK; }
virtual void Cleanup() {};
nsresult ResetInputBuffers();
nsresult ResetOutputBuffers();
void DecoderLoop();
nsresult GetInputBuffer(JNIEnv* env, int index, jni::Object::LocalRef* buffer);
virtual void ClearQueue();
};
} // namwspace mozilla
#endif