mirror of
https://github.com/TelegramMessenger/tgcalls.git
synced 2026-11-18 21:35:28 +00:00
group: ReferenceImpl never lets WebRTC create unsignaled receive streams
Two production defects with one cause: a packet the network thread has
already handed to the worker when the worker tears down a receive
stream is received as an unknown SSRC, and WebRTC creates a default
("unsignaled") receive stream for it on a channel whose remote content
never changes again. That stream is never reset and keeps the SSRC's
binding in the Call's RtpDemuxer, so the m-line later negotiated for
the SSRC logs "Sink could not be added" and never receives a packet.
Video (device log 2026-09-18): after the app dropped all video
endpoints and requested them again on the same PeerConnection, one tile
stayed frozen while every decoded frame logged
"VideoReceiveStreamInterface not connected to a VideoSink". The factory
now gets its own FieldTrialsView (GRFieldTrials) that enables
WebRTC-Video-DiscardPacketsWithUnknownSsrc and resolves everything else
through tgcalls' shared FieldTrialBasedConfig; before, the engine
inherited the trial only if a CustomImpl call had run earlier in the
process.
Audio (found in the CLI while reproducing the above): the same race at
the first discovery renegotiation recreated an unsignaled stream on the
mid-0 catch-all right after WebRTC reset it. The participant stayed
audible through that stream, but the level sink on the dedicated
receiver never fired, so peers never saw them as speaking (2 of 6 level
sinks dead in a 3-participant run). The outgoing audio transceiver is
now sendonly (answered recvonly), the GRAudioFrameTransformer catch-all
is gone, discovery goes only through the un-demuxable-packet tap, and
the PeerConnection opts into the new vendored-webrtc seam
RTCConfiguration::disable_payload_type_demuxing. The seam is
load-bearing: without it the lone recvonly audio m-line becomes the
payload-type catch-all and a late unmuter is swallowed there
(--unmute-after scored 0/2). First remote audio now arrives ~280 ms
after the first packet (debounce plus one offer/answer), as with
CustomImpl.
CLI: --video-rerequest drops and re-requests every video endpoint five
times under a 150 ms SFU downlink delay and requires every sink to
receive frames past the count taken just before the re-request
(reproduces the frozen tile with --reference-participants 6: 1/30
stalled on the unfixed engine, both runs). Every group run now also
prints "Audio levels heard: X/Y pairs" (every peer must report a real
level for every unmuted sender) and "Unsignaled audio: N stream(s)
(must be 0)" (engine log scanned for the stream WebRTC creates on its
own; 6 for 3 reference participants before). Full sweep green: audio
3 and 6 reference participants, late unmute (reference and mixed),
mixed e2e with video, reference e2e, custom-only, early video request,
capture feeds, 6-participant re-request, group-churn, bandwidth
step-down scenarios.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
783d3c03a2
commit
a029775032
8 files changed
+297
-184
No files matched your search
@@ -147,6 +147,13 @@ Located at `submodules/TgVoipWebrtc/tgcalls/tools/cli/`. Runs tgcalls instances
|
||||
# regression test for the ReferenceImpl dangling-sink crash in rtc::VideoBroadcaster::OnFrame
|
||||
./bazel-bin/submodules/TgVoipWebrtc/tgcalls/tools/cli/tgcalls_cli --mode group --participants 1 --reference-participants 1 --video --video-sink-churn --duration 8
|
||||
|
||||
# Every video request dropped and issued again on the same PeerConnection, five times, under a
|
||||
# 150 ms downlink delay (what leaving and re-entering the video grid does in the app) — the
|
||||
# regression test for ReferenceImpl's "one tile stays frozen after the grid comes back" bug (a
|
||||
# default receive stream created from an in-flight packet kept the SSRC's demuxer binding). Needs
|
||||
# six participants to hit the window reliably on a host; must give "0/30 stalled".
|
||||
./bazel-bin/submodules/TgVoipWebrtc/tgcalls/tools/cli/tgcalls_cli --mode group --participants 0 --reference-participants 6 --video --video-rerequest --duration 6
|
||||
|
||||
# Outgoing video handed over the way the iOS wrapper does it — as a VideoCaptureInterface, at join
|
||||
# (descriptor.videoCapture) or after it (setVideoCapture) — the regression test for ReferenceImpl's
|
||||
# "camera on, server says video, nothing ever sent" bug. Both must give 2/2.
|
||||
@@ -205,6 +212,12 @@ For group-churn: success = all churn cycles complete without crash/hang AND base
|
||||
- `--delay min-max` — signaling delay range in ms (e.g., `50-200`)
|
||||
- `--video` — enable H264 video with simulcast in group mode (both CustomImpl and ReferenceImpl participants)
|
||||
- `--video-sink-churn` — with `--video`, once frames flow each participant replaces every incoming video sink five times, one second apart (`addIncomingVideoOutput` with a fresh sink, old sink released) — what the app does on a quality switch, where the tile's view owns the sink. An engine that keeps a raw pointer to a dead sink segfaults in `rtc::VideoBroadcaster::OnFrame`; validation then counts frames on the NEW sinks only. Known limitation: in mixed groups the pairs receiving from a ReferenceImpl SENDER fail this (0 frames after the last replacement) because the host reference sender throttles to ~1–3 fps after the first seconds regardless of sinks (41–65 frames in 30 s vs ~750 from CustomImpl senders; `_minOutgoingVideoBitrateKbit` is never applied there) — use it with reference-only or CustomImpl-only groups, or with reference RECEIVERS of CustomImpl senders.
|
||||
- `--video-rerequest` — with `--video`, once frames flow each participant's SFU downlink gets a
|
||||
150 ms delay, then five rounds of `setRequestedVideoChannels({})` followed a second later by the
|
||||
full accumulated set again, on the same PeerConnection, sinks kept throughout. Validation adds
|
||||
`Video after re-request: X/Y stalled (must be 0)`: every sink must receive frames past the count
|
||||
recorded just before the re-request. The regression test for ReferenceImpl's frozen tile after
|
||||
the video grid comes back; needs `--reference-participants 6` to hit the window on a host.
|
||||
- `--builtin-codec-order` — expose the raw builtin WebRTC video factory order to PeerConnection instead of the default iOS-shaped order (two H264 entries, VP8, VP9 profile 0) the fake platform advertises. PeerConnection numbers dynamic payload types by walking that list, so the order decides what lands on PT 104; the builtin host order happens to put an H264 profile there and masked the ReferenceImpl receive-table bug (see the ReferenceImpl notes in `submodules/TgVoipWebrtc/CLAUDE.md`). Use it only to compare against the old behaviour.
|
||||
- `--early-video-request` — with `--video`, each joining participant calls `setRequestedVideoChannels` for every already-joined participant right after `emitJoinPayload`, i.e. before the join response is applied and before the data channel opens. That is the real app's call order (`PresentationGroupCall` requests video for known participants immediately after the context issues `emitJoinPayload`); the stock harness only requests video once the SFU announces `ActiveVideoSsrcs`, which arrives ~500 ms after the data channel opens and never exercised that path. Group mode only.
|
||||
- `--video-via-capture` / `--video-via-capture-late` — with `--video`, participants hand their outgoing video to the engine as a `VideoCaptureInterface` (built by the fake platform's `FakeVideoCapturer`, tinted by participant id) instead of the CLI-only `descriptor.getVideoSource` shortcut: `--video-via-capture` sets `descriptor.videoCapture` at construction (the iOS wrapper's join-time path, camera already on), `--video-via-capture-late` calls `setVideoCapture()` right after the join response (the wrapper's `requestVideo:` path, camera switched on mid-call). This is the only way the harness exercises the contract the app actually uses; `GroupInstanceReferenceImpl::setVideoCapture` was an empty stub until 2026-09-06 and every `getVideoSource` run passed regardless. Group mode only.
|
||||
@@ -236,9 +249,10 @@ For group-churn: success = all churn cycles complete without crash/hang AND base
|
||||
participants mid-call. **Nothing is signalled to the peers** — they must notice the new SSRC from
|
||||
the media alone, as in a real call. This is the regression test for "a participant who unmutes after
|
||||
a while is never heard" on `GroupInstanceReferenceImpl`: the unmute deliberately lands *after* the
|
||||
peers have renegotiated for the SSRCs they saw at join, which is when WebRTC stops routing unknown
|
||||
audio SSRCs to the unsignaled catch-all (see the ReferenceImpl notes in
|
||||
`submodules/TgVoipWebrtc/CLAUDE.md`). Validation adds a `Late unmute heard: X/Y` line requiring
|
||||
peers have renegotiated for the SSRCs they saw at join, which is when the original design's
|
||||
unsignaled catch-all on mid=0 stopped receiving (see the ReferenceImpl notes in
|
||||
`submodules/TgVoipWebrtc/CLAUDE.md`; since 2026-09-19 mid=0 is sendonly and every SSRC is found
|
||||
from the packets the demuxer drops). Validation adds a `Late unmute heard: X/Y` line requiring
|
||||
every peer to report a real level for the late SSRC. Use ≥3 participants so a first renegotiation
|
||||
actually happens: `--participants 2 --reference-participants 1 --mute-participants 1 --unmute-after 8
|
||||
--duration 20` scored 1/2 before the fix and 2/2 after. Two controls make the result meaningful:
|
||||
@@ -246,6 +260,12 @@ For group-churn: success = all churn cycles complete without crash/hang AND base
|
||||
and the same late unmute with NO prior renegotiation
|
||||
(`--participants 1 --reference-participants 1 --mute-participants 0 --unmute-after 8`) also passes
|
||||
either way — which is what pins the cause to the renegotiation rather than to the lateness.
|
||||
- Every group run also prints `Audio levels heard: X/Y pairs` (every peer must report a real level
|
||||
for every unmuted sender — a participant who is audible but never reaches the level reports is
|
||||
the "never shown as speaking" defect) and `Unsignaled audio: N stream(s) (must be 0)` (the engine
|
||||
log is scanned for `Creating unsignaled receive stream`; the reference engine must receive audio
|
||||
only through m-lines that signal the SSRC). Both added 2026-09-19; the unfixed engine scored 6
|
||||
unsignaled streams for 3 reference participants.
|
||||
- `--churn-cycles N` — number of join/leave cycles in group-churn mode (default: 100)
|
||||
- `--network-scenario NAME` — network simulation test scenario (e.g., `step-down-up`). Group mode only.
|
||||
- `--quiet` — summary output only
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
#include "group/GroupFrameTransformer.h"
|
||||
#include "group/GroupAudioCapturePostProcessor.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_packet_received.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "FieldTrialsConfig.h"
|
||||
|
||||
#include "third-party/json11.hpp"
|
||||
|
||||
@@ -75,6 +77,38 @@ absl::string_view mapIceCandidateTypeToInternal(const std::string &type) {
|
||||
return type;
|
||||
}
|
||||
|
||||
// Field trials for this engine's PeerConnectionFactory.
|
||||
//
|
||||
// Video packets whose SSRC no m-section signals must be dropped, never turned
|
||||
// into a default (unsignaled) receive stream. A packet the network thread has
|
||||
// already handed to the worker when the worker removes an endpoint's receive
|
||||
// stream (the app requested fewer endpoints) is otherwise received as unknown
|
||||
// and creates such a stream on the old, still-open transceiver's channel.
|
||||
// That channel's remote content never changes again, so the stream is never
|
||||
// reset, and it keeps the SSRC's binding in the Call's demuxer: when the same
|
||||
// endpoint is requested again, the new transceiver's receive stream cannot
|
||||
// register for the SSRC, the old stream decodes every frame into a sink that
|
||||
// was detached with the endpoint ("VideoReceiveStreamInterface not connected
|
||||
// to a VideoSink"), and the participant's tile stays frozen for the rest of
|
||||
// the call. Signaled SSRCs are always available here: buildRemoteAnswer puts
|
||||
// every requested endpoint's SSRC groups into its m-section.
|
||||
//
|
||||
// CustomImpl enables the same trial process-wide from its start(), which used
|
||||
// to make this engine's behaviour depend on whether a CustomImpl call had run
|
||||
// earlier in the process. Everything else still resolves through tgcalls'
|
||||
// shared FieldTrialBasedConfig (the global trial string), exactly as before.
|
||||
class GRFieldTrials final : public webrtc::FieldTrialsView {
|
||||
public:
|
||||
static constexpr absl::string_view kDiscardUnknownSsrcVideo = "WebRTC-Video-DiscardPacketsWithUnknownSsrc";
|
||||
|
||||
std::string Lookup(absl::string_view key) const override {
|
||||
if (key == kDiscardUnknownSsrcVideo) {
|
||||
return "Enabled";
|
||||
}
|
||||
return fieldTrialsBasedConfig.Lookup(key);
|
||||
}
|
||||
};
|
||||
|
||||
// --- PeerConnection observer adapter ---
|
||||
|
||||
class GRPeerConnectionObserver : public webrtc::PeerConnectionObserver {
|
||||
@@ -321,131 +355,6 @@ private:
|
||||
GroupLevelValue _value;
|
||||
};
|
||||
|
||||
// --- Audio SSRC-discovery tap ---
|
||||
//
|
||||
// Single instance installed on mid=0's receiver (the catch-all for
|
||||
// unsignaled audio SSRCs). The first packet for an unknown SSRC arrives
|
||||
// at mid=0; the voice channel constructs an unsignaled WebRtcAudioReceiveStream
|
||||
// and attaches this transformer (because it is the channel's
|
||||
// `unsignaled_frame_transformer_`). Transform() then notifies discovery on
|
||||
// first-sight per SSRC and passes the frame straight through to the stream's
|
||||
// depacketizer/decoder so the discovery-window audio plays normally.
|
||||
//
|
||||
// No buffering. After renegotiation propagates the SSRC to a recvonly
|
||||
// transceiver, the BUNDLE demuxer routes packets to the per-receiver
|
||||
// transformer (`GRPerReceiverAudioTransformer`); this tap stops seeing them.
|
||||
//
|
||||
// E2E note: this tap intentionally does NOT decrypt. SSRC lives in the
|
||||
// unencrypted RTP header, so discovery works on encrypted frames as-is.
|
||||
// Decryption belongs on the per-receiver transformer (per-user keys).
|
||||
class GRAudioFrameTransformer : public webrtc::FrameTransformerInterface {
|
||||
public:
|
||||
using SsrcCallback = std::function<void(uint32_t ssrc)>;
|
||||
|
||||
GRAudioFrameTransformer(SsrcCallback onNewSsrc,
|
||||
GroupEncryptDecryptFunction e2eEncryptDecrypt,
|
||||
std::shared_ptr<GRUserIdRegistry> userIds,
|
||||
std::map<int32_t, FrameTransformerPayloadType> payloadTypeMapping)
|
||||
: _onNewSsrc(std::move(onNewSsrc))
|
||||
, _e2eEncryptDecrypt(std::move(e2eEncryptDecrypt))
|
||||
, _userIds(std::move(userIds))
|
||||
, _payloadTypeMapping(std::move(payloadTypeMapping)) {}
|
||||
|
||||
void Transform(std::unique_ptr<webrtc::TransformableFrameInterface> frame) override {
|
||||
if (!frame) return;
|
||||
const uint32_t ssrc = frame->GetSsrc();
|
||||
|
||||
bool notifyDiscovery = false;
|
||||
rtc::scoped_refptr<webrtc::TransformedFrameCallback> sink;
|
||||
{
|
||||
webrtc::MutexLock lock(&_mu);
|
||||
if (_seen.size() < kMaxSeen && _seen.insert(ssrc).second) {
|
||||
notifyDiscovery = true;
|
||||
}
|
||||
sink = _sink;
|
||||
}
|
||||
|
||||
// Notify on every frame while encryption is on and the sender is still
|
||||
// unknown: handleDiscoveredAudioSsrc de-dupes on an in-flight request the
|
||||
// way CustomImpl's maybeRequestUnknownSsrc does. Without this the engine
|
||||
// asks exactly once ever, and a description response that omits the SSRC
|
||||
// leaves that participant permanently undecryptable.
|
||||
if (!notifyDiscovery && _e2eEncryptDecrypt && _userIds && !_userIds->isKnown(ssrc)) {
|
||||
notifyDiscovery = true;
|
||||
}
|
||||
|
||||
if (notifyDiscovery && _onNewSsrc) {
|
||||
_onNewSsrc(ssrc);
|
||||
}
|
||||
if (!sink) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_e2eEncryptDecrypt) {
|
||||
sink->OnTransformedFrame(std::move(frame));
|
||||
return;
|
||||
}
|
||||
|
||||
// Encrypted: forwarding ciphertext would render a burst of noise, so a
|
||||
// frame whose sender is not yet known is dropped. Decrypting here rather
|
||||
// than dropping unconditionally keeps the discovery window audible and is
|
||||
// correct whether or not this tap keeps seeing an SSRC after the recvonly
|
||||
// transceiver is negotiated.
|
||||
//
|
||||
// Membership, not value, decides: an unresolved SSRC and a genuine
|
||||
// userId of 0 are indistinguishable by value.
|
||||
if (!_userIds || !_userIds->isKnown(ssrc)) {
|
||||
return;
|
||||
}
|
||||
const int64_t userId = _userIds->userIdForSsrc(ssrc);
|
||||
|
||||
FrameTransformerPayloadType payloadType = FrameTransformerPayloadType::Unknown;
|
||||
const auto found = _payloadTypeMapping.find(frame->GetPayloadType());
|
||||
if (found != _payloadTypeMapping.end()) {
|
||||
payloadType = found->second;
|
||||
}
|
||||
if (payloadType != FrameTransformerPayloadType::Opus) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The trailer's level is discarded: remote levels come from
|
||||
// GRAudioLevelSink's real decoded PCM.
|
||||
auto result = decryptGroupAudioFrame(_e2eEncryptDecrypt, userId, frame->GetData(),
|
||||
nullptr, nullptr, nullptr);
|
||||
if (result.empty()) {
|
||||
return;
|
||||
}
|
||||
frame->SetData(result);
|
||||
sink->OnTransformedFrame(std::move(frame));
|
||||
}
|
||||
|
||||
void RegisterTransformedFrameCallback(
|
||||
rtc::scoped_refptr<webrtc::TransformedFrameCallback> cb) override {
|
||||
webrtc::MutexLock lock(&_mu);
|
||||
_sink = std::move(cb);
|
||||
}
|
||||
void RegisterTransformedFrameSinkCallback(
|
||||
rtc::scoped_refptr<webrtc::TransformedFrameCallback>,
|
||||
uint32_t) override {}
|
||||
void UnregisterTransformedFrameCallback() override {
|
||||
webrtc::MutexLock lock(&_mu);
|
||||
_sink = nullptr;
|
||||
}
|
||||
void UnregisterTransformedFrameSinkCallback(uint32_t) override {}
|
||||
|
||||
private:
|
||||
static constexpr size_t kMaxSeen = 256;
|
||||
|
||||
SsrcCallback _onNewSsrc;
|
||||
GroupEncryptDecryptFunction _e2eEncryptDecrypt;
|
||||
std::shared_ptr<GRUserIdRegistry> _userIds;
|
||||
std::map<int32_t, FrameTransformerPayloadType> _payloadTypeMapping;
|
||||
|
||||
webrtc::Mutex _mu;
|
||||
rtc::scoped_refptr<webrtc::TransformedFrameCallback> _sink RTC_GUARDED_BY(_mu);
|
||||
std::set<uint32_t> _seen RTC_GUARDED_BY(_mu);
|
||||
};
|
||||
|
||||
// Opus is fixed at 111 for every participant in a group call — payload types are
|
||||
// pinned, never negotiated per pair (see mungeVideoCodecsInOffer). That is what
|
||||
// lets the transport-level tap tell audio from video without parsing the payload.
|
||||
@@ -734,10 +643,6 @@ public:
|
||||
void start() {
|
||||
const auto weak = std::weak_ptr<GroupInstanceReferenceInternal>(shared_from_this());
|
||||
|
||||
// Note: we do NOT set DiscardPacketsWithUnknownSsrc because the outgoing
|
||||
// video transceiver is sendonly (no receive side). Unsignaled video packets
|
||||
// will be routed to the recvonly incoming video transceiver.
|
||||
|
||||
// 1. Create AudioDeviceModule on the worker thread — platform ADMs (notably
|
||||
// iOS) assert on the worker thread during Init/Terminate and touch
|
||||
// AVAudioSession; mirrors GroupInstanceCustomImpl's worker-thread ADM
|
||||
@@ -751,6 +656,7 @@ public:
|
||||
|
||||
// 2. Create PeerConnectionFactory.
|
||||
webrtc::PeerConnectionFactoryDependencies deps;
|
||||
deps.trials = std::make_unique<GRFieldTrials>();
|
||||
deps.network_thread = _threads->getNetworkThread();
|
||||
deps.signaling_thread = _threads->getMediaThread();
|
||||
deps.worker_thread = _threads->getWorkerThread();
|
||||
@@ -826,22 +732,33 @@ public:
|
||||
config.rtcp_mux_policy = webrtc::PeerConnectionInterface::RtcpMuxPolicy::kRtcpMuxPolicyRequire;
|
||||
config.continual_gathering_policy = webrtc::PeerConnectionInterface::ContinualGatheringPolicy::GATHER_CONTINUALLY;
|
||||
config.audio_jitter_buffer_fast_accelerate = true;
|
||||
// Every audio SSRC is received through an m-line that signals it, and
|
||||
// unknown SSRCs are learned from the packets the demuxer drops (the tap
|
||||
// below). Payload-type routing would defeat both: WebRTC turns it on
|
||||
// for the lone receiving audio m-line of the BUNDLE (the answer carries
|
||||
// no MID extension), so while exactly one remote SSRC is negotiated a
|
||||
// new speaker's packets are routed to that channel by payload type,
|
||||
// create an "unsignaled" receive stream there, never reach the tap,
|
||||
// and keep the SSRC's demuxer binding away from the m-line added for
|
||||
// it later. A tgcalls seam in the vendored webrtc turns the mechanism
|
||||
// off for this PeerConnection.
|
||||
config.disable_payload_type_demuxing = true;
|
||||
|
||||
webrtc::PeerConnectionDependencies pcDeps(nullptr);
|
||||
pcDeps.observer = _peerConnectionObserver.get();
|
||||
|
||||
// Audio SSRC discovery for a participant who starts sending after the
|
||||
// call settled. Once two receiving audio m-lines in the BUNDLE group
|
||||
// advertise Opus 111 (sendrecv mid=0 plus one recvonly per remote SSRC),
|
||||
// SdpOfferAnswerHandler::UpdatePayloadTypeDemuxingState disables
|
||||
// payload-type demuxing and resets the unsignaled catch-all, so an
|
||||
// unknown SSRC - no MID extension (buildRemoteAnswer strips it), no SSRC
|
||||
// binding - is dropped by RtpDemuxer before any receive stream or frame
|
||||
// transformer exists. RtpTransport reports exactly those drops through
|
||||
// PeerConnectionObserver::OnUnDemuxableRtpPacket (a tgcalls seam in the
|
||||
// vendored webrtc), parsed and SRTP-unprotected, on the network thread.
|
||||
// Packets that still reach the mid=0 catch-all are demuxed, never arrive
|
||||
// here, and are covered by the GRAudioFrameTransformer as before.
|
||||
// Audio SSRC discovery, the only path. No audio m-line receives
|
||||
// without a signaled SSRC (mid 0 is sendonly, see below; each remote
|
||||
// SSRC gets its own recvonly m-line carrying that SSRC), so a packet
|
||||
// for an SSRC without an m-line yet - no MID extension (buildRemoteAnswer
|
||||
// strips it), no SSRC binding, no payload-type routing - is dropped by
|
||||
// RtpDemuxer before any receive stream exists. RtpTransport reports
|
||||
// exactly those drops through PeerConnectionObserver::OnUnDemuxableRtpPacket
|
||||
// (a tgcalls seam in the vendored webrtc), parsed and SRTP-unprotected,
|
||||
// on the network thread. A new speaker is therefore heard once the
|
||||
// discovery renegotiation has added their m-line
|
||||
// (kDiscoveryRenegotiationDelayMs plus one offer/answer), which is also
|
||||
// when CustomImpl starts playing an unknown SSRC.
|
||||
_audioSsrcTap = std::make_shared<AudioSsrcTap>();
|
||||
{
|
||||
auto tap = _audioSsrcTap;
|
||||
@@ -860,8 +777,8 @@ public:
|
||||
return;
|
||||
}
|
||||
bool report = tap->shouldReport(ssrc);
|
||||
// Mirrors GRAudioFrameTransformer: while encryption is on and the
|
||||
// sender is still unknown, keep reporting so
|
||||
// While encryption is on and the sender is still unknown, keep
|
||||
// reporting so
|
||||
// handleDiscoveredAudioSsrc re-asks for the description (it de-dupes
|
||||
// on the in-flight request). A response that omits the SSRC would
|
||||
// otherwise leave that participant permanently undecryptable.
|
||||
@@ -916,6 +833,22 @@ public:
|
||||
|
||||
webrtc::RtpTransceiverInit transceiverInit;
|
||||
transceiverInit.stream_ids = {"0"};
|
||||
// Send-only: this m-line never receives. Every remote audio SSRC gets
|
||||
// its own recvonly m-line that signals the SSRC (renegotiate), and is
|
||||
// found through the un-demuxable-packet tap below. Were mid 0 sendrecv,
|
||||
// it would be the only receiving audio channel until the first
|
||||
// renegotiation, so WebRTC would route unknown SSRCs to it by payload
|
||||
// type and create "unsignaled" receive streams there. Those streams
|
||||
// are reset exactly once, when the first dedicated m-line disables
|
||||
// payload-type demuxing, and a packet already handed to the worker
|
||||
// thread at that moment recreates one; nothing ever resets mid 0
|
||||
// again, so the SSRC's dedicated m-line can never register in the
|
||||
// Call's demuxer ("Sink could not be added for SSRC"): the participant
|
||||
// is heard through the stray stream but their level sink, which sits
|
||||
// on the dedicated receiver, never fires, and they are never shown as
|
||||
// speaking. With no receiving role there is nothing for WebRTC to
|
||||
// create such a stream on.
|
||||
transceiverInit.direction = webrtc::RtpTransceiverDirection::kSendOnly;
|
||||
|
||||
auto result = _peerConnection->AddTransceiver(audioTrack, transceiverInit);
|
||||
if (result.ok()) {
|
||||
@@ -945,28 +878,6 @@ public:
|
||||
nullptr));
|
||||
}
|
||||
|
||||
// Install the SSRC-discovery tap on mid=0's receiver. mid=0 is the
|
||||
// catch-all for unsignaled audio: the first packet for an unknown
|
||||
// SSRC arrives at mid=0's voice channel, which constructs an
|
||||
// unsignaled WebRtcAudioReceiveStream and attaches this transformer
|
||||
// (it lives in `unsignaled_frame_transformer_`). The tap notifies
|
||||
// discovery once per SSRC and passes the frame straight through —
|
||||
// discovery-window audio plays normally via mid=0's stream until
|
||||
// renegotiation hands the SSRC off to a recvonly transceiver
|
||||
// (`GRPerReceiverAudioTransformer`), at which point the BUNDLE
|
||||
// demuxer routes packets there and this tap stops seeing them.
|
||||
_audioFrameTransformer = rtc::make_ref_counted<GRAudioFrameTransformer>(
|
||||
[weak, threads = _threads](uint32_t ssrc) {
|
||||
threads->getMediaThread()->PostTask([weak, ssrc]() {
|
||||
if (auto strong = weak.lock()) {
|
||||
strong->handleDiscoveredAudioSsrc(ssrc);
|
||||
}
|
||||
});
|
||||
},
|
||||
_e2eEncryptDecrypt, _userIds, _payloadTypeMapping);
|
||||
_outgoingAudioTransceiver->receiver()
|
||||
->SetDepacketizerToDecoderFrameTransformer(_audioFrameTransformer);
|
||||
|
||||
startStatsLogging();
|
||||
|
||||
// Muted by default (`_isMuted` starts true): this leaves the send
|
||||
@@ -1332,14 +1243,17 @@ public:
|
||||
audioContent->set_rtcp_mux(true);
|
||||
|
||||
if (isFirstAudio) {
|
||||
// --- First audio m-line: sendrecv (our outgoing audio) ---
|
||||
// --- First audio m-line: our outgoing audio only ---
|
||||
// The local transceiver is sendonly, so the SFU's side is
|
||||
// recvonly: no stream ever demuxes here (see start()).
|
||||
isFirstAudio = false;
|
||||
|
||||
// Copy RTP header extensions from local offer, excluding MID.
|
||||
// The SFU forwards raw RTP with the sender's MID value, which
|
||||
// would cause BUNDLE demux to route packets to the wrong channel.
|
||||
// Without MID in the extension map, PeerConnection uses SSRC/PT
|
||||
// routing for all incoming media.
|
||||
// Without MID in the extension map, incoming media demuxes by
|
||||
// signaled SSRC only (payload-type routing is off for this
|
||||
// PeerConnection, see start()).
|
||||
for (const auto& ext : localMedia->rtp_header_extensions()) {
|
||||
if (ext.uri == webrtc::RtpExtension::kMidUri) {
|
||||
continue;
|
||||
@@ -1347,7 +1261,7 @@ public:
|
||||
audioContent->AddRtpHeaderExtension(ext);
|
||||
}
|
||||
|
||||
audioContent->set_direction(webrtc::RtpTransceiverDirection::kSendRecv);
|
||||
audioContent->set_direction(webrtc::RtpTransceiverDirection::kRecvOnly);
|
||||
} else {
|
||||
// --- Recvonly audio transceiver: answer with sendonly ---
|
||||
// Include the remote SSRC so PeerConnection's AudioRtpReceiver
|
||||
@@ -1427,9 +1341,10 @@ public:
|
||||
} else {
|
||||
videoContent->set_direction(webrtc::RtpTransceiverDirection::kSendOnly);
|
||||
|
||||
// Include remote SSRCs for SSRC-based demux. Required because
|
||||
// CustomImpl sets DiscardPacketsWithUnknownSsrc process-wide,
|
||||
// which prevents unsignaled stream creation in mixed groups.
|
||||
// Include remote SSRCs for SSRC-based demux. Required: the
|
||||
// factory discards video packets with unsignaled SSRCs (see
|
||||
// GRFieldTrials), so an endpoint is only received through
|
||||
// the SSRC groups signaled here.
|
||||
for (const auto& [epId, ep] : _remoteVideoEndpoints) {
|
||||
if (ep.transceiver && ep.transceiver->mid().has_value() &&
|
||||
ep.transceiver->mid().value() == mid) {
|
||||
@@ -1911,9 +1826,8 @@ private:
|
||||
// processing of the answer's m-line), media_channel propagates it to the
|
||||
// newly-created ChannelReceive's frame_transformer_delegate_, which calls
|
||||
// RegisterTransformedFrameCallback on our instance. Without this, the
|
||||
// signaled stream constructs with frame_transformer=nullptr (because mid=N's
|
||||
// channel has unsignaled_frame_transformer_=nullptr — only mid=0's channel
|
||||
// has it set), and the e2e PR's decrypt hook would have no attachment point.
|
||||
// signaled stream constructs with frame_transformer=nullptr, and the e2e
|
||||
// decrypt hook would have no attachment point.
|
||||
// Each receiver gets its OWN instance: sharing one across
|
||||
// receivers makes Register{Sink,}TransformedFrameCallback
|
||||
// overwrite valid registrations (verified empirically).
|
||||
@@ -2633,8 +2547,6 @@ private:
|
||||
// Audio.
|
||||
webrtc::scoped_refptr<webrtc::AudioTrackInterface> _outgoingAudioTrack;
|
||||
webrtc::scoped_refptr<webrtc::RtpTransceiverInterface> _outgoingAudioTransceiver;
|
||||
// Per-receiver audio frame transformer (catch-all + every recvonly).
|
||||
rtc::scoped_refptr<GRAudioFrameTransformer> _audioFrameTransformer;
|
||||
|
||||
// Data channel.
|
||||
webrtc::scoped_refptr<webrtc::DataChannelInterface> _dataChannel;
|
||||
|
||||
+2
-1
@@ -30,7 +30,7 @@ In-process test harness for tgcalls. See the root `CLAUDE.md` for build instruct
|
||||
- SCTP: over DTLS, accepts data channel from client, reads Colibri messages, sends `ActiveVideoSsrcs` notifications
|
||||
- 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]ssrcInfo` with kind (audio/video/video-rtx) and simulcast layer index, exposed via `GoSfu_QuerySsrc` and `GoSfu_QueryVideoSsrcs` CGo exports
|
||||
- SSRC discovery: video SSRCs are broadcast via `ActiveVideoSsrcs` (the test app's `dataChannelMessageReceived` callback consumes them and calls `setRequestedVideoChannels`). Audio SSRCs are discovered by `GroupInstanceReferenceImpl`'s per-receiver `GRAudioFrameTransformer` directly from incoming RTP — same shape CustomImpl uses (`receiveUnknownSsrcPacket` → `_requestMediaChannelDescriptions`). The legacy `ActiveAudioSsrcs` data-channel message has been removed.
|
||||
- SSRC discovery: video SSRCs are broadcast via `ActiveVideoSsrcs` (the test app's `dataChannelMessageReceived` callback consumes them and calls `setRequestedVideoChannels`). Audio SSRCs are discovered by `GroupInstanceReferenceImpl` from the RTP packets WebRTC's demuxer drops (`OnUnDemuxableRtpPacket` seam; mid=0 is sendonly and payload-type demuxing is off, so an SSRC without its own m-line is always dropped) — same shape CustomImpl uses (`receiveUnknownSsrcPacket` → `_requestMediaChannelDescriptions`). The legacy `ActiveAudioSsrcs` data-channel message has been removed.
|
||||
- Video SSRC groups: parsed from join payload `"ssrc-groups"` field (SIM + FID semantics), stored per participant
|
||||
- Colibri video constraints: SFU parses `ReceiverVideoConstraints` from receivers, sends `SenderVideoConstraints` back to senders with `idealHeight`, 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).
|
||||
@@ -41,6 +41,7 @@ In-process test harness for tgcalls. See the root `CLAUDE.md` for build instruct
|
||||
- `FakeAudioDeviceModule` with `SineRecorder` (440Hz tone) and `NoOpRenderer` — same as P2P mode
|
||||
- `FakeInterface` (`tgcalls/platform/fake/FakeInterface.cpp`) wraps the builtin video encoder/decoder factories so `GetSupportedFormats()` comes back in the iOS platform order — two H264 entries (packetization-mode 1, the constrained-baseline one kept), VP8, VP9 profile 0. PeerConnection assigns dynamic payload types by walking that list (96, 98, 100, ... with RTX at +1), so the ORDER decides which codec sits on which number; the raw builtin host order lists five H264 profiles and lands one on PT 104 by coincidence, which is exactly the number the group-call convention uses for H264 and hid a ReferenceImpl bug for the device (where PT 104 was H265). `--builtin-codec-order` restores the raw order for comparison
|
||||
- `churnVideoSinks()` (group_participant.cpp, `--video-sink-churn`) replaces every participant's incoming sinks via `addIncomingVideoOutput` and releases the old ones, mirroring the app recreating tile views on quality changes; the engine must only ever hold weak references (a raw sink pointer left on the track crashes on the next frame)
|
||||
- `dropAllVideoRequests()` / `rerequestAllVideo()` (group_participant.cpp, `--video-rerequest`): after frames flow, every participant's SFU egress gets a 150 ms delay (`GoSfu_SetNetworkParams`), then five rounds of `setRequestedVideoChannels({})` followed a second later by the full accumulated set again, sinks kept throughout. Validation requires every sink's frame count to grow past the value recorded at the last drop ("Video after re-request: N/M stalled", must be 0). The delay is load-bearing: on the in-process SFU the streams stop before the renegotiation lands, whereas on a real network the packets forwarded before the SFU read the empty `ReceiverVideoConstraints` are still arriving while the receive streams are torn down; that in-flight packet is what used to create a default receive stream on the abandoned transceiver's channel and freeze the tile on re-request. The window is sub-millisecond at the harness's packet rates, so the reproduction needs `--reference-participants 6` (both unfixed runs failed 1/30; three participants passed by luck).
|
||||
- `FakeVideoTrackSource` generates 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's `kSimulcastFormats`)
|
||||
- Two ways a participant feeds outgoing video (`VideoFeed` in group_participant.h): `Source` — `descriptor.getVideoSource` returning the `FakeVideoTrackSource` above (the CLI's original shortcut, no app uses it); `CaptureAtJoin` / `CaptureLate` (`--video-via-capture` / `--video-via-capture-late`) — a real `tgcalls::VideoCaptureInterface::Create(threads, "<id>")`, handed over as `descriptor.videoCapture` or via `setVideoCapture()` after the join response, exactly as the iOS wrapper does. For that to produce frames on the host, the fake platform implements `makeVideoSource` (a `FakePlatformVideoSource`: plain adapted source, pushed into) and `makeVideoCapturer` (`FakeVideoCapturer`: 1280x720 @ 30 fps, tint from `deviceId`, a sweeping bar for motion, also feeds the uncropped preview sink) in `tgcalls/platform/fake/FakeVideoCapturer.{h,cpp}`. Both used to return nullptr, which is why `setVideoCapture` could be a no-op in the reference engine without any test noticing.
|
||||
- `--request-own-video`: `requestVideoFromEndpoints()` appends the participant's own endpoint to every request (the SFU's `ActiveVideoSsrcs` never names the receiver, but the app's roster includes the local participant and is handed to the engine unfiltered) and registers a sink for it. Validation reads `GoSfu_QueryRequestedLayer(receiver, receiver)` before the SFU is destroyed (`ParticipantState::sfuSelfRequestedLayer`) — any value ≥ 0 means the engine let a self-request through — and, for Capture* feeds, requires the own-endpoint sink to have received preview frames (`videoViaCapture` outlives the released `videoCapture`). The own-endpoint sink is never counted as a received pair.
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// CGo header
|
||||
#include "submodules/TgVoipWebrtc/tgcalls/tools/go_sfu/go_sfu.h"
|
||||
|
||||
int runGroupMode(int customParticipants, int referenceParticipants, int duration, bool quiet, bool video, const std::string& networkScenario, const std::set<int>& mutedParticipants, bool earlyVideoRequest, bool videoSinkChurn, bool e2e, VideoFeed videoFeed, bool requestOwnVideo, int unmuteAfterSeconds) {
|
||||
int runGroupMode(int customParticipants, int referenceParticipants, int duration, bool quiet, bool video, const std::string& networkScenario, const std::set<int>& mutedParticipants, bool earlyVideoRequest, bool videoSinkChurn, bool e2e, VideoFeed videoFeed, bool requestOwnVideo, int unmuteAfterSeconds, bool videoRerequest) {
|
||||
gGroupQuiet = quiet;
|
||||
gGroupStartTime = std::chrono::steady_clock::now();
|
||||
|
||||
@@ -107,6 +107,38 @@ int runGroupMode(int customParticipants, int referenceParticipants, int duration
|
||||
}
|
||||
}
|
||||
|
||||
// Optionally drop every video request and issue it again on the same
|
||||
// PeerConnection (the app does this whenever the UI leaves and re-enters
|
||||
// the video grid, e.g. on backgrounding). Video keeps flowing under a
|
||||
// downlink delay while the engines renegotiate, because on a real network
|
||||
// the packets the SFU forwarded before it read the empty
|
||||
// ReceiverVideoConstraints are still in flight when the receive streams
|
||||
// are torn down; without the delay the in-process SFU stops the streams
|
||||
// before the renegotiation lands and the case is never exercised.
|
||||
//
|
||||
// The cycle repeats: the hazard is a packet that the network thread has
|
||||
// already handed to the worker when the worker tears the stream down, and
|
||||
// at the harness's packet rates a single cycle rarely lands in that
|
||||
// window. Validation compares against the counts recorded at the last
|
||||
// drop, so every round must come back for the run to pass.
|
||||
if (video && videoRerequest) {
|
||||
constexpr int kEgressDelayMs = 150;
|
||||
constexpr int kRerequestRounds = 5;
|
||||
groupLog("Group", "video-rerequest: waiting 3s for frames, then %dms downlink delay and %d drop/re-request rounds", kEgressDelayMs, kRerequestRounds);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||
for (const auto& s : states) {
|
||||
GoSfu_SetNetworkParams(sfuHandle, s->id, 1, kEgressDelayMs, 0, 0.0, 0);
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
for (int round = 0; round < kRerequestRounds; ++round) {
|
||||
groupLog("Group", "video-rerequest: round %d", round + 1);
|
||||
dropAllVideoRequests(states);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
rerequestAllVideo(states);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
}
|
||||
}
|
||||
|
||||
// Run for the specified duration, optionally with network scenario.
|
||||
if (!networkScenario.empty() && networkScenario == "step-down-up") {
|
||||
// Scenario: start uncapped, then step down, step up, uncap.
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
|
||||
#include "group_participant.h"
|
||||
|
||||
int runGroupMode(int customParticipants, int referenceParticipants, int duration, bool quiet, bool video, const std::string& networkScenario = "", const std::set<int>& mutedParticipants = {}, bool earlyVideoRequest = false, bool videoSinkChurn = false, bool e2e = false, VideoFeed videoFeed = VideoFeed::Source, bool requestOwnVideo = false, int unmuteAfterSeconds = 0);
|
||||
int runGroupMode(int customParticipants, int referenceParticipants, int duration, bool quiet, bool video, const std::string& networkScenario = "", const std::set<int>& mutedParticipants = {}, bool earlyVideoRequest = false, bool videoSinkChurn = false, bool e2e = false, VideoFeed videoFeed = VideoFeed::Source, bool requestOwnVideo = false, int unmuteAfterSeconds = 0, bool videoRerequest = false);
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <set>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
@@ -120,6 +121,49 @@ void churnVideoSinks(const std::vector<std::unique_ptr<ParticipantState>>& state
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// dropAllVideoRequests / rerequestAllVideo (--video-rerequest)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void dropAllVideoRequests(const std::vector<std::unique_ptr<ParticipantState>>& states) {
|
||||
for (const auto& state : states) {
|
||||
if (!state || !state->instance) continue;
|
||||
std::string tag = "P" + std::to_string(state->id);
|
||||
size_t sinks = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(state->videoSinksMutex);
|
||||
sinks = state->videoSinks.size();
|
||||
}
|
||||
state->instance->setRequestedVideoChannels({});
|
||||
groupLog(tag.c_str(), "video-rerequest: dropped all video requests (%zu sink(s) kept)", sinks);
|
||||
}
|
||||
}
|
||||
|
||||
void rerequestAllVideo(const std::vector<std::unique_ptr<ParticipantState>>& states) {
|
||||
for (const auto& state : states) {
|
||||
if (!state || !state->instance) continue;
|
||||
std::string tag = "P" + std::to_string(state->id);
|
||||
std::vector<tgcalls::VideoChannelDescription> fullSet;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(state->videoSinksMutex);
|
||||
fullSet = state->requestedVideoChannels;
|
||||
state->videoRerequested = !fullSet.empty();
|
||||
// Baseline taken here, not at the drop: the drop is applied on the
|
||||
// engine's media thread some time after setRequestedVideoChannels
|
||||
// returns, and every frame that lands in between would count as
|
||||
// "after the re-request" and let a frozen tile pass. By now the
|
||||
// proxy has been detached for a second and the sinks are quiet.
|
||||
state->videoFramesAtRerequest.clear();
|
||||
for (const auto& [endpointId, sink] : state->videoSinks) {
|
||||
state->videoFramesAtRerequest[endpointId] = sink->frameCount();
|
||||
}
|
||||
}
|
||||
if (fullSet.empty()) continue;
|
||||
groupLog(tag.c_str(), "video-rerequest: requesting %zu endpoint(s) again", fullSet.size());
|
||||
state->instance->setRequestedVideoChannels(std::move(fullSet));
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// requestVideoFromEndpoints
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -647,6 +691,23 @@ GroupValidationResult validateGroupState(
|
||||
groupLog("Validate", "P%d <- endpoint %s: %d video frames (%dx%d)",
|
||||
s->id, endpointId.c_str(), frames,
|
||||
sink->lastWidth(), sink->lastHeight());
|
||||
if (s->videoRerequested) {
|
||||
// The sink kept counting across the drop, so frames that
|
||||
// arrived before the drop must not satisfy the check: only
|
||||
// growth past the recorded count proves the re-requested
|
||||
// transceiver is delivering.
|
||||
auto before = s->videoFramesAtRerequest.find(endpointId);
|
||||
int framesBefore = before != s->videoFramesAtRerequest.end() ? before->second : 0;
|
||||
result.videoRerequestExpectedPairs++;
|
||||
if (frames <= framesBefore) {
|
||||
result.videoRerequestStalledPairs++;
|
||||
groupLog("Validate", "FAIL: P%d (%s) <- endpoint %s: no video frame after the re-request (%d before, %d now)",
|
||||
s->id, s->isReference ? "ref" : "custom", endpointId.c_str(), framesBefore, frames);
|
||||
} else {
|
||||
groupLog("Validate", "OK: P%d (%s) <- endpoint %s: %d frame(s) after the re-request",
|
||||
s->id, s->isReference ? "ref" : "custom", endpointId.c_str(), frames - framesBefore);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -763,6 +824,49 @@ GroupValidationResult validateGroupState(
|
||||
}
|
||||
}
|
||||
|
||||
// Every unmuted sender must reach every peer's level reports, not only be
|
||||
// audible. Levels come from the sink on the sender's dedicated receiver
|
||||
// track; a receiver whose packets are stolen by a stray catch-all stream
|
||||
// still plays audio (the catch-all decodes it) but never reports a level,
|
||||
// so the app would never show that participant as speaking.
|
||||
for (const auto& sender : states) {
|
||||
if (sender->muted || sender->audioSsrc == 0) continue;
|
||||
for (const auto& peer : states) {
|
||||
if (peer.get() == sender.get()) continue;
|
||||
result.audioLevelExpectedPairs++;
|
||||
std::lock_guard<std::mutex> lock(peer->audioLevelsMutex);
|
||||
auto it = peer->maxAudioLevelPerSsrc.find(sender->audioSsrc);
|
||||
float maxLevel = (it != peer->maxAudioLevelPerSsrc.end()) ? it->second : 0.0f;
|
||||
if (maxLevel >= kMutedLevelThreshold) {
|
||||
result.audioLevelHeardPairs++;
|
||||
} else {
|
||||
groupLog("Validate",
|
||||
"FAIL: P%d (%s) never reported a level for P%d (ssrc=%u), max %.3f",
|
||||
peer->id, peer->isReference ? "ref" : "custom",
|
||||
sender->id, sender->audioSsrc, maxLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Every participant's log sink receives the whole process's RTC log while
|
||||
// that participant is alive, so the first participant's file holds every
|
||||
// engine's lines from the start of the run until that participant was
|
||||
// stopped, which is after the whole call ran. Scan it once.
|
||||
for (const auto& s : states) {
|
||||
FILE* f = fopen(s->logPath.c_str(), "r");
|
||||
if (!f) continue;
|
||||
static const char kNeedle[] = "Creating unsignaled receive stream for SSRC=";
|
||||
char line[4096];
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
if (strstr(line, kNeedle)) {
|
||||
result.unsignaledAudioStreams++;
|
||||
groupLog("Validate", "FAIL: %s", line);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
break;
|
||||
}
|
||||
|
||||
bool hasMuted = false;
|
||||
for (const auto& s : states) {
|
||||
if (s->muted) { hasMuted = true; break; }
|
||||
@@ -784,11 +888,16 @@ GroupValidationResult validateGroupState(
|
||||
if (video) {
|
||||
result.success = result.success && (result.selfVideoRequests == 0) && (result.ownPreviewMissing == 0);
|
||||
}
|
||||
if (result.videoRerequestExpectedPairs > 0) {
|
||||
result.success = result.success && (result.videoRerequestStalledPairs == 0);
|
||||
}
|
||||
if (result.lateUnmuteExpectedPairs > 0) {
|
||||
result.success = result.success &&
|
||||
(result.lateUnmuteHeardPairs == result.lateUnmuteExpectedPairs);
|
||||
}
|
||||
result.success = result.success && (result.mutedAudioLeaks == 0);
|
||||
result.success = result.success && (result.audioLevelHeardPairs == result.audioLevelExpectedPairs);
|
||||
result.success = result.success && (result.unsignaledAudioStreams == 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -815,11 +924,16 @@ bool printGroupSummary(
|
||||
printf("SFU: Go/Pion (in-process)\n");
|
||||
printf("Connected: %d/%d\n", result.connectedCount, result.totalParticipants);
|
||||
printf("Audio received: %d/%d\n", result.audioReceivedCount, result.totalParticipants);
|
||||
printf("Audio levels heard: %d/%d pairs\n", result.audioLevelHeardPairs, result.audioLevelExpectedPairs);
|
||||
printf("Unsignaled audio: %d stream(s) (must be 0)\n", result.unsignaledAudioStreams);
|
||||
if (video) {
|
||||
printf("Video received: %d/%d\n", result.videoReceivedPairs, result.videoExpectedPairs);
|
||||
printf("Self video requests: %d (must be 0)\n", result.selfVideoRequests);
|
||||
printf("Own preview missing: %d (must be 0)\n", result.ownPreviewMissing);
|
||||
}
|
||||
if (result.videoRerequestExpectedPairs > 0) {
|
||||
printf("Video after re-request: %d/%d stalled (must be 0)\n", result.videoRerequestStalledPairs, result.videoRerequestExpectedPairs);
|
||||
}
|
||||
if (result.lateUnmuteExpectedPairs > 0) {
|
||||
printf("Late unmute heard: %d/%d\n", result.lateUnmuteHeardPairs, result.lateUnmuteExpectedPairs);
|
||||
}
|
||||
|
||||
@@ -168,6 +168,12 @@ struct ParticipantState {
|
||||
// list rather than only the newly discovered entries. Guarded by
|
||||
// `videoSinksMutex`.
|
||||
std::vector<tgcalls::VideoChannelDescription> requestedVideoChannels;
|
||||
// --video-rerequest: frame count of every incoming sink just before the
|
||||
// dropped endpoints were requested again (a second after the drop, sinks
|
||||
// quiet). Validation requires each sink to have grown past this on the
|
||||
// same PeerConnection. Guarded by `videoSinksMutex`.
|
||||
std::map<std::string, int> videoFramesAtRerequest;
|
||||
bool videoRerequested{false};
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -191,6 +197,20 @@ struct GroupValidationResult {
|
||||
// non-trivial level for the late unmuter's SSRC, over the pairs expected.
|
||||
int lateUnmuteHeardPairs;
|
||||
int lateUnmuteExpectedPairs;
|
||||
// --video-rerequest: (receiver, endpoint) pairs that were dropped and
|
||||
// requested again, and how many of them received no frame afterwards
|
||||
// (must be 0).
|
||||
int videoRerequestExpectedPairs;
|
||||
int videoRerequestStalledPairs;
|
||||
// Every (peer, unmuted sender) pair, and how many of them the peer reported
|
||||
// at a non-trivial level. A sender that is heard but never reaches its
|
||||
// peers' level reports is the "audible but never shown speaking" defect.
|
||||
int audioLevelHeardPairs;
|
||||
int audioLevelExpectedPairs;
|
||||
// "Creating unsignaled receive stream" lines in the engine log (must be 0):
|
||||
// the reference engine must receive audio only through m-lines that signal
|
||||
// the SSRC, never through a catch-all stream that WebRTC created on its own.
|
||||
int unsignaledAudioStreams;
|
||||
// Participants that stayed muted for the whole run.
|
||||
int mutedParticipants;
|
||||
// Of those, the ones the SFU still received audio RTP from (must be 0).
|
||||
@@ -240,6 +260,17 @@ std::unique_ptr<ParticipantState> createParticipant(
|
||||
// runs against the NEW sinks, which must still receive frames.
|
||||
void churnVideoSinks(const std::vector<std::unique_ptr<ParticipantState>>& states);
|
||||
|
||||
// --video-rerequest, step 1: every participant asks the engine for NO video
|
||||
// (`setRequestedVideoChannels({})`) while keeping its sinks, the way the app
|
||||
// does when the call UI leaves the video grid.
|
||||
void dropAllVideoRequests(const std::vector<std::unique_ptr<ParticipantState>>& states);
|
||||
|
||||
// --video-rerequest, step 2: every participant records each sink's frame
|
||||
// count and requests the full accumulated set again, on the same
|
||||
// PeerConnection. Validation then requires every re-requested sink to receive
|
||||
// frames past that count.
|
||||
void rerequestAllVideo(const std::vector<std::unique_ptr<ParticipantState>>& states);
|
||||
|
||||
// Requests video from `endpointIds` (endpoints already requested are skipped):
|
||||
// registers a FakeVideoSink per new endpoint, resolves the sender's simulcast
|
||||
// SSRC groups from the SFU registry, and resends the accumulated full request
|
||||
|
||||
+4
-1
@@ -262,6 +262,7 @@ int main(int argc, char* argv[]) {
|
||||
bool enableVideo = false;
|
||||
bool earlyVideoRequest = false;
|
||||
bool videoSinkChurn = false;
|
||||
bool videoRerequest = false;
|
||||
bool e2e = false;
|
||||
VideoFeed videoFeed = VideoFeed::Source;
|
||||
bool requestOwnVideo = false;
|
||||
@@ -309,6 +310,8 @@ int main(int argc, char* argv[]) {
|
||||
e2e = true;
|
||||
} else if (std::string(argv[i]) == "--video-sink-churn") {
|
||||
videoSinkChurn = true;
|
||||
} else if (std::string(argv[i]) == "--video-rerequest") {
|
||||
videoRerequest = true;
|
||||
} else if (std::string(argv[i]) == "--video-via-capture") {
|
||||
videoFeed = VideoFeed::CaptureAtJoin;
|
||||
} else if (std::string(argv[i]) == "--video-via-capture-late") {
|
||||
@@ -397,7 +400,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
// Group mode: dispatch to separate implementation
|
||||
if (mode == "group") {
|
||||
return runGroupMode(participants, referenceParticipants, duration, gQuiet, enableVideo, networkScenario, mutedParticipants, earlyVideoRequest, videoSinkChurn, e2e, videoFeed, requestOwnVideo, unmuteAfterSeconds);
|
||||
return runGroupMode(participants, referenceParticipants, duration, gQuiet, enableVideo, networkScenario, mutedParticipants, earlyVideoRequest, videoSinkChurn, e2e, videoFeed, requestOwnVideo, unmuteAfterSeconds, videoRerequest);
|
||||
}
|
||||
if (mode == "group-churn") {
|
||||
return runGroupChurnMode(participants, referenceParticipants, duration, gQuiet, enableVideo, churnCycles);
|
||||
|
||||
Reference in new issue
Block a user