Fix #851, HTTP API support number of video frames for FPS. 2.0.240
正在显示
7 个修改的文件
包含
45 行增加
和
1 行删除
| @@ -337,6 +337,7 @@ Remark: | @@ -337,6 +337,7 @@ Remark: | ||
| 337 | 337 | ||
| 338 | ## History | 338 | ## History |
| 339 | 339 | ||
| 340 | +* v2.0, 2017-04-23, Fix [#851][bug #851], HTTP API support number of video frames for FPS. 2.0.240 | ||
| 340 | * <strong>v2.0, 2017-04-18, [2.0 release1(2.0.239)][r2.0r1] released. 86515 lines.</strong> | 341 | * <strong>v2.0, 2017-04-18, [2.0 release1(2.0.239)][r2.0r1] released. 86515 lines.</strong> |
| 341 | * v2.0, 2017-04-18, Fix [#848][bug #848], crash at HTTP fast buffer grow. 2.0.239 | 342 | * v2.0, 2017-04-18, Fix [#848][bug #848], crash at HTTP fast buffer grow. 2.0.239 |
| 342 | * v2.0, 2017-04-15, Fix [#844][bug #844], support Haivision encoder. 2.0.238 | 343 | * v2.0, 2017-04-15, Fix [#844][bug #844], support Haivision encoder. 2.0.238 |
| @@ -1291,6 +1292,7 @@ Winlin | @@ -1291,6 +1292,7 @@ Winlin | ||
| 1291 | [bug #846]: https://github.com/ossrs/srs/issues/846 | 1292 | [bug #846]: https://github.com/ossrs/srs/issues/846 |
| 1292 | [bug #844]: https://github.com/ossrs/srs/issues/844 | 1293 | [bug #844]: https://github.com/ossrs/srs/issues/844 |
| 1293 | [bug #848]: https://github.com/ossrs/srs/issues/848 | 1294 | [bug #848]: https://github.com/ossrs/srs/issues/848 |
| 1295 | +[bug #851]: https://github.com/ossrs/srs/issues/851 | ||
| 1294 | [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx | 1296 | [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx |
| 1295 | 1297 | ||
| 1296 | [exo #828]: https://github.com/google/ExoPlayer/pull/828 | 1298 | [exo #828]: https://github.com/google/ExoPlayer/pull/828 |
| @@ -257,6 +257,7 @@ SrsPublishRecvThread::SrsPublishRecvThread( | @@ -257,6 +257,7 @@ SrsPublishRecvThread::SrsPublishRecvThread( | ||
| 257 | 257 | ||
| 258 | recv_error_code = ERROR_SUCCESS; | 258 | recv_error_code = ERROR_SUCCESS; |
| 259 | _nb_msgs = 0; | 259 | _nb_msgs = 0; |
| 260 | + video_frames = 0; | ||
| 260 | error = st_cond_new(); | 261 | error = st_cond_new(); |
| 261 | ncid = cid = 0; | 262 | ncid = cid = 0; |
| 262 | 263 | ||
| @@ -298,6 +299,11 @@ int64_t SrsPublishRecvThread::nb_msgs() | @@ -298,6 +299,11 @@ int64_t SrsPublishRecvThread::nb_msgs() | ||
| 298 | return _nb_msgs; | 299 | return _nb_msgs; |
| 299 | } | 300 | } |
| 300 | 301 | ||
| 302 | +uint64_t SrsPublishRecvThread::nb_video_frames() | ||
| 303 | +{ | ||
| 304 | + return video_frames; | ||
| 305 | +} | ||
| 306 | + | ||
| 301 | int SrsPublishRecvThread::error_code() | 307 | int SrsPublishRecvThread::error_code() |
| 302 | { | 308 | { |
| 303 | return recv_error_code; | 309 | return recv_error_code; |
| @@ -378,6 +384,10 @@ int SrsPublishRecvThread::handle(SrsCommonMessage* msg) | @@ -378,6 +384,10 @@ int SrsPublishRecvThread::handle(SrsCommonMessage* msg) | ||
| 378 | 384 | ||
| 379 | _nb_msgs++; | 385 | _nb_msgs++; |
| 380 | 386 | ||
| 387 | + if (msg->header.is_video()) { | ||
| 388 | + video_frames++; | ||
| 389 | + } | ||
| 390 | + | ||
| 381 | // log to show the time of recv thread. | 391 | // log to show the time of recv thread. |
| 382 | srs_verbose("recv thread now=%"PRId64"us, got msg time=%"PRId64"ms, size=%d", | 392 | srs_verbose("recv thread now=%"PRId64"us, got msg time=%"PRId64"ms, size=%d", |
| 383 | srs_update_system_time_ms(), msg->header.timestamp, msg->size); | 393 | srs_update_system_time_ms(), msg->header.timestamp, msg->size); |
| @@ -154,6 +154,8 @@ private: | @@ -154,6 +154,8 @@ private: | ||
| 154 | SrsRequest* req; | 154 | SrsRequest* req; |
| 155 | // the msgs already got. | 155 | // the msgs already got. |
| 156 | int64_t _nb_msgs; | 156 | int64_t _nb_msgs; |
| 157 | + // The video frames we got. | ||
| 158 | + uint64_t video_frames; | ||
| 157 | // for mr(merged read), | 159 | // for mr(merged read), |
| 158 | // @see https://github.com/ossrs/srs/issues/241 | 160 | // @see https://github.com/ossrs/srs/issues/241 |
| 159 | bool mr; | 161 | bool mr; |
| @@ -186,6 +188,7 @@ public: | @@ -186,6 +188,7 @@ public: | ||
| 186 | */ | 188 | */ |
| 187 | virtual int wait(int timeout_ms); | 189 | virtual int wait(int timeout_ms); |
| 188 | virtual int64_t nb_msgs(); | 190 | virtual int64_t nb_msgs(); |
| 191 | + virtual uint64_t nb_video_frames(); | ||
| 189 | virtual int error_code(); | 192 | virtual int error_code(); |
| 190 | virtual void set_cid(int v); | 193 | virtual void set_cid(int v); |
| 191 | virtual int get_cid(); | 194 | virtual int get_cid(); |
| @@ -906,6 +906,7 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) | @@ -906,6 +906,7 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) | ||
| 906 | } | 906 | } |
| 907 | 907 | ||
| 908 | int64_t nb_msgs = 0; | 908 | int64_t nb_msgs = 0; |
| 909 | + uint64_t nb_frames = 0; | ||
| 909 | while (!disposed) { | 910 | while (!disposed) { |
| 910 | pprint->elapse(); | 911 | pprint->elapse(); |
| 911 | 912 | ||
| @@ -942,6 +943,14 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) | @@ -942,6 +943,14 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) | ||
| 942 | } | 943 | } |
| 943 | nb_msgs = trd->nb_msgs(); | 944 | nb_msgs = trd->nb_msgs(); |
| 944 | 945 | ||
| 946 | + // Update the stat for video fps. | ||
| 947 | + // @remark https://github.com/ossrs/srs/issues/851 | ||
| 948 | + SrsStatistic* stat = SrsStatistic::instance(); | ||
| 949 | + if ((ret = stat->on_video_frames(req, (int)(trd->nb_video_frames() - nb_frames))) != ERROR_SUCCESS) { | ||
| 950 | + return ret; | ||
| 951 | + } | ||
| 952 | + nb_frames = trd->nb_video_frames(); | ||
| 953 | + | ||
| 945 | // reportable | 954 | // reportable |
| 946 | if (pprint->can_print()) { | 955 | if (pprint->can_print()) { |
| 947 | kbps->sample(); | 956 | kbps->sample(); |
| @@ -111,6 +111,7 @@ SrsStatisticStream::SrsStatisticStream() | @@ -111,6 +111,7 @@ SrsStatisticStream::SrsStatisticStream() | ||
| 111 | kbps->set_io(NULL, NULL); | 111 | kbps->set_io(NULL, NULL); |
| 112 | 112 | ||
| 113 | nb_clients = 0; | 113 | nb_clients = 0; |
| 114 | + nb_frames = 0; | ||
| 114 | } | 115 | } |
| 115 | 116 | ||
| 116 | SrsStatisticStream::~SrsStatisticStream() | 117 | SrsStatisticStream::~SrsStatisticStream() |
| @@ -129,6 +130,7 @@ int SrsStatisticStream::dumps(stringstream& ss) | @@ -129,6 +130,7 @@ int SrsStatisticStream::dumps(stringstream& ss) | ||
| 129 | << SRS_JFIELD_STR("app", app) << SRS_JFIELD_CONT | 130 | << SRS_JFIELD_STR("app", app) << SRS_JFIELD_CONT |
| 130 | << SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT | 131 | << SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT |
| 131 | << SRS_JFIELD_ORG("clients", nb_clients) << SRS_JFIELD_CONT | 132 | << SRS_JFIELD_ORG("clients", nb_clients) << SRS_JFIELD_CONT |
| 133 | + << SRS_JFIELD_ORG("frames", nb_frames) << SRS_JFIELD_CONT | ||
| 132 | << SRS_JFIELD_ORG("send_bytes", kbps->get_send_bytes()) << SRS_JFIELD_CONT | 134 | << SRS_JFIELD_ORG("send_bytes", kbps->get_send_bytes()) << SRS_JFIELD_CONT |
| 133 | << SRS_JFIELD_ORG("recv_bytes", kbps->get_recv_bytes()) << SRS_JFIELD_CONT | 135 | << SRS_JFIELD_ORG("recv_bytes", kbps->get_recv_bytes()) << SRS_JFIELD_CONT |
| 134 | << SRS_JFIELD_OBJ("kbps") | 136 | << SRS_JFIELD_OBJ("kbps") |
| @@ -327,6 +329,18 @@ int SrsStatistic::on_audio_info(SrsRequest* req, | @@ -327,6 +329,18 @@ int SrsStatistic::on_audio_info(SrsRequest* req, | ||
| 327 | return ret; | 329 | return ret; |
| 328 | } | 330 | } |
| 329 | 331 | ||
| 332 | +int SrsStatistic::on_video_frames(SrsRequest* req, int nb_frames) | ||
| 333 | +{ | ||
| 334 | + int ret = ERROR_SUCCESS; | ||
| 335 | + | ||
| 336 | + SrsStatisticVhost* vhost = create_vhost(req); | ||
| 337 | + SrsStatisticStream* stream = create_stream(vhost, req); | ||
| 338 | + | ||
| 339 | + stream->nb_frames += nb_frames; | ||
| 340 | + | ||
| 341 | + return ret; | ||
| 342 | +} | ||
| 343 | + | ||
| 330 | void SrsStatistic::on_stream_publish(SrsRequest* req, int cid) | 344 | void SrsStatistic::on_stream_publish(SrsRequest* req, int cid) |
| 331 | { | 345 | { |
| 332 | SrsStatisticVhost* vhost = create_vhost(req); | 346 | SrsStatisticVhost* vhost = create_vhost(req); |
| @@ -70,6 +70,7 @@ public: | @@ -70,6 +70,7 @@ public: | ||
| 70 | bool active; | 70 | bool active; |
| 71 | int connection_cid; | 71 | int connection_cid; |
| 72 | int nb_clients; | 72 | int nb_clients; |
| 73 | + uint64_t nb_frames; | ||
| 73 | public: | 74 | public: |
| 74 | /** | 75 | /** |
| 75 | * stream total kbps. | 76 | * stream total kbps. |
| @@ -173,6 +174,11 @@ public: | @@ -173,6 +174,11 @@ public: | ||
| 173 | SrsAacObjectType aac_object | 174 | SrsAacObjectType aac_object |
| 174 | ); | 175 | ); |
| 175 | /** | 176 | /** |
| 177 | + * When got videos, update the frames. | ||
| 178 | + * We only stat the total number of video frames. | ||
| 179 | + */ | ||
| 180 | + virtual int on_video_frames(SrsRequest* req, int nb_frames); | ||
| 181 | + /** | ||
| 176 | * when publish stream. | 182 | * when publish stream. |
| 177 | * @param req the request object of publish connection. | 183 | * @param req the request object of publish connection. |
| 178 | * @param cid the cid of publish connection. | 184 | * @param cid the cid of publish connection. |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR 2 | 32 | #define VERSION_MAJOR 2 |
| 33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
| 34 | -#define VERSION_REVISION 239 | 34 | +#define VERSION_REVISION 240 |
| 35 | 35 | ||
| 36 | // generated by configure, only macros. | 36 | // generated by configure, only macros. |
| 37 | #include <srs_auto_headers.hpp> | 37 | #include <srs_auto_headers.hpp> |
-
请 注册 或 登录 后发表评论