From 04dcdc3772c8bc5775f2314578af5cba060fa3a1 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Thu, 3 Dec 2020 22:13:30 -0800 Subject: [PATCH] subscribe the right target participant --- pkg/rtc/room.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index 6c6d55388..4bd2c6003 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -119,16 +119,16 @@ func (r *Room) onTrackAdded(peer *Participant, track *Track) { defer r.lock.RUnlock() // subscribe all existing participants to this mediaTrack - for _, p := range r.participants { - if p == peer { + for _, existingParticipant := range r.participants { + if existingParticipant == peer { // skip publishing peer continue } - if err := track.AddSubscriber(peer); err != nil { + if err := track.AddSubscriber(existingParticipant); err != nil { logger.GetLogger().Errorw("could not subscribe to mediaTrack", "srcParticipant", peer.ID(), "mediaTrack", track.id, - "dstParticipant", p.ID()) + "dstParticipant", existingParticipant.ID()) } } }