telegabber/calls/audio/ntg.go
2026-05-27 08:37:47 -07:00

29 lines
982 B
Go

package audio
// audio doesn't import ntgcalls directly so it builds and tests without
// CGO + libntgcalls; ntgadapter bridges *ntgcalls.Client to NtgClient
// one 10ms s16-LE interleaved PCM frame from ntgcalls
type PCMFrame struct {
SSRC uint32
Data []byte // 1920 bytes for 48k stereo 10ms
}
// batch handler for PCM frames already filtered down to
// (PlaybackStream, MicrophoneStream) by the adapter
type NtgFrameHandler func(chatID int64, frames []PCMFrame)
// bridge's view of ntgcalls
type NtgClient interface {
// returned cancel drops the handler; the Go ntgcalls binding has no
// unregister, so we own the dispatch list ourselves
OnFrame(NtgFrameHandler) func()
// capture=true: gateway sends to peer; capture=false: gateway receives
SetExternalMicrophone(chatID int64, capture bool, sampleRate uint32, channels uint8) error
ClearStreams(chatID int64) error
// ships one 10ms s16-LE stereo PCM frame
SendMicrophonePCM(chatID int64, pcm []byte) error
}