fix: use track SID instead of source ID
This commit is contained in:
@@ -241,7 +241,7 @@ func (t *MediaTrack) AddReceiver(receiver *webrtc.RTPReceiver, track *webrtc.Tra
|
|||||||
defer t.lock.Unlock()
|
defer t.lock.Unlock()
|
||||||
if t.receiver == nil {
|
if t.receiver == nil {
|
||||||
// pack ID to identify all publishedTracks
|
// 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 = NewWrappedReceiver(sfu.NewWebRTCReceiver(receiver, track, t.participantId), packedId)
|
||||||
t.receiver.SetRTCPCh(t.rtcpCh)
|
t.receiver.SetRTCPCh(t.rtcpCh)
|
||||||
t.receiver.OnCloseHandler(func() {
|
t.receiver.OnCloseHandler(func() {
|
||||||
|
|||||||
+15
-2
@@ -1,6 +1,7 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@@ -57,7 +58,7 @@ func TestSinglePublisher(t *testing.T) {
|
|||||||
// a new client joins and should get the initial stream
|
// a new client joins and should get the initial stream
|
||||||
c3 := createRTCClient("c3", defaultServerPort)
|
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 {
|
if len(c2.SubscribedTracks()) == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -70,10 +71,13 @@ func TestSinglePublisher(t *testing.T) {
|
|||||||
assert.Equal(t, "webcam", tr1.StreamID())
|
assert.Equal(t, "webcam", tr1.StreamID())
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
if !success {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
// ensure that new client that has joined also received tracks
|
// ensure that new client that has joined also received tracks
|
||||||
waitUntilConnected(t, c3)
|
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 {
|
if len(c3.SubscribedTracks()) == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -83,4 +87,13 @@ func TestSinglePublisher(t *testing.T) {
|
|||||||
}
|
}
|
||||||
return true
|
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")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user