Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SITE OBJECTIVE
- // This site has a variety of codecs. It will prefer hw-secure CDM, but it's main
- // priority is being able to transition between codecs. Not sure if this is realistic,
- // but it helps exercise all the code.
- function allTransitionSupported(info_list) {
- return info_list.every((info) => info.codec_transitions_supported);
- }
- (async _ => {
- // First try to setup hw-secure with transitions
- let hw_secure_configs = [ VP9_OPUS_HW_SECURE, H264_AAC_HW_SECURE ];
- let hw_secure_infos = await Promise.all(hw_secure_configs.map(config => decodingInfo(config)));
- let hw_secure_supported = allSupported(hw_secure_infos);
- if (hw_secure_supported && allTransitionsSupported(hw_secure_infos)) {
- setupPlayback(hw_secure_infos);
- return;
- }
- // HW-secure either wasn't supported, or couldn't transition. Let's see about sw-secure.
- let sw_secure_configs = [ VP9_OPUS_SW_SECURE, H264_AAC_SW_SECURE ];
- let sw_secure_infos = await Promise.all(sw_secure_configs.map(config => decodingInfo(config)));
- let sw_secure_supported = allSupported(sw_secure_infos);
- if (sw_secure_supported && allTransitionsSupported(sw_secure_infos)) {
- setupPlayback(sw_secure_infos);
- return;
- }
- }
- // Didn't get transitions with either. Fall back to h264+aac using the highest security available
- if (hw_secure_supported) {
- setupPlayback(hw_secure_infos.slice(1));
- } else if (sw_secure_supported) {
- setupPlayback(sw_secure_infos.slice(1));
- } else {
- alert('no supported configurations');
- }
- })(); // End async wrapper
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement