mirror of
https://github.com/livekit/livekit.git
synced 2026-03-30 22:05:39 +00:00
munges
This commit is contained in:
@@ -16,6 +16,7 @@ package rtc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"slices"
|
||||
"sync"
|
||||
|
||||
"github.com/pion/rtcp"
|
||||
@@ -311,7 +312,7 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, wr *
|
||||
if transceiver == nil {
|
||||
info := t.params.MediaTrack.ToProto()
|
||||
addTrackParams := types.AddTrackParams{
|
||||
Stereo: info.Stereo,
|
||||
Stereo: slices.Contains(info.AudioFeatures, livekit.AudioTrackFeature_TF_STEREO),
|
||||
Red: !info.DisableRed,
|
||||
}
|
||||
if addTrackParams.Red && (len(codecs) == 1 && mime.IsMimeTypeStringOpus(codecs[0].MimeType)) {
|
||||
|
||||
@@ -2713,6 +2713,8 @@ func (p *ParticipantImpl) addPendingTrackLocked(req *livekit.AddTrackRequest) *l
|
||||
|
||||
track.(*MediaTrack).UpdateCodecInfo(req.SimulcastCodecs)
|
||||
return track.ToProto()
|
||||
|
||||
// SINGLE-PEER-CONNECTION-TODO: AddRemoteTrack
|
||||
}
|
||||
|
||||
backupCodecPolicy := req.BackupCodecPolicy
|
||||
@@ -3792,7 +3794,7 @@ func (p *ParticipantImpl) UpdateAudioTrack(update *livekit.UpdateLocalAudioTrack
|
||||
if ti.Sid == update.TrackSid {
|
||||
isPending = true
|
||||
|
||||
ti.AudioFeatures = update.Features
|
||||
ti.AudioFeatures = sutils.DedupeSlice(update.Features)
|
||||
ti.Stereo = false
|
||||
ti.DisableDtx = false
|
||||
for _, feature := range update.Features {
|
||||
|
||||
@@ -16,6 +16,7 @@ package rtc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -467,7 +468,7 @@ func (p *ParticipantImpl) configurePublisherAnswer(answer webrtc.SessionDescript
|
||||
if !ti.DisableDtx {
|
||||
attr.Value += ";usedtx=1"
|
||||
}
|
||||
if ti.Stereo {
|
||||
if slices.Contains(ti.AudioFeatures, livekit.AudioTrackFeature_TF_STEREO) {
|
||||
attr.Value += ";stereo=1;maxaveragebitrate=510000"
|
||||
}
|
||||
m.Attributes[i] = attr
|
||||
|
||||
@@ -935,7 +935,6 @@ func (t *PCTransport) AddTrack(trackLocal webrtc.TrackLocal, params types.AddTra
|
||||
return
|
||||
}
|
||||
|
||||
// as there is no way to get transceiver from sender, search
|
||||
for _, tr := range t.pc.GetTransceivers() {
|
||||
if tr.Sender() == sender {
|
||||
transceiver = tr
|
||||
@@ -1021,7 +1020,7 @@ func (t *PCTransport) AddRemoteTrackAndNegotiate(
|
||||
}
|
||||
}
|
||||
if !disabled && !mime.IsMimeTypeStringRTX(c.RTPCodecCapability.MimeType) {
|
||||
// SINGLE-PEER-CONNECTION-TOOD: remove `nack` for RED and add `nack` for Opus
|
||||
// SINGLE-PEER-CONNECTION-TOOD: remove `nack` for RED?
|
||||
if rtpCodecType == webrtc.RTPCodecTypeVideo {
|
||||
c.RTPCodecCapability.RTCPFeedback = rtcpFeedbackConfig.Video
|
||||
} else {
|
||||
@@ -1082,9 +1081,40 @@ func (t *PCTransport) AddRemoteTrackAndNegotiate(
|
||||
leftCodecs = append(leftCodecs, enabledCodec)
|
||||
}
|
||||
}
|
||||
transceiver.SetCodecPreferences(append(append([]webrtc.RTPCodecParameters{}, preferredCodecs...), leftCodecs...))
|
||||
// SINGLE-PEER-CONNECTION-TOOD: need to configure stereo for audio codecs
|
||||
// SINGLE-PEER-CONNECTION-TODO: do setCodecPreferencesOpusRedForPublisher for audio
|
||||
|
||||
enabledCodecs = append(append([]webrtc.RTPCodecParameters{}, preferredCodecs...), leftCodecs...)
|
||||
|
||||
// enable dtx, stereo for Opus
|
||||
opusPayload := webrtc.PayloadType(0)
|
||||
for _, enabledCodec := range enabledCodecs {
|
||||
if mime.IsMimeTypeStringOpus(enabledCodec.RTPCodecCapability.MimeType) {
|
||||
opusPayload = enabledCodec.PayloadType
|
||||
if !ti.DisableDtx {
|
||||
enabledCodec.RTPCodecCapability.SDPFmtpLine += ";usedtx=1"
|
||||
}
|
||||
if slices.Contains(ti.AudioFeatures, livekit.AudioTrackFeature_TF_STEREO) {
|
||||
enabledCodec.RTPCodecCapability.SDPFmtpLine += ";stereo=1;maxaveragebitrate=510000"
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// prioritize audio/red if not disabled and available
|
||||
if opusPayload != 0 {
|
||||
preferredCodecs = nil
|
||||
leftCodecs = nil
|
||||
for _, enabledCodec := range enabledCodecs {
|
||||
if !ti.DisableRed && mime.IsMimeTypeStringRED(enabledCodec.RTPCodecCapability.MimeType) && strings.Contains(enabledCodec.RTPCodecCapability.SDPFmtpLine, strconv.FormatInt(int64(opusPayload), 10)) {
|
||||
preferredCodecs = append(preferredCodecs, enabledCodec)
|
||||
} else {
|
||||
leftCodecs = append(leftCodecs, enabledCodec)
|
||||
}
|
||||
}
|
||||
|
||||
enabledCodecs = append(append([]webrtc.RTPCodecParameters{}, preferredCodecs...), leftCodecs...)
|
||||
}
|
||||
|
||||
transceiver.SetCodecPreferences(enabledCodecs)
|
||||
|
||||
t.Negotiate(true)
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user