mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-27 00:29:27 +00:00
Merge remote-tracking branch 'origin/media-works' into master
This commit is contained in:
@@ -47,14 +47,18 @@ public:
|
||||
|
||||
}
|
||||
|
||||
nsresult Init() override {
|
||||
nsRefPtr<InitPromise> Init() override {
|
||||
mSurfaceTexture = AndroidSurfaceTexture::Create();
|
||||
if (!mSurfaceTexture) {
|
||||
NS_WARNING("Failed to create SurfaceTexture for video decode\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
return InitPromise::CreateAndReject(DecoderFailureReason::INIT_ERROR, __func__);
|
||||
}
|
||||
|
||||
return InitDecoder(mSurfaceTexture->JavaSurface());
|
||||
if (NS_FAILED(InitDecoder(mSurfaceTexture->JavaSurface()))) {
|
||||
return InitPromise::CreateAndReject(DecoderFailureReason::INIT_ERROR, __func__);
|
||||
}
|
||||
|
||||
return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__);
|
||||
}
|
||||
|
||||
void Cleanup() override {
|
||||
@@ -95,7 +99,8 @@ public:
|
||||
return eglImage;
|
||||
}
|
||||
|
||||
virtual nsresult PostOutput(BufferInfo::Param aInfo, MediaFormat::Param aFormat, Microseconds aDuration) override {
|
||||
virtual nsresult PostOutput(BufferInfo::Param aInfo, MediaFormat::Param aFormat,
|
||||
const media::TimeUnit& aDuration) override {
|
||||
if (!EnsureGLContext()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -158,7 +163,7 @@ public:
|
||||
mImageContainer,
|
||||
offset,
|
||||
presentationTimeUs,
|
||||
aDuration,
|
||||
aDuration.ToMicroseconds(),
|
||||
img,
|
||||
isSync,
|
||||
presentationTimeUs,
|
||||
@@ -207,7 +212,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
nsresult Output(BufferInfo::Param aInfo, void* aBuffer, MediaFormat::Param aFormat, Microseconds aDuration) {
|
||||
nsresult Output(BufferInfo::Param aInfo, void* aBuffer,
|
||||
MediaFormat::Param aFormat,
|
||||
const media::TimeUnit& aDuration) {
|
||||
// The output on Android is always 16-bit signed
|
||||
|
||||
nsresult rv;
|
||||
@@ -233,7 +240,7 @@ public:
|
||||
NS_ENSURE_SUCCESS(rv = aInfo->PresentationTimeUs(&presentationTimeUs), rv);
|
||||
|
||||
nsRefPtr<AudioData> data = new AudioData(offset, presentationTimeUs,
|
||||
aDuration,
|
||||
aDuration.ToMicroseconds(),
|
||||
numFrames,
|
||||
audio,
|
||||
numChannels,
|
||||
@@ -246,6 +253,9 @@ public:
|
||||
|
||||
bool AndroidDecoderModule::SupportsMimeType(const nsACString& aMimeType)
|
||||
{
|
||||
if (!AndroidBridge::Bridge() || (AndroidBridge::Bridge()->GetAPIVersion() < 16)) {
|
||||
return false;
|
||||
}
|
||||
if (aMimeType.EqualsLiteral("video/mp4") ||
|
||||
aMimeType.EqualsLiteral("video/avc")) {
|
||||
return true;
|
||||
@@ -258,7 +268,7 @@ AndroidDecoderModule::CreateVideoDecoder(
|
||||
const VideoInfo& aConfig,
|
||||
layers::LayersBackend aLayersBackend,
|
||||
layers::ImageContainer* aImageContainer,
|
||||
FlushableMediaTaskQueue* aVideoTaskQueue,
|
||||
FlushableTaskQueue* aVideoTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback)
|
||||
{
|
||||
MediaFormat::LocalRef format;
|
||||
@@ -277,7 +287,7 @@ AndroidDecoderModule::CreateVideoDecoder(
|
||||
|
||||
already_AddRefed<MediaDataDecoder>
|
||||
AndroidDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
|
||||
FlushableMediaTaskQueue* aAudioTaskQueue,
|
||||
FlushableTaskQueue* aAudioTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback)
|
||||
{
|
||||
MOZ_ASSERT(aConfig.mBitDepth == 16, "We only handle 16-bit audio!");
|
||||
@@ -330,9 +340,17 @@ MediaCodecDataDecoder::~MediaCodecDataDecoder()
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
nsresult MediaCodecDataDecoder::Init()
|
||||
nsRefPtr<MediaDataDecoder::InitPromise> MediaCodecDataDecoder::Init()
|
||||
{
|
||||
return InitDecoder(nullptr);
|
||||
nsresult rv = InitDecoder(nullptr);
|
||||
|
||||
TrackInfo::TrackType type =
|
||||
(mType == MediaData::AUDIO_DATA ? TrackInfo::TrackType::kAudioTrack
|
||||
: TrackInfo::TrackType::kVideoTrack);
|
||||
|
||||
return NS_SUCCEEDED(rv) ?
|
||||
InitPromise::CreateAndResolve(type, __func__) :
|
||||
InitPromise::CreateAndReject(MediaDataDecoder::DecoderFailureReason::INIT_ERROR, __func__);
|
||||
}
|
||||
|
||||
nsresult MediaCodecDataDecoder::InitDecoder(Surface::Param aSurface)
|
||||
@@ -479,7 +497,7 @@ void MediaCodecDataDecoder::DecoderLoop()
|
||||
sample->mTime, 0);
|
||||
HANDLE_DECODER_ERROR();
|
||||
|
||||
mDurations.push(sample->mDuration);
|
||||
mDurations.push(media::TimeUnit::FromMicroseconds(sample->mDuration));
|
||||
sample = nullptr;
|
||||
outputDone = false;
|
||||
}
|
||||
@@ -537,7 +555,7 @@ void MediaCodecDataDecoder::DecoderLoop()
|
||||
|
||||
MOZ_ASSERT(!mDurations.empty(), "Should have had a duration queued");
|
||||
|
||||
Microseconds duration = 0;
|
||||
media::TimeUnit duration;
|
||||
if (!mDurations.empty()) {
|
||||
duration = mDurations.front();
|
||||
mDurations.pop();
|
||||
|
||||
Reference in New Issue
Block a user