Commit c64eec2c authored by Vi Nguyen's avatar Vi Nguyen Committed by Commit Bot

Implement MediaCapabilities: HDR decoding query

This CL allows for HDR to be queried with MediaCapabilities.decodingInfo
with hdrMetadataType, colorGamut, and transferFunction. Both Blink- and
Media-side changes are included. The feature is flagged by
MediaCapabilitiesDynamicRange.

Bug: 1048045
Change-Id: I9f144726bbc7aaead4dcc1c9f69cf536da1bf2a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2035053
Commit-Queue: Vi Nguyen <ving@microsoft.com>
Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Reviewed-by: default avatarChrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756829}
parent 1f113396
...@@ -297,6 +297,13 @@ bool CastContentRendererClient::IsSupportedAudioType( ...@@ -297,6 +297,13 @@ bool CastContentRendererClient::IsSupportedAudioType(
bool CastContentRendererClient::IsSupportedVideoType( bool CastContentRendererClient::IsSupportedVideoType(
const ::media::VideoType& type) { const ::media::VideoType& type) {
// TODO(servolk): make use of eotf. // TODO(servolk): make use of eotf.
// TODO(1066567): Check attached screen for support of type.hdr_metadata_type.
if (type.hdr_metadata_type != ::media::HdrMetadataType::kNone) {
NOTIMPLEMENTED() << "HdrMetadataType support signaling not implemented.";
return false;
}
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
return supported_profiles_->IsSupportedVideoConfig( return supported_profiles_->IsSupportedVideoConfig(
media::ToCastVideoCodec(type.codec, type.profile), media::ToCastVideoCodec(type.codec, type.profile),
......
...@@ -34,7 +34,13 @@ const char* kPropSupported = kSupported; ...@@ -34,7 +34,13 @@ const char* kPropSupported = kSupported;
const char* kPropSupported = kUnsupported; const char* kPropSupported = kUnsupported;
#endif // USE_PROPRIETARY_CODECS #endif // USE_PROPRIETARY_CODECS
enum StreamType { kAudio, kVideo, kAudioWithSpatialRendering }; enum StreamType {
kAudio,
kVideo,
kAudioWithSpatialRendering,
kVideoWithHdrMetadata,
kVideoWithoutHdrMetadata
};
enum ConfigType { kFile, kMediaSource }; enum ConfigType { kFile, kMediaSource };
...@@ -47,10 +53,10 @@ class MediaCapabilitiesTest : public ContentBrowserTest { ...@@ -47,10 +53,10 @@ class MediaCapabilitiesTest : public ContentBrowserTest {
MediaCapabilitiesTest() = default; MediaCapabilitiesTest() = default;
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures,
"MediaCapabilities");
command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures, command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures,
"MediaCapabilitiesSpatialAudio"); "MediaCapabilitiesSpatialAudio");
command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures,
"MediaCapabilitiesDynamicRange");
} }
std::string CanDecodeAudio(const std::string& config_type, std::string CanDecodeAudio(const std::string& config_type,
...@@ -71,16 +77,58 @@ class MediaCapabilitiesTest : public ContentBrowserTest { ...@@ -71,16 +77,58 @@ class MediaCapabilitiesTest : public ContentBrowserTest {
StreamType::kAudioWithSpatialRendering, spatial_rendering); StreamType::kAudioWithSpatialRendering, spatial_rendering);
} }
std::string CanDecodeVideoWithHdrMetadata(
const std::string& config_type,
const std::string& content_type,
const std::string& color_gamut,
const std::string& transfer_function,
const std::string& hdr_metadata_type = "") {
StreamType stream_type = StreamType::kVideoWithHdrMetadata;
if (hdr_metadata_type == "")
stream_type = StreamType::kVideoWithoutHdrMetadata;
return CanDecode(config_type, content_type, stream_type,
/* spatialRendering */ false, hdr_metadata_type,
color_gamut, transfer_function);
}
std::string CanDecode(const std::string& config_type, std::string CanDecode(const std::string& config_type,
const std::string& content_type, const std::string& content_type,
StreamType stream_type, StreamType stream_type,
const bool& spatial_rendering = false) { const bool& spatial_rendering = false,
const std::string& hdr_metadata_type = "",
const std::string& color_gamut = "",
const std::string& transfer_function = "") {
std::string command; std::string command;
if (stream_type == StreamType::kAudio) { if (stream_type == StreamType::kAudio) {
command.append("testAudioConfig("); command.append("testAudioConfig(");
} else if (stream_type == StreamType::kAudioWithSpatialRendering) { } else if (stream_type == StreamType::kAudioWithSpatialRendering) {
command.append("testAudioConfigWithSpatialRendering("); command.append("testAudioConfigWithSpatialRendering(");
command.append(spatial_rendering ? "true, " : "false, "); command.append(spatial_rendering ? "true, " : "false, ");
} else if (stream_type == StreamType::kVideoWithHdrMetadata) {
command.append("testVideoConfigWithHdrMetadata(");
DCHECK(!hdr_metadata_type.empty());
DCHECK(!color_gamut.empty());
DCHECK(!transfer_function.empty());
command.append("\"");
command.append(hdr_metadata_type);
command.append("\", ");
command.append("\"");
command.append(color_gamut);
command.append("\", ");
command.append("\"");
command.append(transfer_function);
command.append("\", ");
} else if (stream_type == StreamType::kVideoWithoutHdrMetadata) {
command.append("testVideoConfigWithoutHdrMetadata(");
DCHECK(!color_gamut.empty());
DCHECK(!transfer_function.empty());
command.append("\"");
command.append(color_gamut);
command.append("\", ");
command.append("\"");
command.append(transfer_function);
command.append("\", ");
} else { } else {
command.append("testVideoConfig("); command.append("testVideoConfig(");
} }
...@@ -316,6 +364,66 @@ IN_PROC_BROWSER_TEST_P(MediaCapabilitiesTestWithConfigType, ...@@ -316,6 +364,66 @@ IN_PROC_BROWSER_TEST_P(MediaCapabilitiesTestWithConfigType,
/*spatial_rendering*/ true)); /*spatial_rendering*/ true));
} }
// Cover basic HDR support.
IN_PROC_BROWSER_TEST_P(MediaCapabilitiesTestWithConfigType,
VideoTypesWithDynamicRange) {
base::FilePath file_path = media::GetTestDataFilePath(kDecodeTestFile);
const std::string& config_type = GetTypeString();
EXPECT_TRUE(
NavigateToURL(shell(), content::GetFileUrlWithQuery(file_path, "")));
// All color gamuts and transfer functions should be supported.
EXPECT_EQ(kSupported, CanDecodeVideoWithHdrMetadata(
config_type, "'video/webm; codecs=\"vp8\"'",
/* colorGamut */ "srgb",
/* transferFunction */ "srgb"));
EXPECT_EQ(kSupported, CanDecodeVideoWithHdrMetadata(
config_type, "'video/webm; codecs=\"vp8\"'",
/* colorGamut */ "p3",
/* transferFunction */ "pq"));
EXPECT_EQ(kSupported, CanDecodeVideoWithHdrMetadata(
config_type, "'video/webm; codecs=\"vp8\"'",
/* colorGamut */ "rec2020",
/* transferFunction */ "hlg"));
// No HdrMetadataType is currently supported.
EXPECT_EQ(kUnsupported, CanDecodeVideoWithHdrMetadata(
config_type, "'video/webm; codecs=\"vp8\"'",
/* colorGamut */ "srgb",
/* transferFunction */ "srgb",
/* hdrMetadataType */ "smpteSt2086"));
EXPECT_EQ(kUnsupported, CanDecodeVideoWithHdrMetadata(
config_type, "'video/webm; codecs=\"vp8\"'",
/* colorGamut */ "srgb",
/* transferFunction */ "srgb",
/* hdrMetadataType */ "smpteSt2094-10"));
EXPECT_EQ(kUnsupported, CanDecodeVideoWithHdrMetadata(
config_type, "'video/webm; codecs=\"vp8\"'",
/* colorGamut */ "srgb",
/* transferFunction */ "srgb",
/* hdrMetadataType */ "smpteSt2094-40"));
// Make sure results are expected with some USE_PROPRIETARY_CODECS
EXPECT_EQ(kPropSupported,
CanDecodeVideoWithHdrMetadata(config_type,
"'video/mp4; codecs=\"avc1.42E01E\"'",
/* colorGamut */ "p3",
/* transferFunction */ "pq"));
EXPECT_EQ(kPropSupported,
CanDecodeVideoWithHdrMetadata(config_type,
"'video/mp4; codecs=\"avc1.42101E\"'",
/* colorGamut */ "srgb",
/* transferFunction */ "srgb"));
EXPECT_EQ(kUnsupported,
CanDecodeVideoWithHdrMetadata(config_type,
"'video/mp4; codecs=\"avc1.42701E\"'",
/* colorGamut */ "srgb",
/* transferFunction */ "srgb",
/* hdrMetadataType */ "smpteSt2086"));
}
INSTANTIATE_TEST_SUITE_P(File, INSTANTIATE_TEST_SUITE_P(File,
MediaCapabilitiesTestWithConfigType, MediaCapabilitiesTestWithConfigType,
::testing::Values(ConfigType::kFile)); ::testing::Values(ConfigType::kFile));
......
...@@ -52,6 +52,15 @@ struct MEDIA_EXPORT HDRMetadata { ...@@ -52,6 +52,15 @@ struct MEDIA_EXPORT HDRMetadata {
} }
}; };
// HDR metadata types as described in
// https://w3c.github.io/media-capabilities/#enumdef-hdrmetadatatype
enum class HdrMetadataType {
kNone,
kSmpteSt2086,
kSmpteSt2094_10,
kSmpteSt2094_40,
};
} // namespace media } // namespace media
#endif // MEDIA_BASE_HDR_METADATA_H_ #endif // MEDIA_BASE_HDR_METADATA_H_
...@@ -33,6 +33,7 @@ struct MEDIA_EXPORT VideoType { ...@@ -33,6 +33,7 @@ struct MEDIA_EXPORT VideoType {
VideoCodecProfile profile; VideoCodecProfile profile;
int level; int level;
VideoColorSpace color_space; VideoColorSpace color_space;
HdrMetadataType hdr_metadata_type;
}; };
MEDIA_EXPORT bool operator==(const AudioType& x, const AudioType& y); MEDIA_EXPORT bool operator==(const AudioType& x, const AudioType& y);
......
...@@ -31,6 +31,22 @@ ...@@ -31,6 +31,22 @@
namespace media { namespace media {
namespace {
bool IsSupportedHdrMetadata(const HdrMetadataType& hdr_metadata_type) {
switch (hdr_metadata_type) {
case HdrMetadataType::kNone:
return true;
case HdrMetadataType::kSmpteSt2086:
case HdrMetadataType::kSmpteSt2094_10:
case HdrMetadataType::kSmpteSt2094_40:
return false;
}
}
} // namespace
bool IsSupportedAudioType(const AudioType& type) { bool IsSupportedAudioType(const AudioType& type) {
MediaClient* media_client = GetMediaClient(); MediaClient* media_client = GetMediaClient();
if (media_client) if (media_client)
...@@ -257,6 +273,9 @@ bool IsVideoCodecProprietary(VideoCodec codec) { ...@@ -257,6 +273,9 @@ bool IsVideoCodecProprietary(VideoCodec codec) {
// TODO(chcunningham): Add platform specific logic for Android (move from // TODO(chcunningham): Add platform specific logic for Android (move from
// MimeUtilIntenral). // MimeUtilIntenral).
bool IsDefaultSupportedVideoType(const VideoType& type) { bool IsDefaultSupportedVideoType(const VideoType& type) {
if (!IsSupportedHdrMetadata(type.hdr_metadata_type))
return false;
#if !BUILDFLAG(USE_PROPRIETARY_CODECS) #if !BUILDFLAG(USE_PROPRIETARY_CODECS)
if (IsVideoCodecProprietary(type.codec)) if (IsVideoCodecProprietary(type.codec))
return false; return false;
......
...@@ -240,4 +240,58 @@ TEST(SupportedTypesTest, XHE_AACSupportedOnAndroidOnly) { ...@@ -240,4 +240,58 @@ TEST(SupportedTypesTest, XHE_AACSupportedOnAndroidOnly) {
#endif #endif
} }
TEST(SupportedTypesTest, IsSupportedVideoTypeWithHdrMetadataBasics) {
// Default to common 709.
media::VideoColorSpace color_space = media::VideoColorSpace::REC709();
// Some codecs do not have a notion of level.
const int kUnspecifiedLevel = 0;
// Expect support for baseline configuration of known codecs.
EXPECT_TRUE(IsSupportedVideoType({media::kCodecVP8, media::VP8PROFILE_ANY,
kUnspecifiedLevel, color_space}));
EXPECT_TRUE(
IsSupportedVideoType({media::kCodecVP9, media::VP9PROFILE_PROFILE0,
kUnspecifiedLevel, color_space}));
EXPECT_TRUE(IsSupportedVideoType({media::kCodecTheora,
media::VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, color_space}));
// All combinations of combinations of color gamuts and transfer functions
// should be supported.
color_space.primaries = media::VideoColorSpace::PrimaryID::SMPTEST431_2;
color_space.transfer = media::VideoColorSpace::TransferID::SMPTEST2084;
EXPECT_TRUE(IsSupportedVideoType({media::kCodecVP8, media::VP8PROFILE_ANY,
kUnspecifiedLevel, color_space}));
EXPECT_TRUE(
IsSupportedVideoType({media::kCodecVP9, media::VP9PROFILE_PROFILE0,
kUnspecifiedLevel, color_space}));
EXPECT_TRUE(IsSupportedVideoType({media::kCodecTheora,
media::VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, color_space}));
color_space.primaries = media::VideoColorSpace::PrimaryID::BT2020;
color_space.transfer = media::VideoColorSpace::TransferID::ARIB_STD_B67;
EXPECT_TRUE(IsSupportedVideoType({media::kCodecVP8, media::VP8PROFILE_ANY,
kUnspecifiedLevel, color_space}));
EXPECT_TRUE(
IsSupportedVideoType({media::kCodecVP9, media::VP9PROFILE_PROFILE0,
kUnspecifiedLevel, color_space}));
EXPECT_TRUE(IsSupportedVideoType({media::kCodecTheora,
media::VIDEO_CODEC_PROFILE_UNKNOWN,
kUnspecifiedLevel, color_space}));
// No HDR metadata types are supported.
EXPECT_FALSE(IsSupportedVideoType({media::kCodecVP8, media::VP8PROFILE_ANY,
kUnspecifiedLevel, color_space,
media::HdrMetadataType::kSmpteSt2086}));
EXPECT_FALSE(IsSupportedVideoType({media::kCodecVP8, media::VP8PROFILE_ANY,
kUnspecifiedLevel, color_space,
media::HdrMetadataType::kSmpteSt2094_10}));
EXPECT_FALSE(IsSupportedVideoType({media::kCodecVP8, media::VP8PROFILE_ANY,
kUnspecifiedLevel, color_space,
media::HdrMetadataType::kSmpteSt2094_40}));
}
} // namespace media } // namespace media
...@@ -84,4 +84,64 @@ ...@@ -84,4 +84,64 @@
runTest(configuration); runTest(configuration);
} }
function testVideoConfigWithHdrMetadata(hdrMetadataType,
colorGamut,
transferFunction,
queryType,
contentType) {
// Clear previous test result from title.
document.title = '';
log("Testing video content type: " + contentType +
", HDR metadata type: " + hdrMetadataType +
", color gamut: " + colorGamut +
", transfer function: " + transferFunction);
const configuration = {
type : queryType,
video : {
contentType : contentType,
hdrMetadataType : hdrMetadataType,
colorGamut : colorGamut,
transferFunction : transferFunction,
// Any reasonable value will do.
width : 640,
height : 480,
bitrate : 10000,
framerate : 30
}
};
runTest(configuration);
}
function testVideoConfigWithoutHdrMetadata(colorGamut,
transferFunction,
queryType,
contentType) {
// Clear previous test result from title.
document.title = '';
log("Testing video content type: " + contentType +
", color gamut: " + colorGamut +
", transfer function: " + transferFunction);
const configuration = {
type : queryType,
video : {
contentType : contentType,
colorGamut : colorGamut,
transferFunction : transferFunction,
// Any reasonable value will do.
width : 640,
height : 480,
bitrate : 10000,
framerate : 30
}
};
runTest(configuration);
}
</script> </script>
...@@ -74,6 +74,15 @@ constexpr const char* kApplicationMimeTypePrefix = "application/"; ...@@ -74,6 +74,15 @@ constexpr const char* kApplicationMimeTypePrefix = "application/";
constexpr const char* kAudioMimeTypePrefix = "audio/"; constexpr const char* kAudioMimeTypePrefix = "audio/";
constexpr const char* kVideoMimeTypePrefix = "video/"; constexpr const char* kVideoMimeTypePrefix = "video/";
constexpr const char* kCodecsMimeTypeParam = "codecs"; constexpr const char* kCodecsMimeTypeParam = "codecs";
constexpr const char* kSmpteSt2086HdrMetadataType = "smpteSt2086";
constexpr const char* kSmpteSt209410HdrMetadataType = "smpteSt2094-10";
constexpr const char* kSmpteSt209440HdrMetadataType = "smpteSt2094-40";
constexpr const char* kSrgbColorGamut = "srgb";
constexpr const char* kP3ColorGamut = "p3";
constexpr const char* kRec2020ColorGamut = "rec2020";
constexpr const char* kSrgbTransferFunction = "srgb";
constexpr const char* kPqTransferFunction = "pq";
constexpr const char* kHlgTransferFunction = "hlg";
// Gets parameters for kMediaLearningSmoothnessExperiment field trial. Will // Gets parameters for kMediaLearningSmoothnessExperiment field trial. Will
// provide sane defaults when field trial not enabled. Values of -1 indicate // provide sane defaults when field trial not enabled. Values of -1 indicate
...@@ -357,6 +366,57 @@ bool CheckMseSupport(const String& mime_type, const String& codec) { ...@@ -357,6 +366,57 @@ bool CheckMseSupport(const String& mime_type, const String& codec) {
return true; return true;
} }
void ParseDynamicRangeConfigurations(
const blink::VideoConfiguration* video_config,
media::VideoColorSpace* color_space,
media::HdrMetadataType* hdr_metadata) {
DCHECK(color_space);
DCHECK(hdr_metadata);
// TODO(1066628): Follow up on MediaCapabilities spec regarding reconciling
// discrepancies between mime type and colorGamut/transferFunction; for now,
// give precedence to the latter.
const String& hdr_metadata_type = video_config->hdrMetadataType();
if (hdr_metadata_type == kSmpteSt2086HdrMetadataType) {
*hdr_metadata = media::HdrMetadataType::kSmpteSt2086;
} else if (hdr_metadata_type == kSmpteSt209410HdrMetadataType) {
*hdr_metadata = media::HdrMetadataType::kSmpteSt2094_10;
} else if (hdr_metadata_type == kSmpteSt209440HdrMetadataType) {
*hdr_metadata = media::HdrMetadataType::kSmpteSt2094_40;
} else if (hdr_metadata_type.IsNull()) {
*hdr_metadata = media::HdrMetadataType::kNone;
} else {
NOTREACHED();
}
const String& color_gamut = video_config->colorGamut();
if (color_gamut == kSrgbColorGamut) {
color_space->primaries = media::VideoColorSpace::PrimaryID::BT709;
} else if (color_gamut == kP3ColorGamut) {
color_space->primaries = media::VideoColorSpace::PrimaryID::SMPTEST431_2;
} else if (color_gamut == kRec2020ColorGamut) {
color_space->primaries = media::VideoColorSpace::PrimaryID::BT2020;
} else if (color_gamut.IsNull()) {
// Leave |color_space->primaries| as-is.
} else {
NOTREACHED();
}
const String& transfer_function = video_config->transferFunction();
if (transfer_function == kSrgbTransferFunction) {
color_space->transfer = media::VideoColorSpace::TransferID::BT709;
} else if (transfer_function == kPqTransferFunction) {
color_space->transfer = media::VideoColorSpace::TransferID::SMPTEST2084;
} else if (transfer_function == kHlgTransferFunction) {
color_space->transfer = media::VideoColorSpace::TransferID::ARIB_STD_B67;
} else if (transfer_function.IsNull()) {
// Leave |color_space->transfer| as-is.
} else {
NOTREACHED();
}
}
// Returns whether the audio codec associated with the audio configuration is // Returns whether the audio codec associated with the audio configuration is
// valid and non-ambiguous. // valid and non-ambiguous.
// |console_warning| is an out param containing a message to be printed in the // |console_warning| is an out param containing a message to be printed in the
...@@ -456,6 +516,7 @@ bool IsVideoConfigurationSupported( ...@@ -456,6 +516,7 @@ bool IsVideoConfigurationSupported(
uint8_t video_level = 0; uint8_t video_level = 0;
media::VideoColorSpace video_color_space; media::VideoColorSpace video_color_space;
bool is_video_codec_ambiguous = true; bool is_video_codec_ambiguous = true;
media::HdrMetadataType hdr_metadata_type;
// Must succeed as IsVideoCodecValid() should have been called before. // Must succeed as IsVideoCodecValid() should have been called before.
bool parsed = media::ParseVideoCodecString( bool parsed = media::ParseVideoCodecString(
...@@ -463,8 +524,11 @@ bool IsVideoConfigurationSupported( ...@@ -463,8 +524,11 @@ bool IsVideoConfigurationSupported(
&video_profile, &video_level, &video_color_space); &video_profile, &video_level, &video_color_space);
DCHECK(parsed && !is_video_codec_ambiguous); DCHECK(parsed && !is_video_codec_ambiguous);
return media::IsSupportedVideoType( ParseDynamicRangeConfigurations(video_config, &video_color_space,
{video_codec, video_profile, video_level, video_color_space}); &hdr_metadata_type);
return media::IsSupportedVideoType({video_codec, video_profile, video_level,
video_color_space, hdr_metadata_type});
} }
void OnMediaCapabilitiesEncodingInfo( void OnMediaCapabilitiesEncodingInfo(
......
...@@ -4,10 +4,17 @@ ...@@ -4,10 +4,17 @@
// https://wicg.github.io/media-capabilities/#dictdef-videoconfiguration // https://wicg.github.io/media-capabilities/#dictdef-videoconfiguration
enum HdrMetadataType { "smpteSt2086", "smpteSt2094-10", "smpteSt2094-40" };
enum ColorGamut { "srgb", "p3", "rec2020" };
enum TransferFunction { "srgb", "pq", "hlg" };
dictionary VideoConfiguration { dictionary VideoConfiguration {
required DOMString contentType; required DOMString contentType;
required unsigned long width; required unsigned long width;
required unsigned long height; required unsigned long height;
required unsigned long bitrate; required unsigned long bitrate;
required double framerate; required double framerate;
[RuntimeEnabled=MediaCapabilitiesDynamicRange] HdrMetadataType hdrMetadataType;
[RuntimeEnabled=MediaCapabilitiesDynamicRange] ColorGamut colorGamut;
[RuntimeEnabled=MediaCapabilitiesDynamicRange] TransferFunction transferFunction;
}; };
...@@ -19,6 +19,9 @@ struct WebVideoConfiguration { ...@@ -19,6 +19,9 @@ struct WebVideoConfiguration {
unsigned height; unsigned height;
unsigned bitrate; unsigned bitrate;
double framerate; double framerate;
base::Optional<WebString> hdr_metadata_type;
base::Optional<WebString> color_gamut;
base::Optional<WebString> transfer_function;
}; };
} // namespace blink } // namespace blink
......
...@@ -990,6 +990,10 @@ ...@@ -990,6 +990,10 @@
origin_trial_feature_name: "MeasureMemory", origin_trial_feature_name: "MeasureMemory",
status:"experimental", status:"experimental",
}, },
{
name: "MediaCapabilitiesDynamicRange",
status: "test",
},
{ {
name: "MediaCapabilitiesEncodingInfo", name: "MediaCapabilitiesEncodingInfo",
status: "experimental", status: "experimental",
......
...@@ -23,6 +23,19 @@ var audioConfigurationWithSpatialRendering = { ...@@ -23,6 +23,19 @@ var audioConfigurationWithSpatialRendering = {
spatialRendering: true, spatialRendering: true,
}; };
// VideoConfiguration with optional hdrMetadataType, colorGamut, and
// transferFunction properties.
var videoConfigurationWithDynamicRange = {
contentType: 'video/webm; codecs="vp09.00.10.08"',
width: 800,
height: 600,
bitrate: 3000,
framerate: 24,
hdrMetadataType: "smpteSt2086",
colorGamut: "srgb",
transferFunction: "srgb",
}
promise_test(t => { promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo()); return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo());
}, "Test that decodingInfo rejects if it doesn't get a configuration"); }, "Test that decodingInfo rejects if it doesn't get a configuration");
...@@ -314,3 +327,57 @@ promise_test(t => { ...@@ -314,3 +327,57 @@ promise_test(t => {
assert_equals(typeof ability.keySystemAccess, "object"); assert_equals(typeof ability.keySystemAccess, "object");
}); });
}, "Test that decodingInfo with spatialRendering set returns a valid MediaCapabilitiesInfo objects"); }, "Test that decodingInfo with spatialRendering set returns a valid MediaCapabilitiesInfo objects");
promise_test(t => {
return navigator.mediaCapabilities.decodingInfo({
type: 'file',
video: videoConfigurationWithDynamicRange,
}).then(ability => {
assert_equals(typeof ability.supported, "boolean");
assert_equals(typeof ability.smooth, "boolean");
assert_equals(typeof ability.powerEfficient, "boolean");
assert_equals(typeof ability.keySystemAccess, "object");
});
}, "Test that decodingInfo with hdrMetadataType, colorGamut, and transferFunction set returns a valid MediaCapabilitiesInfo objects");
promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
type: 'file',
video: {
contentType: 'video/webm; codecs="vp09.00.10.08"',
width: 800,
height: 600,
bitrate: 3000,
framerate: 24,
hdrMetadataType: ""
},
}));
}, "Test that decodingInfo rejects if the video configuration has an empty hdrMetadataType");
promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
type: 'file',
video: {
contentType: 'video/webm; codecs="vp09.00.10.08"',
width: 800,
height: 600,
bitrate: 3000,
framerate: 24,
colorGamut: true
},
}));
}, "Test that decodingInfo rejects if the video configuration has a colorGamut set to true");
promise_test(t => {
return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
type: 'file',
video: {
contentType: 'video/webm; codecs="vp09.00.10.08"',
width: 800,
height: 600,
bitrate: 3000,
framerate: 24,
transferFunction: 3
},
}));
}, "Test that decodingInfo rejects if the video configuration has a transferFunction set to 3");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment