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

feat: prefetch audio languages. #6139

Merged
merged 14 commits into from Jan 29, 2024

Conversation

gkatsev
Copy link
Contributor

@gkatsev gkatsev commented Jan 22, 2024

Implements the behavior outlines in #6128.
Adds streaming.prefetchAudioLanguages and streaming.disableVideoPrefetch options.

Does not currently have disableAudioPrefetch and disableTextPrefetch.

Implements the behavior outlines in shaka-project#6128.
Adds `streaming.prefetchAudioLanguages` and `streaming.disableVideoPrefetch` options.

Does not currently have `disableAudioPrefetch` and `disableTextPrefetch`.
@gkatsev
Copy link
Contributor Author

gkatsev commented Jan 22, 2024

This is a draft PR because some tests are failing (they pass in our fork) but I wanted to get this out asap to get some eyes on them. I'll take a look into why tests are failing and fix them before adding in support for disableAudioPrefetch and disableTextPrefetch.

Copy link
Collaborator

@avelad avelad left a comment

Choose a reason for hiding this comment

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

Since it is not complete, I leave a first review with the things I have seen, but it looks good!

lib/media/segment_prefetch.js Outdated Show resolved Hide resolved
externs/shaka/player.js Show resolved Hide resolved
demo/config.js Outdated Show resolved Hide resolved
lib/media/streaming_engine.js Outdated Show resolved Hide resolved
lib/media/streaming_engine.js Outdated Show resolved Hide resolved
lib/media/streaming_engine.js Outdated Show resolved Hide resolved
lib/media/segment_prefetch.js Outdated Show resolved Hide resolved
@avelad avelad added type: enhancement New feature or request priority: P2 Smaller impact or easy workaround labels Jan 23, 2024
@avelad avelad added this to the v5.0 milestone Jan 23, 2024
@gkatsev
Copy link
Contributor Author

gkatsev commented Jan 23, 2024

Tests fixed. I also ran a quick check locally and seems to be working as expected, still. Next steps for this PR:

  • update the API for SegmentPrefetch
  • disable video segment prefetch if disableVideoPrefetch is enabled after playback began
  • add disableAudioPrefetch
  • add disableTextPrefetch
  • address demo config change

@gkatsev
Copy link
Contributor Author

gkatsev commented Jan 24, 2024

Noticed that if I enable disableVideoPrefetch after the fact, it doesn't disable it if previously enabled, so, another change that needs to happen.

@gkatsev
Copy link
Contributor Author

gkatsev commented Jan 24, 2024

Also, right now, segment prefetch never runs for text. createSegmentPrefetch only runs for VIDEO and AUDIO streams:

if (
stream.type !== shaka.util.ManifestParserUtils.ContentType.VIDEO &&
stream.type !== shaka.util.ManifestParserUtils.ContentType.AUDIO
) {

Given this, I'm inclined to skip disableTextPrefetch as enabling it would be a whole other feature.

@gkatsev gkatsev marked this pull request as ready for review January 26, 2024 00:43
@gkatsev
Copy link
Contributor Author

gkatsev commented Jan 26, 2024

I think this PR is ready for a proper review now.

* The maximum number of segments for each active stream to be prefetched
* ahead of playhead in parallel.
* If <code>0</code>, the segments will be fetched sequentially.
* Defaults to <code>0</code>.
* @property {!Array<string>} prefetchAudioLanguages
* The audio languages to prefetch.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switching is a lot faster if rebufferingGoal is set to a low value. Is this something worth noting here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not think it's necessary

Copy link
Collaborator

@avelad avelad left a comment

Choose a reason for hiding this comment

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

I'm going to push changes to your branch to correct these comments. Thank you!

if (!reference) {
return;
}
if (reference.initSegmentReference) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This if should be moved inside the while loop and take into account whether prefetchAllowed (I would move it to line 110-111)

return;
}
const currTime = startReference.startTime;
const maxTime = Math.max(currTime, this.prefetchPosTime_);
const iterator = this.stream_.segmentIndex.getIteratorForTime(maxTime);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I realized that this would not work for partial segments in HLS, so I am going to make a change so that it works as well.

@avelad
Copy link
Collaborator

avelad commented Jan 26, 2024

Please fix the tests

@gkatsev
Copy link
Contributor Author

gkatsev commented Jan 26, 2024

Tests fixed.

@avelad avelad merged commit a8ab0c8 into shaka-project:main Jan 29, 2024
11 of 15 checks passed
@gkatsev gkatsev deleted the prefetch-audio-languages branch January 29, 2024 07:58
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Mar 29, 2024
@shaka-project shaka-project locked as resolved and limited conversation to collaborators Mar 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: P2 Smaller impact or easy workaround status: archived Archived and locked; will not be updated type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants