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

use the right int type for port.

This commit is contained in:
winlin 2015-09-24 18:33:07 +08:00
parent 1c7d5f1852
commit d8f18aee37
20 changed files with 105 additions and 149 deletions

View file

@ -44,7 +44,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_CONSTS_RTMP_DEFAULT_VHOST "__defaultVhost__"
#define SRS_CONSTS_RTMP_DEFAULT_APP "__defaultApp__"
// default port of rtmp
#define SRS_CONSTS_RTMP_DEFAULT_PORT "1935"
#define SRS_CONSTS_RTMP_DEFAULT_PORT 1935
// the default chunk size for system.
#define SRS_CONSTS_RTMP_SRS_CHUNK_SIZE 60000

View file

@ -180,13 +180,27 @@ string srs_dns_resolve(string host)
void srs_parse_hostport(const string& hostport, string& host, int& port)
{
host = hostport;
size_t pos = hostport.find(":");
if (pos != std::string::npos) {
string p = hostport.substr(pos + 1);
host = hostport.substr(0, pos);
port = ::atoi(p.c_str());
} else {
host = hostport;
}
}
void srs_parse_endpoint(string hostport, string& ip, int& port)
{
ip = "0.0.0.0";
size_t pos = string::npos;
if ((pos = hostport.find(":")) != string::npos) {
ip = hostport.substr(0, pos);
string sport = hostport.substr(pos + 1);
port = ::atoi(sport.c_str());
} else {
port = ::atoi(hostport.c_str());
}
}
@ -206,6 +220,10 @@ string srs_float2str(double value)
return tmp;
}
string srs_bool2switch(bool v) {
return v? "on" : "off";
}
bool srs_is_little_endian()
{
// convert to network(big-endian) order, if not equals,

View file

@ -52,13 +52,21 @@ extern int64_t srs_update_system_time_ms();
// dns resolve utility, return the resolved ip address.
extern std::string srs_dns_resolve(std::string host);
// split the host:port to host and port.
// @remark the hostport format in <host[:port]>, where port is optional.
extern void srs_parse_hostport(const std::string& hostport, std::string& host, int& port);
// parse the endpoint to ip and port.
// @remark hostport format in <[ip:]port>, where ip is default to "0.0.0.0".
extern void srs_parse_endpoint(std::string hostport, std::string& ip, int& port);
// parse the int64 value to string.
extern std::string srs_int2str(int64_t value);
// parse the float value to string, precise is 2.
extern std::string srs_float2str(double value);
// convert bool to switch value, true to "on", false to "off".
extern std::string srs_bool2switch(bool v);
// whether system is little endian
extern bool srs_is_little_endian();