Skip to content

Commit

Permalink
Merge branch 'main' of github.com:videojs/http-streaming into fix-hls…
Browse files Browse the repository at this point in the history
…-load-after-media-change
  • Loading branch information
Dzianis Dashkevich committed Nov 27, 2023
2 parents 234bf06 + 9f2a4de commit a713008
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 2 deletions.
47 changes: 47 additions & 0 deletions docs/content-steering.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Content Steering

Content Steering provides content creators a method of runtime control over
the location from which segments are fetched via a content steering server and
pathways defined in the content manifest. For a working example visit
https://www.content-steering.com/.

HLS and DASH each define their own specific Content Steering tags and properties
that prescribe how the client should fetch the content steering manifest as well
as make steering decisions. `#EXT-X-CONTENT-STEERING` and `<ContentSteering>` respectively.

For reference, HLS spec section 4.4.6.6:
https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis#section-4.4.6.6

DASH-IF:
https://dashif.org/docs/DASH-IF-CTS-00XX-Content-Steering-Community-Review.pdf

Both protocols rely on a content steering server to provide steering guidance.
VHS will request the content steering manifest from the location defined in the
content steering tag in the `.m3u8` or `.mpd` and refresh the steering manifest
at an interval defined in that manifest.

A content steering manifest response will look something like this:
```
{
"VERSION": 1,
"TTL": 300,
"RELOAD-URI": "https://steeringservice.com/app/instance12345?session=abc",
"CDN-PRIORITY": ["beta","alpha"]
}
```
`CDN-PRIORITY` represents either `PATHWAY-PRIORITY` for HLS or `SERVICE-LOCATION-PRIORITY` for DASH. This list of keys in priority order will match with either a `PATHWAY-ID` or `serviceLocation` (HLS and DASH respectively) associated with a location where VHS can fetch segments.

VHS will attempt to fetch segments from the locations defined in the steering manifest response in the order. Then, during playback, VHS will provide quality of experience metrics back to the steering server which can adjust the steering guidance accordingly.

## Notable Support

### HLS
* Pathway Cloning
### DASH
* queryBeforeStart
* proxyServerURL

## Currently Missing Support

### DASH
* Extended HTTP GET request parametrization, see: ISO/IEC 23009-1 [2], clause I.3
1 change: 1 addition & 0 deletions docs/supported-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ not meant serve as an exhaustive list.
tracks
* [AES-128] segment encryption
* DASH In-manifest EventStream and Event tags are automatically translated into HTML5 metadata cues
* [Content Steering](content-steering.md) for both HLS and DASH.

## Notable Missing Features

Expand Down
2 changes: 1 addition & 1 deletion src/util/text-tracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export const addMetadata = ({
// Map each cue group's endTime to the next group's startTime
sortedStartTimes.forEach((startTime, idx) => {
const cueGroup = cuesGroupedByStartTime[startTime];
const finiteDuration = isFinite(videoDuration) ? videoDuration : 0;
const finiteDuration = isFinite(videoDuration) ? videoDuration : startTime;
const nextTime = Number(sortedStartTimes[idx + 1]) || finiteDuration;

// Map each cue's endTime the next group's startTime
Expand Down
14 changes: 13 additions & 1 deletion src/videojs-http-streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,15 @@ class VhsHandler extends Component {
this.on(this.tech_, 'play', this.play);
}

setOptions_() {
/**
* Set VHS options based on options from configuration, as well as partial
* options to be passed at a later time.
*
* @param {Object} options A partial chunk of config options
*/
setOptions_(options = {}) {
this.options_ = merge(this.options_, options);

// defaults
this.options_.withCredentials = this.options_.withCredentials || false;
this.options_.limitRenditionByPlayerDimensions = this.options_.limitRenditionByPlayerDimensions === false ? false : true;
Expand Down Expand Up @@ -756,6 +764,10 @@ class VhsHandler extends Component {
this.limitRenditionByPlayerDimensions = this.options_.limitRenditionByPlayerDimensions;
this.useDevicePixelRatio = this.options_.useDevicePixelRatio;
}
// alias for public method to set options
setOptions(options = {}) {
this.setOptions_(options);
}
/**
* called when player.src gets called, handle a new source
*
Expand Down
23 changes: 23 additions & 0 deletions test/videojs-http-streaming.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,29 @@ QUnit.test('VhsHandler is referenced by player.tech().vhs', function(assert) {
);
});

QUnit.test.only('options are updated when setOptions is called', function(assert) {
this.player.src({
src: 'manifest/playlist.m3u8',
type: 'application/vnd.apple.mpegurl'
});
this.clock.tick(1);

const vhs = this.player.tech().vhs;

assert.equal(this.env.log.warn.calls, 1, 'warning logged');
assert.equal(
this.env.log.warn.args[0][0],
'Using the tech directly can be dangerous. I hope you know what you\'re doing.\n' +
'See https://github.com/videojs/video.js/issues/2617 for more info.\n',
'logged warning'
);
assert.equal(vhs.options_.withCredentials, false);

vhs.setOptions({ withCredentials: true });

assert.equal(vhs.options_.withCredentials, true, 'options are updated');
});

QUnit.test('starts playing if autoplay is specified', function(assert) {
this.player.autoplay(true);
this.player.src({
Expand Down

0 comments on commit a713008

Please sign in to comment.