Files
SimpleRemoter/android/app/src/main/cpp/gsm
yuanyuanxianganddeepseek-flash 4aedca8ee0 Feature: Support voice monitoring on Android hosts
The master's voice monitoring menu sends COMMAND_AUDIO; the client opens a
ConnAuth sub-connection with TOKEN_AUDIO_START, the server opens CAudioDlg
and answers COMMAND_NEXT, then audio flows both ways. The protocol matches
the Windows client, so the server needs no changes.

The server's ACM format was read from Audio.cpp and AudioDlg.cpp first:
WAVE_FORMAT_GSM610, 8000 Hz mono, 65-byte blocks of 320 samples (40 ms),
about 1625 B/s. libgsm 1.0.13 (AOSP external/libgsm mirror) is vendored
under cpp/gsm and built with -DSASR -DWAV49 so its MS-GSM packing is
byte-identical to ACM GSM610. Encode and decode use separate gsm states
because frame_index/frame_chain live in the state.

Uplink packets are always exactly 1000 bytes: CAudio::PlayBuffer copies
1000 bytes from the buffer start regardless of packet length, so a short
packet would over-read. Since 1000 is not a multiple of 65, blocks
straddle packets; the stream is continuous and codec state carries over.

AudioMonitor.kt owns AudioRecord (8 kHz/16-bit/mono, 320 samples a read)
and AudioTrack playback of decoded downlink PCM. RECORD_AUDIO is requested
with POST_NOTIFICATIONS before the projection dialog, and CaptureService
adds the microphone FGS type only when held, falling back on failure. An
8-second dialog wait or missing microphone reports a tip to the master
instead of failing silently.

Verified on an Android 15 emulator against the Debug server: dialog
opened, uplink started, server receive counter grew at ~1.6 KB/s.
Downlink playback was not exercised (the test machine has no recording
device); that path is code-reviewed only.

Co-Authored-By: deepseek-flash
2026-11-11 21:58:54 +01:00
..

libgsm (GSM 06.10)

语音监听(COMMAND_AUDIO / TOKEN_AUDIO_START)的客户端音频编码器。

为什么放在这里

Windows 客户端的「语音监听」用系统 ACM 的 WAVE_FORMAT_GSM610 (client/Audio.cpp:8000 Hz、单声道、blockAlign=65、320 采样/块,VBR 1625 B/s)。 Android 没有可用的 GSM 6.10 编码器(AudioRecord 只出 PCM,MediaCodec 不提供 GSM),所以把 Jutta Degener / Carsten Bormann 的参考实现随 App 编译,用 GSM_OPT_WAV49 产出与 ACM 完全相同的 65 字节 MS-GSM 块,服务端 CAudioDlg/CAudio::PlayBuffer 不需要任何改动。

来源与许可

编译

CMakeLists.txt 里以静态库 gsm610 编译,固定加 -DSASR -DWAV49 (与 AOSP 的 Android.mk 一致)。WAV49 打开 MS-GSM 打包;调用时必须成对: 每 65 字节块写入两次(gsm_encode(state, pcm, out) 写 32 字节、 gsm_encode(state, pcm + 160, out + 32) 写 33 字节),解码同理 (gsm_decode(state, p, pcm)、gsm_decode(state, p + 33, pcm + 160))。 编码与解码必须用两个独立的 gsm 状态——frame_index / frame_chain 是编解码共用的,混用会打乱半字节对齐。