Dash.js Refactor
Created by: kirkshoop
- Conversion the player architecture from Pull to Push model. Q.js dependency has been removed, promises pattern has been replaced with Observer pattern. Now most of the dashjs objects 'inherit' subscribe/notify methods which allow them to notify observers about their state change.
-
Refactoring of classes. Complex logic that was accumulated in BufferController has been separated into several new classes by functionality (buffering, scheduling, playback, updating manifest data etc. The goal was to increase understanding of logic, ease in reusing and maintaining the code.
-
Scheduling improvements Scheduling logic has been moved into rules. How many segments, which segments and when they should be requested are now calculated in the competing rules. Live edge search logic also has been moved into rules. Scheduling by timer has been removed. Segments are now requested in an response to events. A request of each type (audio/video) waits for a request of the other type with the same presentation time before being loaded. Initialization segments for dynamic mpds are loaded only once. Pending requests are cancelled only when seeking.
-
ABR improvements The number of quality switches per unit time has been restricted to prevent frequent switching.
-
Buffering improvements Pending segments for a better quality are allowed to be appended to the buffer even if the quality has been changed to a low value, i.e. if there are several segments for a quality 4 which are already loaded and waiting in the queue for appending or even if they are being loaded and AbrController signals that the quality should change to 1, the player will complete appending and loading remaining segments for quality 4 w/o switching initialization segments. But at the same time the player starts requesting segments for a new quality. Handling of QuotaExceededError - the value of acceptable buffer level is restricted to 80% of the buffer level which was at the moment the error occurred.
-
Removed duplicated code
-
Code complexity has been reduced As a result of the improvements listed above the size of methods has been reduced as well as code nesting, number of conditional statements etc.
A new custom rules API. It adds support for adding and setting custom rules for both scheduling and abr rule types.
-
Added new public methods to MediaPlayer: setSchedulingRules, addSchedulingRules, setABRRules, addABRRules. They take a parameter - rules collection object.
-
Added RulesController class that is responsible for storing, setting, adding and applying the rules.
-
BaseRulesCollection has been renamed into ABRRulesCollection in order to correspond its purpose and moved into "../streaming/rules/ABRRules" directory together with abr-related rules.