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

refactor: rename 'blacklist' to 'exclude' #1274

Merged
merged 8 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Video.js Compatibility: 6.0, 7.0
- [useCueTags](#usecuetags)
- [parse708captions](#parse708captions)
- [overrideNative](#overridenative)
- [blacklistDuration](#blacklistduration)
- [playlistExclusionDuration](#playlistexclusionduration)
- [maxPlaylistRetries](#maxplaylistretries)
- [bandwidth](#bandwidth)
- [useBandwidthFromLocalStorage](#usebandwidthfromlocalstorage)
Expand Down Expand Up @@ -347,13 +347,13 @@ var player = videojs('playerId', {

Since MSE playback may be desirable on all browsers with some native support other than Safari, `overrideNative: !videojs.browser.IS_SAFARI` could be used.

##### blacklistDuration
##### playlistExclusionDuration
* Type: `number`
* can be used as an initialization option

When the `blacklistDuration` property is set to a time duration in seconds,
if a playlist is blacklisted, it will be blacklisted for a period of that
customized duration. This enables the blacklist duration to be configured
When the `playlistExclusionDuration` property is set to a time duration in seconds,
if a playlist is excluded, it will be excluded for a period of that
customized duration. This enables the exclusion duration to be configured
by the user.

##### maxPlaylistRetries
Expand Down Expand Up @@ -774,7 +774,7 @@ Each of the following usage events are fired per use:
| vhs-audio-change | a user selected an alternate audio stream |
| vhs-rendition-disabled | a rendition was disabled |
| vhs-rendition-enabled | a rendition was enabled |
| vhs-rendition-blacklisted | a rendition was blacklisted |
| vhs-rendition-excluded| a rendition was excluded |
| vhs-timestamp-offset | a timestamp offset was set in HLS (can identify discontinuities) |
| vhs-unknown-waiting | the player stopped for an unknown reason and we seeked to current time try to address it |
| vhs-live-resync | playback fell off the back of a live playlist and we resynced to the live point |
Expand Down
2 changes: 1 addition & 1 deletion src/dash-playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export default class DashPlaylistLoader extends EventTarget {
response: '',
playlist,
internal: true,
blacklistDuration: Infinity,
playlistExclusionDuration: Infinity,
// MEDIA_ERR_NETWORK
code: 2
}, request);
Expand Down
52 changes: 26 additions & 26 deletions src/master-playlist-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class MasterPlaylistController extends videojs.EventTarget {
bandwidth,
externVhs,
useCueTags,
blacklistDuration,
playlistExclusionDuration,
enableLowInitialPlaylist,
sourceType,
cacheEncryptionKeys,
Expand Down Expand Up @@ -183,7 +183,7 @@ export class MasterPlaylistController extends videojs.EventTarget {
this.vhs_ = tech.vhs;
this.sourceType_ = sourceType;
this.useCueTags_ = useCueTags;
this.blacklistDuration = blacklistDuration;
this.playlistExclusionDuration = playlistExclusionDuration;
this.maxPlaylistRetries = maxPlaylistRetries;
this.enableLowInitialPlaylist = enableLowInitialPlaylist;

Expand Down Expand Up @@ -525,7 +525,7 @@ export class MasterPlaylistController extends videojs.EventTarget {
vhs: this.vhs_,
master: this.master(),
mediaTypes: this.mediaTypes_,
blacklistCurrentPlaylist: this.blacklistCurrentPlaylist.bind(this)
excludeCurrentPlaylist: this.excludeCurrentPlaylist.bind(this)
});

this.triggerPresenceUsage_(this.master(), media);
Expand Down Expand Up @@ -592,7 +592,7 @@ export class MasterPlaylistController extends videojs.EventTarget {
});

this.masterPlaylistLoader_.on('error', () => {
this.blacklistCurrentPlaylist(this.masterPlaylistLoader_.error);
this.excludeCurrentPlaylist(this.masterPlaylistLoader_.error);
});

this.masterPlaylistLoader_.on('mediachanging', () => {
Expand Down Expand Up @@ -640,10 +640,10 @@ export class MasterPlaylistController extends videojs.EventTarget {

if (playlistOutdated) {
// Playlist has stopped updating and we're stuck at its end. Try to
// blacklist it and switch to another playlist in the hope that that
// exclude it and switch to another playlist in the hope that that
// one is updating (and give the player a chance to re-adjust to the
// safe live point).
this.blacklistCurrentPlaylist({
this.excludeCurrentPlaylist({
message: 'Playlist no longer updating.',
reason: 'playlist-unchanged'
});
Expand Down Expand Up @@ -778,7 +778,7 @@ export class MasterPlaylistController extends videojs.EventTarget {
}

this.mainSegmentLoader_.on('error', () => {
this.blacklistCurrentPlaylist(this.mainSegmentLoader_.error());
this.excludeCurrentPlaylist(this.mainSegmentLoader_.error());
});

this.mainSegmentLoader_.on('appenderror', () => {
Expand Down Expand Up @@ -815,7 +815,7 @@ export class MasterPlaylistController extends videojs.EventTarget {

this.delegateLoaders_('all', ['abort']);

this.blacklistCurrentPlaylist({
this.excludeCurrentPlaylist({
message: 'Aborted early because there isn\'t enough bandwidth to complete the ' +
'request without rebuffering.'
}, ABORT_EARLY_BLACKLIST_SECONDS);
Expand Down Expand Up @@ -1134,25 +1134,25 @@ export class MasterPlaylistController extends videojs.EventTarget {
}

/**
* Blacklists a playlist when an error occurs for a set amount of time
* Exclude a playlist when an error occurs for a set amount of time
* making it unavailable for selection by the rendition selection algorithm
* and then forces a new playlist (rendition) selection.
*
* @param {Object=} error an optional error that may include the playlist
* to blacklist
* @param {number=} blacklistDuration an optional number of seconds to blacklist the
* to exclude
* @param {number=} playlistExclusionDuration an optional number of seconds to exclude the
* playlist
*/
blacklistCurrentPlaylist(error = {}, blacklistDuration) {
excludeCurrentPlaylist(error = {}, playlistExclusionDuration) {
// If the `error` was generated by the playlist loader, it will contain
// the playlist we were trying to load (but failed) and that should be
// blacklisted instead of the currently selected playlist which is likely
// excluded instead of the currently selected playlist which is likely
// out-of-date in this scenario
const currentPlaylist = error.playlist || this.masterPlaylistLoader_.media();

blacklistDuration = blacklistDuration ||
error.blacklistDuration ||
this.blacklistDuration;
playlistExclusionDuration = playlistExclusionDuration ||
error.playlistExclusionDuration ||
this.playlistExclusionDuration;

// If there is no current playlist, then an error occurred while we were
// trying to load the master OR while we were disposing of the tech
Expand All @@ -1176,7 +1176,7 @@ export class MasterPlaylistController extends videojs.EventTarget {

// Don't blacklist the only playlist unless it was blacklisted
// forever
if (playlists.length === 1 && blacklistDuration !== Infinity) {
if (playlists.length === 1 && playlistExclusionDuration !== Infinity) {
videojs.log.warn(`Problem encountered with playlist ${currentPlaylist.id}. ` +
'Trying again since it is the only playlist.');

Expand Down Expand Up @@ -1216,13 +1216,13 @@ export class MasterPlaylistController extends videojs.EventTarget {
}
}

// Blacklist this playlist
// Exclude this playlist
let excludeUntil;

if (currentPlaylist.playlistErrors_ > this.maxPlaylistRetries) {
excludeUntil = Infinity;
} else {
excludeUntil = Date.now() + (blacklistDuration * 1000);
excludeUntil = Date.now() + (playlistExclusionDuration * 1000);
}

currentPlaylist.excludeUntil = excludeUntil;
Expand All @@ -1231,7 +1231,7 @@ export class MasterPlaylistController extends videojs.EventTarget {
currentPlaylist.lastExcludeReason_ = error.reason;
}
this.tech_.trigger('blacklistplaylist');
this.tech_.trigger({type: 'usage', name: 'vhs-rendition-blacklisted'});
this.tech_.trigger({type: 'usage', name: 'vhs-rendition-excluded'});

// TODO: should we select a new playlist if this blacklist wasn't for the currentPlaylist?
// Would be something like media().id !=== currentPlaylist.id and we would need something
Expand Down Expand Up @@ -1706,10 +1706,10 @@ export class MasterPlaylistController extends videojs.EventTarget {

// no codecs, no playback.
if (!codecs.audio && !codecs.video) {
this.blacklistCurrentPlaylist({
this.excludeCurrentPlaylist({
playlist: this.media(),
message: 'Could not determine codecs for playlist.',
blacklistDuration: Infinity
playlistExclusionDuration: Infinity
});
return;
}
Expand Down Expand Up @@ -1758,11 +1758,11 @@ export class MasterPlaylistController extends videojs.EventTarget {
return acc;
}, '') + '.';

this.blacklistCurrentPlaylist({
this.excludeCurrentPlaylist({
playlist: this.media(),
internal: true,
message,
blacklistDuration: Infinity
playlistExclusionDuration: Infinity
});
return;
}
Expand All @@ -1783,10 +1783,10 @@ export class MasterPlaylistController extends videojs.EventTarget {
});

if (switchMessages.length) {
this.blacklistCurrentPlaylist({
this.excludeCurrentPlaylist({
playlist: this.media(),
message: `Codec switching not supported: ${switchMessages.join(', ')}.`,
blacklistDuration: Infinity,
playlistExclusionDuration: Infinity,
internal: true
});
return;
Expand Down
8 changes: 4 additions & 4 deletions src/media-groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export const onError = {
const {
segmentLoaders: { [type]: segmentLoader},
mediaTypes: { [type]: mediaType },
blacklistCurrentPlaylist
excludeCurrentPlaylist
} = settings;

stopLoaders(segmentLoader, mediaType);
Expand All @@ -265,7 +265,7 @@ export const onError = {
if (activeTrack === defaultTrack) {
// Default track encountered an error. All we can do now is blacklist the current
// rendition and hope another will switch audio groups
blacklistCurrentPlaylist({
excludeCurrentPlaylist({
message: 'Problem encountered loading the default audio track.'
});
return;
Expand Down Expand Up @@ -844,8 +844,8 @@ export const getActiveGroup = (type, {mediaTypes}) => () => {
* The parsed master manifest
* @param {Object} settings.mediaTypes
* Object to store the loaders, tracks, and utility methods for each media type
* @param {Function} settings.blacklistCurrentPlaylist
* Blacklists the current rendition and forces a rendition switch.
* @param {Function} settings.excludeCurrentPlaylist
* Excludes the current rendition and forces a rendition switch.
* @function setupMediaGroups
*/
export const setupMediaGroups = (settings) => {
Expand Down
2 changes: 1 addition & 1 deletion src/playback-watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export default class PlaybackWatcher {

// TODO: should we exclude audio tracks rather than main tracks
// when type is audio?
mpc.blacklistCurrentPlaylist({
mpc.excludeCurrentPlaylist({
message: `Excessive ${type} segment downloading detected.`
}, Infinity);
}
Expand Down
14 changes: 7 additions & 7 deletions src/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,13 @@ export const getMediaInfoForTime = function({
};

/**
* Check whether the playlist is blacklisted or not.
* Check whether the playlist is excluded or not.
*
* @param {Object} playlist the media playlist object
* @return {boolean} whether the playlist is blacklisted or not
* @function isBlacklisted
* @return {boolean} whether the playlist is excluded or not
* @function isExcluded
*/
export const isBlacklisted = function(playlist) {
export const isExcluded = function(playlist) {
return playlist.excludeUntil && playlist.excludeUntil > Date.now();
};

Expand All @@ -566,9 +566,9 @@ export const isIncompatible = function(playlist) {
* @function isEnabled
*/
export const isEnabled = function(playlist) {
const blacklisted = isBlacklisted(playlist);
const excluded = isExcluded(playlist);

return (!playlist.disabled && !blacklisted);
return (!playlist.disabled && !excluded);
};

/**
Expand Down Expand Up @@ -766,7 +766,7 @@ export default {
getMediaInfoForTime,
isEnabled,
isDisabled,
isBlacklisted,
isExcluded,
isIncompatible,
playlistEnd,
isAes,
Expand Down
4 changes: 2 additions & 2 deletions src/segment-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2798,7 +2798,7 @@ export default class SegmentLoader extends videojs.EventTarget {
if (!trackInfo) {
this.error({
message: 'No starting media returned, likely due to an unsupported media format.',
blacklistDuration: Infinity
playlistExclusionDuration: Infinity
});
this.trigger('error');
return;
Expand Down Expand Up @@ -2879,7 +2879,7 @@ export default class SegmentLoader extends videojs.EventTarget {
if (illegalMediaSwitchError) {
this.error({
message: illegalMediaSwitchError,
blacklistDuration: Infinity
playlistExclusionDuration: Infinity
});
this.trigger('error');
return true;
Expand Down
8 changes: 4 additions & 4 deletions src/videojs-http-streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ class VhsHandler extends Component {
this.options_.customTagMappers = this.options_.customTagMappers || [];
this.options_.cacheEncryptionKeys = this.options_.cacheEncryptionKeys || false;

if (typeof this.options_.blacklistDuration !== 'number') {
this.options_.blacklistDuration = 5 * 60;
if (typeof this.options_.playlistExclusionDuration !== 'number') {
this.options_.playlistExclusionDuration = 5 * 60;
}

if (typeof this.options_.bandwidth !== 'number') {
Expand Down Expand Up @@ -1022,10 +1022,10 @@ class VhsHandler extends Component {

this.player_.tech_.on('keystatuschange', (e) => {
if (e.status === 'output-restricted') {
this.masterPlaylistController_.blacklistCurrentPlaylist({
this.masterPlaylistController_.excludeCurrentPlaylist({
playlist: this.masterPlaylistController_.media(),
message: `DRM keystatus changed to ${e.status}. Playlist will fail to play. Check for HDCP content.`,
blacklistDuration: Infinity
playlistExclusionDuration: Infinity
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion test/dash-playlist-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ QUnit.test('addSidxSegments_: adds/triggers error on invalid container', functio
assert.ok(triggeredError, 'triggered an error');

assert.deepEqual(loader.error, {
blacklistDuration: Infinity,
playlistExclusionDuration: Infinity,
code: 2,
internal: true,
message: 'Unsupported unknown container type for sidx segment at URL: sidx.mp4',
Expand Down
Loading