Skip to content

Commit becc754

Browse files
committed
Update ProtectionController.js
1 parent 5345b31 commit becc754

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/streaming/protection/controllers/ProtectionController.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ import {HTTPRequest} from '../../vo/metrics/HTTPRequest.js';
3939
import Utils from '../../../core/Utils.js';
4040
import Constants from '../../constants/Constants.js';
4141
import FactoryMaker from '../../../core/FactoryMaker.js';
42-
import ProtectionConstants from '../../constants/ProtectionConstants.js';
4342

4443
import { getPSSHData } from '@svta/common-media-library/drm/common-encryption/getPSSHData.js';
4544
import { getPSSHForKeySystem } from '@svta/common-media-library/drm/common-encryption/getPSSHForKeySystem.js';
4645
import { getLicenseServerUrlFromContentProtection } from '@svta/common-media-library/drm/common-encryption/getLicenseServerUrlFromContentProtection.js';
46+
import { MEDIA_KEY_MESSAGE_TYPES } from '@svta/common-media-library/drm/common/const/MEDIA_KEY_MESSAGE_TYPES.js';
47+
import { INITIALIZATION_DATA_TYPE } from '@svta/common-media-library/drm/common/const/INITIALIZATION_DATA_TYPE.js';
48+
import { PLAYREADY_UUID } from '@svta/common-media-library/drm/common/const/PLAYREADY_UUID.js';
49+
import { MEDIA_KEY_STATUSES } from '@svta/common-media-library/drm/common/const/MEDIA_KEY_STATUSES.js';
4750

4851
const NEEDKEY_BEFORE_INITIALIZE_RETRIES = 5;
4952
const NEEDKEY_BEFORE_INITIALIZE_TIMEOUT = 500;
@@ -306,7 +309,7 @@ function ProtectionController(config) {
306309
const protData = keySystemData.protData;
307310
const audioCapabilities = [];
308311
const videoCapabilities = [];
309-
const initDataTypes = (protData && protData.initDataTypes && protData.initDataTypes.length > 0) ? protData.initDataTypes : [ProtectionConstants.INITIALIZATION_DATA_TYPE_CENC];
312+
const initDataTypes = (protData && protData.initDataTypes && protData.initDataTypes.length > 0) ? protData.initDataTypes : [INITIALIZATION_DATA_TYPE.CENC];
310313
const audioRobustness = (protData && protData.audioRobustness && protData.audioRobustness.length > 0) ? protData.audioRobustness : robustnessLevel;
311314
const videoRobustness = (protData && protData.videoRobustness && protData.videoRobustness.length > 0) ? protData.videoRobustness : robustnessLevel;
312315
const ksSessionType = keySystemData.sessionType;
@@ -681,7 +684,7 @@ function ProtectionController(config) {
681684
// Dispatch event to applications indicating we received a key message
682685
const keyMessage = e.data;
683686
eventBus.trigger(events.KEY_MESSAGE, { data: keyMessage });
684-
const messageType = (keyMessage.messageType) ? keyMessage.messageType : ProtectionConstants.MEDIA_KEY_MESSAGE_TYPES.LICENSE_REQUEST;
687+
const messageType = (keyMessage.messageType) ? keyMessage.messageType : MEDIA_KEY_MESSAGE_TYPES.LICENSE_REQUEST;
685688
const message = keyMessage.message;
686689
const sessionToken = keyMessage.sessionToken;
687690
const protData = _getProtDataForKeySystem(selectedKeySystem);
@@ -735,7 +738,7 @@ function ProtectionController(config) {
735738
*/
736739
function _issueLicenseRequest(keyMessage, licenseServerData, protData) {
737740
const sessionToken = keyMessage.sessionToken;
738-
const messageType = (keyMessage.messageType) ? keyMessage.messageType : ProtectionConstants.MEDIA_KEY_MESSAGE_TYPES.LICENSE_REQUEST;
741+
const messageType = (keyMessage.messageType) ? keyMessage.messageType : MEDIA_KEY_MESSAGE_TYPES.LICENSE_REQUEST;
739742
const eventData = { sessionToken: sessionToken, messageType: messageType };
740743
const keySystemString = selectedKeySystem ? selectedKeySystem.systemString : null;
741744

@@ -1073,7 +1076,7 @@ function ProtectionController(config) {
10731076
logger.debug('DRM: onNeedKey');
10741077

10751078
// Ignore non-cenc initData
1076-
if (event.key.initDataType !== ProtectionConstants.INITIALIZATION_DATA_TYPE_CENC) {
1079+
if (event.key.initDataType !== INITIALIZATION_DATA_TYPE.CENC) {
10771080
logger.warn('DRM: Only \'cenc\' initData is supported! Ignoring initData of type: ' + event.key.initDataType);
10781081
return;
10791082
}
@@ -1150,7 +1153,7 @@ function ProtectionController(config) {
11501153
const isEdgeBrowser = ua && ua.browser && ua.browser.name && ua.browser.name.toLowerCase() === 'edge';
11511154
parsedKeyStatuses.forEach((keyStatus) => {
11521155
if (isEdgeBrowser
1153-
&& selectedKeySystem.uuid === ProtectionConstants.PLAYREADY_UUID
1156+
&& selectedKeySystem.uuid === PLAYREADY_UUID
11541157
&& keyStatus.keyId && keyStatus.keyId.byteLength === 16) {
11551158
_handlePlayreadyKeyId(keyStatus.keyId);
11561159
}
@@ -1185,7 +1188,7 @@ function ProtectionController(config) {
11851188

11861189
return [...normalizedKeyIds].some((normalizedKeyId) => {
11871190
const keyStatus = keyStatusMap.get(normalizedKeyId);
1188-
return keyStatus && keyStatus !== ProtectionConstants.MEDIA_KEY_STATUSES.INTERNAL_ERROR && keyStatus !== ProtectionConstants.MEDIA_KEY_STATUSES.OUTPUT_RESTRICTED;
1191+
return keyStatus && keyStatus !== MEDIA_KEY_STATUSES.INTERNAL_ERROR && keyStatus !== MEDIA_KEY_STATUSES.OUTPUT_RESTRICTED;
11891192
});
11901193
} catch (error) {
11911194
logger.error(error);
@@ -1201,7 +1204,7 @@ function ProtectionController(config) {
12011204

12021205
return [...normalizedKeyIds].every((normalizedKeyId) => {
12031206
const keyStatus = keyStatusMap.get(normalizedKeyId);
1204-
return keyStatus === ProtectionConstants.MEDIA_KEY_STATUSES.EXPIRED;
1207+
return keyStatus === MEDIA_KEY_STATUSES.EXPIRED;
12051208
})
12061209
} catch (error) {
12071210
logger.error(error);

0 commit comments

Comments
 (0)