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

Improve track index adjustment logic by adding index comparison #436

Merged

Conversation

jaeho-lee104
Copy link
Contributor

If the conditions are not suitable, it will use the value of the previousSelectedIndex.
so if the previousSelectedIndex and newSelectedIndex are the same, there is no need to perform that logic.

current implementation

if (!isTrackExcluded(previousSelectedIndex, nowMs)) {
  // Revert back to the previous selection if conditions are not suitable for switching.
  Format currentFormat = getFormat(previousSelectedIndex);
  Format selectedFormat = getFormat(newSelectedIndex);
  long minDurationForQualityIncreaseUs =
      minDurationForQualityIncreaseUs(availableDurationUs, chunkDurationUs);
  if (selectedFormat.bitrate > currentFormat.bitrate
      && bufferedDurationUs < minDurationForQualityIncreaseUs) {
    // The selected track is a higher quality, but we have insufficient buffer to safely switch
    // up. Defer switching up for now.
    newSelectedIndex = previousSelectedIndex;
  } else if (selectedFormat.bitrate < currentFormat.bitrate
      && bufferedDurationUs >= maxDurationForQualityDecreaseUs) {
    // The selected track is a lower quality, but we have sufficient buffer to defer switching
    // down for now.
    newSelectedIndex = previousSelectedIndex;
  }
}

@google-cla
Copy link

google-cla bot commented Jun 2, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jaeho-lee104
Copy link
Contributor Author

@oceanjules @tianyif Hi, thanks for reviewing this pull request.
Have been waiting on a response for some time now.
Please let me know if there is anything I need to do. Thanks.

@tianyif
Copy link
Contributor

tianyif commented Jun 16, 2023

I'm going to send this for internal review now. You may see some more commits being added as I make changes in response to review feedback. Please refrain from pushing any more substantive changes as it will complicate the internal review - thanks!

@tianyif
Copy link
Contributor

tianyif commented Jun 16, 2023

This change has been submitted to the internal repo, you will see it appear in the dev branch next week. No action required at this point. Thanks for the contribution!

@jaeho-lee104
Copy link
Contributor Author

Thanks for the comment.
Thanks!

@marcbaechinger marcbaechinger merged commit af69d58 into androidx:main Jun 19, 2023
tianyif pushed a commit that referenced this pull request Aug 14, 2023
PiperOrigin-RevId: 540875285
(cherry picked from commit af69d58)
@androidx androidx locked and limited conversation to collaborators Aug 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants