diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf
index 1a23b87c9..3c8abe1c6 100644
--- a/trunk/conf/full.conf
+++ b/trunk/conf/full.conf
@@ -306,6 +306,25 @@ srt_server {
default_app live;
}
+#############################################################################################
+# WebRTC server section
+#############################################################################################
+rtc {
+ # Whether enable WebRTC server.
+ # default: off
+ enabled on;
+ # The udp listen port, we will reuse it for connections.
+ # default: 8080
+ listen 8000;
+ # The exposed candidate IP, response in SDP candidate line.
+ # It can be:
+ # * Retrieve server IP automatically, specified by stats.network for multiple networks.
+ # $CANDIDATE Read the IP from ENV variable $EIP, 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.
+ # default: *
+ candidate *;
+}
+
#############################################################################################
# Kafka sections
#############################################################################################
diff --git a/trunk/conf/rtc.conf b/trunk/conf/rtc.conf
index fe8d545ec..03b42c75d 100644
--- a/trunk/conf/rtc.conf
+++ b/trunk/conf/rtc.conf
@@ -1,40 +1,32 @@
-# main config for srs.
-# @see full.conf for detail config.
listen 1935;
max_connections 1000;
-srs_log_tank file;
+srs_log_tank console;
srs_log_file ./objs/srs.log;
-http_api {
- enabled on;
- listen 1985;
- raw_api {
- enabled on;
- allow_reload on;
- allow_query on;
- allow_update on;
- }
-}
+
http_server {
enabled on;
listen 8080;
dir ./objs/nginx/html;
}
-rtc {
+
+http_api {
enabled on;
- listen 9527;
- # candidate device ip: *(all interface), 192.168.1.1 ...
- candidate *;
+ listen 1985;
}
stats {
network 0;
- disk sda sdb xvda xvdb;
}
+rtc {
+ enabled on;
+ # Listen at udp://8000
+ listen 8000;
+ # The * means using IP of network interface stats.network,
+ # For example, if stats.network=0, then use IP of eth0 as candidate.
+ # @see https://github.com/ossrs/srs/issues/307#issuecomment-599028124
+ candidate *;
+}
+
vhost __defaultVhost__ {
- http_remux {
- enabled on;
- mount [vhost]/[app]/[stream].flv;
- }
}
-
diff --git a/trunk/research/players/rtc.html b/trunk/research/players/rtc.html
index 4dd8e44f2..80cd1a2c0 100644
--- a/trunk/research/players/rtc.html
+++ b/trunk/research/players/rtc.html
@@ -7,7 +7,7 @@
rtc_media_player:
-
+
@@ -16,7 +16,7 @@ rtc_media_player:
var PeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
var SessionDescription = window.RTCSessionDescription || window.mozRTCSessionDescription || window.webkitRTCSessionDescription;
-var url = "http://hw.com:1985/api/v1/sdp/";
+var url = "http://localhost:1985/api/v1/sdp/";
var method = "POST";
var shouldBeAsync = true;
@@ -40,7 +40,7 @@ var sendViewerOfferFn = function(desc) {
pc.setLocalDescription(desc);
- var sdp_json = {"sdp":desc.sdp, "app":"webrtc", "stream":"test"};
+ var sdp_json = {"sdp":desc.sdp, "app":"live", "stream":"livestream"};
request.send(JSON.stringify(sdp_json));
};
diff --git a/trunk/research/players/rtc_upload.html b/trunk/research/players/rtc_upload.html
deleted file mode 100644
index 68c515d8e..000000000
--- a/trunk/research/players/rtc_upload.html
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-
-
-
-
-
-
-
local_media_player:
-
-
rtc_media_player:
-
-
-
-
-
-
-
diff --git a/trunk/research/players/srs_rtc_player.html b/trunk/research/players/srs_rtc_player.html
deleted file mode 100644
index bbb605ab5..000000000
--- a/trunk/research/players/srs_rtc_player.html
+++ /dev/null
@@ -1,90 +0,0 @@
-
-
-
-
-
-
-
-
-rtc_media_player:
-
-
-
-
-
-
-
diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp
index a206dc6da..cb47e12e0 100644
--- a/trunk/src/app/srs_app_config.cpp
+++ b/trunk/src/app/srs_app_config.cpp
@@ -4290,7 +4290,7 @@ bool SrsConfig::get_rtc_enabled(SrsConfDirective* conf)
int SrsConfig::get_rtc_listen()
{
- static int DEFAULT = 9527;
+ static int DEFAULT = 8000;
SrsConfDirective* conf = root->get("rtc");
if (!conf) {
@@ -4318,6 +4318,11 @@ std::string SrsConfig::get_rtc_candidates()
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
+
+ string eip = srs_getenv(conf->arg0());
+ if (!eip.empty()) {
+ return eip;
+ }
return (conf->arg0().c_str());
}
diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp
index fd418bf86..5cf5fe038 100644
--- a/trunk/src/app/srs_app_http_api.cpp
+++ b/trunk/src/app/srs_app_http_api.cpp
@@ -851,7 +851,7 @@ srs_error_t SrsGoApiSdp::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage*
obj->set("server", SrsJsonAny::integer(stat->server_id()));
// XXX: ice candidate
- //string candidate_str = "candidate:1 1 udp 2115783679 192.168.170.129:9527 typ host generation 0 ufrag "
+ //string candidate_str = "candidate:1 1 udp 2115783679 192.168.170.129:8000 typ host generation 0 ufrag "
// + local_sdp.get_ice_ufrag() + "netwrok-cost 50";
//SrsJsonObject* candidate_obj = SrsJsonAny::object();
diff --git a/trunk/src/app/srs_app_utility.cpp b/trunk/src/app/srs_app_utility.cpp
index 66ae11269..f6da9502f 100644
--- a/trunk/src/app/srs_app_utility.cpp
+++ b/trunk/src/app/srs_app_utility.cpp
@@ -1227,3 +1227,23 @@ string dump_string_hex(const char* buf, const int nb_buf, const int& max_len)
return ret;
}
+
+string srs_getenv(string key)
+{
+ string ekey = key;
+ if (srs_string_starts_with(key, "$")) {
+ ekey = key.substr(1);
+ }
+
+ if (ekey.empty()) {
+ return "";
+ }
+
+ char* value = ::getenv(ekey.c_str());
+ if (value) {
+ return value;
+ }
+
+ return "";
+}
+
diff --git a/trunk/src/app/srs_app_utility.hpp b/trunk/src/app/srs_app_utility.hpp
index 77d28f802..0ae50687d 100644
--- a/trunk/src/app/srs_app_utility.hpp
+++ b/trunk/src/app/srs_app_utility.hpp
@@ -653,5 +653,9 @@ extern void srs_api_dump_summaries(SrsJsonObject* obj);
extern std::string dump_string_hex(const std::string& str, const int& max_len = INT_MAX);
extern std::string dump_string_hex(const char* buf, const int nb_buf, const int& max_len = INT_MAX);
+// Get ENV variable, which may starts with $.
+// srs_getenv("EIP") === srs_getenv("$EIP")
+extern std::string srs_getenv(std::string key);
+
#endif
diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp
index 61f4f1d0d..0778c72f1 100644
--- a/trunk/src/main/srs_main_server.cpp
+++ b/trunk/src/main/srs_main_server.cpp
@@ -59,7 +59,6 @@ using namespace std;
srs_error_t run_directly_or_daemon();
srs_error_t run_hybrid_server();
void show_macro_features();
-string srs_getenv(const char* name);
// @global log and context.
ISrsLog* _srs_log = new SrsFastLog();
@@ -344,17 +343,6 @@ void show_macro_features()
#endif
}
-string srs_getenv(const char* name)
-{
- char* cv = ::getenv(name);
-
- if (cv) {
- return cv;
- }
-
- return "";
-}
-
// Detect docker by https://stackoverflow.com/a/41559867
bool _srs_in_docker = false;
srs_error_t srs_detect_docker()