Skip to content

Developer Getting Started Guide

Dan Sparacio edited this page May 11, 2017 · 9 revisions

General Tips

  • Please start by making sure you have read the README.md
  • Follow the code standards set by the .jscsrc config.
  • Just run grunt debug quick build during dev.
  • Make sure you run grunt before you commit so that you may catch test failures, lint issues, or syntax errors.

Project Structure

  • 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.

FactoryMaker

  • 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 FactoryMarker 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.

let factory = FactoryMaker.getSingletonFactory(MediaPlayerModel);
export default factory;
  • This is an example of MediaPlayer.js being created as a class.
let 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.
factory.events = MediaPlayerEvents; (Take note of how we expose the public event class from mediaplayer.  More info in section EVENTS.)
factory.DEFAULT_UTC_TIMING_SOURCE = DEFAULT_UTC_TIMING_SOURCE;
  • Finally, All objects need a reference name so you lookup object post creation to extend or override.
MediaPlayer.__dashjs_factory_name = 'MediaPlayer';

MediaPlayer

  • Is the main entry point to the project and is responsible for initialization.
  • Is the 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 the MediaPlayer.events.<EVENT_NAME> syntax

Events

  • EventBus.js
  • Event Aggregation system
  • public_
  • Events.js vs
  • CoreEvents vs MediaPlayerEvents vs ProtectionEvents.

Stream, StreamController, StreamProcessor

  • There is a Stream instance created for every period 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.

ScheduleController

BufferController, SourceBufferController

ABR

Clone this wiki locally