Skip to content

Commit

Permalink
feat: transmux before append (TBA) and low latency http streaming (LHLS)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed May 3, 2019
1 parent 8d56d36 commit 068da21
Show file tree
Hide file tree
Showing 60 changed files with 9,171 additions and 4,150 deletions.
324 changes: 197 additions & 127 deletions src/master-playlist-controller.js

Large diffs are not rendered by default.

33 changes: 26 additions & 7 deletions src/media-groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,23 @@ export const onTrackChanged = (type, settings) => () => {
return;
}

if (!activeGroup.playlistLoader) {
// when switching from demuxed audio/video to muxed audio/video (noted by no playlist
// loader for the audio group), we want to do a destructive reset of the main segment
// loader and not restart the audio loaders
mainSegmentLoader.resetEverything();
return;
if (type === 'AUDIO') {
if (!activeGroup.playlistLoader) {
// when switching from demuxed audio/video to muxed audio/video (noted by no
// playlist loader for the audio group), we want to do a destructive reset of the
// main segment loader and not restart the audio loaders
mainSegmentLoader.setAudio(true);
// don't have to worry about disabling the audio of the audio segment loader since
// it should be stopped
mainSegmentLoader.resetEverything();
return;
}

// although the segment loader is an audio segment loader, call the setAudio
// function to ensure it is prepared to re-append the init segment (or handle other
// config changes)
segmentLoader.setAudio(true);
mainSegmentLoader.setAudio(false);
}

if (previousActiveLoader === activeGroup.playlistLoader) {
Expand Down Expand Up @@ -713,7 +724,11 @@ export const setupMediaGroups = (settings) => {
mediaTypes,
masterPlaylistLoader,
tech,
hls
hls,
segmentLoaders: {
AUDIO: audioSegmentLoader,
main: mainSegmentLoader
}
} = settings;

// setup active group and track getters and change event handlers
Expand All @@ -733,11 +748,15 @@ export const setupMediaGroups = (settings) => {
mediaTypes.AUDIO.onTrackChanged();

masterPlaylistLoader.on('mediachange', () => {
mainSegmentLoader.appendAudioInitSegment_ = true;
audioSegmentLoader.appendAudioInitSegment_ = true;
['AUDIO', 'SUBTITLES'].forEach(type => mediaTypes[type].onGroupChanged());
});

// custom audio track change event handler for usage event
const onAudioTrackChanged = () => {
mainSegmentLoader.appendAudioInitSegment_ = true;
audioSegmentLoader.appendAudioInitSegment_ = true;
mediaTypes.AUDIO.onTrackChanged();
tech.trigger({ type: 'usage', name: 'hls-audio-change' });
};
Expand Down
Loading

0 comments on commit 068da21

Please sign in to comment.