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

fix: export generateSidxKey, multiple audio/vtt playlists #123

Merged
merged 3 commits into from
Mar 26, 2021

Conversation

brandonocasey
Copy link
Contributor

@brandonocasey brandonocasey commented Mar 15, 2021

Currently we drop multiple playlists for the same group, when we should allow multiple renditions for the same group. This allows that to happen.

Fixes: #93
Fixes: #105
Fixes: #77

@@ -3,6 +3,9 @@ import { findIndexes } from './utils/list';
import { addSegmentsToPlaylist } from './segment/segmentBase';
import { byteRangeToString } from './segment/urlType';

export const generateSidxKey = (sidx) => sidx &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this function in VHS, we re-implemented it there which was fairly pointless imo.

@@ -40,25 +43,24 @@ const mergeDiscontiguousPlaylists = playlists => {
});
};

const addSegmentInfoFromSidx = (playlists, sidxMapping = {}) => {
export const addSidxSegmentsToPlaylist = (playlist, sidxMapping) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Sidx segments to a single playlist. We used to do this only on an array of playlists, but it was weird because for audio/vtt playlists we needed to pass in a single playlist. The naming of these functions was also weird.

a[label].playlists[0].attributes.BANDWIDTH >
playlist.attributes.bandwidth) {
return a;
if (!a[label]) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix here, we should create the group, and add playlists to it. Not only create a group with one playlist ever.

// skip if we already have subtitles
if (a[label]) {
return a;
if (!a[label]) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same fix as audio playlists.

@@ -237,6 +229,13 @@ export const formatVideoPlaylist = ({ attributes, segments, sidx }) => {
return playlist;
};

const videoOnly = ({ attributes }) =>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We defined these in a function before, needlessly creating these functions on every mpd parse isn't something we should do.

@@ -274,7 +266,7 @@ export const toM3u8 = (dashPlaylists, locations, sidxMapping = {}) => {
},
uri: '',
duration,
playlists: addSegmentInfoFromSidx(videoPlaylists, sidxMapping)
playlists: addSidxSegmentsToPlaylists(videoPlaylists, sidxMapping)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new name, same function.

@@ -67,7 +67,7 @@ export const segmentsFromBase = (attributes) => {
* @param {Object} sidx the parsed sidx box
* @return {Object} the playlist object with the updated sidx information
*/
export const addSegmentsToPlaylist = (playlist, sidx, baseUrl) => {
export const addSidxSegmentsToPlaylist = (playlist, sidx, baseUrl) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed this function, as it was named terribly. It only adds sidx segments to a playlist, and we have other functions that add segments from our dash manifest to a playlist object.

@brandonocasey brandonocasey force-pushed the fix/add-multiple-vtt-audio-playlist branch from 985ca65 to 7291421 Compare March 15, 2021 20:50
@brandonocasey brandonocasey changed the title fix: export generateSidxKey add multiple audio/vtt playlists fix: export generateSidxKey, multiple audio/vtt playlists Mar 17, 2021
@brandonocasey brandonocasey force-pushed the fix/add-multiple-vtt-audio-playlist branch from 7028b95 to 740f110 Compare March 17, 2021 20:33
@@ -1,10 +1,10 @@
import { version } from '../package.json';
import { toM3u8 } from './toM3u8';
import { toM3u8, generateSidxKey } from './toM3u8';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we duplicate this exact function in vhs right now. Seems better to have one source of truth.

@@ -89,6 +91,11 @@ export const formatAudioPlaylist = ({ attributes, segments, sidx }) => {
playlist.sidx = sidx;
}

if (isAudioOnly) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are an audio only playlist, we still want subtitles and audio groups to work correctly.

@gkatsev
Copy link
Member

gkatsev commented Mar 24, 2021

I believe this fixes #105 and seems to improve #77 though, there's still more to do for #77.

@brandonocasey brandonocasey merged commit f7105d8 into main Mar 26, 2021
@brandonocasey brandonocasey deleted the fix/add-multiple-vtt-audio-playlist branch March 26, 2021 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants