diff --git a/internal/webrtc/manager.go b/internal/webrtc/manager.go index 9d51efb7..9f13902d 100644 --- a/internal/webrtc/manager.go +++ b/internal/webrtc/manager.go @@ -215,12 +215,12 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin return nil } - _, err = connection.AddTrack(manager.audioTrack) + rtpAudio, err := connection.AddTrack(manager.audioTrack) if err != nil { return nil, err } - _, err = connection.AddTrack(videoTrack) + rtpVideo, err := connection.AddTrack(videoTrack) if err != nil { return nil, err } @@ -356,6 +356,24 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin } }() + go func() { + rtcpBuf := make([]byte, 1500) + for { + if _, _, err := rtpAudio.Read(rtcpBuf); err != nil { + return + } + } + }() + + go func() { + rtcpBuf := make([]byte, 1500) + for { + if _, _, err := rtpVideo.Read(rtcpBuf); err != nil { + return + } + } + }() + session.SetWebRTCPeer(peer) return connection.LocalDescription(), nil }