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

feat: transmux before append (TBA) and low latency http streaming (LHLS) #494

Merged
merged 1 commit into from
May 20, 2019

Conversation

brandonocasey
Copy link
Contributor

@brandonocasey brandonocasey commented May 3, 2019

Description

This takes most of the changes from #466, gesinger#10, and changes that have occurred in master since both of those and packages them up.

I still have the following to do:

  • Verify that all fixes and changes from master have been brought into this branch
  • Make the src diff easier to read where possible, or add comments on code.
  • Get all the tests working and make sure that all the tests still exist
  • what is the difference between mux.js segmentTimingInfo/videoSegmentTimingInfo and timingInfo/videoTimingInfo.
  • Generate an encrypted ts segment with a key for unit tests

This is based on the following, which will have to be merged first:

@@ -210,15 +225,7 @@ export class MasterPlaylistController extends videojs.EventTarget {
});

this.triggerPresenceUsage_(this.master(), media);

try {
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 handled by a sourceopen on the media source in handleSourceOpen_()

@@ -276,30 +283,6 @@ export class MasterPlaylistController extends videojs.EventTarget {
this.audioSegmentLoader_.load();
}
}

if (!updatedPlaylist.endList) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Presumably we no longer have to update seekable or deal with durationchange since we are using a native media source. This code should have lived in our non-native media source I think.

@@ -395,10 +378,6 @@ export class MasterPlaylistController extends videojs.EventTarget {
this.tech_.trigger({type: 'usage', name: 'hls-aes'});
}

if (Hls.Playlist.isFmp4(media)) {
this.tech_.trigger({type: 'usage', name: 'hls-fmp4'});
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 code was moved to setupSegmentLoaderListeners_() and we trigger the usage event when a segmentLoader triggers an fmp4 event.

@@ -472,24 +461,31 @@ export class MasterPlaylistController extends videojs.EventTarget {
}, ABORT_EARLY_BLACKLIST_SECONDS);
});

this.mainSegmentLoader_.on('reseteverything', () => {
// If playing an MTS stream, a videojs.MediaSource is listening for
Copy link
Contributor Author

@brandonocasey brandonocasey May 3, 2019

Choose a reason for hiding this comment

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

we use a native media source so reseteverything and segmenttimemapping are no longer fired or needed.

@brandonocasey brandonocasey force-pushed the feat/tba-lhls branch 2 times, most recently from 043f330 to db5f24f Compare May 3, 2019 17:21
* @private
*/
handleSourceEnded_() {
if (!this.inbandTextTracks_.metadataTrack_) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

mostly taken and modified from the sourceended handler in html-media-source

@brandonocasey brandonocasey force-pushed the feat/tba-lhls branch 5 times, most recently from 98ec660 to fdfd3a3 Compare May 3, 2019 17:40
// even if the media source is open and source buffers are not
// updating, something about the media source being in an invalid state.
this.logger_(`Setting duration from ${this.mediaSource.duration} => ${newDuration}`);
try {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The try catch here was moved into sourceUpdaters actions.duration handler. Most of the rest of this logic is reformatted but unchanged.

@brandonocasey brandonocasey force-pushed the feat/tba-lhls branch 3 times, most recently from 068da21 to 9aec73c Compare May 3, 2019 17:53
// loader and not restart the audio loaders
mainSegmentLoader.resetEverything();
return;
if (type === 'AUDIO') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this just handles moving from demuxed audio/video to muxed audio/video in a better way.

*
* @return {Boolean} true if the playlist contains fMP4
*/
export const isFmp4 = function(media) {
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 now use util/codecs.js#isLikelyFmp4Data() to determine if a segment is fmp4 during media segment requests. Then we add segment.isFmp4 to the segment object.

@brandonocasey brandonocasey force-pushed the feat/tba-lhls branch 4 times, most recently from f21c2d2 to 373e4ea Compare May 3, 2019 19:56

for (let trackId in segment.captionStreams) {
if (!sourceBuffer.inbandTextTracks_[trackId]) {
player.tech_.trigger({type: 'usage', name: 'hls-608'});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all of this logic was the same as createCaptionsTrackIfNotExists.

export const addTextTrackData = function(sourceHandler, captionArray, metadataArray) {
let Cue = window.WebKitDataCue || window.VTTCue;

if (captionArray) {
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/was addCaptionData, not sure why we repeated the logic here, but it was removed and is now done in segment-loader.

@brandonocasey brandonocasey force-pushed the feat/tba-lhls branch 2 times, most recently from 74b70cc to f757166 Compare May 3, 2019 20:33
this.pendingCallback_ = null;
this.sourceBuffer_.removing = false;

this.logger_(`buffered [${printableRange(this.buffered())}]`);
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 logic is now in the onUpdateend function right above the class for this file.

sourceUpdater: this,
action: actions.callback(callback),
name: 'callback'
});
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this file will eventually need some updates. Some places we have function that pass a type and are generic for audio and video. Then others functions are prepended with audio or video (IE audioTimestampOffset vs videoTimestampOffset) and they do nearly the same thing.

*
* @param {SegmentInfo} segmentInfo - The current active request information
*/
probeSegmentInfo(segmentInfo) {
Copy link
Contributor Author

@brandonocasey brandonocasey May 3, 2019

Choose a reason for hiding this comment

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

All of the probe logic seems to have been moved into src/util/segment and I think we store syncinfo on the playlist now.

}
});

transmuxer.on('caption', function(caption) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think caption and id3Frame takes the place of transmuxer.captionStream?

package.json Outdated Show resolved Hide resolved
@brandonocasey brandonocasey force-pushed the feat/tba-lhls branch 6 times, most recently from af9912b to cf2030e Compare May 20, 2019 18:18
@brandonocasey brandonocasey changed the base branch from tba-master to master May 20, 2019 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants