subscriber control of tracks (unsubscribe/mute/quality), support simulcast (#23)

* subscription control & simulcast RTC APIs

* don't remove tracks for simulcast
This commit is contained in:
David Zhao
2021-02-16 13:52:50 -08:00
committed by GitHub
parent cd5cac6c5e
commit e402d0d0af
11 changed files with 745 additions and 164 deletions
+7 -2
View File
@@ -89,6 +89,13 @@ func (t *DataTrack) OnClose(f func()) {
}
func (t *DataTrack) AddSubscriber(participant types.Participant) error {
t.lock.Lock()
defer t.lock.Unlock()
if t.subscribers[participant.ID()] != nil {
return nil
}
label := PackDataTrackLabel(t.participantId, t.ID(), t.dataChannel.Label())
downChannel, err := participant.SubscriberPC().CreateDataChannel(label, t.dataChannelOptions())
if err != nil {
@@ -100,9 +107,7 @@ func (t *DataTrack) AddSubscriber(participant types.Participant) error {
dataChannel: downChannel,
}
t.lock.Lock()
t.subscribers[participant.ID()] = sub
t.lock.Unlock()
downChannel.OnClose(func() {
t.RemoveSubscriber(sub.participantId)