@@ -254,6 +254,8 @@ SrsRtcServer::SrsRtcServer()
254
254
handler = NULL ;
255
255
hijacker = NULL ;
256
256
257
+ async_tunnel_ = false ;
258
+
257
259
_srs_config->subscribe (this );
258
260
}
259
261
@@ -295,11 +297,14 @@ srs_error_t SrsRtcServer::initialize()
295
297
_srs_rtp_msg_cache_buffers->setup (rtp_msg_cache_enabled, rtp_msg_cache_buffer_size);
296
298
_srs_rtp_msg_cache_objs->setup (rtp_msg_cache_enabled, rtp_msg_cache_msg_size);
297
299
298
- srs_trace (" RTC: Object cache init, rtp-cache=(enabled:%d,pkt:%dm-%dw,payload:%dm-%dw-%dw), msg-cache=(enabled:%d,obj:%dm-%dw,buf:%dm-%dw)" ,
300
+ async_tunnel_ = _srs_config->get_threads_async_tunnel ();
301
+
302
+ srs_trace (" RTC: Object cache init, rtp-cache=(enabled:%d,pkt:%dm-%dw,payload:%dm-%dw-%dw), msg-cache=(enabled:%d,obj:%dm-%dw,buf:%dm-%dw), tunnel=%d" ,
299
303
rtp_cache_enabled, (int )(rtp_cache_pkt_size/1024 /1024 ), _srs_rtp_cache->capacity ()/10000 ,
300
304
(int )(rtp_cache_payload_size/1024 /1024 ), _srs_rtp_raw_cache->capacity ()/10000 , _srs_rtp_fua_cache->capacity ()/10000 ,
301
305
rtp_msg_cache_enabled, (int )(rtp_msg_cache_msg_size/1024 /1024 ), _srs_rtp_msg_cache_objs->capacity ()/10000 ,
302
- (int )(rtp_msg_cache_buffer_size/1024 /1024 ), _srs_rtp_msg_cache_buffers->capacity ()/10000 );
306
+ (int )(rtp_msg_cache_buffer_size/1024 /1024 ), _srs_rtp_msg_cache_buffers->capacity ()/10000 ,
307
+ async_tunnel_);
303
308
304
309
return err;
305
310
}
@@ -446,6 +451,11 @@ srs_error_t SrsRtcServer::on_udp_packet(SrsUdpMuxSocket* skt)
446
451
ping.get_username ().c_str (), peer_id.c_str (), fast_id);
447
452
}
448
453
454
+ // Try to dig tunnel for ping-pong(the address might change).
455
+ if (async_tunnel_) {
456
+ session->dig_tunnel (skt);
457
+ }
458
+
449
459
return session->on_stun (skt, &ping);
450
460
}
451
461
@@ -475,7 +485,14 @@ srs_error_t SrsRtcServer::on_udp_packet(SrsUdpMuxSocket* skt)
475
485
if (srs_is_dtls ((uint8_t *)data, size)) {
476
486
++_srs_pps_rstuns->sugar ;
477
487
478
- return session->on_dtls (data, size);
488
+ err = session->on_dtls (data, size);
489
+
490
+ // Try to dig tunnel for DTLS packets(when DTLS done).
491
+ if (async_tunnel_) {
492
+ session->dig_tunnel (skt);
493
+ }
494
+
495
+ return err;
479
496
}
480
497
return srs_error_new (ERROR_RTC_UDP, " unknown packet" );
481
498
}
0 commit comments