Separate publish and subscribe enabled codecs for finer grained control. (#2217)
This commit is contained in:
+18
-19
@@ -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()) || shouldDisable(c, disabledCodecs.GetPublish()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
publishCodecs = append(publishCodecs, c)
|
||||||
|
}
|
||||||
|
p.enabledPublishCodecs = publishCodecs
|
||||||
|
|
||||||
|
subscribeCodecs := make([]*livekit.Codec, 0, len(subscribeEnabledCodecs))
|
||||||
|
for _, c := range subscribeEnabledCodecs {
|
||||||
if shouldDisable(c, disabledCodecs.GetCodecs()) {
|
if shouldDisable(c, disabledCodecs.GetCodecs()) {
|
||||||
publishDisabled = true
|
continue
|
||||||
subscribeDisabled = true
|
|
||||||
} else if shouldDisable(c, disabledCodecs.GetPublish()) {
|
|
||||||
publishDisabled = true
|
|
||||||
}
|
|
||||||
if !publishDisabled {
|
|
||||||
publishCodecs = append(publishCodecs, c)
|
|
||||||
}
|
|
||||||
if !subscribeDisabled {
|
|
||||||
subscribeCodecs = append(subscribeCodecs, c)
|
|
||||||
}
|
}
|
||||||
|
subscribeCodecs = append(subscribeCodecs, c)
|
||||||
}
|
}
|
||||||
p.enabledSubscribeCodecs = subscribeCodecs
|
p.enabledSubscribeCodecs = subscribeCodecs
|
||||||
p.enabledPublishCodecs = publishCodecs
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -748,19 +748,20 @@ func newParticipantForTestWithOpts(identity livekit.ParticipantIdentity, opts *p
|
|||||||
}
|
}
|
||||||
sid := livekit.ParticipantID(utils.NewGuid(utils.ParticipantPrefix))
|
sid := livekit.ParticipantID(utils.NewGuid(utils.ParticipantPrefix))
|
||||||
p, _ := NewParticipant(ParticipantParams{
|
p, _ := NewParticipant(ParticipantParams{
|
||||||
SID: sid,
|
SID: sid,
|
||||||
Identity: identity,
|
Identity: identity,
|
||||||
Config: rtcConf,
|
Config: rtcConf,
|
||||||
Sink: &routingfakes.FakeMessageSink{},
|
Sink: &routingfakes.FakeMessageSink{},
|
||||||
ProtocolVersion: opts.protocolVersion,
|
ProtocolVersion: opts.protocolVersion,
|
||||||
PLIThrottleConfig: conf.RTC.PLIThrottle,
|
PLIThrottleConfig: conf.RTC.PLIThrottle,
|
||||||
Grants: grants,
|
Grants: grants,
|
||||||
EnabledCodecs: enabledCodecs,
|
PublishEnabledCodecs: enabledCodecs,
|
||||||
ClientConf: opts.clientConf,
|
SubscribeEnabledCodecs: enabledCodecs,
|
||||||
ClientInfo: ClientInfo{ClientInfo: opts.clientInfo},
|
ClientConf: opts.clientConf,
|
||||||
Logger: LoggerWithParticipant(logger.GetLogger(), identity, sid, false),
|
ClientInfo: ClientInfo{ClientInfo: opts.clientInfo},
|
||||||
Telemetry: &telemetryfakes.FakeTelemetryService{},
|
Logger: LoggerWithParticipant(logger.GetLogger(), identity, sid, false),
|
||||||
VersionGenerator: utils.NewDefaultTimedVersionGenerator(),
|
Telemetry: &telemetryfakes.FakeTelemetryService{},
|
||||||
|
VersionGenerator: utils.NewDefaultTimedVersionGenerator(),
|
||||||
})
|
})
|
||||||
p.isPublisher.Store(opts.publisher)
|
p.isPublisher.Store(opts.publisher)
|
||||||
p.updateState(livekit.ParticipantInfo_ACTIVE)
|
p.updateState(livekit.ParticipantInfo_ACTIVE)
|
||||||
|
|||||||
@@ -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