commit 67d3b441bf4fde550e9fe624c867a807e5717d77
parent 7742bfaf382777b4044c7fd64703cd4275ea0c5a
Author: Andrew Osmond <aosmond@gmail.com>
Date: Wed, 10 Dec 2025 16:24:53 +0000
Bug 2005096 - Expose MediaCodec ffmpeg decoder properties for Android. r=media-playback-reviewers,padenot
This matches changes in bug 1905878 for AndroidDecoderModule and
RemoteVideoDecoder, in order to place limits on how many outstanding
output buffers we can have with MediaCodec decoders.
Differential Revision: https://phabricator.services.mozilla.com/D275701
Diffstat:
2 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -1927,6 +1927,37 @@ FFmpegVideoDecoder<LIBAV_VER>::ProcessFlush() {
return FFmpegDataDecoder::ProcessFlush();
}
+#ifdef MOZ_WIDGET_ANDROID
+Maybe<MediaDataDecoder::PropertyValue> FFmpegVideoDecoder<
+ LIBAV_VER>::GetDecodeProperty(MediaDataDecoder::PropertyName aName) const {
+ // If we are using a software decoder, then we aren't subject to platform
+ // limits. If we don't have mCodecContext, assume worst case.
+ if (mCodecContext) {
+ if (const auto* codec = mCodecContext->codec) {
+ if (!(codec->capabilities & AV_CODEC_CAP_HARDWARE)) {
+ return MediaDataDecoder::GetDecodeProperty(aName);
+ }
+ }
+ }
+
+ // Android has limited amount of output buffers. See Bug 794747.
+ static constexpr uint32_t kNumOutputBuffers = 3;
+ // SurfaceTexture can have only one current/renderable image at a time.
+ // See Bug 1299068
+ static constexpr uint32_t kNumCurrentImages = 1;
+ switch (aName) {
+ case PropertyName::MaxNumVideoBuffers:
+ [[fallthrough]];
+ case PropertyName::MinNumVideoBuffers:
+ return Some(PropertyValue(kNumOutputBuffers));
+ case PropertyName::MaxNumCurrentImages:
+ return Some(PropertyValue(kNumCurrentImages));
+ default:
+ return MediaDataDecoder::GetDecodeProperty(aName);
+ }
+}
+#endif
+
AVCodecID FFmpegVideoDecoder<LIBAV_VER>::GetCodecId(
const nsACString& aMimeType) {
if (MP4Decoder::IsH264(aMimeType)) {
diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h
@@ -100,6 +100,11 @@ class FFmpegVideoDecoder<LIBAV_VER>
#endif
}
+#ifdef MOZ_WIDGET_ANDROID
+ Maybe<MediaDataDecoder::PropertyValue> GetDecodeProperty(
+ MediaDataDecoder::PropertyName aName) const override;
+#endif
+
static AVCodecID GetCodecId(const nsACString& aMimeType);
#if LIBAVCODEC_VERSION_MAJOR >= 57 && LIBAVUTIL_VERSION_MAJOR >= 56