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

DASH: Fix Period overlap resolution logic for when the first Period is removed #1311

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

peaBerberian
Copy link
Collaborator

@peaBerberian peaBerberian commented Nov 7, 2023

Some streaming technologies/protocols such as DASH have a concept of Period, which is a temporal subpart of the content with its own tracks, qualities and other characteristics. You can think of it for example as various programs in a contents, some having multiple audio languages and subtitles, other not.

In the RxPlayer, Period are meant to be non-overlapping, to always rely on a single known list of available tracks (for audio, video and text) and available qualities at any given position.
This means that you may have a Period from the position 10 (let's say seconds) to 20, then from 20 to 30, but never something like from position 10 to 25 then from 20 to 30, as the 20-25 interval would be ambiguous regarding its available tracks and qualities: the two Periods are competing for it, which one should the RxPlayer consider at e.g. position 22?

Because the RxPlayer does not control the server providing the content, it has safe guards ensuring that Periods do not overlap, and in the rare cases where they do, has an algorithm to resolve such overlaps.

Usually we give in that algorithm more priority to the later Periods (for example it makes sense for a live content, where a later Period most likely has been produced later and might thus be an updated version of the content if conflicting at some timecodes with a previous Period).

We found out however that there was a bug in that code for when the initial Period was removed due to a later Period completely overlapping it (meaning: the later Period starts at the same time or before the initial Period).

This PR fixes this, and adds a test for it.

This may be seen as a very rare situation, and it is as we just encountered for the first time lately, and most likely indicative of an issue at the back-end-side: why would a Period scheduled for later begins before (or at) a previous Period's start?

It turns out that this is a trick made by some packagers in some ad-switching scenarios, to dynamically remove an ad from a content once it has been completely watched and replace it with the original content - which may even begin before the start of the now removed ad.

Some streaming technologies/protocol, such as DASH, have a concept of
`Period`, which is a temporal subpart of the content with its own tracks
and qualities.

In the RxPlayer, Period are meant to be non-overlapping, to always rely
on a single known list of available tracks (for audio, video and text)
and available qualities at any given position.
This means that you may have a Period from the position `10` (let's say
seconds) to `20`, then from `20` to `30`, but never something like from
position `10` to `25` then from `20` to `30`, as the `20-25` interval
would be ambiguous regarding its available tracks and qualities: the two
Periods are competing for it, which one should the RxPlayer consider
here?

Because the RxPlayer does not control the server providing the content,
it has safe guards ensuring that Periods do not overlap, and in the rare
cases where they do, has an algorithm to resolve such overlaps.

Usually we give in that algorithm more priority to the later Periods
(for example it makes sense for a live content, where a later Period
most likely has been produced later and might thus be an updated
version of the content if conflicting at some timecodes with a
previous Period).

We found out however that there was a bug in that code for when the
initial Period was removed due to a later Period completely overlapping
it (meaning: the later Period starts at the same time or before the
initial Period).

This commit fixes this, and add a test for it.

This may be seen as a very rare situation, and it is as we just
encountered for the first time lately, and most likely
indicative of an issue at the back-end-side: why would a Period encoded
later begins before (or at) a previous Period's start?

It turns out that this is a trick made by some packagers in some
ad-switching scenarios, to dynamically remove an ad from a content once
it has been completely watched and replace it with the original
content - which may even begin before the start of the now removed ad.
@peaBerberian peaBerberian added the Priority: 1 (High) This issue or PR has a high priority. label Nov 7, 2023
@peaBerberian peaBerberian added this to the 3.33.0 milestone Nov 7, 2023
@peaBerberian peaBerberian added the bug This is an RxPlayer issue (unexpected result when comparing to the API) label Nov 7, 2023
@peaBerberian peaBerberian changed the title Fix Period overlap resolution logic for when the first Period is removed DASH: Fix Period overlap resolution logic for when the first Period is removed Nov 7, 2023
@peaBerberian peaBerberian merged commit d1fde0d into master Nov 13, 2023
5 checks passed
@peaBerberian peaBerberian deleted the fix/overlapping-first-period branch January 5, 2024 13:57
@peaBerberian peaBerberian restored the fix/overlapping-first-period branch January 5, 2024 13:57
@peaBerberian peaBerberian mentioned this pull request Jan 24, 2024
@peaBerberian peaBerberian deleted the fix/overlapping-first-period branch February 7, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is an RxPlayer issue (unexpected result when comparing to the API) Priority: 1 (High) This issue or PR has a high priority.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants