mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Squash: Merge SRS4.0
This commit is contained in:
parent
8aee0169ce
commit
a830289d97
3 changed files with 17 additions and 7 deletions
|
@ -755,8 +755,12 @@ srs_error_t SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa
|
||||||
if (!stream) {
|
if (!stream) {
|
||||||
SrsJsonArray* data = SrsJsonAny::array();
|
SrsJsonArray* data = SrsJsonAny::array();
|
||||||
obj->set("streams", data);
|
obj->set("streams", data);
|
||||||
|
|
||||||
if ((err = stat->dumps_streams(data)) != srs_success) {
|
std::string rstart = r->query_get("start");
|
||||||
|
std::string rcount = r->query_get("count");
|
||||||
|
int start = srs_max(0, atoi(rstart.c_str()));
|
||||||
|
int count = srs_max(10, atoi(rcount.c_str()));
|
||||||
|
if ((err = stat->dumps_streams(data, start, count)) != srs_success) {
|
||||||
int code = srs_error_code(err);
|
int code = srs_error_code(err);
|
||||||
srs_error_reset(err);
|
srs_error_reset(err);
|
||||||
return srs_api_response_code(w, r, code);
|
return srs_api_response_code(w, r, code);
|
||||||
|
|
|
@ -495,12 +495,16 @@ srs_error_t SrsStatistic::dumps_vhosts(SrsJsonArray* arr)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsStatistic::dumps_streams(SrsJsonArray* arr)
|
srs_error_t SrsStatistic::dumps_streams(SrsJsonArray* arr, int start, int count)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
std::map<std::string, SrsStatisticStream*>::iterator it;
|
std::map<std::string, SrsStatisticStream*>::iterator it = streams.begin();
|
||||||
for (it = streams.begin(); it != streams.end(); it++) {
|
for (int i = 0; i < start + count && it != streams.end(); it++, i++) {
|
||||||
|
if (i < start) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
SrsStatisticStream* stream = it->second;
|
SrsStatisticStream* stream = it->second;
|
||||||
|
|
||||||
SrsJsonObject* obj = SrsJsonAny::object();
|
SrsJsonObject* obj = SrsJsonAny::object();
|
||||||
|
|
|
@ -182,7 +182,9 @@ public:
|
||||||
// Dumps the vhosts to amf0 array.
|
// Dumps the vhosts to amf0 array.
|
||||||
virtual srs_error_t dumps_vhosts(SrsJsonArray* arr);
|
virtual srs_error_t dumps_vhosts(SrsJsonArray* arr);
|
||||||
// Dumps the streams to amf0 array.
|
// Dumps the streams to amf0 array.
|
||||||
virtual srs_error_t dumps_streams(SrsJsonArray* arr);
|
// @param start the start index, from 0.
|
||||||
|
// @param count the max count of streams to dump.
|
||||||
|
virtual srs_error_t dumps_streams(SrsJsonArray* arr, int start, int count);
|
||||||
// Dumps the clients to amf0 array
|
// Dumps the clients to amf0 array
|
||||||
// @param start the start index, from 0.
|
// @param start the start index, from 0.
|
||||||
// @param count the max count of clients to dump.
|
// @param count the max count of clients to dump.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue