From 67af635be7916fb6584f0496f0cfdf4aa621da02 Mon Sep 17 00:00:00 2001 From: Erik Hortsch Date: Thu, 16 Jul 2026 13:40:29 -0700 Subject: [PATCH] rtc: route answer to publisher in single-PC / one-shot mode Correct the previous nil-guard: dropping the answer prevents the crash but breaks subscribe renegotiation. In single-PC (UseSinglePeerConnection) and one-shot signalling modes the single publisher PC carries both directions; when the server renegotiates to push a subscribed track it offers on that PC (NegotiateSubscriber -> publisher.Negotiate -> signalSendOffer) and the client replies with an answer. Route that answer to the publisher, matching every other subscriber-path method in TransportManager (GetSubscriberRTT, AddTrackLocal, AddSubscribedTrack, NegotiateSubscriber, ...). Co-Authored-By: Claude Opus 4.8 --- pkg/rtc/transportmanager.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/rtc/transportmanager.go b/pkg/rtc/transportmanager.go index 3534e09c7..12c58cbb0 100644 --- a/pkg/rtc/transportmanager.go +++ b/pkg/rtc/transportmanager.go @@ -542,12 +542,11 @@ func (t *TransportManager) ProcessPendingPublisherOffer() { } func (t *TransportManager) HandleAnswer(answer webrtc.SessionDescription, answerId uint32) { - if t.subscriber == nil { - // no subscriber transport in single-PC / one-shot signalling mode - t.params.Logger.Warnw("answer received, but no subscriber peer connection", nil) - return + if t.params.UseOneShotSignallingMode || t.params.UseSinglePeerConnection { + t.publisher.HandleRemoteDescription(answer, answerId) + } else { + t.subscriber.HandleRemoteDescription(answer, answerId) } - t.subscriber.HandleRemoteDescription(answer, answerId) } // AddICECandidate adds candidates for remote peer