-
Notifications
You must be signed in to change notification settings - Fork 131
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
[WIP] Add getLivePosition API and better handle availabilityTimeOffset for DASH #1300
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
peaBerberian
force-pushed
the
feat/getLiveEdge
branch
6 times, most recently
from
October 13, 2023 09:03
7b9cece
to
d3f0772
Compare
peaBerberian
force-pushed
the
next
branch
3 times, most recently
from
October 13, 2023 09:47
bedffb8
to
82033df
Compare
peaBerberian
force-pushed
the
feat/getLiveEdge
branch
from
October 13, 2023 09:50
d3f0772
to
6fff961
Compare
peaBerberian
added
the
Priority: 2 (Medium)
This issue or PR has a medium priority.
label
Nov 2, 2023
peaBerberian
commented
Nov 24, 2023
src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts
Outdated
Show resolved
Hide resolved
peaBerberian
force-pushed
the
feat/getLiveEdge
branch
from
December 1, 2023 18:44
8ac1b67
to
6bfaf7c
Compare
Florent-Bouisset
approved these changes
Dec 4, 2023
peaBerberian
added a commit
that referenced
this pull request
Dec 5, 2023
[WIP] Add getLivePosition API and better handle availabilityTimeOffset for DASH
peaBerberian
added a commit
that referenced
this pull request
Dec 5, 2023
[WIP] Add getLivePosition API and better handle availabilityTimeOffset for DASH
peaBerberian
added a commit
that referenced
this pull request
Dec 7, 2023
[WIP] Add getLivePosition API and better handle availabilityTimeOffset for DASH
peaBerberian
added a commit
that referenced
this pull request
Dec 19, 2023
[WIP] Add getLivePosition API and better handle availabilityTimeOffset for DASH
peaBerberian
added a commit
that referenced
this pull request
Dec 20, 2023
[WIP] Add getLivePosition API and better handle availabilityTimeOffset for DASH
peaBerberian
added a commit
that referenced
this pull request
Dec 22, 2023
[WIP] Add getLivePosition API and better handle availabilityTimeOffset for DASH
peaBerberian
added a commit
that referenced
this pull request
Jan 3, 2024
[WIP] Add getLivePosition API and better handle availabilityTimeOffset for DASH
peaBerberian
added a commit
that referenced
this pull request
Jan 3, 2024
[WIP] Add getLivePosition API and better handle availabilityTimeOffset for DASH
peaBerberian
added a commit
that referenced
this pull request
Jan 11, 2024
[WIP] Add getLivePosition API and better handle availabilityTimeOffset for DASH
peaBerberian
added a commit
that referenced
this pull request
Jan 15, 2024
[WIP] Add getLivePosition API and better handle availabilityTimeOffset for DASH
peaBerberian
added a commit
that referenced
this pull request
Jan 23, 2024
[WIP] Add getLivePosition API and better handle availabilityTimeOffset for DASH
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR improves several parts around the detection of the live edge of the content, especially when the DASH
availabilityTimeOffset
property is set, which may indicate that some segments announced in the MPD may or may not be ready to be fetched.It also adds the
getLivePosition
method to the RxPlayer, and allows for a more precize initial position choice by the RxPlayer when the live position is known.Gains are mostly for some ad-switched DASH contents and DASH low-latency live contents. Behavior should not change that much for other cases.
Set better initial position for live contents
Only when an explicit clock has been communicated to the RxPlayer (that is, either through
DASH
<UTCTiming>
elements or through theserverSyncInfos
loadVideo
option), we will now by default initially play dynamic DASH contents close to the current date indicated by that clock.Previously, rules were complex (and in a way they still are), but if segments were explicitely declared in the DASH MPD, we could consider the end of the last declared segment as the true live position, and thus begin playback close to it.
This is problematic in the rare scenario (but one that we encounter today) where the DASH MPD actually already includes segments that is intended to be played in the future (so, not now).
For example a trick exists when doing ad-switching, where you might want to declare all segments from an ad break in advance to simplify/optimize your back-end, but still want the player to start playback at a "live" position (and not close to that ad break's end like it would have done without this PR). Here, you thus want the player to not rely on the last segment's end to define its starting position - it would be beginning playback in the "future".
new
getLivePosition
APIA new API,
getLivePosition
, was added to let the RxPlayer communicate what the live edge of the content is.Previously
getMaximumPosition
filled that need. But now that we handle cases where segments further than the live position might already be loaded and seeked to, it seems thatgetMaximumPosition
should be set to the MPD's last requestable segment's end whereas a newgetLivePosition
method should be added so that an application can display to the user what the generally-intended maximum playable position is if playing further than live is forbidden (as it should be in most cases I guess).Sadly, for technical reasons detailed below, this method will only return a pertinent result in that aforementioned case if a clock has been explicitely communicated to the RxPlayer (again, either through
DASH
<UTCTiming>
elements or through theserverSyncInfos
loadVideo
option) for DASH contents.For all other cases, this value should be very close to or equal to what would have been returned by
getMaximumPosition
.availabilityTimeOffset
treatmentI realize that the
availabilityTimeOffset
attribute was never used when aSegmentTimeline
was present. In that case, we just always assumed that all segments announced in the MPD were directly available.This does not seem to be in accordance with DASH specs which seems to allow segments to be announced in the manifest BEFORE they can actually be requested.
I ended up relying on a complex behavior, which is not fully spec-compliant (I'm generally against this but hear me up :P), but which makes more sense for the DASH MPD we encounter in practice.
The behavior depends on multiple criteria, described below.
When it's a SegmentTimeline-based Representation:
If at least one of either the
availabilityTimeOffset
OR theavailabilityTimeComplete
attribute (or both) is linked to that Representation AND an explicit clock has been provided to the RxPlayer (either from anUTCTiming
element in the MPD or from theserverSyncInfos
loadVideo
option) we try at best to apply the specification or at least what I understood of it: only segments which are available up to their "adjusted availability start time" are available.Basically, we will only download a segment seen in the MPD if MPD attributes tells us that it should be fully available (which could be simplified as: when the clock +
availabilityTimeOffset
is equal or superior to that segment's end + theMPD@availabilityStartTime
).Moreover, the new
RxPlayer
sgetLivePosition
API will return the new value of the synchronized clock, as expected.If no
availabilityTimeOffset
noravailabilityTimeComplete
is explicitely set on the MPD for this Representation's segments, or if at least one of them is set BUT no explicit clock has been communicated to the RxPlayer, we just consider that all announced segments are available.This is NOT what I interpreted from the various DASH specs but it seems to be a more adapted logic relative to the contents I encountered.
The advantage of doing this is that we can request the last segments of an MPD even when the given clock is not synchronized to the server's, with the assumption that segments announced in the MPD are only available segments.
The main disadvantage of doing this is that we may request segments which are not considered to be requestable yet but which are in the MPD.
If this does happen in the future for any content, I may correct this behavior, but for now, it seems that announcing future segments is mainly done either for low-latency contents or ad-switching where the
availabilityTimeOffset
attribute seems to be set.This is why this special behavior is only enabled when
availabilityTimeOffset
andavailabilityTimeComplete
are NOT found, in which case we assume that it is just a "regular" content, or when no clock is provided in which case we assume that the user's clock is unreliable.Also in that case, the new
RxPlayer
'sgetLivePosition
API may weirdly return a position based on the maximum segment's end encountered on the last refreshed manifest, which may be completely wrong.When it's a SegmentTemplate without SegmentTimeline Representation:
The rules I understood from the DASH specs are always applied, only they are based on the perhaps-unsynchronized
Date.now()
-based cliend-side clock if no clock was explicitely communicated to the RxPlayer (again, either from anUTCTiming
element in the MPD or from theserverSyncInfos
loadVideo
option).In that case, the new
RxPlayer
'sgetLivePosition
API will be based on the user clock.We're forced to rely on the user's clock here, as no segment are listed when no
SegmentTimeline
is present in the MPD.When it's any other segment indexing scheme:
In reality, rules are even more complex because we may have a mix of SegmentTimeline and SegmentTemplate without SegmentTimeline in the same MPD, but describing the whole logic in details would be too long here.