mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #913, APP support complex error.
This commit is contained in:
parent
6eae93258a
commit
e2c1f58674
13 changed files with 423 additions and 536 deletions
|
@ -58,9 +58,9 @@ SrsStatisticVhost::~SrsStatisticVhost()
|
|||
srs_freep(kbps);
|
||||
}
|
||||
|
||||
int SrsStatisticVhost::dumps(SrsJsonObject* obj)
|
||||
srs_error_t SrsStatisticVhost::dumps(SrsJsonObject* obj)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// dumps the config of vhost.
|
||||
bool hls_enabled = _srs_config->get_hls_enabled(vhost);
|
||||
|
@ -88,7 +88,7 @@ int SrsStatisticVhost::dumps(SrsJsonObject* obj)
|
|||
hls->set("fragment", SrsJsonAny::number(_srs_config->get_hls_fragment(vhost)));
|
||||
}
|
||||
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
SrsStatisticStream::SrsStatisticStream()
|
||||
|
@ -123,9 +123,9 @@ SrsStatisticStream::~SrsStatisticStream()
|
|||
srs_freep(kbps);
|
||||
}
|
||||
|
||||
int SrsStatisticStream::dumps(SrsJsonObject* obj)
|
||||
srs_error_t SrsStatisticStream::dumps(SrsJsonObject* obj)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
obj->set("id", SrsJsonAny::integer(id));
|
||||
obj->set("name", SrsJsonAny::str(stream.c_str()));
|
||||
|
@ -174,7 +174,7 @@ int SrsStatisticStream::dumps(SrsJsonObject* obj)
|
|||
audio->set("profile", SrsJsonAny::str(srs_aac_object2str(aac_object).c_str()));
|
||||
}
|
||||
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
void SrsStatisticStream::publish(int cid)
|
||||
|
@ -208,9 +208,9 @@ SrsStatisticClient::~SrsStatisticClient()
|
|||
{
|
||||
}
|
||||
|
||||
int SrsStatisticClient::dumps(SrsJsonObject* obj)
|
||||
srs_error_t SrsStatisticClient::dumps(SrsJsonObject* obj)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
obj->set("id", SrsJsonAny::integer(id));
|
||||
obj->set("vhost", SrsJsonAny::integer(stream->vhost->id));
|
||||
|
@ -224,7 +224,7 @@ int SrsStatisticClient::dumps(SrsJsonObject* obj)
|
|||
obj->set("publish", SrsJsonAny::boolean(srs_client_type_is_publish(type)));
|
||||
obj->set("alive", SrsJsonAny::number((srs_get_system_time_ms() - create) / 1000.0));
|
||||
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
SrsStatistic* SrsStatistic::_instance = new SrsStatistic();
|
||||
|
@ -310,9 +310,9 @@ SrsStatisticClient* SrsStatistic::find_client(int cid)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int SrsStatistic::on_video_info(SrsRequest* req, SrsVideoCodecId vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level, int width, int height)
|
||||
srs_error_t SrsStatistic::on_video_info(SrsRequest* req, SrsVideoCodecId vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level, int width, int height)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
SrsStatisticVhost* vhost = create_vhost(req);
|
||||
SrsStatisticStream* stream = create_stream(vhost, req);
|
||||
|
@ -325,12 +325,12 @@ int SrsStatistic::on_video_info(SrsRequest* req, SrsVideoCodecId vcodec, SrsAvcP
|
|||
stream->width = width;
|
||||
stream->height = height;
|
||||
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
int SrsStatistic::on_audio_info(SrsRequest* req, SrsAudioCodecId acodec, SrsAudioSampleRate asample_rate, SrsAudioChannels asound_type, SrsAacObjectType aac_object)
|
||||
srs_error_t SrsStatistic::on_audio_info(SrsRequest* req, SrsAudioCodecId acodec, SrsAudioSampleRate asample_rate, SrsAudioChannels asound_type, SrsAacObjectType aac_object)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
SrsStatisticVhost* vhost = create_vhost(req);
|
||||
SrsStatisticStream* stream = create_stream(vhost, req);
|
||||
|
@ -341,19 +341,19 @@ int SrsStatistic::on_audio_info(SrsRequest* req, SrsAudioCodecId acodec, SrsAudi
|
|||
stream->asound_type = asound_type;
|
||||
stream->aac_object = aac_object;
|
||||
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
int SrsStatistic::on_video_frames(SrsRequest* req, int nb_frames)
|
||||
srs_error_t SrsStatistic::on_video_frames(SrsRequest* req, int nb_frames)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
SrsStatisticVhost* vhost = create_vhost(req);
|
||||
SrsStatisticStream* stream = create_stream(vhost, req);
|
||||
|
||||
stream->nb_frames += nb_frames;
|
||||
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
void SrsStatistic::on_stream_publish(SrsRequest* req, int cid)
|
||||
|
@ -387,9 +387,9 @@ void SrsStatistic::on_stream_close(SrsRequest* req)
|
|||
}
|
||||
}
|
||||
|
||||
int SrsStatistic::on_client(int id, SrsRequest* req, SrsConnection* conn, SrsRtmpConnType type)
|
||||
srs_error_t SrsStatistic::on_client(int id, SrsRequest* req, SrsConnection* conn, SrsRtmpConnType type)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
SrsStatisticVhost* vhost = create_vhost(req);
|
||||
SrsStatisticStream* stream = create_stream(vhost, req);
|
||||
|
@ -412,7 +412,7 @@ int SrsStatistic::on_client(int id, SrsRequest* req, SrsConnection* conn, SrsRtm
|
|||
stream->nb_clients++;
|
||||
vhost->nb_clients++;
|
||||
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
void SrsStatistic::on_disconnect(int id)
|
||||
|
@ -481,9 +481,9 @@ int64_t SrsStatistic::server_id()
|
|||
return _server_id;
|
||||
}
|
||||
|
||||
int SrsStatistic::dumps_vhosts(SrsJsonArray* arr)
|
||||
srs_error_t SrsStatistic::dumps_vhosts(SrsJsonArray* arr)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
std::map<int64_t, SrsStatisticVhost*>::iterator it;
|
||||
for (it = vhosts.begin(); it != vhosts.end(); it++) {
|
||||
|
@ -492,17 +492,17 @@ int SrsStatistic::dumps_vhosts(SrsJsonArray* arr)
|
|||
SrsJsonObject* obj = SrsJsonAny::object();
|
||||
arr->append(obj);
|
||||
|
||||
if ((ret = vhost->dumps(obj)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
if ((err = vhost->dumps(obj)) != srs_success) {
|
||||
return srs_error_wrap(err, "dump vhost");
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
int SrsStatistic::dumps_streams(SrsJsonArray* arr)
|
||||
srs_error_t SrsStatistic::dumps_streams(SrsJsonArray* arr)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
std::map<int64_t, SrsStatisticStream*>::iterator it;
|
||||
for (it = streams.begin(); it != streams.end(); it++) {
|
||||
|
@ -511,17 +511,17 @@ int SrsStatistic::dumps_streams(SrsJsonArray* arr)
|
|||
SrsJsonObject* obj = SrsJsonAny::object();
|
||||
arr->append(obj);
|
||||
|
||||
if ((ret = stream->dumps(obj)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
if ((err = stream->dumps(obj)) != srs_success) {
|
||||
return srs_error_wrap(err, "dump stream");
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
int SrsStatistic::dumps_clients(SrsJsonArray* arr, int start, int count)
|
||||
srs_error_t SrsStatistic::dumps_clients(SrsJsonArray* arr, int start, int count)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
std::map<int, SrsStatisticClient*>::iterator it = clients.begin();
|
||||
for (int i = 0; i < start + count && it != clients.end(); it++, i++) {
|
||||
|
@ -534,12 +534,12 @@ int SrsStatistic::dumps_clients(SrsJsonArray* arr, int start, int count)
|
|||
SrsJsonObject* obj = SrsJsonAny::object();
|
||||
arr->append(obj);
|
||||
|
||||
if ((ret = client->dumps(obj)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
if ((err = client->dumps(obj)) != srs_success) {
|
||||
return srs_error_wrap(err, "dump client");
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
SrsStatisticVhost* SrsStatistic::create_vhost(SrsRequest* req)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue