mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge GB28181
This commit is contained in:
commit
e19b927f92
18 changed files with 4428 additions and 52 deletions
|
@ -275,6 +275,11 @@ bool srs_stream_caster_is_flv(string caster)
|
|||
return caster == "flv";
|
||||
}
|
||||
|
||||
bool srs_stream_caster_is_gb28181(string caster)
|
||||
{
|
||||
return caster == "gb28181";
|
||||
}
|
||||
|
||||
bool srs_config_apply_filter(SrsConfDirective* dvr_apply, SrsRequest* req)
|
||||
{
|
||||
static bool DEFAULT = true;
|
||||
|
@ -2137,7 +2142,30 @@ srs_error_t SrsConfig::global_to_json(SrsJsonObject* obj)
|
|||
sobj->set(sdir->name, sdir->dumps_arg0_to_integer());
|
||||
} else if (sdir->name == "rtp_port_max") {
|
||||
sobj->set(sdir->name, sdir->dumps_arg0_to_integer());
|
||||
} else if (sdir->name == "rtp_idle_timeout") {
|
||||
sobj->set(sdir->name, sdir->dumps_arg0_to_integer());
|
||||
} else if (sdir->name == "ack_timeout") {
|
||||
sobj->set(sdir->name, sdir->dumps_arg0_to_integer());
|
||||
} else if (sdir->name == "keepalive_timeout") {
|
||||
sobj->set(sdir->name, sdir->dumps_arg0_to_integer());
|
||||
} else if (sdir->name == "audio_enable") {
|
||||
sobj->set(sdir->name, sdir->dumps_arg0_to_boolean());
|
||||
} else if (sdir->name == "host") {
|
||||
sobj->set(sdir->name, sdir->dumps_arg0_to_str());
|
||||
} else if (sdir->name == "serial") {
|
||||
sobj->set(sdir->name, sdir->dumps_arg0_to_str());
|
||||
} else if (sdir->name == "realm") {
|
||||
sobj->set(sdir->name, sdir->dumps_arg0_to_str());
|
||||
} else if (sdir->name == "wait_keyframe") {
|
||||
sobj->set(sdir->name, sdir->dumps_arg0_to_str());
|
||||
} else if (sdir->name == "print_sip_message") {
|
||||
sobj->set(sdir->name, sdir->dumps_arg0_to_str());
|
||||
} else if (sdir->name == "invite_port_fixed") {
|
||||
sobj->set(sdir->name, sdir->dumps_arg0_to_str());
|
||||
} else if (sdir->name == "auto_play") {
|
||||
sobj->set(sdir->name, sdir->dumps_arg0_to_str());
|
||||
}
|
||||
|
||||
}
|
||||
obj->set(dir->name, sobj);
|
||||
} else {
|
||||
|
@ -3650,9 +3678,25 @@ srs_error_t SrsConfig::check_normal_config()
|
|||
SrsConfDirective* conf = stream_caster->at(i);
|
||||
string n = conf->name;
|
||||
if (n != "enabled" && n != "caster" && n != "output"
|
||||
&& n != "listen" && n != "rtp_port_min" && n != "rtp_port_max") {
|
||||
&& n != "listen" && n != "rtp_port_min" && n != "rtp_port_max"
|
||||
&& n != "rtp_idle_timeout" && n != "sip"
|
||||
&& n != "audio_enable" && n != "wait_keyframe"
|
||||
&& n != "host") {
|
||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal stream_caster.%s", n.c_str());
|
||||
}
|
||||
|
||||
if (n == "sip") {
|
||||
for (int j = 0; j < (int)conf->directives.size(); j++) {
|
||||
string m = conf->at(j)->name;
|
||||
if (m != "enabled" && m != "listen"
|
||||
&& m != "ack_timeout" && m != "keepalive_timeout"
|
||||
&& m != "host" && m != "serial" && m != "realm"
|
||||
&& m != "print_sip_message" && m != "auto_play"
|
||||
&& m != "invite_port_fixed") {
|
||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal stream_caster.%s", m.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4273,6 +4317,262 @@ int SrsConfig::get_stream_caster_rtp_port_max(SrsConfDirective* conf)
|
|||
return ::atoi(conf->arg0().c_str());
|
||||
}
|
||||
|
||||
srs_utime_t SrsConfig::get_stream_caster_gb28181_rtp_idle_timeout(SrsConfDirective* conf)
|
||||
{
|
||||
static srs_utime_t DEFAULT = 30 * SRS_UTIME_SECONDS;
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("rtp_idle_timeout");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return (srs_utime_t)(::atoi(conf->arg0().c_str()) * SRS_UTIME_SECONDS);
|
||||
}
|
||||
|
||||
int SrsConfig::get_stream_caster_gb28181_ack_timeout(SrsConfDirective* conf)
|
||||
{
|
||||
static int DEFAULT = 30;
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("sip");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("ack_timeout");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return ::atoi(conf->arg0().c_str());
|
||||
}
|
||||
|
||||
int SrsConfig::get_stream_caster_gb28181_keepalive_timeout(SrsConfDirective* conf)
|
||||
{
|
||||
static int DEFAULT = 120;
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("sip");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("keepalive_timeout");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return ::atoi(conf->arg0().c_str());
|
||||
}
|
||||
|
||||
string SrsConfig::get_stream_caster_gb28181_host(SrsConfDirective* conf)
|
||||
{
|
||||
static string DEFAULT = "";
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("host");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return conf->arg0();
|
||||
}
|
||||
|
||||
string SrsConfig::get_stream_caster_gb28181_serial(SrsConfDirective* conf)
|
||||
{
|
||||
static string DEFAULT = "34020000002000000001";
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("sip");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("serial");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return conf->arg0();
|
||||
}
|
||||
|
||||
string SrsConfig::get_stream_caster_gb28181_realm(SrsConfDirective* conf)
|
||||
{
|
||||
static string DEFAULT = "3402000000";
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("sip");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("realm");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return conf->arg0();
|
||||
}
|
||||
|
||||
bool SrsConfig::get_stream_caster_gb28181_audio_enable(SrsConfDirective* conf)
|
||||
{
|
||||
static bool DEFAULT = false;
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("audio_enable");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
bool SrsConfig::get_stream_caster_gb28181_print_sip_message(SrsConfDirective* conf)
|
||||
{
|
||||
static bool DEFAULT = false;
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("sip");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("print_sip_message");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
bool SrsConfig::get_stream_caster_gb28181_wait_keyframe(SrsConfDirective* conf)
|
||||
{
|
||||
static bool DEFAULT = false;
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("wait_keyframe");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
bool SrsConfig::get_stream_caster_gb28181_sip_enable(SrsConfDirective* conf)
|
||||
{
|
||||
static bool DEFAULT = true;
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("sip");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("enabled");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
bool SrsConfig::get_stream_caster_gb28181_sip_auto_play(SrsConfDirective* conf)
|
||||
{
|
||||
static bool DEFAULT = true;
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("sip");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("auto_play");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
|
||||
}
|
||||
|
||||
int SrsConfig::get_stream_caster_gb28181_sip_listen(SrsConfDirective* conf)
|
||||
{
|
||||
static int DEFAULT = 5060;
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("sip");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("listen");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return ::atoi(conf->arg0().c_str());
|
||||
|
||||
}
|
||||
|
||||
bool SrsConfig::get_stream_caster_gb28181_sip_invite_port_fixed(SrsConfDirective* conf)
|
||||
{
|
||||
static bool DEFAULT = true;
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("sip");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
conf = conf->get("invite_port_fixed");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
|
||||
}
|
||||
|
||||
int SrsConfig::get_rtc_server_enabled()
|
||||
{
|
||||
SrsConfDirective* conf = root->get("rtc_server");
|
||||
|
@ -4282,45 +4582,45 @@ int SrsConfig::get_rtc_server_enabled()
|
|||
bool SrsConfig::get_rtc_server_enabled(SrsConfDirective* conf)
|
||||
{
|
||||
static bool DEFAULT = false;
|
||||
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
conf = conf->get("enabled");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
int SrsConfig::get_rtc_server_listen()
|
||||
{
|
||||
static int DEFAULT = 8000;
|
||||
|
||||
|
||||
SrsConfDirective* conf = root->get("rtc_server");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
conf = conf->get("listen");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
return ::atoi(conf->arg0().c_str());
|
||||
}
|
||||
|
||||
std::string SrsConfig::get_rtc_server_candidates()
|
||||
{
|
||||
static string DEFAULT = "*";
|
||||
|
||||
|
||||
SrsConfDirective* conf = root->get("rtc_server");
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
conf = conf->get("candidate");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
|
@ -4335,7 +4635,7 @@ std::string SrsConfig::get_rtc_server_candidates()
|
|||
if (srs_string_starts_with(conf->arg0(), "$")) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
return (conf->arg0().c_str());
|
||||
}
|
||||
|
||||
|
@ -4348,36 +4648,36 @@ SrsConfDirective* SrsConfig::get_rtc(string vhost)
|
|||
bool SrsConfig::get_rtc_enabled(string vhost)
|
||||
{
|
||||
static bool DEFAULT = false;
|
||||
|
||||
|
||||
SrsConfDirective* conf = get_rtc(vhost);
|
||||
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
conf = conf->get("enabled");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||
}
|
||||
|
||||
bool SrsConfig::get_rtc_bframe_discard(string vhost)
|
||||
{
|
||||
static bool DEFAULT = false;
|
||||
|
||||
|
||||
SrsConfDirective* conf = get_rtc(vhost);
|
||||
|
||||
|
||||
if (!conf) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
conf = conf->get("bframe");
|
||||
if (!conf || conf->arg0().empty()) {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
return conf->arg0() == "discard";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue