diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index b53766ef2..809eb1cb2 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -412,7 +412,7 @@ rtc_server { # The exposed candidate IPs, response in SDP candidate line. It can be: # * Retrieve server IP automatically, from all network interfaces. # eth0 Retrieve server IP by specified network interface name. # TODO: Implements it. - # $CANDIDATE Read the IP from ENV variable $EIP, use * if not set, see https://github.com/ossrs/srs/issues/307#issuecomment-599028124 + # $CANDIDATE Read the IP from ENV variable, use * if not set, see https://github.com/ossrs/srs/issues/307#issuecomment-599028124 # x.x.x.x A specified IP address or DNS name, which can be access by client such as Chrome. # You can specific more than one interface name: # eth0 eth1 Use network interface eth0 and eth1. # TODO: Implements it. diff --git a/trunk/conf/rtc.conf b/trunk/conf/rtc.conf index 608ba3798..f628813d9 100644 --- a/trunk/conf/rtc.conf +++ b/trunk/conf/rtc.conf @@ -28,6 +28,7 @@ rtc_server { # The * means retrieving server IP automatically, from all network interfaces, # @see https://github.com/ossrs/srs/issues/307#issuecomment-599028124 candidate $CANDIDATE; + #candidate 10.0.0.123; } vhost __defaultVhost__ { diff --git a/trunk/src/app/srs_app_rtc_server.cpp b/trunk/src/app/srs_app_rtc_server.cpp index a44d82e7b..2704833dd 100644 --- a/trunk/src/app/srs_app_rtc_server.cpp +++ b/trunk/src/app/srs_app_rtc_server.cpp @@ -39,6 +39,7 @@ #include #include #include +#include // @global dtls certficate for rtc module. SrsDtlsCertificate* _srs_rtc_dtls_certificate = new SrsDtlsCertificate(); @@ -331,11 +332,13 @@ srs_error_t SrsRtcServer::create_session( // We allows to mock the eip of server. if (!mock_eip.empty()) { local_sdp.add_candidate(mock_eip, _srs_config->get_rtc_server_listen(), "host"); + srs_trace("RTC: Use candidate mock_eip %s", mock_eip.c_str()); } else { std::vector candidate_ips = get_candidate_ips(); for (int i = 0; i < (int)candidate_ips.size(); ++i) { local_sdp.add_candidate(candidate_ips[i], _srs_config->get_rtc_server_listen(), "host"); } + srs_trace("RTC: Use candidates %s", srs_join_vector_string(candidate_ips, ", ").c_str()); } SrsRtcSession* session = new SrsRtcSession(this); @@ -357,7 +360,7 @@ srs_error_t SrsRtcServer::create_session( return err; } -srs_error_t SrsRtcServer::create_session2(SrsSdp& local_sdp, SrsRtcSession** psession) +srs_error_t SrsRtcServer::create_session2(SrsSdp& local_sdp, const std::string& mock_eip, SrsRtcSession** psession) { srs_error_t err = srs_success; @@ -374,9 +377,15 @@ srs_error_t SrsRtcServer::create_session2(SrsSdp& local_sdp, SrsRtcSession** pse local_sdp.set_fingerprint(_srs_rtc_dtls_certificate->get_fingerprint()); // We allows to mock the eip of server. - std::vector candidate_ips = get_candidate_ips(); - for (int i = 0; i < (int)candidate_ips.size(); ++i) { - local_sdp.add_candidate(candidate_ips[i], _srs_config->get_rtc_server_listen(), "host"); + if (!mock_eip.empty()) { + local_sdp.add_candidate(mock_eip, _srs_config->get_rtc_server_listen(), "host"); + srs_trace("RTC: Use candidate mock_eip %s", mock_eip.c_str()); + } else { + std::vector candidate_ips = get_candidate_ips(); + for (int i = 0; i < (int)candidate_ips.size(); ++i) { + local_sdp.add_candidate(candidate_ips[i], _srs_config->get_rtc_server_listen(), "host"); + } + srs_trace("RTC: Use candidates %s", srs_join_vector_string(candidate_ips, ", ").c_str()); } session->set_local_sdp(local_sdp); diff --git a/trunk/src/app/srs_app_rtc_server.hpp b/trunk/src/app/srs_app_rtc_server.hpp index 164971710..84aeb4128 100644 --- a/trunk/src/app/srs_app_rtc_server.hpp +++ b/trunk/src/app/srs_app_rtc_server.hpp @@ -81,7 +81,7 @@ public: SrsRtcSession** psession ); // We start offering, create_session2 to generate offer, setup_session2 to handle answer. - srs_error_t create_session2(SrsSdp& local_sdp, SrsRtcSession** psession); + srs_error_t create_session2(SrsSdp& local_sdp, const std::string& mock_eip, SrsRtcSession** psession); srs_error_t setup_session2(SrsRtcSession* session, SrsRequest* req, const SrsSdp& remote_sdp); // Destroy the session from server. void destroy(SrsRtcSession* session);