feat: 内置 FFmpeg 音频扩展软解 AC3/DTS

新增 player-media3-ffmpeg:media3 1.11.1 的 decoder_ffmpeg 源码 + 自带
FFmpeg 6.0.1 静态库(arm64-v8a / armeabi-v7a,ac3/eac3/truehd/mlp/dca),
以 EXTENSION_RENDERER_MODE_PREFER 接入,AAC 等仍走系统 MediaCodec。

音轨选择改为仅在默认音轨不可解码时才自动改选;提示文案去掉环绕音频
警告,只保留真正无法解码的情况。构建脚本与依赖下载见 tools/ffmpeg。
This commit is contained in:
tongtong committed 2026-12-01 23:54:29 +08:00
1 parent 71a5d5f72e
commit 40435701fb
17 files changed
+1382 -23

No files matched your search

@@ -55,8 +55,6 @@ import com.ttstd.player.render.TextureViewBinding
import kotlinx.coroutines.launch
import kotlin.math.roundToInt
private val PASSTHROUGH_AUDIO = setOf("audio/ac3", "audio/eac3", "audio/vnd.dts", "audio/vnd.dts.hd", "audio/truehd")
/** 播放界面只拥有 Surface 与控件;内核/观看会话由 PlayerModel 管理。 */
class PlayerActivity : AppCompatActivity() {
private lateinit var model: PlayerModel
@@ -123,7 +121,6 @@ class PlayerActivity : AppCompatActivity() {
val audioTracks = state.tracks.filter { it.type == TrackType.AUDIO }
val selectedAudio = audioTracks.firstOrNull { it.selected } ?: audioTracks.firstOrNull()
val audioUnsupported = selectedAudio != null && !selectedAudio.supported
val audioWarning = audioUnsupported || selectedAudio?.mimeType in PASSTHROUGH_AUDIO
val centerText = when {
remote == "dlna" -> "正在 ${dlna.device} 播放\n${dlna.error ?: "可关闭页面,投屏会继续"}"
loading || state.phase == PlaybackPhase.PREPARING || state.phase == PlaybackPhase.BUFFERING -> "正在缓冲…"
@@ -147,11 +144,10 @@ class PlayerActivity : AppCompatActivity() {
}
LaunchedEffect(state.playWhenReady, ratio, remote) { updatePipParams() }
LaunchedEffect(pip) { if (pip) controlsVisible = false else controlsVisible = true }
LaunchedEffect(current?.ref?.id, audioWarning, audioUnsupported) {
if (audioWarning) Toast.makeText(
LaunchedEffect(current?.ref?.id, audioUnsupported) {
if (audioUnsupported) Toast.makeText(
this@PlayerActivity,
if (audioUnsupported) "当前音轨设备不支持,将静音播放;可切换音轨或使用 AAC 转码版本"
else "当前音轨为 AC3/DTS 环绕音频,需设备/功放支持;若无声音请切换音轨或使用 AAC 转码版本",
"当前音轨设备无法解码,将静音播放;可在“更多 → 音轨”切换其他音轨",
Toast.LENGTH_LONG,
).show()
}
@@ -198,7 +194,7 @@ class PlayerActivity : AppCompatActivity() {
dlna = dlna,
landscape = true,
fromServer = current?.ref?.accountId != null,
audioWarning = audioWarning,
audioUnsupported = audioUnsupported,
modifier = Modifier.align(Alignment.BottomCenter),
onSeek = ::seekTo,
onSeekBy = ::seekBy,
@@ -243,7 +239,7 @@ class PlayerActivity : AppCompatActivity() {
dlna = dlna,
landscape = false,
fromServer = current?.ref?.accountId != null,
audioWarning = audioWarning,
audioUnsupported = audioUnsupported,
onSeek = ::seekTo,
onSeekBy = ::seekBy,
onToggle = { togglePlayback(remote, dlna) },
@@ -430,7 +426,7 @@ class PlayerActivity : AppCompatActivity() {
dlna: DlnaUiState,
landscape: Boolean,
fromServer: Boolean,
audioWarning: Boolean,
audioUnsupported: Boolean,
modifier: Modifier = Modifier,
onSeek: (Long) -> Unit,
onSeekBy: (Long) -> Unit,
@@ -483,7 +479,7 @@ class PlayerActivity : AppCompatActivity() {
Text(
(if (remote != null) "投屏中 · 点击右上角投屏管理连接"
else "${if (fromServer) "媒体来源播放" else "本机 / 在线播放"} · 双击画面快进 / 后退\n音轨、字幕、倍速与显示选项在更多菜单中") +
if (audioWarning) "\n当前音轨可能需要设备/功放支持,若无声可切换音轨或转码" else "",
if (audioUnsupported) "\n正在播放的音轨设备无法解码,可切换其他音轨" else "",
style = MaterialTheme.typography.labelSmall,
color = AppMuted,
modifier = Modifier.padding(top = 4.dp),
@@ -544,7 +540,7 @@ class PlayerActivity : AppCompatActivity() {
val tracks = state.tracks.filter { it.type == dialog.type }
val prefix = if (dialog.type == TrackType.TEXT) "关闭字幕" else "自动选择"
val labels = listOf(prefix) + tracks.map {
val note = if (!it.supported) "(设备不支持)" else if (it.mimeType in PASSTHROUGH_AUDIO) "(可能需要设备支持)" else ""
val note = if (!it.supported) "(设备不支持)" else ""
"${it.label ?: it.language ?: "轨道 ${it.id}"}${if (it.selected) " ✓" else ""}$note"
}
ChoiceDialog(