Skip to content

Commit 159ded1

Browse files
committed
Timeout missing key-status with fallback to status from other session
Resolves #7519
1 parent 6d30359 commit 159ded1

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/controller/eme-controller.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -929,11 +929,11 @@ class EMEController extends Logger implements ComponentAPI {
929929

930930
// handle status of current key
931931
let keyStatus = context.keyStatuses[keyId] as MediaKeyStatus | undefined;
932-
933932
if (!keyStatus) {
934933
keyStatus = 'status-pending';
935934
const keyIds = Object.keys(context.keyStatuses);
936935
if (keyIds.length) {
936+
// Timeout key-status
937937
const timeout = (this.hls as any)?.config.keyLoadPolicy.default
938938
.maxTimeToFirstByteMs;
939939
context.keyStatusTimeouts ||= {};
@@ -945,15 +945,28 @@ class EMEController extends Logger implements ComponentAPI {
945945
if (keyId in context.keyStatuses) {
946946
keyStatus = context.keyStatuses[keyId];
947947
} else {
948+
// Find key status in another session if missing (PlayReady #7519 no key-status "single-key" setup with shared key)
949+
const { mediaKeySessions } = this;
950+
for (let i = 0; i < mediaKeySessions.length; i++) {
951+
const keyStatuses = mediaKeySessions[i].keyStatuses;
952+
if (keyId in keyStatuses) {
953+
this.log(
954+
`No status for keyId ${keyId} in session ${context.mediaKeysSession.sessionId}. Using session key-status ${keyStatuses[keyId]} from session ${mediaKeySessions[i].mediaKeysSession.sessionId}.`,
955+
);
956+
return handleKeyStatus(keyStatuses[keyId]);
957+
}
958+
}
959+
// Timeout key with internal-error
948960
this.log(
949-
`key status for ${keyId} in session ${context.mediaKeysSession.sessionId} timed out after 5s.`,
961+
`key status for ${keyId} in session ${context.mediaKeysSession.sessionId} timed out after ${timeout}ms`,
950962
);
951963
keyStatus = 'internal-error';
952964
}
965+
953966
handleKeyStatus(keyStatus);
954967
}, timeout);
955968
this.log(
956-
`No status for keyId ${keyId}. Using session key-status ${keyStatus} (${stringify(context.keyStatuses)}).`,
969+
`No status for keyId ${keyId}. Using key-status ${keyStatus} (${stringify(context.keyStatuses)}).`,
957970
);
958971
}
959972
}

0 commit comments

Comments
 (0)