From 22befff6c18d6429171778fdcd6a387911f2e001 Mon Sep 17 00:00:00 2001 From: boks1971 Date: Sat, 16 Aug 2025 20:06:48 +0530 Subject: [PATCH] limit to receive only --- pkg/rtc/participant_sdp.go | 4 ++++ pkg/rtc/transport.go | 10 ++++++++++ pkg/rtc/transportmanager.go | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/pkg/rtc/participant_sdp.go b/pkg/rtc/participant_sdp.go index 3cea576a4..731f328b3 100644 --- a/pkg/rtc/participant_sdp.go +++ b/pkg/rtc/participant_sdp.go @@ -179,6 +179,10 @@ func (p *ParticipantImpl) populateMid(parsedOffer *sdp.SessionDescription) { continue } + if p.TransportManager.GetPublisherRTPTransceiverDirection(mid) != webrtc.RTPTransceiverDirectionRecvonly { + continue + } + p.pendingTracksLock.Lock() signalCid, ti, migrated := p.getPendingTrackByTrackTypeWithoutMid(trackType) if migrated || ti == nil || signalCid == "" { diff --git a/pkg/rtc/transport.go b/pkg/rtc/transport.go index ca7fe9efb..d8fa9c0b7 100644 --- a/pkg/rtc/transport.go +++ b/pkg/rtc/transport.go @@ -1160,6 +1160,16 @@ func (t *PCTransport) GetRTPReceiver(mid string) *webrtc.RTPReceiver { return nil } +func (t *PCTransport) GetRTPTransceiverDirection(mid string) webrtc.RTPTransceiverDirection { + for _, tr := range t.pc.GetTransceivers() { + if tr.Mid() == mid { + return tr.Direction() + } + } + + return webrtc.RTPTransceiverDirectionUnknown +} + func (t *PCTransport) CreateDataChannel(label string, dci *webrtc.DataChannelInit) error { dc, err := t.pc.CreateDataChannel(label, dci) if err != nil { diff --git a/pkg/rtc/transportmanager.go b/pkg/rtc/transportmanager.go index 82bb32ee4..49da1456a 100644 --- a/pkg/rtc/transportmanager.go +++ b/pkg/rtc/transportmanager.go @@ -248,6 +248,14 @@ func (t *TransportManager) GetPublisherRTPReceiver(mid string) *webrtc.RTPReceiv } } +func (t *TransportManager) GetPublisherRTPTransceiverDirection(mid string) webrtc.RTPTransceiverDirection { + if t.params.SinglePeerConnection { + return t.subscriber.GetRTPTransceiverDirection(mid) + } else { + return t.publisher.GetRTPTransceiverDirection(mid) + } +} + func (t *TransportManager) WritePublisherRTCP(pkts []rtcp.Packet) error { if t.params.SinglePeerConnection { return t.subscriber.WriteRTCP(pkts)