-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Implementing a Source Handlers interface for supporting adaptive formats #1560
Conversation
|
||
/** | ||
* Check if the volume can be changed in this browser/device. | ||
* Volume cannot be changed from 1 on iOS. |
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.
a lot of mobile devices don't support changing volume programmatically.
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.
Cool, I'll update that
Does this mean we will have to standardize the tech API? Export/Extern it for gcc? One thing that I worry about this design is tech-level state. Handing off the underlying tech element allows consumers to perform operations that can invalidate the assumptions of the tech. For instance, lastSeekTarget_ in the Flash tech. Am I misunderstanding how source handlers interact with the tech? Do you have any ideas how we can ensure things don't get out of sync? |
We already do that for the most part so the player can interact with external techs. I imagine we can improve that, but is there specific properties or whatever you're thinking of?
I at least don't mean for this to significantly change how the HLS logic interacts with the tech and tech element today, but I could be missing some details. With HTML-MSE my understanding is that our code would respond to "need data" events, fetch the data, and feed it into the source buffer. Based on that (very unconfirmed) example I don't see it screwing with tech state, however the HLS (Flash) plugin does currently insert itself earlier in processes by modifying Assuming MSE needs the same, we could consider other options for allowing a source handler to insert itself into currentTime and duration. Possibly firing events from those methods that allow preventDefault on them or modifying return values. |
Updated it to share the selection logic more, per @gkatsev's comment. @dmlap I realized there was a place where only the element was passed to the source handler, not the tech. That was wrong in case that was confusing things. The source handler would be passed the source and the tech, not the el directly. |
In the latest update I:
In the process I was able to create an RTMP source handler, separating all the RTMP code from the main Flash code. So that's at least one nice thing that's come of this. The next step is to approach the HLS plugin with these changes in mind and see what additional issue I run into. If there's any other feedback so far let me know. @dmlap let me know if you have any follow up thoughts on my previous comments. |
Added a feature request on videojs-contrib-media-sources for MSE's duration method, videojs/videojs-contrib-media-sources#18. It would prevent source handlers having to be involved in the duration getting process. |
I added some pretty pictures to the issue description that probably don't do any better of a job explaining this, but hopefully. The pseudo code at the end of the description might help the most to illustrate the process. |
I added a pic on the ideal code sharing scenario to the description. One question I'm trying to answer now is if we'll need Source Handlers to create instances. It'd be nice to keep them singletons, but then that leaves the question of where state should be stored. Possibly the tech itself, but that doesn't feel very clean. |
After chatting with @dmlap I changed the workflow to have the source handler return an instance, and the dispose method is (optionally) on that instance. The native source handlers don't need to create an instance or support a dispose method because they just pass the url to the video element. |
Rebased and updated with tests. I think this is ready to be pulled in. |
Refactoring of HTML5 source handler pattern Updated source handlers to share selection logic Created a mixin for source handler functions and update Flash to have source handlers
The source handler pattern came from the need to support adaptive formats using the Media Source Extensions (or faux MSE with Flash) while keeping the code optional and external to core since it's very heavy. I'm hoping to get some feedback on the current implementation, especially from anyone working on the HLS plugin (e.g. @dmlap, @gkatsev, @seniorflexdeveloper)
TO-DO
HLS (to prove this will work)
The source handler interface
After registering a source handler it will be included when the tech is asked if it can support a source (Html5.canPlaySource) and handed source types that it supports (Html5.prototype.setSource).
I've currently only implemented it on the HTML5 side, but Flash should look identical.(done)Native format support is also set up as a source handler here, which allows it to be prioritized in case we want our own HLS support to come before native, for example.
HLS-HTML Source Handler Pseudo Code
Overview
Native Source Handler
HLS Source Handler
Ideal Code Sharing