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

Add Quality Selection to Playback Overlay #1924

Merged
merged 19 commits into from
Sep 13, 2022

Conversation

zkhcohen
Copy link
Contributor

@zkhcohen zkhcohen commented Aug 2, 2022

Changes

  1. Added quality selection (max bitrate) menu to playback overlay.
  2. Added PlaybackController.refreshSteam() function to restart a stream when transcoding options are changed.
  3. Fixed Mbit/s to Kbit/s conversion factor (100 -> 1000).
  4. Fixed unusual Mbit/s increment (21Mbit/s -> 20Mbit/s).

This PR builds off of #1302 using my very limited understanding of Kotlin, implementing VideoQualityController / SelectQualityAction.

As a result of this change, it was necessary to implement the function PlaybackController.refreshSteam() in order to restart the stream when the setting is changed, applying the new setting.

During this change, it was also noted that the Mbit/s to Kbit/s conversion factor was incorrect (x100), and an unusual quality increment had been added to the settings menu (21 Mbit/s). These have been fixed.

Issues
May satisfy these vague enhancements:

Testing

  • Try changing quality settings through the playback menu. You should be able to verify that the media is being transcoded through the logs / dashboard.
  • Try playing a different video - the settings should persist.
  • Open the settings -> playback menu through the main menu - the settings configured through the overlay should persist there.
  • Change the quality in the settings -> playback menu through the main menu, then open both menus in the playback overlay - the settings should persist and you should be able to verify that the media is being transcoded through the logs / dashboard.

@zkhcohen
Copy link
Contributor Author

zkhcohen commented Aug 2, 2022

@nielsvanvelzen @mueslimak3r I removed the transcoding settings from #1406 and built this off of the new v0.14.0 release for Jellyfin 10.8.1.

Everything appears to be working as expected, but the audio transcoding options still fail, so they will be added to a separate branch / PR in the future.

@nielsvanvelzen nielsvanvelzen added this to the v0.15.0 milestone Aug 2, 2022
@mueslimak3r
Copy link
Member

I'll test and review tonight or tomorrow

Copy link
Member

@mueslimak3r mueslimak3r left a comment

Choose a reason for hiding this comment

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

Nice work!
The UI button looks nice.
Quality switching during playback works well.
The addition of refreshStream() and its use is good, and it mirrors how a stream is reloaded in a couple other places.
I'm not really qualified to review the kotlin code.

Other than some minor changes it looks good. 🙂

@zkhcohen
Copy link
Contributor Author

zkhcohen commented Aug 5, 2022

Suggestions implemented and tested.

Clearly I don't understand GitHub PR diff behavior because my rebase has integrated changes into the diff which are already merged with master. It seems like it's using the common ancestor in the diff instead of resetting to the tip of the target branch rebased with.

If this is an issue, let me know how you're handling this.

@mueslimak3r
Copy link
Member

It's a little hard to tell exactly how it happened but it looks like you merged two copies of your branch together but they have different bases. Assuming the most recent merge commit is responsible, and that the branches are the same (so discarding the "merged-from" one won't lose any code, you could try checking out the commit prior to that and force-pushing. Definitely back up first though since that's just a guess.

If I were to guess what happened, it may be due to not syncing your remote and local branches at some point and then merging them. 🤷

I've attached screenshots from gitkraken that made it a little easier to visualize what's going on.

Screen Shot 2022-08-07 at 5 35 53 PM

@zkhcohen
Copy link
Contributor Author

zkhcohen commented Aug 9, 2022

If I were to guess what happened, it may be due to not syncing your remote and local branches at some point and then merging them. 🤷

Yes, you're correct.

I fixed this issue and implemented some fixes suggested by the code scanner.

Re-tested after #1943 was merged and everything is working as expected.

This should be good to go, pending final approval.

@nielsvanvelzen nielsvanvelzen added the enhancement New feature or request label Aug 11, 2022
@nielsvanvelzen nielsvanvelzen self-requested a review August 21, 2022 20:23
@zkhcohen zkhcohen requested review from nielsvanvelzen and mueslimak3r and removed request for nielsvanvelzen and mueslimak3r September 11, 2022 19:36
@zkhcohen
Copy link
Contributor Author

@nielsvanvelzen I can also consolidate the mapping transformation into the following class, but I would need some guidance on where to store it since it would no longer be a constant:
studio64_olbDTTBZaR

Let me know if you think this is a better solution.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

Found 18 potential problems in the proposed changes. Check the Files changed tab for more details.

@nielsvanvelzen
Copy link
Member

Right, if the same mapping is needed in two places it makes sense to keep it in a class. Another option would be to make it a function that receives the context and returns the mapping, that might make more sense actually.

@zkhcohen
Copy link
Contributor Author

zkhcohen commented Sep 13, 2022

Right, if the same mapping is needed in two places it makes sense to keep it in a class. Another option would be to make it a function that receives the context and returns the mapping, that might make more sense actually.

Okay, I updated it to be a top-level function (Kotlin). I still don't really think that storing it in org.jellyfin.androidtv.constant is necessarily appropriate, but without converting back to my original model of using an enum class and then moving the mapping function to a companion object, I'm not really sure where to put it.

Let me know if you want any further changes.

Copy link
Member

@nielsvanvelzen nielsvanvelzen left a comment

Choose a reason for hiding this comment

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

I've formatted the code to be more in line with our other Kotlin code and pushed that in the last commit. Everything looks fine now, thanks for the contribution!

@nielsvanvelzen nielsvanvelzen enabled auto-merge (squash) September 13, 2022 17:12
@nielsvanvelzen nielsvanvelzen added the release-highlight Pull request might be suitable for mentioning in the release blog post label Sep 13, 2022
leanbackOverlayFragment: LeanbackOverlayFragment,
context: Context, view: View
) {
val qualityMenu = PopupMenu(context, view, Gravity.END).apply {

Check warning

Code scanning / detekt

Private member is unused and should be removed.

Private property `qualityMenu` is unused.
@nielsvanvelzen nielsvanvelzen merged commit bc169d6 into jellyfin:master Sep 13, 2022
@Y0ngg4n
Copy link

Y0ngg4n commented Nov 25, 2022

@nielsvanvelzen for bitrates < 5mbit i always get a player error.

@nielsvanvelzen
Copy link
Member

@nielsvanvelzen for bitrates < 5mbit i always get a player error.

Please open an issue so we can track it.

@Y0ngg4n
Copy link

Y0ngg4n commented Nov 25, 2022

@nielsvanvelzen but the logs do not trow any errors :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request release-highlight Pull request might be suitable for mentioning in the release blog post
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants