Limit transcoding profiles with maximum resolution

This commit is contained in:
Dmitry Lyzo 2022-01-16 22:25:03 +03:00
parent 999011509e
commit bbfe904a28

View File

@ -39,6 +39,25 @@ function getDeviceProfile(item) {
profile = profileBuilder(builderOpts); profile = profileBuilder(builderOpts);
} }
const maxTranscodingVideoWidth = appHost.screen()?.maxAllowedWidth;
if (maxTranscodingVideoWidth) {
profile.TranscodingProfiles.forEach((transcodingProfile) => {
if (transcodingProfile.Type === 'Video') {
transcodingProfile.Conditions = (transcodingProfile.Conditions || []).filter((condition) => {
return condition.Property !== 'Width';
});
transcodingProfile.Conditions.push({
Condition: 'LessThanEqual',
Property: 'Width',
Value: maxTranscodingVideoWidth.toString(),
IsRequired: false
});
}
});
}
resolve(profile); resolve(profile);
}); });
} }
@ -382,6 +401,27 @@ export const appHost = {
const att = scalable ? 'width=device-width, initial-scale=1, minimum-scale=1, user-scalable=yes' : 'width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no'; const att = scalable ? 'width=device-width, initial-scale=1, minimum-scale=1, user-scalable=yes' : 'width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no';
document.querySelector('meta[name=viewport]').setAttribute('content', att); document.querySelector('meta[name=viewport]').setAttribute('content', att);
} }
},
screen: () => {
let hostScreen = null;
const appHostImpl = window.NativeShell?.AppHost;
if (appHostImpl?.screen) {
hostScreen = appHostImpl.screen();
} else if (window.screen && !browser.tv) {
hostScreen = {
width: Math.floor(window.screen.width * window.devicePixelRatio),
height: Math.floor(window.screen.height * window.devicePixelRatio)
};
}
if (hostScreen) {
// Use larger dimension to account for screen orientation changes
hostScreen.maxAllowedWidth = Math.max(hostScreen.width, hostScreen.height);
}
return hostScreen;
} }
}; };