Skip to content

Commit

Permalink
Replace addTransceiver with addTrack to avoid renegotiation loop
Browse files Browse the repository at this point in the history
  • Loading branch information
tyohan committed Oct 31, 2024
1 parent 3a52945 commit 4c2f2d3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ func (c *Client) setClientTrack(t ITrack) iClientTrack {

localTrack := outputTrack.LocalTrack()

senderTcv, err := c.peerConnection.PC().AddTransceiverFromTrack(localTrack, webrtc.RTPTransceiverInit{Direction: webrtc.RTPTransceiverDirectionSendonly})
sender, err := c.peerConnection.PC().AddTrack(localTrack)
if err != nil {
c.log.Errorf("client: error on adding track ", err)
return nil
Expand All @@ -1022,8 +1022,6 @@ func (c *Client) setClientTrack(t ITrack) iClientTrack {
c.muTracks.Unlock()
}()

sender := senderTcv.Sender()

if sender == nil {
return
}
Expand All @@ -1032,7 +1030,7 @@ func (c *Client) setClientTrack(t ITrack) iClientTrack {
})

// enable RTCP report and stats
c.enableReportAndStats(senderTcv.Sender(), outputTrack)
c.enableReportAndStats(sender, outputTrack)

c.muTracks.Lock()
c.clientTracks[outputTrack.ID()] = outputTrack
Expand Down

0 comments on commit 4c2f2d3

Please sign in to comment.