-
Notifications
You must be signed in to change notification settings - Fork 422
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
chore: vhs utils update #1036
Merged
Merged
chore: vhs utils update #1036
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5022f84
chore: vhs utils update
brandonocasey 3fb1171
change imports
brandonocasey 29255e7
Use new parseCodecs return values
brandonocasey ab9b3d8
make it a log line
brandonocasey 2d752cf
update packages
brandonocasey 549cb71
get tests working
brandonocasey dbf9af6
fix for browsers that support ac-3
brandonocasey 9bc69e8
better error again
brandonocasey b02e8c3
remove log line
brandonocasey 0354b78
update packages and rollup
brandonocasey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,8 @@ import { | |
muxerSupportsCodec, | ||
DEFAULT_AUDIO_CODEC, | ||
DEFAULT_VIDEO_CODEC | ||
} from '@videojs/vhs-utils/dist/codecs.js'; | ||
import { codecsForPlaylist } from './util/codecs.js'; | ||
} from '@videojs/vhs-utils/es/codecs.js'; | ||
import { codecsForPlaylist, unwrapCodecList, codecCount } from './util/codecs.js'; | ||
import { createMediaTypes, setupMediaGroups } from './media-groups'; | ||
import logger from './util/logger'; | ||
|
||
|
@@ -1562,8 +1562,8 @@ export class MasterPlaylistController extends videojs.EventTarget { | |
const switchMessages = []; | ||
|
||
['video', 'audio'].forEach((type) => { | ||
const newCodec = (parseCodecs(this.sourceUpdater_.codecs[type] || '')[type] || {}).type; | ||
const oldCodec = (parseCodecs(codecs[type] || '')[type] || {}).type; | ||
const newCodec = (parseCodecs(this.sourceUpdater_.codecs[type] || '')[0] || {}).type; | ||
const oldCodec = (parseCodecs(codecs[type] || '')[0] || {}).type; | ||
|
||
if (newCodec && oldCodec && newCodec.toLowerCase() !== oldCodec.toLowerCase()) { | ||
switchMessages.push(`"${this.sourceUpdater_.codecs[type]}" -> "${codecs[type]}"`); | ||
|
@@ -1642,22 +1642,20 @@ export class MasterPlaylistController extends videojs.EventTarget { | |
const unsupported = []; | ||
|
||
if (codecs.audio && !muxerSupportsCodec(codecs.audio) && !browserSupportsCodec(codecs.audio)) { | ||
variant.excludeUntil = Infinity; | ||
unsupported.push(`audio codec ${codecs.audio}`); | ||
} | ||
|
||
if (codecs.video && !muxerSupportsCodec(codecs.video) && !browserSupportsCodec(codecs.video)) { | ||
variant.excludeUntil = Infinity; | ||
unsupported.push(`video codec ${codecs.video}`); | ||
} | ||
|
||
if (codecs.text && codecs.text === 'stpp.ttml.im1t') { | ||
variant.excludeUntil = Infinity; | ||
unsupported.push(`text codec ${codecs.text}`); | ||
} | ||
|
||
if (unsupported.length) { | ||
this.logger_(`excluding ${variant.id} as codecs ${unsupported.join(', ')} are unsupported`); | ||
variant.excludeUntil = Infinity; | ||
this.logger_(`excluding ${variant.id} for unsupported: ${unsupported.join(', ')}`); | ||
} | ||
}); | ||
} | ||
|
@@ -1677,67 +1675,61 @@ export class MasterPlaylistController extends videojs.EventTarget { | |
* @private | ||
*/ | ||
excludeIncompatibleVariants_(codecString) { | ||
const codecs = parseCodecs(codecString); | ||
const codecCount = Object.keys(codecs).length; | ||
const ids = []; | ||
const playlists = this.master().playlists; | ||
const codecs = unwrapCodecList(parseCodecs(codecString)); | ||
const codecCount_ = codecCount(codecs); | ||
const videoDetails = codecs.video && parseCodecs(codecs.video)[0] || null; | ||
const audioDetails = codecs.audio && parseCodecs(codecs.audio)[0] || null; | ||
|
||
Object.keys(playlists).forEach((key) => { | ||
const variant = playlists[key]; | ||
|
||
this.master().playlists.forEach((variant) => { | ||
// skip variants that are already blacklisted forever | ||
if (variant.excludeUntil === Infinity) { | ||
// check if we already processed this playlist. | ||
// or it if it is already excluded forever. | ||
if (ids.indexOf(variant.id) !== -1 || variant.excludeUntil === Infinity) { | ||
return; | ||
} | ||
/* TODO: Decide whether two codecs should be assumed here. | ||
* Right now, for playlists that don't specify codecs, VHS assumes | ||
* that there are two (one for audio and one for video). | ||
* Although this is often the case, this may lead to broken behavior | ||
* if the playlist only has one codec. It may be better in the future | ||
* to decide at time of segment download how many tracks there are and | ||
* determine the proper codecs. This will come at a cost of potentially | ||
* more bandwidth, but will be a more robust approach than the assumption here. | ||
*/ | ||
|
||
let variantCodecs = {}; | ||
let variantCodecCount = 2; | ||
|
||
ids.push(variant.id); | ||
const blacklistReasons = []; | ||
|
||
// get codecs from the playlist for this variant | ||
const variantCodecStrings = codecsForPlaylist(this.masterPlaylistLoader_.master, variant); | ||
|
||
if (variantCodecStrings.audio || variantCodecStrings.video) { | ||
const variantCodecString = [variantCodecStrings.video, variantCodecStrings.audio] | ||
.filter(Boolean) | ||
.join(','); | ||
const variantCodecs = codecsForPlaylist(this.masterPlaylistLoader_.master, variant); | ||
const variantCodecCount = codecCount(variantCodecs); | ||
|
||
variantCodecs = parseCodecs(variantCodecString); | ||
variantCodecCount = Object.keys(variantCodecs).length; | ||
// if no codecs are listed, we cannot determine that this | ||
// variant is incompatible. Wait for mux.js to probe | ||
if (!variantCodecs.audio && !variantCodecs.video) { | ||
return; | ||
} | ||
|
||
// TODO: we can support this by removing the | ||
// old media source and creating a new one, but it will take some work. | ||
// The number of streams cannot change | ||
if (variantCodecCount !== codecCount) { | ||
blacklistReasons.push(`codec count "${variantCodecCount}" !== "${codecCount}"`); | ||
variant.excludeUntil = Infinity; | ||
if (variantCodecCount !== codecCount_) { | ||
blacklistReasons.push(`codec count "${variantCodecCount}" !== "${codecCount_}"`); | ||
} | ||
|
||
// only exclude playlists by codec change, if codecs cannot switch | ||
// during playback. | ||
if (!this.sourceUpdater_.canChangeType()) { | ||
const variantVideoDetails = variantCodecs.video && parseCodecs(variantCodecs.video)[0] || null; | ||
const variantAudioDetails = variantCodecs.audio && parseCodecs(variantCodecs.audio)[0] || null; | ||
|
||
// the video codec cannot change | ||
if (variantCodecs.video && codecs.video && | ||
variantCodecs.video.type.toLowerCase() !== codecs.video.type.toLowerCase()) { | ||
blacklistReasons.push(`video codec "${variantCodecs.video.type}" !== "${codecs.video.type}"`); | ||
variant.excludeUntil = Infinity; | ||
if (variantVideoDetails && videoDetails && variantVideoDetails.type.toLowerCase() !== videoDetails.type.toLowerCase()) { | ||
blacklistReasons.push(`video codec "${variantVideoDetails.type}" !== "${videoDetails.type}"`); | ||
} | ||
|
||
// the audio codec cannot change | ||
if (variantCodecs.audio && codecs.audio && | ||
variantCodecs.audio.type.toLowerCase() !== codecs.audio.type.toLowerCase()) { | ||
variant.excludeUntil = Infinity; | ||
blacklistReasons.push(`audio codec "${variantCodecs.audio.type}" !== "${codecs.audio.type}"`); | ||
if (variantAudioDetails && audioDetails && variantAudioDetails.type.toLowerCase() !== audioDetails.type.toLowerCase()) { | ||
blacklistReasons.push(`audio codec "${variantAudioDetails.type}" !== "${audioDetails.type}"`); | ||
} | ||
} | ||
|
||
if (blacklistReasons.length) { | ||
variant.excludeUntil = Infinity; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved the exclude down here so we don't do it in every if. |
||
this.logger_(`blacklisting ${variant.id}: ${blacklistReasons.join(' && ')}`); | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loop through all playlists for sure