Squashed buildout of the tgcalls testbench: - CLI test tool with --mode p2p/reflector/group/group-churn, cross-version interop (--version, --version2), and quiet/summary output - Linux toolchain + Docker multi-stage build, AWS Fargate mass test harness, local parallel mass test harness with signaling loss simulation - SCTP writable gate, retransmission timer tuning, role-based handshake - InstanceV2CompatImpl (PeerConnection backend with V2Impl signaling) and SignalingTranslator for v14.0.0 interop - In-process Go/Pion SFU (ICE+DTLS+SRTP+SCTP per participant) with audio RTP forwarding, ActiveAudio/VideoSsrcs data channel broadcast, RTCP feedback path, and CGo c-archive integration - GroupInstanceReferenceImpl (PeerConnection group-call) and mixed-impl group mode (--reference-participants), with SDP munging for simulcast - H264 simulcast group video (FakeVideoTrackSource pattern generator, FakeVideoSink frame counting, --video flag, two-pass channel setup, reactive video setup from ActiveVideoSsrcs) - Group churn stress mode (--mode group-churn, --churn-cycles) - SFU stream-quality adaptation: BandwidthEstimator, LayerSelector state machine, RtxRingBuffer, simulcast SSRC rewrite - Transport-cc feedback generation, NetworkSimulator (delay/jitter/loss/ token-bucket bandwidth), --network-scenario step-down-up - CLAUDE.md updates throughout Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4.5 KiB
4.5 KiB
tgcalls CLI Test Tool
In-process test harness for tgcalls. See the root CLAUDE.md for build instructions, top-level CLI usage, and the CLI options reference.
Supported Versions
| Version | Implementation | Notes |
|---|---|---|
14.0.0 |
InstanceV2CompatImpl |
WebRTC PeerConnection + V2Impl signaling. Cross-version interop with 7.0.0–13.0.0 |
13.0.0 (default) |
InstanceV2Impl |
Also: 7.0.0, 8.0.0, 9.0.0, 12.0.0 |
11.0.0 |
InstanceV2ReferenceImpl |
Also: 10.0.0. Uses WebRTC PeerConnection |
5.0.0 |
InstanceImpl (v1) |
Also: 2.7.7. Legacy |
Architecture (P2P/Reflector)
- Two
tgcalls::Instanceobjects (caller + callee) created viaMeta::Create(version, ...) - Signaling bridged via
SignalingBridgewith configurable drop rate and delay FakeAudioDeviceModulewithSineRecorder(440Hz tone) andNoOpRenderer(audio discarded; validation via BWE)FakeInterfaceplatform implementation (pure C++, no iOS/ObjC deps)- Stats log validation: both caller and callee write
config.statsLogPathwith bitrate records; non-empty log with at least one non-zero BWE value is a success condition - On failure, full tgcalls internal logs (caller + callee) are dumped to stdout via
config.logPath
Architecture (Group)
- N participants using
GroupInstanceCustomImpland/orGroupInstanceReferenceImplconnect to an in-process Go SFU - SFU uses Pion's low-level APIs (pion/ice, pion/dtls, pion/srtp, pion/sctp) — NOT PeerConnection
- ICE: lite mode, loopback-only, UDP host candidates on 127.0.0.1. SFU uses
Dial(controlling) for CustomImpl clients andAccept(controlled) for PeerConnection clients - DTLS: SFU acts as DTLS client (setup=active); GroupNetworkManager hardcodes SSL_SERVER for the tgcalls client
- SRTP: AES-256-GCM (negotiated via DTLS-SRTP; GroupNetworkManager requires GCM suites)
- SCTP: over DTLS, accepts data channel from client, reads Colibri messages, sends
ActiveAudioSsrcsandActiveVideoSsrcsnotifications - RTP forwarding: audio RTP forwarded to all others unconditionally; video RTP forwarded only to receivers that have requested video from that sender (via
ReceiverVideoConstraints) - SSRC tracking: SFU maintains
ssrcRegistry map[uint32]ssrcInfowith kind (audio/video/video-rtx) and simulcast layer index, exposed viaGoSfu_QuerySsrcandGoSfu_QueryVideoSsrcsCGo exports - SSRC discovery: SFU broadcasts
ActiveAudioSsrcsandActiveVideoSsrcsover data channel when participants connect - Video SSRC groups: parsed from join payload
"ssrc-groups"field (SIM + FID semantics), stored per participant - Colibri video constraints: SFU parses
ReceiverVideoConstraintsfrom receivers, sendsSenderVideoConstraintsback to senders withidealHeight, and sends proactive PLI to trigger keyframes when a receiver first requests video - RTCP feedback: SFU demuxes SRTCP from the shared ICE transport (RFC 5761: byte[1] >= 200 && < 224), decrypts with per-participant SRTCP contexts, parses PLI/FIR, and forwards as new PLI to the sender. NACK is terminated (not forwarded).
- Audio validation:
audioLevelsUpdatedcallback tracks remote audio levels; success requires every participant to receive audio from at least one other participant (remote SSRC != 0, level > 0.05). The 440Hz sine tone arrives at ~0.126 level after SFU forwarding. - Video validation:
FakeVideoSink(implementsrtc::VideoSinkInterface<VideoFrame>) counts decoded frames per remote endpoint; success requires every participant to receive ≥1 frame from every other - Video signaling flow: SFU broadcasts
ActiveVideoSsrcsover data channel →dataChannelMessageReceivedcallback fires in the app → app callssetRequestedVideoChannels→ CustomImpl createsIncomingVideoChannel/ ReferenceImpl adds recvonly video transceiver → both sendReceiverVideoConstraints→ SFU sendsSenderVideoConstraints+ proactive PLI → sender produces keyframe → receiver decodes dataChannelMessageReceivedcallback: added toGroupInstanceDescriptor, forwards all incoming Colibri data channel messages to the application. Used by the CLI test tool to react toActiveVideoSsrcsand dynamically set up video channels — mirrors the real Telegram app's reactive flowFakeAudioDeviceModulewithSineRecorder(440Hz tone) andNoOpRenderer— same as P2P modeFakeVideoTrackSourcegenerates 1280x720 I420 frames at 30fps with per-participant color tint and frame counter (720p needed for 3 simulcast layers; 640x360 only allows 2 per WebRTC'skSimulcastFormats)- Group mode source:
tools/tgcalls_cli/group_mode.cpp