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

fix(HLS): Fix load of LL-HLS when the partial segment is not independent #5277

Merged
merged 3 commits into from
Jun 12, 2023

Conversation

avelad
Copy link
Member

@avelad avelad commented Jun 9, 2023

No description provided.

@avelad avelad added type: bug Something isn't working correctly component: HLS The issue involves Apple's HLS manifest format priority: P1 Big impact or workaround impractical; resolve before feature release labels Jun 9, 2023
@avelad avelad added this to the v4.4 milestone Jun 9, 2023
@@ -1262,6 +1262,17 @@ shaka.media.StreamingEngine = class {
mediaState.stream.segmentIndex.getIteratorForTime(presentationTime);
ref = mediaState.segmentIterator &&
mediaState.segmentIterator.next().value;
// For LL-HLS we need to find the nearest INDEPENDENT segment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh hey, while examining this code, I found a JSDoc problem!

In the definition for shaka.media.StreamingEngine.MediaState_, we refer to segmentIterator as being a shaka.media.SegmentIndexIterator object at one point. That should be shaka.media.SegmentIterator

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the definition is true, because it's used in other parts and it works, It's a private definition

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason that it works is that the JSDoc lists it as a shaka.media.SegmentIndexIterator, but the @typedef above correctly lists it as a shaka.media.SegmentIterator. I think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure... but it works :S

let attempt = 0;
const maxAttempts = 5;
while (ref && !ref.isIndependent() && attempt < maxAttempts) {
const newTime = ref.startTime - 0.1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is looking back 0.1s 5 times the correct way to do this?

Looking at Apple's sample manifest here:
https://developer.apple.com/documentation/http-live-streaming/enabling-low-latency-http-live-streaming-hls
They only seem to have an INDEPENDENT part every 1.3 seconds at best. So this might potentially miss an independent part, depending on the exact time this falls on, right?

If it's possible to have a part that has a duration that is <100ms, this approach could also be a problem the other way; that is to say, there might be the potential of "skipping over" the independent part.

Copy link
Member Author

@avelad avelad Jun 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, It's going to back 5 times, but from previous start time less 0.1 second to find the previous segment. Example:

  • Segment 1 --> StartTime 0 EndTime 1, INDEPENDENT
  • Segment 2 --> StartTime 1 EndTime 2
  • Segment 3 --> StartTime 2 EndTime 3

If presentationTime = 3;
initial choice = Segment 3
1st loop
2-0.1 --> Segment 2
2nd loop
1-0.1 --> Segment 1 INDEPENDENT

So the loop is not 0.1 * 5ms, depends of previous segments

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see what you mean. I hadn't been thinking about it correctly.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2023

Incremental code coverage: 76.67%

@avelad avelad requested a review from theodab June 9, 2023 16:21
@@ -1262,6 +1262,17 @@ shaka.media.StreamingEngine = class {
mediaState.stream.segmentIndex.getIteratorForTime(presentationTime);
ref = mediaState.segmentIterator &&
mediaState.segmentIterator.next().value;
// For LL-HLS we need to find the nearest INDEPENDENT segment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason that it works is that the JSDoc lists it as a shaka.media.SegmentIndexIterator, but the @typedef above correctly lists it as a shaka.media.SegmentIterator. I think?

let attempt = 0;
const maxAttempts = 5;
while (ref && !ref.isIndependent() && attempt < maxAttempts) {
const newTime = ref.startTime - 0.1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see what you mean. I hadn't been thinking about it correctly.

@avelad avelad merged commit ed5915e into shaka-project:main Jun 12, 2023
@avelad avelad deleted the hls-ll-independent-segments branch June 12, 2023 10:04
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Aug 11, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: HLS The issue involves Apple's HLS manifest format priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants