Skip to content

Commit

Permalink
fix(drm): enums and certificate (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Ziv authored Aug 24, 2017
1 parent 1d71b03 commit 083cbfa
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 51 deletions.
55 changes: 31 additions & 24 deletions dist/ovpProvider.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ovpProvider.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions flow-typed/types/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ declare type MediaType = { value: number };
declare type MediaEntryType = string;
declare type UIConfType = number;
declare type UIConfCreationMode = number;
declare type Scheme = string;
12 changes: 9 additions & 3 deletions src/entities/drm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//@flow

import {Scheme} from '../k-provider/enums';

/**
* Drm data
* @classdesc
Expand All @@ -19,13 +17,21 @@ export default class Drm {
*/
scheme: Scheme;

/**
* @member - The drm certificate
* @type {?string}
*/
certificate: ?string;

/**
* @constructor
* @param {string} licenseUrl - the license URL
* @param {Scheme} scheme - the drm scheme
* @param {?string} certificate - the drm certificate
*/
constructor(licenseUrl: string, scheme: Scheme) {
constructor(licenseUrl: string, scheme: Scheme, certificate: ?string) {
this.licenseUrl = licenseUrl;
this.scheme = scheme;
this.certificate = certificate;
}
}
12 changes: 5 additions & 7 deletions src/k-provider/enums.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
//@flow
export class Scheme {
static PLAYREADY_CENC: string = "drm.PLAYREADY_CENC";
static WIDEVINE_CENC: string = "drm.WIDEVINE_CENC";
static FAIRPLAY: string = "fairplay.FAIRPLAY";
static PLAYREADY: string = "playReady.PLAYREADY";
static WIDEVINE: string = "widevine.WIDEVINE";
}
export const DrmScheme = {
'drm.PLAYREADY_CENC': 'com.microsoft.playready',
'drm.WIDEVINE_CENC': 'com.widevine.alpha',
'fairplay.FAIRPLAY': 'com.apple.fairplay'
};

export class KalturaRuleActionTypes {
static DRM_POLICY: KalturaRuleActionType = "drm.DRM_POLICY";
Expand Down
10 changes: 5 additions & 5 deletions src/k-provider/ovp/provider-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import KalturaFlavorAsset from './response-types/kaltura-flavor-asset'
import KalturaMetadataListResponse from './response-types/kaltura-metadata-list-response'
import PlaySourceUrlBuilder from "./play-source-url-builder"
import XmlParser from '../xml-parser'
import {MediaEntryTypes, EntryTypes, MediaTypes} from '../enums'
import {MediaEntryTypes, EntryTypes, MediaTypes, DrmScheme} from '../enums'
import Logger from '../../util/logger'
import Configuration from './config'
import {MediaFormats} from '../../entities/media-format'
Expand Down Expand Up @@ -107,7 +107,7 @@ export default class ProviderParser {
static _getParsedSources(kalturaSources: Array<KalturaPlaybackSource>, ks: string, partnerID: number, uiConfId: number, entry: Object, playbackContext: Object): MediaSources {
let sources: MediaSources = new MediaSources();

let addAdaptiveSource = function(source: KalturaPlaybackSource): void{
let addAdaptiveSource = function (source: KalturaPlaybackSource): void {
let parsedSource = ProviderParser._parseAdaptiveSource(source, playbackContext.flavorAssets, ks, partnerID, uiConfId, entry.id);
let sourceFormat = SUPPORTED_FORMATS.get(source.format);
sources.map(parsedSource, sourceFormat);
Expand All @@ -117,7 +117,7 @@ export default class ProviderParser {
kalturaSources.filter((source) => !ProviderParser._isProgressiveSource(source)).forEach(addAdaptiveSource);
};

let parseProgressiveSources = function (): void{
let parseProgressiveSources = function (): void {
let progressiveSource = kalturaSources.find(ProviderParser._isProgressiveSource);
sources.progressive = ProviderParser._parseProgressiveSources(progressiveSource, playbackContext.flavorAssets, ks, partnerID, uiConfId, entry.id);
};
Expand Down Expand Up @@ -177,7 +177,7 @@ export default class ProviderParser {
playUrl = kalturaSource.url;
}

if (playUrl == "") {
if (playUrl === "") {
logger.error(`failed to create play url from source, discarding source: (${entryId}_${kalturaSource.deliveryProfileId}), ${kalturaSource.format}.`);
return mediaSource;
}
Expand All @@ -187,7 +187,7 @@ export default class ProviderParser {
if (kalturaSource.hasDrmData()) {
let drmParams: Array<Drm> = [];
kalturaSource.drm.forEach((drm) => {
drmParams.push(new Drm(drm.licenseURL, drm.scheme));
drmParams.push(new Drm(drm.licenseURL, DrmScheme[drm.scheme], drm.certificate));
});
mediaSource.drmData = drmParams;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@flow
import {Scheme} from '../../enums'

/**
* Ovp BE DrmPlaybackPluginData
Expand All @@ -18,13 +17,20 @@ export default class KalturaDrmPlaybackPluginData {
*/
licenseURL: string;

/**
* @member - The drm certificate
* @type {?string}
*/
certificate: ?string;

/**
* @constructor
* @param {Object} drm The json response
*/
constructor(drm: any) {
this.scheme = drm.scheme;
this.licenseURL = drm.licenseURL;
this.certificate = drm.certificate;
}
}

Expand Down
6 changes: 3 additions & 3 deletions test/src/k-provider/ovp/be-stubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ let AnonymousMocEntryWithoutUIConfWithDrmData = [
"url": "https://cdnapisec.kaltura.com/p/1068292/sp/1068292/playManifest/entryId/1_rwbj3j0a/flavorIds/1_92dfyrz5,1_9dhh6m0i,1_zudouuah,1_r0wu6y77,1_oz343kla/deliveryProfileId/11311/protocol/https/format/applehttp/a.m3u8",
"drm": [
{
"certificate": "MIIE8DCCA9igAwIBAgIIWErELxCBDA4wDQYJKoZIhvcNAQEFBQAwfzELMAkGA1UEBhMCVVMxEzARBgNVBAoMCkFwcGxlIEluYy4xJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MTMwMQYDVQQDDCpBcHBsZSBLZXkgU2VydmljZXMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTYxMTIzMDA0NDQyWhcNMTgxMTI0MDA0NDQyWjB0MQswCQYDVQQGEwJVUzEdMBsGA1UECgwUU3RhcndhdmUgQ29ycG9yYXRpb24xEzARBgNVBAsMCldLM1lFUlZK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ykriSnF3zO2aNY43AQsTzIpGvQ9kSJVBdTO7u/UevlbRcHDHrSoQ/8fKSVKvx9Be1pIRgznBRqS+iV6V0572rZOuR0ZQf0nY5vtEHBN6kTZyhPYFuTE32f77E/dtv6XnZ6qB1OKtv483mjVLqQrI0IOl3LyMKgAJ51whloEJEJC6g8frCmwmTLsmmOR17wq24/6YKjGNM2NuSa7/7RqwdEKuqDzzVyh3Zafmtn8rlIptACGPYWnmAP2gnCzBO/V6AIQDf0JcZUpOb+GfhQ7M7ik=",
"certificate": "ABCD1234",
"scheme": "fairplay.FAIRPLAY",
"licenseURL": "https://udrmv3.kaltura.com//fps/license?custom_data=eyJjYV9zeXN0ZW0iOiJPVlAiLCJ1c2VyX3Rva2VuIjoiTlRBd1pqVmlaV1pqWTJOak5UUmtOR0V5TWpVMU1UZzRPR0UxTm1Vd05EbGpaV0prTXprMU1Yd3hNRFk0TWpreU96RXdOamd5T1RJN01UUTVNREUzTmpFME5qc3dPekUwT1RBd09EazNORFl1TURJeU5qc3dPM1pwWlhjNktpeDNhV1JuWlhRNk1UczciLCJhY2NvdW50X2lkIjoxMDY4MjkyLCJjb250ZW50X2lkIjoiMV9yd2JqM2owYSIsImZpbGVzIjoiMV85MmRmeXJ6NSwxXzlkaGg2bTBpLDFfenVkb3V1YWgsMV9yMHd1Nnk3NywxX296MzQza2xhIn0%3D&signature=jl09zYv64OyEfVUt85rlA0WnK1w%3D",
"objectType": "KalturaFairPlayPlaybackPluginData"
Expand Down Expand Up @@ -910,7 +910,7 @@ let EntryWithUIConfWithDrmData = [
"url": "https://cdnapisec.kaltura.com/p/1068292/sp/1068292/playManifest/entryId/1_rwbj3j0a/flavorIds/1_92dfyrz5,1_9dhh6m0i,1_zudouuah,1_r0wu6y77,1_oz343kla/deliveryProfileId/11311/protocol/https/format/applehttp/a.m3u8",
"drm": [
{
"certificate": "MIIE8DCCA9igAwIBAgIIWErELxCBDA4wDQYJKoZIhvcNAQEFBQAwfzELMAkGA1UEBhMCVVM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MA4GA1UdDwEB/wQEAwIFIDBGBgsqhkiG92NkBg0BAwEB/wQ0AXdxb2EwczF5bWZ4cG5vN2gwcnh0bXp4amJzb2psa3BndTh5eWRsa3d1Y3NxZXltcWZvNTA1BgsqhkiG92NkBg0BBAEB/wQjAW5kam03a3hsamFiandvaXU3NGRmeG1zdXkybHlsMmhhdGIwDQYJKoZIhvcNAQEFBQADggEBAC2i5fDiQClCkp9mIyWBW+ZyMlUiM3Wr5eui0dUvKwSBTc8pyv4m4f60X7JoN5iZykriSnF3zO2aNY43AQsTzIpGvQ9kSJVBdTO7u/UevlbRcHDHrSoQ/8fKSVKvx9Be1pIRgznBRqS+iV6V0572rZOuR0ZQf0nY5vtEHBN6kTZyhPYFuTE32f77E/dtv6XnZ6qB1OKtv483mjVLqQrI0IOl3LyMKgAJ51whloEJEJC6g8frCmwmTLsmmOR17wq24/6YKjGNM2NuSa7/7RqwdEKuqDzzVyh3Zafmtn8rlIptACGPYWnmAP2gnCzBO/V6AIQDf0JcZUpOb+GfhQ7M7ik=",
"certificate": "ABCD1234",
"scheme": "fairplay.FAIRPLAY",
"licenseURL": "https://udrmv3.kaltura.com//fps/license?custom_data=eyJjYV9zeXN0ZW0iOiJPVlAiLCJ1c2VyX3Rva2VuIjoiWlRGaU56azRNbU01TWpKaVl6a3dPRGxpTXpRelpUUTNZMkk0TXpJd1lUSXpNbVF6TVRNeFlud3hNRFk0TWpreU96RXdOamd5T1RJN01UUTVNREkxTWprNU1qc3dPekUwT1RBeE5qWTFPVEl1T0RVeU1Uc3dPM1pwWlhjNktpeDNhV1JuWlhRNk1UczciLCJhY2NvdW50X2lkIjoxMDY4MjkyLCJjb250ZW50X2lkIjoiMV9yd2JqM2owYSIsImZpbGVzIjoiMV85MmRmeXJ6NSwxXzlkaGg2bTBpLDFfenVkb3V1YWgsMV9yMHd1Nnk3NywxX296MzQza2xhIn0%3D&signature=AZaaKvEx5j8CAh6VMSZbGzmUK1A%3D",
"objectType": "KalturaFairPlayPlaybackPluginData"
Expand Down Expand Up @@ -1149,7 +1149,7 @@ let WrongUiConfID = [
"url": "https://cdnapisec.kaltura.com/p/1068292/sp/1068292/playManifest/entryId/1_rwbj3j0a/flavorIds/1_92dfyrz5,1_9dhh6m0i,1_zudouuah,1_r0wu6y77,1_oz343kla/deliveryProfileId/11311/protocol/https/format/applehttp/a.m3u8",
"drm": [
{
"certificate": "MIIE8DCCA9igAwIBAgIIWErELxCBDA4wDQYJKoZIhvcNAQEFBQAwfzELMAkGA1UEBhMCVVMxEzARBgNVBAoMCkFwcGxlIEluYy4xJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MTMwMQYDVQQDDCpBcHBsZSBLZXkgU2VydmljZXMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTYxMTIzMDA0NDQyWhcNMTgxMTI0MDA0NDQyWjB0MQswCQYDVQQGEwJVUzEdMBsGA1UECgwUU3RhcndhdmUgQ29ycG9yYXRpb24xEzARBgNVBAsMCldLM1lFUlZKV0ExMTAvBgNVBAMMKEZhaXJQbGF5IFN0cmVhbWluZzogU3RhcndhdmUgQ29ycG9yYXRpb24wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKDqSYs/fp9+BOvrgvnwy0p9WQt7ZUrPV4/RfWjcwU3ndYSR6LtNEWlRjHU18OF8HsU678nMqsxRAFwv12Hdew4WoZ7AEdPTX2tOZkvHqgQczo0TKdtuKF3+SYPWiE2u3epFuTAldCkc5stXOwtPnutHsUm+SxWc+DPhMBO1ryBlAgMBAAGjggH9MIIB+TAdBgNVHQ4EFgQUDCgFiGFqGqz0LuWC9mVG3Zktm5IwDAYDVR0TAQH/BAIwADAfBgNVHSMEGDAWgBRj5EdUy4VxWUYsg6zMRDFkZwMsvjCB4gYDVR0gBIHaMIHXMIHUBgkqhkiG92NkBQEwgcYwgcMGCCsGAQUFBwICMIG2DIGzUmVsaWFuY2Ugb24gdGhpcyBjZXJ0aWZpY2F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d01Ec3dPekUwT1RBeE5qZzBNREF1TVRBMk16c3dPM1pwWlhjNktpeDNhV1JuWlhRNk1UczciLCJhY2NvdW50X2lkIjoxMDY4MjkyLCJjb250ZW50X2lkIjoiMV9yd2JqM2owYSIsImZpbGVzIjoiMV85MmRmeXJ6NSwxXzlkaGg2bTBpLDFfenVkb3V1YWgsMV9yMHd1Nnk3NywxX296MzQza2xhIn0%3D&signature=RW0rJqR9HuXDUlN8gqmDF08PMLE%3D",
"objectType": "KalturaFairPlayPlaybackPluginData"
Expand Down
Loading

0 comments on commit 083cbfa

Please sign in to comment.