Skip to content

Commit

Permalink
Make 4k support configurable (using old device based method as defaul…
Browse files Browse the repository at this point in the history
…t setting)
  • Loading branch information
t0mas committed Oct 9, 2023
1 parent 81513d2 commit 7e36ca6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ class UserPreferences(context: Context) : SharedPreferenceStore(
*/
var refreshRateSwitchingBehavior = enumPreference("refresh_rate_switching_behavior", RefreshRateSwitchingBehavior.DISABLED)

/**
* Enable 4k codecs for direct play and transcode target
*/
var enable4kSupport = booleanPreference("pref_enable_4k_support", DeviceUtils.has4kVideoSupport())

/* Playback - Audio related */
/**
* Preferred behavior for audio streaming.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.jellyfin.androidtv.data.compat.AudioOptions;
import org.jellyfin.androidtv.data.compat.StreamInfo;
import org.jellyfin.androidtv.data.model.DataRefreshService;
import org.jellyfin.androidtv.preference.UserPreferences;
import org.jellyfin.androidtv.preference.UserSettingPreferences;
import org.jellyfin.androidtv.ui.itemhandling.AudioQueueItem;
import org.jellyfin.androidtv.ui.itemhandling.BaseRowItem;
Expand Down Expand Up @@ -609,7 +610,8 @@ private void playInternal(final org.jellyfin.sdk.model.api.BaseItemDto item, fin
if (DeviceUtils.is60()) {
String[] audioDirectPlay = { Codec.Audio.AAC, Codec.Audio.MP3, Codec.Audio.MP2 };
String[] audioTranscode = { Codec.Audio.AAC, Codec.Audio.MP3, Codec.Audio.MP2 };
profile = new ExoPlayerProfile(context, false, audioDirectPlay, audioTranscode);
Boolean enable4kSupport = userPrefs.getValue().get(UserPreferences.Companion.getEnable4kSupport());
profile = new ExoPlayerProfile(context, false, audioDirectPlay, audioTranscode, enable4kSupport);
} else {
profile = new LibVlcProfile(context, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ private VideoOptions buildExoPlayerOptions(@Nullable Integer forcedSubtitleIndex
mFragment.getContext(),
isLiveTv && !userPreferences.getValue().get(UserPreferences.Companion.getLiveTvDirectPlayEnabled()),
getDirectPlayPreferences(),
getAudioTranscodeTarget()
getAudioTranscodeTarget(),
userPreferences.getValue().get(UserPreferences.Companion.getEnable4kSupport())
);
internalOptions.setProfile(internalProfile);
return internalOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ class PlaybackPreferencesScreen : OptionsFragment() {
bind(userPreferences, UserPreferences.refreshRateSwitchingBehavior)
depends { DeviceUtils.is60() && userPreferences[UserPreferences.videoPlayer] != PreferredVideoPlayer.EXTERNAL }
}

checkbox {
setTitle(R.string.pref_enable_4k_support)
setContent(R.string.pref_enable_4k_support_description)
bind(userPreferences, UserPreferences.enable4kSupport)
}
}

category {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class ExoPlayerProfile(
context: Context,
disableVideoDirectPlay: Boolean = false,
audioDirectPlayCodecs : Array<String>,
audioTranscodeTarget : Array<String>
audioTranscodeTarget : Array<String>,
enable4KSupport : Boolean
) : DeviceProfile() {
private val downmixSupportedAudioCodecs = arrayOf(
Codec.Audio.AAC,
Expand Down Expand Up @@ -127,7 +128,7 @@ class ExoPlayerProfile(
conditions = buildList {
add(h264VideoProfileCondition)
add(h264VideoLevelProfileCondition)
if (!DeviceUtils.has4kVideoSupport()) addAll(max1080pProfileConditions)
if (!enable4KSupport) addAll(max1080pProfileConditions)
}.toTypedArray()
})
// H264 ref frames profile
Expand Down Expand Up @@ -173,7 +174,7 @@ class ExoPlayerProfile(
// AV1 profile
add(deviceAV1CodecProfile)
// Limit video resolution support for older devices
if (!DeviceUtils.has4kVideoSupport()) {
if (!enable4KSupport) {
add(CodecProfile().apply {
type = CodecType.Video
conditions = max1080pProfileConditions
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<string name="byletter_letters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
<string name="pref_playback">Playback</string>
<string name="pref_max_bitrate_title">Max streaming bitrate</string>
<string name="pref_enable_4k_support">Enable 4k playback</string>
<string name="pref_enable_4k_support_description">Allow device to receive 4k streams</string>
<string name="settings_title">Preferences</string>
<string name="pref_authentication_cat">Authentication</string>
<string name="chapters">Chapters</string>
Expand Down

0 comments on commit 7e36ca6

Please sign in to comment.