Support for video dimensions in publications (#36)
* send back video dimensions * Store video dimensions in MediaTrack and forward in TrackInfo * use committed protocol
This commit is contained in:
+12
-8
@@ -188,7 +188,7 @@ func (p *ParticipantImpl) ToProto() *livekit.ParticipantInfo {
|
||||
|
||||
p.lock.RLock()
|
||||
for _, t := range p.publishedTracks {
|
||||
info.Tracks = append(info.Tracks, ToProtoTrack(t))
|
||||
info.Tracks = append(info.Tracks, t.ToProto())
|
||||
}
|
||||
p.lock.RUnlock()
|
||||
return info
|
||||
@@ -275,26 +275,28 @@ func (p *ParticipantImpl) HandleOffer(sdp webrtc.SessionDescription) (answer web
|
||||
|
||||
// AddTrack is called when client intends to publish track.
|
||||
// records track details and lets client know it's ok to proceed
|
||||
func (p *ParticipantImpl) AddTrack(clientId, name string, trackType livekit.TrackType) {
|
||||
func (p *ParticipantImpl) AddTrack(req *livekit.AddTrackRequest) {
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
|
||||
// if track is already published, reject
|
||||
if p.pendingTracks[clientId] != nil {
|
||||
if p.pendingTracks[req.Cid] != nil {
|
||||
return
|
||||
}
|
||||
|
||||
ti := &livekit.TrackInfo{
|
||||
Type: trackType,
|
||||
Name: name,
|
||||
Sid: utils.NewGuid(utils.TrackPrefix),
|
||||
Type: req.Type,
|
||||
Name: req.Name,
|
||||
Sid: utils.NewGuid(utils.TrackPrefix),
|
||||
Width: req.Width,
|
||||
Height: req.Height,
|
||||
}
|
||||
p.pendingTracks[clientId] = ti
|
||||
p.pendingTracks[req.Cid] = ti
|
||||
|
||||
_ = p.writeMessage(&livekit.SignalResponse{
|
||||
Message: &livekit.SignalResponse_TrackPublished{
|
||||
TrackPublished: &livekit.TrackPublishedResponse{
|
||||
Cid: clientId,
|
||||
Cid: req.Cid,
|
||||
Track: ti,
|
||||
},
|
||||
},
|
||||
@@ -710,6 +712,8 @@ func (p *ParticipantImpl) onMediaTrack(track *webrtc.TrackRemote, rtpReceiver *w
|
||||
ReceiverConfig: p.params.Config.Receiver,
|
||||
AudioConfig: p.params.AudioConfig,
|
||||
Stats: p.params.Stats,
|
||||
Width: ti.Width,
|
||||
Height: ti.Height,
|
||||
})
|
||||
mt.name = ti.Name
|
||||
newTrack = true
|
||||
|
||||
Reference in New Issue
Block a user