From 1b1a2a1e638720d4c79432175531bb902e864045 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 28 Aug 2015 18:00:24 +0800 Subject: [PATCH] fix #471, api response the width and height. 3.0.2 --- README.md | 2 ++ trunk/src/app/srs_app_http_api.cpp | 17 +++++++++++++---- trunk/src/app/srs_app_source.cpp | 2 +- trunk/src/app/srs_app_statistic.cpp | 12 ++++++++++-- trunk/src/app/srs_app_statistic.hpp | 6 +++++- trunk/src/core/srs_core.hpp | 2 +- trunk/src/kernel/srs_kernel_error.hpp | 1 + 7 files changed, 33 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ca8c02188..8a2d06f1c 100755 --- a/README.md +++ b/README.md @@ -345,6 +345,7 @@ Remark: ## History +* v3.0, 2015-08-28, fix [#471][bug #471], api response the width and height. 3.0.2 * v3.0, 2015-08-25, fix [#367](https://github.com/simple-rtmp-server/srs/issues/367), support nginx-rtmp exec. 3.0.1 * v2.0, 2015-08-23, [2.0 alpha(2.0.185)](https://github.com/simple-rtmp-server/srs/releases/tag/2.0a0) released. 89022 lines. * v2.0, 2015-08-22, HTTP API support JSONP by specifies the query string callback=xxx. @@ -1001,6 +1002,7 @@ Winlin [bug #133]: https://github.com/simple-rtmp-server/srs/issues/133 [bug #92]: https://github.com/simple-rtmp-server/srs/issues/92 [bug #367]: https://github.com/simple-rtmp-server/srs/issues/367 +[bug #471]: https://github.com/simple-rtmp-server/srs/issues/471 [contact]: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_Contact diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index d3549a646..591e4f9cb 100755 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -695,7 +695,7 @@ int SrsGoApiVhosts::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) SrsStatisticVhost* vhost = NULL; if (vid > 0 && (vhost = stat->find_vhost(vid)) == NULL) { - ret = ERROR_RTMP_STREAM_NOT_FOUND; + ret = ERROR_RTMP_VHOST_NOT_FOUND; srs_error("vhost id=%d not found. ret=%d", vid, ret); return srs_api_response_code(w, r, ret); } @@ -750,7 +750,7 @@ int SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) SrsStatisticStream* stream = NULL; if (sid >= 0 && (stream = stat->find_stream(sid)) == NULL) { ret = ERROR_RTMP_STREAM_NOT_FOUND; - srs_error("stream stream_id=%d not found. ret=%d", sid, ret); + srs_error("stream id=%d not found. ret=%d", sid, ret); return srs_api_response_code(w, r, ret); } @@ -803,8 +803,8 @@ int SrsGoApiClients::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) SrsStatisticClient* client = NULL; if (cid >= 0 && (client = stat->find_client(cid)) == NULL) { - ret = ERROR_RTMP_STREAM_NOT_FOUND; - srs_error("stream client_id=%d not found. ret=%d", cid, ret); + ret = ERROR_RTMP_CLIENT_NOT_FOUND; + srs_error("client id=%d not found. ret=%d", cid, ret); return srs_api_response_code(w, r, ret); } @@ -830,6 +830,15 @@ int SrsGoApiClients::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) return srs_api_response_code(w, r, ret); } } + } else if (r->is_http_delete()) { + if (!client) { + ret = ERROR_RTMP_CLIENT_NOT_FOUND; + srs_error("client id=%d not found. ret=%d", cid, ret); + return srs_api_response_code(w, r, ret); + } + + client->conn->expire(); + srs_warn("kickoff client id=%d", cid); } else { return srs_go_http_error(w, SRS_CONSTS_HTTP_MethodNotAllowed); } diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 42807e5a4..954662e90 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1893,7 +1893,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) // when got video stream info. SrsStatistic* stat = SrsStatistic::instance(); - if ((ret = stat->on_video_info(_req, SrsCodecVideoAVC, codec.avc_profile, codec.avc_level)) != ERROR_SUCCESS) { + if ((ret = stat->on_video_info(_req, SrsCodecVideoAVC, codec.avc_profile, codec.avc_level, codec.width, codec.height)) != ERROR_SUCCESS) { return ret; } diff --git a/trunk/src/app/srs_app_statistic.cpp b/trunk/src/app/srs_app_statistic.cpp index 927717aca..788536b2f 100644 --- a/trunk/src/app/srs_app_statistic.cpp +++ b/trunk/src/app/srs_app_statistic.cpp @@ -108,6 +108,8 @@ SrsStatisticStream::SrsStatisticStream() asample_rate = SrsCodecAudioSampleRateReserved; asound_type = SrsCodecAudioSoundTypeReserved; aac_object = SrsAacObjectTypeReserved; + width = 0; + height = 0; kbps = new SrsKbps(); kbps->set_io(NULL, NULL); @@ -154,6 +156,8 @@ int SrsStatisticStream::dumps(SrsAmf0Object* obj) video->set("codec", SrsAmf0Any::str(srs_codec_video2str(vcodec).c_str())); video->set("profile", SrsAmf0Any::str(srs_codec_avc_profile2str(avc_profile).c_str())); video->set("level", SrsAmf0Any::str(srs_codec_avc_level2str(avc_level).c_str())); + video->set("width", SrsAmf0Any::number(width)); + video->set("height", SrsAmf0Any::number(height)); } if (!has_audio) { @@ -216,7 +220,7 @@ int SrsStatisticClient::dumps(SrsAmf0Object* obj) obj->set("url", SrsAmf0Any::str(req->get_stream_url().c_str())); obj->set("type", SrsAmf0Any::str(srs_client_type_string(type).c_str())); obj->set("publish", SrsAmf0Any::boolean(srs_client_type_is_publish(type))); - obj->set("alive", SrsAmf0Any::number(srs_get_system_time_ms() - create)); + obj->set("alive", SrsAmf0Any::number((srs_get_system_time_ms() - create) / 1000.0)); return ret; } @@ -305,7 +309,8 @@ SrsStatisticClient* SrsStatistic::find_client(int cid) } int SrsStatistic::on_video_info(SrsRequest* req, - SrsCodecVideo vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level + SrsCodecVideo vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level, + int width, int height ) { int ret = ERROR_SUCCESS; @@ -317,6 +322,9 @@ int SrsStatistic::on_video_info(SrsRequest* req, stream->avc_profile = avc_profile; stream->avc_level = avc_level; + stream->width = width; + stream->height = height; + return ret; } diff --git a/trunk/src/app/srs_app_statistic.hpp b/trunk/src/app/srs_app_statistic.hpp index a93492021..330894865 100644 --- a/trunk/src/app/srs_app_statistic.hpp +++ b/trunk/src/app/srs_app_statistic.hpp @@ -84,6 +84,9 @@ public: SrsAvcProfile avc_profile; // level_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45. SrsAvcLevel avc_level; + // the width and height in codec info. + int width; + int height; public: bool has_audio; SrsCodecAudio acodec; @@ -166,7 +169,8 @@ public: * when got video info for stream. */ virtual int on_video_info(SrsRequest* req, - SrsCodecVideo vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level + SrsCodecVideo vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level, + int width, int height ); /** * when got audio info for stream. diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index c9e82f66b..0234eeefb 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 1 +#define VERSION_REVISION 2 // server info. #define RTMP_SIG_SRS_KEY "SRS" diff --git a/trunk/src/kernel/srs_kernel_error.hpp b/trunk/src/kernel/srs_kernel_error.hpp index a52d86e30..b242dd4cc 100755 --- a/trunk/src/kernel/srs_kernel_error.hpp +++ b/trunk/src/kernel/srs_kernel_error.hpp @@ -154,6 +154,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define ERROR_RTP_TYPE97_CORRUPT 2046 #define ERROR_RTSP_AUDIO_CONFIG 2047 #define ERROR_RTMP_STREAM_NOT_FOUND 2048 +#define ERROR_RTMP_CLIENT_NOT_FOUND 2049 // // system control message, // not an error, but special control logic.