@@ -231,10 +231,10 @@ func (e *RTCEngine) SetLogger(l protoLogger.Logger) {
231
231
e .signalHandler .SetLogger (l )
232
232
e .signalTransport .SetLogger (l )
233
233
if e .publisher != nil {
234
- e .publisher .SetLogger (l )
234
+ e .publisher .SetLogger (l . WithValues ( "transport" , livekit . SignalTarget_PUBLISHER ) )
235
235
}
236
236
if e .subscriber != nil {
237
- e .subscriber .SetLogger (l )
237
+ e .subscriber .SetLogger (l . WithValues ( "transport" , livekit . SignalTarget_SUBSCRIBER ) )
238
238
}
239
239
}
240
240
@@ -254,7 +254,7 @@ func (e *RTCEngine) JoinContext(
254
254
)
255
255
if e .signallingVersion == signalling .SignallingVersionV2 {
256
256
e .pclock .Lock ()
257
- e .createPublisherPCLocked (webrtc.Configuration {}, false )
257
+ e .createPublisherPCLocked (webrtc.Configuration {})
258
258
259
259
publisherOffer , err = e .publisher .GetOffer ()
260
260
if err != nil {
@@ -369,23 +369,23 @@ func (e *RTCEngine) configure(
369
369
if e .publisher != nil {
370
370
setConfiguration (e .publisher , configuration )
371
371
} else {
372
- if err := e .createPublisherPCLocked (configuration , ! e . subscriberPrimary ); err != nil {
372
+ if err := e .createPublisherPCLocked (configuration ); err != nil {
373
373
return err
374
374
}
375
375
}
376
376
377
377
if e .subscriber != nil {
378
378
setConfiguration (e .subscriber , configuration )
379
379
} else {
380
- if err := e .createSubscriberPCLocked (configuration , e . subscriberPrimary ); err != nil {
380
+ if err := e .createSubscriberPCLocked (configuration ); err != nil {
381
381
return err
382
382
}
383
383
}
384
384
385
385
return nil
386
386
}
387
387
388
- func (e * RTCEngine ) createPublisherPCLocked (configuration webrtc.Configuration , isPrimary bool ) error {
388
+ func (e * RTCEngine ) createPublisherPCLocked (configuration webrtc.Configuration ) error {
389
389
var err error
390
390
if e .publisher , err = NewPCTransport (PCTransportParams {
391
391
Configuration : configuration ,
@@ -397,7 +397,7 @@ func (e *RTCEngine) createPublisherPCLocked(configuration webrtc.Configuration,
397
397
}); err != nil {
398
398
return err
399
399
}
400
- e .publisher .SetLogger (e .log )
400
+ e .publisher .SetLogger (e .log . WithValues ( "transport" , livekit . SignalTarget_PUBLISHER ) )
401
401
402
402
e .publisher .pc .OnICECandidate (func (candidate * webrtc.ICECandidate ) {
403
403
if candidate == nil {
@@ -407,20 +407,23 @@ func (e *RTCEngine) createPublisherPCLocked(configuration webrtc.Configuration,
407
407
init := candidate .ToJSON ()
408
408
e .log .Debugw (
409
409
"local ICE candidate" ,
410
- "target " , livekit .SignalTarget_PUBLISHER ,
410
+ "transport " , livekit .SignalTarget_PUBLISHER ,
411
411
"candidate" , init .Candidate ,
412
412
)
413
413
if err := e .signalTransport .SendMessage (
414
414
e .signalling .SignalICECandidate (
415
415
protosignalling .ToProtoTrickle (init , livekit .SignalTarget_PUBLISHER , false ),
416
416
),
417
417
); err != nil {
418
- e .log .Errorw ("could not send ICE candidates for publisher" , err )
418
+ e .log .Errorw (
419
+ "could not send ICE candidate" , err ,
420
+ "transport" , livekit .SignalTarget_PUBLISHER ,
421
+ )
419
422
}
420
423
})
421
424
422
425
e .publisher .pc .OnICEConnectionStateChange (func (state webrtc.ICEConnectionState ) {
423
- e .handleICEConnectionStateChange (e .publisher , livekit .SignalTarget_PUBLISHER , isPrimary , state )
426
+ e .handleICEConnectionStateChange (e .publisher , livekit .SignalTarget_PUBLISHER , state )
424
427
})
425
428
426
429
e .publisher .OnOffer = func (offer webrtc.SessionDescription ) {
@@ -459,7 +462,6 @@ func (e *RTCEngine) createPublisherPCLocked(configuration webrtc.Configuration,
459
462
460
463
// SIGNALLING-V2-TODO: may need a separate peer connection
461
464
// SIGNALLING-V2-TODO: instantiating this should rely on signal transport strategy rather than signalling version
462
- // SIGNALLING-V2-TODO: for signalling v2 instantiate publisher PC before connect and then do just SetConfiguration in OnConnectResponse
463
465
if e .signallingVersion == signalling .SignallingVersionV2 {
464
466
e .signallingDC , err = e .publisher .pc .CreateDataChannel (signallingDataChannelName , & webrtc.DataChannelInit {
465
467
Ordered : & trueVal ,
@@ -475,6 +477,7 @@ func (e *RTCEngine) createPublisherPCLocked(configuration webrtc.Configuration,
475
477
SignalHandler : e .signalHandler ,
476
478
})
477
479
e .signalTransport .SetAsyncTransport (signallingTransportDataChannel )
480
+ e .signalTransport .Start ()
478
481
})
479
482
e .signallingDC .OnClose (func () {
480
483
// SIGNALLING-V2-TODO: should call SignalTransportHandler.OnClose
@@ -486,15 +489,15 @@ func (e *RTCEngine) createPublisherPCLocked(configuration webrtc.Configuration,
486
489
return nil
487
490
}
488
491
489
- func (e * RTCEngine ) createSubscriberPCLocked (configuration webrtc.Configuration , isPrimary bool ) error {
492
+ func (e * RTCEngine ) createSubscriberPCLocked (configuration webrtc.Configuration ) error {
490
493
var err error
491
494
if e .subscriber , err = NewPCTransport (PCTransportParams {
492
495
Configuration : configuration ,
493
496
RetransmitBufferSize : e .connParams .RetransmitBufferSize ,
494
497
}); err != nil {
495
498
return err
496
499
}
497
- e .subscriber .SetLogger (e .log )
500
+ e .subscriber .SetLogger (e .log . WithValues ( "transport" , livekit . SignalTarget_SUBSCRIBER ) )
498
501
499
502
e .subscriber .OnRemoteDescriptionSettled (e .createSubscriberPCAnswerAndSend )
500
503
@@ -506,20 +509,23 @@ func (e *RTCEngine) createSubscriberPCLocked(configuration webrtc.Configuration,
506
509
init := candidate .ToJSON ()
507
510
e .log .Debugw (
508
511
"local ICE candidate" ,
509
- "target " , livekit .SignalTarget_SUBSCRIBER ,
512
+ "transport " , livekit .SignalTarget_SUBSCRIBER ,
510
513
"candidate" , init .Candidate ,
511
514
)
512
515
if err := e .signalTransport .SendMessage (
513
516
e .signalling .SignalICECandidate (
514
517
protosignalling .ToProtoTrickle (init , livekit .SignalTarget_SUBSCRIBER , false ),
515
518
),
516
519
); err != nil {
517
- e .log .Errorw ("could not send ICE candidates for subscriber" , err )
520
+ e .log .Errorw (
521
+ "could not send ICE candidate" , err ,
522
+ "transport" , livekit .SignalTarget_SUBSCRIBER ,
523
+ )
518
524
}
519
525
})
520
526
521
527
e .subscriber .pc .OnICEConnectionStateChange (func (state webrtc.ICEConnectionState ) {
522
- e .handleICEConnectionStateChange (e .subscriber , livekit .SignalTarget_SUBSCRIBER , isPrimary , state )
528
+ e .handleICEConnectionStateChange (e .subscriber , livekit .SignalTarget_SUBSCRIBER , state )
523
529
})
524
530
525
531
e .subscriber .pc .OnTrack (func (remote * webrtc.TrackRemote , receiver * webrtc.RTPReceiver ) {
@@ -545,7 +551,6 @@ func (e *RTCEngine) createSubscriberPCLocked(configuration webrtc.Configuration,
545
551
func (e * RTCEngine ) handleICEConnectionStateChange (
546
552
transport * PCTransport ,
547
553
signalTarget livekit.SignalTarget ,
548
- isPrimary bool ,
549
554
state webrtc.ICEConnectionState ,
550
555
) {
551
556
switch state {
@@ -559,9 +564,7 @@ func (e *RTCEngine) handleICEConnectionStateChange(
559
564
e .log .Debugw ("ICE disconnected" , "transport" , signalTarget )
560
565
case webrtc .ICEConnectionStateFailed :
561
566
e .log .Debugw ("ICE failed" , "transport" , signalTarget )
562
- if isPrimary {
563
- e .handleDisconnect (false )
564
- }
567
+ e .handleDisconnect (false )
565
568
}
566
569
}
567
570
0 commit comments