Browse Source

webrtc: fix bitrate not being applied (#1984)

pull/1985/head
Alessandro Ros 3 years ago committed by GitHub
parent
commit
fb1f8ff81d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      internal/core/webrtc_session.go

24
internal/core/webrtc_session.go

@ -57,10 +57,10 @@ func insertTias(offer *webrtc.SessionDescription, value uint64) {
for _, media := range sd.MediaDescriptions { for _, media := range sd.MediaDescriptions {
if media.MediaName.Media == "video" { if media.MediaName.Media == "video" {
media.Bandwidth = append(media.Bandwidth, sdp.Bandwidth{ media.Bandwidth = []sdp.Bandwidth{{
Type: "TIAS", Type: "TIAS",
Bandwidth: value, Bandwidth: value,
}) }}
} }
} }
@ -309,21 +309,24 @@ func (s *webRTCSession) runPublish() (int, error) {
return http.StatusBadRequest, err return http.StatusBadRequest, err
} }
if s.req.videoBitrate != "" { err = s.waitGatheringDone(pc)
tmp, err := strconv.ParseUint(s.req.videoBitrate, 10, 31)
if err != nil { if err != nil {
return http.StatusBadRequest, err return http.StatusBadRequest, err
} }
insertTias(&answer, tmp*1024) tmp := pc.LocalDescription()
} answer = *tmp
err = s.waitGatheringDone(pc) if s.req.videoBitrate != "" {
tmp, err := strconv.ParseUint(s.req.videoBitrate, 10, 31)
if err != nil { if err != nil {
return http.StatusBadRequest, err return http.StatusBadRequest, err
} }
err = s.writeAnswer(pc.LocalDescription()) insertTias(&answer, tmp*1024)
}
err = s.writeAnswer(&answer)
if err != nil { if err != nil {
return http.StatusBadRequest, err return http.StatusBadRequest, err
} }
@ -429,7 +432,10 @@ func (s *webRTCSession) runRead() (int, error) {
return http.StatusBadRequest, err return http.StatusBadRequest, err
} }
err = s.writeAnswer(pc.LocalDescription()) tmp := pc.LocalDescription()
answer = *tmp
err = s.writeAnswer(&answer)
if err != nil { if err != nil {
return http.StatusBadRequest, err return http.StatusBadRequest, err
} }

Loading…
Cancel
Save