Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/main/java/org/jellyfin/androidtv/constant/Codec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ object Codec {
const val WEBMA = "webma"
const val WMA = "wma"
const val WMAV2 = "wmav2"
const val DTS_HD = "dts_hd"
const val EAC3_JOC = "eac3_joc"
}

object Video {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ class UserPreferences(context: Context) : SharedPreferenceStore(
*/
var ac3Enabled = booleanPreference("pref_bitstream_ac3", true)

/**
* Enable EAC3
*/
var eac3Enabled = booleanPreference("pref_bitstream_eac3", true)

/**
* Enable DTS
*/
var dtsEnabled = booleanPreference("pref_bitstream_dts", true)

/**
* Enable TrueHD
*/
var truehdEnabled = booleanPreference("pref_bitstream_truehd", true)

/* Live TV */
/**
* Use direct play
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ fun SettingsPlaybackAdvancedScreen() {
val userPreferences = koinInject<UserPreferences>()
val userSettingPreferences = koinInject<UserSettingPreferences>()

var ac3Enabled by rememberPreference(userPreferences, UserPreferences.ac3Enabled)
var eac3Enabled by rememberPreference(userPreferences, UserPreferences.eac3Enabled)

SettingsColumn {
item {
ListSection(
Expand Down Expand Up @@ -265,12 +268,44 @@ fun SettingsPlaybackAdvancedScreen() {
}

item {
var ac3Enabled by rememberPreference(userPreferences, UserPreferences.ac3Enabled)

ListButton(
headingContent = { Text(stringResource(R.string.lbl_bitstream_ac3)) },
trailingContent = { Checkbox(checked = ac3Enabled) },
onClick = { ac3Enabled = !ac3Enabled }
onClick = {
val newValue = !ac3Enabled
ac3Enabled = newValue
if (!newValue) {
eac3Enabled = false
}
}
)
}

item {
ListButton(
headingContent = { Text(stringResource(R.string.lbl_bitstream_eac3)) },
trailingContent = { Checkbox(checked = eac3Enabled) },
onClick = { eac3Enabled = !eac3Enabled }, enabled = ac3Enabled
)
}

item {
var dtsEnabled by rememberPreference(userPreferences, UserPreferences.dtsEnabled)

ListButton(
headingContent = { Text(stringResource(R.string.lbl_bitstream_dts)) },
trailingContent = { Checkbox(checked = dtsEnabled) },
onClick = { dtsEnabled = !dtsEnabled }
)
}

item {
var truehdEnabled by rememberPreference(userPreferences, UserPreferences.truehdEnabled)

ListButton(
headingContent = { Text(stringResource(R.string.lbl_bitstream_truehd)) },
trailingContent = { Checkbox(checked = truehdEnabled) },
onClick = { truehdEnabled = !truehdEnabled }
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package org.jellyfin.androidtv.util.profile

import android.content.Context
import android.media.AudioFormat
import androidx.annotation.OptIn
import androidx.media3.common.AudioAttributes
import androidx.media3.common.C
import androidx.media3.common.Format
import androidx.media3.common.MimeTypes
import androidx.media3.common.util.UnstableApi
import androidx.media3.exoplayer.audio.AudioCapabilities
import org.jellyfin.androidtv.constant.Codec
import org.jellyfin.androidtv.preference.UserPreferences
import org.jellyfin.androidtv.preference.constant.AudioBehavior
Expand Down Expand Up @@ -81,7 +88,10 @@ fun createDeviceProfile(
) = createDeviceProfile(
mediaTest = MediaCodecCapabilitiesTest(userPreferences[UserPreferences.softwareCodecsEnabled]),
maxBitrate = userPreferences.getMaxBitrate(),
isAC3Enabled = userPreferences[UserPreferences.ac3Enabled],
isAC3PrefEnabled = userPreferences[UserPreferences.ac3Enabled],
isEAC3PrefEnabled = userPreferences[UserPreferences.eac3Enabled],
isDTSPrefEnabled = userPreferences[UserPreferences.dtsEnabled],
isTrueHDPrefEnabled = userPreferences[UserPreferences.truehdEnabled],
downMixAudio = userPreferences[UserPreferences.audioBehaviour] == AudioBehavior.DOWNMIX_TO_STEREO,
assDirectPlay = userPreferences[UserPreferences.assDirectPlay],
pgsDirectPlay = userPreferences[UserPreferences.pgsDirectPlay],
Expand All @@ -92,7 +102,10 @@ fun createDeviceProfile(
fun createDeviceProfile(
mediaTest: MediaCodecCapabilitiesTest,
maxBitrate: Int,
isAC3Enabled: Boolean,
isAC3PrefEnabled: Boolean,
isEAC3PrefEnabled: Boolean,
isDTSPrefEnabled: Boolean,
isTrueHDPrefEnabled: Boolean,
downMixAudio: Boolean,
assDirectPlay: Boolean,
pgsDirectPlay: Boolean,
Expand All @@ -101,8 +114,16 @@ fun createDeviceProfile(
) = buildDeviceProfile {
val allowedAudioCodecs = when {
downMixAudio -> downmixSupportedAudioCodecs
!isAC3Enabled -> supportedAudioCodecs.filterNot { it == Codec.Audio.EAC3 || it == Codec.Audio.AC3 }.toTypedArray()
else -> supportedAudioCodecs
else -> supportedAudioCodecs.filterNot { supportedPassthroughAudioCodecs ->
when (supportedPassthroughAudioCodecs) {
// Remove codec if false.
Codec.Audio.AC3 -> !isAC3PrefEnabled
Codec.Audio.EAC3 -> !isEAC3PrefEnabled
Codec.Audio.TRUEHD -> !isTrueHDPrefEnabled
Codec.Audio.DTS -> !isDTSPrefEnabled
else -> false
}
}.toTypedArray()
}

val supportsHevc = mediaTest.supportsHevc()
Expand Down Expand Up @@ -547,3 +568,29 @@ private fun DeviceProfileBuilder.subtitleProfile(
if (hls) subtitleProfile(format, SubtitleDeliveryMethod.HLS)
if (encode) subtitleProfile(format, SubtitleDeliveryMethod.ENCODE)
}

@OptIn(UnstableApi::class)
fun isPassthroughAudioAvailable(context: Context, mimetype: String): Boolean {
// Def audio attributes
val audioAttributes = AudioAttributes.Builder()
.setUsage(C.USAGE_MEDIA)
.setContentType(C.AUDIO_CONTENT_TYPE_MOVIE)
.build()
// Get audio capabilities
val audioCapabilities = AudioCapabilities.getCapabilities(
context,
audioAttributes,
null,
listOf(
AudioFormat.CHANNEL_OUT_STEREO,
AudioFormat.CHANNEL_OUT_5POINT1 )
)
// Set audio format for a passthrough audio codec 2.0 check
val format = Format.Builder()
.setSampleMimeType(mimetype)
.setChannelCount(Integer.bitCount(AudioFormat.CHANNEL_OUT_STEREO))
.setSampleRate(Format.NO_VALUE)
.build()
// Test Passthrough Direct Playback
return audioCapabilities.isPassthroughPlaybackSupported(format, audioAttributes)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.util.Range
import android.view.Display
import android.view.Surface
import androidx.core.content.ContextCompat
import androidx.media3.common.MimeTypes
import kotlinx.serialization.json.Json
import org.jellyfin.androidtv.BuildConfig
import org.jellyfin.androidtv.constant.Codec
Expand Down Expand Up @@ -294,4 +295,14 @@ fun createDeviceProfileReport(
if (isS) appendItem("Device SKU") { appendValue(Build.SKU) }
if (isS) appendItem("Device SOC") { appendValue(Build.SOC_MODEL) }
}

appendSection("Audio Passthrough Capabilities") {
appendLine("***AC3 (2.0)***: ${isPassthroughAudioAvailable(context, MimeTypes.AUDIO_AC3)}")
appendLine("***EAC3 (2.0)***: ${isPassthroughAudioAvailable(context, MimeTypes.AUDIO_E_AC3)}")
appendLine("***EAC3-JOC (2.0)***: ${isPassthroughAudioAvailable(context, MimeTypes.AUDIO_E_AC3_JOC)}")
appendLine("***DTS (2.0)***: ${isPassthroughAudioAvailable(context, MimeTypes.AUDIO_DTS)}")
appendLine("***DTS-HD (2.0)***: ${isPassthroughAudioAvailable(context, MimeTypes.AUDIO_DTS_HD)}")
appendLine("***TrueHD (2.0)***: ${isPassthroughAudioAvailable(context, MimeTypes.AUDIO_TRUEHD)}")
appendLine()
}
}
3 changes: 3 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -669,4 +669,7 @@
<string name="playback_buffer_auto">Auto</string>
<string name="playback_buffer_large">Grand</string>
<string name="playback_buffer_extra_large">Très grand</string>
<string name="lbl_bitstream_eac3">Flux audio Dolby Digital Plus</string>
<string name="lbl_bitstream_dts">Flux audio Digital Theater System</string>
<string name="lbl_bitstream_truehd">Flux audio Dolby TrueHD</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -664,4 +664,7 @@
<string name="hlg">HLG</string>
<string name="pref_software_codecs_enabled">Use software codecs</string>
<string name="pref_software_codecs_enabled_description">Some software-based implementations may degrade performance. Disabling this option makes transcoding more likely.</string>
<string name="lbl_bitstream_eac3">Bitstream Dolby Digital Plus</string>
<string name="lbl_bitstream_dts">Bitstream Digital Theater System</string>
<string name="lbl_bitstream_truehd">Bitstream Dolby TrueHD</string>
</resources>