正在显示
18 个修改的文件
包含
493 行增加
和
493 行删除
| @@ -52,14 +52,14 @@ using namespace _srs_internal; | @@ -52,14 +52,14 @@ using namespace _srs_internal; | ||
| 52 | #define SRS_WIKI_URL_LOG "https://github.com/winlinvip/simple-rtmp-server/wiki/v1_CN_SrsLog" | 52 | #define SRS_WIKI_URL_LOG "https://github.com/winlinvip/simple-rtmp-server/wiki/v1_CN_SrsLog" |
| 53 | 53 | ||
| 54 | // '\n' | 54 | // '\n' |
| 55 | -#define __LF (char)0x0a | 55 | +#define SRS_LF (char)0x0a |
| 56 | 56 | ||
| 57 | // '\r' | 57 | // '\r' |
| 58 | -#define __CR (char)0x0d | 58 | +#define SRS_CR (char)0x0d |
| 59 | 59 | ||
| 60 | bool is_common_space(char ch) | 60 | bool is_common_space(char ch) |
| 61 | { | 61 | { |
| 62 | - return (ch == ' ' || ch == '\t' || ch == __CR || ch == __LF); | 62 | + return (ch == ' ' || ch == '\t' || ch == SRS_CR || ch == SRS_LF); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | SrsConfDirective::SrsConfDirective() | 65 | SrsConfDirective::SrsConfDirective() |
| @@ -242,7 +242,7 @@ int SrsConfDirective::read_token(SrsConfigBuffer* buffer, vector<string>& args, | @@ -242,7 +242,7 @@ int SrsConfDirective::read_token(SrsConfigBuffer* buffer, vector<string>& args, | ||
| 242 | 242 | ||
| 243 | char ch = *buffer->pos++; | 243 | char ch = *buffer->pos++; |
| 244 | 244 | ||
| 245 | - if (ch == __LF) { | 245 | + if (ch == SRS_LF) { |
| 246 | buffer->line++; | 246 | buffer->line++; |
| 247 | sharp_comment = false; | 247 | sharp_comment = false; |
| 248 | } | 248 | } |
| @@ -44,7 +44,7 @@ using namespace std; | @@ -44,7 +44,7 @@ using namespace std; | ||
| 44 | #include <srs_app_json.hpp> | 44 | #include <srs_app_json.hpp> |
| 45 | 45 | ||
| 46 | // update the flv duration and filesize every this interval in ms. | 46 | // update the flv duration and filesize every this interval in ms. |
| 47 | -#define __SRS_DVR_UPDATE_DURATION_INTERVAL 60000 | 47 | +#define SRS_DVR_UPDATE_DURATION_INTERVAL 60000 |
| 48 | 48 | ||
| 49 | // the sleep interval for http async callback. | 49 | // the sleep interval for http async callback. |
| 50 | #define SRS_AUTO_ASYNC_CALLBACL_SLEEP_US 300000 | 50 | #define SRS_AUTO_ASYNC_CALLBACL_SLEEP_US 300000 |
| @@ -920,7 +920,7 @@ int SrsDvrAppendPlan::update_duration(SrsSharedPtrMessage* msg) | @@ -920,7 +920,7 @@ int SrsDvrAppendPlan::update_duration(SrsSharedPtrMessage* msg) | ||
| 920 | return ret; | 920 | return ret; |
| 921 | } | 921 | } |
| 922 | 922 | ||
| 923 | - if (__SRS_DVR_UPDATE_DURATION_INTERVAL > msg->timestamp - last_update_time) { | 923 | + if (SRS_DVR_UPDATE_DURATION_INTERVAL > msg->timestamp - last_update_time) { |
| 924 | return ret; | 924 | return ret; |
| 925 | } | 925 | } |
| 926 | last_update_time = msg->timestamp; | 926 | last_update_time = msg->timestamp; |
| @@ -66,14 +66,14 @@ void SrsHttpHeartbeat::heartbeat() | @@ -66,14 +66,14 @@ void SrsHttpHeartbeat::heartbeat() | ||
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | std::stringstream ss; | 68 | std::stringstream ss; |
| 69 | - ss << __SRS_JOBJECT_START | ||
| 70 | - << __SRS_JFIELD_STR("device_id", device_id) << __SRS_JFIELD_CONT | ||
| 71 | - << __SRS_JFIELD_STR("ip", ip); | 69 | + ss << SRS_JOBJECT_START |
| 70 | + << SRS_JFIELD_STR("device_id", device_id) << SRS_JFIELD_CONT | ||
| 71 | + << SRS_JFIELD_STR("ip", ip); | ||
| 72 | if (_srs_config->get_heartbeat_summaries()) { | 72 | if (_srs_config->get_heartbeat_summaries()) { |
| 73 | - ss << __SRS_JFIELD_CONT << __SRS_JFIELD_ORG("summaries", ""); | 73 | + ss << SRS_JFIELD_CONT << SRS_JFIELD_ORG("summaries", ""); |
| 74 | srs_api_dump_summaries(ss); | 74 | srs_api_dump_summaries(ss); |
| 75 | } | 75 | } |
| 76 | - ss << __SRS_JOBJECT_END; | 76 | + ss << SRS_JOBJECT_END; |
| 77 | 77 | ||
| 78 | std::string req = ss.str(); | 78 | std::string req = ss.str(); |
| 79 | 79 |
| @@ -217,7 +217,7 @@ void SrsHttpHeader::write(stringstream& ss) | @@ -217,7 +217,7 @@ void SrsHttpHeader::write(stringstream& ss) | ||
| 217 | { | 217 | { |
| 218 | std::map<std::string, std::string>::iterator it; | 218 | std::map<std::string, std::string>::iterator it; |
| 219 | for (it = headers.begin(); it != headers.end(); ++it) { | 219 | for (it = headers.begin(); it != headers.end(); ++it) { |
| 220 | - ss << it->first << ": " << it->second << __SRS_HTTP_CRLF; | 220 | + ss << it->first << ": " << it->second << SRS_HTTP_CRLF; |
| 221 | } | 221 | } |
| 222 | } | 222 | } |
| 223 | 223 | ||
| @@ -472,7 +472,7 @@ int SrsHttpFileServer::copy(ISrsHttpResponseWriter* w, SrsFileReader* fs, SrsHtt | @@ -472,7 +472,7 @@ int SrsHttpFileServer::copy(ISrsHttpResponseWriter* w, SrsFileReader* fs, SrsHtt | ||
| 472 | 472 | ||
| 473 | while (left > 0) { | 473 | while (left > 0) { |
| 474 | ssize_t nread = -1; | 474 | ssize_t nread = -1; |
| 475 | - int max_read = srs_min(left, __SRS_HTTP_TS_SEND_BUFFER_SIZE); | 475 | + int max_read = srs_min(left, SRS_HTTP_TS_SEND_BUFFER_SIZE); |
| 476 | if ((ret = fs->read(buf, max_read, &nread)) != ERROR_SUCCESS) { | 476 | if ((ret = fs->read(buf, max_read, &nread)) != ERROR_SUCCESS) { |
| 477 | break; | 477 | break; |
| 478 | } | 478 | } |
| @@ -764,7 +764,7 @@ int SrsHttpResponseWriter::final_request() | @@ -764,7 +764,7 @@ int SrsHttpResponseWriter::final_request() | ||
| 764 | // complete the chunked encoding. | 764 | // complete the chunked encoding. |
| 765 | if (content_length == -1) { | 765 | if (content_length == -1) { |
| 766 | std::stringstream ss; | 766 | std::stringstream ss; |
| 767 | - ss << 0 << __SRS_HTTP_CRLF << __SRS_HTTP_CRLF; | 767 | + ss << 0 << SRS_HTTP_CRLF << SRS_HTTP_CRLF; |
| 768 | std::string ch = ss.str(); | 768 | std::string ch = ss.str(); |
| 769 | return skt->write((void*)ch.data(), (int)ch.length(), NULL); | 769 | return skt->write((void*)ch.data(), (int)ch.length(), NULL); |
| 770 | } | 770 | } |
| @@ -810,7 +810,7 @@ int SrsHttpResponseWriter::write(char* data, int size) | @@ -810,7 +810,7 @@ int SrsHttpResponseWriter::write(char* data, int size) | ||
| 810 | 810 | ||
| 811 | // send in chunked encoding. | 811 | // send in chunked encoding. |
| 812 | std::stringstream ss; | 812 | std::stringstream ss; |
| 813 | - ss << hex << size << __SRS_HTTP_CRLF; | 813 | + ss << hex << size << SRS_HTTP_CRLF; |
| 814 | std::string ch = ss.str(); | 814 | std::string ch = ss.str(); |
| 815 | if ((ret = skt->write((void*)ch.data(), (int)ch.length(), NULL)) != ERROR_SUCCESS) { | 815 | if ((ret = skt->write((void*)ch.data(), (int)ch.length(), NULL)) != ERROR_SUCCESS) { |
| 816 | return ret; | 816 | return ret; |
| @@ -818,7 +818,7 @@ int SrsHttpResponseWriter::write(char* data, int size) | @@ -818,7 +818,7 @@ int SrsHttpResponseWriter::write(char* data, int size) | ||
| 818 | if ((ret = skt->write((void*)data, size, NULL)) != ERROR_SUCCESS) { | 818 | if ((ret = skt->write((void*)data, size, NULL)) != ERROR_SUCCESS) { |
| 819 | return ret; | 819 | return ret; |
| 820 | } | 820 | } |
| 821 | - if ((ret = skt->write((void*)__SRS_HTTP_CRLF, 2, NULL)) != ERROR_SUCCESS) { | 821 | + if ((ret = skt->write((void*)SRS_HTTP_CRLF, 2, NULL)) != ERROR_SUCCESS) { |
| 822 | return ret; | 822 | return ret; |
| 823 | } | 823 | } |
| 824 | 824 | ||
| @@ -852,7 +852,7 @@ int SrsHttpResponseWriter::send_header(char* data, int size) | @@ -852,7 +852,7 @@ int SrsHttpResponseWriter::send_header(char* data, int size) | ||
| 852 | 852 | ||
| 853 | // status_line | 853 | // status_line |
| 854 | ss << "HTTP/1.1 " << status << " " | 854 | ss << "HTTP/1.1 " << status << " " |
| 855 | - << srs_generate_http_status_text(status) << __SRS_HTTP_CRLF; | 855 | + << srs_generate_http_status_text(status) << SRS_HTTP_CRLF; |
| 856 | 856 | ||
| 857 | // detect content type | 857 | // detect content type |
| 858 | if (srs_go_http_body_allowd(status)) { | 858 | if (srs_go_http_body_allowd(status)) { |
| @@ -878,7 +878,7 @@ int SrsHttpResponseWriter::send_header(char* data, int size) | @@ -878,7 +878,7 @@ int SrsHttpResponseWriter::send_header(char* data, int size) | ||
| 878 | hdr->write(ss); | 878 | hdr->write(ss); |
| 879 | 879 | ||
| 880 | // header_eof | 880 | // header_eof |
| 881 | - ss << __SRS_HTTP_CRLF; | 881 | + ss << SRS_HTTP_CRLF; |
| 882 | 882 | ||
| 883 | std::string buf = ss.str(); | 883 | std::string buf = ss.str(); |
| 884 | return skt->write((void*)buf.c_str(), buf.length(), NULL); | 884 | return skt->write((void*)buf.c_str(), buf.length(), NULL); |
| @@ -947,7 +947,7 @@ int SrsHttpResponseReader::read_chunked(std::string& data) | @@ -947,7 +947,7 @@ int SrsHttpResponseReader::read_chunked(std::string& data) | ||
| 947 | char* start = buffer->bytes(); | 947 | char* start = buffer->bytes(); |
| 948 | char* end = start + buffer->size(); | 948 | char* end = start + buffer->size(); |
| 949 | for (char* p = start; p < end - 1; p++) { | 949 | for (char* p = start; p < end - 1; p++) { |
| 950 | - if (p[0] == __SRS_HTTP_CR && p[1] == __SRS_HTTP_LF) { | 950 | + if (p[0] == SRS_HTTP_CR && p[1] == SRS_HTTP_LF) { |
| 951 | // invalid chunk, ignore. | 951 | // invalid chunk, ignore. |
| 952 | if (p == start) { | 952 | if (p == start) { |
| 953 | ret = ERROR_HTTP_INVALID_CHUNK_HEADER; | 953 | ret = ERROR_HTTP_INVALID_CHUNK_HEADER; |
| @@ -1044,7 +1044,7 @@ SrsHttpMessage::SrsHttpMessage(SrsStSocket* io) | @@ -1044,7 +1044,7 @@ SrsHttpMessage::SrsHttpMessage(SrsStSocket* io) | ||
| 1044 | chunked = false; | 1044 | chunked = false; |
| 1045 | _uri = new SrsHttpUri(); | 1045 | _uri = new SrsHttpUri(); |
| 1046 | _body = new SrsHttpResponseReader(this, io); | 1046 | _body = new SrsHttpResponseReader(this, io); |
| 1047 | - _http_ts_send_buffer = new char[__SRS_HTTP_TS_SEND_BUFFER_SIZE]; | 1047 | + _http_ts_send_buffer = new char[SRS_HTTP_TS_SEND_BUFFER_SIZE]; |
| 1048 | } | 1048 | } |
| 1049 | 1049 | ||
| 1050 | SrsHttpMessage::~SrsHttpMessage() | 1050 | SrsHttpMessage::~SrsHttpMessage() |
| @@ -53,9 +53,9 @@ class SrsFastBuffer; | @@ -53,9 +53,9 @@ class SrsFastBuffer; | ||
| 53 | 53 | ||
| 54 | // http specification | 54 | // http specification |
| 55 | // CR = <US-ASCII CR, carriage return (13)> | 55 | // CR = <US-ASCII CR, carriage return (13)> |
| 56 | -#define __SRS_HTTP_CR SRS_CONSTS_CR // 0x0D | 56 | +#define SRS_HTTP_CR SRS_CONSTS_CR // 0x0D |
| 57 | // LF = <US-ASCII LF, linefeed (10)> | 57 | // LF = <US-ASCII LF, linefeed (10)> |
| 58 | -#define __SRS_HTTP_LF SRS_CONSTS_LF // 0x0A | 58 | +#define SRS_HTTP_LF SRS_CONSTS_LF // 0x0A |
| 59 | // SP = <US-ASCII SP, space (32)> | 59 | // SP = <US-ASCII SP, space (32)> |
| 60 | #define __SRS_HTTP_SP ' ' // 0x20 | 60 | #define __SRS_HTTP_SP ' ' // 0x20 |
| 61 | // HT = <US-ASCII HT, horizontal-tab (9)> | 61 | // HT = <US-ASCII HT, horizontal-tab (9)> |
| @@ -64,11 +64,11 @@ class SrsFastBuffer; | @@ -64,11 +64,11 @@ class SrsFastBuffer; | ||
| 64 | // HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all | 64 | // HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all |
| 65 | // protocol elements except the entity-body (see appendix 19.3 for | 65 | // protocol elements except the entity-body (see appendix 19.3 for |
| 66 | // tolerant applications). | 66 | // tolerant applications). |
| 67 | -#define __SRS_HTTP_CRLF "\r\n" // 0x0D0A | ||
| 68 | -#define __SRS_HTTP_CRLFCRLF "\r\n\r\n" // 0x0D0A0D0A | 67 | +#define SRS_HTTP_CRLF "\r\n" // 0x0D0A |
| 68 | +#define SRS_HTTP_CRLFCRLF "\r\n\r\n" // 0x0D0A0D0A | ||
| 69 | 69 | ||
| 70 | // @see SrsHttpMessage._http_ts_send_buffer | 70 | // @see SrsHttpMessage._http_ts_send_buffer |
| 71 | -#define __SRS_HTTP_TS_SEND_BUFFER_SIZE 4096 | 71 | +#define SRS_HTTP_TS_SEND_BUFFER_SIZE 4096 |
| 72 | 72 | ||
| 73 | // helper function: response in json format. | 73 | // helper function: response in json format. |
| 74 | extern int srs_go_http_response_json(ISrsHttpResponseWriter* w, std::string data); | 74 | extern int srs_go_http_response_json(ISrsHttpResponseWriter* w, std::string data); |
| @@ -52,12 +52,12 @@ int SrsGoApiRoot::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | @@ -52,12 +52,12 @@ int SrsGoApiRoot::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 52 | { | 52 | { |
| 53 | std::stringstream ss; | 53 | std::stringstream ss; |
| 54 | 54 | ||
| 55 | - ss << __SRS_JOBJECT_START | ||
| 56 | - << __SRS_JFIELD_ERROR(ERROR_SUCCESS) << __SRS_JFIELD_CONT | ||
| 57 | - << __SRS_JFIELD_ORG("urls", __SRS_JOBJECT_START) | ||
| 58 | - << __SRS_JFIELD_STR("api", "the api root") | ||
| 59 | - << __SRS_JOBJECT_END | ||
| 60 | - << __SRS_JOBJECT_END; | 55 | + ss << SRS_JOBJECT_START |
| 56 | + << SRS_JFIELD_ERROR(ERROR_SUCCESS) << SRS_JFIELD_CONT | ||
| 57 | + << SRS_JFIELD_ORG("urls", SRS_JOBJECT_START) | ||
| 58 | + << SRS_JFIELD_STR("api", "the api root") | ||
| 59 | + << SRS_JOBJECT_END | ||
| 60 | + << SRS_JOBJECT_END; | ||
| 61 | 61 | ||
| 62 | return srs_go_http_response_json(w, ss.str()); | 62 | return srs_go_http_response_json(w, ss.str()); |
| 63 | } | 63 | } |
| @@ -74,12 +74,12 @@ int SrsGoApiApi::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | @@ -74,12 +74,12 @@ int SrsGoApiApi::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 74 | { | 74 | { |
| 75 | std::stringstream ss; | 75 | std::stringstream ss; |
| 76 | 76 | ||
| 77 | - ss << __SRS_JOBJECT_START | ||
| 78 | - << __SRS_JFIELD_ERROR(ERROR_SUCCESS) << __SRS_JFIELD_CONT | ||
| 79 | - << __SRS_JFIELD_ORG("urls", __SRS_JOBJECT_START) | ||
| 80 | - << __SRS_JFIELD_STR("v1", "the api version 1.0") | ||
| 81 | - << __SRS_JOBJECT_END | ||
| 82 | - << __SRS_JOBJECT_END; | 77 | + ss << SRS_JOBJECT_START |
| 78 | + << SRS_JFIELD_ERROR(ERROR_SUCCESS) << SRS_JFIELD_CONT | ||
| 79 | + << SRS_JFIELD_ORG("urls", SRS_JOBJECT_START) | ||
| 80 | + << SRS_JFIELD_STR("v1", "the api version 1.0") | ||
| 81 | + << SRS_JOBJECT_END | ||
| 82 | + << SRS_JOBJECT_END; | ||
| 83 | 83 | ||
| 84 | return srs_go_http_response_json(w, ss.str()); | 84 | return srs_go_http_response_json(w, ss.str()); |
| 85 | } | 85 | } |
| @@ -96,21 +96,21 @@ int SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | @@ -96,21 +96,21 @@ int SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 96 | { | 96 | { |
| 97 | std::stringstream ss; | 97 | std::stringstream ss; |
| 98 | 98 | ||
| 99 | - ss << __SRS_JOBJECT_START | ||
| 100 | - << __SRS_JFIELD_ERROR(ERROR_SUCCESS) << __SRS_JFIELD_CONT | ||
| 101 | - << __SRS_JFIELD_ORG("urls", __SRS_JOBJECT_START) | ||
| 102 | - << __SRS_JFIELD_STR("versions", "the version of SRS") << __SRS_JFIELD_CONT | ||
| 103 | - << __SRS_JFIELD_STR("summaries", "the summary(pid, argv, pwd, cpu, mem) of SRS") << __SRS_JFIELD_CONT | ||
| 104 | - << __SRS_JFIELD_STR("rusages", "the rusage of SRS") << __SRS_JFIELD_CONT | ||
| 105 | - << __SRS_JFIELD_STR("self_proc_stats", "the self process stats") << __SRS_JFIELD_CONT | ||
| 106 | - << __SRS_JFIELD_STR("system_proc_stats", "the system process stats") << __SRS_JFIELD_CONT | ||
| 107 | - << __SRS_JFIELD_STR("meminfos", "the meminfo of system") << __SRS_JFIELD_CONT | ||
| 108 | - << __SRS_JFIELD_STR("authors", "the primary authors and contributors") << __SRS_JFIELD_CONT | ||
| 109 | - << __SRS_JFIELD_STR("requests", "the request itself, for http debug") << __SRS_JFIELD_CONT | ||
| 110 | - << __SRS_JFIELD_STR("vhosts", "dumps vhost to json") << __SRS_JFIELD_CONT | ||
| 111 | - << __SRS_JFIELD_STR("streams", "dumps streams to json") | ||
| 112 | - << __SRS_JOBJECT_END | ||
| 113 | - << __SRS_JOBJECT_END; | 99 | + ss << SRS_JOBJECT_START |
| 100 | + << SRS_JFIELD_ERROR(ERROR_SUCCESS) << SRS_JFIELD_CONT | ||
| 101 | + << SRS_JFIELD_ORG("urls", SRS_JOBJECT_START) | ||
| 102 | + << SRS_JFIELD_STR("versions", "the version of SRS") << SRS_JFIELD_CONT | ||
| 103 | + << SRS_JFIELD_STR("summaries", "the summary(pid, argv, pwd, cpu, mem) of SRS") << SRS_JFIELD_CONT | ||
| 104 | + << SRS_JFIELD_STR("rusages", "the rusage of SRS") << SRS_JFIELD_CONT | ||
| 105 | + << SRS_JFIELD_STR("self_proc_stats", "the self process stats") << SRS_JFIELD_CONT | ||
| 106 | + << SRS_JFIELD_STR("system_proc_stats", "the system process stats") << SRS_JFIELD_CONT | ||
| 107 | + << SRS_JFIELD_STR("meminfos", "the meminfo of system") << SRS_JFIELD_CONT | ||
| 108 | + << SRS_JFIELD_STR("authors", "the primary authors and contributors") << SRS_JFIELD_CONT | ||
| 109 | + << SRS_JFIELD_STR("requests", "the request itself, for http debug") << SRS_JFIELD_CONT | ||
| 110 | + << SRS_JFIELD_STR("vhosts", "dumps vhost to json") << SRS_JFIELD_CONT | ||
| 111 | + << SRS_JFIELD_STR("streams", "dumps streams to json") | ||
| 112 | + << SRS_JOBJECT_END | ||
| 113 | + << SRS_JOBJECT_END; | ||
| 114 | 114 | ||
| 115 | return srs_go_http_response_json(w, ss.str()); | 115 | return srs_go_http_response_json(w, ss.str()); |
| 116 | } | 116 | } |
| @@ -127,15 +127,15 @@ int SrsGoApiVersion::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | @@ -127,15 +127,15 @@ int SrsGoApiVersion::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 127 | { | 127 | { |
| 128 | std::stringstream ss; | 128 | std::stringstream ss; |
| 129 | 129 | ||
| 130 | - ss << __SRS_JOBJECT_START | ||
| 131 | - << __SRS_JFIELD_ERROR(ERROR_SUCCESS) << __SRS_JFIELD_CONT | ||
| 132 | - << __SRS_JFIELD_ORG("data", __SRS_JOBJECT_START) | ||
| 133 | - << __SRS_JFIELD_ORG("major", VERSION_MAJOR) << __SRS_JFIELD_CONT | ||
| 134 | - << __SRS_JFIELD_ORG("minor", VERSION_MINOR) << __SRS_JFIELD_CONT | ||
| 135 | - << __SRS_JFIELD_ORG("revision", VERSION_REVISION) << __SRS_JFIELD_CONT | ||
| 136 | - << __SRS_JFIELD_STR("version", RTMP_SIG_SRS_VERSION) | ||
| 137 | - << __SRS_JOBJECT_END | ||
| 138 | - << __SRS_JOBJECT_END; | 130 | + ss << SRS_JOBJECT_START |
| 131 | + << SRS_JFIELD_ERROR(ERROR_SUCCESS) << SRS_JFIELD_CONT | ||
| 132 | + << SRS_JFIELD_ORG("data", SRS_JOBJECT_START) | ||
| 133 | + << SRS_JFIELD_ORG("major", VERSION_MAJOR) << SRS_JFIELD_CONT | ||
| 134 | + << SRS_JFIELD_ORG("minor", VERSION_MINOR) << SRS_JFIELD_CONT | ||
| 135 | + << SRS_JFIELD_ORG("revision", VERSION_REVISION) << SRS_JFIELD_CONT | ||
| 136 | + << SRS_JFIELD_STR("version", RTMP_SIG_SRS_VERSION) | ||
| 137 | + << SRS_JOBJECT_END | ||
| 138 | + << SRS_JOBJECT_END; | ||
| 139 | 139 | ||
| 140 | return srs_go_http_response_json(w, ss.str()); | 140 | return srs_go_http_response_json(w, ss.str()); |
| 141 | } | 141 | } |
| @@ -169,29 +169,29 @@ int SrsGoApiRusages::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* req) | @@ -169,29 +169,29 @@ int SrsGoApiRusages::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* req) | ||
| 169 | 169 | ||
| 170 | SrsRusage* r = srs_get_system_rusage(); | 170 | SrsRusage* r = srs_get_system_rusage(); |
| 171 | 171 | ||
| 172 | - ss << __SRS_JOBJECT_START | ||
| 173 | - << __SRS_JFIELD_ERROR(ERROR_SUCCESS) << __SRS_JFIELD_CONT | ||
| 174 | - << __SRS_JFIELD_ORG("data", __SRS_JOBJECT_START) | ||
| 175 | - << __SRS_JFIELD_ORG("ok", (r->ok? "true":"false")) << __SRS_JFIELD_CONT | ||
| 176 | - << __SRS_JFIELD_ORG("sample_time", r->sample_time) << __SRS_JFIELD_CONT | ||
| 177 | - << __SRS_JFIELD_ORG("ru_utime", r->r.ru_utime.tv_sec) << __SRS_JFIELD_CONT | ||
| 178 | - << __SRS_JFIELD_ORG("ru_stime", r->r.ru_stime.tv_sec) << __SRS_JFIELD_CONT | ||
| 179 | - << __SRS_JFIELD_ORG("ru_maxrss", r->r.ru_maxrss) << __SRS_JFIELD_CONT | ||
| 180 | - << __SRS_JFIELD_ORG("ru_ixrss", r->r.ru_ixrss) << __SRS_JFIELD_CONT | ||
| 181 | - << __SRS_JFIELD_ORG("ru_idrss", r->r.ru_idrss) << __SRS_JFIELD_CONT | ||
| 182 | - << __SRS_JFIELD_ORG("ru_isrss", r->r.ru_isrss) << __SRS_JFIELD_CONT | ||
| 183 | - << __SRS_JFIELD_ORG("ru_minflt", r->r.ru_minflt) << __SRS_JFIELD_CONT | ||
| 184 | - << __SRS_JFIELD_ORG("ru_majflt", r->r.ru_majflt) << __SRS_JFIELD_CONT | ||
| 185 | - << __SRS_JFIELD_ORG("ru_nswap", r->r.ru_nswap) << __SRS_JFIELD_CONT | ||
| 186 | - << __SRS_JFIELD_ORG("ru_inblock", r->r.ru_inblock) << __SRS_JFIELD_CONT | ||
| 187 | - << __SRS_JFIELD_ORG("ru_oublock", r->r.ru_oublock) << __SRS_JFIELD_CONT | ||
| 188 | - << __SRS_JFIELD_ORG("ru_msgsnd", r->r.ru_msgsnd) << __SRS_JFIELD_CONT | ||
| 189 | - << __SRS_JFIELD_ORG("ru_msgrcv", r->r.ru_msgrcv) << __SRS_JFIELD_CONT | ||
| 190 | - << __SRS_JFIELD_ORG("ru_nsignals", r->r.ru_nsignals) << __SRS_JFIELD_CONT | ||
| 191 | - << __SRS_JFIELD_ORG("ru_nvcsw", r->r.ru_nvcsw) << __SRS_JFIELD_CONT | ||
| 192 | - << __SRS_JFIELD_ORG("ru_nivcsw", r->r.ru_nivcsw) | ||
| 193 | - << __SRS_JOBJECT_END | ||
| 194 | - << __SRS_JOBJECT_END; | 172 | + ss << SRS_JOBJECT_START |
| 173 | + << SRS_JFIELD_ERROR(ERROR_SUCCESS) << SRS_JFIELD_CONT | ||
| 174 | + << SRS_JFIELD_ORG("data", SRS_JOBJECT_START) | ||
| 175 | + << SRS_JFIELD_ORG("ok", (r->ok? "true":"false")) << SRS_JFIELD_CONT | ||
| 176 | + << SRS_JFIELD_ORG("sample_time", r->sample_time) << SRS_JFIELD_CONT | ||
| 177 | + << SRS_JFIELD_ORG("ru_utime", r->r.ru_utime.tv_sec) << SRS_JFIELD_CONT | ||
| 178 | + << SRS_JFIELD_ORG("ru_stime", r->r.ru_stime.tv_sec) << SRS_JFIELD_CONT | ||
| 179 | + << SRS_JFIELD_ORG("ru_maxrss", r->r.ru_maxrss) << SRS_JFIELD_CONT | ||
| 180 | + << SRS_JFIELD_ORG("ru_ixrss", r->r.ru_ixrss) << SRS_JFIELD_CONT | ||
| 181 | + << SRS_JFIELD_ORG("ru_idrss", r->r.ru_idrss) << SRS_JFIELD_CONT | ||
| 182 | + << SRS_JFIELD_ORG("ru_isrss", r->r.ru_isrss) << SRS_JFIELD_CONT | ||
| 183 | + << SRS_JFIELD_ORG("ru_minflt", r->r.ru_minflt) << SRS_JFIELD_CONT | ||
| 184 | + << SRS_JFIELD_ORG("ru_majflt", r->r.ru_majflt) << SRS_JFIELD_CONT | ||
| 185 | + << SRS_JFIELD_ORG("ru_nswap", r->r.ru_nswap) << SRS_JFIELD_CONT | ||
| 186 | + << SRS_JFIELD_ORG("ru_inblock", r->r.ru_inblock) << SRS_JFIELD_CONT | ||
| 187 | + << SRS_JFIELD_ORG("ru_oublock", r->r.ru_oublock) << SRS_JFIELD_CONT | ||
| 188 | + << SRS_JFIELD_ORG("ru_msgsnd", r->r.ru_msgsnd) << SRS_JFIELD_CONT | ||
| 189 | + << SRS_JFIELD_ORG("ru_msgrcv", r->r.ru_msgrcv) << SRS_JFIELD_CONT | ||
| 190 | + << SRS_JFIELD_ORG("ru_nsignals", r->r.ru_nsignals) << SRS_JFIELD_CONT | ||
| 191 | + << SRS_JFIELD_ORG("ru_nvcsw", r->r.ru_nvcsw) << SRS_JFIELD_CONT | ||
| 192 | + << SRS_JFIELD_ORG("ru_nivcsw", r->r.ru_nivcsw) | ||
| 193 | + << SRS_JOBJECT_END | ||
| 194 | + << SRS_JOBJECT_END; | ||
| 195 | 195 | ||
| 196 | return srs_go_http_response_json(w, ss.str()); | 196 | return srs_go_http_response_json(w, ss.str()); |
| 197 | } | 197 | } |
| @@ -210,58 +210,58 @@ int SrsGoApiSelfProcStats::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* | @@ -210,58 +210,58 @@ int SrsGoApiSelfProcStats::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* | ||
| 210 | 210 | ||
| 211 | SrsProcSelfStat* u = srs_get_self_proc_stat(); | 211 | SrsProcSelfStat* u = srs_get_self_proc_stat(); |
| 212 | 212 | ||
| 213 | - ss << __SRS_JOBJECT_START | ||
| 214 | - << __SRS_JFIELD_ERROR(ERROR_SUCCESS) << __SRS_JFIELD_CONT | ||
| 215 | - << __SRS_JFIELD_ORG("data", __SRS_JOBJECT_START) | ||
| 216 | - << __SRS_JFIELD_ORG("ok", (u->ok? "true":"false")) << __SRS_JFIELD_CONT | ||
| 217 | - << __SRS_JFIELD_ORG("sample_time", u->sample_time) << __SRS_JFIELD_CONT | ||
| 218 | - << __SRS_JFIELD_ORG("percent", u->percent) << __SRS_JFIELD_CONT | ||
| 219 | - << __SRS_JFIELD_ORG("pid", u->pid) << __SRS_JFIELD_CONT | ||
| 220 | - << __SRS_JFIELD_STR("comm", u->comm) << __SRS_JFIELD_CONT | ||
| 221 | - << __SRS_JFIELD_STR("state", u->state) << __SRS_JFIELD_CONT | ||
| 222 | - << __SRS_JFIELD_ORG("ppid", u->ppid) << __SRS_JFIELD_CONT | ||
| 223 | - << __SRS_JFIELD_ORG("pgrp", u->pgrp) << __SRS_JFIELD_CONT | ||
| 224 | - << __SRS_JFIELD_ORG("session", u->session) << __SRS_JFIELD_CONT | ||
| 225 | - << __SRS_JFIELD_ORG("tty_nr", u->tty_nr) << __SRS_JFIELD_CONT | ||
| 226 | - << __SRS_JFIELD_ORG("tpgid", u->tpgid) << __SRS_JFIELD_CONT | ||
| 227 | - << __SRS_JFIELD_ORG("flags", u->flags) << __SRS_JFIELD_CONT | ||
| 228 | - << __SRS_JFIELD_ORG("minflt", u->minflt) << __SRS_JFIELD_CONT | ||
| 229 | - << __SRS_JFIELD_ORG("cminflt", u->cminflt) << __SRS_JFIELD_CONT | ||
| 230 | - << __SRS_JFIELD_ORG("majflt", u->majflt) << __SRS_JFIELD_CONT | ||
| 231 | - << __SRS_JFIELD_ORG("cmajflt", u->cmajflt) << __SRS_JFIELD_CONT | ||
| 232 | - << __SRS_JFIELD_ORG("utime", u->utime) << __SRS_JFIELD_CONT | ||
| 233 | - << __SRS_JFIELD_ORG("stime", u->stime) << __SRS_JFIELD_CONT | ||
| 234 | - << __SRS_JFIELD_ORG("cutime", u->cutime) << __SRS_JFIELD_CONT | ||
| 235 | - << __SRS_JFIELD_ORG("cstime", u->cstime) << __SRS_JFIELD_CONT | ||
| 236 | - << __SRS_JFIELD_ORG("priority", u->priority) << __SRS_JFIELD_CONT | ||
| 237 | - << __SRS_JFIELD_ORG("nice", u->nice) << __SRS_JFIELD_CONT | ||
| 238 | - << __SRS_JFIELD_ORG("num_threads", u->num_threads) << __SRS_JFIELD_CONT | ||
| 239 | - << __SRS_JFIELD_ORG("itrealvalue", u->itrealvalue) << __SRS_JFIELD_CONT | ||
| 240 | - << __SRS_JFIELD_ORG("starttime", u->starttime) << __SRS_JFIELD_CONT | ||
| 241 | - << __SRS_JFIELD_ORG("vsize", u->vsize) << __SRS_JFIELD_CONT | ||
| 242 | - << __SRS_JFIELD_ORG("rss", u->rss) << __SRS_JFIELD_CONT | ||
| 243 | - << __SRS_JFIELD_ORG("rsslim", u->rsslim) << __SRS_JFIELD_CONT | ||
| 244 | - << __SRS_JFIELD_ORG("startcode", u->startcode) << __SRS_JFIELD_CONT | ||
| 245 | - << __SRS_JFIELD_ORG("endcode", u->endcode) << __SRS_JFIELD_CONT | ||
| 246 | - << __SRS_JFIELD_ORG("startstack", u->startstack) << __SRS_JFIELD_CONT | ||
| 247 | - << __SRS_JFIELD_ORG("kstkesp", u->kstkesp) << __SRS_JFIELD_CONT | ||
| 248 | - << __SRS_JFIELD_ORG("kstkeip", u->kstkeip) << __SRS_JFIELD_CONT | ||
| 249 | - << __SRS_JFIELD_ORG("signal", u->signal) << __SRS_JFIELD_CONT | ||
| 250 | - << __SRS_JFIELD_ORG("blocked", u->blocked) << __SRS_JFIELD_CONT | ||
| 251 | - << __SRS_JFIELD_ORG("sigignore", u->sigignore) << __SRS_JFIELD_CONT | ||
| 252 | - << __SRS_JFIELD_ORG("sigcatch", u->sigcatch) << __SRS_JFIELD_CONT | ||
| 253 | - << __SRS_JFIELD_ORG("wchan", u->wchan) << __SRS_JFIELD_CONT | ||
| 254 | - << __SRS_JFIELD_ORG("nswap", u->nswap) << __SRS_JFIELD_CONT | ||
| 255 | - << __SRS_JFIELD_ORG("cnswap", u->cnswap) << __SRS_JFIELD_CONT | ||
| 256 | - << __SRS_JFIELD_ORG("exit_signal", u->exit_signal) << __SRS_JFIELD_CONT | ||
| 257 | - << __SRS_JFIELD_ORG("processor", u->processor) << __SRS_JFIELD_CONT | ||
| 258 | - << __SRS_JFIELD_ORG("rt_priority", u->rt_priority) << __SRS_JFIELD_CONT | ||
| 259 | - << __SRS_JFIELD_ORG("policy", u->policy) << __SRS_JFIELD_CONT | ||
| 260 | - << __SRS_JFIELD_ORG("delayacct_blkio_ticks", u->delayacct_blkio_ticks) << __SRS_JFIELD_CONT | ||
| 261 | - << __SRS_JFIELD_ORG("guest_time", u->guest_time) << __SRS_JFIELD_CONT | ||
| 262 | - << __SRS_JFIELD_ORG("cguest_time", u->cguest_time) | ||
| 263 | - << __SRS_JOBJECT_END | ||
| 264 | - << __SRS_JOBJECT_END; | 213 | + ss << SRS_JOBJECT_START |
| 214 | + << SRS_JFIELD_ERROR(ERROR_SUCCESS) << SRS_JFIELD_CONT | ||
| 215 | + << SRS_JFIELD_ORG("data", SRS_JOBJECT_START) | ||
| 216 | + << SRS_JFIELD_ORG("ok", (u->ok? "true":"false")) << SRS_JFIELD_CONT | ||
| 217 | + << SRS_JFIELD_ORG("sample_time", u->sample_time) << SRS_JFIELD_CONT | ||
| 218 | + << SRS_JFIELD_ORG("percent", u->percent) << SRS_JFIELD_CONT | ||
| 219 | + << SRS_JFIELD_ORG("pid", u->pid) << SRS_JFIELD_CONT | ||
| 220 | + << SRS_JFIELD_STR("comm", u->comm) << SRS_JFIELD_CONT | ||
| 221 | + << SRS_JFIELD_STR("state", u->state) << SRS_JFIELD_CONT | ||
| 222 | + << SRS_JFIELD_ORG("ppid", u->ppid) << SRS_JFIELD_CONT | ||
| 223 | + << SRS_JFIELD_ORG("pgrp", u->pgrp) << SRS_JFIELD_CONT | ||
| 224 | + << SRS_JFIELD_ORG("session", u->session) << SRS_JFIELD_CONT | ||
| 225 | + << SRS_JFIELD_ORG("tty_nr", u->tty_nr) << SRS_JFIELD_CONT | ||
| 226 | + << SRS_JFIELD_ORG("tpgid", u->tpgid) << SRS_JFIELD_CONT | ||
| 227 | + << SRS_JFIELD_ORG("flags", u->flags) << SRS_JFIELD_CONT | ||
| 228 | + << SRS_JFIELD_ORG("minflt", u->minflt) << SRS_JFIELD_CONT | ||
| 229 | + << SRS_JFIELD_ORG("cminflt", u->cminflt) << SRS_JFIELD_CONT | ||
| 230 | + << SRS_JFIELD_ORG("majflt", u->majflt) << SRS_JFIELD_CONT | ||
| 231 | + << SRS_JFIELD_ORG("cmajflt", u->cmajflt) << SRS_JFIELD_CONT | ||
| 232 | + << SRS_JFIELD_ORG("utime", u->utime) << SRS_JFIELD_CONT | ||
| 233 | + << SRS_JFIELD_ORG("stime", u->stime) << SRS_JFIELD_CONT | ||
| 234 | + << SRS_JFIELD_ORG("cutime", u->cutime) << SRS_JFIELD_CONT | ||
| 235 | + << SRS_JFIELD_ORG("cstime", u->cstime) << SRS_JFIELD_CONT | ||
| 236 | + << SRS_JFIELD_ORG("priority", u->priority) << SRS_JFIELD_CONT | ||
| 237 | + << SRS_JFIELD_ORG("nice", u->nice) << SRS_JFIELD_CONT | ||
| 238 | + << SRS_JFIELD_ORG("num_threads", u->num_threads) << SRS_JFIELD_CONT | ||
| 239 | + << SRS_JFIELD_ORG("itrealvalue", u->itrealvalue) << SRS_JFIELD_CONT | ||
| 240 | + << SRS_JFIELD_ORG("starttime", u->starttime) << SRS_JFIELD_CONT | ||
| 241 | + << SRS_JFIELD_ORG("vsize", u->vsize) << SRS_JFIELD_CONT | ||
| 242 | + << SRS_JFIELD_ORG("rss", u->rss) << SRS_JFIELD_CONT | ||
| 243 | + << SRS_JFIELD_ORG("rsslim", u->rsslim) << SRS_JFIELD_CONT | ||
| 244 | + << SRS_JFIELD_ORG("startcode", u->startcode) << SRS_JFIELD_CONT | ||
| 245 | + << SRS_JFIELD_ORG("endcode", u->endcode) << SRS_JFIELD_CONT | ||
| 246 | + << SRS_JFIELD_ORG("startstack", u->startstack) << SRS_JFIELD_CONT | ||
| 247 | + << SRS_JFIELD_ORG("kstkesp", u->kstkesp) << SRS_JFIELD_CONT | ||
| 248 | + << SRS_JFIELD_ORG("kstkeip", u->kstkeip) << SRS_JFIELD_CONT | ||
| 249 | + << SRS_JFIELD_ORG("signal", u->signal) << SRS_JFIELD_CONT | ||
| 250 | + << SRS_JFIELD_ORG("blocked", u->blocked) << SRS_JFIELD_CONT | ||
| 251 | + << SRS_JFIELD_ORG("sigignore", u->sigignore) << SRS_JFIELD_CONT | ||
| 252 | + << SRS_JFIELD_ORG("sigcatch", u->sigcatch) << SRS_JFIELD_CONT | ||
| 253 | + << SRS_JFIELD_ORG("wchan", u->wchan) << SRS_JFIELD_CONT | ||
| 254 | + << SRS_JFIELD_ORG("nswap", u->nswap) << SRS_JFIELD_CONT | ||
| 255 | + << SRS_JFIELD_ORG("cnswap", u->cnswap) << SRS_JFIELD_CONT | ||
| 256 | + << SRS_JFIELD_ORG("exit_signal", u->exit_signal) << SRS_JFIELD_CONT | ||
| 257 | + << SRS_JFIELD_ORG("processor", u->processor) << SRS_JFIELD_CONT | ||
| 258 | + << SRS_JFIELD_ORG("rt_priority", u->rt_priority) << SRS_JFIELD_CONT | ||
| 259 | + << SRS_JFIELD_ORG("policy", u->policy) << SRS_JFIELD_CONT | ||
| 260 | + << SRS_JFIELD_ORG("delayacct_blkio_ticks", u->delayacct_blkio_ticks) << SRS_JFIELD_CONT | ||
| 261 | + << SRS_JFIELD_ORG("guest_time", u->guest_time) << SRS_JFIELD_CONT | ||
| 262 | + << SRS_JFIELD_ORG("cguest_time", u->cguest_time) | ||
| 263 | + << SRS_JOBJECT_END | ||
| 264 | + << SRS_JOBJECT_END; | ||
| 265 | 265 | ||
| 266 | return srs_go_http_response_json(w, ss.str()); | 266 | return srs_go_http_response_json(w, ss.str()); |
| 267 | } | 267 | } |
| @@ -280,23 +280,23 @@ int SrsGoApiSystemProcStats::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessag | @@ -280,23 +280,23 @@ int SrsGoApiSystemProcStats::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessag | ||
| 280 | 280 | ||
| 281 | SrsProcSystemStat* s = srs_get_system_proc_stat(); | 281 | SrsProcSystemStat* s = srs_get_system_proc_stat(); |
| 282 | 282 | ||
| 283 | - ss << __SRS_JOBJECT_START | ||
| 284 | - << __SRS_JFIELD_ERROR(ERROR_SUCCESS) << __SRS_JFIELD_CONT | ||
| 285 | - << __SRS_JFIELD_ORG("data", __SRS_JOBJECT_START) | ||
| 286 | - << __SRS_JFIELD_ORG("ok", (s->ok? "true":"false")) << __SRS_JFIELD_CONT | ||
| 287 | - << __SRS_JFIELD_ORG("sample_time", s->sample_time) << __SRS_JFIELD_CONT | ||
| 288 | - << __SRS_JFIELD_ORG("percent", s->percent) << __SRS_JFIELD_CONT | ||
| 289 | - << __SRS_JFIELD_ORG("user", s->user) << __SRS_JFIELD_CONT | ||
| 290 | - << __SRS_JFIELD_ORG("nice", s->nice) << __SRS_JFIELD_CONT | ||
| 291 | - << __SRS_JFIELD_ORG("sys", s->sys) << __SRS_JFIELD_CONT | ||
| 292 | - << __SRS_JFIELD_ORG("idle", s->idle) << __SRS_JFIELD_CONT | ||
| 293 | - << __SRS_JFIELD_ORG("iowait", s->iowait) << __SRS_JFIELD_CONT | ||
| 294 | - << __SRS_JFIELD_ORG("irq", s->irq) << __SRS_JFIELD_CONT | ||
| 295 | - << __SRS_JFIELD_ORG("softirq", s->softirq) << __SRS_JFIELD_CONT | ||
| 296 | - << __SRS_JFIELD_ORG("steal", s->steal) << __SRS_JFIELD_CONT | ||
| 297 | - << __SRS_JFIELD_ORG("guest", s->guest) | ||
| 298 | - << __SRS_JOBJECT_END | ||
| 299 | - << __SRS_JOBJECT_END; | 283 | + ss << SRS_JOBJECT_START |
| 284 | + << SRS_JFIELD_ERROR(ERROR_SUCCESS) << SRS_JFIELD_CONT | ||
| 285 | + << SRS_JFIELD_ORG("data", SRS_JOBJECT_START) | ||
| 286 | + << SRS_JFIELD_ORG("ok", (s->ok? "true":"false")) << SRS_JFIELD_CONT | ||
| 287 | + << SRS_JFIELD_ORG("sample_time", s->sample_time) << SRS_JFIELD_CONT | ||
| 288 | + << SRS_JFIELD_ORG("percent", s->percent) << SRS_JFIELD_CONT | ||
| 289 | + << SRS_JFIELD_ORG("user", s->user) << SRS_JFIELD_CONT | ||
| 290 | + << SRS_JFIELD_ORG("nice", s->nice) << SRS_JFIELD_CONT | ||
| 291 | + << SRS_JFIELD_ORG("sys", s->sys) << SRS_JFIELD_CONT | ||
| 292 | + << SRS_JFIELD_ORG("idle", s->idle) << SRS_JFIELD_CONT | ||
| 293 | + << SRS_JFIELD_ORG("iowait", s->iowait) << SRS_JFIELD_CONT | ||
| 294 | + << SRS_JFIELD_ORG("irq", s->irq) << SRS_JFIELD_CONT | ||
| 295 | + << SRS_JFIELD_ORG("softirq", s->softirq) << SRS_JFIELD_CONT | ||
| 296 | + << SRS_JFIELD_ORG("steal", s->steal) << SRS_JFIELD_CONT | ||
| 297 | + << SRS_JFIELD_ORG("guest", s->guest) | ||
| 298 | + << SRS_JOBJECT_END | ||
| 299 | + << SRS_JOBJECT_END; | ||
| 300 | 300 | ||
| 301 | return srs_go_http_response_json(w, ss.str()); | 301 | return srs_go_http_response_json(w, ss.str()); |
| 302 | } | 302 | } |
| @@ -315,24 +315,24 @@ int SrsGoApiMemInfos::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | @@ -315,24 +315,24 @@ int SrsGoApiMemInfos::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 315 | 315 | ||
| 316 | SrsMemInfo* m = srs_get_meminfo(); | 316 | SrsMemInfo* m = srs_get_meminfo(); |
| 317 | 317 | ||
| 318 | - ss << __SRS_JOBJECT_START | ||
| 319 | - << __SRS_JFIELD_ERROR(ERROR_SUCCESS) << __SRS_JFIELD_CONT | ||
| 320 | - << __SRS_JFIELD_ORG("data", __SRS_JOBJECT_START) | ||
| 321 | - << __SRS_JFIELD_ORG("ok", (m->ok? "true":"false")) << __SRS_JFIELD_CONT | ||
| 322 | - << __SRS_JFIELD_ORG("sample_time", m->sample_time) << __SRS_JFIELD_CONT | ||
| 323 | - << __SRS_JFIELD_ORG("percent_ram", m->percent_ram) << __SRS_JFIELD_CONT | ||
| 324 | - << __SRS_JFIELD_ORG("percent_swap", m->percent_swap) << __SRS_JFIELD_CONT | ||
| 325 | - << __SRS_JFIELD_ORG("MemActive", m->MemActive) << __SRS_JFIELD_CONT | ||
| 326 | - << __SRS_JFIELD_ORG("RealInUse", m->RealInUse) << __SRS_JFIELD_CONT | ||
| 327 | - << __SRS_JFIELD_ORG("NotInUse", m->NotInUse) << __SRS_JFIELD_CONT | ||
| 328 | - << __SRS_JFIELD_ORG("MemTotal", m->MemTotal) << __SRS_JFIELD_CONT | ||
| 329 | - << __SRS_JFIELD_ORG("MemFree", m->MemFree) << __SRS_JFIELD_CONT | ||
| 330 | - << __SRS_JFIELD_ORG("Buffers", m->Buffers) << __SRS_JFIELD_CONT | ||
| 331 | - << __SRS_JFIELD_ORG("Cached", m->Cached) << __SRS_JFIELD_CONT | ||
| 332 | - << __SRS_JFIELD_ORG("SwapTotal", m->SwapTotal) << __SRS_JFIELD_CONT | ||
| 333 | - << __SRS_JFIELD_ORG("SwapFree", m->SwapFree) | ||
| 334 | - << __SRS_JOBJECT_END | ||
| 335 | - << __SRS_JOBJECT_END; | 318 | + ss << SRS_JOBJECT_START |
| 319 | + << SRS_JFIELD_ERROR(ERROR_SUCCESS) << SRS_JFIELD_CONT | ||
| 320 | + << SRS_JFIELD_ORG("data", SRS_JOBJECT_START) | ||
| 321 | + << SRS_JFIELD_ORG("ok", (m->ok? "true":"false")) << SRS_JFIELD_CONT | ||
| 322 | + << SRS_JFIELD_ORG("sample_time", m->sample_time) << SRS_JFIELD_CONT | ||
| 323 | + << SRS_JFIELD_ORG("percent_ram", m->percent_ram) << SRS_JFIELD_CONT | ||
| 324 | + << SRS_JFIELD_ORG("percent_swap", m->percent_swap) << SRS_JFIELD_CONT | ||
| 325 | + << SRS_JFIELD_ORG("MemActive", m->MemActive) << SRS_JFIELD_CONT | ||
| 326 | + << SRS_JFIELD_ORG("RealInUse", m->RealInUse) << SRS_JFIELD_CONT | ||
| 327 | + << SRS_JFIELD_ORG("NotInUse", m->NotInUse) << SRS_JFIELD_CONT | ||
| 328 | + << SRS_JFIELD_ORG("MemTotal", m->MemTotal) << SRS_JFIELD_CONT | ||
| 329 | + << SRS_JFIELD_ORG("MemFree", m->MemFree) << SRS_JFIELD_CONT | ||
| 330 | + << SRS_JFIELD_ORG("Buffers", m->Buffers) << SRS_JFIELD_CONT | ||
| 331 | + << SRS_JFIELD_ORG("Cached", m->Cached) << SRS_JFIELD_CONT | ||
| 332 | + << SRS_JFIELD_ORG("SwapTotal", m->SwapTotal) << SRS_JFIELD_CONT | ||
| 333 | + << SRS_JFIELD_ORG("SwapFree", m->SwapFree) | ||
| 334 | + << SRS_JOBJECT_END | ||
| 335 | + << SRS_JOBJECT_END; | ||
| 336 | 336 | ||
| 337 | return srs_go_http_response_json(w, ss.str()); | 337 | return srs_go_http_response_json(w, ss.str()); |
| 338 | } | 338 | } |
| @@ -349,15 +349,15 @@ int SrsGoApiAuthors::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | @@ -349,15 +349,15 @@ int SrsGoApiAuthors::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 349 | { | 349 | { |
| 350 | std::stringstream ss; | 350 | std::stringstream ss; |
| 351 | 351 | ||
| 352 | - ss << __SRS_JOBJECT_START | ||
| 353 | - << __SRS_JFIELD_ERROR(ERROR_SUCCESS) << __SRS_JFIELD_CONT | ||
| 354 | - << __SRS_JFIELD_ORG("data", __SRS_JOBJECT_START) | ||
| 355 | - << __SRS_JFIELD_STR("primary", RTMP_SIG_SRS_PRIMARY) << __SRS_JFIELD_CONT | ||
| 356 | - << __SRS_JFIELD_STR("authors", RTMP_SIG_SRS_AUTHROS) << __SRS_JFIELD_CONT | ||
| 357 | - << __SRS_JFIELD_STR("contributors_link", RTMP_SIG_SRS_CONTRIBUTORS_URL) << __SRS_JFIELD_CONT | ||
| 358 | - << __SRS_JFIELD_STR("contributors", SRS_AUTO_CONSTRIBUTORS) | ||
| 359 | - << __SRS_JOBJECT_END | ||
| 360 | - << __SRS_JOBJECT_END; | 352 | + ss << SRS_JOBJECT_START |
| 353 | + << SRS_JFIELD_ERROR(ERROR_SUCCESS) << SRS_JFIELD_CONT | ||
| 354 | + << SRS_JFIELD_ORG("data", SRS_JOBJECT_START) | ||
| 355 | + << SRS_JFIELD_STR("primary", RTMP_SIG_SRS_PRIMARY) << SRS_JFIELD_CONT | ||
| 356 | + << SRS_JFIELD_STR("authors", RTMP_SIG_SRS_AUTHROS) << SRS_JFIELD_CONT | ||
| 357 | + << SRS_JFIELD_STR("contributors_link", RTMP_SIG_SRS_CONTRIBUTORS_URL) << SRS_JFIELD_CONT | ||
| 358 | + << SRS_JFIELD_STR("contributors", SRS_AUTO_CONSTRIBUTORS) | ||
| 359 | + << SRS_JOBJECT_END | ||
| 360 | + << SRS_JOBJECT_END; | ||
| 361 | 361 | ||
| 362 | return srs_go_http_response_json(w, ss.str()); | 362 | return srs_go_http_response_json(w, ss.str()); |
| 363 | } | 363 | } |
| @@ -376,49 +376,49 @@ int SrsGoApiRequests::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | @@ -376,49 +376,49 @@ int SrsGoApiRequests::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 376 | 376 | ||
| 377 | std::stringstream ss; | 377 | std::stringstream ss; |
| 378 | 378 | ||
| 379 | - ss << __SRS_JOBJECT_START | ||
| 380 | - << __SRS_JFIELD_ERROR(ERROR_SUCCESS) << __SRS_JFIELD_CONT | ||
| 381 | - << __SRS_JFIELD_ORG("data", __SRS_JOBJECT_START) | ||
| 382 | - << __SRS_JFIELD_STR("uri", req->uri()) << __SRS_JFIELD_CONT | ||
| 383 | - << __SRS_JFIELD_STR("path", req->path()) << __SRS_JFIELD_CONT; | 379 | + ss << SRS_JOBJECT_START |
| 380 | + << SRS_JFIELD_ERROR(ERROR_SUCCESS) << SRS_JFIELD_CONT | ||
| 381 | + << SRS_JFIELD_ORG("data", SRS_JOBJECT_START) | ||
| 382 | + << SRS_JFIELD_STR("uri", req->uri()) << SRS_JFIELD_CONT | ||
| 383 | + << SRS_JFIELD_STR("path", req->path()) << SRS_JFIELD_CONT; | ||
| 384 | 384 | ||
| 385 | // method | 385 | // method |
| 386 | if (req->is_http_get()) { | 386 | if (req->is_http_get()) { |
| 387 | - ss << __SRS_JFIELD_STR("METHOD", "GET"); | 387 | + ss << SRS_JFIELD_STR("METHOD", "GET"); |
| 388 | } else if (req->is_http_post()) { | 388 | } else if (req->is_http_post()) { |
| 389 | - ss << __SRS_JFIELD_STR("METHOD", "POST"); | 389 | + ss << SRS_JFIELD_STR("METHOD", "POST"); |
| 390 | } else if (req->is_http_put()) { | 390 | } else if (req->is_http_put()) { |
| 391 | - ss << __SRS_JFIELD_STR("METHOD", "PUT"); | 391 | + ss << SRS_JFIELD_STR("METHOD", "PUT"); |
| 392 | } else if (req->is_http_delete()) { | 392 | } else if (req->is_http_delete()) { |
| 393 | - ss << __SRS_JFIELD_STR("METHOD", "DELETE"); | 393 | + ss << SRS_JFIELD_STR("METHOD", "DELETE"); |
| 394 | } else { | 394 | } else { |
| 395 | - ss << __SRS_JFIELD_ORG("METHOD", req->method()); | 395 | + ss << SRS_JFIELD_ORG("METHOD", req->method()); |
| 396 | } | 396 | } |
| 397 | - ss << __SRS_JFIELD_CONT; | 397 | + ss << SRS_JFIELD_CONT; |
| 398 | 398 | ||
| 399 | // request headers | 399 | // request headers |
| 400 | - ss << __SRS_JFIELD_NAME("headers") << __SRS_JOBJECT_START; | 400 | + ss << SRS_JFIELD_NAME("headers") << SRS_JOBJECT_START; |
| 401 | for (int i = 0; i < req->request_header_count(); i++) { | 401 | for (int i = 0; i < req->request_header_count(); i++) { |
| 402 | std::string key = req->request_header_key_at(i); | 402 | std::string key = req->request_header_key_at(i); |
| 403 | std::string value = req->request_header_value_at(i); | 403 | std::string value = req->request_header_value_at(i); |
| 404 | if ( i < req->request_header_count() - 1) { | 404 | if ( i < req->request_header_count() - 1) { |
| 405 | - ss << __SRS_JFIELD_STR(key, value) << __SRS_JFIELD_CONT; | 405 | + ss << SRS_JFIELD_STR(key, value) << SRS_JFIELD_CONT; |
| 406 | } else { | 406 | } else { |
| 407 | - ss << __SRS_JFIELD_STR(key, value); | 407 | + ss << SRS_JFIELD_STR(key, value); |
| 408 | } | 408 | } |
| 409 | } | 409 | } |
| 410 | - ss << __SRS_JOBJECT_END << __SRS_JFIELD_CONT; | 410 | + ss << SRS_JOBJECT_END << SRS_JFIELD_CONT; |
| 411 | 411 | ||
| 412 | // server informations | 412 | // server informations |
| 413 | - ss << __SRS_JFIELD_NAME("server") << __SRS_JOBJECT_START | ||
| 414 | - << __SRS_JFIELD_STR("sigature", RTMP_SIG_SRS_KEY) << __SRS_JFIELD_CONT | ||
| 415 | - << __SRS_JFIELD_STR("name", RTMP_SIG_SRS_NAME) << __SRS_JFIELD_CONT | ||
| 416 | - << __SRS_JFIELD_STR("version", RTMP_SIG_SRS_VERSION) << __SRS_JFIELD_CONT | ||
| 417 | - << __SRS_JFIELD_STR("link", RTMP_SIG_SRS_URL) << __SRS_JFIELD_CONT | ||
| 418 | - << __SRS_JFIELD_ORG("time", srs_get_system_time_ms()) | ||
| 419 | - << __SRS_JOBJECT_END | ||
| 420 | - << __SRS_JOBJECT_END | ||
| 421 | - << __SRS_JOBJECT_END; | 413 | + ss << SRS_JFIELD_NAME("server") << SRS_JOBJECT_START |
| 414 | + << SRS_JFIELD_STR("sigature", RTMP_SIG_SRS_KEY) << SRS_JFIELD_CONT | ||
| 415 | + << SRS_JFIELD_STR("name", RTMP_SIG_SRS_NAME) << SRS_JFIELD_CONT | ||
| 416 | + << SRS_JFIELD_STR("version", RTMP_SIG_SRS_VERSION) << SRS_JFIELD_CONT | ||
| 417 | + << SRS_JFIELD_STR("link", RTMP_SIG_SRS_URL) << SRS_JFIELD_CONT | ||
| 418 | + << SRS_JFIELD_ORG("time", srs_get_system_time_ms()) | ||
| 419 | + << SRS_JOBJECT_END | ||
| 420 | + << SRS_JOBJECT_END | ||
| 421 | + << SRS_JOBJECT_END; | ||
| 422 | 422 | ||
| 423 | return srs_go_http_response_json(w, ss.str()); | 423 | return srs_go_http_response_json(w, ss.str()); |
| 424 | } | 424 | } |
| @@ -439,11 +439,11 @@ int SrsGoApiVhosts::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | @@ -439,11 +439,11 @@ int SrsGoApiVhosts::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 439 | 439 | ||
| 440 | std::stringstream ss; | 440 | std::stringstream ss; |
| 441 | 441 | ||
| 442 | - ss << __SRS_JOBJECT_START | ||
| 443 | - << __SRS_JFIELD_ERROR(ret) << __SRS_JFIELD_CONT | ||
| 444 | - << __SRS_JFIELD_ORG("server", stat->server_id()) << __SRS_JFIELD_CONT | ||
| 445 | - << __SRS_JFIELD_ORG("vhosts", data.str()) | ||
| 446 | - << __SRS_JOBJECT_END; | 442 | + ss << SRS_JOBJECT_START |
| 443 | + << SRS_JFIELD_ERROR(ret) << SRS_JFIELD_CONT | ||
| 444 | + << SRS_JFIELD_ORG("server", stat->server_id()) << SRS_JFIELD_CONT | ||
| 445 | + << SRS_JFIELD_ORG("vhosts", data.str()) | ||
| 446 | + << SRS_JOBJECT_END; | ||
| 447 | 447 | ||
| 448 | return srs_go_http_response_json(w, ss.str()); | 448 | return srs_go_http_response_json(w, ss.str()); |
| 449 | } | 449 | } |
| @@ -464,11 +464,11 @@ int SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | @@ -464,11 +464,11 @@ int SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 464 | 464 | ||
| 465 | std::stringstream ss; | 465 | std::stringstream ss; |
| 466 | 466 | ||
| 467 | - ss << __SRS_JOBJECT_START | ||
| 468 | - << __SRS_JFIELD_ERROR(ret) << __SRS_JFIELD_CONT | ||
| 469 | - << __SRS_JFIELD_ORG("server", stat->server_id()) << __SRS_JFIELD_CONT | ||
| 470 | - << __SRS_JFIELD_ORG("streams", data.str()) | ||
| 471 | - << __SRS_JOBJECT_END; | 467 | + ss << SRS_JOBJECT_START |
| 468 | + << SRS_JFIELD_ERROR(ret) << SRS_JFIELD_CONT | ||
| 469 | + << SRS_JFIELD_ORG("server", stat->server_id()) << SRS_JFIELD_CONT | ||
| 470 | + << SRS_JFIELD_ORG("streams", data.str()) | ||
| 471 | + << SRS_JOBJECT_END; | ||
| 472 | 472 | ||
| 473 | return srs_go_http_response_json(w, ss.str()); | 473 | return srs_go_http_response_json(w, ss.str()); |
| 474 | } | 474 | } |
| @@ -87,13 +87,13 @@ int SrsHttpClient::post(string path, string req, SrsHttpMessage** ppmsg) | @@ -87,13 +87,13 @@ int SrsHttpClient::post(string path, string req, SrsHttpMessage** ppmsg) | ||
| 87 | // POST %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s | 87 | // POST %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s |
| 88 | std::stringstream ss; | 88 | std::stringstream ss; |
| 89 | ss << "POST " << path << " " | 89 | ss << "POST " << path << " " |
| 90 | - << "HTTP/1.1" << __SRS_HTTP_CRLF | ||
| 91 | - << "Host: " << host << __SRS_HTTP_CRLF | ||
| 92 | - << "Connection: Keep-Alive" << __SRS_HTTP_CRLF | ||
| 93 | - << "Content-Length: " << std::dec << req.length() << __SRS_HTTP_CRLF | ||
| 94 | - << "User-Agent: " << RTMP_SIG_SRS_NAME << RTMP_SIG_SRS_VERSION << __SRS_HTTP_CRLF | ||
| 95 | - << "Content-Type: application/json" << __SRS_HTTP_CRLF | ||
| 96 | - << __SRS_HTTP_CRLF | 90 | + << "HTTP/1.1" << SRS_HTTP_CRLF |
| 91 | + << "Host: " << host << SRS_HTTP_CRLF | ||
| 92 | + << "Connection: Keep-Alive" << SRS_HTTP_CRLF | ||
| 93 | + << "Content-Length: " << std::dec << req.length() << SRS_HTTP_CRLF | ||
| 94 | + << "User-Agent: " << RTMP_SIG_SRS_NAME << RTMP_SIG_SRS_VERSION << SRS_HTTP_CRLF | ||
| 95 | + << "Content-Type: application/json" << SRS_HTTP_CRLF | ||
| 96 | + << SRS_HTTP_CRLF | ||
| 97 | << req; | 97 | << req; |
| 98 | 98 | ||
| 99 | std::string data = ss.str(); | 99 | std::string data = ss.str(); |
| @@ -133,13 +133,13 @@ int SrsHttpClient::get(string path, std::string req, SrsHttpMessage** ppmsg) | @@ -133,13 +133,13 @@ int SrsHttpClient::get(string path, std::string req, SrsHttpMessage** ppmsg) | ||
| 133 | // GET %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s | 133 | // GET %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s |
| 134 | std::stringstream ss; | 134 | std::stringstream ss; |
| 135 | ss << "GET " << path << " " | 135 | ss << "GET " << path << " " |
| 136 | - << "HTTP/1.1" << __SRS_HTTP_CRLF | ||
| 137 | - << "Host: " << host << __SRS_HTTP_CRLF | ||
| 138 | - << "Connection: Keep-Alive" << __SRS_HTTP_CRLF | ||
| 139 | - << "Content-Length: " << std::dec << req.length() << __SRS_HTTP_CRLF | ||
| 140 | - << "User-Agent: " << RTMP_SIG_SRS_NAME << RTMP_SIG_SRS_VERSION << __SRS_HTTP_CRLF | ||
| 141 | - << "Content-Type: application/json" << __SRS_HTTP_CRLF | ||
| 142 | - << __SRS_HTTP_CRLF | 136 | + << "HTTP/1.1" << SRS_HTTP_CRLF |
| 137 | + << "Host: " << host << SRS_HTTP_CRLF | ||
| 138 | + << "Connection: Keep-Alive" << SRS_HTTP_CRLF | ||
| 139 | + << "Content-Length: " << std::dec << req.length() << SRS_HTTP_CRLF | ||
| 140 | + << "User-Agent: " << RTMP_SIG_SRS_NAME << RTMP_SIG_SRS_VERSION << SRS_HTTP_CRLF | ||
| 141 | + << "Content-Type: application/json" << SRS_HTTP_CRLF | ||
| 142 | + << SRS_HTTP_CRLF | ||
| 143 | << req; | 143 | << req; |
| 144 | 144 | ||
| 145 | std::string data = ss.str(); | 145 | std::string data = ss.str(); |
| @@ -37,7 +37,7 @@ using namespace std; | @@ -37,7 +37,7 @@ using namespace std; | ||
| 37 | #include <srs_app_http_client.hpp> | 37 | #include <srs_app_http_client.hpp> |
| 38 | #include <srs_core_autofree.hpp> | 38 | #include <srs_core_autofree.hpp> |
| 39 | 39 | ||
| 40 | -#define SRS_HTTP_RESPONSE_OK __SRS_XSTR(ERROR_SUCCESS) | 40 | +#define SRS_HTTP_RESPONSE_OK SRS_XSTR(ERROR_SUCCESS) |
| 41 | 41 | ||
| 42 | #define SRS_HTTP_HEADER_BUFFER 1024 | 42 | #define SRS_HTTP_HEADER_BUFFER 1024 |
| 43 | #define SRS_HTTP_BODY_BUFFER 32 * 1024 | 43 | #define SRS_HTTP_BODY_BUFFER 32 * 1024 |
| @@ -55,15 +55,15 @@ int SrsHttpHooks::on_connect(string url, int client_id, string ip, SrsRequest* r | @@ -55,15 +55,15 @@ int SrsHttpHooks::on_connect(string url, int client_id, string ip, SrsRequest* r | ||
| 55 | int ret = ERROR_SUCCESS; | 55 | int ret = ERROR_SUCCESS; |
| 56 | 56 | ||
| 57 | std::stringstream ss; | 57 | std::stringstream ss; |
| 58 | - ss << __SRS_JOBJECT_START | ||
| 59 | - << __SRS_JFIELD_STR("action", "on_connect") << __SRS_JFIELD_CONT | ||
| 60 | - << __SRS_JFIELD_ORG("client_id", client_id) << __SRS_JFIELD_CONT | ||
| 61 | - << __SRS_JFIELD_STR("ip", ip) << __SRS_JFIELD_CONT | ||
| 62 | - << __SRS_JFIELD_STR("vhost", req->vhost) << __SRS_JFIELD_CONT | ||
| 63 | - << __SRS_JFIELD_STR("app", req->app) << __SRS_JFIELD_CONT | ||
| 64 | - << __SRS_JFIELD_STR("tcUrl", req->tcUrl) << __SRS_JFIELD_CONT | ||
| 65 | - << __SRS_JFIELD_STR("pageUrl", req->pageUrl) | ||
| 66 | - << __SRS_JOBJECT_END; | 58 | + ss << SRS_JOBJECT_START |
| 59 | + << SRS_JFIELD_STR("action", "on_connect") << SRS_JFIELD_CONT | ||
| 60 | + << SRS_JFIELD_ORG("client_id", client_id) << SRS_JFIELD_CONT | ||
| 61 | + << SRS_JFIELD_STR("ip", ip) << SRS_JFIELD_CONT | ||
| 62 | + << SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT | ||
| 63 | + << SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT | ||
| 64 | + << SRS_JFIELD_STR("tcUrl", req->tcUrl) << SRS_JFIELD_CONT | ||
| 65 | + << SRS_JFIELD_STR("pageUrl", req->pageUrl) | ||
| 66 | + << SRS_JOBJECT_END; | ||
| 67 | 67 | ||
| 68 | std::string data = ss.str(); | 68 | std::string data = ss.str(); |
| 69 | std::string res; | 69 | std::string res; |
| @@ -87,15 +87,15 @@ void SrsHttpHooks::on_close(string url, int client_id, string ip, SrsRequest* re | @@ -87,15 +87,15 @@ void SrsHttpHooks::on_close(string url, int client_id, string ip, SrsRequest* re | ||
| 87 | int ret = ERROR_SUCCESS; | 87 | int ret = ERROR_SUCCESS; |
| 88 | 88 | ||
| 89 | std::stringstream ss; | 89 | std::stringstream ss; |
| 90 | - ss << __SRS_JOBJECT_START | ||
| 91 | - << __SRS_JFIELD_STR("action", "on_close") << __SRS_JFIELD_CONT | ||
| 92 | - << __SRS_JFIELD_ORG("client_id", client_id) << __SRS_JFIELD_CONT | ||
| 93 | - << __SRS_JFIELD_STR("ip", ip) << __SRS_JFIELD_CONT | ||
| 94 | - << __SRS_JFIELD_STR("vhost", req->vhost) << __SRS_JFIELD_CONT | ||
| 95 | - << __SRS_JFIELD_ORG("send_bytes", send_bytes) << __SRS_JFIELD_CONT | ||
| 96 | - << __SRS_JFIELD_ORG("recv_bytes", recv_bytes) << __SRS_JFIELD_CONT | ||
| 97 | - << __SRS_JFIELD_STR("app", req->app) | ||
| 98 | - << __SRS_JOBJECT_END; | 90 | + ss << SRS_JOBJECT_START |
| 91 | + << SRS_JFIELD_STR("action", "on_close") << SRS_JFIELD_CONT | ||
| 92 | + << SRS_JFIELD_ORG("client_id", client_id) << SRS_JFIELD_CONT | ||
| 93 | + << SRS_JFIELD_STR("ip", ip) << SRS_JFIELD_CONT | ||
| 94 | + << SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT | ||
| 95 | + << SRS_JFIELD_ORG("send_bytes", send_bytes) << SRS_JFIELD_CONT | ||
| 96 | + << SRS_JFIELD_ORG("recv_bytes", recv_bytes) << SRS_JFIELD_CONT | ||
| 97 | + << SRS_JFIELD_STR("app", req->app) | ||
| 98 | + << SRS_JOBJECT_END; | ||
| 99 | 99 | ||
| 100 | std::string data = ss.str(); | 100 | std::string data = ss.str(); |
| 101 | std::string res; | 101 | std::string res; |
| @@ -119,14 +119,14 @@ int SrsHttpHooks::on_publish(string url, int client_id, string ip, SrsRequest* r | @@ -119,14 +119,14 @@ int SrsHttpHooks::on_publish(string url, int client_id, string ip, SrsRequest* r | ||
| 119 | int ret = ERROR_SUCCESS; | 119 | int ret = ERROR_SUCCESS; |
| 120 | 120 | ||
| 121 | std::stringstream ss; | 121 | std::stringstream ss; |
| 122 | - ss << __SRS_JOBJECT_START | ||
| 123 | - << __SRS_JFIELD_STR("action", "on_publish") << __SRS_JFIELD_CONT | ||
| 124 | - << __SRS_JFIELD_ORG("client_id", client_id) << __SRS_JFIELD_CONT | ||
| 125 | - << __SRS_JFIELD_STR("ip", ip) << __SRS_JFIELD_CONT | ||
| 126 | - << __SRS_JFIELD_STR("vhost", req->vhost) << __SRS_JFIELD_CONT | ||
| 127 | - << __SRS_JFIELD_STR("app", req->app) << __SRS_JFIELD_CONT | ||
| 128 | - << __SRS_JFIELD_STR("stream", req->stream) | ||
| 129 | - << __SRS_JOBJECT_END; | 122 | + ss << SRS_JOBJECT_START |
| 123 | + << SRS_JFIELD_STR("action", "on_publish") << SRS_JFIELD_CONT | ||
| 124 | + << SRS_JFIELD_ORG("client_id", client_id) << SRS_JFIELD_CONT | ||
| 125 | + << SRS_JFIELD_STR("ip", ip) << SRS_JFIELD_CONT | ||
| 126 | + << SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT | ||
| 127 | + << SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT | ||
| 128 | + << SRS_JFIELD_STR("stream", req->stream) | ||
| 129 | + << SRS_JOBJECT_END; | ||
| 130 | 130 | ||
| 131 | std::string data = ss.str(); | 131 | std::string data = ss.str(); |
| 132 | std::string res; | 132 | std::string res; |
| @@ -150,14 +150,14 @@ void SrsHttpHooks::on_unpublish(string url, int client_id, string ip, SrsRequest | @@ -150,14 +150,14 @@ void SrsHttpHooks::on_unpublish(string url, int client_id, string ip, SrsRequest | ||
| 150 | int ret = ERROR_SUCCESS; | 150 | int ret = ERROR_SUCCESS; |
| 151 | 151 | ||
| 152 | std::stringstream ss; | 152 | std::stringstream ss; |
| 153 | - ss << __SRS_JOBJECT_START | ||
| 154 | - << __SRS_JFIELD_STR("action", "on_unpublish") << __SRS_JFIELD_CONT | ||
| 155 | - << __SRS_JFIELD_ORG("client_id", client_id) << __SRS_JFIELD_CONT | ||
| 156 | - << __SRS_JFIELD_STR("ip", ip) << __SRS_JFIELD_CONT | ||
| 157 | - << __SRS_JFIELD_STR("vhost", req->vhost) << __SRS_JFIELD_CONT | ||
| 158 | - << __SRS_JFIELD_STR("app", req->app) << __SRS_JFIELD_CONT | ||
| 159 | - << __SRS_JFIELD_STR("stream", req->stream) | ||
| 160 | - << __SRS_JOBJECT_END; | 153 | + ss << SRS_JOBJECT_START |
| 154 | + << SRS_JFIELD_STR("action", "on_unpublish") << SRS_JFIELD_CONT | ||
| 155 | + << SRS_JFIELD_ORG("client_id", client_id) << SRS_JFIELD_CONT | ||
| 156 | + << SRS_JFIELD_STR("ip", ip) << SRS_JFIELD_CONT | ||
| 157 | + << SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT | ||
| 158 | + << SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT | ||
| 159 | + << SRS_JFIELD_STR("stream", req->stream) | ||
| 160 | + << SRS_JOBJECT_END; | ||
| 161 | 161 | ||
| 162 | std::string data = ss.str(); | 162 | std::string data = ss.str(); |
| 163 | std::string res; | 163 | std::string res; |
| @@ -181,14 +181,14 @@ int SrsHttpHooks::on_play(string url, int client_id, string ip, SrsRequest* req) | @@ -181,14 +181,14 @@ int SrsHttpHooks::on_play(string url, int client_id, string ip, SrsRequest* req) | ||
| 181 | int ret = ERROR_SUCCESS; | 181 | int ret = ERROR_SUCCESS; |
| 182 | 182 | ||
| 183 | std::stringstream ss; | 183 | std::stringstream ss; |
| 184 | - ss << __SRS_JOBJECT_START | ||
| 185 | - << __SRS_JFIELD_STR("action", "on_play") << __SRS_JFIELD_CONT | ||
| 186 | - << __SRS_JFIELD_ORG("client_id", client_id) << __SRS_JFIELD_CONT | ||
| 187 | - << __SRS_JFIELD_STR("ip", ip) << __SRS_JFIELD_CONT | ||
| 188 | - << __SRS_JFIELD_STR("vhost", req->vhost) << __SRS_JFIELD_CONT | ||
| 189 | - << __SRS_JFIELD_STR("app", req->app) << __SRS_JFIELD_CONT | ||
| 190 | - << __SRS_JFIELD_STR("stream", req->stream) | ||
| 191 | - << __SRS_JOBJECT_END; | 184 | + ss << SRS_JOBJECT_START |
| 185 | + << SRS_JFIELD_STR("action", "on_play") << SRS_JFIELD_CONT | ||
| 186 | + << SRS_JFIELD_ORG("client_id", client_id) << SRS_JFIELD_CONT | ||
| 187 | + << SRS_JFIELD_STR("ip", ip) << SRS_JFIELD_CONT | ||
| 188 | + << SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT | ||
| 189 | + << SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT | ||
| 190 | + << SRS_JFIELD_STR("stream", req->stream) | ||
| 191 | + << SRS_JOBJECT_END; | ||
| 192 | 192 | ||
| 193 | std::string data = ss.str(); | 193 | std::string data = ss.str(); |
| 194 | std::string res; | 194 | std::string res; |
| @@ -212,14 +212,14 @@ void SrsHttpHooks::on_stop(string url, int client_id, string ip, SrsRequest* req | @@ -212,14 +212,14 @@ void SrsHttpHooks::on_stop(string url, int client_id, string ip, SrsRequest* req | ||
| 212 | int ret = ERROR_SUCCESS; | 212 | int ret = ERROR_SUCCESS; |
| 213 | 213 | ||
| 214 | std::stringstream ss; | 214 | std::stringstream ss; |
| 215 | - ss << __SRS_JOBJECT_START | ||
| 216 | - << __SRS_JFIELD_STR("action", "on_stop") << __SRS_JFIELD_CONT | ||
| 217 | - << __SRS_JFIELD_ORG("client_id", client_id) << __SRS_JFIELD_CONT | ||
| 218 | - << __SRS_JFIELD_STR("ip", ip) << __SRS_JFIELD_CONT | ||
| 219 | - << __SRS_JFIELD_STR("vhost", req->vhost) << __SRS_JFIELD_CONT | ||
| 220 | - << __SRS_JFIELD_STR("app", req->app) << __SRS_JFIELD_CONT | ||
| 221 | - << __SRS_JFIELD_STR("stream", req->stream) | ||
| 222 | - << __SRS_JOBJECT_END; | 215 | + ss << SRS_JOBJECT_START |
| 216 | + << SRS_JFIELD_STR("action", "on_stop") << SRS_JFIELD_CONT | ||
| 217 | + << SRS_JFIELD_ORG("client_id", client_id) << SRS_JFIELD_CONT | ||
| 218 | + << SRS_JFIELD_STR("ip", ip) << SRS_JFIELD_CONT | ||
| 219 | + << SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT | ||
| 220 | + << SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT | ||
| 221 | + << SRS_JFIELD_STR("stream", req->stream) | ||
| 222 | + << SRS_JOBJECT_END; | ||
| 223 | 223 | ||
| 224 | std::string data = ss.str(); | 224 | std::string data = ss.str(); |
| 225 | std::string res; | 225 | std::string res; |
| @@ -243,16 +243,16 @@ int SrsHttpHooks::on_dvr(string url, int client_id, string ip, SrsRequest* req, | @@ -243,16 +243,16 @@ int SrsHttpHooks::on_dvr(string url, int client_id, string ip, SrsRequest* req, | ||
| 243 | int ret = ERROR_SUCCESS; | 243 | int ret = ERROR_SUCCESS; |
| 244 | 244 | ||
| 245 | std::stringstream ss; | 245 | std::stringstream ss; |
| 246 | - ss << __SRS_JOBJECT_START | ||
| 247 | - << __SRS_JFIELD_STR("action", "on_dvr") << __SRS_JFIELD_CONT | ||
| 248 | - << __SRS_JFIELD_ORG("client_id", client_id) << __SRS_JFIELD_CONT | ||
| 249 | - << __SRS_JFIELD_STR("ip", ip) << __SRS_JFIELD_CONT | ||
| 250 | - << __SRS_JFIELD_STR("vhost", req->vhost) << __SRS_JFIELD_CONT | ||
| 251 | - << __SRS_JFIELD_STR("app", req->app) << __SRS_JFIELD_CONT | ||
| 252 | - << __SRS_JFIELD_STR("stream", req->stream) << __SRS_JFIELD_CONT | ||
| 253 | - << __SRS_JFIELD_STR("cwd", cwd) << __SRS_JFIELD_CONT | ||
| 254 | - << __SRS_JFIELD_STR("file", file) | ||
| 255 | - << __SRS_JOBJECT_END; | 246 | + ss << SRS_JOBJECT_START |
| 247 | + << SRS_JFIELD_STR("action", "on_dvr") << SRS_JFIELD_CONT | ||
| 248 | + << SRS_JFIELD_ORG("client_id", client_id) << SRS_JFIELD_CONT | ||
| 249 | + << SRS_JFIELD_STR("ip", ip) << SRS_JFIELD_CONT | ||
| 250 | + << SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT | ||
| 251 | + << SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT | ||
| 252 | + << SRS_JFIELD_STR("stream", req->stream) << SRS_JFIELD_CONT | ||
| 253 | + << SRS_JFIELD_STR("cwd", cwd) << SRS_JFIELD_CONT | ||
| 254 | + << SRS_JFIELD_STR("file", file) | ||
| 255 | + << SRS_JOBJECT_END; | ||
| 256 | 256 | ||
| 257 | std::string data = ss.str(); | 257 | std::string data = ss.str(); |
| 258 | std::string res; | 258 | std::string res; |
| @@ -276,15 +276,15 @@ int SrsHttpHooks::on_dvr_reap_segment(string url, int client_id, SrsRequest* req | @@ -276,15 +276,15 @@ int SrsHttpHooks::on_dvr_reap_segment(string url, int client_id, SrsRequest* req | ||
| 276 | int ret = ERROR_SUCCESS; | 276 | int ret = ERROR_SUCCESS; |
| 277 | 277 | ||
| 278 | std::stringstream ss; | 278 | std::stringstream ss; |
| 279 | - ss << __SRS_JOBJECT_START | ||
| 280 | - << __SRS_JFIELD_STR("action", "on_dvr_reap_segment") << __SRS_JFIELD_CONT | ||
| 281 | - << __SRS_JFIELD_ORG("client_id", client_id) << __SRS_JFIELD_CONT | ||
| 282 | - << __SRS_JFIELD_STR("vhost", req->vhost) << __SRS_JFIELD_CONT | ||
| 283 | - << __SRS_JFIELD_STR("app", req->app) << __SRS_JFIELD_CONT | ||
| 284 | - << __SRS_JFIELD_STR("stream", req->stream) << __SRS_JFIELD_CONT | ||
| 285 | - << __SRS_JFIELD_STR("cwd", cwd) << __SRS_JFIELD_CONT | ||
| 286 | - << __SRS_JFIELD_STR("file", file) | ||
| 287 | - << __SRS_JOBJECT_END; | 279 | + ss << SRS_JOBJECT_START |
| 280 | + << SRS_JFIELD_STR("action", "on_dvr_reap_segment") << SRS_JFIELD_CONT | ||
| 281 | + << SRS_JFIELD_ORG("client_id", client_id) << SRS_JFIELD_CONT | ||
| 282 | + << SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT | ||
| 283 | + << SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT | ||
| 284 | + << SRS_JFIELD_STR("stream", req->stream) << SRS_JFIELD_CONT | ||
| 285 | + << SRS_JFIELD_STR("cwd", cwd) << SRS_JFIELD_CONT | ||
| 286 | + << SRS_JFIELD_STR("file", file) | ||
| 287 | + << SRS_JOBJECT_END; | ||
| 288 | 288 | ||
| 289 | std::string data = ss.str(); | 289 | std::string data = ss.str(); |
| 290 | std::string res; | 290 | std::string res; |
| @@ -27,7 +27,7 @@ using namespace std; | @@ -27,7 +27,7 @@ using namespace std; | ||
| 27 | 27 | ||
| 28 | #include <srs_kernel_log.hpp> | 28 | #include <srs_kernel_log.hpp> |
| 29 | 29 | ||
| 30 | -#ifdef __SRS_JSON_USE_NXJSON | 30 | +#ifdef SRS_JSON_USE_NXJSON |
| 31 | 31 | ||
| 32 | //////////////////////////////////////////////////////////////////////////////////////////////// | 32 | //////////////////////////////////////////////////////////////////////////////////////////////// |
| 33 | //////////////////////////////////////////////////////////////////////////////////////////////// | 33 | //////////////////////////////////////////////////////////////////////////////////////////////// |
| @@ -302,7 +302,7 @@ SrsJsonArray* SrsJsonAny::array() | @@ -302,7 +302,7 @@ SrsJsonArray* SrsJsonAny::array() | ||
| 302 | return new SrsJsonArray(); | 302 | return new SrsJsonArray(); |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | -#ifdef __SRS_JSON_USE_NXJSON | 305 | +#ifdef SRS_JSON_USE_NXJSON |
| 306 | SrsJsonAny* srs_json_parse_tree_nx_json(const nx_json* node) | 306 | SrsJsonAny* srs_json_parse_tree_nx_json(const nx_json* node) |
| 307 | { | 307 | { |
| 308 | if (!node) { | 308 | if (!node) { |
| @@ -504,7 +504,7 @@ void SrsJsonArray::add(SrsJsonAny* value) | @@ -504,7 +504,7 @@ void SrsJsonArray::add(SrsJsonAny* value) | ||
| 504 | properties.push_back(value); | 504 | properties.push_back(value); |
| 505 | } | 505 | } |
| 506 | 506 | ||
| 507 | -#ifdef __SRS_JSON_USE_NXJSON | 507 | +#ifdef SRS_JSON_USE_NXJSON |
| 508 | 508 | ||
| 509 | //////////////////////////////////////////////////////////////////////////////////////////////// | 509 | //////////////////////////////////////////////////////////////////////////////////////////////// |
| 510 | //////////////////////////////////////////////////////////////////////////////////////////////// | 510 | //////////////////////////////////////////////////////////////////////////////////////////////// |
| @@ -34,8 +34,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -34,8 +34,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 34 | 34 | ||
| 35 | // whether use nxjson | 35 | // whether use nxjson |
| 36 | // @see: https://bitbucket.org/yarosla/nxjson | 36 | // @see: https://bitbucket.org/yarosla/nxjson |
| 37 | -#undef __SRS_JSON_USE_NXJSON | ||
| 38 | -#define __SRS_JSON_USE_NXJSON | 37 | +#undef SRS_JSON_USE_NXJSON |
| 38 | +#define SRS_JSON_USE_NXJSON | ||
| 39 | 39 | ||
| 40 | //////////////////////////////////////////////////////////////////////// | 40 | //////////////////////////////////////////////////////////////////////// |
| 41 | //////////////////////////////////////////////////////////////////////// | 41 | //////////////////////////////////////////////////////////////////////// |
| @@ -174,16 +174,16 @@ public: | @@ -174,16 +174,16 @@ public: | ||
| 174 | //////////////////////////////////////////////////////////////////////// | 174 | //////////////////////////////////////////////////////////////////////// |
| 175 | //////////////////////////////////////////////////////////////////////// | 175 | //////////////////////////////////////////////////////////////////////// |
| 176 | /* json encode | 176 | /* json encode |
| 177 | - cout<< __SRS_JOBJECT_START | ||
| 178 | - << __SRS_JFIELD_STR("name", "srs") << __SRS_JFIELD_CONT | ||
| 179 | - << __SRS_JFIELD_ORG("version", 100) << __SRS_JFIELD_CONT | ||
| 180 | - << __SRS_JFIELD_NAME("features") << __SRS_JOBJECT_START | ||
| 181 | - << __SRS_JFIELD_STR("rtmp", "released") << __SRS_JFIELD_CONT | ||
| 182 | - << __SRS_JFIELD_STR("hls", "released") << __SRS_JFIELD_CONT | ||
| 183 | - << __SRS_JFIELD_STR("dash", "plan") | ||
| 184 | - << __SRS_JOBJECT_END << __SRS_JFIELD_CONT | ||
| 185 | - << __SRS_JFIELD_STR("author", "srs team") | ||
| 186 | - << __SRS_JOBJECT_END | 177 | + cout<< SRS_JOBJECT_START |
| 178 | + << SRS_JFIELD_STR("name", "srs") << SRS_JFIELD_CONT | ||
| 179 | + << SRS_JFIELD_ORG("version", 100) << SRS_JFIELD_CONT | ||
| 180 | + << SRS_JFIELD_NAME("features") << SRS_JOBJECT_START | ||
| 181 | + << SRS_JFIELD_STR("rtmp", "released") << SRS_JFIELD_CONT | ||
| 182 | + << SRS_JFIELD_STR("hls", "released") << SRS_JFIELD_CONT | ||
| 183 | + << SRS_JFIELD_STR("dash", "plan") | ||
| 184 | + << SRS_JOBJECT_END << SRS_JFIELD_CONT | ||
| 185 | + << SRS_JFIELD_STR("author", "srs team") | ||
| 186 | + << SRS_JOBJECT_END | ||
| 187 | it's: | 187 | it's: |
| 188 | cont<< "{" | 188 | cont<< "{" |
| 189 | << "name:" << "srs" << "," | 189 | << "name:" << "srs" << "," |
| @@ -212,16 +212,16 @@ that is: | @@ -212,16 +212,16 @@ that is: | ||
| 212 | //////////////////////////////////////////////////////////////////////// | 212 | //////////////////////////////////////////////////////////////////////// |
| 213 | //////////////////////////////////////////////////////////////////////// | 213 | //////////////////////////////////////////////////////////////////////// |
| 214 | //////////////////////////////////////////////////////////////////////// | 214 | //////////////////////////////////////////////////////////////////////// |
| 215 | -#define __SRS_JOBJECT_START "{" | ||
| 216 | -#define __SRS_JFIELD_NAME(k) "\"" << k << "\":" | ||
| 217 | -#define __SRS_JFIELD_STR(k, v) "\"" << k << "\":\"" << v << "\"" | ||
| 218 | -#define __SRS_JFIELD_ORG(k, v) "\"" << k << "\":" << std::dec << v | ||
| 219 | -#define __SRS_JFIELD_BOOL(k, v) __SRS_JFIELD_ORG(k, (v? "true":"false")) | ||
| 220 | -#define __SRS_JFIELD_NULL(k) "\"" << k << "\":null" | ||
| 221 | -#define __SRS_JFIELD_ERROR(ret) "\"" << "code" << "\":" << ret | ||
| 222 | -#define __SRS_JFIELD_CONT "," | ||
| 223 | -#define __SRS_JOBJECT_END "}" | ||
| 224 | -#define __SRS_JARRAY_START "[" | ||
| 225 | -#define __SRS_JARRAY_END "]" | 215 | +#define SRS_JOBJECT_START "{" |
| 216 | +#define SRS_JFIELD_NAME(k) "\"" << k << "\":" | ||
| 217 | +#define SRS_JFIELD_STR(k, v) "\"" << k << "\":\"" << v << "\"" | ||
| 218 | +#define SRS_JFIELD_ORG(k, v) "\"" << k << "\":" << std::dec << v | ||
| 219 | +#define SRS_JFIELD_BOOL(k, v) SRS_JFIELD_ORG(k, (v? "true":"false")) | ||
| 220 | +#define SRS_JFIELD_NULL(k) "\"" << k << "\":null" | ||
| 221 | +#define SRS_JFIELD_ERROR(ret) "\"" << "code" << "\":" << ret | ||
| 222 | +#define SRS_JFIELD_CONT "," | ||
| 223 | +#define SRS_JOBJECT_END "}" | ||
| 224 | +#define SRS_JARRAY_START "[" | ||
| 225 | +#define SRS_JARRAY_END "]" | ||
| 226 | 226 | ||
| 227 | #endif | 227 | #endif |
| @@ -250,22 +250,22 @@ int SrsStatistic::dumps_vhosts(stringstream& ss) | @@ -250,22 +250,22 @@ int SrsStatistic::dumps_vhosts(stringstream& ss) | ||
| 250 | { | 250 | { |
| 251 | int ret = ERROR_SUCCESS; | 251 | int ret = ERROR_SUCCESS; |
| 252 | 252 | ||
| 253 | - ss << __SRS_JARRAY_START; | 253 | + ss << SRS_JARRAY_START; |
| 254 | std::map<std::string, SrsStatisticVhost*>::iterator it; | 254 | std::map<std::string, SrsStatisticVhost*>::iterator it; |
| 255 | for (it = vhosts.begin(); it != vhosts.end(); it++) { | 255 | for (it = vhosts.begin(); it != vhosts.end(); it++) { |
| 256 | SrsStatisticVhost* vhost = it->second; | 256 | SrsStatisticVhost* vhost = it->second; |
| 257 | if (it != vhosts.begin()) { | 257 | if (it != vhosts.begin()) { |
| 258 | - ss << __SRS_JFIELD_CONT; | 258 | + ss << SRS_JFIELD_CONT; |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | - ss << __SRS_JOBJECT_START | ||
| 262 | - << __SRS_JFIELD_ORG("id", vhost->id) << __SRS_JFIELD_CONT | ||
| 263 | - << __SRS_JFIELD_STR("name", vhost->vhost) << __SRS_JFIELD_CONT | ||
| 264 | - << __SRS_JFIELD_ORG("send_bytes", vhost->kbps->get_send_bytes()) << __SRS_JFIELD_CONT | ||
| 265 | - << __SRS_JFIELD_ORG("recv_bytes", vhost->kbps->get_recv_bytes()) | ||
| 266 | - << __SRS_JOBJECT_END; | 261 | + ss << SRS_JOBJECT_START |
| 262 | + << SRS_JFIELD_ORG("id", vhost->id) << SRS_JFIELD_CONT | ||
| 263 | + << SRS_JFIELD_STR("name", vhost->vhost) << SRS_JFIELD_CONT | ||
| 264 | + << SRS_JFIELD_ORG("send_bytes", vhost->kbps->get_send_bytes()) << SRS_JFIELD_CONT | ||
| 265 | + << SRS_JFIELD_ORG("recv_bytes", vhost->kbps->get_recv_bytes()) | ||
| 266 | + << SRS_JOBJECT_END; | ||
| 267 | } | 267 | } |
| 268 | - ss << __SRS_JARRAY_END; | 268 | + ss << SRS_JARRAY_END; |
| 269 | 269 | ||
| 270 | return ret; | 270 | return ret; |
| 271 | } | 271 | } |
| @@ -274,12 +274,12 @@ int SrsStatistic::dumps_streams(stringstream& ss) | @@ -274,12 +274,12 @@ int SrsStatistic::dumps_streams(stringstream& ss) | ||
| 274 | { | 274 | { |
| 275 | int ret = ERROR_SUCCESS; | 275 | int ret = ERROR_SUCCESS; |
| 276 | 276 | ||
| 277 | - ss << __SRS_JARRAY_START; | 277 | + ss << SRS_JARRAY_START; |
| 278 | std::map<std::string, SrsStatisticStream*>::iterator it; | 278 | std::map<std::string, SrsStatisticStream*>::iterator it; |
| 279 | for (it = streams.begin(); it != streams.end(); it++) { | 279 | for (it = streams.begin(); it != streams.end(); it++) { |
| 280 | SrsStatisticStream* stream = it->second; | 280 | SrsStatisticStream* stream = it->second; |
| 281 | if (it != streams.begin()) { | 281 | if (it != streams.begin()) { |
| 282 | - ss << __SRS_JFIELD_CONT; | 282 | + ss << SRS_JFIELD_CONT; |
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | int client_num = 0; | 285 | int client_num = 0; |
| @@ -291,41 +291,41 @@ int SrsStatistic::dumps_streams(stringstream& ss) | @@ -291,41 +291,41 @@ int SrsStatistic::dumps_streams(stringstream& ss) | ||
| 291 | } | 291 | } |
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | - ss << __SRS_JOBJECT_START | ||
| 295 | - << __SRS_JFIELD_ORG("id", stream->id) << __SRS_JFIELD_CONT | ||
| 296 | - << __SRS_JFIELD_STR("name", stream->stream) << __SRS_JFIELD_CONT | ||
| 297 | - << __SRS_JFIELD_ORG("vhost", stream->vhost->id) << __SRS_JFIELD_CONT | ||
| 298 | - << __SRS_JFIELD_ORG("clients", client_num) << __SRS_JFIELD_CONT | ||
| 299 | - << __SRS_JFIELD_ORG("send_bytes", stream->kbps->get_send_bytes()) << __SRS_JFIELD_CONT | ||
| 300 | - << __SRS_JFIELD_ORG("recv_bytes", stream->kbps->get_recv_bytes()) << __SRS_JFIELD_CONT; | 294 | + ss << SRS_JOBJECT_START |
| 295 | + << SRS_JFIELD_ORG("id", stream->id) << SRS_JFIELD_CONT | ||
| 296 | + << SRS_JFIELD_STR("name", stream->stream) << SRS_JFIELD_CONT | ||
| 297 | + << SRS_JFIELD_ORG("vhost", stream->vhost->id) << SRS_JFIELD_CONT | ||
| 298 | + << SRS_JFIELD_ORG("clients", client_num) << SRS_JFIELD_CONT | ||
| 299 | + << SRS_JFIELD_ORG("send_bytes", stream->kbps->get_send_bytes()) << SRS_JFIELD_CONT | ||
| 300 | + << SRS_JFIELD_ORG("recv_bytes", stream->kbps->get_recv_bytes()) << SRS_JFIELD_CONT; | ||
| 301 | 301 | ||
| 302 | if (!stream->has_video) { | 302 | if (!stream->has_video) { |
| 303 | - ss << __SRS_JFIELD_NULL("video") << __SRS_JFIELD_CONT; | 303 | + ss << SRS_JFIELD_NULL("video") << SRS_JFIELD_CONT; |
| 304 | } else { | 304 | } else { |
| 305 | - ss << __SRS_JFIELD_NAME("video") | ||
| 306 | - << __SRS_JOBJECT_START | ||
| 307 | - << __SRS_JFIELD_STR("codec", srs_codec_video2str(stream->vcodec)) << __SRS_JFIELD_CONT | ||
| 308 | - << __SRS_JFIELD_STR("profile", srs_codec_avc_profile2str(stream->avc_profile)) << __SRS_JFIELD_CONT | ||
| 309 | - << __SRS_JFIELD_ORG("level", srs_codec_avc_level2str(stream->avc_level)) | ||
| 310 | - << __SRS_JOBJECT_END | ||
| 311 | - << __SRS_JFIELD_CONT; | 305 | + ss << SRS_JFIELD_NAME("video") |
| 306 | + << SRS_JOBJECT_START | ||
| 307 | + << SRS_JFIELD_STR("codec", srs_codec_video2str(stream->vcodec)) << SRS_JFIELD_CONT | ||
| 308 | + << SRS_JFIELD_STR("profile", srs_codec_avc_profile2str(stream->avc_profile)) << SRS_JFIELD_CONT | ||
| 309 | + << SRS_JFIELD_ORG("level", srs_codec_avc_level2str(stream->avc_level)) | ||
| 310 | + << SRS_JOBJECT_END | ||
| 311 | + << SRS_JFIELD_CONT; | ||
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | if (!stream->has_audio) { | 314 | if (!stream->has_audio) { |
| 315 | - ss << __SRS_JFIELD_NULL("audio"); | 315 | + ss << SRS_JFIELD_NULL("audio"); |
| 316 | } else { | 316 | } else { |
| 317 | - ss << __SRS_JFIELD_NAME("audio") | ||
| 318 | - << __SRS_JOBJECT_START | ||
| 319 | - << __SRS_JFIELD_STR("codec", srs_codec_audio2str(stream->acodec)) << __SRS_JFIELD_CONT | ||
| 320 | - << __SRS_JFIELD_ORG("sample_rate", (int)flv_sample_rates[stream->asample_rate]) << __SRS_JFIELD_CONT | ||
| 321 | - << __SRS_JFIELD_ORG("channel", (int)stream->asound_type + 1) << __SRS_JFIELD_CONT | ||
| 322 | - << __SRS_JFIELD_STR("profile", srs_codec_aac_object2str(stream->aac_object)) | ||
| 323 | - << __SRS_JOBJECT_END; | 317 | + ss << SRS_JFIELD_NAME("audio") |
| 318 | + << SRS_JOBJECT_START | ||
| 319 | + << SRS_JFIELD_STR("codec", srs_codec_audio2str(stream->acodec)) << SRS_JFIELD_CONT | ||
| 320 | + << SRS_JFIELD_ORG("sample_rate", (int)flv_sample_rates[stream->asample_rate]) << SRS_JFIELD_CONT | ||
| 321 | + << SRS_JFIELD_ORG("channel", (int)stream->asound_type + 1) << SRS_JFIELD_CONT | ||
| 322 | + << SRS_JFIELD_STR("profile", srs_codec_aac_object2str(stream->aac_object)) | ||
| 323 | + << SRS_JOBJECT_END; | ||
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | - ss << __SRS_JOBJECT_END; | 326 | + ss << SRS_JOBJECT_END; |
| 327 | } | 327 | } |
| 328 | - ss << __SRS_JARRAY_END; | 328 | + ss << SRS_JARRAY_END; |
| 329 | 329 | ||
| 330 | return ret; | 330 | return ret; |
| 331 | } | 331 | } |
| @@ -1123,51 +1123,51 @@ void srs_api_dump_summaries(std::stringstream& ss) | @@ -1123,51 +1123,51 @@ void srs_api_dump_summaries(std::stringstream& ss) | ||
| 1123 | bool ok = (r->ok && u->ok && s->ok && c->ok | 1123 | bool ok = (r->ok && u->ok && s->ok && c->ok |
| 1124 | && d->ok && m->ok && p->ok && n_ok && nrs->ok); | 1124 | && d->ok && m->ok && p->ok && n_ok && nrs->ok); |
| 1125 | 1125 | ||
| 1126 | - ss << __SRS_JOBJECT_START | ||
| 1127 | - << __SRS_JFIELD_ERROR(ERROR_SUCCESS) << __SRS_JFIELD_CONT | ||
| 1128 | - << __SRS_JFIELD_ORG("data", __SRS_JOBJECT_START) | ||
| 1129 | - << __SRS_JFIELD_ORG("ok", (ok? "true":"false")) << __SRS_JFIELD_CONT | ||
| 1130 | - << __SRS_JFIELD_ORG("now_ms", now) << __SRS_JFIELD_CONT | ||
| 1131 | - << __SRS_JFIELD_ORG("self", __SRS_JOBJECT_START) | ||
| 1132 | - << __SRS_JFIELD_STR("version", RTMP_SIG_SRS_VERSION) << __SRS_JFIELD_CONT | ||
| 1133 | - << __SRS_JFIELD_ORG("pid", getpid()) << __SRS_JFIELD_CONT | ||
| 1134 | - << __SRS_JFIELD_ORG("ppid", u->ppid) << __SRS_JFIELD_CONT | ||
| 1135 | - << __SRS_JFIELD_STR("argv", _srs_config->argv()) << __SRS_JFIELD_CONT | ||
| 1136 | - << __SRS_JFIELD_STR("cwd", _srs_config->cwd()) << __SRS_JFIELD_CONT | ||
| 1137 | - << __SRS_JFIELD_ORG("mem_kbyte", r->r.ru_maxrss) << __SRS_JFIELD_CONT | ||
| 1138 | - << __SRS_JFIELD_ORG("mem_percent", self_mem_percent) << __SRS_JFIELD_CONT | ||
| 1139 | - << __SRS_JFIELD_ORG("cpu_percent", u->percent) << __SRS_JFIELD_CONT | ||
| 1140 | - << __SRS_JFIELD_ORG("srs_uptime", srs_uptime) | ||
| 1141 | - << __SRS_JOBJECT_END << __SRS_JFIELD_CONT | ||
| 1142 | - << __SRS_JFIELD_ORG("system", __SRS_JOBJECT_START) | ||
| 1143 | - << __SRS_JFIELD_ORG("cpu_percent", s->percent) << __SRS_JFIELD_CONT | ||
| 1144 | - << __SRS_JFIELD_ORG("disk_read_KBps", d->in_KBps) << __SRS_JFIELD_CONT | ||
| 1145 | - << __SRS_JFIELD_ORG("disk_write_KBps", d->out_KBps) << __SRS_JFIELD_CONT | ||
| 1146 | - << __SRS_JFIELD_ORG("disk_busy_percent", d->busy) << __SRS_JFIELD_CONT | ||
| 1147 | - << __SRS_JFIELD_ORG("mem_ram_kbyte", m->MemTotal) << __SRS_JFIELD_CONT | ||
| 1148 | - << __SRS_JFIELD_ORG("mem_ram_percent", m->percent_ram) << __SRS_JFIELD_CONT | ||
| 1149 | - << __SRS_JFIELD_ORG("mem_swap_kbyte", m->SwapTotal) << __SRS_JFIELD_CONT | ||
| 1150 | - << __SRS_JFIELD_ORG("mem_swap_percent", m->percent_swap) << __SRS_JFIELD_CONT | ||
| 1151 | - << __SRS_JFIELD_ORG("cpus", c->nb_processors) << __SRS_JFIELD_CONT | ||
| 1152 | - << __SRS_JFIELD_ORG("cpus_online", c->nb_processors_online) << __SRS_JFIELD_CONT | ||
| 1153 | - << __SRS_JFIELD_ORG("uptime", p->os_uptime) << __SRS_JFIELD_CONT | ||
| 1154 | - << __SRS_JFIELD_ORG("ilde_time", p->os_ilde_time) << __SRS_JFIELD_CONT | ||
| 1155 | - << __SRS_JFIELD_ORG("load_1m", p->load_one_minutes) << __SRS_JFIELD_CONT | ||
| 1156 | - << __SRS_JFIELD_ORG("load_5m", p->load_five_minutes) << __SRS_JFIELD_CONT | ||
| 1157 | - << __SRS_JFIELD_ORG("load_15m", p->load_fifteen_minutes) << __SRS_JFIELD_CONT | ||
| 1158 | - << __SRS_JFIELD_ORG("net_sample_time", n_sample_time) << __SRS_JFIELD_CONT | ||
| 1159 | - << __SRS_JFIELD_ORG("net_recv_bytes", nr_bytes) << __SRS_JFIELD_CONT | ||
| 1160 | - << __SRS_JFIELD_ORG("net_send_bytes", ns_bytes) << __SRS_JFIELD_CONT | ||
| 1161 | - << __SRS_JFIELD_ORG("srs_sample_time", nrs->sample_time) << __SRS_JFIELD_CONT | ||
| 1162 | - << __SRS_JFIELD_ORG("srs_recv_bytes", nrs->rbytes) << __SRS_JFIELD_CONT | ||
| 1163 | - << __SRS_JFIELD_ORG("srs_send_bytes", nrs->sbytes) << __SRS_JFIELD_CONT | ||
| 1164 | - << __SRS_JFIELD_ORG("conn_sys", nrs->nb_conn_sys) << __SRS_JFIELD_CONT | ||
| 1165 | - << __SRS_JFIELD_ORG("conn_sys_et", nrs->nb_conn_sys_et) << __SRS_JFIELD_CONT | ||
| 1166 | - << __SRS_JFIELD_ORG("conn_sys_tw", nrs->nb_conn_sys_tw) << __SRS_JFIELD_CONT | ||
| 1167 | - << __SRS_JFIELD_ORG("conn_sys_udp", nrs->nb_conn_sys_udp) << __SRS_JFIELD_CONT | ||
| 1168 | - << __SRS_JFIELD_ORG("conn_srs", nrs->nb_conn_srs) | ||
| 1169 | - << __SRS_JOBJECT_END | ||
| 1170 | - << __SRS_JOBJECT_END | ||
| 1171 | - << __SRS_JOBJECT_END; | 1126 | + ss << SRS_JOBJECT_START |
| 1127 | + << SRS_JFIELD_ERROR(ERROR_SUCCESS) << SRS_JFIELD_CONT | ||
| 1128 | + << SRS_JFIELD_ORG("data", SRS_JOBJECT_START) | ||
| 1129 | + << SRS_JFIELD_ORG("ok", (ok? "true":"false")) << SRS_JFIELD_CONT | ||
| 1130 | + << SRS_JFIELD_ORG("now_ms", now) << SRS_JFIELD_CONT | ||
| 1131 | + << SRS_JFIELD_ORG("self", SRS_JOBJECT_START) | ||
| 1132 | + << SRS_JFIELD_STR("version", RTMP_SIG_SRS_VERSION) << SRS_JFIELD_CONT | ||
| 1133 | + << SRS_JFIELD_ORG("pid", getpid()) << SRS_JFIELD_CONT | ||
| 1134 | + << SRS_JFIELD_ORG("ppid", u->ppid) << SRS_JFIELD_CONT | ||
| 1135 | + << SRS_JFIELD_STR("argv", _srs_config->argv()) << SRS_JFIELD_CONT | ||
| 1136 | + << SRS_JFIELD_STR("cwd", _srs_config->cwd()) << SRS_JFIELD_CONT | ||
| 1137 | + << SRS_JFIELD_ORG("mem_kbyte", r->r.ru_maxrss) << SRS_JFIELD_CONT | ||
| 1138 | + << SRS_JFIELD_ORG("mem_percent", self_mem_percent) << SRS_JFIELD_CONT | ||
| 1139 | + << SRS_JFIELD_ORG("cpu_percent", u->percent) << SRS_JFIELD_CONT | ||
| 1140 | + << SRS_JFIELD_ORG("srs_uptime", srs_uptime) | ||
| 1141 | + << SRS_JOBJECT_END << SRS_JFIELD_CONT | ||
| 1142 | + << SRS_JFIELD_ORG("system", SRS_JOBJECT_START) | ||
| 1143 | + << SRS_JFIELD_ORG("cpu_percent", s->percent) << SRS_JFIELD_CONT | ||
| 1144 | + << SRS_JFIELD_ORG("disk_read_KBps", d->in_KBps) << SRS_JFIELD_CONT | ||
| 1145 | + << SRS_JFIELD_ORG("disk_write_KBps", d->out_KBps) << SRS_JFIELD_CONT | ||
| 1146 | + << SRS_JFIELD_ORG("disk_busy_percent", d->busy) << SRS_JFIELD_CONT | ||
| 1147 | + << SRS_JFIELD_ORG("mem_ram_kbyte", m->MemTotal) << SRS_JFIELD_CONT | ||
| 1148 | + << SRS_JFIELD_ORG("mem_ram_percent", m->percent_ram) << SRS_JFIELD_CONT | ||
| 1149 | + << SRS_JFIELD_ORG("mem_swap_kbyte", m->SwapTotal) << SRS_JFIELD_CONT | ||
| 1150 | + << SRS_JFIELD_ORG("mem_swap_percent", m->percent_swap) << SRS_JFIELD_CONT | ||
| 1151 | + << SRS_JFIELD_ORG("cpus", c->nb_processors) << SRS_JFIELD_CONT | ||
| 1152 | + << SRS_JFIELD_ORG("cpus_online", c->nb_processors_online) << SRS_JFIELD_CONT | ||
| 1153 | + << SRS_JFIELD_ORG("uptime", p->os_uptime) << SRS_JFIELD_CONT | ||
| 1154 | + << SRS_JFIELD_ORG("ilde_time", p->os_ilde_time) << SRS_JFIELD_CONT | ||
| 1155 | + << SRS_JFIELD_ORG("load_1m", p->load_one_minutes) << SRS_JFIELD_CONT | ||
| 1156 | + << SRS_JFIELD_ORG("load_5m", p->load_five_minutes) << SRS_JFIELD_CONT | ||
| 1157 | + << SRS_JFIELD_ORG("load_15m", p->load_fifteen_minutes) << SRS_JFIELD_CONT | ||
| 1158 | + << SRS_JFIELD_ORG("net_sample_time", n_sample_time) << SRS_JFIELD_CONT | ||
| 1159 | + << SRS_JFIELD_ORG("net_recv_bytes", nr_bytes) << SRS_JFIELD_CONT | ||
| 1160 | + << SRS_JFIELD_ORG("net_send_bytes", ns_bytes) << SRS_JFIELD_CONT | ||
| 1161 | + << SRS_JFIELD_ORG("srs_sample_time", nrs->sample_time) << SRS_JFIELD_CONT | ||
| 1162 | + << SRS_JFIELD_ORG("srs_recv_bytes", nrs->rbytes) << SRS_JFIELD_CONT | ||
| 1163 | + << SRS_JFIELD_ORG("srs_send_bytes", nrs->sbytes) << SRS_JFIELD_CONT | ||
| 1164 | + << SRS_JFIELD_ORG("conn_sys", nrs->nb_conn_sys) << SRS_JFIELD_CONT | ||
| 1165 | + << SRS_JFIELD_ORG("conn_sys_et", nrs->nb_conn_sys_et) << SRS_JFIELD_CONT | ||
| 1166 | + << SRS_JFIELD_ORG("conn_sys_tw", nrs->nb_conn_sys_tw) << SRS_JFIELD_CONT | ||
| 1167 | + << SRS_JFIELD_ORG("conn_sys_udp", nrs->nb_conn_sys_udp) << SRS_JFIELD_CONT | ||
| 1168 | + << SRS_JFIELD_ORG("conn_srs", nrs->nb_conn_srs) | ||
| 1169 | + << SRS_JOBJECT_END | ||
| 1170 | + << SRS_JOBJECT_END | ||
| 1171 | + << SRS_JOBJECT_END; | ||
| 1172 | } | 1172 | } |
| 1173 | 1173 |
| @@ -50,17 +50,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -50,17 +50,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 50 | #define RTMP_SIG_SRS_HANDSHAKE RTMP_SIG_SRS_KEY"("RTMP_SIG_SRS_VERSION")" | 50 | #define RTMP_SIG_SRS_HANDSHAKE RTMP_SIG_SRS_KEY"("RTMP_SIG_SRS_VERSION")" |
| 51 | #define RTMP_SIG_SRS_RELEASE RTMP_SIG_SRS_URL"/tree/1.0release" | 51 | #define RTMP_SIG_SRS_RELEASE RTMP_SIG_SRS_URL"/tree/1.0release" |
| 52 | #define RTMP_SIG_SRS_ISSUES(id) RTMP_SIG_SRS_URL"/issues/"#id | 52 | #define RTMP_SIG_SRS_ISSUES(id) RTMP_SIG_SRS_URL"/issues/"#id |
| 53 | -#define RTMP_SIG_SRS_VERSION __SRS_XSTR(VERSION_MAJOR)"."__SRS_XSTR(VERSION_MINOR)"."__SRS_XSTR(VERSION_REVISION) | 53 | +#define RTMP_SIG_SRS_VERSION SRS_XSTR(VERSION_MAJOR)"."SRS_XSTR(VERSION_MINOR)"."SRS_XSTR(VERSION_REVISION) |
| 54 | #define RTMP_SIG_SRS_SERVER RTMP_SIG_SRS_KEY"/"RTMP_SIG_SRS_VERSION"("RTMP_SIG_SRS_CODE")" | 54 | #define RTMP_SIG_SRS_SERVER RTMP_SIG_SRS_KEY"/"RTMP_SIG_SRS_VERSION"("RTMP_SIG_SRS_CODE")" |
| 55 | 55 | ||
| 56 | // stable major version | 56 | // stable major version |
| 57 | #define VERSION_STABLE 1 | 57 | #define VERSION_STABLE 1 |
| 58 | -#define VERSION_STABLE_BRANCH __SRS_XSTR(VERSION_STABLE)".0release" | 58 | +#define VERSION_STABLE_BRANCH SRS_XSTR(VERSION_STABLE)".0release" |
| 59 | 59 | ||
| 60 | // internal macros, covert macro values to str, | 60 | // internal macros, covert macro values to str, |
| 61 | // see: read https://gcc.gnu.org/onlinedocs/cpp/Stringification.html#Stringification | 61 | // see: read https://gcc.gnu.org/onlinedocs/cpp/Stringification.html#Stringification |
| 62 | -#define __SRS_XSTR(v) __SRS_STR(v) | ||
| 63 | -#define __SRS_STR(v) #v | 62 | +#define SRS_XSTR(v) SRS_INTERNAL_STR(v) |
| 63 | +#define SRS_INTERNAL_STR(v) #v | ||
| 64 | 64 | ||
| 65 | /** | 65 | /** |
| 66 | * the core provides the common defined macros, utilities, | 66 | * the core provides the common defined macros, utilities, |
| @@ -304,10 +304,10 @@ int SrsCodecSample::add_sample_unit(char* bytes, int size) | @@ -304,10 +304,10 @@ int SrsCodecSample::add_sample_unit(char* bytes, int size) | ||
| 304 | { | 304 | { |
| 305 | int ret = ERROR_SUCCESS; | 305 | int ret = ERROR_SUCCESS; |
| 306 | 306 | ||
| 307 | - if (nb_sample_units >= __SRS_SRS_MAX_CODEC_SAMPLE) { | 307 | + if (nb_sample_units >= SRS_SRS_MAX_CODEC_SAMPLE) { |
| 308 | ret = ERROR_HLS_DECODE_ERROR; | 308 | ret = ERROR_HLS_DECODE_ERROR; |
| 309 | srs_error("hls decode samples error, " | 309 | srs_error("hls decode samples error, " |
| 310 | - "exceed the max count: %d, ret=%d", __SRS_SRS_MAX_CODEC_SAMPLE, ret); | 310 | + "exceed the max count: %d, ret=%d", SRS_SRS_MAX_CODEC_SAMPLE, ret); |
| 311 | return ret; | 311 | return ret; |
| 312 | } | 312 | } |
| 313 | 313 | ||
| @@ -335,7 +335,7 @@ SrsAvcAacCodec::SrsAvcAacCodec() | @@ -335,7 +335,7 @@ SrsAvcAacCodec::SrsAvcAacCodec() | ||
| 335 | avc_profile = SrsAvcProfileReserved; | 335 | avc_profile = SrsAvcProfileReserved; |
| 336 | avc_level = SrsAvcLevelReserved; | 336 | avc_level = SrsAvcLevelReserved; |
| 337 | aac_object = SrsAacObjectTypeReserved; | 337 | aac_object = SrsAacObjectTypeReserved; |
| 338 | - aac_sample_rate = __SRS_AAC_SAMPLE_RATE_UNSET; // sample rate ignored | 338 | + aac_sample_rate = SRS_AAC_SAMPLE_RATE_UNSET; // sample rate ignored |
| 339 | aac_channels = 0; | 339 | aac_channels = 0; |
| 340 | avc_extra_size = 0; | 340 | avc_extra_size = 0; |
| 341 | avc_extra_data = NULL; | 341 | avc_extra_data = NULL; |
| @@ -452,7 +452,7 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | @@ -452,7 +452,7 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | ||
| 452 | } | 452 | } |
| 453 | 453 | ||
| 454 | // reset the sample rate by sequence header | 454 | // reset the sample rate by sequence header |
| 455 | - if (aac_sample_rate != __SRS_AAC_SAMPLE_RATE_UNSET) { | 455 | + if (aac_sample_rate != SRS_AAC_SAMPLE_RATE_UNSET) { |
| 456 | static int aac_sample_rates[] = { | 456 | static int aac_sample_rates[] = { |
| 457 | 96000, 88200, 64000, 48000, | 457 | 96000, 88200, 64000, 48000, |
| 458 | 44100, 32000, 24000, 22050, | 458 | 44100, 32000, 24000, 22050, |
| @@ -234,8 +234,8 @@ extern int flv_sample_rates[]; | @@ -234,8 +234,8 @@ extern int flv_sample_rates[]; | ||
| 234 | */ | 234 | */ |
| 235 | extern int aac_sample_rates[]; | 235 | extern int aac_sample_rates[]; |
| 236 | 236 | ||
| 237 | -#define __SRS_SRS_MAX_CODEC_SAMPLE 128 | ||
| 238 | -#define __SRS_AAC_SAMPLE_RATE_UNSET 15 | 237 | +#define SRS_SRS_MAX_CODEC_SAMPLE 128 |
| 238 | +#define SRS_AAC_SAMPLE_RATE_UNSET 15 | ||
| 239 | 239 | ||
| 240 | // in ms, for HLS aac flush the audio | 240 | // in ms, for HLS aac flush the audio |
| 241 | #define SRS_CONF_DEFAULT_AAC_DELAY 60 | 241 | #define SRS_CONF_DEFAULT_AAC_DELAY 60 |
| @@ -319,7 +319,7 @@ public: | @@ -319,7 +319,7 @@ public: | ||
| 319 | * where avc/h264 video packet may contains multiple buffer. | 319 | * where avc/h264 video packet may contains multiple buffer. |
| 320 | */ | 320 | */ |
| 321 | int nb_sample_units; | 321 | int nb_sample_units; |
| 322 | - SrsCodecSampleUnit sample_units[__SRS_SRS_MAX_CODEC_SAMPLE]; | 322 | + SrsCodecSampleUnit sample_units[SRS_SRS_MAX_CODEC_SAMPLE]; |
| 323 | public: | 323 | public: |
| 324 | /** | 324 | /** |
| 325 | * whether the sample is video sample which demux from video packet. | 325 | * whether the sample is video sample which demux from video packet. |
| @@ -39,7 +39,7 @@ using namespace std; | @@ -39,7 +39,7 @@ using namespace std; | ||
| 39 | 39 | ||
| 40 | #ifdef SRS_AUTO_STREAM_CASTER | 40 | #ifdef SRS_AUTO_STREAM_CASTER |
| 41 | 41 | ||
| 42 | -#define __SRS_RTSP_BUFFER 4096 | 42 | +#define SRS_RTSP_BUFFER 4096 |
| 43 | 43 | ||
| 44 | // get the status text of code. | 44 | // get the status text of code. |
| 45 | string srs_generate_rtsp_status_text(int status) | 45 | string srs_generate_rtsp_status_text(int status) |
| @@ -105,17 +105,17 @@ string srs_generate_rtsp_status_text(int status) | @@ -105,17 +105,17 @@ string srs_generate_rtsp_status_text(int status) | ||
| 105 | std::string srs_generate_rtsp_method_str(SrsRtspMethod method) | 105 | std::string srs_generate_rtsp_method_str(SrsRtspMethod method) |
| 106 | { | 106 | { |
| 107 | switch (method) { | 107 | switch (method) { |
| 108 | - case SrsRtspMethodDescribe: return __SRS_METHOD_DESCRIBE; | ||
| 109 | - case SrsRtspMethodAnnounce: return __SRS_METHOD_ANNOUNCE; | ||
| 110 | - case SrsRtspMethodGetParameter: return __SRS_METHOD_GET_PARAMETER; | ||
| 111 | - case SrsRtspMethodOptions: return __SRS_METHOD_OPTIONS; | ||
| 112 | - case SrsRtspMethodPause: return __SRS_METHOD_PAUSE; | ||
| 113 | - case SrsRtspMethodPlay: return __SRS_METHOD_PLAY; | ||
| 114 | - case SrsRtspMethodRecord: return __SRS_METHOD_RECORD; | ||
| 115 | - case SrsRtspMethodRedirect: return __SRS_METHOD_REDIRECT; | ||
| 116 | - case SrsRtspMethodSetup: return __SRS_METHOD_SETUP; | ||
| 117 | - case SrsRtspMethodSetParameter: return __SRS_METHOD_SET_PARAMETER; | ||
| 118 | - case SrsRtspMethodTeardown: return __SRS_METHOD_TEARDOWN; | 108 | + case SrsRtspMethodDescribe: return SRS_METHOD_DESCRIBE; |
| 109 | + case SrsRtspMethodAnnounce: return SRS_METHOD_ANNOUNCE; | ||
| 110 | + case SrsRtspMethodGetParameter: return SRS_METHOD_GET_PARAMETER; | ||
| 111 | + case SrsRtspMethodOptions: return SRS_METHOD_OPTIONS; | ||
| 112 | + case SrsRtspMethodPause: return SRS_METHOD_PAUSE; | ||
| 113 | + case SrsRtspMethodPlay: return SRS_METHOD_PLAY; | ||
| 114 | + case SrsRtspMethodRecord: return SRS_METHOD_RECORD; | ||
| 115 | + case SrsRtspMethodRedirect: return SRS_METHOD_REDIRECT; | ||
| 116 | + case SrsRtspMethodSetup: return SRS_METHOD_SETUP; | ||
| 117 | + case SrsRtspMethodSetParameter: return SRS_METHOD_SET_PARAMETER; | ||
| 118 | + case SrsRtspMethodTeardown: return SRS_METHOD_TEARDOWN; | ||
| 119 | default: return "Unknown"; | 119 | default: return "Unknown"; |
| 120 | } | 120 | } |
| 121 | } | 121 | } |
| @@ -382,7 +382,7 @@ int SrsRtspSdp::parse(string token) | @@ -382,7 +382,7 @@ int SrsRtspSdp::parse(string token) | ||
| 382 | while (p < end) { | 382 | while (p < end) { |
| 383 | // parse an attribute, split by SP. | 383 | // parse an attribute, split by SP. |
| 384 | char* pa = p; | 384 | char* pa = p; |
| 385 | - for (; p < end && p[0] != __SRS_RTSP_SP; p++) { | 385 | + for (; p < end && p[0] != SRS_RTSP_SP; p++) { |
| 386 | } | 386 | } |
| 387 | std::string attr; | 387 | std::string attr; |
| 388 | if (p > pa) { | 388 | if (p > pa) { |
| @@ -693,22 +693,22 @@ SrsRtspRequest::~SrsRtspRequest() | @@ -693,22 +693,22 @@ SrsRtspRequest::~SrsRtspRequest() | ||
| 693 | 693 | ||
| 694 | bool SrsRtspRequest::is_options() | 694 | bool SrsRtspRequest::is_options() |
| 695 | { | 695 | { |
| 696 | - return method == __SRS_METHOD_OPTIONS; | 696 | + return method == SRS_METHOD_OPTIONS; |
| 697 | } | 697 | } |
| 698 | 698 | ||
| 699 | bool SrsRtspRequest::is_announce() | 699 | bool SrsRtspRequest::is_announce() |
| 700 | { | 700 | { |
| 701 | - return method == __SRS_METHOD_ANNOUNCE; | 701 | + return method == SRS_METHOD_ANNOUNCE; |
| 702 | } | 702 | } |
| 703 | 703 | ||
| 704 | bool SrsRtspRequest::is_setup() | 704 | bool SrsRtspRequest::is_setup() |
| 705 | { | 705 | { |
| 706 | - return method == __SRS_METHOD_SETUP; | 706 | + return method == SRS_METHOD_SETUP; |
| 707 | } | 707 | } |
| 708 | 708 | ||
| 709 | bool SrsRtspRequest::is_record() | 709 | bool SrsRtspRequest::is_record() |
| 710 | { | 710 | { |
| 711 | - return method == __SRS_METHOD_RECORD; | 711 | + return method == SRS_METHOD_RECORD; |
| 712 | } | 712 | } |
| 713 | 713 | ||
| 714 | SrsRtspResponse::SrsRtspResponse(int cseq) | 714 | SrsRtspResponse::SrsRtspResponse(int cseq) |
| @@ -726,21 +726,21 @@ int SrsRtspResponse::encode(stringstream& ss) | @@ -726,21 +726,21 @@ int SrsRtspResponse::encode(stringstream& ss) | ||
| 726 | int ret = ERROR_SUCCESS; | 726 | int ret = ERROR_SUCCESS; |
| 727 | 727 | ||
| 728 | // status line | 728 | // status line |
| 729 | - ss << __SRS_VERSION << __SRS_RTSP_SP | ||
| 730 | - << status << __SRS_RTSP_SP | ||
| 731 | - << srs_generate_rtsp_status_text(status) << __SRS_RTSP_CRLF; | 729 | + ss << SRS_RTSP_VERSION << SRS_RTSP_SP |
| 730 | + << status << SRS_RTSP_SP | ||
| 731 | + << srs_generate_rtsp_status_text(status) << SRS_RTSP_CRLF; | ||
| 732 | 732 | ||
| 733 | // cseq | 733 | // cseq |
| 734 | - ss << __SRS_TOKEN_CSEQ << ":" << __SRS_RTSP_SP << seq << __SRS_RTSP_CRLF; | 734 | + ss << SRS_RTSP_TOKEN_CSEQ << ":" << SRS_RTSP_SP << seq << SRS_RTSP_CRLF; |
| 735 | 735 | ||
| 736 | // others. | 736 | // others. |
| 737 | - ss << "Cache-Control: no-store" << __SRS_RTSP_CRLF | ||
| 738 | - << "Pragma: no-cache" << __SRS_RTSP_CRLF | ||
| 739 | - << "Server: " << RTMP_SIG_SRS_SERVER << __SRS_RTSP_CRLF; | 737 | + ss << "Cache-Control: no-store" << SRS_RTSP_CRLF |
| 738 | + << "Pragma: no-cache" << SRS_RTSP_CRLF | ||
| 739 | + << "Server: " << RTMP_SIG_SRS_SERVER << SRS_RTSP_CRLF; | ||
| 740 | 740 | ||
| 741 | // session if specified. | 741 | // session if specified. |
| 742 | if (!session.empty()) { | 742 | if (!session.empty()) { |
| 743 | - ss << __SRS_TOKEN_SESSION << ":" << session << __SRS_RTSP_CRLF; | 743 | + ss << SRS_RTSP_TOKEN_SESSION << ":" << session << SRS_RTSP_CRLF; |
| 744 | } | 744 | } |
| 745 | 745 | ||
| 746 | if ((ret = encode_header(ss)) != ERROR_SUCCESS) { | 746 | if ((ret = encode_header(ss)) != ERROR_SUCCESS) { |
| @@ -749,7 +749,7 @@ int SrsRtspResponse::encode(stringstream& ss) | @@ -749,7 +749,7 @@ int SrsRtspResponse::encode(stringstream& ss) | ||
| 749 | }; | 749 | }; |
| 750 | 750 | ||
| 751 | // header EOF. | 751 | // header EOF. |
| 752 | - ss << __SRS_RTSP_CRLF; | 752 | + ss << SRS_RTSP_CRLF; |
| 753 | 753 | ||
| 754 | return ret; | 754 | return ret; |
| 755 | } | 755 | } |
| @@ -786,7 +786,7 @@ int SrsRtspOptionsResponse::encode_header(stringstream& ss) | @@ -786,7 +786,7 @@ int SrsRtspOptionsResponse::encode_header(stringstream& ss) | ||
| 786 | SrsRtspMethodTeardown, | 786 | SrsRtspMethodTeardown, |
| 787 | }; | 787 | }; |
| 788 | 788 | ||
| 789 | - ss << __SRS_TOKEN_PUBLIC << ":" << __SRS_RTSP_SP; | 789 | + ss << SRS_RTSP_TOKEN_PUBLIC << ":" << SRS_RTSP_SP; |
| 790 | 790 | ||
| 791 | bool appended = false; | 791 | bool appended = false; |
| 792 | int nb_methods = (int)(sizeof(__methods) / sizeof(SrsRtspMethod)); | 792 | int nb_methods = (int)(sizeof(__methods) / sizeof(SrsRtspMethod)); |
| @@ -802,7 +802,7 @@ int SrsRtspOptionsResponse::encode_header(stringstream& ss) | @@ -802,7 +802,7 @@ int SrsRtspOptionsResponse::encode_header(stringstream& ss) | ||
| 802 | ss << srs_generate_rtsp_method_str(method); | 802 | ss << srs_generate_rtsp_method_str(method); |
| 803 | appended = true; | 803 | appended = true; |
| 804 | } | 804 | } |
| 805 | - ss << __SRS_RTSP_CRLF; | 805 | + ss << SRS_RTSP_CRLF; |
| 806 | 806 | ||
| 807 | return ERROR_SUCCESS; | 807 | return ERROR_SUCCESS; |
| 808 | } | 808 | } |
| @@ -819,11 +819,11 @@ SrsRtspSetupResponse::~SrsRtspSetupResponse() | @@ -819,11 +819,11 @@ SrsRtspSetupResponse::~SrsRtspSetupResponse() | ||
| 819 | 819 | ||
| 820 | int SrsRtspSetupResponse::encode_header(stringstream& ss) | 820 | int SrsRtspSetupResponse::encode_header(stringstream& ss) |
| 821 | { | 821 | { |
| 822 | - ss << __SRS_TOKEN_SESSION << ":" << __SRS_RTSP_SP << session << __SRS_RTSP_CRLF; | ||
| 823 | - ss << __SRS_TOKEN_TRANSPORT << ":" << __SRS_RTSP_SP | 822 | + ss << SRS_RTSP_TOKEN_SESSION << ":" << SRS_RTSP_SP << session << SRS_RTSP_CRLF; |
| 823 | + ss << SRS_RTSP_TOKEN_TRANSPORT << ":" << SRS_RTSP_SP | ||
| 824 | << "RTP/AVP;unicast;client_port=" << client_port_min << "-" << client_port_max << ";" | 824 | << "RTP/AVP;unicast;client_port=" << client_port_min << "-" << client_port_max << ";" |
| 825 | << "server_port=" << local_port_min << "-" << local_port_max | 825 | << "server_port=" << local_port_min << "-" << local_port_max |
| 826 | - << __SRS_RTSP_CRLF; | 826 | + << SRS_RTSP_CRLF; |
| 827 | return ERROR_SUCCESS; | 827 | return ERROR_SUCCESS; |
| 828 | } | 828 | } |
| 829 | 829 | ||
| @@ -918,38 +918,38 @@ int SrsRtspStack::do_recv_message(SrsRtspRequest* req) | @@ -918,38 +918,38 @@ int SrsRtspStack::do_recv_message(SrsRtspRequest* req) | ||
| 918 | } | 918 | } |
| 919 | 919 | ||
| 920 | // parse the header value according by header name | 920 | // parse the header value according by header name |
| 921 | - if (token == __SRS_TOKEN_CSEQ) { | 921 | + if (token == SRS_RTSP_TOKEN_CSEQ) { |
| 922 | std::string seq; | 922 | std::string seq; |
| 923 | if ((ret = recv_token_eof(seq)) != ERROR_SUCCESS) { | 923 | if ((ret = recv_token_eof(seq)) != ERROR_SUCCESS) { |
| 924 | if (!srs_is_client_gracefully_close(ret)) { | 924 | if (!srs_is_client_gracefully_close(ret)) { |
| 925 | - srs_error("rtsp: parse %s failed. ret=%d", __SRS_TOKEN_CSEQ, ret); | 925 | + srs_error("rtsp: parse %s failed. ret=%d", SRS_RTSP_TOKEN_CSEQ, ret); |
| 926 | } | 926 | } |
| 927 | return ret; | 927 | return ret; |
| 928 | } | 928 | } |
| 929 | req->seq = ::atol(seq.c_str()); | 929 | req->seq = ::atol(seq.c_str()); |
| 930 | - } else if (token == __SRS_TOKEN_CONTENT_TYPE) { | 930 | + } else if (token == SRS_RTSP_TOKEN_CONTENT_TYPE) { |
| 931 | std::string ct; | 931 | std::string ct; |
| 932 | if ((ret = recv_token_eof(ct)) != ERROR_SUCCESS) { | 932 | if ((ret = recv_token_eof(ct)) != ERROR_SUCCESS) { |
| 933 | if (!srs_is_client_gracefully_close(ret)) { | 933 | if (!srs_is_client_gracefully_close(ret)) { |
| 934 | - srs_error("rtsp: parse %s failed. ret=%d", __SRS_TOKEN_CONTENT_TYPE, ret); | 934 | + srs_error("rtsp: parse %s failed. ret=%d", SRS_RTSP_TOKEN_CONTENT_TYPE, ret); |
| 935 | } | 935 | } |
| 936 | return ret; | 936 | return ret; |
| 937 | } | 937 | } |
| 938 | req->content_type = ct; | 938 | req->content_type = ct; |
| 939 | - } else if (token == __SRS_TOKEN_CONTENT_LENGTH) { | 939 | + } else if (token == SRS_RTSP_TOKEN_CONTENT_LENGTH) { |
| 940 | std::string cl; | 940 | std::string cl; |
| 941 | if ((ret = recv_token_eof(cl)) != ERROR_SUCCESS) { | 941 | if ((ret = recv_token_eof(cl)) != ERROR_SUCCESS) { |
| 942 | if (!srs_is_client_gracefully_close(ret)) { | 942 | if (!srs_is_client_gracefully_close(ret)) { |
| 943 | - srs_error("rtsp: parse %s failed. ret=%d", __SRS_TOKEN_CONTENT_LENGTH, ret); | 943 | + srs_error("rtsp: parse %s failed. ret=%d", SRS_RTSP_TOKEN_CONTENT_LENGTH, ret); |
| 944 | } | 944 | } |
| 945 | return ret; | 945 | return ret; |
| 946 | } | 946 | } |
| 947 | req->content_length = ::atol(cl.c_str()); | 947 | req->content_length = ::atol(cl.c_str()); |
| 948 | - } else if (token == __SRS_TOKEN_TRANSPORT) { | 948 | + } else if (token == SRS_RTSP_TOKEN_TRANSPORT) { |
| 949 | std::string transport; | 949 | std::string transport; |
| 950 | if ((ret = recv_token_eof(transport)) != ERROR_SUCCESS) { | 950 | if ((ret = recv_token_eof(transport)) != ERROR_SUCCESS) { |
| 951 | if (!srs_is_client_gracefully_close(ret)) { | 951 | if (!srs_is_client_gracefully_close(ret)) { |
| 952 | - srs_error("rtsp: parse %s failed. ret=%d", __SRS_TOKEN_TRANSPORT, ret); | 952 | + srs_error("rtsp: parse %s failed. ret=%d", SRS_RTSP_TOKEN_TRANSPORT, ret); |
| 953 | } | 953 | } |
| 954 | return ret; | 954 | return ret; |
| 955 | } | 955 | } |
| @@ -960,10 +960,10 @@ int SrsRtspStack::do_recv_message(SrsRtspRequest* req) | @@ -960,10 +960,10 @@ int SrsRtspStack::do_recv_message(SrsRtspRequest* req) | ||
| 960 | srs_error("rtsp: parse transport failed, transport=%s. ret=%d", transport.c_str(), ret); | 960 | srs_error("rtsp: parse transport failed, transport=%s. ret=%d", transport.c_str(), ret); |
| 961 | return ret; | 961 | return ret; |
| 962 | } | 962 | } |
| 963 | - } else if (token == __SRS_TOKEN_SESSION) { | 963 | + } else if (token == SRS_RTSP_TOKEN_SESSION) { |
| 964 | if ((ret = recv_token_eof(req->session)) != ERROR_SUCCESS) { | 964 | if ((ret = recv_token_eof(req->session)) != ERROR_SUCCESS) { |
| 965 | if (!srs_is_client_gracefully_close(ret)) { | 965 | if (!srs_is_client_gracefully_close(ret)) { |
| 966 | - srs_error("rtsp: parse %s failed. ret=%d", __SRS_TOKEN_SESSION, ret); | 966 | + srs_error("rtsp: parse %s failed. ret=%d", SRS_RTSP_TOKEN_SESSION, ret); |
| 967 | } | 967 | } |
| 968 | return ret; | 968 | return ret; |
| 969 | } | 969 | } |
| @@ -1117,9 +1117,9 @@ int SrsRtspStack::recv_token(std::string& token, SrsRtspTokenState& state, char | @@ -1117,9 +1117,9 @@ int SrsRtspStack::recv_token(std::string& token, SrsRtspTokenState& state, char | ||
| 1117 | if (append_bytes) { | 1117 | if (append_bytes) { |
| 1118 | append_bytes = false; | 1118 | append_bytes = false; |
| 1119 | 1119 | ||
| 1120 | - char buffer[__SRS_RTSP_BUFFER]; | 1120 | + char buffer[SRS_RTSP_BUFFER]; |
| 1121 | ssize_t nb_read = 0; | 1121 | ssize_t nb_read = 0; |
| 1122 | - if ((ret = skt->read(buffer, __SRS_RTSP_BUFFER, &nb_read)) != ERROR_SUCCESS) { | 1122 | + if ((ret = skt->read(buffer, SRS_RTSP_BUFFER, &nb_read)) != ERROR_SUCCESS) { |
| 1123 | if (!srs_is_client_gracefully_close(ret)) { | 1123 | if (!srs_is_client_gracefully_close(ret)) { |
| 1124 | srs_error("rtsp: io read failed. ret=%d", ret); | 1124 | srs_error("rtsp: io read failed. ret=%d", ret); |
| 1125 | } | 1125 | } |
| @@ -1136,7 +1136,7 @@ int SrsRtspStack::recv_token(std::string& token, SrsRtspTokenState& state, char | @@ -1136,7 +1136,7 @@ int SrsRtspStack::recv_token(std::string& token, SrsRtspTokenState& state, char | ||
| 1136 | char* p = start; | 1136 | char* p = start; |
| 1137 | 1137 | ||
| 1138 | // find util SP/CR/LF, max 2 EOF, to finger out the EOF of message. | 1138 | // find util SP/CR/LF, max 2 EOF, to finger out the EOF of message. |
| 1139 | - for (; p < end && p[0] != normal_ch && p[0] != __SRS_RTSP_CR && p[0] != __SRS_RTSP_LF; p++) { | 1139 | + for (; p < end && p[0] != normal_ch && p[0] != SRS_RTSP_CR && p[0] != SRS_RTSP_LF; p++) { |
| 1140 | } | 1140 | } |
| 1141 | 1141 | ||
| 1142 | // matched. | 1142 | // matched. |
| @@ -1161,7 +1161,7 @@ int SrsRtspStack::recv_token(std::string& token, SrsRtspTokenState& state, char | @@ -1161,7 +1161,7 @@ int SrsRtspStack::recv_token(std::string& token, SrsRtspTokenState& state, char | ||
| 1161 | } | 1161 | } |
| 1162 | 1162 | ||
| 1163 | // ignore SP/CR/LF | 1163 | // ignore SP/CR/LF |
| 1164 | - for (int i = 0; i < 2 && p < end && (p[0] == normal_ch || p[0] == __SRS_RTSP_CR || p[0] == __SRS_RTSP_LF); p++, i++) { | 1164 | + for (int i = 0; i < 2 && p < end && (p[0] == normal_ch || p[0] == SRS_RTSP_CR || p[0] == SRS_RTSP_LF); p++, i++) { |
| 1165 | } | 1165 | } |
| 1166 | 1166 | ||
| 1167 | // consume the token bytes. | 1167 | // consume the token bytes. |
| @@ -44,43 +44,43 @@ class ISrsProtocolReaderWriter; | @@ -44,43 +44,43 @@ class ISrsProtocolReaderWriter; | ||
| 44 | 44 | ||
| 45 | // rtsp specification | 45 | // rtsp specification |
| 46 | // CR = <US-ASCII CR, carriage return (13)> | 46 | // CR = <US-ASCII CR, carriage return (13)> |
| 47 | -#define __SRS_RTSP_CR SRS_CONSTS_CR // 0x0D | 47 | +#define SRS_RTSP_CR SRS_CONSTS_CR // 0x0D |
| 48 | // LF = <US-ASCII LF, linefeed (10)> | 48 | // LF = <US-ASCII LF, linefeed (10)> |
| 49 | -#define __SRS_RTSP_LF SRS_CONSTS_LF // 0x0A | 49 | +#define SRS_RTSP_LF SRS_CONSTS_LF // 0x0A |
| 50 | // SP = <US-ASCII SP, space (32)> | 50 | // SP = <US-ASCII SP, space (32)> |
| 51 | -#define __SRS_RTSP_SP ' ' // 0x20 | 51 | +#define SRS_RTSP_SP ' ' // 0x20 |
| 52 | 52 | ||
| 53 | // 4 RTSP Message, @see rtsp-rfc2326-1998.pdf, page 37 | 53 | // 4 RTSP Message, @see rtsp-rfc2326-1998.pdf, page 37 |
| 54 | // Lines are terminated by CRLF, but | 54 | // Lines are terminated by CRLF, but |
| 55 | // receivers should be prepared to also interpret CR and LF by | 55 | // receivers should be prepared to also interpret CR and LF by |
| 56 | // themselves as line terminators. | 56 | // themselves as line terminators. |
| 57 | -#define __SRS_RTSP_CRLF "\r\n" // 0x0D0A | ||
| 58 | -#define __SRS_RTSP_CRLFCRLF "\r\n\r\n" // 0x0D0A0D0A | 57 | +#define SRS_RTSP_CRLF "\r\n" // 0x0D0A |
| 58 | +#define SRS_RTSP_CRLFCRLF "\r\n\r\n" // 0x0D0A0D0A | ||
| 59 | 59 | ||
| 60 | // RTSP token | 60 | // RTSP token |
| 61 | -#define __SRS_TOKEN_CSEQ "CSeq" | ||
| 62 | -#define __SRS_TOKEN_PUBLIC "Public" | ||
| 63 | -#define __SRS_TOKEN_CONTENT_TYPE "Content-Type" | ||
| 64 | -#define __SRS_TOKEN_CONTENT_LENGTH "Content-Length" | ||
| 65 | -#define __SRS_TOKEN_TRANSPORT "Transport" | ||
| 66 | -#define __SRS_TOKEN_SESSION "Session" | 61 | +#define SRS_RTSP_TOKEN_CSEQ "CSeq" |
| 62 | +#define SRS_RTSP_TOKEN_PUBLIC "Public" | ||
| 63 | +#define SRS_RTSP_TOKEN_CONTENT_TYPE "Content-Type" | ||
| 64 | +#define SRS_RTSP_TOKEN_CONTENT_LENGTH "Content-Length" | ||
| 65 | +#define SRS_RTSP_TOKEN_TRANSPORT "Transport" | ||
| 66 | +#define SRS_RTSP_TOKEN_SESSION "Session" | ||
| 67 | 67 | ||
| 68 | // RTSP methods | 68 | // RTSP methods |
| 69 | -#define __SRS_METHOD_OPTIONS "OPTIONS" | ||
| 70 | -#define __SRS_METHOD_DESCRIBE "DESCRIBE" | ||
| 71 | -#define __SRS_METHOD_ANNOUNCE "ANNOUNCE" | ||
| 72 | -#define __SRS_METHOD_SETUP "SETUP" | ||
| 73 | -#define __SRS_METHOD_PLAY "PLAY" | ||
| 74 | -#define __SRS_METHOD_PAUSE "PAUSE" | ||
| 75 | -#define __SRS_METHOD_TEARDOWN "TEARDOWN" | ||
| 76 | -#define __SRS_METHOD_GET_PARAMETER "GET_PARAMETER" | ||
| 77 | -#define __SRS_METHOD_SET_PARAMETER "SET_PARAMETER" | ||
| 78 | -#define __SRS_METHOD_REDIRECT "REDIRECT" | ||
| 79 | -#define __SRS_METHOD_RECORD "RECORD" | 69 | +#define SRS_METHOD_OPTIONS "OPTIONS" |
| 70 | +#define SRS_METHOD_DESCRIBE "DESCRIBE" | ||
| 71 | +#define SRS_METHOD_ANNOUNCE "ANNOUNCE" | ||
| 72 | +#define SRS_METHOD_SETUP "SETUP" | ||
| 73 | +#define SRS_METHOD_PLAY "PLAY" | ||
| 74 | +#define SRS_METHOD_PAUSE "PAUSE" | ||
| 75 | +#define SRS_METHOD_TEARDOWN "TEARDOWN" | ||
| 76 | +#define SRS_METHOD_GET_PARAMETER "GET_PARAMETER" | ||
| 77 | +#define SRS_METHOD_SET_PARAMETER "SET_PARAMETER" | ||
| 78 | +#define SRS_METHOD_REDIRECT "REDIRECT" | ||
| 79 | +#define SRS_METHOD_RECORD "RECORD" | ||
| 80 | // Embedded (Interleaved) Binary Data | 80 | // Embedded (Interleaved) Binary Data |
| 81 | 81 | ||
| 82 | // RTSP-Version | 82 | // RTSP-Version |
| 83 | -#define __SRS_VERSION "RTSP/1.0" | 83 | +#define SRS_RTSP_VERSION "RTSP/1.0" |
| 84 | 84 | ||
| 85 | /** | 85 | /** |
| 86 | * the rtsp sdp parse state. | 86 | * the rtsp sdp parse state. |
| @@ -565,7 +565,7 @@ public: | @@ -565,7 +565,7 @@ public: | ||
| 565 | * final CRLF sequence. | 565 | * final CRLF sequence. |
| 566 | * Status-Line = RTSP-Version SP Status-Code SP Reason-Phrase CRLF | 566 | * Status-Line = RTSP-Version SP Status-Code SP Reason-Phrase CRLF |
| 567 | */ | 567 | */ |
| 568 | - // @see about the version of rtsp, see __SRS_VERSION | 568 | + // @see about the version of rtsp, see SRS_RTSP_VERSION |
| 569 | // @see about the status of rtsp, see SRS_CONSTS_RTSP_OK | 569 | // @see about the status of rtsp, see SRS_CONSTS_RTSP_OK |
| 570 | int status; | 570 | int status; |
| 571 | /** | 571 | /** |
| @@ -703,11 +703,11 @@ private: | @@ -703,11 +703,11 @@ private: | ||
| 703 | * @param token, output the read token. | 703 | * @param token, output the read token. |
| 704 | * @param state, output the token parse state. | 704 | * @param state, output the token parse state. |
| 705 | * @param normal_ch, the char to indicates the normal token. | 705 | * @param normal_ch, the char to indicates the normal token. |
| 706 | - * the SP use to indicates the normal token, @see __SRS_RTSP_SP | 706 | + * the SP use to indicates the normal token, @see SRS_RTSP_SP |
| 707 | * the 0x00 use to ignore normal token flag. @see recv_token_util_eof | 707 | * the 0x00 use to ignore normal token flag. @see recv_token_util_eof |
| 708 | * @param pconsumed, output the token parsed length. NULL to ignore. | 708 | * @param pconsumed, output the token parsed length. NULL to ignore. |
| 709 | */ | 709 | */ |
| 710 | - virtual int recv_token(std::string& token, SrsRtspTokenState& state, char normal_ch = __SRS_RTSP_SP, int* pconsumed = NULL); | 710 | + virtual int recv_token(std::string& token, SrsRtspTokenState& state, char normal_ch = SRS_RTSP_SP, int* pconsumed = NULL); |
| 711 | }; | 711 | }; |
| 712 | 712 | ||
| 713 | #endif | 713 | #endif |
| @@ -33,11 +33,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -33,11 +33,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 33 | 33 | ||
| 34 | #include <srs_app_log.hpp> | 34 | #include <srs_app_log.hpp> |
| 35 | 35 | ||
| 36 | -#define __UTEST_DEV | ||
| 37 | -#undef __UTEST_DEV | 36 | +#define SRS_UTEST_DEV |
| 37 | +#undef SRS_UTEST_DEV | ||
| 38 | 38 | ||
| 39 | // enable all utest. | 39 | // enable all utest. |
| 40 | -#ifndef __UTEST_DEV | 40 | +#ifndef SRS_UTEST_DEV |
| 41 | #define ENABLE_UTEST_AMF0 | 41 | #define ENABLE_UTEST_AMF0 |
| 42 | #define ENABLE_UTEST_CONFIG | 42 | #define ENABLE_UTEST_CONFIG |
| 43 | #define ENABLE_UTEST_CORE | 43 | #define ENABLE_UTEST_CORE |
| @@ -47,7 +47,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -47,7 +47,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 47 | #endif | 47 | #endif |
| 48 | 48 | ||
| 49 | // disable some for fast dev, compile and startup. | 49 | // disable some for fast dev, compile and startup. |
| 50 | -#ifdef __UTEST_DEV | 50 | +#ifdef SRS_UTEST_DEV |
| 51 | #undef ENABLE_UTEST_AMF0 | 51 | #undef ENABLE_UTEST_AMF0 |
| 52 | #undef ENABLE_UTEST_CONFIG | 52 | #undef ENABLE_UTEST_CONFIG |
| 53 | #undef ENABLE_UTEST_CORE | 53 | #undef ENABLE_UTEST_CORE |
| @@ -56,7 +56,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -56,7 +56,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 56 | #undef ENABLE_UTEST_RELOAD | 56 | #undef ENABLE_UTEST_RELOAD |
| 57 | #endif | 57 | #endif |
| 58 | 58 | ||
| 59 | -#ifdef __UTEST_DEV | 59 | +#ifdef SRS_UTEST_DEV |
| 60 | #define ENABLE_UTEST_RELOAD | 60 | #define ENABLE_UTEST_RELOAD |
| 61 | #endif | 61 | #endif |
| 62 | 62 |
-
请 注册 或 登录 后发表评论