senza-sdk 4.4.3 → 4.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +1 -1
- package/dist/implementation.bundle.js +1 -1
- package/package.json +1 -1
- package/src/api.js +16 -2
- package/src/implementation/api.js +7 -5
- package/src/implementation/deviceManager.js +0 -141
- package/src/implementation/displayManager.js +181 -0
- package/src/implementation/edidParser.js +125 -0
- package/src/implementation/remotePlayer.js +5 -2
- package/src/interface/api.js +1 -0
- package/src/interface/deviceManager.js +0 -33
- package/src/interface/displayManager.js +126 -0
- package/src/interface/version.js +1 -1
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sdkLogger, noop } from "./interface/utils.js";
|
|
2
2
|
|
|
3
|
-
import { Lifecycle, RemotePlayer, DeviceManager, PlatformManager, AlarmManager, MessageManager, ShakaPlayer, shaka, showSequence, initSequence } from "./interface/api.js";
|
|
3
|
+
import { Lifecycle, RemotePlayer, DeviceManager, PlatformManager, AlarmManager, MessageManager, ShakaPlayer, shaka, showSequence, initSequence, DisplayManager } from "./interface/api.js";
|
|
4
4
|
|
|
5
5
|
import { version } from "./interface/version.js";
|
|
6
6
|
|
|
@@ -252,6 +252,18 @@ let alarmManager;
|
|
|
252
252
|
*/
|
|
253
253
|
let deviceManager;
|
|
254
254
|
|
|
255
|
+
/**
|
|
256
|
+
* @module
|
|
257
|
+
* @private
|
|
258
|
+
* @type {DisplayManager}
|
|
259
|
+
* @example
|
|
260
|
+
* import { displayManager } from "senza-sdk";
|
|
261
|
+
* const connection = await displayManager.connection;
|
|
262
|
+
* console.info(connection);
|
|
263
|
+
*
|
|
264
|
+
* @return {DisplayManager} pointer to the DisplayManager singleton
|
|
265
|
+
*/
|
|
266
|
+
let displayManager;
|
|
255
267
|
|
|
256
268
|
/**
|
|
257
269
|
* @module
|
|
@@ -317,6 +329,7 @@ if (!isRunningE2E()) {
|
|
|
317
329
|
remotePlayer = new RemotePlayer();
|
|
318
330
|
alarmManager = new AlarmManager();
|
|
319
331
|
deviceManager = new DeviceManager();
|
|
332
|
+
displayManager = new DisplayManager();
|
|
320
333
|
platformManager = new PlatformManager();
|
|
321
334
|
messageManager = new MessageManager();
|
|
322
335
|
ShakaPlayerImplementation = ShakaPlayer;
|
|
@@ -327,6 +340,7 @@ if (!isRunningE2E()) {
|
|
|
327
340
|
remotePlayer = window.senzaSDKImplementation.remotePlayer;
|
|
328
341
|
alarmManager = window.senzaSDKImplementation.alarmManager;
|
|
329
342
|
deviceManager = window.senzaSDKImplementation.deviceManager;
|
|
343
|
+
displayManager = window.senzaSDKImplementation.displayManager;
|
|
330
344
|
platformManager = window.senzaSDKImplementation.platformManager;
|
|
331
345
|
messageManager = window.senzaSDKImplementation.messageManager;
|
|
332
346
|
ShakaPlayerImplementation = window.senzaSDKImplementation.ShakaPlayer;
|
|
@@ -373,7 +387,7 @@ export function setTimezone(timezone) {
|
|
|
373
387
|
}
|
|
374
388
|
}
|
|
375
389
|
|
|
376
|
-
export { lifecycle, remotePlayer, alarmManager, deviceManager, platformManager, messageManager, ShakaPlayerImplementation as ShakaPlayer, shakaImplementation as shaka, showSequence, initSequence };
|
|
390
|
+
export { lifecycle, remotePlayer, alarmManager, deviceManager, displayManager, platformManager, messageManager, ShakaPlayerImplementation as ShakaPlayer, shakaImplementation as shaka, showSequence, initSequence };
|
|
377
391
|
|
|
378
392
|
// Assign the senza library to the old name (hs) for backward compatibility
|
|
379
393
|
import * as senzaSDK from "./api.js";
|
|
@@ -4,11 +4,13 @@ import { lifecycle } from "./lifecycle.js";
|
|
|
4
4
|
import { alarmManager } from "./alarmManager.js";
|
|
5
5
|
import { remotePlayer } from "./remotePlayer.js";
|
|
6
6
|
import { deviceManager } from "./deviceManager.js";
|
|
7
|
+
import { displayManager } from "./displayManager.js";
|
|
7
8
|
import { messageManager } from "./messageManager.js";
|
|
8
9
|
|
|
9
10
|
export { remotePlayer };
|
|
10
|
-
export { lifecycle }
|
|
11
|
+
export { lifecycle };
|
|
11
12
|
export { deviceManager };
|
|
13
|
+
export { displayManager };
|
|
12
14
|
export { platformManager } from "./platformManager.js";
|
|
13
15
|
export { alarmManager };
|
|
14
16
|
export { messageManager };
|
|
@@ -101,9 +103,9 @@ export async function init(interfaceApiVersion, showSequenceFunc, initSequenceFu
|
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
// Set default device manager event timeout using UI-Streamer settings
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
|
|
106
|
+
const displayManagerEventTimeout = sessionInfoObj?.settings?.["ui-streamer"]?.displayManagerEventTimeout;
|
|
107
|
+
if (displayManagerEventTimeout) {
|
|
108
|
+
displayManager._setDefaultTimeout(displayManagerEventTimeout);
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
// Get trigger event
|
|
@@ -139,7 +141,7 @@ export async function init(interfaceApiVersion, showSequenceFunc, initSequenceFu
|
|
|
139
141
|
await remotePlayer._init(sessionInfoObj, triggerEvent);
|
|
140
142
|
alarmManager._init();
|
|
141
143
|
messageManager._init();
|
|
142
|
-
|
|
144
|
+
await displayManager._init();
|
|
143
145
|
sdkLogger.log("All submodules initialized");
|
|
144
146
|
|
|
145
147
|
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { DeviceManager as DeviceManagerInterface } from "../interface/deviceManager";
|
|
2
2
|
import { getFCID, sdkLogger, getRestResponse } from "./utils";
|
|
3
3
|
import { sessionInfo } from "./SessionInfo";
|
|
4
|
-
import { EventListenersManager } from "./eventListenersManager";
|
|
5
|
-
import { bus, Events } from "./eventBus";
|
|
6
|
-
import { lifecycle } from "./lifecycle";
|
|
7
4
|
|
|
8
5
|
let wifi_ap_data;
|
|
9
6
|
let wifi_status;
|
|
@@ -41,134 +38,6 @@ class DeviceManager extends DeviceManagerInterface {
|
|
|
41
38
|
|
|
42
39
|
constructor() {
|
|
43
40
|
super();
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Mapping of CEC active source status to HdmiStatus.
|
|
47
|
-
* @type {Object}
|
|
48
|
-
* @private
|
|
49
|
-
*/
|
|
50
|
-
this._cecActiveSourceStatusMap = Object.freeze({
|
|
51
|
-
active: this.HdmiStatus.ACTIVE,
|
|
52
|
-
inactive: this.HdmiStatus.INACTIVE,
|
|
53
|
-
unknown: this.HdmiStatus.UNKNOWN
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Event listeners manager for the deviceManager events
|
|
58
|
-
* @type {EventListenersManager}
|
|
59
|
-
* @private
|
|
60
|
-
*/
|
|
61
|
-
this._eventManager = new EventListenersManager({
|
|
62
|
-
timeoutMs: 10000 // Default timeout of 10 seconds, can be overridden by _setDefaultTimeout
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @type {boolean}
|
|
67
|
-
* @private
|
|
68
|
-
*/
|
|
69
|
-
this._isInitialized = false;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @private
|
|
74
|
-
*/
|
|
75
|
-
_init() {
|
|
76
|
-
sdkLogger.log("Initializing DeviceManager");
|
|
77
|
-
if (!this._isInitialized) {
|
|
78
|
-
this._isInitialized = true;
|
|
79
|
-
this._addSenzaEventListeners();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Translate the HdmiStatus information to a single HdmiStatus for the application
|
|
85
|
-
* 1) cecStatus is a configuration setting from the client. If false, we always return UNKNOWN to the application
|
|
86
|
-
* 2) If cecStatus is true, we check the hdmiStatus. If not "connected", the HDMI status is definitely INACTIVE.
|
|
87
|
-
* 3) If hdmiStatus is "connected" and cecStatus is true, we rely on the cecActiveSourceStatus to determine the HdmiStatus
|
|
88
|
-
* @private
|
|
89
|
-
*/
|
|
90
|
-
_translateHdmiStatus(hdmiStatusStr) {
|
|
91
|
-
const hdmiStatusObj = JSON.parse(hdmiStatusStr ?? "{}"); // Object containing the 3 statuses
|
|
92
|
-
let hdmiStatus = this.HdmiStatus.UNKNOWN;
|
|
93
|
-
if (hdmiStatusObj?.cecStatus) {
|
|
94
|
-
if (hdmiStatusObj.hdmiStatus !== "connected") {
|
|
95
|
-
hdmiStatus = this.HdmiStatus.INACTIVE;
|
|
96
|
-
} else {
|
|
97
|
-
const cecActive = this._cecActiveSourceStatusMap[hdmiStatusObj.cecActiveSourceStatus];
|
|
98
|
-
hdmiStatus = cecActive ?? this.HdmiStatus.UNKNOWN;
|
|
99
|
-
if (!cecActive) {
|
|
100
|
-
sdkLogger.warn(`Unknown CEC active source status: ${hdmiStatusObj.cecActiveSourceStatus}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
sdkLogger.warn("cec is disabled or no hdmiStatus");
|
|
105
|
-
}
|
|
106
|
-
sdkLogger.log("HDMI status is:", hdmiStatus);
|
|
107
|
-
return hdmiStatus;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* @private Add event listeners for system events
|
|
112
|
-
*/
|
|
113
|
-
_addSenzaEventListeners() {
|
|
114
|
-
bus.addEventListener(Events.LifecycleForeground, () => {
|
|
115
|
-
this._moveToForegroundHasBeenCalled = true;
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
typeof document !== "undefined" && document.addEventListener("hs/hdmiStatusChanged", async (event) => {
|
|
119
|
-
sdkLogger.info("Got hs/hdmiStatusChanged event with detail", JSON.stringify(event?.detail));
|
|
120
|
-
|
|
121
|
-
const hdmiStatus = this._translateHdmiStatus(event?.detail?.hdmiStatus);
|
|
122
|
-
|
|
123
|
-
const timeBeforeCallbacks = Date.now();
|
|
124
|
-
|
|
125
|
-
// Dispatch event to application and allow a chance to move to foreground.
|
|
126
|
-
// If there are no callbacks or the application doesn't move to foreground, the UI will be disconnected.
|
|
127
|
-
await this._eventManager.dispatch("hdmistatuschanged", {hdmiStatus});
|
|
128
|
-
|
|
129
|
-
const callbackDuration = Date.now() - timeBeforeCallbacks;
|
|
130
|
-
sdkLogger.log(`All callbacks for hdmiStatusChanged are finished within ${callbackDuration}ms`);
|
|
131
|
-
const isTriggering = lifecycle.triggerEvent.type === "hdmiStatusChanged" && lifecycle._triggerEventFcid && lifecycle._triggerEventFcid === event.detail.fcid;
|
|
132
|
-
if (isTriggering) {
|
|
133
|
-
if (!this._moveToForegroundHasBeenCalled && window.cefQuery) {
|
|
134
|
-
sdkLogger.log("Application is about to be disconnected since didn't move to foreground");
|
|
135
|
-
const message = { type: "disconnect" };
|
|
136
|
-
const request = { target: "TC", waitForResponse: false, message: JSON.stringify(message) };
|
|
137
|
-
window.cefQuery({
|
|
138
|
-
request: JSON.stringify(request),
|
|
139
|
-
persistent: false,
|
|
140
|
-
onSuccess: () => {
|
|
141
|
-
sdkLogger.log("disconnect request successfully sent");
|
|
142
|
-
},
|
|
143
|
-
onFailure: (code, msg) => {
|
|
144
|
-
sdkLogger.error(`disconnect request failed: ${code} ${msg}`);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Set the default timeout for device manager event listeners
|
|
154
|
-
* @param {number} timeout - Timeout in milliseconds for device manager event listeners
|
|
155
|
-
* @private
|
|
156
|
-
*/
|
|
157
|
-
_setDefaultTimeout(timeout) {
|
|
158
|
-
if (typeof timeout === "number" && timeout > 0) {
|
|
159
|
-
this._eventManager.timeoutMs = timeout;
|
|
160
|
-
sdkLogger.log(`DeviceManager event listener timeout set to ${timeout}ms`);
|
|
161
|
-
} else {
|
|
162
|
-
sdkLogger.warn(`Invalid timeout value: ${timeout}. Must be a positive number.`);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
addEventListener(type, callback) {
|
|
167
|
-
this._eventManager.addEventListener(type, callback);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
removeEventListener(type, callback) {
|
|
171
|
-
this._eventManager.removeEventListener(type, callback);
|
|
172
41
|
}
|
|
173
42
|
|
|
174
43
|
get deviceInfo() {
|
|
@@ -188,16 +57,6 @@ class DeviceManager extends DeviceManagerInterface {
|
|
|
188
57
|
return super.deviceInfo;
|
|
189
58
|
}
|
|
190
59
|
|
|
191
|
-
async getHdmiStatus() {
|
|
192
|
-
try {
|
|
193
|
-
const response = await getRestResponse("hdmi-status");
|
|
194
|
-
return this._translateHdmiStatus(response);
|
|
195
|
-
} catch (e) {
|
|
196
|
-
sdkLogger.error(e);
|
|
197
|
-
return this.HdmiStatus.UNKNOWN;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
60
|
reboot() {
|
|
202
61
|
return new Promise((resolve, reject) => {
|
|
203
62
|
if (window.cefQuery) {
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { DisplayManager as DisplayManagerInterface } from "../interface/displayManager";
|
|
2
|
+
import { sdkLogger, getRestResponse } from "./utils";
|
|
3
|
+
import { parseEdid } from "./edidParser";
|
|
4
|
+
import { EventListenersManager } from "./eventListenersManager";
|
|
5
|
+
import { bus, Events } from "./eventBus";
|
|
6
|
+
import { lifecycle } from "./lifecycle";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export class DisplayManager extends DisplayManagerInterface {
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
/**
|
|
14
|
+
* Event listeners manager for the displayManager events
|
|
15
|
+
* @type {EventListenersManager}
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
this._eventManager = new EventListenersManager({
|
|
19
|
+
timeoutMs: 10000 // Default timeout of 10 seconds, can be overridden by _setDefaultTimeout
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @type {boolean}
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
this._isInitialized = false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async _updateDisplayInfo() {
|
|
30
|
+
try {
|
|
31
|
+
const displayInfoResponse = await getRestResponse("display-info");
|
|
32
|
+
const displayInfo = this._parseDisplayInfo(displayInfoResponse);
|
|
33
|
+
this._setDisplayProperties(displayInfo);
|
|
34
|
+
} catch (e) {
|
|
35
|
+
sdkLogger.error(e);
|
|
36
|
+
this._setDisplayProperties({ connection: this.DisplayConnectionStatus.UNKNOWN });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async _init() {
|
|
41
|
+
sdkLogger.log("Initializing DisplayManager");
|
|
42
|
+
await this._updateDisplayInfo();
|
|
43
|
+
if (!this._isInitialized) {
|
|
44
|
+
this._isInitialized = true;
|
|
45
|
+
this._addSenzaEventListeners();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @private Add event listeners for system events
|
|
51
|
+
*/
|
|
52
|
+
_addSenzaEventListeners() {
|
|
53
|
+
bus.addEventListener(Events.LifecycleForeground, () => {
|
|
54
|
+
this._moveToForegroundHasBeenCalled = true;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
typeof document !== "undefined" && document.addEventListener("hs/displayInfoChanged", async (event) => {
|
|
58
|
+
sdkLogger.info("Got hs/displayInfoChanged event with detail", JSON.stringify(event?.detail));
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
const displayInfo = this._parseDisplayInfo(event.detail.displayInfo);
|
|
62
|
+
this._setDisplayProperties(displayInfo);
|
|
63
|
+
|
|
64
|
+
const timeBeforeCallbacks = Date.now();
|
|
65
|
+
|
|
66
|
+
// Dispatch event to application and allow a chance to move to foreground.
|
|
67
|
+
// If there are no callbacks or the application doesn't move to foreground, the UI will be disconnected.
|
|
68
|
+
await this._eventManager.dispatch("displayinfochanged", { displayInfo });
|
|
69
|
+
|
|
70
|
+
const callbackDuration = Date.now() - timeBeforeCallbacks;
|
|
71
|
+
sdkLogger.log(`All callbacks for displayInfoChanged are finished within ${callbackDuration}ms`);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
sdkLogger.error("Failed to handle displayInfo update", error);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const isTriggering = lifecycle.triggerEvent.type === "displayInfoChanged" && lifecycle._triggerEventFcid && lifecycle._triggerEventFcid === event.detail.fcid;
|
|
77
|
+
if (isTriggering) {
|
|
78
|
+
if (!this._moveToForegroundHasBeenCalled && window.cefQuery) {
|
|
79
|
+
sdkLogger.log("Application is about to be disconnected since didn't move to foreground");
|
|
80
|
+
const message = { type: "disconnect" };
|
|
81
|
+
const request = { target: "TC", waitForResponse: false, message: JSON.stringify(message) };
|
|
82
|
+
window.cefQuery({
|
|
83
|
+
request: JSON.stringify(request),
|
|
84
|
+
persistent: false,
|
|
85
|
+
onSuccess: () => {
|
|
86
|
+
sdkLogger.log("disconnect request successfully sent");
|
|
87
|
+
},
|
|
88
|
+
onFailure: (code, msg) => {
|
|
89
|
+
sdkLogger.error(`disconnect request failed: ${code} ${msg}`);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Set the default timeout for display manager event listeners
|
|
99
|
+
* @param {number} timeout - Timeout in milliseconds for display manager event listeners
|
|
100
|
+
* @private
|
|
101
|
+
*/
|
|
102
|
+
_setDefaultTimeout(timeout) {
|
|
103
|
+
if (typeof timeout === "number" && timeout > 0) {
|
|
104
|
+
this._eventManager.timeoutMs = timeout;
|
|
105
|
+
sdkLogger.log(`displayManager event listener timeout set to ${timeout}ms`);
|
|
106
|
+
} else {
|
|
107
|
+
sdkLogger.warn(`Invalid timeout value: ${timeout}. Must be a positive number.`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
_setDisplayProperties(displayInfo) {
|
|
112
|
+
|
|
113
|
+
if (displayInfo.connection !== undefined) {
|
|
114
|
+
this.connection = displayInfo.connection;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// If the connection is disconnected/unknown, reset all the display properties
|
|
118
|
+
if (this.connection !== this.DisplayConnectionStatus.CONNECTED) {
|
|
119
|
+
this.selected = undefined;
|
|
120
|
+
this.resolution = undefined;
|
|
121
|
+
this.framerate = undefined;
|
|
122
|
+
this.security = undefined;
|
|
123
|
+
this.make = undefined;
|
|
124
|
+
this.model = undefined;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
for (const [key, value] of Object.entries(displayInfo)) {
|
|
129
|
+
if (value !== undefined) {
|
|
130
|
+
this[key] = value;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
_parseDisplayInfo(displayInfoResponseStr) {
|
|
136
|
+
const displayInfoResponse = JSON.parse(displayInfoResponseStr);
|
|
137
|
+
|
|
138
|
+
const displayInfo = {
|
|
139
|
+
connection: displayInfoResponse?.connection,
|
|
140
|
+
selected: displayInfoResponse?.connectedDisplayInfo?.selected,
|
|
141
|
+
resolution: displayInfoResponse?.connectedDisplayInfo?.resolution,
|
|
142
|
+
framerate: displayInfoResponse?.connectedDisplayInfo?.framerate,
|
|
143
|
+
security: displayInfoResponse?.connectedDisplayInfo?.hdcpVersion
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
if (displayInfoResponse?.connectedDisplayInfo?.edid) {
|
|
148
|
+
try {
|
|
149
|
+
const { manufacturerName, modelName } = parseEdid(displayInfoResponse.connectedDisplayInfo.edid);
|
|
150
|
+
displayInfo.make = manufacturerName ? manufacturerName : "unknown";
|
|
151
|
+
displayInfo.model = modelName ? modelName : "unknown";
|
|
152
|
+
} catch (error) {
|
|
153
|
+
sdkLogger.error("Failed to parse EDID", error);
|
|
154
|
+
displayInfo.make = "unknown";
|
|
155
|
+
displayInfo.model = "unknown";
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return displayInfo;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
addEventListener(type, callback) {
|
|
162
|
+
this._eventManager.addEventListener(type, callback);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
removeEventListener(type, callback) {
|
|
166
|
+
this._eventManager.removeEventListener(type, callback);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @module
|
|
173
|
+
* @type {DisplayManager}
|
|
174
|
+
* @example
|
|
175
|
+
* import { displayManager } from "senza-sdk";
|
|
176
|
+
* const connection = await displayManager.connection;
|
|
177
|
+
* console.info(connection);
|
|
178
|
+
*
|
|
179
|
+
* @return {DisplayManager} pointer to the DisplayManager singleton
|
|
180
|
+
*/
|
|
181
|
+
export const displayManager = new DisplayManager();
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const MANUFACTURER_MAP = {
|
|
2
|
+
// Major PC & Display Brands
|
|
3
|
+
ACR: "Acer",
|
|
4
|
+
APP: "Apple",
|
|
5
|
+
AOC: "AOC",
|
|
6
|
+
AUO: "AU Optronics",
|
|
7
|
+
BNQ: "BenQ",
|
|
8
|
+
BOE: "BOE Technology",
|
|
9
|
+
CMN: "Innolux (Chimei Innolux)",
|
|
10
|
+
CMO: "Chi Mei Optoelectronics",
|
|
11
|
+
CPQ: "Compaq",
|
|
12
|
+
DELL: "Dell", // some EDIDs use DEL
|
|
13
|
+
DEL: "Dell",
|
|
14
|
+
EIZ: "EIZO",
|
|
15
|
+
FUS: "Fujitsu",
|
|
16
|
+
HPN: "HP",
|
|
17
|
+
HWP: "HP",
|
|
18
|
+
IVM: "Iiyama",
|
|
19
|
+
LEN: "Lenovo",
|
|
20
|
+
LPL: "LG Philips LCD",
|
|
21
|
+
LGE: "LG Electronics",
|
|
22
|
+
GSM: "LG Electronics (GoldStar)",
|
|
23
|
+
MEI: "Panasonic (Matsushita)",
|
|
24
|
+
NEC: "NEC",
|
|
25
|
+
NVD: "Nvidia",
|
|
26
|
+
PHL: "Philips",
|
|
27
|
+
PHI: "Philips",
|
|
28
|
+
SAM: "Samsung",
|
|
29
|
+
SNY: "Sony",
|
|
30
|
+
TOS: "Toshiba",
|
|
31
|
+
VSC: "ViewSonic",
|
|
32
|
+
VIZ: "Vizio",
|
|
33
|
+
|
|
34
|
+
// Panel Makers / ODMs
|
|
35
|
+
CPT: "Chunghwa Picture Tubes",
|
|
36
|
+
HSD: "HannStar Display",
|
|
37
|
+
QDS: "Quanta Display",
|
|
38
|
+
SEC: "Samsung Electronics Display",
|
|
39
|
+
SHP: "Sharp",
|
|
40
|
+
TMX: "Tianma",
|
|
41
|
+
CMI: "Chi Mei Innolux",
|
|
42
|
+
|
|
43
|
+
// Other common consumer brands
|
|
44
|
+
JVC: "JVC (Victor Company of Japan)",
|
|
45
|
+
PIO: "Pioneer",
|
|
46
|
+
FUN: "Funai",
|
|
47
|
+
GRN: "Grundig",
|
|
48
|
+
MAG: "MAG Innovision",
|
|
49
|
+
TCL: "TCL",
|
|
50
|
+
HAI: "Haier",
|
|
51
|
+
HIT: "Hitachi",
|
|
52
|
+
SMC: "Sumitomo",
|
|
53
|
+
WAC: "Wacom",
|
|
54
|
+
ASUS: "ASUSTek", // often ASU
|
|
55
|
+
ASU: "ASUS",
|
|
56
|
+
GIG: "Gigabyte",
|
|
57
|
+
MSI: "Micro-Star International",
|
|
58
|
+
|
|
59
|
+
// Catch-alls / misc seen in monitors
|
|
60
|
+
ENC: "Energizer",
|
|
61
|
+
ZOW: "Zowie",
|
|
62
|
+
TTX: "Tatung",
|
|
63
|
+
KDS: "KDS",
|
|
64
|
+
HIS: "HIS",
|
|
65
|
+
XXX: "TCL",
|
|
66
|
+
XMD: "Xiaomi"
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// --- helpers ---
|
|
70
|
+
function hexToBytes(hex) {
|
|
71
|
+
const clean = hex.replace(/[^0-9a-fA-F]/g, "");
|
|
72
|
+
if (clean.length % 2 !== 0) throw new Error("Hex length must be even");
|
|
73
|
+
const out = new Uint8Array(clean.length / 2);
|
|
74
|
+
for (let i = 0; i < clean.length; i += 2) {
|
|
75
|
+
out[i / 2] = parseInt(clean.slice(i, i + 2), 16);
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function decodeEisaId(word) {
|
|
81
|
+
const a = (word >> 10 & 0x1f) + 64;
|
|
82
|
+
const b = (word >> 5 & 0x1f) + 64;
|
|
83
|
+
const c = (word & 0x1f) + 64;
|
|
84
|
+
return [a, b, c].map(n => n >= 65 && n <= 90 ? String.fromCharCode(n) : "?").join("");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function sanitizeEdidString(bytes) {
|
|
88
|
+
let out = "";
|
|
89
|
+
for (const b of bytes) {
|
|
90
|
+
if (b === 0x00 || b === 0x0a) break;
|
|
91
|
+
if (b >= 0x20 && b <= 0x7e) out += String.fromCharCode(b);
|
|
92
|
+
}
|
|
93
|
+
return out.trim();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
export function parseEdid(input) {
|
|
98
|
+
const edid = input instanceof Uint8Array ? input : hexToBytes(input);
|
|
99
|
+
|
|
100
|
+
// Manufacturer ID (bytes 8–9)
|
|
101
|
+
const mfgWord = edid[8] << 8 | edid[9];
|
|
102
|
+
const manufacturerId = decodeEisaId(mfgWord);
|
|
103
|
+
const manufacturerName = MANUFACTURER_MAP[manufacturerId] || manufacturerId;
|
|
104
|
+
|
|
105
|
+
// Product code (bytes 10–11)
|
|
106
|
+
const productCode = (edid[10] | edid[11] << 8) >>> 0;
|
|
107
|
+
const modelNumber = String(productCode);
|
|
108
|
+
|
|
109
|
+
// Monitor name descriptor (0xFC) and serial number descriptor (0xFF) in base block
|
|
110
|
+
let modelName;
|
|
111
|
+
let serialNumber;
|
|
112
|
+
for (let off = 0x36; off <= 0x7e - 18; off += 18) {
|
|
113
|
+
const d = edid.slice(off, off + 18);
|
|
114
|
+
if (d[0] === 0x00 && d[1] === 0x00 && d[2] === 0x00) {
|
|
115
|
+
if (d[3] === 0xFC) {
|
|
116
|
+
modelName = sanitizeEdidString(d.slice(5, 18));
|
|
117
|
+
} else if (d[3] === 0xFF) {
|
|
118
|
+
serialNumber = sanitizeEdidString(d.slice(5, 18));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return { manufacturerName, modelName, modelNumber, serialNumber };
|
|
124
|
+
}
|
|
125
|
+
|
|
@@ -246,6 +246,7 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
246
246
|
|
|
247
247
|
typeof document !== "undefined" && document.addEventListener("hs/EOS", () => {
|
|
248
248
|
sdkLogger.info("Got hs/EOS event");
|
|
249
|
+
this._changePlayMode(false);
|
|
249
250
|
this.dispatchEvent(new Event("ended"));
|
|
250
251
|
});
|
|
251
252
|
|
|
@@ -790,10 +791,12 @@ class RemotePlayer extends RemotePlayerInterface {
|
|
|
790
791
|
fcid: FCID
|
|
791
792
|
};
|
|
792
793
|
if (this._uiAvSyncIntervalMs !== undefined) {
|
|
793
|
-
message.
|
|
794
|
+
message.connectorSettings = message.connectorSettings || {};
|
|
795
|
+
message.connectorSettings.uiAvSyncIntervalMs = this._uiAvSyncIntervalMs;
|
|
794
796
|
}
|
|
795
797
|
if (this._abrAvSyncIntervalMs !== undefined) {
|
|
796
|
-
message.
|
|
798
|
+
message.connectorSettings = message.connectorSettings || {};
|
|
799
|
+
message.connectorSettings.abrAvSyncIntervalMs = this._abrAvSyncIntervalMs;
|
|
797
800
|
}
|
|
798
801
|
if (this._remotePlayerApiVersion >= 2) {
|
|
799
802
|
message.type = "remotePlayer.load";
|
package/src/interface/api.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Lifecycle } from "./lifecycle.js";
|
|
2
2
|
export { DeviceManager } from "./deviceManager.js";
|
|
3
|
+
export { DisplayManager } from "./displayManager.js";
|
|
3
4
|
export { PlatformManager } from "./platformManager.js";
|
|
4
5
|
export { AlarmManager } from "./alarmManager.js";
|
|
5
6
|
export { MessageManager } from "./messageManager.js";
|
|
@@ -1,32 +1,9 @@
|
|
|
1
1
|
import { sdkLogger, noop } from "./utils.js";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @event DeviceManager#hdmistatuschanged
|
|
5
|
-
* @description Fired when the HDMI connection status changes.<br>
|
|
6
|
-
* @property {HdmiStatus} hdmiStatus - the status of the HDMI connection.
|
|
7
|
-
* @example
|
|
8
|
-
* deviceManager.addEventListener("hdmistatuschanged", (e) => {
|
|
9
|
-
* console.info("HDMI status changed:", e.detail.hdmiStatus);
|
|
10
|
-
* });
|
|
11
|
-
* @private
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
3
|
/**
|
|
15
4
|
* DeviceManager is a singleton class that manages the device.<br>
|
|
16
|
-
* @fires hdmistatuschanged
|
|
17
5
|
*/
|
|
18
6
|
export class DeviceManager extends EventTarget {
|
|
19
|
-
/**
|
|
20
|
-
* @typedef {Object} HdmiStatus - The HDMI status of the device
|
|
21
|
-
* @property {string} ACTIVE - The device is connected to the active HDMI source.
|
|
22
|
-
* @property {string} INACTIVE - The active HDMI source is different than the one connected to the device or the TV is in standby.
|
|
23
|
-
* @property {string} UNKNOWN - The status is unknown. This can happen if the TV does not support HDMI status detection.
|
|
24
|
-
*/
|
|
25
|
-
HdmiStatus = Object.freeze({
|
|
26
|
-
ACTIVE: "active",
|
|
27
|
-
INACTIVE: "inactive",
|
|
28
|
-
UNKNOWN: "unknown"
|
|
29
|
-
});
|
|
30
7
|
|
|
31
8
|
/**
|
|
32
9
|
* @property {object} DeviceInfo
|
|
@@ -54,16 +31,6 @@ export class DeviceManager extends EventTarget {
|
|
|
54
31
|
|
|
55
32
|
}
|
|
56
33
|
|
|
57
|
-
/**
|
|
58
|
-
* Get the current HDMI status from the connector
|
|
59
|
-
* @return {Promise<HdmiStatus>} Promise which is resolved when getHdmiStatus has been successfully performed
|
|
60
|
-
* Failure to getHdmiStatus for any reason, results in the promise being rejected.
|
|
61
|
-
* @private
|
|
62
|
-
*/
|
|
63
|
-
getHdmiStatus() {
|
|
64
|
-
return noop("DeviceManager.getHdmiStatus");
|
|
65
|
-
}
|
|
66
|
-
|
|
67
34
|
/**
|
|
68
35
|
* Reboot the device
|
|
69
36
|
* @return {Promise} Promise which is resolved when the reboot command has been successfully processed.
|