Skip to content

Commit ff1ef7c

Browse files
aveladtykus160
andauthored
feat: Add HDR detection in Tizen and WebOS (#8680)
Close #8441 --------- Co-authored-by: Wojciech Tyczyński <[email protected]>
1 parent 642cecf commit ff1ef7c

File tree

5 files changed

+93
-1
lines changed

5 files changed

+93
-1
lines changed

externs/tizen.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,13 @@ webapis.productinfo.is8KPanelSupported = function() {};
3939
*/
4040
webapis.productinfo.isUdPanelSupported = function() {};
4141

42+
43+
/** @const */
44+
webapis.avinfo = {};
45+
46+
47+
/**
48+
* @return {boolean}
49+
*/
50+
webapis.avinfo.isHdrTvSupport = function() {};
51+

externs/webos.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,15 @@ var PalmSystem = {};
1717

1818
/** @type {string} */
1919
PalmSystem.deviceInfo;
20+
21+
22+
/** @constructor */
23+
function PalmServiceBridge() {}
24+
25+
26+
/** @type {?Function} */
27+
PalmServiceBridge.prototype.onservicecallback;
28+
29+
30+
/** @type {Function} */
31+
PalmServiceBridge.prototype.call = function() {};

lib/device/tizen.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,21 @@ shaka.device.Tizen = class extends shaka.device.AbstractDevice {
173173
return codecs;
174174
}
175175

176+
/**
177+
* @override
178+
*/
179+
getHdrLevel(preferHLG) {
180+
try {
181+
if (webapis.avinfo.isHdrTvSupport()) {
182+
// It relies on previous codec filtering
183+
return preferHLG ? 'HLG' : 'PQ';
184+
}
185+
} catch (e) {
186+
return super.getHdrLevel(preferHLG);
187+
}
188+
return 'SDR';
189+
}
190+
176191
/**
177192
* @override
178193
*/

lib/device/webos.js

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,33 @@ shaka.device.WebOS = class extends shaka.device.AbstractDevice {
2222

2323
/** @private {?number} */
2424
this.osVersion_ = this.guessWebOSVersion_();
25+
26+
/** @private {?boolean} */
27+
this.supportHdr_ = null;
28+
29+
try {
30+
const bridge = new PalmServiceBridge();
31+
bridge.onservicecallback = (n) => {
32+
shaka.log.info(n);
33+
const configsJSON =
34+
/** @type {shaka.device.WebOS.PalmServiceBridgeResponse} */ (
35+
JSON.parse(n));
36+
this.supportHdr_ = configsJSON.configs['tv.model.supportHDR'] ||
37+
configsJSON.configs['tv.config.supportDolbyHDRContents'] || false;
38+
};
39+
const configs = {
40+
configNames: [
41+
'tv.model.supportHDR',
42+
'tv.config.supportDolbyHDRContents',
43+
],
44+
};
45+
// eslint-disable-next-line no-restricted-syntax
46+
bridge.call('luna://com.webos.service.config/getConfigs',
47+
JSON.stringify(configs));
48+
} catch (e) {
49+
shaka.log.alwaysWarn('WebOS: getConfigs call failed', e);
50+
// Ignore errors.
51+
}
2552
}
2653

2754
/**
@@ -123,6 +150,21 @@ shaka.device.WebOS = class extends shaka.device.AbstractDevice {
123150
return config;
124151
}
125152

153+
/**
154+
* @override
155+
*/
156+
getHdrLevel(preferHLG) {
157+
if (this.supportHdr_ == null) {
158+
shaka.log.alwaysWarn('WebOS: getConfigs call haven\'t finished');
159+
return super.getHdrLevel(preferHLG);
160+
}
161+
if (this.supportHdr_) {
162+
// It relies on previous codec filtering
163+
return preferHLG ? 'HLG' : 'PQ';
164+
}
165+
return 'SDR';
166+
}
167+
126168
/**
127169
* @return {?number}
128170
* @private
@@ -172,7 +214,18 @@ shaka.device.WebOS = class extends shaka.device.AbstractDevice {
172214
}
173215
};
174216

217+
218+
/**
219+
* @typedef {{
220+
* configs: Object
221+
* }}
222+
*
223+
* @property {Object} configs
224+
*/
225+
shaka.device.WebOS.PalmServiceBridgeResponse;
226+
175227
if (shaka.device.WebOS.isWebOS_()) {
228+
const webOSDevice = new shaka.device.WebOS();
176229
shaka.device.DeviceFactory.registerDeviceFactory(
177-
() => new shaka.device.WebOS());
230+
() => webOSDevice);
178231
}

project-words.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ TARGETDURATION
468468

469469
# other
470470
autoglottonym
471+
avinfo
471472
awesomplete
472473
axinom
473474
beatle
@@ -492,6 +493,7 @@ malform
492493
masterlist
493494
mbps
494495
msdk
496+
onservicecallback
495497
productinfo
496498
servernum
497499
sintel

0 commit comments

Comments
 (0)