receiver class, imported relevant SFU helpers

This commit is contained in:
David Zhao
2020-10-23 23:01:35 -07:00
parent 71d3a470f5
commit 6c039bc64f
12 changed files with 890 additions and 25 deletions
+12 -4
View File
@@ -18,6 +18,7 @@ const (
type MediaEngine struct {
webrtc.MediaEngine
feedbackTypes []webrtc.RTCPFeedback
tCCExt int
}
// PopulateFromSDP finds all codecs in sd and adds them to m, using the dynamic
@@ -27,16 +28,23 @@ type MediaEngine struct {
// PopulateFromSDP allows an answerer to properly match the PayloadTypes from the offerer.
// A MediaEngine populated by PopulateFromSDP should be used only for a single session.
func (e *MediaEngine) PopulateFromSDP(sd webrtc.SessionDescription) error {
sdp := sdp.SessionDescription{}
if err := sdp.Unmarshal([]byte(sd.SDP)); err != nil {
s := sdp.SessionDescription{}
if err := s.Unmarshal([]byte(sd.SDP)); err != nil {
return err
}
for _, md := range sdp.MediaDescriptions {
for _, md := range s.MediaDescriptions {
if md.MediaName.Media != mediaNameAudio && md.MediaName.Media != mediaNameVideo {
continue
}
for _, att := range md.Attributes {
if att.Key == sdp.AttrKeyExtMap && strings.HasSuffix(att.Value, sdp.TransportCCURI) {
e.tCCExt, _ = strconv.Atoi(att.Value[:1])
break
}
}
for _, format := range md.MediaName.Formats {
pt, err := strconv.Atoi(format)
if err != nil {
@@ -44,7 +52,7 @@ func (e *MediaEngine) PopulateFromSDP(sd webrtc.SessionDescription) error {
}
payloadType := uint8(pt)
payloadCodec, err := sdp.GetCodecForPayloadType(payloadType)
payloadCodec, err := s.GetCodecForPayloadType(payloadType)
if err != nil {
return fmt.Errorf("could not find codec for payload type %d", payloadType)
}