From d18d95c5ce64cae454f2b505832ceff188496440 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Thu, 10 Sep 2020 08:13:43 -0400 Subject: [PATCH 01/17] docs: sample-aes encryption isn't currently supported (#923) --- docs/supported-features.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/supported-features.md b/docs/supported-features.md index b1aac1086..20440c1f5 100644 --- a/docs/supported-features.md +++ b/docs/supported-features.md @@ -63,7 +63,7 @@ not meant serve as an exhaustive list. * Video only (non DRM) * In-manifest [WebVTT] subtitles are automatically translated into standard HTML5 subtitle tracks -* [AES-128] and SAMPLE-AES segment encryption +* [AES-128] segment encryption ## Notable Missing Features @@ -126,6 +126,7 @@ not yet been implemented. VHS currently supports everything in the * Use of AVERAGE-BANDWIDTH in [EXT-X-STREAM-INF] (value parsed but not used) * Use of FRAME-RATE in [EXT-X-STREAM-INF] (value parsed but not used) * Use of HDCP-LEVEL in [EXT-X-STREAM-INF] +* SAMPLE-AES segment encryption In the event of encoding changes within a playlist (see https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-6.3.3), the From 7d6311b983a8a3cca088152e11b4aeeebd497a92 Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Mon, 16 Nov 2020 16:11:44 +0100 Subject: [PATCH 02/17] chore: Added docs --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 8aa7229f2..581b39827 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Video.js Compatibility: 6.0, 7.0 - [customTagMappers](#customtagmappers) - [cacheEncryptionKeys](#cacheencryptionkeys) - [handlePartialData](#handlepartialdata) + - [liveRangeSafeTimeDelta](#liverangesafetimedelta) - [Runtime Properties](#runtime-properties) - [vhs.playlists.master](#vhsplaylistsmaster) - [vhs.playlists.media](#vhsplaylistsmedia) @@ -451,6 +452,11 @@ This option defaults to `false`. * Default: `false` * Use partial appends in the transmuxer and segment loader +##### liveRangeSafeTimeDelta +* Type: `boolean`, +* Default: `false` +* Allow to re-define length (in seconds) of time delta when you compare current time and the end of the buffered range. + ### Runtime Properties Runtime properties are attached to the tech object when HLS is in use. You can get a reference to the VHS source handler like this: From 4537833652df194dbbe271475abdf6d7b7c6c9a0 Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Mon, 16 Nov 2020 16:13:11 +0100 Subject: [PATCH 03/17] Update playback-watcher.js --- src/playback-watcher.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/playback-watcher.js b/src/playback-watcher.js index 6ebb7ed55..21b92a793 100644 --- a/src/playback-watcher.js +++ b/src/playback-watcher.js @@ -75,6 +75,7 @@ export default class PlaybackWatcher { this.tech_ = options.tech; this.seekable = options.seekable; this.allowSeeksWithinUnsafeLiveWindow = options.allowSeeksWithinUnsafeLiveWindow; + this.liveRangeSafeTimeDelta = options.liveRangeSafeTimeDelta; this.media = options.media; this.consecutiveUpdates = 0; @@ -502,7 +503,7 @@ export default class PlaybackWatcher { if (seekable.length && // can't fall before 0 and 0 seekable start identifies VOD stream seekable.start(0) > 0 && - currentTime < seekable.start(0) - Ranges.SAFE_TIME_DELTA) { + currentTime < seekable.start(0) - (this.liveRangeSafeTimeDelta || Ranges.SAFE_TIME_DELTA)) { return true; } From 9fd73611a81797c5ec338946cdaba5d09f7f5a72 Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Mon, 16 Nov 2020 16:13:53 +0100 Subject: [PATCH 04/17] Update playback-watcher.test.js --- test/playback-watcher.test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/playback-watcher.test.js b/test/playback-watcher.test.js index ab127f359..4aace1d61 100644 --- a/test/playback-watcher.test.js +++ b/test/playback-watcher.test.js @@ -1222,6 +1222,23 @@ QUnit.test('detects live window falloff', function(assert) { ); }); +QUnit.test('respects liveRangeSafeTimeDelta flag', function(assert) { + this.playbackWatcher.liveRangeSafeTimeDelta = 1; + + const beforeSeekableWindow_ = + this.playbackWatcher.beforeSeekableWindow_.bind(this.playbackWatcher); + + assert.ok( + beforeSeekableWindow_(videojs.createTimeRanges([[12, 20]]), 10), + 'true if playlist live and current time before seekable' + ); + + assert.ok( + !beforeSeekableWindow_(videojs.createTimeRanges([]), 10), + 'false if no seekable range' + ); +}); + QUnit.test('detects beyond seekable window for VOD', function(assert) { const playlist = { endList: true, From 64d3584dd4f3a7d57203489c0073c5eddda1d2cd Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Wed, 18 Nov 2020 09:51:45 +0100 Subject: [PATCH 05/17] fix: Changes improvements --- README.md | 4 ++-- package.json | 6 +----- src/playback-watcher.js | 2 +- src/videojs-http-streaming.js | 10 +++++++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 581b39827..e849cce51 100644 --- a/README.md +++ b/README.md @@ -453,8 +453,8 @@ This option defaults to `false`. * Use partial appends in the transmuxer and segment loader ##### liveRangeSafeTimeDelta -* Type: `boolean`, -* Default: `false` +* Type: `number`, +* Default: [`SAFE_TIME_DELTA`](https://github.com/videojs/http-streaming/blob/e7cb63af010779108336eddb5c8fd138d6390e95/src/ranges.js#L17) * Allow to re-define length (in seconds) of time delta when you compare current time and the end of the buffered range. ### Runtime Properties diff --git a/package.json b/package.json index 497afbcd1..9413b76b1 100644 --- a/package.json +++ b/package.json @@ -100,11 +100,7 @@ "node": ">=8", "npm": ">=5" }, - "husky": { - "hooks": { - "pre-commit": "lint-staged" - } - }, + "lint-staged": { "*.js": [ "vjsstandard --fix", diff --git a/src/playback-watcher.js b/src/playback-watcher.js index 21b92a793..33cac2552 100644 --- a/src/playback-watcher.js +++ b/src/playback-watcher.js @@ -503,7 +503,7 @@ export default class PlaybackWatcher { if (seekable.length && // can't fall before 0 and 0 seekable start identifies VOD stream seekable.start(0) > 0 && - currentTime < seekable.start(0) - (this.liveRangeSafeTimeDelta || Ranges.SAFE_TIME_DELTA)) { + currentTime < seekable.start(0) - this.liveRangeSafeTimeDelta) { return true; } diff --git a/src/videojs-http-streaming.js b/src/videojs-http-streaming.js index ef403bd2e..f3a8016f8 100644 --- a/src/videojs-http-streaming.js +++ b/src/videojs-http-streaming.js @@ -636,11 +636,15 @@ class VhsHandler extends Component { }; this.masterPlaylistController_ = new MasterPlaylistController(this.options_); - this.playbackWatcher_ = new PlaybackWatcher(videojs.mergeOptions(this.options_, { + + const playbackWatcherOptions = videojs.mergeOptions(this.options_, { seekable: () => this.seekable(), media: () => this.masterPlaylistController_.media(), - masterPlaylistController: this.masterPlaylistController_ - })); + masterPlaylistController: this.masterPlaylistController_, + liveRangeSafeTimeDelta: Ranges.SAFE_TIME_DELTA + }); + + this.playbackWatcher_ = new PlaybackWatcher(playbackWatcherOptions); this.masterPlaylistController_.on('error', () => { const player = videojs.players[this.tech_.options_.playerId]; From eee9a18f87156e5c758af07f988ca5e8b1214a08 Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Wed, 18 Nov 2020 10:23:40 +0100 Subject: [PATCH 06/17] fix: Missing retrieving of parameter --- src/videojs-http-streaming.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/videojs-http-streaming.js b/src/videojs-http-streaming.js index f3a8016f8..7f08eca8a 100644 --- a/src/videojs-http-streaming.js +++ b/src/videojs-http-streaming.js @@ -31,6 +31,7 @@ import { comparePlaylistResolution } from './playlist-selectors.js'; import {isAudioCodec, isVideoCodec, browserSupportsCodec} from '@videojs/vhs-utils/dist/codecs.js'; +import {SAFE_TIME_DELTA} from './ranges'; // IMPORTANT: // keep these at the bottom they are replaced at build time @@ -603,7 +604,8 @@ class VhsHandler extends Component { 'handlePartialData', 'playlistSelector', 'initialPlaylistSelector', - 'experimentalBufferBasedABR' + 'experimentalBufferBasedABR', + 'liveRangeSafeTimeDelta' ].forEach((option) => { if (typeof this.source_[option] !== 'undefined') { this.options_[option] = this.source_[option]; @@ -637,12 +639,16 @@ class VhsHandler extends Component { this.masterPlaylistController_ = new MasterPlaylistController(this.options_); - const playbackWatcherOptions = videojs.mergeOptions(this.options_, { - seekable: () => this.seekable(), - media: () => this.masterPlaylistController_.media(), - masterPlaylistController: this.masterPlaylistController_, - liveRangeSafeTimeDelta: Ranges.SAFE_TIME_DELTA - }); + const playbackWatcherOptions = videojs.mergeOptions({ + liveRangeSafeTimeDelta: SAFE_TIME_DELTA + }, + this.options_, + { + seekable: () => this.seekable(), + media: () => this.masterPlaylistController_.media(), + masterPlaylistController: this.masterPlaylistController_ + } + ); this.playbackWatcher_ = new PlaybackWatcher(playbackWatcherOptions); From fa66f8947a19ca4ffb6ebf664dae79ef1718715e Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Wed, 18 Nov 2020 10:34:46 +0100 Subject: [PATCH 07/17] fix: Code indentation --- src/videojs-http-streaming.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/videojs-http-streaming.js b/src/videojs-http-streaming.js index 7f08eca8a..b51037751 100644 --- a/src/videojs-http-streaming.js +++ b/src/videojs-http-streaming.js @@ -639,10 +639,11 @@ class VhsHandler extends Component { this.masterPlaylistController_ = new MasterPlaylistController(this.options_); - const playbackWatcherOptions = videojs.mergeOptions({ + const playbackWatcherOptions = videojs.mergeOptions( + { liveRangeSafeTimeDelta: SAFE_TIME_DELTA }, - this.options_, + this.options_, { seekable: () => this.seekable(), media: () => this.masterPlaylistController_.media(), From dc55cd580390e04af2d2da201bfd813295ad7b89 Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Wed, 18 Nov 2020 11:08:02 +0100 Subject: [PATCH 08/17] fix: Test failed for window falloff --- test/playback-watcher.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/playback-watcher.test.js b/test/playback-watcher.test.js index 4aace1d61..2cd511419 100644 --- a/test/playback-watcher.test.js +++ b/test/playback-watcher.test.js @@ -13,6 +13,7 @@ import { } from '../src/playback-watcher'; // needed for plugin registration import '../src/videojs-http-streaming'; +import { SAFE_TIME_DELTA } from '../src/ranges'; let monitorCurrentTime_; @@ -1184,6 +1185,8 @@ QUnit.test('skips gap from muxed video underflow', function(assert) { }); QUnit.test('detects live window falloff', function(assert) { + this.playbackWatcher.liveRangeSafeTimeDelta = SAFE_TIME_DELTA; + const beforeSeekableWindow_ = this.playbackWatcher.beforeSeekableWindow_.bind(this.playbackWatcher); From 890c7c5650336f17704712e370d7a612f40e145c Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Wed, 18 Nov 2020 11:17:41 +0100 Subject: [PATCH 09/17] Update playback-watcher.test.js --- test/playback-watcher.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/playback-watcher.test.js b/test/playback-watcher.test.js index 2cd511419..62e6fc406 100644 --- a/test/playback-watcher.test.js +++ b/test/playback-watcher.test.js @@ -1185,7 +1185,7 @@ QUnit.test('skips gap from muxed video underflow', function(assert) { }); QUnit.test('detects live window falloff', function(assert) { - this.playbackWatcher.liveRangeSafeTimeDelta = SAFE_TIME_DELTA; + this.playbackWatcher.liveRangeSafeTimeDelta = SAFE_TIME_DELTA; const beforeSeekableWindow_ = this.playbackWatcher.beforeSeekableWindow_.bind(this.playbackWatcher); From ef6e2db903beb6dcc9694d14e6d2096f86058a46 Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Wed, 18 Nov 2020 11:19:13 +0100 Subject: [PATCH 10/17] Update playback-watcher.test.js --- test/playback-watcher.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/playback-watcher.test.js b/test/playback-watcher.test.js index 62e6fc406..2cd511419 100644 --- a/test/playback-watcher.test.js +++ b/test/playback-watcher.test.js @@ -1185,7 +1185,7 @@ QUnit.test('skips gap from muxed video underflow', function(assert) { }); QUnit.test('detects live window falloff', function(assert) { - this.playbackWatcher.liveRangeSafeTimeDelta = SAFE_TIME_DELTA; + this.playbackWatcher.liveRangeSafeTimeDelta = SAFE_TIME_DELTA; const beforeSeekableWindow_ = this.playbackWatcher.beforeSeekableWindow_.bind(this.playbackWatcher); From 3b1f39f3128a2243f43d40b6397dab0c5644ff84 Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Wed, 18 Nov 2020 18:54:48 +0100 Subject: [PATCH 11/17] Update playback-watcher.test.js --- test/playback-watcher.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/playback-watcher.test.js b/test/playback-watcher.test.js index 2cd511419..7db0cd930 100644 --- a/test/playback-watcher.test.js +++ b/test/playback-watcher.test.js @@ -13,7 +13,7 @@ import { } from '../src/playback-watcher'; // needed for plugin registration import '../src/videojs-http-streaming'; -import { SAFE_TIME_DELTA } from '../src/ranges'; +import { SAFE_TIME_DELTA } from '../src/ranges'; let monitorCurrentTime_; From c6e4674f313d881af9ddb4b4c36b902d0a4885f5 Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Wed, 18 Nov 2020 18:54:56 +0100 Subject: [PATCH 12/17] Update playback-watcher.test.js --- test/playback-watcher.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/playback-watcher.test.js b/test/playback-watcher.test.js index 7db0cd930..2cd511419 100644 --- a/test/playback-watcher.test.js +++ b/test/playback-watcher.test.js @@ -13,7 +13,7 @@ import { } from '../src/playback-watcher'; // needed for plugin registration import '../src/videojs-http-streaming'; -import { SAFE_TIME_DELTA } from '../src/ranges'; +import { SAFE_TIME_DELTA } from '../src/ranges'; let monitorCurrentTime_; From 9ebc8519d7d7f0eb23ce8730f787ca6314af45d1 Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Thu, 19 Nov 2020 12:54:19 +0100 Subject: [PATCH 13/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e849cce51..66742f91d 100644 --- a/README.md +++ b/README.md @@ -455,7 +455,7 @@ This option defaults to `false`. ##### liveRangeSafeTimeDelta * Type: `number`, * Default: [`SAFE_TIME_DELTA`](https://github.com/videojs/http-streaming/blob/e7cb63af010779108336eddb5c8fd138d6390e95/src/ranges.js#L17) -* Allow to re-define length (in seconds) of time delta when you compare current time and the end of the buffered range. +* Allow to re-define length (in seconds) of time delta when you compare current time and the end of the buffered range. ### Runtime Properties Runtime properties are attached to the tech object when HLS is in From b3d3db281ff42253c3528b8ff33001202013f057 Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Mon, 23 Nov 2020 16:57:12 +0100 Subject: [PATCH 14/17] fix: Add husky --- package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0d9ed0cb7..0a5a9451b 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,11 @@ "node": ">=8", "npm": ">=5" }, - + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } + }, "lint-staged": { "*.js": [ "vjsstandard --fix", From 908946ea717ed37fac69b16fbf6816d755f3a541 Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Mon, 23 Nov 2020 17:04:15 +0100 Subject: [PATCH 15/17] chore: Fixed docs --- docs/supported-features.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/supported-features.md b/docs/supported-features.md index 7a24f9f56..7f8d293b1 100644 --- a/docs/supported-features.md +++ b/docs/supported-features.md @@ -63,7 +63,7 @@ not meant serve as an exhaustive list. * Video only (non DRM) * In-manifest [WebVTT] subtitles are automatically translated into standard HTML5 subtitle tracks -* [AES-128] segment encryption +* [AES-128] and SAMPLE-AES segment encryption ## Notable Missing Features @@ -126,7 +126,6 @@ not yet been implemented. VHS currently supports everything in the * Use of AVERAGE-BANDWIDTH in [EXT-X-STREAM-INF] (value parsed but not used) * Use of FRAME-RATE in [EXT-X-STREAM-INF] (value parsed but not used) * Use of HDCP-LEVEL in [EXT-X-STREAM-INF] -* SAMPLE-AES segment encryption In the event of encoding changes within a playlist (see https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-6.3.3), the From 99363befe41d631de7ef178db66b082493906f38 Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Mon, 23 Nov 2020 17:25:46 +0100 Subject: [PATCH 16/17] chore: Test name change --- test/playback-watcher.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/playback-watcher.test.js b/test/playback-watcher.test.js index 2cd511419..7fbd15784 100644 --- a/test/playback-watcher.test.js +++ b/test/playback-watcher.test.js @@ -1225,7 +1225,7 @@ QUnit.test('detects live window falloff', function(assert) { ); }); -QUnit.test('respects liveRangeSafeTimeDelta flag', function(assert) { +QUnit.test('Respects liveRangeSafeTimeDelta flag', function(assert) { this.playbackWatcher.liveRangeSafeTimeDelta = 1; const beforeSeekableWindow_ = From 4396a9d18fdf030b4ba8936aa8afc8065b328626 Mon Sep 17 00:00:00 2001 From: dario-fiore <32436485+dario-fiore@users.noreply.github.com> Date: Mon, 23 Nov 2020 18:18:01 +0100 Subject: [PATCH 17/17] chore: Test run --- test/playback-watcher.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/playback-watcher.test.js b/test/playback-watcher.test.js index 7fbd15784..2cd511419 100644 --- a/test/playback-watcher.test.js +++ b/test/playback-watcher.test.js @@ -1225,7 +1225,7 @@ QUnit.test('detects live window falloff', function(assert) { ); }); -QUnit.test('Respects liveRangeSafeTimeDelta flag', function(assert) { +QUnit.test('respects liveRangeSafeTimeDelta flag', function(assert) { this.playbackWatcher.liveRangeSafeTimeDelta = 1; const beforeSeekableWindow_ =