Separate publish and subscribe enabled codecs for finer grained control. (#2217)
This commit is contained in:
+16
-17
@@ -101,7 +101,8 @@ type ParticipantParams struct {
|
|||||||
PLIThrottleConfig config.PLIThrottleConfig
|
PLIThrottleConfig config.PLIThrottleConfig
|
||||||
CongestionControlConfig config.CongestionControlConfig
|
CongestionControlConfig config.CongestionControlConfig
|
||||||
// codecs that are enabled for this room
|
// codecs that are enabled for this room
|
||||||
EnabledCodecs []*livekit.Codec
|
PublishEnabledCodecs []*livekit.Codec
|
||||||
|
SubscribeEnabledCodecs []*livekit.Codec
|
||||||
Logger logger.Logger
|
Logger logger.Logger
|
||||||
SimTracks map[uint32]SimulcastTrackInfo
|
SimTracks map[uint32]SimulcastTrackInfo
|
||||||
Grants *auth.ClaimGrants
|
Grants *auth.ClaimGrants
|
||||||
@@ -249,7 +250,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
|
|||||||
p.state.Store(livekit.ParticipantInfo_JOINING)
|
p.state.Store(livekit.ParticipantInfo_JOINING)
|
||||||
p.grants = params.Grants
|
p.grants = params.Grants
|
||||||
p.SetResponseSink(params.Sink)
|
p.SetResponseSink(params.Sink)
|
||||||
p.setupEnabledCodecs(params.EnabledCodecs, params.ClientConf.GetDisabledCodecs())
|
p.setupEnabledCodecs(params.PublishEnabledCodecs, params.SubscribeEnabledCodecs, params.ClientConf.GetDisabledCodecs())
|
||||||
|
|
||||||
p.supervisor.OnPublicationError(p.onPublicationError)
|
p.supervisor.OnPublicationError(p.onPublicationError)
|
||||||
|
|
||||||
@@ -2334,9 +2335,7 @@ func (p *ParticipantImpl) SendDataPacket(dp *livekit.DataPacket, data []byte) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParticipantImpl) setupEnabledCodecs(codecs []*livekit.Codec, disabledCodecs *livekit.DisabledCodecs) {
|
func (p *ParticipantImpl) setupEnabledCodecs(publishEnabledCodecs []*livekit.Codec, subscribeEnabledCodecs []*livekit.Codec, disabledCodecs *livekit.DisabledCodecs) {
|
||||||
subscribeCodecs := make([]*livekit.Codec, 0, len(codecs))
|
|
||||||
publishCodecs := make([]*livekit.Codec, 0, len(codecs))
|
|
||||||
shouldDisable := func(c *livekit.Codec, disabled []*livekit.Codec) bool {
|
shouldDisable := func(c *livekit.Codec, disabled []*livekit.Codec) bool {
|
||||||
for _, disableCodec := range disabled {
|
for _, disableCodec := range disabled {
|
||||||
// disable codec's fmtp is empty means disable this codec entirely
|
// disable codec's fmtp is empty means disable this codec entirely
|
||||||
@@ -2346,22 +2345,22 @@ func (p *ParticipantImpl) setupEnabledCodecs(codecs []*livekit.Codec, disabledCo
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for _, c := range codecs {
|
|
||||||
var publishDisabled bool
|
publishCodecs := make([]*livekit.Codec, 0, len(publishEnabledCodecs))
|
||||||
var subscribeDisabled bool
|
for _, c := range publishEnabledCodecs {
|
||||||
if shouldDisable(c, disabledCodecs.GetCodecs()) {
|
if shouldDisable(c, disabledCodecs.GetCodecs()) || shouldDisable(c, disabledCodecs.GetPublish()) {
|
||||||
publishDisabled = true
|
continue
|
||||||
subscribeDisabled = true
|
|
||||||
} else if shouldDisable(c, disabledCodecs.GetPublish()) {
|
|
||||||
publishDisabled = true
|
|
||||||
}
|
}
|
||||||
if !publishDisabled {
|
|
||||||
publishCodecs = append(publishCodecs, c)
|
publishCodecs = append(publishCodecs, c)
|
||||||
}
|
}
|
||||||
if !subscribeDisabled {
|
p.enabledPublishCodecs = publishCodecs
|
||||||
|
|
||||||
|
subscribeCodecs := make([]*livekit.Codec, 0, len(subscribeEnabledCodecs))
|
||||||
|
for _, c := range subscribeEnabledCodecs {
|
||||||
|
if shouldDisable(c, disabledCodecs.GetCodecs()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
subscribeCodecs = append(subscribeCodecs, c)
|
subscribeCodecs = append(subscribeCodecs, c)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
p.enabledSubscribeCodecs = subscribeCodecs
|
p.enabledSubscribeCodecs = subscribeCodecs
|
||||||
p.enabledPublishCodecs = publishCodecs
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -755,7 +755,8 @@ func newParticipantForTestWithOpts(identity livekit.ParticipantIdentity, opts *p
|
|||||||
ProtocolVersion: opts.protocolVersion,
|
ProtocolVersion: opts.protocolVersion,
|
||||||
PLIThrottleConfig: conf.RTC.PLIThrottle,
|
PLIThrottleConfig: conf.RTC.PLIThrottle,
|
||||||
Grants: grants,
|
Grants: grants,
|
||||||
EnabledCodecs: enabledCodecs,
|
PublishEnabledCodecs: enabledCodecs,
|
||||||
|
SubscribeEnabledCodecs: enabledCodecs,
|
||||||
ClientConf: opts.clientConf,
|
ClientConf: opts.clientConf,
|
||||||
ClientInfo: ClientInfo{ClientInfo: opts.clientInfo},
|
ClientInfo: ClientInfo{ClientInfo: opts.clientInfo},
|
||||||
Logger: LoggerWithParticipant(logger.GetLogger(), identity, sid, false),
|
Logger: LoggerWithParticipant(logger.GetLogger(), identity, sid, false),
|
||||||
|
|||||||
@@ -393,7 +393,8 @@ func (r *RoomManager) StartSession(
|
|||||||
Trailer: room.Trailer(),
|
Trailer: room.Trailer(),
|
||||||
PLIThrottleConfig: r.config.RTC.PLIThrottle,
|
PLIThrottleConfig: r.config.RTC.PLIThrottle,
|
||||||
CongestionControlConfig: r.config.RTC.CongestionControl,
|
CongestionControlConfig: r.config.RTC.CongestionControl,
|
||||||
EnabledCodecs: protoRoom.EnabledCodecs,
|
PublishEnabledCodecs: protoRoom.EnabledCodecs,
|
||||||
|
SubscribeEnabledCodecs: protoRoom.EnabledCodecs,
|
||||||
Grants: pi.Grants,
|
Grants: pi.Grants,
|
||||||
Logger: pLogger,
|
Logger: pLogger,
|
||||||
ClientConf: clientConf,
|
ClientConf: clientConf,
|
||||||
|
|||||||
Reference in New Issue
Block a user