Skip to content

Commit

Permalink
Timeline and multiperiod optimizations (Dash-Industry-Forum#3413)
Browse files Browse the repository at this point in the history
* Add key session updated event and enable reuse of sourcebuffers via settings flag

* WiP

* WiP: Commong DVR window for all periods

* Rename methods

* Remove LiveEdgeFinder.js

* Remove setExpectedLiveEdge and getExpectedLiveEdge

* Fix unit tests

* Fix linting error

* Add additional unit tests for availabilityWindow calculation

* Add missing return value

* Adjust Settings.js

* Adjust timeline calculation for availability window and dvr window

* Adjust segment availability calculation

* Use timeshift window as DVR window instead of availability windo

* Use allowed gap length as tolerance for buffer level estimation

* updateCurrentTime when representation update failed

* Adjust segmentAvailability calculation to use availabilityWindow

* Fix the representation update errors for multiperiod

* Fix segment availability calculation

* Small adjustments for segment availability calculation

* Add timeline manifest drift

* VoD onEnded fixes

* Only set the initial live edge once after startup.

* Remove hasDiscontinuities handling as we have gap handling as this can lead to an endless loop at period boundaries

* Support availabilityTimeOffset set to Inf

* Add unit tests for TimelineConverter.js

* Adjust live start logic for SegmentTemplate using DVRwindow.

* Fix MPD anchors for multiperiod static

* Calculate DVR window using segmenttimeline

* Adjust calculation of time for dynamic streams

* Remove gap checking in SourceBufferSink.js

* Use lastSeekWasInternal instead of removing event listener

* Adjust unit tests

* Add unintened removal again

* Small change in timeline DVR window calculation

* Fix a bug in the DVR window calculation for timeline

* No gap jump when track change is in progress

* Fix audio switch for multiperiod prebuffered streams

* Fix errors in TimelineConverter.js and add additonal unit tests

* Update StreamMock.js

* Fix linting errors and unit tests

* Fix a bug in AbrController.js

* WiP: Enable preloading after seeking between periods

* Fix bug in event presentation time calculation

* Remove gap check in SourceBufferSink.js

* prune buffer when seek causes a period switch

* Fix Buffer.abort call for multiperiod streams

* Fix stalling problem for multiperiod multi audio when seeking between periods

* Fix linting errors and unit tests

* Remove some stuff in SourceBufferSink.js

* Minor formatting changes

* Separate init handling in PlaybackController.js after period switch

* Fix seg.replacementTime for $time and SegmentTemplate

* Subtract duration of one segment from availability window

* No need to subtract duration when calculating the avail window as we use the duration of the segment in SegmentsUtils.js

* Small linting fix in AbrController.js

* Distinguish between inner and outer period seeking to call specific seeking handler

* Small refactoring in StreamController.js

* Adjust seek to stream end logic in gap controller

* Small adjustment in GapController.js

* Use index of buffered ranges for gap jumping

* Internal seek only if next stream is prebuffered

* Fix a bug when seeking between periods. If some buffers are already pruned we can fire BUFFER_CLEARED_FOR_STREAM_SWITCH immediately

* Fix a bug which lead to multiple stream switches when seeking

* Fix a bug which lead to multiple stream switches when seeking

* Fix calculation segmentReplacementTime for Template streams

* Fix a bug in the GapController.js

* Call updateCurrentTime when wallclock time is updated

* Fix audio switch in multiperiod streams

* wip audio switch when preloading streams

* Deactivate preloading streams when switching a track

* Wait for the now time to reach AST + Perio@start before starting playback

* Wait for the now time to reach AST + Perio@start before starting playback

* Adjust availabilityWindow calculation. The availability window is allowed to be larger than the period boundary.

* Reset isEndedEventSignaled when switching stream

* Add stream id specific handling in BufferController.js

* Remove comment

* Do not maintain an availabilityWindow, instead use SAST and SAET to calculate whether a segment can be downloaded or not.

* Do not cann updateCurrentTime if there is already a seek going on

* GapController.js stalls before seeking over gaps in a livestream. Otherwise we move too close to the end of the DVR window. Need to maintain a consistent live edge.

* Reset gap timneout when seeking is done

* WiP: Multiperiod gap handling and falsy termination of streams

* WiP: Rewrite of the seek and buffer pruning logic

* Fix and uncomment some of the unit tests

* Fix linting errors

* Fix missing values

* Add required changes to calculate start times in StreamController.js

* Minor bugfixes

* Adjust _checkIfPrebufferingCanStart logic. No need to calculate AST in StreamController.js this is handled by the scheduling logic

* Minor refactoring and cleanup

* Adjust prebuffering logic

* Add Elemental test streams

* Remove unnecessarily exposed methods and rename buffer variables

* Add setting to disable init segment caching

* Rename append init function

* Fix unit tests

* Add additional JSDoc

* Fix: Add dispatching of mediatype and streamId to SourceBufferSink.js otherwise segment scheduling logic is broken.

* WiP: Adjust seeking logic

* WiP: Adjust seeking logic

* Fix bug in the timline calculation with negative @r parameter

* WiP: Fix outer period seeking

* Minor refactoring

* Wip: Rework buffering completed logic

* Add protdata to ProtectionController when updating in StreamController.js

* Add missing streamId for ABR calculation

* Fix wrong method naming

* Remove unnecessary values in ScheduleController.js hasTopQualityChanged

* Add missing streamId parameters in calls to AbrController.js methods

* Fix linting errors

* Rewrite scheduling logic

* WiP : Rewrite logic to determine if scheduling is finished

* WiP : Rewrite logic to determine if scheduling is finished

* Fix cancelation of segment request at startup

* WiP: Simplify scheduling logic

* WiP: Simplify scheduling logic

* Simplify scheduling logic

* WiP: Outer period seek

* Fix outer period seek

* Fix preloading in case video is already buffered but audio is still missing some parts

* Add small offsets to append window

* Subtract small offset from waiting time when jumping gaps

* Subtract UTC offset instead of adding it

* WiP: Support track switching again

* WiP: Seeking still causes minor issues. Move to promise based buffer handling

* Working seeks, maybe some minor edge cases left

* WiP: Move to promise based BufferController.js and SourceBufferSink.js

* Add additional promises

* Fix additional seeking bugs

* Fix audio track switch

* Account for quota exceeded error

* Small adjustments in SourceBufferSink.js

* Use TRACK_CHANGE_RENDERED event in GapController.js

* Start working on SegmentBase support

* WiP: Fix SegmentBase and SegmentList

* Fix missing TimelineConverter in SegmentsController

* Fix SegmentBase

* Small changes to SegmentBase logic and bump of version number

* Fix a bug in the SourceBufferSink.js that lead to chunks not being appended

* Repair Thumbnails

* Fix external VTT

* Fix TTML segmented VoD

* Fix sideloaded and fragmented TTML

* Small improvement in TextController.js

* WiP: Fix fragmented tracks for multiperiod

* Fix wrong mime type when switching tracks

* Remove prebuffering comment

* Fix race condition when switching audio language

* Fix a bug for multiperiod fragmented texts.

* Fix MSE reinit error after loading a new stream

* Fix DroppedFramesRule.js for multiperiod

* ABR changes and reduce scheduling timeout

* Add max index downloading

* Proper AbrController.js resets

* WiP: Fix embedded text tracks

* Save sources.json

* Fix CEA608 captions

* Fix bug in DashAdapter.js caused by capability filtering. DashAdapter.js should always build voAdaptation based on data in DashManifestModel

* Fix track switch if existing track is not to be replaced

* Initial support for initialBufferLevel

* Further improvements for initialBufferLevel

* Fix a bug in subtitle switching

* Compare codecs in isTracksEqual

* Compare codecs in isTracksEqual

* Fix thumbnails for SegmentTimeline with $time

* Add pruneAllSafely to NotFragmentedTextBufferController.js

* Add MediaCapabilitiesAPI

* WiP: Optimize Textrack switching in multiperiod

* Fix custom capabilities filter

* Readd some stuff that has been removed while merging development

* Minimal cleanup of MediaPlayer.js

* Fix linting errors

* Fix a bug in updateCurrentTime. Always use a media type to get the DVR window. Otherwise issues with removing media types in the CapabilitiesFilter

* Fix a bug in the GapController.js leading to unwanted gap jumps once a stream has been completely buffered and the user is seeking back

* WiP: TextController changes. Only one TextController which handles all periods

* Fix two subtitle bugs

* Fix linting errors

* Retrigger init request in case no valid request could be made

* Minor cleanups in ScheduleController.js and BufferController.js

* Fix a bug in the TextController.js for multiperiod streams with texttracks

* WiP: Fix unit tests

* Fix unit test for DashAdapter.js

* Fix unit tests for SegmentBaseLoader.js

* Fix unit tests

* Fix unit tests for streaming.Stream.js

* Fix unit tests for AbrController.js

* Fix unit tests for streaming.controllers.BufferController.js

* Small refactoring and additional fixes for unit tests

* Add streamInfo check to TextController.js

* Fix unit tests in streaming.controllers.SourceBufferSink.js

* Rework MediaCapabilities check

* Fix unit tests for streaming.controllers.StreamController.js , streaming.Stream.js, streaming.models.FragmentModel.js

* Additional unit test and linting fixes

* Update version number in package-lock.json

* Fix typo in sample

* WiP: Restructure Settings.js

* Minor settings parameter changes

* Cleanup sources.json

* Fix track change for tracks that are completely buffered. Preloading needs to be triggered again.

* Fix display of metric values in reference UI for multiperiod content
  • Loading branch information
dsilhavy committed Apr 23, 2021
1 parent 3b6897c commit a66913f
Show file tree
Hide file tree
Showing 136 changed files with 9,584 additions and 7,595 deletions.
308 changes: 185 additions & 123 deletions contrib/akamai/controlbar/ControlBar.js

Large diffs are not rendered by default.

534 changes: 371 additions & 163 deletions index.d.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dashjs",
"version": "3.2.2",
"version": "4.0.0",
"description": "A reference client implementation for the playback of MPEG DASH via Javascript and compliant browsers.",
"author": "Dash Industry Forum",
"license": "BSD-3-Clause",
Expand Down
45 changes: 29 additions & 16 deletions samples/advanced/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@

<script>
var player;

function init() {
var video,
url = "https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd";
url = 'https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd';

video = document.querySelector("video");
video = document.querySelector('video');
player = dashjs.MediaPlayer().create();
player.initialize(video, url, true);

applySettings()

player.on(dashjs.MediaPlayer.events["PLAYBACK_ENDED"], function() {
player.on(dashjs.MediaPlayer.events['PLAYBACK_ENDED'], function () {
clearInterval(eventPoller);
});

var eventPoller = setInterval(function() {
var eventPoller = setInterval(function () {
var streamInfo = player.getActiveStream().getStreamInfo();
var dashMetrics = player.getDashMetrics();
var dashAdapter = player.getDashAdapter();
Expand All @@ -35,8 +36,8 @@
var repSwitch = dashMetrics.getCurrentRepresentationSwitch('video', true);
var bufferLevel = dashMetrics.getCurrentBufferLevel('video', true);
var bitrate = repSwitch ? Math.round(dashAdapter.getBandwidthForRepresentation(repSwitch.to, periodIdx) / 1000) : NaN;
document.getElementById('currentBufferLevel').innerText = bufferLevel + " secs";
document.getElementById('reportedBitrate').innerText = bitrate + " Kbps";
document.getElementById('currentBufferLevel').innerText = bufferLevel + ' secs';
document.getElementById('reportedBitrate').innerText = bitrate + ' Kbps';
}
}, 1000);
}
Expand All @@ -52,8 +53,10 @@

player.updateSettings({
'streaming': {
'stableBufferTime': stableBuffer,
'bufferTimeAtTopQualityLongForm': bufferAtTopQuality,
'buffer': {
'bufferTimeAtTopQualityLongForm': bufferAtTopQuality,
'stableBufferTime': stableBuffer
},
'abr': {
'minBitrate': {
'video': minBitrate
Expand All @@ -80,6 +83,7 @@
fieldset {
width: 70%;
}

fieldset > div {
margin-top: 20px;
}
Expand All @@ -94,38 +98,47 @@
<body>
<div id="container">
<div class="video-container">
<video data-dashjs-player autoplay controls="true">
<video data-dashjs-player autoplay controls="true">
</video>
</div>
<fieldset>
<legend>Configuration parameters</legend>
<div>
Max stable buffer (seconds): <input type="number" id="stableBuffer" value="20"> (Current Buffer: <span id="currentBufferLevel")>0</span> seconds)
<div class="description">The time that the internal buffer target will be set to post startup/seeks (NOT top quality).</div>
Max stable buffer (seconds): <input type="number" id="stableBuffer" value="20"> (Current Buffer: <span
id="currentBufferLevel" )>0</span> seconds)
<div class="description">The time that the internal buffer target will be set to post startup/seeks (NOT top
quality).
</div>
</div>
<div>
Buffer lenght at top quality (seconds): <input type="number" id="topQualityBuffer" value="20">
<div class="description">The time that the internal buffer target will be set to once playing the top quality.</div>
<div class="description">The time that the internal buffer target will be set to once playing the top
quality.
</div>
</div>
<div>
Max selectable bitrate (Kbps): <input type="number" id="maxBitrate" value="5000"> (Downloading bitrate: <span id="reportedBitrate")>0</span>)
<div class="description">The maximum bitrate selectable by the ABR algorithms will choose. Use -1 for no limit.</div>
Max selectable bitrate (Kbps): <input type="number" id="maxBitrate" value="5000"> (Downloading bitrate:
<span id="reportedBitrate" )>0</span>)
<div class="description">The maximum bitrate selectable by the ABR algorithms will choose. Use -1 for no
limit.
</div>
</div>
<div>
Min selectable bitrate (Kbps): <input type="number" id="minBitrate" value="-1">
<div class="description">The minimum bitrate that the ABR algorithms will choose. Use -1 for no limit.</div>
</div>
<div>
Limit Bitrate By Portal Size: <input type="checkbox" id="limitByPortal">
<div class="description">If true, the size of the video portal will limit the max chosen video resolution.</div>
<div class="description">If true, the size of the video portal will limit the max chosen video resolution.
</div>
</div>
<div>
<button onclick="applySettings()">Apply changes</button>
</div>
</fieldset>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
document.addEventListener('DOMContentLoaded', function () {
init();
});
</script>
Expand Down
1 change: 0 additions & 1 deletion samples/captioning/caption_vtt.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

player = dashjs.MediaPlayer({}).create();
player.initialize(video, url, true);
player.setTextDefaultEnabled(true);
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion samples/captioning/multi-track-captions.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

function setTextDefaultEnabled() {
var checkbox = document.getElementById("textDefaultEnabled");
player.setTextDefaultEnabled(checkbox.checked);
player.updateSettings({streaming: {text: {defaultEnabled: checkbox.checked}}});
}

function setLang() {
Expand Down
1 change: 0 additions & 1 deletion samples/captioning/ttml-ebutt-sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

player = dashjs.MediaPlayer().create();
player.initialize(videoElement, url, true);
player.setTextDefaultEnabled(true);
player.attachTTMLRenderingDiv(TTMLRenderingDiv);
controlbar = new ControlBar(player); // Checkout ControlBar.js for more info on how to target/add text tracks to UI
controlbar.initialize();
Expand Down
Loading

0 comments on commit a66913f

Please sign in to comment.