Skip to content

Commit

Permalink
fix #471, api response the width and height. 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Aug 28, 2015
1 parent 04bea78 commit 1b1a2a1
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
* <strong>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.</strong>
* v2.0, 2015-08-22, HTTP API support JSONP by specifies the query string callback=xxx.
Expand Down Expand Up @@ -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
Expand Down
17 changes: 13 additions & 4 deletions trunk/src/app/srs_app_http_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 10 additions & 2 deletions trunk/src/app/srs_app_statistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down
6 changes: 5 additions & 1 deletion trunk/src/app/srs_app_statistic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ struct SrsStatisticStream
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;
Expand Down Expand Up @@ -166,7 +169,8 @@ class SrsStatistic
* 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.
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions trunk/src/kernel/srs_kernel_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1b1a2a1

Please sign in to comment.