From 2f0b150588ddd6334d36353538c701c8d7cc1413 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 16 Mar 2020 18:05:42 +0800 Subject: [PATCH] For #1638, #307, accept srs_string_dumps_hex to app utility. --- trunk/src/app/srs_app_utility.cpp | 11 +++++------ trunk/src/app/srs_app_utility.hpp | 5 +++-- trunk/src/kernel/srs_kernel_flv.hpp | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/trunk/src/app/srs_app_utility.cpp b/trunk/src/app/srs_app_utility.cpp index f6da9502fa..2cbd0aeeba 100644 --- a/trunk/src/app/srs_app_utility.cpp +++ b/trunk/src/app/srs_app_utility.cpp @@ -1193,22 +1193,21 @@ void srs_api_dump_summaries(SrsJsonObject* obj) sys->set("conn_srs", SrsJsonAny::integer(nrs->nb_conn_srs)); } -string dump_string_hex(const std::string& str, const int& max_len) +string srs_string_dumps_hex(const std::string& str, const int& limit) { - return dump_string_hex(str.c_str(), str.size(), max_len); + return srs_string_dumps_hex(str.c_str(), str.size(), limit); } -string dump_string_hex(const char* buf, const int nb_buf, const int& max_len) +string srs_string_dumps_hex(const char* buf, const int length, const int& limit) { string ret; - ret.reserve(max_len * 4); + ret.reserve(limit * 4); char tmp_buf[1024*16]; tmp_buf[0] = '\n'; int len = 1; - for (int i = 0; i < nb_buf && i < max_len; ++i) { - //int nb = snprintf(tmp_buf + len, sizeof(tmp_buf) - len - 2, "(%03d)%02X ", i, (uint8_t)buf[i]); + for (int i = 0; i < length && i < limit; ++i) { int nb = snprintf(tmp_buf + len, sizeof(tmp_buf) - len - 2, "%02X ", (uint8_t)buf[i]); if (nb <= 0) break; diff --git a/trunk/src/app/srs_app_utility.hpp b/trunk/src/app/srs_app_utility.hpp index 0ae50687de..8618c3798a 100644 --- a/trunk/src/app/srs_app_utility.hpp +++ b/trunk/src/app/srs_app_utility.hpp @@ -650,8 +650,9 @@ extern bool srs_is_boolean(std::string str); // Dump summaries for /api/v1/summaries. 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); +// Dump string(str in length) to hex, it will process min(limit, length) chars. +extern std::string srs_string_dumps_hex(const std::string& str, const int& limit = INT_MAX); +extern std::string srs_string_dumps_hex(const char* str, const int length, const int& limit = INT_MAX); // Get ENV variable, which may starts with $. // srs_getenv("EIP") === srs_getenv("$EIP") diff --git a/trunk/src/kernel/srs_kernel_flv.hpp b/trunk/src/kernel/srs_kernel_flv.hpp index 3bf3afc69b..ec4545d968 100644 --- a/trunk/src/kernel/srs_kernel_flv.hpp +++ b/trunk/src/kernel/srs_kernel_flv.hpp @@ -39,7 +39,6 @@ class ISrsWriter; class ISrsReader; class SrsFileReader; class SrsPacket; -class SrsSample; class SrsRtpSharedPacket; #define SRS_FLV_TAG_HEADER_SIZE 11