forked from video-dev/hls.js
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feature/frag loading refactor #196
Merged
Merged
Conversation
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
Refactor classes which load fragments in order to utilize new promise flow
…or compatibility in base-stream-controller
robwalch
reviewed
Feb 25, 2019
package-lock.json
Outdated
@@ -35,12 +35,12 @@ | |||
} | |||
}, | |||
"@babel/generator": { | |||
"version": "7.2.0", |
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.
need this?
robwalch
reviewed
Feb 25, 2019
* Convert fetch loader to TypeScript, implement simple abort and improve error handling * Use fetch loader by default in browsers that support Readable Stream * Implement abort and timeout in fetch loader fetch and xhr loaders abort on timeout fetch and xhr loaders call onProgress before success Improve typing in fetch and xhr loaders * Implement progress callback in fetch loader * Only listen to xhr progress if onProgress callback is defined * Handle loader abort callbacks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR will...
fragment-loader.js
:load
now takes a fragment and returns a promiseFRAG_LOADED
event, and returnsonSuccess
ERROR
, and returnsonError,
andonTimeout
loadprogress
(for now)fragCurrent
by reference)*-stream-controller.js
to use new promise based data flowfragment-loader
instancefragmentLoader.load
FRAG_LOADING
for API compatibilityFRAG_LOADED
ERROR
events on load error_loadFragForPlayback
:onFragLoaded
functionFRAG_LOADED
event for API compatibility_loadBitrateTestFrag
FRAG_LOADED
_loadInitSegment
FRAG_LOADED
fragment-loader
andxhr-loader
This is a big one but each task is in its own commit:
The only catch: Hls.js now relies on Promises to be present. This is probably API breaking. We can merge this into a
1.0.0
branch if we decide not to ship this in a minor.Why is this Pull Request needed?
Making fragment loading private and explicit to the controller which requested it allows us to simplify load callbacks. Instead of having each
FRAG_LOADED
callback check whether it should handle the event (by checking fragment type & controller state), promises allow each controller to handle only the fragment it requested. This allows us to remove a few checks at the top of each callback. Furthermore, we can split out specialized fragment loading scenarios (bitrate test, init segment) which are not demuxed into their own functions by attaching a different.then
.In addition to code cleanliness, this new pattern is the first step in enabling LHLS. LHLS requires progressive playback, which means that we're not going to have the same event flow that we have now; a fragment will be loading, parsing, and buffering at the same time, several times during its download. Our current architecture cannot handle this because it relies on events being fired in a specific sequence to propagate fragment data. By shifting to promises we eliminate the dependency on events for propagating fragment data.
Are there any points in the code the reviewer needs to double check?
Downstream clone of video-dev#2123