@@ -9,7 +9,7 @@ use crate::messages::{
9
9
} ;
10
10
use crate :: server:: states:: ServerStates ;
11
11
use bytes:: BytesMut ;
12
- use log:: { debug, warn} ;
12
+ use log:: { debug, info , trace , warn} ;
13
13
use retty:: channel:: { Handler , InboundContext , InboundHandler , OutboundContext , OutboundHandler } ;
14
14
use retty:: transport:: TransportContext ;
15
15
use shared:: error:: { Error , Result } ;
@@ -275,6 +275,12 @@ impl GatewayInbound {
275
275
endpoint_id, four_tuple
276
276
) ) ) ?;
277
277
transport. set_association_handle_and_stream_id ( association_handle, stream_id) ;
278
+ info ! (
279
+ "{}/{}: data channel is ready for {:?}" ,
280
+ session_id,
281
+ endpoint_id,
282
+ transport. four_tuple( )
283
+ ) ;
278
284
endpoint. set_renegotiation_needed ( !new_transceivers. is_empty ( ) ) ;
279
285
280
286
let ( mids, transceivers) = endpoint. get_mut_mids_and_transceivers ( ) ;
@@ -336,7 +342,7 @@ impl GatewayInbound {
336
342
let answer_str =
337
343
serde_json:: to_string ( & answer) . map_err ( |err| Error :: Other ( err. to_string ( ) ) ) ?;
338
344
339
- let peers = GatewayInbound :: get_other_transport_contexts (
345
+ let peers = GatewayInbound :: get_other_datachannel_transport_contexts (
340
346
server_states,
341
347
& transport_context,
342
348
) ?;
@@ -396,10 +402,10 @@ impl GatewayInbound {
396
402
) -> Result < Vec < TaggedMessageEvent > > {
397
403
//TODO: Selective Forwarding RTP Packets
398
404
let peers =
399
- GatewayInbound :: get_other_transport_contexts ( server_states, & transport_context) ?;
405
+ GatewayInbound :: get_other_media_transport_contexts ( server_states, & transport_context) ?;
400
406
401
407
let mut outgoing_messages = Vec :: with_capacity ( peers. len ( ) ) ;
402
- for ( transport, _ , _ , _ ) in peers {
408
+ for transport in peers {
403
409
outgoing_messages. push ( TaggedMessageEvent {
404
410
now,
405
411
transport,
@@ -418,10 +424,10 @@ impl GatewayInbound {
418
424
) -> Result < Vec < TaggedMessageEvent > > {
419
425
//TODO: Selective Forwarding RTCP Packets
420
426
let peers =
421
- GatewayInbound :: get_other_transport_contexts ( server_states, & transport_context) ?;
427
+ GatewayInbound :: get_other_media_transport_contexts ( server_states, & transport_context) ?;
422
428
423
429
let mut outgoing_messages = Vec :: with_capacity ( peers. len ( ) ) ;
424
- for ( transport, _ , _ , _ ) in peers {
430
+ for transport in peers {
425
431
outgoing_messages. push ( TaggedMessageEvent {
426
432
now,
427
433
transport,
@@ -483,7 +489,7 @@ impl GatewayInbound {
483
489
}
484
490
}
485
491
486
- fn get_other_transport_contexts (
492
+ fn get_other_datachannel_transport_contexts (
487
493
server_states : & mut ServerStates ,
488
494
transport_context : & TransportContext ,
489
495
) -> Result < Vec < ( TransportContext , usize , u16 , bool ) > > {
@@ -518,9 +524,56 @@ impl GatewayInbound {
518
524
other_endpoint. is_renegotiation_needed ( ) ,
519
525
) ) ;
520
526
} else {
521
- warn ! (
522
- "session id {}/endpoint id {}'s data channel is not ready" ,
523
- session_id, endpoint_id
527
+ // data channel is not ready yet for other_endpoint_id's other_four_tuple.
528
+ // this transport just joins, but data channel is still setup
529
+ trace ! (
530
+ "{}/{}'s data channel is not ready yet for {:?} since it is still setup" ,
531
+ session_id,
532
+ other_endpoint_id,
533
+ other_four_tuple,
534
+ ) ;
535
+ }
536
+ }
537
+ }
538
+ }
539
+ Ok ( peers)
540
+ }
541
+
542
+ fn get_other_media_transport_contexts (
543
+ server_states : & mut ServerStates ,
544
+ transport_context : & TransportContext ,
545
+ ) -> Result < Vec < TransportContext > > {
546
+ let four_tuple = transport_context. into ( ) ;
547
+ let ( session_id, endpoint_id) = server_states
548
+ . find_endpoint ( & four_tuple)
549
+ . ok_or ( Error :: ErrClientTransportNotSet ) ?;
550
+ let session = server_states
551
+ . get_session ( & session_id)
552
+ . ok_or ( Error :: Other ( format ! (
553
+ "can't find session id {}" ,
554
+ session_id
555
+ ) ) ) ?;
556
+
557
+ let mut peers = vec ! [ ] ;
558
+ let endpoints = session. get_endpoints ( ) ;
559
+ for ( & other_endpoint_id, other_endpoint) in endpoints. iter ( ) {
560
+ if other_endpoint_id != endpoint_id {
561
+ let transports = other_endpoint. get_transports ( ) ;
562
+ for ( other_four_tuple, other_transport) in transports. iter ( ) {
563
+ if other_transport. is_local_srtp_context_ready ( ) {
564
+ peers. push ( TransportContext {
565
+ local_addr : other_four_tuple. local_addr ,
566
+ peer_addr : other_four_tuple. peer_addr ,
567
+ ecn : transport_context. ecn ,
568
+ } ) ;
569
+ } else {
570
+ // local_srtp_context is not ready yet for other_endpoint_id's other_four_tuple.
571
+ // this transport just joins, but local_srtp_context is still setup
572
+ trace ! (
573
+ "{}/{}'s local_srtp_context is not ready yet for {:?} since it is still setup" ,
574
+ session_id,
575
+ other_endpoint_id,
576
+ other_four_tuple,
524
577
) ;
525
578
}
526
579
}
0 commit comments