From b78132e6aadacc3b16082a10a13f03c4c892c53f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Wed, 3 Mar 2021 18:53:35 +0100 Subject: [PATCH] WebRTC: add rtp consumer. --- internal/webrtc/manager.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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 }