server-sdk-go
server-sdk-go copied to clipboard
Can I publish the track in Muted?
my application need to publish track muted by default. but I cant find option controll muted in TrackPublicationOptions so, I want to add muted option to SDK like below
// localparticipant.go
func (p *LocalParticipant) PublishTrack(track webrtc.TrackLocal, opts *TrackPublicationOptions) (*LocalTrackPublication, error) {
if opts == nil {
opts = &TrackPublicationOptions{}
}
kind := KindFromRTPType(track.Kind())
// default sources, since clients generally look for camera/mic
if opts.Source == livekit.TrackSource_UNKNOWN {
if kind == TrackKindVideo {
opts.Source = livekit.TrackSource_CAMERA
} else if kind == TrackKindAudio {
opts.Source = livekit.TrackSource_MICROPHONE
}
}
pub := NewLocalTrackPublication(kind, track, *opts, p.engine.client)
pub.onMuteChanged = p.onTrackMuted
req := &livekit.AddTrackRequest{
Cid: track.ID(),
Name: opts.Name,
Source: opts.Source,
Type: kind.ProtoType(),
Width: uint32(opts.VideoWidth),
Height: uint32(opts.VideoHeight),
DisableDtx: opts.DisableDTX,
Stereo: opts.Stereo,
Stream: opts.Stream,
Muted: opts.Muted, <- add here
}
if kind == TrackKindVideo {
// single layer
req.Layers = []*livekit.VideoLayer{
{
Quality: livekit.VideoQuality_HIGH,
Width: uint32(opts.VideoWidth),
Height: uint32(opts.VideoHeight),
},
}
}
and, change TrackPublicationOptions
// publication.go
type TrackPublicationOptions struct {
Name string
Source livekit.TrackSource
// Set dimensions for video
VideoWidth int
VideoHeight int
// Opus only
DisableDTX bool
Stereo bool
// which stream the track belongs to, used to group tracks together.
// if not specified, server will infer it from track source to bundle camera/microphone, screenshare/audio together
Stream string
Muted bool <- add here
}
That's not possible currently. The track will need to send a few packets in order to be registered correctly.
@davidzhao thank you for your reply. If that's the case, I don't have a choice, I'll try to publish and then mute.