Skip to content

Commit

Permalink
add ability to specify cmcd keys
Browse files Browse the repository at this point in the history
  • Loading branch information
littlespex committed Oct 23, 2023
1 parent c1c9303 commit b2d3924
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export type CMCDControllerConfig = {
sessionId?: string;
contentId?: string;
useHeaders?: boolean;
includeKeys?: string[];
};

export type DRMSystemOptions = {
Expand Down
12 changes: 12 additions & 0 deletions src/controller/cmcd-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class CMCDController implements ComponentAPI {
private sid?: string;
private cid?: string;
private useHeaders: boolean = false;
private includeKeys?: string[];
private initialized: boolean = false;
private starved: boolean = false;
private buffering: boolean = true;
Expand All @@ -54,6 +55,7 @@ export default class CMCDController implements ComponentAPI {
this.sid = cmcd.sessionId || uuid();
this.cid = cmcd.contentId;
this.useHeaders = cmcd.useHeaders === true;
this.includeKeys = cmcd.includeKeys;
this.registerListeners();
}
}
Expand Down Expand Up @@ -163,6 +165,16 @@ export default class CMCDController implements ComponentAPI {

// TODO: Implement rtp, nrr, nor, dl

const { includeKeys } = this;
if (includeKeys) {
data = Object.keys(data)
.filter((key) => includeKeys.includes(key))
.reduce((acc, key) => {
acc[key] = data[key];
return acc;
}, {});
}

if (this.useHeaders) {
if (!context.headers) {
context.headers = {};
Expand Down

0 comments on commit b2d3924

Please sign in to comment.