正在显示
4 个修改的文件
包含
32 行增加
和
18 行删除
| @@ -217,6 +217,7 @@ usr sys idl wai hiq siq| read writ| recv send| in out | int csw | @@ -217,6 +217,7 @@ usr sys idl wai hiq siq| read writ| recv send| in out | int csw | ||
| 217 | * nginx v1.5.0: 139524 lines <br/> | 217 | * nginx v1.5.0: 139524 lines <br/> |
| 218 | 218 | ||
| 219 | ### History | 219 | ### History |
| 220 | +* v0.9, 2013-12-22, merge from wenjie, support banwidth test. | ||
| 220 | * v0.9, 2013-12-22, merge from wenjie: support set chunk size at vhost level | 221 | * v0.9, 2013-12-22, merge from wenjie: support set chunk size at vhost level |
| 221 | * v0.9, 2013-12-21, add [players](http://demo.srs.com/players) for play and publish. | 222 | * v0.9, 2013-12-21, add [players](http://demo.srs.com/players) for play and publish. |
| 222 | * v0.9, 2013-12-15, ensure the HLS(ts) is continous when republish stream. | 223 | * v0.9, 2013-12-15, ensure the HLS(ts) is continous when republish stream. |
| @@ -170,6 +170,11 @@ int SrsBandwidth::do_bandwidth_check() | @@ -170,6 +170,11 @@ int SrsBandwidth::do_bandwidth_check() | ||
| 170 | int play_kbps = play_bytes * 8 / play_actual_duration_ms; | 170 | int play_kbps = play_bytes * 8 / play_actual_duration_ms; |
| 171 | int publish_kbps = publish_bytes * 8 / publish_actual_duration_ms; | 171 | int publish_kbps = publish_bytes * 8 / publish_actual_duration_ms; |
| 172 | 172 | ||
| 173 | + srs_trace("bandwidth check finished. start=%"PRId64"ms, end=%"PRId64"ms, " | ||
| 174 | + "duartion=%dms, play=%dkbps, publish=%dkbps, tcUrl=%s, ret=%#x", | ||
| 175 | + start_time, end_time, (int)(end_time - start_time), play_kbps, publish_kbps, | ||
| 176 | + req->tcUrl.c_str(), ret); | ||
| 177 | + | ||
| 173 | // send finished msg | 178 | // send finished msg |
| 174 | SrsBandwidthPacket* pkt = SrsBandwidthPacket::create_finish(); | 179 | SrsBandwidthPacket* pkt = SrsBandwidthPacket::create_finish(); |
| 175 | pkt->data->set("code", new SrsAmf0Number(ERROR_SUCCESS)); | 180 | pkt->data->set("code", new SrsAmf0Number(ERROR_SUCCESS)); |
| @@ -193,19 +198,20 @@ int SrsBandwidth::do_bandwidth_check() | @@ -193,19 +198,20 @@ int SrsBandwidth::do_bandwidth_check() | ||
| 193 | SrsCommonMessage* msg = NULL; | 198 | SrsCommonMessage* msg = NULL; |
| 194 | SrsBandwidthPacket* pkt = NULL; | 199 | SrsBandwidthPacket* pkt = NULL; |
| 195 | if ((ret = srs_rtmp_expect_message<SrsBandwidthPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) { | 200 | if ((ret = srs_rtmp_expect_message<SrsBandwidthPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) { |
| 196 | - srs_error("expect final message failed. ret=%d", ret); | ||
| 197 | - return ret; | 201 | + // info level to ignore and return success. |
| 202 | + srs_info("expect final message failed. ret=%d", ret); | ||
| 203 | + return ERROR_SUCCESS; | ||
| 198 | } | 204 | } |
| 199 | SrsAutoFree(SrsCommonMessage, msg, false); | 205 | SrsAutoFree(SrsCommonMessage, msg, false); |
| 200 | - srs_info("get final message succes."); | 206 | + srs_info("get final message success."); |
| 201 | 207 | ||
| 202 | if (pkt->is_flash_final()) { | 208 | if (pkt->is_flash_final()) { |
| 203 | - srs_trace("BW check recv flash final response."); | 209 | + srs_info("BW check recv flash final response."); |
| 204 | break; | 210 | break; |
| 205 | } | 211 | } |
| 206 | } | 212 | } |
| 207 | 213 | ||
| 208 | - srs_trace("BW check finished."); | 214 | + srs_info("BW check finished."); |
| 209 | 215 | ||
| 210 | return ret; | 216 | return ret; |
| 211 | } | 217 | } |
| @@ -230,7 +236,7 @@ int SrsBandwidth::check_play( | @@ -230,7 +236,7 @@ int SrsBandwidth::check_play( | ||
| 230 | srs_error("send bandwidth check start play message failed. ret=%d", ret); | 236 | srs_error("send bandwidth check start play message failed. ret=%d", ret); |
| 231 | return ret; | 237 | return ret; |
| 232 | } | 238 | } |
| 233 | - srs_trace("BW check begin."); | 239 | + srs_info("BW check begin."); |
| 234 | } | 240 | } |
| 235 | 241 | ||
| 236 | while (true) { | 242 | while (true) { |
| @@ -245,7 +251,7 @@ int SrsBandwidth::check_play( | @@ -245,7 +251,7 @@ int SrsBandwidth::check_play( | ||
| 245 | srs_info("get bandwidth message succes."); | 251 | srs_info("get bandwidth message succes."); |
| 246 | 252 | ||
| 247 | if (pkt->is_starting_play()) { | 253 | if (pkt->is_starting_play()) { |
| 248 | - srs_trace("BW check recv play begin response."); | 254 | + srs_info("BW check recv play begin response."); |
| 249 | break; | 255 | break; |
| 250 | } | 256 | } |
| 251 | } | 257 | } |
| @@ -293,7 +299,7 @@ int SrsBandwidth::check_play( | @@ -293,7 +299,7 @@ int SrsBandwidth::check_play( | ||
| 293 | } | 299 | } |
| 294 | } | 300 | } |
| 295 | actual_duration_ms = srs_get_system_time_ms() - current_time; | 301 | actual_duration_ms = srs_get_system_time_ms() - current_time; |
| 296 | - srs_trace("BW check send play bytes over."); | 302 | + srs_info("BW check send play bytes over."); |
| 297 | 303 | ||
| 298 | if (true) { | 304 | if (true) { |
| 299 | // notify client to stop play | 305 | // notify client to stop play |
| @@ -308,7 +314,7 @@ int SrsBandwidth::check_play( | @@ -308,7 +314,7 @@ int SrsBandwidth::check_play( | ||
| 308 | srs_error("send bandwidth check stop play message failed. ret=%d", ret); | 314 | srs_error("send bandwidth check stop play message failed. ret=%d", ret); |
| 309 | return ret; | 315 | return ret; |
| 310 | } | 316 | } |
| 311 | - srs_trace("BW check stop play bytes."); | 317 | + srs_info("BW check stop play bytes."); |
| 312 | } | 318 | } |
| 313 | 319 | ||
| 314 | while (true) { | 320 | while (true) { |
| @@ -323,7 +329,7 @@ int SrsBandwidth::check_play( | @@ -323,7 +329,7 @@ int SrsBandwidth::check_play( | ||
| 323 | srs_info("get bandwidth message succes."); | 329 | srs_info("get bandwidth message succes."); |
| 324 | 330 | ||
| 325 | if (pkt->is_stopped_play()) { | 331 | if (pkt->is_stopped_play()) { |
| 326 | - srs_trace("BW check recv stop play response."); | 332 | + srs_info("BW check recv stop play response."); |
| 327 | break; | 333 | break; |
| 328 | } | 334 | } |
| 329 | } | 335 | } |
| @@ -351,7 +357,7 @@ int SrsBandwidth::check_publish( | @@ -351,7 +357,7 @@ int SrsBandwidth::check_publish( | ||
| 351 | srs_error("send bandwidth check start publish message failed. ret=%d", ret); | 357 | srs_error("send bandwidth check start publish message failed. ret=%d", ret); |
| 352 | return ret; | 358 | return ret; |
| 353 | } | 359 | } |
| 354 | - srs_trace("BW check publish begin."); | 360 | + srs_info("BW check publish begin."); |
| 355 | } | 361 | } |
| 356 | 362 | ||
| 357 | while (true) { | 363 | while (true) { |
| @@ -366,7 +372,7 @@ int SrsBandwidth::check_publish( | @@ -366,7 +372,7 @@ int SrsBandwidth::check_publish( | ||
| 366 | srs_info("get bandwidth message succes."); | 372 | srs_info("get bandwidth message succes."); |
| 367 | 373 | ||
| 368 | if (pkt->is_starting_publish()) { | 374 | if (pkt->is_starting_publish()) { |
| 369 | - srs_trace("BW check recv publish begin response."); | 375 | + srs_info("BW check recv publish begin response."); |
| 370 | break; | 376 | break; |
| 371 | } | 377 | } |
| 372 | } | 378 | } |
| @@ -399,7 +405,7 @@ int SrsBandwidth::check_publish( | @@ -399,7 +405,7 @@ int SrsBandwidth::check_publish( | ||
| 399 | } | 405 | } |
| 400 | } | 406 | } |
| 401 | actual_duration_ms = srs_get_system_time_ms() - current_time; | 407 | actual_duration_ms = srs_get_system_time_ms() - current_time; |
| 402 | - srs_trace("BW check recv publish data over."); | 408 | + srs_info("BW check recv publish data over."); |
| 403 | 409 | ||
| 404 | if (true) { | 410 | if (true) { |
| 405 | // notify client to stop publish | 411 | // notify client to stop publish |
| @@ -414,7 +420,7 @@ int SrsBandwidth::check_publish( | @@ -414,7 +420,7 @@ int SrsBandwidth::check_publish( | ||
| 414 | srs_error("send bandwidth check stop publish message failed. ret=%d", ret); | 420 | srs_error("send bandwidth check stop publish message failed. ret=%d", ret); |
| 415 | return ret; | 421 | return ret; |
| 416 | } | 422 | } |
| 417 | - srs_trace("BW check stop publish bytes."); | 423 | + srs_info("BW check stop publish bytes."); |
| 418 | } | 424 | } |
| 419 | 425 | ||
| 420 | // expect client to stop publish | 426 | // expect client to stop publish |
| @@ -435,7 +441,7 @@ int SrsBandwidth::check_publish( | @@ -435,7 +441,7 @@ int SrsBandwidth::check_publish( | ||
| 435 | srs_info("get bandwidth message succes."); | 441 | srs_info("get bandwidth message succes."); |
| 436 | 442 | ||
| 437 | if (pkt->is_stopped_publish()) { | 443 | if (pkt->is_stopped_publish()) { |
| 438 | - srs_trace("BW check recv stop publish response."); | 444 | + srs_info("BW check recv stop publish response."); |
| 439 | break; | 445 | break; |
| 440 | } | 446 | } |
| 441 | } | 447 | } |
| @@ -60,9 +60,12 @@ class SrsRtmp; | @@ -60,9 +60,12 @@ class SrsRtmp; | ||
| 60 | * | result(stopped)-----> | onSrsBandCheckStoppedPublishBytes(1) | 60 | * | result(stopped)-----> | onSrsBandCheckStoppedPublishBytes(1) |
| 61 | * | | | 61 | * | | |
| 62 | * | <--------------report | | 62 | * | <--------------report | |
| 63 | +* | final---------------> | finalClientPacket(2) | ||
| 63 | * | <END> | | 64 | * | <END> | |
| 64 | -* 1. when flash client, server ignore the publish stopped result. | ||
| 65 | -* and flash client should close connection when got the report. | 65 | +* 1. when flash client, server ignore the publish stopped result, |
| 66 | +* and directly send the report to flash client. | ||
| 67 | +* 2. flash client only. when got report, flash client should send out | ||
| 68 | +* a final packet and close the connection immediately. | ||
| 66 | */ | 69 | */ |
| 67 | class SrsBandwidth | 70 | class SrsBandwidth |
| 68 | { | 71 | { |
| @@ -231,6 +231,8 @@ messages. | @@ -231,6 +231,8 @@ messages. | ||
| 231 | #define SRS_BW_CHECK_FINISHED "onSrsBandCheckFinished" | 231 | #define SRS_BW_CHECK_FINISHED "onSrsBandCheckFinished" |
| 232 | // for flash, it will sendout a final call, | 232 | // for flash, it will sendout a final call, |
| 233 | // used to confirm got the report. | 233 | // used to confirm got the report. |
| 234 | +// actually, client send out this packet and close the connection, | ||
| 235 | +// so server may cannot got this packet, ignore is ok. | ||
| 234 | #define SRS_BW_CHECK_FLASH_FINAL "finalClientPacket" | 236 | #define SRS_BW_CHECK_FLASH_FINAL "finalClientPacket" |
| 235 | 237 | ||
| 236 | // client only | 238 | // client only |
| @@ -1356,7 +1358,9 @@ int SrsCommonMessage::decode_packet(SrsProtocol* protocol) | @@ -1356,7 +1358,9 @@ int SrsCommonMessage::decode_packet(SrsProtocol* protocol) | ||
| 1356 | || command == SRS_BW_CHECK_START_PUBLISH | 1358 | || command == SRS_BW_CHECK_START_PUBLISH |
| 1357 | || command == SRS_BW_CHECK_STOPPED_PLAY | 1359 | || command == SRS_BW_CHECK_STOPPED_PLAY |
| 1358 | || command == SRS_BW_CHECK_STOP_PLAY | 1360 | || command == SRS_BW_CHECK_STOP_PLAY |
| 1359 | - || command == SRS_BW_CHECK_STOP_PUBLISH) | 1361 | + || command == SRS_BW_CHECK_STOP_PUBLISH |
| 1362 | + || command == SRS_BW_CHECK_STOPPED_PUBLISH | ||
| 1363 | + || command == SRS_BW_CHECK_FLASH_FINAL) | ||
| 1360 | { | 1364 | { |
| 1361 | srs_info("decode the AMF0/AMF3 band width check message."); | 1365 | srs_info("decode the AMF0/AMF3 band width check message."); |
| 1362 | packet = new SrsBandwidthPacket(); | 1366 | packet = new SrsBandwidthPacket(); |
-
请 注册 或 登录 后发表评论