diff --git a/README.md b/README.md
index 62706d78d..511c0f0fd 100755
--- a/README.md
+++ b/README.md
@@ -217,6 +217,7 @@ usr sys idl wai hiq siq| read writ| recv send| in out | int csw
* nginx v1.5.0: 139524 lines
### 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-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.
diff --git a/trunk/src/core/srs_core_bandwidth.cpp b/trunk/src/core/srs_core_bandwidth.cpp
index caca441d0..b5b1f1109 100644
--- a/trunk/src/core/srs_core_bandwidth.cpp
+++ b/trunk/src/core/srs_core_bandwidth.cpp
@@ -170,6 +170,11 @@ int SrsBandwidth::do_bandwidth_check()
int play_kbps = play_bytes * 8 / play_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
SrsBandwidthPacket* pkt = SrsBandwidthPacket::create_finish();
pkt->data->set("code", new SrsAmf0Number(ERROR_SUCCESS));
@@ -193,19 +198,20 @@ int SrsBandwidth::do_bandwidth_check()
SrsCommonMessage* msg = NULL;
SrsBandwidthPacket* pkt = NULL;
if ((ret = srs_rtmp_expect_message(protocol, &msg, &pkt)) != ERROR_SUCCESS) {
- srs_error("expect final message failed. ret=%d", ret);
- return ret;
+ // info level to ignore and return success.
+ srs_info("expect final message failed. ret=%d", ret);
+ return ERROR_SUCCESS;
}
SrsAutoFree(SrsCommonMessage, msg, false);
- srs_info("get final message succes.");
+ srs_info("get final message success.");
if (pkt->is_flash_final()) {
- srs_trace("BW check recv flash final response.");
+ srs_info("BW check recv flash final response.");
break;
}
}
- srs_trace("BW check finished.");
+ srs_info("BW check finished.");
return ret;
}
@@ -230,7 +236,7 @@ int SrsBandwidth::check_play(
srs_error("send bandwidth check start play message failed. ret=%d", ret);
return ret;
}
- srs_trace("BW check begin.");
+ srs_info("BW check begin.");
}
while (true) {
@@ -245,7 +251,7 @@ int SrsBandwidth::check_play(
srs_info("get bandwidth message succes.");
if (pkt->is_starting_play()) {
- srs_trace("BW check recv play begin response.");
+ srs_info("BW check recv play begin response.");
break;
}
}
@@ -293,7 +299,7 @@ int SrsBandwidth::check_play(
}
}
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) {
// 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);
return ret;
}
- srs_trace("BW check stop play bytes.");
+ srs_info("BW check stop play bytes.");
}
while (true) {
@@ -323,7 +329,7 @@ int SrsBandwidth::check_play(
srs_info("get bandwidth message succes.");
if (pkt->is_stopped_play()) {
- srs_trace("BW check recv stop play response.");
+ srs_info("BW check recv stop play response.");
break;
}
}
@@ -351,7 +357,7 @@ int SrsBandwidth::check_publish(
srs_error("send bandwidth check start publish message failed. ret=%d", ret);
return ret;
}
- srs_trace("BW check publish begin.");
+ srs_info("BW check publish begin.");
}
while (true) {
@@ -366,7 +372,7 @@ int SrsBandwidth::check_publish(
srs_info("get bandwidth message succes.");
if (pkt->is_starting_publish()) {
- srs_trace("BW check recv publish begin response.");
+ srs_info("BW check recv publish begin response.");
break;
}
}
@@ -399,7 +405,7 @@ int SrsBandwidth::check_publish(
}
}
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) {
// 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);
return ret;
}
- srs_trace("BW check stop publish bytes.");
+ srs_info("BW check stop publish bytes.");
}
// expect client to stop publish
@@ -435,7 +441,7 @@ int SrsBandwidth::check_publish(
srs_info("get bandwidth message succes.");
if (pkt->is_stopped_publish()) {
- srs_trace("BW check recv stop publish response.");
+ srs_info("BW check recv stop publish response.");
break;
}
}
diff --git a/trunk/src/core/srs_core_bandwidth.hpp b/trunk/src/core/srs_core_bandwidth.hpp
index a170855dd..472459157 100644
--- a/trunk/src/core/srs_core_bandwidth.hpp
+++ b/trunk/src/core/srs_core_bandwidth.hpp
@@ -60,9 +60,12 @@ class SrsRtmp;
* | result(stopped)-----> | onSrsBandCheckStoppedPublishBytes(1)
* | |
* | <--------------report |
+* | final---------------> | finalClientPacket(2)
* | |
-* 1. when flash client, server ignore the publish stopped result.
-* and flash client should close connection when got the report.
+* 1. when flash client, server ignore the publish stopped result,
+* 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
{
diff --git a/trunk/src/core/srs_core_protocol.cpp b/trunk/src/core/srs_core_protocol.cpp
index 6b4475302..2cbe75b5a 100644
--- a/trunk/src/core/srs_core_protocol.cpp
+++ b/trunk/src/core/srs_core_protocol.cpp
@@ -231,6 +231,8 @@ messages.
#define SRS_BW_CHECK_FINISHED "onSrsBandCheckFinished"
// for flash, it will sendout a final call,
// 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"
// client only
@@ -1356,7 +1358,9 @@ int SrsCommonMessage::decode_packet(SrsProtocol* protocol)
|| command == SRS_BW_CHECK_START_PUBLISH
|| command == SRS_BW_CHECK_STOPPED_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.");
packet = new SrsBandwidthPacket();