From cf48a5594d6883850fff3830816e8addf38f6106 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 9 Apr 2020 08:37:28 +0800 Subject: [PATCH] Refactor code for #1691 --- trunk/src/app/srs_app_config.cpp | 44 +-------------------- trunk/src/app/srs_app_config.hpp | 1 - trunk/src/app/srs_app_gb28181.cpp | 3 +- trunk/src/app/srs_app_gb28181.hpp | 1 - trunk/src/service/srs_service_http_conn.cpp | 4 +- 5 files changed, 4 insertions(+), 49 deletions(-) diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 5829d47d4..f63c3a07c 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -2144,31 +2144,15 @@ srs_error_t SrsConfig::global_to_json(SrsJsonObject* obj) 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()); } else if (sdir->name == "auto_create_channel") { sobj->set(sdir->name, sdir->dumps_arg0_to_str()); } - - } obj->set(dir->name, sobj); } else { @@ -3701,11 +3685,8 @@ srs_error_t SrsConfig::check_normal_config() 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") { + if (m != "enabled" && m != "listen" && m != "ack_timeout" && m != "keepalive_timeout" + && m != "host" && m != "serial" && m != "realm" && m != "auto_play" && m != "invite_port_fixed") { return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal stream_caster.%s", m.c_str()); } } @@ -4485,27 +4466,6 @@ bool SrsConfig::get_stream_caster_gb28181_audio_enable(SrsConfDirective* conf) 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; diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index b717a233d..f7f449b08 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -509,7 +509,6 @@ public: virtual std::string get_stream_caster_gb28181_host(SrsConfDirective* conf); virtual std::string get_stream_caster_gb28181_serial(SrsConfDirective* conf); virtual std::string get_stream_caster_gb28181_realm(SrsConfDirective* conf); - //virtual bool get_stream_caster_gb28181_print_sip_message(SrsConfDirective* conf); virtual bool get_stream_caster_gb28181_wait_keyframe(SrsConfDirective* conf); virtual bool get_stream_caster_gb28181_sip_enable(SrsConfDirective* conf); virtual bool get_stream_caster_gb28181_sip_auto_play(SrsConfDirective* conf); diff --git a/trunk/src/app/srs_app_gb28181.cpp b/trunk/src/app/srs_app_gb28181.cpp index c964c9ac9..fe3fa90da 100644 --- a/trunk/src/app/srs_app_gb28181.cpp +++ b/trunk/src/app/srs_app_gb28181.cpp @@ -645,8 +645,7 @@ SrsGb28181Config::SrsGb28181Config(SrsConfDirective* c) sip_auto_play = _srs_config->get_stream_caster_gb28181_sip_auto_play(c); sip_ack_timeout = _srs_config->get_stream_caster_gb28181_ack_timeout(c); sip_keepalive_timeout = _srs_config->get_stream_caster_gb28181_keepalive_timeout(c); - //print_sip_message = _srs_config->get_stream_caster_gb28181_print_sip_message(c); - sip_invite_port_fixed = _srs_config->get_stream_caster_gb28181_sip_invite_port_fixed(c); + sip_invite_port_fixed = _srs_config->get_stream_caster_gb28181_sip_invite_port_fixed(c); } SrsGb28181Config::~SrsGb28181Config() diff --git a/trunk/src/app/srs_app_gb28181.hpp b/trunk/src/app/srs_app_gb28181.hpp index 4600ba010..a7cde0b85 100644 --- a/trunk/src/app/srs_app_gb28181.hpp +++ b/trunk/src/app/srs_app_gb28181.hpp @@ -311,7 +311,6 @@ public: bool sip_enable; srs_utime_t sip_ack_timeout; srs_utime_t sip_keepalive_timeout; - bool print_sip_message; bool sip_auto_play; bool sip_invite_port_fixed; diff --git a/trunk/src/service/srs_service_http_conn.cpp b/trunk/src/service/srs_service_http_conn.cpp index 40f40f18f..d28e7b724 100644 --- a/trunk/src/service/srs_service_http_conn.cpp +++ b/trunk/src/service/srs_service_http_conn.cpp @@ -120,7 +120,6 @@ srs_error_t SrsHttpParser::parse_message_imp(ISrsReader* reader) if (buffer->size() > 0) { ssize_t consumed = http_parser_execute(&parser, &settings, buffer->bytes(), buffer->size()); - // The error is set in http_errno. enum http_errno code; if ((code = HTTP_PARSER_ERRNO(&parser)) != HPE_OK) { @@ -141,8 +140,7 @@ srs_error_t SrsHttpParser::parse_message_imp(ISrsReader* reader) } } - //TODO: fixme 'nparsed' undefined, open info compile error! - srs_info("size=%d, nparsed=%d, consumed=%d", buffer->size(), (int)nparsed, consumed); + srs_info("size=%d, nparsed=%d", buffer->size(), (int)consumed); // Only consume the header bytes. buffer->read_slice(consumed);