Bug 1944991 - Enable H265 decoding support on macOS r=media-playback-reviewers,jolin

This patch enables VideoDecoder to return "supported" when users request
H265 video decoding on macOS by adding and modifying the necessary
functions.

Additionally, this patch introduces an H265 codec enum type to bypass an
assertion that checks the mapping between H265 codec string and internal
codec enum type for VideoEncoder. Since the underlying encoder does not
yet support H265, VideoEncoder will continue to return "unsupported".

Differential Revision: https://phabricator.services.mozilla.com/D236651
This commit is contained in:
Chun-Min Chang
2025-02-16 05:29:50 +00:00
parent 91cea54bdb
commit 75f5803935
3 changed files with 15 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ namespace mozilla {
enum class CodecType {
_BeginVideo_,
H264,
H265,
VP8,
VP9,
AV1,

View File

@@ -23,6 +23,8 @@ const char* GetCodecTypeString(const CodecType& aCodecType) {
return "_BeginVideo_";
case CodecType::H264:
return "H264";
case CodecType::H265:
return "H265";
case CodecType::VP8:
return "VP8";
case CodecType::VP9:

View File

@@ -57,6 +57,10 @@ nsTArray<nsCString> GuessContainers(const nsAString& aCodec) {
return {"mp4"_ns, "3gpp"_ns, "3gpp2"_ns, "3gp2"_ns};
}
if (IsH265CodecString(aCodec)) {
return {"mp4"_ns};
}
if (IsAACCodecString(aCodec)) {
return {"adts"_ns, "mp4"_ns};
}
@@ -602,6 +606,10 @@ Maybe<CodecType> CodecStringToCodecType(const nsAString& aCodecString) {
StringBeginsWith(aCodecString, u"avc3"_ns)) {
return Some(CodecType::H264);
}
if (StringBeginsWith(aCodecString, u"hev1"_ns) ||
StringBeginsWith(aCodecString, u"hvc1"_ns)) {
return Some(CodecType::H265);
}
return Nothing();
}
@@ -618,6 +626,10 @@ bool IsSupportedVideoCodec(const nsAString& aCodec) {
// The only codec string accepted for vp8 is "vp8"
if (!IsVP9CodecString(aCodec) && !IsH264CodecString(aCodec) &&
!IsAV1CodecString(aCodec) && !aCodec.EqualsLiteral("vp8")) {
if (IsH265CodecString(aCodec)) {
// H265 is supported only on MacOS for now.
return IsOnMacOS();
}
return false;
}