From 93b170e6292d58d251299b5d3d7c51c5c0afd65b Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 27 Apr 2022 10:18:49 +0000 Subject: Issue #1820 - Part 2: Add VP9-in-MP4 support to the decoder This also adds support in StageFright for VP9.0 FourCCs and consolidates individual string checks to helpers for WebM --- dom/media/fmp4/MP4Decoder.cpp | 6 ++++++ dom/media/webm/WebMDecoder.cpp | 3 +-- .../frameworks/av/media/libstagefright/MPEG4Extractor.cpp | 3 +++ .../libstagefright/frameworks/av/media/libstagefright/MediaDefs.cpp | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dom/media/fmp4/MP4Decoder.cpp b/dom/media/fmp4/MP4Decoder.cpp index 7a340d8297..b57cd9b528 100644 --- a/dom/media/fmp4/MP4Decoder.cpp +++ b/dom/media/fmp4/MP4Decoder.cpp @@ -134,6 +134,12 @@ MP4Decoder::CanHandleMediaType(const MediaContentType& aType, NS_LITERAL_CSTRING("audio/flac"), aType)); continue; } + if (IsVP9CodecString(codec)) { + trackInfos.AppendElement( + CreateTrackInfoWithMIMETypeAndContainerTypeExtraParameters( + NS_LITERAL_CSTRING("video/vp9"), aType)); + continue; + } #ifdef MOZ_AV1 if (IsAV1CodecString(codec)) { trackInfos.AppendElement( diff --git a/dom/media/webm/WebMDecoder.cpp b/dom/media/webm/WebMDecoder.cpp index cbe9ffdb78..f0686577d6 100644 --- a/dom/media/webm/WebMDecoder.cpp +++ b/dom/media/webm/WebMDecoder.cpp @@ -67,8 +67,7 @@ WebMDecoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs, // Note: Only accept VP8/VP9 in a video content type, not in an audio // content type. if ((isWebMVideo || isMatroskaVideo) && - (codec.EqualsLiteral("vp8") || codec.EqualsLiteral("vp8.0") || - codec.EqualsLiteral("vp9") || codec.EqualsLiteral("vp9.0"))) { + (IsVP8CodecString(codec) || IsVP9CodecString(codec))) { continue; } diff --git a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp index 786e804878..bbc067ab19 100644 --- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp @@ -269,6 +269,9 @@ static const char *FourCC2MIME(uint32_t fourcc) { case FOURCC('V', 'P', '6', 'F'): return MEDIA_MIMETYPE_VIDEO_VP6; + case FOURCC('v', 'p', '0', '9'): + return MEDIA_MIMETYPE_VIDEO_VP9; + case FOURCC('a', 'v', '0', '1'): case FOURCC('.', 'a', 'v', '1'): return MEDIA_MIMETYPE_VIDEO_AV1; diff --git a/media/libstagefright/frameworks/av/media/libstagefright/MediaDefs.cpp b/media/libstagefright/frameworks/av/media/libstagefright/MediaDefs.cpp index a7c6e75fcc..bc81dceb38 100644 --- a/media/libstagefright/frameworks/av/media/libstagefright/MediaDefs.cpp +++ b/media/libstagefright/frameworks/av/media/libstagefright/MediaDefs.cpp @@ -22,7 +22,7 @@ const char *MEDIA_MIMETYPE_IMAGE_JPEG = "image/jpeg"; const char *MEDIA_MIMETYPE_VIDEO_VP6 = "video/x-vnd.on2.vp6"; const char *MEDIA_MIMETYPE_VIDEO_VP8 = "video/x-vnd.on2.vp8"; -const char *MEDIA_MIMETYPE_VIDEO_VP9 = "video/x-vnd.on2.vp9"; +const char *MEDIA_MIMETYPE_VIDEO_VP9 = "video/vp9"; const char *MEDIA_MIMETYPE_VIDEO_AV1 = "video/av1"; const char *MEDIA_MIMETYPE_VIDEO_AVC = "video/avc"; const char *MEDIA_MIMETYPE_VIDEO_MPEG4 = "video/mp4v-es"; -- cgit v1.2.3