Use constant data channel ids in proto (#5029)

Also don't create neogitated channels in migration case.
This commit is contained in:
cnderrauber authored and GitHub committed 2026-10-19 19:41:05 +08:00
1 parent 11d2736d86
commit 7f6224d823
5 files changed
+15 -19

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ require (
github.com/jxskiss/base62 v1.1.0
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731
github.com/livekit/mediatransportutil v0.0.0-20261014192331-dd8e31a0adc0
github.com/livekit/protocol v1.52.2-0.20261017062747-c45251b06f46
github.com/livekit/protocol v1.52.2-0.20261019104604-8a409dee75df
github.com/livekit/psrpc v0.8.2
github.com/mackerelio/go-osstat v0.2.8
github.com/magefile/mage v1.17.2
+2 -2
View File
@@ -166,8 +166,8 @@ github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731 h1:9x+U2HGLrSw5AT
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
github.com/livekit/mediatransportutil v0.0.0-20261014192331-dd8e31a0adc0 h1:BSLyHr3Lsl71bHGHsfiYNmbohugR2yoaf9HjAZeFJnc=
github.com/livekit/mediatransportutil v0.0.0-20261014192331-dd8e31a0adc0/go.mod h1:o8CFmAdrVwzJNOCsQCLUzXRjokkufNshnQHOe4fRaqU=
github.com/livekit/protocol v1.52.2-0.20261017062747-c45251b06f46 h1:GdUO6oD7i98eZ1fAPw8Lke6swP5UA9q4QL/NvKyy/Yc=
github.com/livekit/protocol v1.52.2-0.20261017062747-c45251b06f46/go.mod h1:kUTAI2TrTngGOiWP6MTAOkJpru6YYGd0MP9wzlDATy4=
github.com/livekit/protocol v1.52.2-0.20261019104604-8a409dee75df h1:HTs2Bh+gerbHsecuE7p7W77G7JWjW5gaGxGyJxroPRU=
github.com/livekit/protocol v1.52.2-0.20261019104604-8a409dee75df/go.mod h1:kUTAI2TrTngGOiWP6MTAOkJpru6YYGd0MP9wzlDATy4=
github.com/livekit/psrpc v0.8.2 h1:7tbkhBJoYlK5Csfkdv1XYbZjyAQeaEZgupvIXNCv7Dc=
github.com/livekit/psrpc v0.8.2/go.mod h1:6KnU8vULoizX0Er9NNfeKJDV8ug87j3fuo19M0bhj6Q=
github.com/livekit/webrtc-pion/v4 v4.2.18-warp.6 h1:UaGYlQ/Ma73LN12xPDlH3OBYNfOEDTVOtHdRZbHg2dY=
-6
View File
@@ -72,12 +72,6 @@ const (
ReliableDataChannel = "_reliable"
DataTrackDataChannel = "_data_track"
// Fixed SCTP stream IDs of the publisher data channels which create the data channels as negotiated.
// Kept away from low IDs that in-band channels auto-allocate.
NegotiatedReliableDataChannelID uint16 = 100
NegotiatedLossyDataChannelID uint16 = 101
NegotiatedDataTrackDataChannelID uint16 = 102
fastNegotiationFrequency = 10 * time.Millisecond
negotiationFrequency = 150 * time.Millisecond
negotiationFailedTimeout = 15 * time.Second
+9 -7
View File
@@ -439,9 +439,15 @@ func (t *TransportManager) useNegotiatedDataChannels() bool {
}
func (t *TransportManager) createNegotiatedDataChannelsForPublisher() error {
// Migration recreates the publisher data channels as negotiated with the IDs the client reports
// in ProcessPendingPublisherDataChannels instead.
if t.params.Migration {
return nil
}
negotiated := true
reliableID := NegotiatedReliableDataChannelID
reliableID := uint16(livekit.NegotiatedDataChannelID_NDCI_RELIABLE)
ordered := true
if err := t.publisher.CreateDataChannel(ReliableDataChannel, &webrtc.DataChannelInit{
Ordered: &ordered,
@@ -453,7 +459,7 @@ func (t *TransportManager) createNegotiatedDataChannelsForPublisher() error {
ordered = false
retransmits := uint16(0)
lossyID := NegotiatedLossyDataChannelID
lossyID := uint16(livekit.NegotiatedDataChannelID_NDCI_LOSSY)
if err := t.publisher.CreateDataChannel(LossyDataChannel, &webrtc.DataChannelInit{
Ordered: &ordered,
MaxRetransmits: &retransmits,
@@ -463,7 +469,7 @@ func (t *TransportManager) createNegotiatedDataChannelsForPublisher() error {
return err
}
dataTrackID := NegotiatedDataTrackDataChannelID
dataTrackID := uint16(livekit.NegotiatedDataChannelID_NDCI_DATA_TRACK)
return t.publisher.CreateDataChannel(DataTrackDataChannel, &webrtc.DataChannelInit{
Ordered: &ordered,
MaxRetransmits: &retransmits,
@@ -966,10 +972,6 @@ func (t *TransportManager) ProcessPendingPublisherDataChannels() {
t.pendingDataChannelsPublisher = nil
t.lock.Unlock()
if t.useNegotiatedDataChannels() {
return
}
ordered := true
negotiated := true
+3 -3
View File
@@ -1415,7 +1415,7 @@ func encodeQueryParam(key, value string) string {
func createNegotiatedDataChannels(t *rtc.PCTransport) error {
negotiated := true
ordered := true
reliableID := rtc.NegotiatedReliableDataChannelID
reliableID := uint16(livekit.NegotiatedDataChannelID_NDCI_RELIABLE)
if err := t.CreateDataChannel(rtc.ReliableDataChannel, &webrtc.DataChannelInit{
Ordered: &ordered,
Negotiated: &negotiated,
@@ -1426,7 +1426,7 @@ func createNegotiatedDataChannels(t *rtc.PCTransport) error {
ordered = false
maxRetransmits := uint16(0)
lossyID := rtc.NegotiatedLossyDataChannelID
lossyID := uint16(livekit.NegotiatedDataChannelID_NDCI_LOSSY)
if err := t.CreateDataChannel(rtc.LossyDataChannel, &webrtc.DataChannelInit{
Ordered: &ordered,
MaxRetransmits: &maxRetransmits,
@@ -1436,7 +1436,7 @@ func createNegotiatedDataChannels(t *rtc.PCTransport) error {
return err
}
dataTrackID := rtc.NegotiatedDataTrackDataChannelID
dataTrackID := uint16(livekit.NegotiatedDataChannelID_NDCI_DATA_TRACK)
return t.CreateDataChannel(rtc.DataTrackDataChannel, &webrtc.DataChannelInit{
Ordered: &ordered,
MaxRetransmits: &maxRetransmits,