protocol to synchronize published tracks
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/logger"
|
||||
"github.com/livekit/livekit-server/pkg/utils"
|
||||
"github.com/livekit/livekit-server/proto/livekit"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -57,6 +58,10 @@ func (t *Track) Start() {
|
||||
go t.forwardWorker()
|
||||
}
|
||||
|
||||
func (t *Track) Kind() webrtc.RTPCodecType {
|
||||
return t.mediaTrack.Kind()
|
||||
}
|
||||
|
||||
// subscribes participant to current mediaTrack
|
||||
// creates and add necessary forwarders and starts them
|
||||
func (t *Track) AddSubscriber(participant *Participant) error {
|
||||
@@ -125,6 +130,22 @@ func (t *Track) RemoveAllSubscribers() {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Track) ToProto() *livekit.TrackInfo {
|
||||
var kind livekit.TrackInfo_Type
|
||||
switch t.Kind() {
|
||||
case webrtc.RTPCodecTypeAudio:
|
||||
kind = livekit.TrackInfo_AUDIO
|
||||
case webrtc.RTPCodecTypeVideo:
|
||||
kind = livekit.TrackInfo_VIDEO
|
||||
}
|
||||
|
||||
return &livekit.TrackInfo{
|
||||
Sid: t.id,
|
||||
Type: kind,
|
||||
Name: t.mediaTrack.Label(),
|
||||
}
|
||||
}
|
||||
|
||||
// forwardWorker reads from the receiver and writes to each sender
|
||||
func (t *Track) forwardWorker() {
|
||||
for pkt := range t.receiver.RTPChan() {
|
||||
|
||||
Reference in New Issue
Block a user