Add participant option for data track auto-subscribe. (#4240)
* Add participant option for data track auto-subscribe. Default disabled. * protocol update to use data track auto subscribe setting * deps
This commit is contained in:
@@ -127,6 +127,7 @@ var (
|
||||
|
||||
type Options struct {
|
||||
AutoSubscribe bool
|
||||
AutoSubscribeDataTrack bool
|
||||
Publish string
|
||||
Attributes map[string]string
|
||||
ClientInfo *livekit.ClientInfo
|
||||
@@ -162,7 +163,8 @@ func NewWebSocketConn(host, token string, opts *Options) (*websocket.Conn, error
|
||||
}
|
||||
|
||||
connectionSettings := &livekit.ConnectionSettings{
|
||||
AutoSubscribe: opts.AutoSubscribe,
|
||||
AutoSubscribe: opts.AutoSubscribe,
|
||||
AutoSubscribeDataTrack: &opts.AutoSubscribeDataTrack,
|
||||
}
|
||||
|
||||
joinRequest := &livekit.JoinRequest{
|
||||
@@ -185,6 +187,7 @@ func NewWebSocketConn(host, token string, opts *Options) (*websocket.Conn, error
|
||||
sdk := "go"
|
||||
if opts != nil {
|
||||
connectUrl += fmt.Sprintf("&auto_subscribe=%t", opts.AutoSubscribe)
|
||||
connectUrl += fmt.Sprintf("&auto_subscribe_data_track=%t", opts.AutoSubscribeDataTrack)
|
||||
if opts.Publish != "" {
|
||||
connectUrl += encodeQueryParam("publish", opts.Publish)
|
||||
}
|
||||
|
||||
+4
-4
@@ -209,9 +209,9 @@ func scenarioDataUnlabeledPublish(t *testing.T) {
|
||||
func scenarioDataTracksPublishingUponJoining(t *testing.T) {
|
||||
for _, testRTCServicePath := range testRTCServicePaths {
|
||||
t.Run(fmt.Sprintf("scenarioDataTracksPublishingUponJoining/testRTCServicePath=%s", testRTCServicePath.String()), func(t *testing.T) {
|
||||
c1 := createRTCClient("dtpuj_1", defaultServerPort, testRTCServicePath, nil)
|
||||
c2 := createRTCClient("dtpuj_2", secondServerPort, testRTCServicePath, &testclient.Options{AutoSubscribe: true})
|
||||
c3 := createRTCClient("dtpuj_3", defaultServerPort, testRTCServicePath, &testclient.Options{AutoSubscribe: true})
|
||||
c1 := createRTCClient("dtpuj_1", defaultServerPort, testRTCServicePath, &testclient.Options{AutoSubscribeDataTrack: true})
|
||||
c2 := createRTCClient("dtpuj_2", secondServerPort, testRTCServicePath, &testclient.Options{AutoSubscribeDataTrack: true})
|
||||
c3 := createRTCClient("dtpuj_3", defaultServerPort, testRTCServicePath, &testclient.Options{AutoSubscribeDataTrack: true})
|
||||
defer stopClients(c1, c2, c3)
|
||||
|
||||
waitUntilConnected(t, c1, c2, c3)
|
||||
@@ -261,7 +261,7 @@ func scenarioDataTracksPublishingUponJoining(t *testing.T) {
|
||||
|
||||
logger.Infow("c2 reconnecting")
|
||||
// connect to a diff port
|
||||
c2 = createRTCClient("dtpuj_2", defaultServerPort, testRTCServicePath, nil)
|
||||
c2 = createRTCClient("dtpuj_2", defaultServerPort, testRTCServicePath, &testclient.Options{AutoSubscribeDataTrack: true})
|
||||
defer c2.Stop()
|
||||
waitUntilConnected(t, c2)
|
||||
writers = publishDataTracksForClients(t, c2)
|
||||
|
||||
@@ -1036,8 +1036,8 @@ func TestSinglePublisherDataTrack(t *testing.T) {
|
||||
|
||||
for _, testRTCServicePath := range testRTCServicePaths {
|
||||
t.Run(fmt.Sprintf("testRTCServicePath=%s", testRTCServicePath.String()), func(t *testing.T) {
|
||||
c1 := createRTCClient("c1", defaultServerPort, testRTCServicePath, nil)
|
||||
c2 := createRTCClient("c2", defaultServerPort, testRTCServicePath, nil)
|
||||
c1 := createRTCClient("c1", defaultServerPort, testRTCServicePath, &testclient.Options{AutoSubscribeDataTrack: true})
|
||||
c2 := createRTCClient("c2", defaultServerPort, testRTCServicePath, &testclient.Options{AutoSubscribeDataTrack: true})
|
||||
waitUntilConnected(t, c1, c2)
|
||||
|
||||
// publish a couple of data tracks and ensure clients receive it ok
|
||||
@@ -1061,7 +1061,7 @@ func TestSinglePublisherDataTrack(t *testing.T) {
|
||||
})
|
||||
|
||||
// a new client joins and should get the initial stream
|
||||
c3 := createRTCClient("c3", defaultServerPort, testRTCServicePath, nil)
|
||||
c3 := createRTCClient("c3", defaultServerPort, testRTCServicePath, &testclient.Options{AutoSubscribeDataTrack: true})
|
||||
|
||||
// ensure that new client that has joined also received data tracks
|
||||
waitUntilConnected(t, c3)
|
||||
|
||||
Reference in New Issue
Block a user