Support multiple codecs for WebRTC producer

This commit is contained in:
Alexey Khit
2023-03-12 14:30:42 +03:00
parent 0b714a59e5
commit 0382fbf8a9
2 changed files with 32 additions and 32 deletions

View File

@@ -43,15 +43,18 @@ func (c *Conn) GetAnswer() (answer string, err error) {
for _, md := range sd.MediaDescriptions {
for _, attr := range md.Attributes {
var direction webrtc.RTPTransceiverDirection
switch attr.Key {
case "recvonly":
_, _ = c.pc.AddTransceiverFromKind(
webrtc.NewRTPCodecType(md.MediaName.Media),
webrtc.RTPTransceiverInit{Direction: webrtc.RTPTransceiverDirectionSendonly},
)
direction = webrtc.RTPTransceiverDirectionSendonly
case "sendrecv":
_, _ = c.pc.AddTransceiverFromKind(
webrtc.NewRTPCodecType(md.MediaName.Media),
direction = webrtc.RTPTransceiverDirectionSendrecv
}
if direction > 0 {
_, _ = c.pc.AddTransceiverFromTrack(
NewTrack(md.MediaName.Media),
webrtc.RTPTransceiverInit{Direction: direction},
)
}
}