1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-12 19:31:53 +00:00

Merge SRS2 for #851

This commit is contained in:
winlin 2017-04-23 21:00:06 +08:00
commit c97f2233a2
6 changed files with 44 additions and 0 deletions

View file

@ -215,6 +215,7 @@ Please select your language:
### V2 changes ### V2 changes
* v2.0, 2017-04-23, Fix [#851][bug #851], HTTP API support number of video frames for FPS. 2.0.240
* <strong>v2.0, 2017-04-18, [2.0 release1(2.0.239)][r2.0r1] released. 86515 lines.</strong> * <strong>v2.0, 2017-04-18, [2.0 release1(2.0.239)][r2.0r1] released. 86515 lines.</strong>
* v2.0, 2017-04-18, Fix [#848][bug #848], crash at HTTP fast buffer grow. 2.0.239 * v2.0, 2017-04-18, Fix [#848][bug #848], crash at HTTP fast buffer grow. 2.0.239
* v2.0, 2017-04-15, Fix [#844][bug #844], support Haivision encoder. 2.0.238 * v2.0, 2017-04-15, Fix [#844][bug #844], support Haivision encoder. 2.0.238
@ -1397,6 +1398,7 @@ Winlin
[bug #846]: https://github.com/ossrs/srs/issues/846 [bug #846]: https://github.com/ossrs/srs/issues/846
[bug #844]: https://github.com/ossrs/srs/issues/844 [bug #844]: https://github.com/ossrs/srs/issues/844
[bug #848]: https://github.com/ossrs/srs/issues/848 [bug #848]: https://github.com/ossrs/srs/issues/848
[bug #851]: https://github.com/ossrs/srs/issues/851
[bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx
[bug #735]: https://github.com/ossrs/srs/issues/735 [bug #735]: https://github.com/ossrs/srs/issues/735

View file

@ -261,6 +261,7 @@ SrsPublishRecvThread::SrsPublishRecvThread(SrsRtmpServer* rtmp_sdk, SrsRequest*
recv_error_code = ERROR_SUCCESS; recv_error_code = ERROR_SUCCESS;
_nb_msgs = 0; _nb_msgs = 0;
video_frames = 0;
error = st_cond_new(); error = st_cond_new();
ncid = cid = 0; ncid = cid = 0;
@ -302,6 +303,11 @@ int64_t SrsPublishRecvThread::nb_msgs()
return _nb_msgs; return _nb_msgs;
} }
uint64_t SrsPublishRecvThread::nb_video_frames()
{
return video_frames;
}
int SrsPublishRecvThread::error_code() int SrsPublishRecvThread::error_code()
{ {
return recv_error_code; return recv_error_code;
@ -341,6 +347,10 @@ int SrsPublishRecvThread::consume(SrsCommonMessage* msg)
_nb_msgs++; _nb_msgs++;
if (msg->header.is_video()) {
video_frames++;
}
// log to show the time of recv thread. // log to show the time of recv thread.
srs_verbose("recv thread now=%"PRId64"us, got msg time=%"PRId64"ms, size=%d", srs_verbose("recv thread now=%"PRId64"us, got msg time=%"PRId64"ms, size=%d",
srs_update_system_time_ms(), msg->header.timestamp, msg->size); srs_update_system_time_ms(), msg->header.timestamp, msg->size);

View file

@ -164,6 +164,8 @@ private:
SrsRequest* req; SrsRequest* req;
// the msgs already got. // the msgs already got.
int64_t _nb_msgs; int64_t _nb_msgs;
// The video frames we got.
uint64_t video_frames;
// for mr(merged read), // for mr(merged read),
// @see https://github.com/ossrs/srs/issues/241 // @see https://github.com/ossrs/srs/issues/241
bool mr; bool mr;
@ -192,6 +194,7 @@ public:
*/ */
virtual int wait(uint64_t timeout_ms); virtual int wait(uint64_t timeout_ms);
virtual int64_t nb_msgs(); virtual int64_t nb_msgs();
virtual uint64_t nb_video_frames();
virtual int error_code(); virtual int error_code();
virtual void set_cid(int v); virtual void set_cid(int v);
virtual int get_cid(); virtual int get_cid();

View file

@ -950,6 +950,7 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd)
} }
int64_t nb_msgs = 0; int64_t nb_msgs = 0;
uint64_t nb_frames = 0;
while (!disposed) { while (!disposed) {
pprint->elapse(); pprint->elapse();
@ -986,6 +987,14 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd)
} }
nb_msgs = trd->nb_msgs(); nb_msgs = trd->nb_msgs();
// Update the stat for video fps.
// @remark https://github.com/ossrs/srs/issues/851
SrsStatistic* stat = SrsStatistic::instance();
if ((ret = stat->on_video_frames(req, (int)(trd->nb_video_frames() - nb_frames))) != ERROR_SUCCESS) {
return ret;
}
nb_frames = trd->nb_video_frames();
// reportable // reportable
if (pprint->can_print()) { if (pprint->can_print()) {
kbps->sample(); kbps->sample();

View file

@ -115,6 +115,7 @@ SrsStatisticStream::SrsStatisticStream()
kbps->set_io(NULL, NULL); kbps->set_io(NULL, NULL);
nb_clients = 0; nb_clients = 0;
nb_frames = 0;
} }
SrsStatisticStream::~SrsStatisticStream() SrsStatisticStream::~SrsStatisticStream()
@ -132,6 +133,7 @@ int SrsStatisticStream::dumps(SrsJsonObject* obj)
obj->set("app", SrsJsonAny::str(app.c_str())); obj->set("app", SrsJsonAny::str(app.c_str()));
obj->set("live_ms", SrsJsonAny::integer(srs_get_system_time_ms())); obj->set("live_ms", SrsJsonAny::integer(srs_get_system_time_ms()));
obj->set("clients", SrsJsonAny::integer(nb_clients)); obj->set("clients", SrsJsonAny::integer(nb_clients));
obj->set("frames", SrsJsonAny::integer(nb_frames));
obj->set("send_bytes", SrsJsonAny::integer(kbps->get_send_bytes())); obj->set("send_bytes", SrsJsonAny::integer(kbps->get_send_bytes()));
obj->set("recv_bytes", SrsJsonAny::integer(kbps->get_recv_bytes())); obj->set("recv_bytes", SrsJsonAny::integer(kbps->get_recv_bytes()));
@ -342,6 +344,18 @@ int SrsStatistic::on_audio_info(SrsRequest* req, SrsAudioCodecId acodec, SrsAudi
return ret; return ret;
} }
int SrsStatistic::on_video_frames(SrsRequest* req, int nb_frames)
{
int ret = ERROR_SUCCESS;
SrsStatisticVhost* vhost = create_vhost(req);
SrsStatisticStream* stream = create_stream(vhost, req);
stream->nb_frames += nb_frames;
return ret;
}
void SrsStatistic::on_stream_publish(SrsRequest* req, int cid) void SrsStatistic::on_stream_publish(SrsRequest* req, int cid)
{ {
SrsStatisticVhost* vhost = create_vhost(req); SrsStatisticVhost* vhost = create_vhost(req);

View file

@ -69,6 +69,7 @@ public:
bool active; bool active;
int connection_cid; int connection_cid;
int nb_clients; int nb_clients;
uint64_t nb_frames;
public: public:
/** /**
* stream total kbps. * stream total kbps.
@ -170,6 +171,11 @@ public:
* when got audio info for stream. * when got audio info for stream.
*/ */
virtual int on_audio_info(SrsRequest* req, SrsAudioCodecId acodec, SrsAudioSampleRate asample_rate, SrsAudioChannels asound_type, SrsAacObjectType aac_object); virtual int on_audio_info(SrsRequest* req, SrsAudioCodecId acodec, SrsAudioSampleRate asample_rate, SrsAudioChannels asound_type, SrsAacObjectType aac_object);
/**
* When got videos, update the frames.
* We only stat the total number of video frames.
*/
virtual int on_video_frames(SrsRequest* req, int nb_frames);
/** /**
* when publish stream. * when publish stream.
* @param req the request object of publish connection. * @param req the request object of publish connection.