WebRTC: add rtp consumer.

This commit is contained in:
Miroslav Šedivý 2021-03-03 18:53:35 +01:00
parent 9dc96036ce
commit b78132e6aa

View File

@ -215,12 +215,12 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
return nil return nil
} }
_, err = connection.AddTrack(manager.audioTrack) rtpAudio, err := connection.AddTrack(manager.audioTrack)
if err != nil { if err != nil {
return nil, err return nil, err
} }
_, err = connection.AddTrack(videoTrack) rtpVideo, err := connection.AddTrack(videoTrack)
if err != nil { if err != nil {
return nil, err 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) session.SetWebRTCPeer(peer)
return connection.LocalDescription(), nil return connection.LocalDescription(), nil
} }