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

use kernel utility int2str and float2str

This commit is contained in:
winlin 2015-09-24 17:54:58 +08:00
parent 6efd2dd27e
commit 9ead08725d
14 changed files with 104 additions and 75 deletions

View file

@ -174,9 +174,7 @@ int64_t SrsHttpHeader::content_length()
void SrsHttpHeader::set_content_length(int64_t size)
{
char buf[64];
snprintf(buf, sizeof(buf), "%"PRId64, size);
set("Content-Length", buf);
set("Content-Length", srs_int2str(size));
}
string SrsHttpHeader::content_type()

View file

@ -28,6 +28,7 @@ using namespace std;
#include <srs_kernel_log.hpp>
#include <srs_protocol_amf0.hpp>
#include <srs_kernel_utility.hpp>
/* json encode
cout<< SRS_JOBJECT_START
@ -328,10 +329,7 @@ string SrsJsonAny::dumps()
return to_boolean()? "true":"false";
}
case SRS_JSON_Integer: {
// len(max int64_t) is 20, plus one "+-."
char tmp[22];
snprintf(tmp, 22, "%"PRId64, to_integer());
return tmp;
return srs_int2str(to_integer());
}
case SRS_JSON_Number: {
// len(max int64_t) is 20, plus one "+-."

View file

@ -125,6 +125,11 @@ void srs_random_generate(char* bytes, int size)
}
}
string srs_generate_tc_url(string ip, string vhost, string app, int port, string param)
{
return srs_generate_tc_url(ip, vhost, app, srs_int2str(port), param);
}
string srs_generate_tc_url(string ip, string vhost, string app, string port, string param)
{
string tcUrl = "rtmp://";

View file

@ -89,6 +89,10 @@ extern std::string srs_generate_tc_url(
std::string ip, std::string vhost, std::string app, std::string port,
std::string param
);
extern std::string srs_generate_tc_url(
std::string ip, std::string vhost, std::string app, int port,
std::string param
);
/**
* compare the memory in bytes.