Skip to content

Commit

Permalink
WebRTC: Support reuse HTTPS port for WebRTC over TCP.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Sep 4, 2022
1 parent 80bd486 commit 42e2135
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 16 deletions.
20 changes: 20 additions & 0 deletions trunk/conf/full.conf
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ auto_reload_for_docker on;
# the rtmp listen ports, split by space, each listen entry is <[ip:]port>
# for example, 192.168.1.100:1935 10.10.10.100:1935
# where the ip is optional, default to 0.0.0.0, that is 1935 equals to 0.0.0.0:1935
# Overwrite by env SRS_LISTEN
listen 1935;
# the default chunk size is 128, max is 65536,
# some client does not support chunk size change,
Expand All @@ -135,12 +136,14 @@ chunk_size 60000;
# where the cli can only be used in shell/terminate.
http_api {
# whether http api is enabled.
# Overwrite by env SRS_HTTP_API_ENABLED
# default: off
enabled on;
# The http api listen entry is <[ip:]port>, For example, 192.168.1.100:8080, where the ip is optional, default to
# 0.0.0.0, that is 8080 equals to 0.0.0.0:8080.
# Note that you're able to use a dedicated port for HTTP API, such as 1985, to be different with HTTP server. In
# this situation, you you must also set another HTTPS API port.
# Overwrite by env SRS_HTTP_API_LISTEN
# Default: 1985
listen 8080;
# whether enable crossdomain request.
Expand All @@ -164,11 +167,13 @@ http_api {
# For https_api or HTTPS API.
https {
# Whether enable HTTPS API.
# Overwrite by env SRS_HTTP_API_HTTPS_ENABLED
# default: off
enabled on;
# The listen endpoint for HTTPS API.
# Note that you're able to use a dedicated port for HTTPS API, such as 1990, and the HTTP API should not be
# the same of HTTP server(8080) neither.
# Overwrite by env SRS_HTTP_API_HTTPS_LISTEN
# Default: 1990
listen 8088;
# The SSL private key file, generated by:
Expand All @@ -193,12 +198,14 @@ http_api {
# need to open the feature http of vhost.
http_server {
# whether http streaming service is enabled.
# Overwrite by env SRS_HTTP_SERVER_ENABLED
# default: off
enabled on;
# the http streaming listen entry is <[ip:]port>
# for example, 192.168.1.100:8080
# where the ip is optional, default to 0.0.0.0, that is 8080 equals to 0.0.0.0:8080
# @remark, if use lower port, for instance 80, user must start srs by root.
# Overwrite by env SRS_HTTP_SERVER_LISTEN
# default: 8080
listen 8080;
# the default dir for http root.
Expand All @@ -211,9 +218,11 @@ http_server {
# For https_server or HTTPS Streaming.
https {
# Whether enable HTTPS Streaming.
# Overwrite by env SRS_HTTP_SERVER_HTTTPS_ENABLED
# default: off
enabled on;
# The listen endpoint for HTTPS Streaming.
# Overwrite by env SRS_HTTP_SERVER_HTTTPS_LISTEN
# default: 8088
listen 8088;
# The SSL private key file, generated by:
Expand Down Expand Up @@ -297,9 +306,11 @@ vhost srt.vhost.srs.com {
#############################################################################################
rtc_server {
# Whether enable WebRTC server.
# Overwrite by env SRS_RTC_SERVER_ENABLED
# default: off
enabled on;
# The udp listen port, we will reuse it for connections.
# Overwrite by env SRS_RTC_SERVER_LISTEN
# default: 8000
listen 8000;
# For WebRTC over TCP directly, not TURN, see https://github.com/ossrs/srs/issues/2852
Expand Down Expand Up @@ -329,32 +340,38 @@ rtc_server {
# x.x.x.x A specified IP address or DNS name, use * if 0.0.0.0.
# @remark For Firefox, the candidate MUST be IP, MUST NOT be DNS name, see https://bugzilla.mozilla.org/show_bug.cgi?id=1239006
# @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate
# Overwrite by env SRS_RTC_SERVER_CANDIDATE
# default: *
candidate *;
# If candidate is * or 0.0.0.0, means SRS could detect IP automatically, filtered by ip_family.
# You can config this to off to disable the detecting, then SRS will try to parse the API hostname.
# Note that browser might fail if no CANDIDATE specified.
# Overwrite by env SRS_RTC_SERVER_USE_AUTO_DETECT_NETWORK_IP
# Default: on
use_auto_detect_network_ip on;
# The IP family filter for auto discover candidate, it can be:
# ipv4 Filter IP v4 candidates.
# ipv6 Filter IP v6 candidates.
# all Filter all IP v4 or v6 candidates.
# For example, if set to ipv4, we only use the IPv4 address as candidate.
# Overwrite by env SRS_RTC_SERVER_IP_FAMILY
# default: ipv4
ip_family ipv4;
# If api_as_candidates is on, SRS would try to use the IP of api server, specified by srs.sdk.js request:
# api:string "http://r.ossrs.net:1985/rtc/v1/play/"
# in this case, the r.ossrs.net and 39.107.238.185 will be added as candidates.
# Overwrite by env SRS_RTC_SERVER_API_AS_CANDIDATES
# Default: on
api_as_candidates on;
# If use api as CANDIDATE, whether resolve the api hostname.
# Note that use original domain name as CANDIDATE, which might make Firefox failed, see https://bugzilla.mozilla.org/show_bug.cgi?id=1239006
# Note that if hostname is IPv4 address, always directly use it.
# Overwrite by env SRS_RTC_SERVER_RESOLVE_API_DOMAIN
# Default: on
resolve_api_domain on;
# If use api as CANDIDATE, whether keep original api domain name as CANDIDATE.
# Note that use original domain name as CANDIDATE, which might make Firefox failed, see https://bugzilla.mozilla.org/show_bug.cgi?id=1239006
# Overwrite by env SRS_RTC_SERVER_KEEP_API_DOMAIN
# Default: off
keep_api_domain off;
# Whether use ECDSA certificate.
Expand Down Expand Up @@ -390,6 +407,7 @@ rtc_server {
vhost rtc.vhost.srs.com {
rtc {
# Whether enable WebRTC server.
# Overwrite by env SRS_VHOST_RTC_ENABLED for all vhosts.
# default: off
enabled on;
# Whether support NACK.
Expand Down Expand Up @@ -420,6 +438,7 @@ vhost rtc.vhost.srs.com {
###############################################################
# Whether enable transmuxing RTMP to RTC.
# If enabled, transcode aac to opus.
# Overwrite by env SRS_VHOST_RTC_RTMP_TO_RTC for all vhosts.
# default: off
rtmp_to_rtc off;
# Whether keep B-frame, which is normal feature in live streaming,
Expand All @@ -428,6 +447,7 @@ vhost rtc.vhost.srs.com {
keep_bframe off;
###############################################################
# Whether enable transmuxing RTC to RTMP.
# Overwrite by env SRS_VHOST_RTC_RTC_TO_RTMP for all vhosts.
# Default: off
rtc_to_rtmp off;
# The PLI interval in seconds, for RTC to RTMP.
Expand Down
1 change: 1 addition & 0 deletions trunk/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The changelog for SRS.

## SRS 5.0 Changelog

* v5.0, 2022-09-04, Fix [#2852](https://github.com/ossrs/srs/issues/2852): WebRTC: WebRTC over TCP directly, not TURN. v5.0.60
* v5.0, 2022-09-01, Fix [#1405](https://github.com/ossrs/srs/issues/1405): Restore the stream when parsing failed. v5.0.59
* v5.0, 2022-09-01, Fix [#1405](https://github.com/ossrs/srs/issues/1405): Support guessing IBMF first. v5.0.58
* v5.0, 2022-09-01, ST: Define and use a new jmpbuf. v5.0.57
Expand Down
44 changes: 44 additions & 0 deletions trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2868,6 +2868,12 @@ int SrsConfig::get_max_connections()
vector<string> SrsConfig::get_listens()
{
std::vector<string> ports;

// SRS_OVERWRITE_BY_ENV_STRING("SRS_LISTEN")
if (getenv("SRS_LISTEN")) {
ports.push_back(getenv("SRS_LISTEN"));
return ports;
}

SrsConfDirective* conf = root->get("listen");
if (!conf) {
Expand Down Expand Up @@ -3575,6 +3581,8 @@ bool SrsConfig::get_rtc_server_enabled()

bool SrsConfig::get_rtc_server_enabled(SrsConfDirective* conf)
{
SRS_OVERWRITE_BY_ENV_BOOL("SRS_RTC_SERVER_ENABLED");

static bool DEFAULT = false;

if (!conf) {
Expand All @@ -3591,6 +3599,8 @@ bool SrsConfig::get_rtc_server_enabled(SrsConfDirective* conf)

int SrsConfig::get_rtc_server_listen()
{
SRS_OVERWRITE_BY_ENV_INT("SRS_RTC_SERVER_LISTEN");

static int DEFAULT = 8000;

SrsConfDirective* conf = root->get("rtc_server");
Expand All @@ -3608,6 +3618,8 @@ int SrsConfig::get_rtc_server_listen()

std::string SrsConfig::get_rtc_server_candidates()
{
SRS_OVERWRITE_BY_ENV_STRING("SRS_RTC_SERVER_CANDIDATE");

static string DEFAULT = "*";

SrsConfDirective* conf = root->get("rtc_server");
Expand Down Expand Up @@ -3635,6 +3647,8 @@ std::string SrsConfig::get_rtc_server_candidates()

bool SrsConfig::get_api_as_candidates()
{
SRS_OVERWRITE_BY_ENV_BOOL2("SRS_RTC_SERVER_API_AS_CANDIDATES");

static bool DEFAULT = true;

SrsConfDirective* conf = root->get("rtc_server");
Expand All @@ -3652,6 +3666,8 @@ bool SrsConfig::get_api_as_candidates()

bool SrsConfig::get_resolve_api_domain()
{
SRS_OVERWRITE_BY_ENV_BOOL2("SRS_RTC_SERVER_RESOLVE_API_DOMAIN");

static bool DEFAULT = true;

SrsConfDirective* conf = root->get("rtc_server");
Expand All @@ -3669,6 +3685,8 @@ bool SrsConfig::get_resolve_api_domain()

bool SrsConfig::get_keep_api_domain()
{
SRS_OVERWRITE_BY_ENV_BOOL("SRS_RTC_SERVER_KEEP_API_DOMAIN");

static bool DEFAULT = false;

SrsConfDirective* conf = root->get("rtc_server");
Expand All @@ -3686,6 +3704,8 @@ bool SrsConfig::get_keep_api_domain()

bool SrsConfig::get_use_auto_detect_network_ip()
{
SRS_OVERWRITE_BY_ENV_BOOL2("SRS_RTC_SERVER_USE_AUTO_DETECT_NETWORK_IP");

static bool DEFAULT = true;

SrsConfDirective* conf = root->get("rtc_server");
Expand Down Expand Up @@ -3770,6 +3790,8 @@ std::string SrsConfig::get_rtc_server_protocol()

std::string SrsConfig::get_rtc_server_ip_family()
{
SRS_OVERWRITE_BY_ENV_STRING("SRS_RTC_SERVER_IP_FAMILY");

static string DEFAULT = "ipv4";

SrsConfDirective* conf = root->get("rtc_server");
Expand Down Expand Up @@ -3919,6 +3941,8 @@ SrsConfDirective* SrsConfig::get_rtc(string vhost)

bool SrsConfig::get_rtc_enabled(string vhost)
{
SRS_OVERWRITE_BY_ENV_BOOL("SRS_VHOST_RTC_ENABLED");

static bool DEFAULT = false;

SrsConfDirective* conf = get_rtc(vhost);
Expand Down Expand Up @@ -3955,6 +3979,8 @@ bool SrsConfig::get_rtc_keep_bframe(string vhost)

bool SrsConfig::get_rtc_from_rtmp(string vhost)
{
SRS_OVERWRITE_BY_ENV_BOOL("SRS_VHOST_RTC_RTMP_TO_RTC");

static bool DEFAULT = false;

SrsConfDirective* conf = get_rtc(vhost);
Expand Down Expand Up @@ -4062,6 +4088,8 @@ int SrsConfig::get_rtc_drop_for_pt(string vhost)

bool SrsConfig::get_rtc_to_rtmp(string vhost)
{
SRS_OVERWRITE_BY_ENV_BOOL("SRS_VHOST_RTC_RTC_TO_RTMP");

static bool DEFAULT = false;

SrsConfDirective* conf = get_rtc(vhost);
Expand Down Expand Up @@ -6686,6 +6714,8 @@ bool SrsConfig::get_http_api_enabled()

bool SrsConfig::get_http_api_enabled(SrsConfDirective* conf)
{
SRS_OVERWRITE_BY_ENV_BOOL("SRS_HTTP_API_ENABLED");

static bool DEFAULT = false;

if (!conf) {
Expand All @@ -6702,6 +6732,8 @@ bool SrsConfig::get_http_api_enabled(SrsConfDirective* conf)

string SrsConfig::get_http_api_listen()
{
SRS_OVERWRITE_BY_ENV_STRING("SRS_HTTP_API_LISTEN");

static string DEFAULT = "1985";

SrsConfDirective* conf = root->get("http_api");
Expand Down Expand Up @@ -6803,6 +6835,8 @@ SrsConfDirective* SrsConfig::get_https_api()

bool SrsConfig::get_https_api_enabled()
{
SRS_OVERWRITE_BY_ENV_BOOL("SRS_HTTP_API_HTTPS_ENABLED");

static bool DEFAULT = false;

SrsConfDirective* conf = get_https_api();
Expand All @@ -6820,6 +6854,8 @@ bool SrsConfig::get_https_api_enabled()

string SrsConfig::get_https_api_listen()
{
SRS_OVERWRITE_BY_ENV_STRING("SRS_HTTP_API_HTTPS_LISTEN");

#ifdef SRS_UTEST
// We should not use static default, because we need to reset for different testcase.
string DEFAULT = "";
Expand Down Expand Up @@ -7178,6 +7214,8 @@ bool SrsConfig::get_http_stream_enabled()

bool SrsConfig::get_http_stream_enabled(SrsConfDirective* conf)
{
SRS_OVERWRITE_BY_ENV_BOOL("SRS_HTTP_SERVER_ENABLED");

static bool DEFAULT = false;

if (!conf) {
Expand All @@ -7194,6 +7232,8 @@ bool SrsConfig::get_http_stream_enabled(SrsConfDirective* conf)

string SrsConfig::get_http_stream_listen()
{
SRS_OVERWRITE_BY_ENV_STRING("SRS_HTTP_SERVER_LISTEN");

static string DEFAULT = "8080";

SrsConfDirective* conf = root->get("http_server");
Expand Down Expand Up @@ -7255,6 +7295,8 @@ SrsConfDirective* SrsConfig::get_https_stream()

bool SrsConfig::get_https_stream_enabled()
{
SRS_OVERWRITE_BY_ENV_BOOL("SRS_HTTP_SERVER_HTTTPS_ENABLED");

static bool DEFAULT = false;

SrsConfDirective* conf = get_https_stream();
Expand All @@ -7272,6 +7314,8 @@ bool SrsConfig::get_https_stream_enabled()

string SrsConfig::get_https_stream_listen()
{
SRS_OVERWRITE_BY_ENV_STRING("SRS_HTTP_SERVER_HTTTPS_LISTEN");

static string DEFAULT = "8088";

SrsConfDirective* conf = get_https_stream();
Expand Down
Loading

0 comments on commit 42e2135

Please # to comment.