Skip to content
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

FEC-8975 QoS data enhancement #72

Merged
merged 6 commits into from
Jun 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/dash-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,17 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
this._shaka.addEventListener(ShakaEvent.BUFFERING, this._adapterEventsBindings.buffering);
this._videoElement.addEventListener(EventType.WAITING, this._adapterEventsBindings.waiting);
this._videoElement.addEventListener(EventType.PLAYING, this._adapterEventsBindings.playing);
// called when a resource is downloaded
this._shaka.getNetworkingEngine().registerResponseFilter((type, response) => {
switch (type) {
case shaka.net.NetworkingEngine.RequestType.SEGMENT:
this._trigger(EventType.FRAG_LOADED, {miliSeconds: response.timeMs, bytes: response.data.byteLength});
break;
case shaka.net.NetworkingEngine.RequestType.MANIFEST:
this._trigger(EventType.MANIFEST_LOADED, {miliSeconds: response.timeMs});
break;
}
});
}

/**
Expand Down Expand Up @@ -875,4 +886,27 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
return 0;
}
}

/**
* gets the target buffer of the player
* @returns {number} - buffer length target in seconds
*/
get targetBuffer(): number {
let targetBufferVal = NaN;
if (!this._shaka) return NaN;
if (this.isLive()) {
if (this._shaka.getManifest()) {
targetBufferVal =
this._shaka.getManifest().presentationTimeline.getSegmentAvailabilityEnd() -
this._shaka.getManifest().presentationTimeline.getSeekRangeEnd() -
(this._videoElement.currentTime - this._getLiveEdge());
targetBufferVal = Math.min(targetBufferVal, this._shaka.getConfiguration().streaming.bufferingGoal);
}
} else {
if (this._shaka.getConfiguration() && this._shaka.getConfiguration().streaming) {
targetBufferVal = this._shaka.getConfiguration().streaming.bufferingGoal;
}
}
return targetBufferVal;
}
}