1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

add srt parameter configure (#1599)

* if there isn't srt connect, it needn't epoll wait

* solve repush srt bugs

* change two thread to one thread

* mpegts discard header is not 0x47

* add srt_epoll_clear_usocks

* add srt parameter configure
This commit is contained in:
Alex.CR 2020-02-12 07:03:27 -06:00 committed by GitHub
parent c2012379af
commit 5f7d23f123
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 227 additions and 6 deletions

View file

@ -3525,7 +3525,10 @@ srs_error_t SrsConfig::check_normal_config()
SrsConfDirective* conf = root->get("srt_server");
for (int i = 0; conf && i < (int)conf->directives.size(); i++) {
string n = conf->at(i)->name;
if (n != "enabled" && n != "listen") {
if (n != "enabled" && n != "listen" && n != "maxbw"
&& n != "mss" && n != "latency" && n != "recvlatency"
&& n != "peerlatency" && n != "tlpkdrop" && n != "connect_timeout"
&& n != "sendbuf" && n != "recvbuf" && n != "payloadsize") {
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal srt_stream.%s", n.c_str());
}
}
@ -6701,6 +6704,146 @@ unsigned short SrsConfig::get_srt_listen_port()
return (unsigned short)atoi(conf->arg0().c_str());
}
int SrsConfig::get_srto_maxbw() {
static int64_t DEFAULT = -1;
SrsConfDirective* conf = root->get("srt_server");
if (!conf) {
return DEFAULT;
}
conf = conf->get("maxbw");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return atoi(conf->arg0().c_str());
}
int SrsConfig::get_srto_mss() {
static int DEFAULT = 1500;
SrsConfDirective* conf = root->get("srt_server");
if (!conf) {
return DEFAULT;
}
conf = conf->get("mms");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return atoi(conf->arg0().c_str());
}
int SrsConfig::get_srto_latency() {
static int DEFAULT = 120;
SrsConfDirective* conf = root->get("srt_server");
if (!conf) {
return DEFAULT;
}
conf = conf->get("latency");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return atoi(conf->arg0().c_str());
}
int SrsConfig::get_srto_recv_latency() {
static int DEFAULT = 120;
SrsConfDirective* conf = root->get("srt_server");
if (!conf) {
return DEFAULT;
}
conf = conf->get("recvlatency");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return atoi(conf->arg0().c_str());
}
int SrsConfig::get_srto_peer_latency() {
static int DEFAULT = 120;
SrsConfDirective* conf = root->get("srt_server");
if (!conf) {
return DEFAULT;
}
conf = conf->get("peerlatency");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return atoi(conf->arg0().c_str());
}
bool SrsConfig::get_srto_tlpkdrop() {
static bool DEFAULT = true;
SrsConfDirective* conf = root->get("srt_server");
if (!conf) {
return DEFAULT;
}
conf = conf->get("tlpkdrop");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return SRS_CONF_PERFER_TRUE(conf->arg0());
}
int SrsConfig::get_srto_conntimeout() {
static int DEFAULT = 3000;
SrsConfDirective* conf = root->get("srt_server");
if (!conf) {
return DEFAULT;
}
conf = conf->get("connect_timeout");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return atoi(conf->arg0().c_str());
}
int SrsConfig::get_srto_sendbuf() {
static int64_t DEFAULT = 8192 * (1500-28);
SrsConfDirective* conf = root->get("srt_server");
if (!conf) {
return DEFAULT;
}
conf = conf->get("sendbuf");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return atoi(conf->arg0().c_str());
}
int SrsConfig::get_srto_recvbuf() {
static int64_t DEFAULT = 8192 * (1500-28);
SrsConfDirective* conf = root->get("srt_server");
if (!conf) {
return DEFAULT;
}
conf = conf->get("recvbuf");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return atoi(conf->arg0().c_str());
}
int SrsConfig::get_srto_payloadsize() {
static int DEFAULT = 1316;
SrsConfDirective* conf = root->get("srt_server");
if (!conf) {
return DEFAULT;
}
conf = conf->get("payloadsize");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return atoi(conf->arg0().c_str());
}
bool SrsConfig::get_http_stream_enabled()
{
SrsConfDirective* conf = root->get("http_server");