diff --git a/group/group.go b/group/group.go index 2a9b1f9..1bdd82e 100644 --- a/group/group.go +++ b/group/group.go @@ -252,14 +252,19 @@ func CodecPayloadType(codec webrtc.RTPCodecCapability) (webrtc.PayloadType, erro } } -func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) { - fb := []webrtc.RTCPFeedback{ - {"goog-remb", ""}, - {"nack", ""}, - {"nack", "pli"}, - {"ccm", "fir"}, - } +// VideoRTCPFeedback are the RTCP feedback types that we expect for video +// tracks. +var VideoRTCPFeedback = []webrtc.RTCPFeedback{ + {"goog-remb", ""}, + {"nack", ""}, + {"nack", "pli"}, + {"ccm", "fir"}, +} +// AudioRTCPFeedback is like VideoRTCPFeedback but for audio tracks. +var AudioRTCPFeedback = []webrtc.RTCPFeedback(nil) + +func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) { var codecs []webrtc.RTPCodecCapability switch name { @@ -268,7 +273,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) { { "video/VP8", 90000, 0, "", - fb, + VideoRTCPFeedback, }, } case "vp9": @@ -276,12 +281,12 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) { { "video/VP9", 90000, 0, "profile-id=0", - fb, + VideoRTCPFeedback, }, { "video/VP9", 90000, 0, "profile-id=2", - fb, + VideoRTCPFeedback, }, } case "av1": @@ -289,7 +294,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) { { "video/AV1", 90000, 0, "", - fb, + VideoRTCPFeedback, }, } case "h264": @@ -297,7 +302,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) { { "video/H264", 90000, 0, "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f", - fb, + VideoRTCPFeedback, }, } case "opus": @@ -305,7 +310,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) { { "audio/opus", 48000, 2, "minptime=10;useinbandfec=1;stereo=1;sprop-stereo=1", - nil, + AudioRTCPFeedback, }, } case "g722": @@ -313,7 +318,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) { { "audio/G722", 8000, 1, "", - nil, + AudioRTCPFeedback, }, } case "pcmu": @@ -321,7 +326,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) { { "audio/PCMU", 8000, 1, "", - nil, + AudioRTCPFeedback, }, } case "pcma": @@ -329,7 +334,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) { { "audio/PCMU", 8000, 1, "", - nil, + AudioRTCPFeedback, }, } default: diff --git a/rtpconn/webclient.go b/rtpconn/webclient.go index 5e6567c..2730031 100644 --- a/rtpconn/webclient.go +++ b/rtpconn/webclient.go @@ -9,6 +9,7 @@ import ( "log" "net" "os" + "strings" "sync" "time" @@ -381,8 +382,16 @@ func addDownTrackUnlocked(conn *rtpDownConnection, remoteTrack *rtpUpTrack) erro msid = "dummy" } + // replace the RTCP feedback types with the ones we understand + remoteCodec := remoteTrack.Codec() + if strings.HasPrefix(strings.ToLower(remoteCodec.MimeType), "video/") { + remoteCodec.RTCPFeedback = group.VideoRTCPFeedback + } else { + remoteCodec.RTCPFeedback = group.AudioRTCPFeedback + } + local, err := webrtc.NewTrackLocalStaticRTP( - remoteTrack.Codec(), id, msid, + remoteCodec, id, msid, ) if err != nil { return err @@ -1660,7 +1669,7 @@ func handleClientMessage(c *webClient, m clientMessage) error { m := clientMessage{ Type: "usermessage", Kind: "clearchat", - Value: m.Value, + Value: m.Value, Privileged: true, } err := broadcast(g.GetClients(nil), m)