1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-12-22 15:25:48 +01:00

Replace RTCPFeedback in down tracks.

We used to copy the RTCPFeeback field from the up track.  It is
more correct to regenerate it with the exact feedback types
that we expect.
This commit is contained in:
Juliusz Chroboczek 2024-11-30 17:55:24 +01:00
parent 9eb7428b98
commit ef0201c94d
2 changed files with 32 additions and 18 deletions

View file

@ -252,14 +252,19 @@ func CodecPayloadType(codec webrtc.RTPCodecCapability) (webrtc.PayloadType, erro
} }
} }
func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) { // VideoRTCPFeedback are the RTCP feedback types that we expect for video
fb := []webrtc.RTCPFeedback{ // tracks.
{"goog-remb", ""}, var VideoRTCPFeedback = []webrtc.RTCPFeedback{
{"nack", ""}, {"goog-remb", ""},
{"nack", "pli"}, {"nack", ""},
{"ccm", "fir"}, {"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 var codecs []webrtc.RTPCodecCapability
switch name { switch name {
@ -268,7 +273,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) {
{ {
"video/VP8", 90000, 0, "video/VP8", 90000, 0,
"", "",
fb, VideoRTCPFeedback,
}, },
} }
case "vp9": case "vp9":
@ -276,12 +281,12 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) {
{ {
"video/VP9", 90000, 0, "video/VP9", 90000, 0,
"profile-id=0", "profile-id=0",
fb, VideoRTCPFeedback,
}, },
{ {
"video/VP9", 90000, 0, "video/VP9", 90000, 0,
"profile-id=2", "profile-id=2",
fb, VideoRTCPFeedback,
}, },
} }
case "av1": case "av1":
@ -289,7 +294,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) {
{ {
"video/AV1", 90000, 0, "video/AV1", 90000, 0,
"", "",
fb, VideoRTCPFeedback,
}, },
} }
case "h264": case "h264":
@ -297,7 +302,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) {
{ {
"video/H264", 90000, 0, "video/H264", 90000, 0,
"level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f", "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f",
fb, VideoRTCPFeedback,
}, },
} }
case "opus": case "opus":
@ -305,7 +310,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) {
{ {
"audio/opus", 48000, 2, "audio/opus", 48000, 2,
"minptime=10;useinbandfec=1;stereo=1;sprop-stereo=1", "minptime=10;useinbandfec=1;stereo=1;sprop-stereo=1",
nil, AudioRTCPFeedback,
}, },
} }
case "g722": case "g722":
@ -313,7 +318,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) {
{ {
"audio/G722", 8000, 1, "audio/G722", 8000, 1,
"", "",
nil, AudioRTCPFeedback,
}, },
} }
case "pcmu": case "pcmu":
@ -321,7 +326,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) {
{ {
"audio/PCMU", 8000, 1, "audio/PCMU", 8000, 1,
"", "",
nil, AudioRTCPFeedback,
}, },
} }
case "pcma": case "pcma":
@ -329,7 +334,7 @@ func codecsFromName(name string) ([]webrtc.RTPCodecParameters, error) {
{ {
"audio/PCMU", 8000, 1, "audio/PCMU", 8000, 1,
"", "",
nil, AudioRTCPFeedback,
}, },
} }
default: default:

View file

@ -9,6 +9,7 @@ import (
"log" "log"
"net" "net"
"os" "os"
"strings"
"sync" "sync"
"time" "time"
@ -381,8 +382,16 @@ func addDownTrackUnlocked(conn *rtpDownConnection, remoteTrack *rtpUpTrack) erro
msid = "dummy" 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( local, err := webrtc.NewTrackLocalStaticRTP(
remoteTrack.Codec(), id, msid, remoteCodec, id, msid,
) )
if err != nil { if err != nil {
return err return err
@ -1660,7 +1669,7 @@ func handleClientMessage(c *webClient, m clientMessage) error {
m := clientMessage{ m := clientMessage{
Type: "usermessage", Type: "usermessage",
Kind: "clearchat", Kind: "clearchat",
Value: m.Value, Value: m.Value,
Privileged: true, Privileged: true,
} }
err := broadcast(g.GetClients(nil), m) err := broadcast(g.GetClients(nil), m)