winlin

add kbps for vhost and stream

@@ -113,11 +113,11 @@ int SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) @@ -113,11 +113,11 @@ int SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
113 << SRS_JFIELD_STR("vhosts", "dumps vhost to json") << SRS_JFIELD_CONT 113 << SRS_JFIELD_STR("vhosts", "dumps vhost to json") << SRS_JFIELD_CONT
114 << SRS_JFIELD_STR("streams", "dumps streams to json") << SRS_JFIELD_CONT 114 << SRS_JFIELD_STR("streams", "dumps streams to json") << SRS_JFIELD_CONT
115 << SRS_JFIELD_STR("clients", "dumps clients to json") << SRS_JFIELD_CONT 115 << SRS_JFIELD_STR("clients", "dumps clients to json") << SRS_JFIELD_CONT
116 - << SRS_JFIELD_ORG("test", SRS_JOBJECT_START) 116 + << SRS_JFIELD_ORG("tests", SRS_JOBJECT_START)
117 << SRS_JFIELD_STR("requests", "show the request info") << SRS_JFIELD_CONT 117 << SRS_JFIELD_STR("requests", "show the request info") << SRS_JFIELD_CONT
118 << SRS_JFIELD_STR("errors", "always return an error 100") << SRS_JFIELD_CONT 118 << SRS_JFIELD_STR("errors", "always return an error 100") << SRS_JFIELD_CONT
119 << SRS_JFIELD_STR("redirects", "always redirect to /api/v1/test/errors") << SRS_JFIELD_CONT 119 << SRS_JFIELD_STR("redirects", "always redirect to /api/v1/test/errors") << SRS_JFIELD_CONT
120 - << SRS_JFIELD_STR(".vhost.", "http vhost for error.srs.com/api/v1/test/errors") 120 + << SRS_JFIELD_STR("[vhost]", "http vhost for http://error.srs.com:1985/api/v1/tests/errors")
121 << SRS_JOBJECT_END 121 << SRS_JOBJECT_END
122 << SRS_JOBJECT_END 122 << SRS_JOBJECT_END
123 << SRS_JOBJECT_END; 123 << SRS_JOBJECT_END;
@@ -811,19 +811,19 @@ int SrsServer::http_handle() @@ -811,19 +811,19 @@ int SrsServer::http_handle()
811 } 811 }
812 812
813 // test the request info. 813 // test the request info.
814 - if ((ret = http_api_mux->handle("/api/v1/test/requests", new SrsGoApiRequests())) != ERROR_SUCCESS) { 814 + if ((ret = http_api_mux->handle("/api/v1/tests/requests", new SrsGoApiRequests())) != ERROR_SUCCESS) {
815 return ret; 815 return ret;
816 } 816 }
817 // test the error code response. 817 // test the error code response.
818 - if ((ret = http_api_mux->handle("/api/v1/test/errors", new SrsGoApiError())) != ERROR_SUCCESS) { 818 + if ((ret = http_api_mux->handle("/api/v1/tests/errors", new SrsGoApiError())) != ERROR_SUCCESS) {
819 return ret; 819 return ret;
820 } 820 }
821 // test the redirect mechenism. 821 // test the redirect mechenism.
822 - if ((ret = http_api_mux->handle("/api/v1/test/redirects", new SrsHttpRedirectHandler("/api/v1/test/errors", SRS_CONSTS_HTTP_MovedPermanently))) != ERROR_SUCCESS) { 822 + if ((ret = http_api_mux->handle("/api/v1/tests/redirects", new SrsHttpRedirectHandler("/api/v1/tests/errors", SRS_CONSTS_HTTP_MovedPermanently))) != ERROR_SUCCESS) {
823 return ret; 823 return ret;
824 } 824 }
825 // test the http vhost. 825 // test the http vhost.
826 - if ((ret = http_api_mux->handle("error.srs.com/api/v1/test/errors", new SrsGoApiError())) != ERROR_SUCCESS) { 826 + if ((ret = http_api_mux->handle("error.srs.com/api/v1/tests/errors", new SrsGoApiError())) != ERROR_SUCCESS) {
827 return ret; 827 return ret;
828 } 828 }
829 829
@@ -71,6 +71,10 @@ int SrsStatisticVhost::dumps(stringstream& ss) @@ -71,6 +71,10 @@ int SrsStatisticVhost::dumps(stringstream& ss)
71 << SRS_JFIELD_ORG("clients", nb_clients) << SRS_JFIELD_CONT 71 << SRS_JFIELD_ORG("clients", nb_clients) << SRS_JFIELD_CONT
72 << SRS_JFIELD_ORG("send_bytes", kbps->get_send_bytes()) << SRS_JFIELD_CONT 72 << SRS_JFIELD_ORG("send_bytes", kbps->get_send_bytes()) << SRS_JFIELD_CONT
73 << SRS_JFIELD_ORG("recv_bytes", kbps->get_recv_bytes()) << SRS_JFIELD_CONT 73 << SRS_JFIELD_ORG("recv_bytes", kbps->get_recv_bytes()) << SRS_JFIELD_CONT
  74 + << SRS_JFIELD_OBJ("kbps")
  75 + << SRS_JFIELD_ORG("r30s", kbps->get_recv_kbps_30s()) << SRS_JFIELD_CONT
  76 + << SRS_JFIELD_ORG("s30s", kbps->get_send_kbps_30s())
  77 + << SRS_JOBJECT_END << SRS_JFIELD_CONT
74 << SRS_JFIELD_NAME("hls") << SRS_JOBJECT_START 78 << SRS_JFIELD_NAME("hls") << SRS_JOBJECT_START
75 << SRS_JFIELD_BOOL("enabled", hls_enabled); 79 << SRS_JFIELD_BOOL("enabled", hls_enabled);
76 if (hls_enabled) { 80 if (hls_enabled) {
@@ -123,6 +127,10 @@ int SrsStatisticStream::dumps(stringstream& ss) @@ -123,6 +127,10 @@ int SrsStatisticStream::dumps(stringstream& ss)
123 << SRS_JFIELD_ORG("clients", nb_clients) << SRS_JFIELD_CONT 127 << SRS_JFIELD_ORG("clients", nb_clients) << SRS_JFIELD_CONT
124 << SRS_JFIELD_ORG("send_bytes", kbps->get_send_bytes()) << SRS_JFIELD_CONT 128 << SRS_JFIELD_ORG("send_bytes", kbps->get_send_bytes()) << SRS_JFIELD_CONT
125 << SRS_JFIELD_ORG("recv_bytes", kbps->get_recv_bytes()) << SRS_JFIELD_CONT 129 << SRS_JFIELD_ORG("recv_bytes", kbps->get_recv_bytes()) << SRS_JFIELD_CONT
  130 + << SRS_JFIELD_OBJ("kbps")
  131 + << SRS_JFIELD_ORG("r30s", kbps->get_recv_kbps_30s()) << SRS_JFIELD_CONT
  132 + << SRS_JFIELD_ORG("s30s", kbps->get_send_kbps_30s())
  133 + << SRS_JOBJECT_END << SRS_JFIELD_CONT
126 << SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT 134 << SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT
127 << SRS_JFIELD_STR("status", status) << SRS_JFIELD_CONT; 135 << SRS_JFIELD_STR("status", status) << SRS_JFIELD_CONT;
128 136
@@ -162,7 +162,7 @@ void show_macro_features() @@ -162,7 +162,7 @@ void show_macro_features()
162 #endif 162 #endif
163 163
164 #ifdef SRS_PERF_TCP_NODELAY 164 #ifdef SRS_PERF_TCP_NODELAY
165 - srs_warn("TCP_NODELAY enabled, hurts performance."); 165 + srs_warn("TCP_NODELAY enabled, may hurts performance.");
166 #else 166 #else
167 srs_trace("TCP_NODELAY disabled."); 167 srs_trace("TCP_NODELAY disabled.");
168 #endif 168 #endif
@@ -276,8 +276,8 @@ int main(int argc, char** argv) @@ -276,8 +276,8 @@ int main(int argc, char** argv)
276 } 276 }
277 277
278 srs_trace("srs(simple-rtmp-server) "RTMP_SIG_SRS_VERSION); 278 srs_trace("srs(simple-rtmp-server) "RTMP_SIG_SRS_VERSION);
279 - srs_trace("license: "RTMP_SIG_SRS_LICENSE);  
280 - srs_trace("primary: "RTMP_SIG_SRS_PRIMARY); 279 + srs_trace("license: "RTMP_SIG_SRS_LICENSE", "RTMP_SIG_SRS_COPYRIGHT);
  280 + srs_trace("primary/master: "RTMP_SIG_SRS_PRIMARY);
281 srs_trace("authors: "RTMP_SIG_SRS_AUTHROS); 281 srs_trace("authors: "RTMP_SIG_SRS_AUTHROS);
282 srs_trace("contributors: "SRS_AUTO_CONSTRIBUTORS); 282 srs_trace("contributors: "SRS_AUTO_CONSTRIBUTORS);
283 srs_trace("uname: "SRS_AUTO_UNAME); 283 srs_trace("uname: "SRS_AUTO_UNAME);
@@ -215,10 +215,11 @@ that is: @@ -215,10 +215,11 @@ that is:
215 //////////////////////////////////////////////////////////////////////// 215 ////////////////////////////////////////////////////////////////////////
216 #define SRS_JOBJECT_START "{" 216 #define SRS_JOBJECT_START "{"
217 #define SRS_JFIELD_NAME(k) "\"" << k << "\":" 217 #define SRS_JFIELD_NAME(k) "\"" << k << "\":"
218 -#define SRS_JFIELD_STR(k, v) "\"" << k << "\":\"" << v << "\""  
219 -#define SRS_JFIELD_ORG(k, v) "\"" << k << "\":" << std::dec << v 218 +#define SRS_JFIELD_OBJ(k) SRS_JFIELD_NAME(k) << SRS_JOBJECT_START
  219 +#define SRS_JFIELD_STR(k, v) SRS_JFIELD_NAME(k) << "\"" << v << "\""
  220 +#define SRS_JFIELD_ORG(k, v) SRS_JFIELD_NAME(k) << std::dec << v
220 #define SRS_JFIELD_BOOL(k, v) SRS_JFIELD_ORG(k, (v? "true":"false")) 221 #define SRS_JFIELD_BOOL(k, v) SRS_JFIELD_ORG(k, (v? "true":"false"))
221 -#define SRS_JFIELD_NULL(k) "\"" << k << "\":null" 222 +#define SRS_JFIELD_NULL(k) SRS_JFIELD_NAME(k) << "null"
222 #define SRS_JFIELD_ERROR(ret) "\"" << "code" << "\":" << ret 223 #define SRS_JFIELD_ERROR(ret) "\"" << "code" << "\":" << ret
223 #define SRS_JFIELD_CONT "," 224 #define SRS_JFIELD_CONT ","
224 #define SRS_JOBJECT_END "}" 225 #define SRS_JOBJECT_END "}"