-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Developer Getting Started Guide
Daniel Silhavy edited this page Jan 23, 2024
·
9 revisions
- Please start by making sure you have read the README.md
- Follow the code standards set by the
.eslintrc
config. - Make sure you run
npm run build
before you commit so that you may catch test failures, lint issues, or syntax errors. - Check the
package.json
for the available commands and scripts.
- You will notice a certain folder structure inside or src/
-
/streaming
: agnostic code to the MPEG-DASH specification. You will not find any terms like Period or AdaptationSet in this code. This was done so other streaming technologies like MicroSoft Smooth Streaming or HLS could be implemented by extending on the code from /streaming. You will find general scheduling logic, ABR rules and system logic in this folder. -
/dash
: Code specific to the DASH specification. You will find all the DASH centric logic in this layer including segment template, index and timeline logic. You will find DASH manifest parser at this layer as well. -
/mss
: Code specific to Microsoft Smooth Streaming.
-
This class is a critical factory responsible for the creation of all the objects initialized by calling
player.create()
-
At the bottom of every file in the project, you will see some FactoryMaker logic. Please get familiar with this code. If you add a singleton or a class, you will need to follow this method.
-
This is an example of MediaPlayerModel.js being created as a singleton.
MediaPlayerModel.__dashjs_factory_name = 'MediaPlayerModel';
export default FactoryMaker.getSingletonFactory(MediaPlayerModel);
- This is an example of MediaPlayer.js being created as a class.
const factory = FactoryMaker.getClassFactory(MediaPlayer);
export default factory;
- This is an example of how you can expose class CONST or other objects to the rest of the codebase.
// Take note of how we expose the public event class from mediaplayer.
// More info in EVENTS section.
factory.events = MediaPlayerEvents;
factory.DEFAULT_UTC_TIMING_SOURCE = DEFAULT_UTC_TIMING_SOURCE;
- Finally, All objects need a reference name, so you look up object post creation to extend or override.
MediaPlayer.__dashjs_factory_name = 'MediaPlayer';
- Main entry point to the project and is responsible for initialization.
- Main API layer and acts like a facade to the streaming library.
- All public API is listed in the instance object.
- Uses MediaPlayerModel.js to hold state for configurations set via API.
- Exposes events to player developer via MediaPlayer.events.<EVENT_NAME>.
- EventBus.js -
- Event Aggregation system
- public_
- Events.js vs
- CoreEvents vs MediaPlayerEvents vs ProtectionEvents.
- There is a Stream instance for every period in the MPD. Created by the StreamController.
- StreamController will handle the transition to the next stream if there are multiple periods.
- StreamController flush metrics for the stream upon ending.
- StreamController will open and close new media sources for each period.