Browse Source

feat: add handlePartialData as a top level option (#532)

pull/544/head
Brandon Casey 6 years ago
committed by Gary Katsevman
parent
commit
8d6e0b78ea
  1. 6
      README.md
  2. 4
      src/master-playlist-controller.js
  3. 2
      src/segment-loader.js
  4. 4
      src/videojs-http-streaming.js
  5. 78
      test/videojs-http-streaming.test.js

6
README.md

@ -53,6 +53,7 @@ Video.js Compatibility: 6.0, 7.0
- [customTagParsers](#customtagparsers)
- [customTagMappers](#customtagmappers)
- [cacheEncryptionKeys](#cacheencryptionkeys)
- [handlePartialData](#handlepartialdata)
- [Runtime Properties](#runtime-properties)
- [hls.playlists.master](#hlsplaylistsmaster)
- [hls.playlists.media](#hlsplaylistsmedia)
@ -430,6 +431,11 @@ Similar to `customTagParsers`, with `customTagMappers` you can pass an array of
This option forces the player to cache AES-128 encryption keys internally instead of requesting the key alongside every segment request.
This option defaults to `false`.
##### handlePartialData
* Type: `boolean`,
* Default: `false`
* Use partial appends in the transmuxer and segment loader
### Runtime Properties
Runtime properties are attached to the tech object when HLS is in
use. You can get a reference to the HLS source handler like this:

4
src/master-playlist-controller.js

@ -70,7 +70,8 @@ export class MasterPlaylistController extends videojs.EventTarget {
enableLowInitialPlaylist,
sourceType,
seekTo,
cacheEncryptionKeys
cacheEncryptionKeys,
handlePartialData
} = options;
if (!url) {
@ -140,6 +141,7 @@ export class MasterPlaylistController extends videojs.EventTarget {
sourceType: this.sourceType_,
inbandTextTracks: this.inbandTextTracks_,
cacheEncryptionKeys,
handlePartialData,
sourceUpdater: this.sourceUpdater_
};

2
src/segment-loader.js

@ -187,7 +187,7 @@ export default class SegmentLoader extends videojs.EventTarget {
this.sourceUpdater_ = settings.sourceUpdater;
this.inbandTextTracks_ = settings.inbandTextTracks;
this.state_ = 'INIT';
this.handlePartialData_ = false;
this.handlePartialData_ = settings.handlePartialData;
// private instance variables
this.checkBufferTimeout_ = null;

4
src/videojs-http-streaming.js

@ -405,6 +405,7 @@ class HlsHandler extends Component {
this.options_.customTagParsers = this.options_.customTagParsers || [];
this.options_.customTagMappers = this.options_.customTagMappers || [];
this.options_.cacheEncryptionKeys = this.options_.cacheEncryptionKeys || false;
this.options_.handlePartialData = this.options_.handlePartialData || false;
if (typeof this.options_.blacklistDuration !== 'number') {
this.options_.blacklistDuration = 5 * 60;
@ -445,7 +446,8 @@ class HlsHandler extends Component {
'customTagParsers',
'customTagMappers',
'handleManifestRedirects',
'cacheEncryptionKeys'
'cacheEncryptionKeys',
'handlePartialData'
].forEach((option) => {
if (typeof this.source_[option] !== 'undefined') {
this.options_[option] = this.source_[option];

78
test/videojs-http-streaming.test.js

@ -1873,6 +1873,84 @@ QUnit.test('if handleManifestRedirects global option is used, it should be passe
videojs.options.hls = hlsOptions;
});
QUnit.test(
'if handlePartialData global option is used, it is set on audio/main loader but not subtitle',
function(assert) {
let hlsOptions = videojs.options.hls;
this.player.dispose();
videojs.options.hls = {
handlePartialData: true
};
this.player = createPlayer();
this.player.src({
src: 'http://example.com/media.m3u8',
type: 'application/vnd.apple.mpegurl'
});
this.clock.tick(1);
openMediaSource(this.player, this.clock);
const {mainSegmentLoader_, subtitleSegmentLoader_, audioSegmentLoader_} =
this.player.vhs.masterPlaylistController_;
assert.equal(mainSegmentLoader_.handlePartialData_, true, 'is set on main');
assert.equal(audioSegmentLoader_.handlePartialData_, true, 'is set on audio');
assert.equal(subtitleSegmentLoader_.handlePartialData_, false, 'is not set on subtitle');
videojs.options.hls = hlsOptions;
});
QUnit.test(
'if handlePartialData source option is used, it is set on audio/main loader but not subtitle',
function(assert) {
let hlsOptions = videojs.options.hls;
this.player.dispose();
this.player = createPlayer();
this.player.src({
src: 'http://example.com/media.m3u8',
type: 'application/vnd.apple.mpegurl',
handlePartialData: true
});
this.clock.tick(1);
openMediaSource(this.player, this.clock);
const {mainSegmentLoader_, subtitleSegmentLoader_, audioSegmentLoader_} =
this.player.vhs.masterPlaylistController_;
assert.equal(mainSegmentLoader_.handlePartialData_, true, 'is set on main');
assert.equal(audioSegmentLoader_.handlePartialData_, true, 'is set on audio');
assert.equal(subtitleSegmentLoader_.handlePartialData_, false, 'is not set on subtitle');
videojs.options.hls = hlsOptions;
});
QUnit.test('the handlePartialData source option overrides the global default', function(assert) {
let hlsOptions = videojs.options.hls;
this.player.dispose();
videojs.options.hls = {
handlePartialData: true
};
this.player = createPlayer();
this.player.src({
src: 'http://example.com/media.m3u8',
type: 'application/vnd.apple.mpegurl',
handlePartialData: false
});
this.clock.tick(1);
openMediaSource(this.player, this.clock);
const {mainSegmentLoader_, subtitleSegmentLoader_, audioSegmentLoader_} =
this.player.vhs.masterPlaylistController_;
assert.equal(mainSegmentLoader_.handlePartialData_, false, 'is set on main');
assert.equal(audioSegmentLoader_.handlePartialData_, false, 'is set on audio');
assert.equal(subtitleSegmentLoader_.handlePartialData_, false, 'is not set on subtitle');
videojs.options.hls = hlsOptions;
});
QUnit.test('the handleManifestRedirects source option overrides the global default', function(assert) {
let hlsOptions = videojs.options.hls;

Loading…
Cancel
Save