Skip to content

Commit

Permalink
Add non-fatal EME/key-system teardown error events (#6807)
Browse files Browse the repository at this point in the history
Authored-by: Huan Pu <[email protected]>
  • Loading branch information
JackPu authored Nov 13, 2024
1 parent 19dc3d1 commit a878ad3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api-extractor/report/hls.js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,12 @@ export enum ErrorDetails {
// (undocumented)
KEY_LOAD_TIMEOUT = "keyLoadTimeOut",
// (undocumented)
KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR = "keySystemDestroyCloseSessionError",
// (undocumented)
KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR = "keySystemDestroyMediaKeysError",
// (undocumented)
KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR = "keySystemDestroyRemoveSessionError",
// (undocumented)
KEY_SYSTEM_LICENSE_REQUEST_FAILED = "keySystemLicenseRequestFailed",
// (undocumented)
KEY_SYSTEM_NO_ACCESS = "keySystemNoAccess",
Expand Down
26 changes: 26 additions & 0 deletions src/controller/eme-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,12 @@ class EMEController extends Logger implements ComponentAPI {
.concat(
media?.setMediaKeys(null)?.catch((error) => {
this.log(`Could not clear media keys: ${error}`);
this.hls?.trigger(Events.ERROR, {
type: ErrorTypes.OTHER_ERROR,
details: ErrorDetails.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,
fatal: false,
error: new Error(`Could not clear media keys: ${error}`),
});
}),
),
)
Expand All @@ -1277,6 +1283,14 @@ class EMEController extends Logger implements ComponentAPI {
})
.catch((error) => {
this.log(`Could not close sessions and clear media keys: ${error}`);
this.hls?.trigger(Events.ERROR, {
type: ErrorTypes.OTHER_ERROR,
details: ErrorDetails.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,
fatal: false,
error: new Error(
`Could not close sessions and clear media keys: ${error}`,
),
});
});
}

Expand Down Expand Up @@ -1348,12 +1362,24 @@ class EMEController extends Logger implements ComponentAPI {
.remove()
.catch((error) => {
this.log(`Could not remove session: ${error}`);
this.hls?.trigger(Events.ERROR, {
type: ErrorTypes.OTHER_ERROR,
details: ErrorDetails.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,
fatal: false,
error: new Error(`Could not remove session: ${error}`),
});
})
.then(() => {
return mediaKeysSession.close();
})
.catch((error) => {
this.log(`Could not close session: ${error}`);
this.hls?.trigger(Events.ERROR, {
type: ErrorTypes.OTHER_ERROR,
details: ErrorDetails.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,
fatal: false,
error: new Error(`Could not close session: ${error}`),
});
});
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export enum ErrorDetails {
KEY_SYSTEM_SESSION_UPDATE_FAILED = 'keySystemSessionUpdateFailed',
KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED = 'keySystemStatusOutputRestricted',
KEY_SYSTEM_STATUS_INTERNAL_ERROR = 'keySystemStatusInternalError',
KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR = 'keySystemDestroyMediaKeysError',
KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR = 'keySystemDestroyCloseSessionError',
KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR = 'keySystemDestroyRemoveSessionError',
// Identifier for a manifest load error - data: { url : faulty URL, response : { code: error code, text: error text }}
MANIFEST_LOAD_ERROR = 'manifestLoadError',
// Identifier for a manifest load timeout - data: { url : faulty URL, response : { code: error code, text: error text }}
Expand Down

0 comments on commit a878ad3

Please sign in to comment.