Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split and extract video range support detection #4804

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions src/scripts/browserDeviceProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,27 @@ function supportsVc1(videoTestElement) {
return browser.tizen || browser.web0s || browser.edgeUwp || videoTestElement.canPlayType('video/mp4; codecs="vc-1"').replace(/no/, '');
}

function supportsHdr10(options) {
return options.supportsHdr10 ?? (false // eslint-disable-line sonarjs/no-redundant-boolean
|| browser.tizen
|| browser.web0s
|| browser.safari && ((browser.iOS && browser.iOSVersion >= 11) || browser.osx)
// Chrome mobile and Firefox have no client side tone-mapping
// Edge Chromium on Nvidia is known to have color issues on 10-bit video
|| browser.chrome && !browser.mobile
);
}

function supportsHlg(options) {
return options.supportsHlg ?? supportsHdr10(options);
}

function supportsDolbyVision(options) {
return options.supportsDolbyVision ?? (false // eslint-disable-line sonarjs/no-redundant-boolean
|| browser.safari && ((browser.iOS && browser.iOSVersion >= 13) || browser.osx)
);
}

function getDirectPlayProfileForVideoContainer(container, videoAudioCodecs, videoTestElement, options) {
let supported = false;
let profileContainer = container;
Expand Down Expand Up @@ -897,25 +918,20 @@ export default function (options) {
let vp9VideoRangeTypes = 'SDR';
let av1VideoRangeTypes = 'SDR';

if (browser.safari && ((browser.iOS && browser.iOSVersion >= 11) || browser.osx)) {
hevcVideoRangeTypes += '|HDR10|HLG';
if ((browser.iOS && browser.iOSVersion >= 13) || browser.osx) {
hevcVideoRangeTypes += '|DOVI';
}
if (supportsHdr10(options)) {
hevcVideoRangeTypes += '|HDR10';
vp9VideoRangeTypes += '|HDR10';
av1VideoRangeTypes += '|HDR10';
}

if (browser.tizen || browser.web0s) {
hevcVideoRangeTypes += '|HDR10|HLG';
vp9VideoRangeTypes += '|HDR10|HLG';
av1VideoRangeTypes += '|HDR10|HLG';
if (supportsHlg(options)) {
hevcVideoRangeTypes += '|HLG';
vp9VideoRangeTypes += '|HLG';
av1VideoRangeTypes += '|HLG';
}

// Chrome mobile and Firefox have no client side tone-mapping
// Edge Chromium on Nvidia is known to have color issues on 10-bit video
if (browser.chrome && !browser.mobile) {
hevcVideoRangeTypes += '|HDR10|HLG';
vp9VideoRangeTypes += '|HDR10|HLG';
av1VideoRangeTypes += '|HDR10|HLG';
if (supportsDolbyVision(options)) {
hevcVideoRangeTypes += '|DOVI';
}

const h264CodecProfileConditions = [
Expand Down
Loading