Skip to content

Commit

Permalink
Add option to transcode AAC to Dolby Digital
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelRUSF committed Oct 9, 2023
1 parent ec7391a commit c6a4dd1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ class UserPreferences(context: Context) : SharedPreferenceStore(
*/
var ac3Enabled = booleanPreference("pref_bitstream_ac3", !DeviceUtils.isFireTvStickGen1)

/**
* Prefer AC3
*/
var aacBypassEnabled = booleanPreference("pref_bypass_aac", false)

/**
* Default audio delay in milliseconds for libVLC
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ private void playInternal(final org.jellyfin.sdk.model.api.BaseItemDto item, fin
options.setMediaSources(item.getMediaSources());
DeviceProfile profile;
if (DeviceUtils.is60()) {
profile = new ExoPlayerProfile(context, false, false);
profile = new ExoPlayerProfile(context, false, false, false);
} else {
profile = new LibVlcProfile(context, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ private VideoOptions buildExoPlayerOptions(@Nullable Integer forcedSubtitleIndex
DeviceProfile internalProfile = new ExoPlayerProfile(
mFragment.getContext(),
isLiveTv && !userPreferences.getValue().get(UserPreferences.Companion.getLiveTvDirectPlayEnabled()),
userPreferences.getValue().get(UserPreferences.Companion.getAc3Enabled())
userPreferences.getValue().get(UserPreferences.Companion.getAc3Enabled()),
userPreferences.getValue().get(UserPreferences.Companion.getAacBypassEnabled())
);
internalOptions.setProfile(internalProfile);
return internalOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ class PlaybackPreferencesScreen : OptionsFragment() {
depends { userPreferences[UserPreferences.videoPlayer] != PreferredVideoPlayer.EXTERNAL }
}

checkbox {
setTitle(R.string.lbl_bypass_aac)
setContent(R.string.desc_bypass_aac)
bind(userPreferences, UserPreferences.aacBypassEnabled)
depends { userPreferences[UserPreferences.videoPlayer] != PreferredVideoPlayer.EXTERNAL }
}

@Suppress("MagicNumber")
seekbar {
setTitle(R.string.pref_libvlc_audio_delay_title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ class ExoPlayerProfile(
context: Context,
disableVideoDirectPlay: Boolean = false,
isAC3Enabled: Boolean = false,
isAACBYPASSEnabled: Boolean = false,
) : DeviceProfile() {
private val downmixSupportedAudioCodecs = arrayOf(
Codec.Audio.AAC,
Codec.Audio.MP3,
Codec.Audio.MP2
)
private val downmixSupportedAudioCodecs = buildList {
if (isAC3Enabled && isAACBYPASSEnabled) add(Codec.Audio.AC3) else add(Codec.Audio.AAC)
add(Codec.Audio.MP3)
add(Codec.Audio.MP2)
}.toTypedArray()

/**
* Returns all audio codecs used commonly in video containers.
Expand All @@ -44,7 +45,7 @@ class ExoPlayerProfile(
addAll(downmixSupportedAudioCodecs)
add(Codec.Audio.AAC_LATM)
add(Codec.Audio.ALAC)
if (isAC3Enabled) add(Codec.Audio.AC3)
if (isAC3Enabled && !isAACBYPASSEnabled) add(Codec.Audio.AC3)
if (isAC3Enabled) add(Codec.Audio.EAC3)
add(Codec.Audio.DCA)
add(Codec.Audio.DTS)
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 @@ -494,6 +494,8 @@
<string name="pref_music_rewrite_disable">Disable new music backend</string>
<string name="pref_music_rewrite_enable_description">Only disable this if you\'re experiencing issues with music playback</string>
<string name="disable_ui_mode_warning">Disable device type warning</string>
<string name="lbl_bypass_aac">Transcode AAC to Dolby Digital audio</string>
<string name="desc_bypass_aac">Must have Dolby Digital bitstreaming enabled</string>
<plurals name="seconds">
<item quantity="one">%1$s second</item>
<item quantity="other">%1$s seconds</item>
Expand Down

0 comments on commit c6a4dd1

Please sign in to comment.