fix: use track SID instead of source ID

This commit is contained in:
David Zhao committed 2021-02-08 16:45:18 -08:00
1 parent bc8cd33dfc
commit 61b9569e38
2 files changed
+16 -3

No files matched your search

+1 -1
View File
@@ -241,7 +241,7 @@ func (t *MediaTrack) AddReceiver(receiver *webrtc.RTPReceiver, track *webrtc.Tra
defer t.lock.Unlock()
if t.receiver == nil {
// pack ID to identify all publishedTracks
packedId := PackTrackId(t.participantId, track.ID())
packedId := PackTrackId(t.participantId, t.ID())
t.receiver = NewWrappedReceiver(sfu.NewWebRTCReceiver(receiver, track, t.participantId), packedId)
t.receiver.SetRTCPCh(t.rtcpCh)
t.receiver.OnCloseHandler(func() {
+15 -2
View File
@@ -1,6 +1,7 @@
package test
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
@@ -57,7 +58,7 @@ func TestSinglePublisher(t *testing.T) {
// a new client joins and should get the initial stream
c3 := createRTCClient("c3", defaultServerPort)
withTimeout(t, "c2 should receive two tracks", func() bool {
success := withTimeout(t, "c2 should receive two tracks", func() bool {
if len(c2.SubscribedTracks()) == 0 {
return false
}
@@ -70,10 +71,13 @@ func TestSinglePublisher(t *testing.T) {
assert.Equal(t, "webcam", tr1.StreamID())
return true
})
if !success {
t.FailNow()
}
// ensure that new client that has joined also received tracks
waitUntilConnected(t, c3)
withTimeout(t, "c2 should receive two tracks", func() bool {
success = withTimeout(t, "c2 should receive two tracks", func() bool {
if len(c3.SubscribedTracks()) == 0 {
return false
}
@@ -83,4 +87,13 @@ func TestSinglePublisher(t *testing.T) {
}
return true
})
if !success {
t.FailNow()
}
// ensure that the track ids are generated by server
tracks := c3.SubscribedTracks()[c1.ID()]
for _, tr := range tracks {
assert.True(t, strings.Contains(tr.ID(), "|TR_"), "track should begin with TR")
}
}