Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate CMCD data into outgoing requests. #4346

Merged
merged 36 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
66e72bf
Integrate CMCD data into outgoing requests.
littlespex Oct 5, 2021
c0199a0
Fix sanity test errors
littlespex Oct 6, 2021
e7db2b2
no message
littlespex Oct 6, 2021
57b5b62
no message
littlespex Oct 6, 2021
8abb3eb
Improve buffer length calculation
littlespex Oct 6, 2021
46cc8e7
- Fix for init object type bug
littlespex Oct 8, 2021
4710b36
Merge branch 'master' into feature/cmcd
littlespex Oct 20, 2021
4d49ecd
Add support for separate buffer and top bandwidth values for audio an…
littlespex Nov 3, 2021
7645f9f
Merge branch 'master' into feature/cmcd
littlespex Nov 3, 2021
1b68962
Use loader composition instead of context transformation
littlespex Nov 3, 2021
6366aad
no message
littlespex Nov 4, 2021
43cb813
no message
littlespex Nov 4, 2021
629011d
Only override loaders and add listereners if cmcd is enabled
littlespex Nov 4, 2021
09dad6a
Merge pull request #2 from cbsinteractive/feature/cmcd-loaders
littlespex Nov 4, 2021
60a92d4
Add context header processing to fetch-loader
littlespex Nov 5, 2021
2848b5c
Convert CMCD to a plugin
littlespex Nov 5, 2021
1423ee7
Merge branch 'master' into feature/cmcd
littlespex Nov 5, 2021
2a305de
Merge branch 'master' into feature/cmcd
littlespex Nov 6, 2021
9e9b120
Fix issue with quotes not being escaped
littlespex Nov 6, 2021
3292a73
Fix doc data type
littlespex Nov 7, 2021
07e0af2
Remove unneeded JSDoc annotations
littlespex Nov 7, 2021
932c58a
Add proper data types for buffer properites
littlespex Nov 7, 2021
d15a0e6
Add backslash escape
littlespex Nov 7, 2021
99dcc24
Use inline class to overload loaders
littlespex Nov 7, 2021
7d6ee68
Move token processing to its own block
littlespex Nov 8, 2021
87df218
Optimize multiple references to this
littlespex Nov 8, 2021
475211f
no message
littlespex Nov 8, 2021
640fe43
Remove unused argument in apply function
littlespex Nov 8, 2021
6cc8799
no message
littlespex Nov 8, 2021
54581b1
Merge branch 'feature/cmcd-config-object' of https://github.com/cbsin…
littlespex Nov 8, 2021
933cf1c
Update cmcd API docs
littlespex Nov 8, 2021
2f9b6b6
Merge pull request #3 from cbsinteractive/feature/cmcd-config-object
littlespex Nov 8, 2021
c8a4dc2
- Remove tokenized custom field code
littlespex Nov 8, 2021
2aa5d55
Merge pull request #4 from cbsinteractive/feature/cmcd-config-object
littlespex Nov 9, 2021
dd94557
Merge branch 'master' into feature/cmcd
littlespex Nov 9, 2021
3dc8057
Update README
littlespex Nov 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ Generated\ Files/
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# VSCode custom workspace settings
.vscode/settings.json
44 changes: 27 additions & 17 deletions api-extractor/report/hls.js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class BaseSegment {
// (undocumented)
get url(): string;
set url(value: string);
}
}

// Warning: (ae-missing-release-tag) "BufferAppendedData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
Expand Down Expand Up @@ -251,6 +251,16 @@ export class ChunkMetadata {
readonly transmuxing: HlsChunkPerformanceTiming;
}

// Warning: (ae-missing-release-tag) "CMCDControllerConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type CMCDControllerConfig = {
cmcdEnabled: boolean;
cmcdSessionId?: string;
cmcdContentId?: string;
cmcdUseHeaders?: boolean;
};

// Warning: (ae-missing-release-tag) "CuesInterface" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
Expand Down Expand Up @@ -839,7 +849,7 @@ class Hls implements HlsEventEmitter {
// (undocumented)
readonly config: HlsConfig;
// (undocumented)
createController(ControllerClass: any, fragmentTracker: any, components: any): any;
createController(ControllerClass: any, fragmentTracker: any, components: any, loaderContextSetup?: any): any;
littlespex marked this conversation as resolved.
Show resolved Hide resolved
get currentLevel(): number;
// Warning: (ae-setter-with-docs) The doc comment for the property "currentLevel" must appear on the getter, not the setter.
set currentLevel(newLevel: number);
Expand Down Expand Up @@ -925,7 +935,6 @@ class Hls implements HlsEventEmitter {
// (undocumented)
static get version(): string;
}

export default Hls;

// Warning: (ae-missing-release-tag) "HlsChunkPerformanceTiming" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
Expand Down Expand Up @@ -963,7 +972,7 @@ export type HlsConfig = {
fpsController: typeof FPSController;
progressive: boolean;
lowLatencyMode: boolean;
} & ABRControllerConfig & BufferControllerConfig & CapLevelControllerConfig & EMEControllerConfig & FPSControllerConfig & FragmentLoaderConfig & LevelControllerConfig & MP4RemuxerConfig & PlaylistLoaderConfig & StreamControllerConfig & LatencyControllerConfig & TimelineControllerConfig & TSDemuxerConfig;
} & ABRControllerConfig & BufferControllerConfig & CapLevelControllerConfig & CMCDControllerConfig & EMEControllerConfig & FPSControllerConfig & FragmentLoaderConfig & LevelControllerConfig & MP4RemuxerConfig & PlaylistLoaderConfig & StreamControllerConfig & LatencyControllerConfig & TimelineControllerConfig & TSDemuxerConfig;

// Warning: (ae-missing-release-tag) "HlsEventEmitter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
Expand Down Expand Up @@ -1426,7 +1435,7 @@ export class LevelKey {
method: string | null;
// (undocumented)
get uri(): string | null;
}
}

// Warning: (ae-missing-release-tag) "LevelLoadedData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
Expand Down Expand Up @@ -1605,6 +1614,8 @@ export interface LoaderConfiguration {
//
// @public (undocumented)
export interface LoaderContext {
// (undocumented)
headers?: Record<string, string>;
// (undocumented)
progressData?: boolean;
// (undocumented)
Expand Down Expand Up @@ -2124,20 +2135,19 @@ export interface UserdataSample {
pts: number;
}


// Warnings were encountered during analysis:
//
// src/config.ts:148:3 - (ae-forgotten-export) The symbol "ILogger" needs to be exported by the entry point hls.d.ts
// src/config.ts:157:3 - (ae-forgotten-export) The symbol "AudioStreamController" needs to be exported by the entry point hls.d.ts
// src/config.ts:158:3 - (ae-forgotten-export) The symbol "AudioTrackController" needs to be exported by the entry point hls.d.ts
// src/config.ts:160:3 - (ae-forgotten-export) The symbol "SubtitleStreamController" needs to be exported by the entry point hls.d.ts
// src/config.ts:161:3 - (ae-forgotten-export) The symbol "SubtitleTrackController" needs to be exported by the entry point hls.d.ts
// src/config.ts:162:3 - (ae-forgotten-export) The symbol "TimelineController" needs to be exported by the entry point hls.d.ts
// src/config.ts:164:3 - (ae-forgotten-export) The symbol "EMEController" needs to be exported by the entry point hls.d.ts
// src/config.ts:166:3 - (ae-forgotten-export) The symbol "AbrController" needs to be exported by the entry point hls.d.ts
// src/config.ts:167:3 - (ae-forgotten-export) The symbol "BufferController" needs to be exported by the entry point hls.d.ts
// src/config.ts:168:3 - (ae-forgotten-export) The symbol "CapLevelController" needs to be exported by the entry point hls.d.ts
// src/config.ts:169:3 - (ae-forgotten-export) The symbol "FPSController" needs to be exported by the entry point hls.d.ts
// src/config.ts:155:3 - (ae-forgotten-export) The symbol "ILogger" needs to be exported by the entry point hls.d.ts
// src/config.ts:164:3 - (ae-forgotten-export) The symbol "AudioStreamController" needs to be exported by the entry point hls.d.ts
// src/config.ts:165:3 - (ae-forgotten-export) The symbol "AudioTrackController" needs to be exported by the entry point hls.d.ts
// src/config.ts:167:3 - (ae-forgotten-export) The symbol "SubtitleStreamController" needs to be exported by the entry point hls.d.ts
// src/config.ts:168:3 - (ae-forgotten-export) The symbol "SubtitleTrackController" needs to be exported by the entry point hls.d.ts
// src/config.ts:169:3 - (ae-forgotten-export) The symbol "TimelineController" needs to be exported by the entry point hls.d.ts
// src/config.ts:171:3 - (ae-forgotten-export) The symbol "EMEController" needs to be exported by the entry point hls.d.ts
// src/config.ts:173:3 - (ae-forgotten-export) The symbol "AbrController" needs to be exported by the entry point hls.d.ts
// src/config.ts:174:3 - (ae-forgotten-export) The symbol "BufferController" needs to be exported by the entry point hls.d.ts
// src/config.ts:175:3 - (ae-forgotten-export) The symbol "CapLevelController" needs to be exported by the entry point hls.d.ts
// src/config.ts:176:3 - (ae-forgotten-export) The symbol "FPSController" needs to be exported by the entry point hls.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
2 changes: 1 addition & 1 deletion demo/basic-usage.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1>Hls.js demo - basic usage</h1>
});
}
// hls.js is not supported on platforms that do not have Media Source Extensions (MSE) enabled.
// When the browser has built-in HLS support (check using `canPlayType`), we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video element throught the `src` property.
// When the browser has built-in HLS support (check using `canPlayType`), we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video element through the `src` property.
// This is using the built-in support of the plain video element, without using hls.js.
else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8';
Expand Down
25 changes: 25 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
- [`licenseResponseCallback`](#licenseResponseCallback)
- [`drmSystemOptions`](#drmSystemOptions)
- [`requestMediaKeySystemAccessFunc`](#requestMediaKeySystemAccessFunc)
- [`cmcdEnabled`](#cmcdEnabled)
- [`cmcdSessionId`](#cmcdSessionId)
- [`cmcdContentId`](#cmcdContentId)
- [`cmcdUseHeaders`](#cmcdUseHeaders)
- [Video Binding/Unbinding API](#video-bindingunbinding-api)
- [`hls.attachMedia(videoElement)`](#hlsattachmediavideoelement)
- [`hls.detachMedia()`](#hlsdetachmedia)
Expand Down Expand Up @@ -391,6 +395,10 @@ var config = {
licenseXhrSetup: undefined,
drmSystemOptions: {},
requestMediaKeySystemAccessFunc: requestMediaKeySystemAccess,
cmcdEnabled: false,
cmcdSessionId: undefined,
cmcdContentId: undefined,
cmcdUseHeaders: false,
};

var hls = new Hls(config);
Expand Down Expand Up @@ -1192,6 +1200,23 @@ With the default argument, `''` will be specified for each option (_i.e. no spec

Allows for the customization of `window.navigator.requestMediaKeySystemAccess`.

### `cmcdEnabled`

Enabled the passing of [Common Media Client Data (CMCD)](https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf)
on all media requests (manifests, playlists, a/v segments, timed text).

### `cmcdSession`

The CMCD session id. One will be automatically generated if none is provided.

### `cmcdContent`

The CMCD content id.

### `cmcdUseHeaders`

Send CMCD data in request headers instead of as query args.

## Video Binding/Unbinding API

### `hls.attachMedia(videoElement)`
Expand Down
12 changes: 12 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ export type CapLevelControllerConfig = {
capLevelToPlayerSize: boolean;
};

export type CMCDControllerConfig = {
cmcdEnabled: boolean;
cmcdSessionId?: string;
cmcdContentId?: string;
cmcdUseHeaders?: boolean;
};

export type DRMSystemOptions = {
audioRobustness?: string;
videoRobustness?: string;
Expand Down Expand Up @@ -172,6 +179,7 @@ export type HlsConfig = {
} & ABRControllerConfig &
BufferControllerConfig &
CapLevelControllerConfig &
CMCDControllerConfig &
littlespex marked this conversation as resolved.
Show resolved Hide resolved
EMEControllerConfig &
FPSControllerConfig &
FragmentLoaderConfig &
Expand Down Expand Up @@ -261,6 +269,10 @@ export const hlsDefaultConfig: HlsConfig = {
testBandwidth: true,
progressive: false,
lowLatencyMode: true,
cmcdEnabled: false,
cmcdSessionId: undefined,
cmcdContentId: undefined,
cmcdUseHeaders: false,

// Dynamic Modules
...timelineConfig(),
Expand Down
10 changes: 7 additions & 3 deletions src/controller/audio-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Events } from '../events';
import { BufferHelper } from '../utils/buffer-helper';
import { FragmentState } from './fragment-tracker';
import { Level } from '../types/level';
import { PlaylistLevelType } from '../types/loader';
import { FragmentLoaderContextSetup, PlaylistLevelType } from '../types/loader';
import { Fragment, ElementaryStreamTypes, Part } from '../loader/fragment';
import ChunkCache from '../demux/chunk-cache';
import TransmuxerInterface from '../demux/transmuxer-interface';
Expand Down Expand Up @@ -56,8 +56,12 @@ class AudioStreamController
private mainDetails: LevelDetails | null = null;
private bufferFlushed: boolean = false;

constructor(hls: Hls, fragmentTracker: FragmentTracker) {
super(hls, fragmentTracker, '[audio-stream-controller]');
constructor(
hls: Hls,
fragmentTracker: FragmentTracker,
contextSetup: FragmentLoaderContextSetup
) {
super(hls, fragmentTracker, contextSetup, '[audio-stream-controller]');
this._registerListeners();
}

Expand Down
13 changes: 10 additions & 3 deletions src/controller/base-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
} from '../types/events';
import Decrypter from '../crypt/decrypter';
import TimeRanges from '../utils/time-ranges';
import { PlaylistLevelType } from '../types/loader';
import { FragmentLoaderContextSetup, PlaylistLevelType } from '../types/loader';
import type { FragmentTracker } from './fragment-tracker';
import type { Level } from '../types/level';
import type { RemuxedTrack } from '../types/remuxer';
Expand Down Expand Up @@ -93,18 +93,25 @@ export default class BaseStreamController
protected initPTS: Array<number> = [];
protected onvseeking: EventListener | null = null;
protected onvended: EventListener | null = null;
protected contextSetup: FragmentLoaderContextSetup;

private readonly logPrefix: string = '';
protected log: (msg: any) => void;
protected warn: (msg: any) => void;

constructor(hls: Hls, fragmentTracker: FragmentTracker, logPrefix: string) {
constructor(
hls: Hls,
fragmentTracker: FragmentTracker,
contextSetup: FragmentLoaderContextSetup,
logPrefix: string
) {
super();
this.logPrefix = logPrefix;
this.log = logger.log.bind(logger, `${logPrefix}:`);
this.warn = logger.warn.bind(logger, `${logPrefix}:`);
this.hls = hls;
this.fragmentLoader = new FragmentLoader(hls.config);
this.contextSetup = contextSetup;
this.fragmentLoader = new FragmentLoader(hls.config, contextSetup);
this.fragmentTracker = fragmentTracker;
this.config = hls.config;
this.decrypter = new Decrypter(hls as HlsEventEmitter, hls.config);
Expand Down
Loading