mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine the bandwidth test
This commit is contained in:
parent
9455181790
commit
084ad79534
4 changed files with 32 additions and 18 deletions
|
@ -217,6 +217,7 @@ usr sys idl wai hiq siq| read writ| recv send| in out | int csw
|
||||||
* nginx v1.5.0: 139524 lines <br/>
|
* nginx v1.5.0: 139524 lines <br/>
|
||||||
|
|
||||||
### History
|
### History
|
||||||
|
* v0.9, 2013-12-22, merge from wenjie, support banwidth test.
|
||||||
* v0.9, 2013-12-22, merge from wenjie: support set chunk size at vhost level
|
* v0.9, 2013-12-22, merge from wenjie: support set chunk size at vhost level
|
||||||
* v0.9, 2013-12-21, add [players](http://demo.srs.com/players) for play and publish.
|
* v0.9, 2013-12-21, add [players](http://demo.srs.com/players) for play and publish.
|
||||||
* v0.9, 2013-12-15, ensure the HLS(ts) is continous when republish stream.
|
* v0.9, 2013-12-15, ensure the HLS(ts) is continous when republish stream.
|
||||||
|
|
|
@ -170,6 +170,11 @@ int SrsBandwidth::do_bandwidth_check()
|
||||||
int play_kbps = play_bytes * 8 / play_actual_duration_ms;
|
int play_kbps = play_bytes * 8 / play_actual_duration_ms;
|
||||||
int publish_kbps = publish_bytes * 8 / publish_actual_duration_ms;
|
int publish_kbps = publish_bytes * 8 / publish_actual_duration_ms;
|
||||||
|
|
||||||
|
srs_trace("bandwidth check finished. start=%"PRId64"ms, end=%"PRId64"ms, "
|
||||||
|
"duartion=%dms, play=%dkbps, publish=%dkbps, tcUrl=%s, ret=%#x",
|
||||||
|
start_time, end_time, (int)(end_time - start_time), play_kbps, publish_kbps,
|
||||||
|
req->tcUrl.c_str(), ret);
|
||||||
|
|
||||||
// send finished msg
|
// send finished msg
|
||||||
SrsBandwidthPacket* pkt = SrsBandwidthPacket::create_finish();
|
SrsBandwidthPacket* pkt = SrsBandwidthPacket::create_finish();
|
||||||
pkt->data->set("code", new SrsAmf0Number(ERROR_SUCCESS));
|
pkt->data->set("code", new SrsAmf0Number(ERROR_SUCCESS));
|
||||||
|
@ -193,19 +198,20 @@ int SrsBandwidth::do_bandwidth_check()
|
||||||
SrsCommonMessage* msg = NULL;
|
SrsCommonMessage* msg = NULL;
|
||||||
SrsBandwidthPacket* pkt = NULL;
|
SrsBandwidthPacket* pkt = NULL;
|
||||||
if ((ret = srs_rtmp_expect_message<SrsBandwidthPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) {
|
if ((ret = srs_rtmp_expect_message<SrsBandwidthPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) {
|
||||||
srs_error("expect final message failed. ret=%d", ret);
|
// info level to ignore and return success.
|
||||||
return ret;
|
srs_info("expect final message failed. ret=%d", ret);
|
||||||
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
SrsAutoFree(SrsCommonMessage, msg, false);
|
SrsAutoFree(SrsCommonMessage, msg, false);
|
||||||
srs_info("get final message succes.");
|
srs_info("get final message success.");
|
||||||
|
|
||||||
if (pkt->is_flash_final()) {
|
if (pkt->is_flash_final()) {
|
||||||
srs_trace("BW check recv flash final response.");
|
srs_info("BW check recv flash final response.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_trace("BW check finished.");
|
srs_info("BW check finished.");
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -230,7 +236,7 @@ int SrsBandwidth::check_play(
|
||||||
srs_error("send bandwidth check start play message failed. ret=%d", ret);
|
srs_error("send bandwidth check start play message failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
srs_trace("BW check begin.");
|
srs_info("BW check begin.");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -245,7 +251,7 @@ int SrsBandwidth::check_play(
|
||||||
srs_info("get bandwidth message succes.");
|
srs_info("get bandwidth message succes.");
|
||||||
|
|
||||||
if (pkt->is_starting_play()) {
|
if (pkt->is_starting_play()) {
|
||||||
srs_trace("BW check recv play begin response.");
|
srs_info("BW check recv play begin response.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,7 +299,7 @@ int SrsBandwidth::check_play(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actual_duration_ms = srs_get_system_time_ms() - current_time;
|
actual_duration_ms = srs_get_system_time_ms() - current_time;
|
||||||
srs_trace("BW check send play bytes over.");
|
srs_info("BW check send play bytes over.");
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
// notify client to stop play
|
// notify client to stop play
|
||||||
|
@ -308,7 +314,7 @@ int SrsBandwidth::check_play(
|
||||||
srs_error("send bandwidth check stop play message failed. ret=%d", ret);
|
srs_error("send bandwidth check stop play message failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
srs_trace("BW check stop play bytes.");
|
srs_info("BW check stop play bytes.");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -323,7 +329,7 @@ int SrsBandwidth::check_play(
|
||||||
srs_info("get bandwidth message succes.");
|
srs_info("get bandwidth message succes.");
|
||||||
|
|
||||||
if (pkt->is_stopped_play()) {
|
if (pkt->is_stopped_play()) {
|
||||||
srs_trace("BW check recv stop play response.");
|
srs_info("BW check recv stop play response.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,7 +357,7 @@ int SrsBandwidth::check_publish(
|
||||||
srs_error("send bandwidth check start publish message failed. ret=%d", ret);
|
srs_error("send bandwidth check start publish message failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
srs_trace("BW check publish begin.");
|
srs_info("BW check publish begin.");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -366,7 +372,7 @@ int SrsBandwidth::check_publish(
|
||||||
srs_info("get bandwidth message succes.");
|
srs_info("get bandwidth message succes.");
|
||||||
|
|
||||||
if (pkt->is_starting_publish()) {
|
if (pkt->is_starting_publish()) {
|
||||||
srs_trace("BW check recv publish begin response.");
|
srs_info("BW check recv publish begin response.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,7 +405,7 @@ int SrsBandwidth::check_publish(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actual_duration_ms = srs_get_system_time_ms() - current_time;
|
actual_duration_ms = srs_get_system_time_ms() - current_time;
|
||||||
srs_trace("BW check recv publish data over.");
|
srs_info("BW check recv publish data over.");
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
// notify client to stop publish
|
// notify client to stop publish
|
||||||
|
@ -414,7 +420,7 @@ int SrsBandwidth::check_publish(
|
||||||
srs_error("send bandwidth check stop publish message failed. ret=%d", ret);
|
srs_error("send bandwidth check stop publish message failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
srs_trace("BW check stop publish bytes.");
|
srs_info("BW check stop publish bytes.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// expect client to stop publish
|
// expect client to stop publish
|
||||||
|
@ -435,7 +441,7 @@ int SrsBandwidth::check_publish(
|
||||||
srs_info("get bandwidth message succes.");
|
srs_info("get bandwidth message succes.");
|
||||||
|
|
||||||
if (pkt->is_stopped_publish()) {
|
if (pkt->is_stopped_publish()) {
|
||||||
srs_trace("BW check recv stop publish response.");
|
srs_info("BW check recv stop publish response.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,9 +60,12 @@ class SrsRtmp;
|
||||||
* | result(stopped)-----> | onSrsBandCheckStoppedPublishBytes(1)
|
* | result(stopped)-----> | onSrsBandCheckStoppedPublishBytes(1)
|
||||||
* | |
|
* | |
|
||||||
* | <--------------report |
|
* | <--------------report |
|
||||||
|
* | final---------------> | finalClientPacket(2)
|
||||||
* | <END> |
|
* | <END> |
|
||||||
* 1. when flash client, server ignore the publish stopped result.
|
* 1. when flash client, server ignore the publish stopped result,
|
||||||
* and flash client should close connection when got the report.
|
* and directly send the report to flash client.
|
||||||
|
* 2. flash client only. when got report, flash client should send out
|
||||||
|
* a final packet and close the connection immediately.
|
||||||
*/
|
*/
|
||||||
class SrsBandwidth
|
class SrsBandwidth
|
||||||
{
|
{
|
||||||
|
|
|
@ -231,6 +231,8 @@ messages.
|
||||||
#define SRS_BW_CHECK_FINISHED "onSrsBandCheckFinished"
|
#define SRS_BW_CHECK_FINISHED "onSrsBandCheckFinished"
|
||||||
// for flash, it will sendout a final call,
|
// for flash, it will sendout a final call,
|
||||||
// used to confirm got the report.
|
// used to confirm got the report.
|
||||||
|
// actually, client send out this packet and close the connection,
|
||||||
|
// so server may cannot got this packet, ignore is ok.
|
||||||
#define SRS_BW_CHECK_FLASH_FINAL "finalClientPacket"
|
#define SRS_BW_CHECK_FLASH_FINAL "finalClientPacket"
|
||||||
|
|
||||||
// client only
|
// client only
|
||||||
|
@ -1356,7 +1358,9 @@ int SrsCommonMessage::decode_packet(SrsProtocol* protocol)
|
||||||
|| command == SRS_BW_CHECK_START_PUBLISH
|
|| command == SRS_BW_CHECK_START_PUBLISH
|
||||||
|| command == SRS_BW_CHECK_STOPPED_PLAY
|
|| command == SRS_BW_CHECK_STOPPED_PLAY
|
||||||
|| command == SRS_BW_CHECK_STOP_PLAY
|
|| command == SRS_BW_CHECK_STOP_PLAY
|
||||||
|| command == SRS_BW_CHECK_STOP_PUBLISH)
|
|| command == SRS_BW_CHECK_STOP_PUBLISH
|
||||||
|
|| command == SRS_BW_CHECK_STOPPED_PUBLISH
|
||||||
|
|| command == SRS_BW_CHECK_FLASH_FINAL)
|
||||||
{
|
{
|
||||||
srs_info("decode the AMF0/AMF3 band width check message.");
|
srs_info("decode the AMF0/AMF3 band width check message.");
|
||||||
packet = new SrsBandwidthPacket();
|
packet = new SrsBandwidthPacket();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue