正在显示
7 个修改的文件
包含
2 行增加
和
452 行删除
| @@ -822,10 +822,6 @@ SrsSource::SrsSource(SrsRequest* req) | @@ -822,10 +822,6 @@ SrsSource::SrsSource(SrsRequest* req) | ||
| 822 | 822 | ||
| 823 | _srs_config->subscribe(this); | 823 | _srs_config->subscribe(this); |
| 824 | atc = _srs_config->get_atc(_req->vhost); | 824 | atc = _srs_config->get_atc(_req->vhost); |
| 825 | - | ||
| 826 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 827 | - chunk_size = 0; | ||
| 828 | -#endif | ||
| 829 | } | 825 | } |
| 830 | 826 | ||
| 831 | SrsSource::~SrsSource() | 827 | SrsSource::~SrsSource() |
| @@ -1052,26 +1048,6 @@ int SrsSource::on_reload_vhost_dvr(string vhost) | @@ -1052,26 +1048,6 @@ int SrsSource::on_reload_vhost_dvr(string vhost) | ||
| 1052 | return ret; | 1048 | return ret; |
| 1053 | } | 1049 | } |
| 1054 | 1050 | ||
| 1055 | -int SrsSource::on_reload_vhost_chunk_size(string vhost) | ||
| 1056 | -{ | ||
| 1057 | - int ret = ERROR_SUCCESS; | ||
| 1058 | - | ||
| 1059 | - if (_req->vhost != vhost) { | ||
| 1060 | - return ret; | ||
| 1061 | - } | ||
| 1062 | - | ||
| 1063 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 1064 | - int size = _srs_config->get_chunk_size(_req->vhost); | ||
| 1065 | - if (chunk_size != size) { | ||
| 1066 | - srs_warn("connected clients will error for mic chunk_size changed %d=>%d", | ||
| 1067 | - chunk_size, size); | ||
| 1068 | - } | ||
| 1069 | - chunk_size = size; | ||
| 1070 | -#endif | ||
| 1071 | - | ||
| 1072 | - return ret; | ||
| 1073 | -} | ||
| 1074 | - | ||
| 1075 | int SrsSource::on_reload_vhost_transcode(string vhost) | 1051 | int SrsSource::on_reload_vhost_transcode(string vhost) |
| 1076 | { | 1052 | { |
| 1077 | int ret = ERROR_SUCCESS; | 1053 | int ret = ERROR_SUCCESS; |
| @@ -1301,14 +1277,6 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata | @@ -1301,14 +1277,6 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata | ||
| 1301 | } | 1277 | } |
| 1302 | srs_verbose("initialize shared ptr metadata success."); | 1278 | srs_verbose("initialize shared ptr metadata success."); |
| 1303 | 1279 | ||
| 1304 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 1305 | - if ((ret = cache_metadata->mic_evaluate(chunk_size)) != ERROR_SUCCESS) { | ||
| 1306 | - srs_error("mic metadata iovs failed, chunk_size=%d. ret=%d", chunk_size, ret); | ||
| 1307 | - return ret; | ||
| 1308 | - } | ||
| 1309 | - srs_info("mic metadata iovs ok, chunk_size=%d", chunk_size); | ||
| 1310 | -#endif | ||
| 1311 | - | ||
| 1312 | // copy to all consumer | 1280 | // copy to all consumer |
| 1313 | if (true) { | 1281 | if (true) { |
| 1314 | std::vector<SrsConsumer*>::iterator it; | 1282 | std::vector<SrsConsumer*>::iterator it; |
| @@ -1350,14 +1318,6 @@ int SrsSource::on_audio(SrsCommonMessage* __audio) | @@ -1350,14 +1318,6 @@ int SrsSource::on_audio(SrsCommonMessage* __audio) | ||
| 1350 | } | 1318 | } |
| 1351 | srs_verbose("initialize shared ptr audio success."); | 1319 | srs_verbose("initialize shared ptr audio success."); |
| 1352 | 1320 | ||
| 1353 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 1354 | - if ((ret = msg.mic_evaluate(chunk_size)) != ERROR_SUCCESS) { | ||
| 1355 | - srs_error("mic audio iovs failed, chunk_size=%d. ret=%d", chunk_size, ret); | ||
| 1356 | - return ret; | ||
| 1357 | - } | ||
| 1358 | - srs_info("mic audio iovs ok, chunk_size=%d", chunk_size); | ||
| 1359 | -#endif | ||
| 1360 | - | ||
| 1361 | #ifdef SRS_AUTO_HLS | 1321 | #ifdef SRS_AUTO_HLS |
| 1362 | if ((ret = hls->on_audio(&msg)) != ERROR_SUCCESS) { | 1322 | if ((ret = hls->on_audio(&msg)) != ERROR_SUCCESS) { |
| 1363 | srs_warn("hls process audio message failed, ignore and disable hls. ret=%d", ret); | 1323 | srs_warn("hls process audio message failed, ignore and disable hls. ret=%d", ret); |
| @@ -1468,14 +1428,6 @@ int SrsSource::on_video(SrsCommonMessage* __video) | @@ -1468,14 +1428,6 @@ int SrsSource::on_video(SrsCommonMessage* __video) | ||
| 1468 | } | 1428 | } |
| 1469 | srs_verbose("initialize shared ptr video success."); | 1429 | srs_verbose("initialize shared ptr video success."); |
| 1470 | 1430 | ||
| 1471 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 1472 | - if ((ret = msg.mic_evaluate(chunk_size)) != ERROR_SUCCESS) { | ||
| 1473 | - srs_error("mic video iovs failed, chunk_size=%d. ret=%d", chunk_size, ret); | ||
| 1474 | - return ret; | ||
| 1475 | - } | ||
| 1476 | - srs_info("mic video iovs ok, chunk_size=%d", chunk_size); | ||
| 1477 | -#endif | ||
| 1478 | - | ||
| 1479 | #ifdef SRS_AUTO_HLS | 1431 | #ifdef SRS_AUTO_HLS |
| 1480 | if ((ret = hls->on_video(&msg)) != ERROR_SUCCESS) { | 1432 | if ((ret = hls->on_video(&msg)) != ERROR_SUCCESS) { |
| 1481 | srs_warn("hls process video message failed, ignore and disable hls. ret=%d", ret); | 1433 | srs_warn("hls process video message failed, ignore and disable hls. ret=%d", ret); |
| @@ -1727,11 +1679,6 @@ int SrsSource::on_publish() | @@ -1727,11 +1679,6 @@ int SrsSource::on_publish() | ||
| 1727 | return ret; | 1679 | return ret; |
| 1728 | } | 1680 | } |
| 1729 | #endif | 1681 | #endif |
| 1730 | - | ||
| 1731 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 1732 | - chunk_size = _srs_config->get_chunk_size(_req->vhost); | ||
| 1733 | - srs_trace("mic use chunk_size=%d to send msgs", chunk_size); | ||
| 1734 | -#endif | ||
| 1735 | 1682 | ||
| 1736 | return ret; | 1683 | return ret; |
| 1737 | } | 1684 | } |
| @@ -403,11 +403,6 @@ private: | @@ -403,11 +403,6 @@ private: | ||
| 403 | std::vector<SrsForwarder*> forwarders; | 403 | std::vector<SrsForwarder*> forwarders; |
| 404 | // for aggregate message | 404 | // for aggregate message |
| 405 | SrsStream* aggregate_stream; | 405 | SrsStream* aggregate_stream; |
| 406 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 407 | - // the chunk size for mic, | ||
| 408 | - // update when publish stream. | ||
| 409 | - int chunk_size; | ||
| 410 | -#endif | ||
| 411 | private: | 406 | private: |
| 412 | /** | 407 | /** |
| 413 | * the sample rate of audio in metadata. | 408 | * the sample rate of audio in metadata. |
| @@ -452,7 +447,6 @@ public: | @@ -452,7 +447,6 @@ public: | ||
| 452 | virtual int on_reload_vhost_forward(std::string vhost); | 447 | virtual int on_reload_vhost_forward(std::string vhost); |
| 453 | virtual int on_reload_vhost_hls(std::string vhost); | 448 | virtual int on_reload_vhost_hls(std::string vhost); |
| 454 | virtual int on_reload_vhost_dvr(std::string vhost); | 449 | virtual int on_reload_vhost_dvr(std::string vhost); |
| 455 | - virtual int on_reload_vhost_chunk_size(std::string vhost); | ||
| 456 | virtual int on_reload_vhost_transcode(std::string vhost); | 450 | virtual int on_reload_vhost_transcode(std::string vhost); |
| 457 | // for the tools callback | 451 | // for the tools callback |
| 458 | public: | 452 | public: |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR 2 | 32 | #define VERSION_MAJOR 2 |
| 33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
| 34 | -#define VERSION_REVISION 67 | 34 | +#define VERSION_REVISION 68 |
| 35 | // server info. | 35 | // server info. |
| 36 | #define RTMP_SIG_SRS_KEY "SRS" | 36 | #define RTMP_SIG_SRS_KEY "SRS" |
| 37 | #define RTMP_SIG_SRS_ROLE "origin/edge server" | 37 | #define RTMP_SIG_SRS_ROLE "origin/edge server" |
| @@ -97,25 +97,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -97,25 +97,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 97 | // the default config of mw. | 97 | // the default config of mw. |
| 98 | #define SRS_PERF_MW_SLEEP 350 | 98 | #define SRS_PERF_MW_SLEEP 350 |
| 99 | /** | 99 | /** |
| 100 | -* use iovs cache in each msg, | ||
| 101 | -* for the shared ptr message, we calc once and used for every copy. | ||
| 102 | -* @see https://github.com/winlinvip/simple-rtmp-server/issues/251 | ||
| 103 | -* @remark if enable this, donot use protocol iovs cache. | ||
| 104 | -* @remark when reload change the chunk size, previous clients error. | ||
| 105 | -*/ | ||
| 106 | -#undef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 107 | -/** | ||
| 108 | * how many msgs can be send entirely. | 100 | * how many msgs can be send entirely. |
| 109 | * for play clients to get msgs then totally send out. | 101 | * for play clients to get msgs then totally send out. |
| 110 | * for the mw sleep set to 1800, the msgs is about 133. | 102 | * for the mw sleep set to 1800, the msgs is about 133. |
| 111 | * @remark, recomment to 128. | 103 | * @remark, recomment to 128. |
| 112 | -* @remark, when mic enabled, use larger iovs cache, to 512. | ||
| 113 | */ | 104 | */ |
| 114 | -#ifndef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 115 | - #define SRS_PERF_MW_MSGS 128 | ||
| 116 | -#else | ||
| 117 | - #define SRS_PERF_MW_MSGS 512 | ||
| 118 | -#endif | 105 | +#define SRS_PERF_MW_MSGS 128 |
| 119 | 106 | ||
| 120 | /** | 107 | /** |
| 121 | * whether set the socket send buffer size. | 108 | * whether set the socket send buffer size. |
| @@ -149,11 +149,6 @@ void show_macro_features() | @@ -149,11 +149,6 @@ void show_macro_features() | ||
| 149 | #endif | 149 | #endif |
| 150 | srs_trace("system default latency in ms: mw(0-%d) + mr(0-%d) + play-queue(0-%d)", | 150 | srs_trace("system default latency in ms: mw(0-%d) + mr(0-%d) + play-queue(0-%d)", |
| 151 | SRS_PERF_MW_SLEEP, possible_mr_latency, SRS_PERF_PLAY_QUEUE*1000); | 151 | SRS_PERF_MW_SLEEP, possible_mr_latency, SRS_PERF_PLAY_QUEUE*1000); |
| 152 | - | ||
| 153 | -#ifndef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 154 | - srs_warn("MIC(message iovs cache) enabled, the connected clients will be" | ||
| 155 | - "disconneted when reload changed the chunk_size."); | ||
| 156 | -#endif | ||
| 157 | } | 152 | } |
| 158 | 153 | ||
| 159 | void check_macro_features() | 154 | void check_macro_features() |
| @@ -387,109 +387,16 @@ SrsSharedPtrMessage::__SrsSharedPtr::__SrsSharedPtr() | @@ -387,109 +387,16 @@ SrsSharedPtrMessage::__SrsSharedPtr::__SrsSharedPtr() | ||
| 387 | payload = NULL; | 387 | payload = NULL; |
| 388 | size = 0; | 388 | size = 0; |
| 389 | shared_count = 0; | 389 | shared_count = 0; |
| 390 | - | ||
| 391 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 392 | - nb_iovs = 0; | ||
| 393 | - iovs = NULL; | ||
| 394 | - chunk_size = 0; | ||
| 395 | -#endif | ||
| 396 | } | 390 | } |
| 397 | 391 | ||
| 398 | SrsSharedPtrMessage::__SrsSharedPtr::~__SrsSharedPtr() | 392 | SrsSharedPtrMessage::__SrsSharedPtr::~__SrsSharedPtr() |
| 399 | { | 393 | { |
| 400 | srs_freep(payload); | 394 | srs_freep(payload); |
| 401 | - | ||
| 402 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 403 | - srs_freep(iovs); | ||
| 404 | -#endif | ||
| 405 | } | 395 | } |
| 406 | 396 | ||
| 407 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 408 | -int SrsSharedPtrMessage::__SrsSharedPtr::mic_evaluate(int chunk_size) | ||
| 409 | -{ | ||
| 410 | - int ret = ERROR_SUCCESS; | ||
| 411 | - | ||
| 412 | - // use the chunk size, shuold not be changed. | ||
| 413 | - this->chunk_size = chunk_size; | ||
| 414 | - | ||
| 415 | - // c0 header | ||
| 416 | - int nbh = srs_chunk_header_c0( | ||
| 417 | - header.perfer_cid, 0, header.payload_length, | ||
| 418 | - header.message_type, 0, | ||
| 419 | - mic_c0, sizeof(mic_c0)); | ||
| 420 | - srs_assert(nbh > 0);; | ||
| 421 | - // c3 header | ||
| 422 | - mic_c3 = 0xC0 | (header.perfer_cid & 0x3F); | ||
| 423 | - | ||
| 424 | - // calc number of iovs | ||
| 425 | - nb_chunks = header.payload_length / chunk_size; | ||
| 426 | - if (header.payload_length % chunk_size) { | ||
| 427 | - nb_chunks++; | ||
| 428 | - } | ||
| 429 | - nb_iovs = 1/*cid*/ + 1/*size*//*type*/+ 1/*chunk*/; | ||
| 430 | - // left chunks, always cid+chunk. | ||
| 431 | - if (nb_chunks > 0) { | ||
| 432 | - nb_iovs += (nb_chunks - 1) * 2; | ||
| 433 | - } | ||
| 434 | - | ||
| 435 | - // create iovs | ||
| 436 | - srs_freep(iovs); | ||
| 437 | - iovs = new iovec[nb_iovs]; | ||
| 438 | - | ||
| 439 | - // for payload chunks. | ||
| 440 | - char* p = payload; | ||
| 441 | - char* end = p + size; | ||
| 442 | - iovec* iov = iovs + 0; | ||
| 443 | - while (p < end) { | ||
| 444 | - // size of payload. | ||
| 445 | - int payload_size = srs_min(chunk_size, end - p); | ||
| 446 | - | ||
| 447 | - // header, c0 or c3 | ||
| 448 | - if (p == payload) { | ||
| 449 | - // c0, cid+size+type | ||
| 450 | - // cid, 1B | ||
| 451 | - iov[0].iov_base = mic_c0; | ||
| 452 | - iov[0].iov_len = 1; | ||
| 453 | - | ||
| 454 | - // size(payload length), 3B | ||
| 455 | - // type(message type), 1B | ||
| 456 | - iov[1].iov_base = mic_c0 + 4; | ||
| 457 | - iov[1].iov_len = 4; | ||
| 458 | - | ||
| 459 | - // chunk | ||
| 460 | - iov[2].iov_base = p; | ||
| 461 | - iov[2].iov_len = payload_size; | ||
| 462 | - | ||
| 463 | - // move to next iovs. | ||
| 464 | - iov += 3; | ||
| 465 | - } else { | ||
| 466 | - // c3 | ||
| 467 | - iov[0].iov_base = &mic_c3; | ||
| 468 | - iov[0].iov_len = 1; | ||
| 469 | - | ||
| 470 | - // chunk | ||
| 471 | - iov[1].iov_base = p; | ||
| 472 | - iov[1].iov_len = payload_size; | ||
| 473 | - | ||
| 474 | - // move to next iovs. | ||
| 475 | - iov += 2; | ||
| 476 | - } | ||
| 477 | - | ||
| 478 | - // to next chunk | ||
| 479 | - p += payload_size; | ||
| 480 | - } | ||
| 481 | - | ||
| 482 | - return ret; | ||
| 483 | -} | ||
| 484 | -#endif | ||
| 485 | - | ||
| 486 | SrsSharedPtrMessage::SrsSharedPtrMessage() | 397 | SrsSharedPtrMessage::SrsSharedPtrMessage() |
| 487 | { | 398 | { |
| 488 | ptr = NULL; | 399 | ptr = NULL; |
| 489 | - | ||
| 490 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 491 | - mic_etime_present = false; | ||
| 492 | -#endif | ||
| 493 | } | 400 | } |
| 494 | 401 | ||
| 495 | SrsSharedPtrMessage::~SrsSharedPtrMessage() | 402 | SrsSharedPtrMessage::~SrsSharedPtrMessage() |
| @@ -592,7 +499,6 @@ bool SrsSharedPtrMessage::is_video() | @@ -592,7 +499,6 @@ bool SrsSharedPtrMessage::is_video() | ||
| 592 | return ptr->header.message_type == RTMP_MSG_VideoMessage; | 499 | return ptr->header.message_type == RTMP_MSG_VideoMessage; |
| 593 | } | 500 | } |
| 594 | 501 | ||
| 595 | -#ifndef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 596 | int SrsSharedPtrMessage::chunk_header(char* cache, int nb_cache, bool c0) | 502 | int SrsSharedPtrMessage::chunk_header(char* cache, int nb_cache, bool c0) |
| 597 | { | 503 | { |
| 598 | if (c0) { | 504 | if (c0) { |
| @@ -606,7 +512,6 @@ int SrsSharedPtrMessage::chunk_header(char* cache, int nb_cache, bool c0) | @@ -606,7 +512,6 @@ int SrsSharedPtrMessage::chunk_header(char* cache, int nb_cache, bool c0) | ||
| 606 | cache, nb_cache); | 512 | cache, nb_cache); |
| 607 | } | 513 | } |
| 608 | } | 514 | } |
| 609 | -#endif | ||
| 610 | 515 | ||
| 611 | SrsSharedPtrMessage* SrsSharedPtrMessage::copy() | 516 | SrsSharedPtrMessage* SrsSharedPtrMessage::copy() |
| 612 | { | 517 | { |
| @@ -625,155 +530,6 @@ SrsSharedPtrMessage* SrsSharedPtrMessage::copy() | @@ -625,155 +530,6 @@ SrsSharedPtrMessage* SrsSharedPtrMessage::copy() | ||
| 625 | return copy; | 530 | return copy; |
| 626 | } | 531 | } |
| 627 | 532 | ||
| 628 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 629 | -int SrsSharedPtrMessage::mic_evaluate(int chunk_size) | ||
| 630 | -{ | ||
| 631 | - int ret = ERROR_SUCCESS; | ||
| 632 | - | ||
| 633 | - // when chunk size changed, error to disconnect the client.. | ||
| 634 | - if (ptr->chunk_size > 0 && chunk_size != ptr->chunk_size) { | ||
| 635 | - ret = ERROR_RTMP_MIC_CHUNKSIZE_CHANGED; | ||
| 636 | - srs_warn("mic chunk size changed %d=>%d, ret=%d", | ||
| 637 | - ptr->chunk_size, chunk_size, ret); | ||
| 638 | - return ret; | ||
| 639 | - } | ||
| 640 | - | ||
| 641 | - // calc the shared ptr iovs at the first time. | ||
| 642 | - if (ptr->chunk_size <= 0) { | ||
| 643 | - if ((ret = ptr->mic_evaluate(chunk_size)) != ERROR_SUCCESS) { | ||
| 644 | - srs_warn("mic evaluate source iovs failed. ret=%d", ret); | ||
| 645 | - return ret; | ||
| 646 | - } | ||
| 647 | - } | ||
| 648 | - | ||
| 649 | - return ret; | ||
| 650 | -} | ||
| 651 | - | ||
| 652 | -int SrsSharedPtrMessage::mic_iovs_dump(iovec* iovs, int max_nb_iovs) | ||
| 653 | -{ | ||
| 654 | - // calc the private iovs | ||
| 655 | - char* pp = NULL; | ||
| 656 | - | ||
| 657 | - // calc number of iovs. | ||
| 658 | - int nb_iovs = 1/*time*/ + 1/*sid*/; | ||
| 659 | - // insert etime before all chunks. | ||
| 660 | - if (mic_etime_present) { | ||
| 661 | - nb_iovs += ptr->nb_chunks; | ||
| 662 | - } | ||
| 663 | - | ||
| 664 | - // not enough, return nagetive to try another loop. | ||
| 665 | - if (max_nb_iovs < nb_iovs + ptr->nb_iovs) { | ||
| 666 | - return -1; | ||
| 667 | - } | ||
| 668 | - | ||
| 669 | - // timestamp for c0/c3 | ||
| 670 | - u_int32_t timestamp = (u_int32_t)this->timestamp; | ||
| 671 | - mic_etime_present = timestamp >= RTMP_EXTENDED_TIMESTAMP; | ||
| 672 | - | ||
| 673 | - // chunk message header, 11 bytes | ||
| 674 | - // timestamp, 3bytes, big-endian | ||
| 675 | - char* p = mic_c0_time; | ||
| 676 | - if (!mic_etime_present) { | ||
| 677 | - pp = (char*)×tamp; | ||
| 678 | - *p++ = pp[2]; | ||
| 679 | - *p++ = pp[1]; | ||
| 680 | - *p++ = pp[0]; | ||
| 681 | - } else { | ||
| 682 | - *p++ = 0xFF; | ||
| 683 | - *p++ = 0xFF; | ||
| 684 | - *p++ = 0xFF; | ||
| 685 | - } | ||
| 686 | - | ||
| 687 | - // stream_id, 4bytes, little-endian | ||
| 688 | - p = mic_c0_sid; | ||
| 689 | - pp = (char*)&stream_id; | ||
| 690 | - *p++ = pp[0]; | ||
| 691 | - *p++ = pp[1]; | ||
| 692 | - *p++ = pp[2]; | ||
| 693 | - *p++ = pp[3]; | ||
| 694 | - | ||
| 695 | - // for c0 | ||
| 696 | - // chunk extended timestamp header, 0 or 4 bytes, big-endian | ||
| 697 | - // | ||
| 698 | - // for c3: | ||
| 699 | - // chunk extended timestamp header, 0 or 4 bytes, big-endian | ||
| 700 | - // 6.1.3. Extended Timestamp | ||
| 701 | - // This field is transmitted only when the normal time stamp in the | ||
| 702 | - // chunk message header is set to 0x00ffffff. If normal time stamp is | ||
| 703 | - // set to any value less than 0x00ffffff, this field MUST NOT be | ||
| 704 | - // present. This field MUST NOT be present if the timestamp field is not | ||
| 705 | - // present. Type 3 chunks MUST NOT have this field. | ||
| 706 | - // adobe changed for Type3 chunk: | ||
| 707 | - // FMLE always sendout the extended-timestamp, | ||
| 708 | - // must send the extended-timestamp to FMS, | ||
| 709 | - // must send the extended-timestamp to flash-player. | ||
| 710 | - // @see: ngx_rtmp_prepare_message | ||
| 711 | - // @see: http://blog.csdn.net/win_lin/article/details/13363699 | ||
| 712 | - // TODO: FIXME: extract to outer. | ||
| 713 | - p = mic_etime; | ||
| 714 | - if (mic_etime_present) { | ||
| 715 | - pp = (char*)×tamp; | ||
| 716 | - *p++ = pp[3]; | ||
| 717 | - *p++ = pp[2]; | ||
| 718 | - *p++ = pp[1]; | ||
| 719 | - *p++ = pp[0]; | ||
| 720 | - } | ||
| 721 | - | ||
| 722 | - // dumps all ovs | ||
| 723 | - iovec* shared = ptr->iovs; | ||
| 724 | - iovec* iov = iovs; | ||
| 725 | - | ||
| 726 | - // dump the c0 chunk | ||
| 727 | - // cid | ||
| 728 | - iov->iov_len = shared->iov_len; | ||
| 729 | - iov->iov_base = shared->iov_base; | ||
| 730 | - iov++; shared++; | ||
| 731 | - // time, 3B | ||
| 732 | - iov->iov_base = mic_c0_time; | ||
| 733 | - iov->iov_len = 3; | ||
| 734 | - iov++; | ||
| 735 | - // size, type | ||
| 736 | - iov->iov_len = shared->iov_len; | ||
| 737 | - iov->iov_base = shared->iov_base; | ||
| 738 | - iov++; shared++; | ||
| 739 | - // sid, 4B | ||
| 740 | - iov->iov_base = mic_c0_sid; | ||
| 741 | - iov->iov_len = 4; | ||
| 742 | - iov++; | ||
| 743 | - // etime, 4B | ||
| 744 | - if (mic_etime_present) { | ||
| 745 | - // etime | ||
| 746 | - iov->iov_base = mic_etime; | ||
| 747 | - iov->iov_len = 4; | ||
| 748 | - iov++; | ||
| 749 | - } | ||
| 750 | - // chunk | ||
| 751 | - iov->iov_len = shared->iov_len; | ||
| 752 | - iov->iov_base = shared->iov_base; | ||
| 753 | - iov++; shared++; | ||
| 754 | - | ||
| 755 | - // dump left c3 chunks | ||
| 756 | - for (int i = 1; i < ptr->nb_chunks; i++) { | ||
| 757 | - // cid | ||
| 758 | - iov->iov_len = shared->iov_len; | ||
| 759 | - iov->iov_base = shared->iov_base; | ||
| 760 | - iov++; shared++; | ||
| 761 | - if (mic_etime_present) { | ||
| 762 | - // etime | ||
| 763 | - iov->iov_base = mic_etime; | ||
| 764 | - iov->iov_len = 4; | ||
| 765 | - iov++; | ||
| 766 | - } | ||
| 767 | - // chunk | ||
| 768 | - iov->iov_len = shared->iov_len; | ||
| 769 | - iov->iov_base = shared->iov_base; | ||
| 770 | - iov++; shared++; | ||
| 771 | - } | ||
| 772 | - | ||
| 773 | - return nb_iovs + ptr->nb_iovs; | ||
| 774 | -} | ||
| 775 | -#endif | ||
| 776 | - | ||
| 777 | SrsProtocol::AckWindowSize::AckWindowSize() | 533 | SrsProtocol::AckWindowSize::AckWindowSize() |
| 778 | { | 534 | { |
| 779 | ack_window_size = 0; | 535 | ack_window_size = 0; |
| @@ -793,10 +549,8 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) | @@ -793,10 +549,8 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) | ||
| 793 | // each chunk consumers atleast 2 iovs | 549 | // each chunk consumers atleast 2 iovs |
| 794 | srs_assert(nb_out_iovs >= 2); | 550 | srs_assert(nb_out_iovs >= 2); |
| 795 | 551 | ||
| 796 | -#ifndef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 797 | warned_c0c3_cache_dry = false; | 552 | warned_c0c3_cache_dry = false; |
| 798 | auto_response_when_recv = true; | 553 | auto_response_when_recv = true; |
| 799 | -#endif | ||
| 800 | 554 | ||
| 801 | cs_cache = NULL; | 555 | cs_cache = NULL; |
| 802 | if (SRS_PERF_CHUNK_STREAM_CACHE > 0) { | 556 | if (SRS_PERF_CHUNK_STREAM_CACHE > 0) { |
| @@ -1004,7 +758,6 @@ int SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msgs) | @@ -1004,7 +758,6 @@ int SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msgs) | ||
| 1004 | { | 758 | { |
| 1005 | int ret = ERROR_SUCCESS; | 759 | int ret = ERROR_SUCCESS; |
| 1006 | 760 | ||
| 1007 | -#ifndef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 1008 | int iov_index = 0; | 761 | int iov_index = 0; |
| 1009 | iovec* iov = out_iovs + iov_index; | 762 | iovec* iov = out_iovs + iov_index; |
| 1010 | 763 | ||
| @@ -1105,51 +858,6 @@ int SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msgs) | @@ -1105,51 +858,6 @@ int SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msgs) | ||
| 1105 | nb_msgs, iov_index, SRS_PERF_MW_MSGS, nb_out_iovs); | 858 | nb_msgs, iov_index, SRS_PERF_MW_MSGS, nb_out_iovs); |
| 1106 | 859 | ||
| 1107 | return do_iovs_send(out_iovs, iov_index); | 860 | return do_iovs_send(out_iovs, iov_index); |
| 1108 | -#else | ||
| 1109 | - // send all iovs for all msgs. | ||
| 1110 | - int msg_sent = 0; | ||
| 1111 | - while (msg_sent < nb_msgs) { | ||
| 1112 | - int iov_index = 0; | ||
| 1113 | - for (int i = msg_sent; i < nb_msgs; i++) { | ||
| 1114 | - SrsSharedPtrMessage* msg = msgs[i]; | ||
| 1115 | - | ||
| 1116 | - // evaluate the first | ||
| 1117 | - if (i == 0 && (ret = msg->mic_evaluate(out_chunk_size)) != ERROR_SUCCESS) { | ||
| 1118 | - return ret; | ||
| 1119 | - } | ||
| 1120 | - | ||
| 1121 | - // dump msg to iovec. | ||
| 1122 | - int ok_iovs = msg->mic_iovs_dump( | ||
| 1123 | - out_iovs + iov_index, nb_out_iovs - iov_index | ||
| 1124 | - ); | ||
| 1125 | - // protocol iovs cache exceed. | ||
| 1126 | - if (ok_iovs <= 0) { | ||
| 1127 | - break; | ||
| 1128 | - } | ||
| 1129 | - | ||
| 1130 | - // ok, dump next. | ||
| 1131 | - msg_sent++; | ||
| 1132 | - iov_index += ok_iovs; | ||
| 1133 | - } | ||
| 1134 | - srs_info("mic nb_iovs=%d, msgs=%d, msg_sent=%d, iovs_sent=%d", | ||
| 1135 | - nb_out_iovs, nb_msgs, msg_sent, iov_index); | ||
| 1136 | - | ||
| 1137 | - // cache not enough. | ||
| 1138 | - if (iov_index <= 0) { | ||
| 1139 | - ret = ERROR_RTMP_MIC_CACHE_OVERFLOW; | ||
| 1140 | - srs_warn("mic iovs overflow, nb_iovs=%d, msgs=%d, msg_sent=%d, iovs_sent=%d, ret=%d", | ||
| 1141 | - nb_out_iovs, nb_msgs, msg_sent, iov_index, ret); | ||
| 1142 | - return ret; | ||
| 1143 | - } | ||
| 1144 | - | ||
| 1145 | - // send out these iovs. | ||
| 1146 | - if ((ret = do_iovs_send(out_iovs, iov_index)) != ERROR_SUCCESS) { | ||
| 1147 | - return ret; | ||
| 1148 | - } | ||
| 1149 | - } | ||
| 1150 | - | ||
| 1151 | - return ret; | ||
| 1152 | -#endif | ||
| 1153 | } | 861 | } |
| 1154 | 862 | ||
| 1155 | int SrsProtocol::do_iovs_send(iovec* iovs, int size) | 863 | int SrsProtocol::do_iovs_send(iovec* iovs, int size) |
| @@ -265,72 +265,10 @@ private: | @@ -265,72 +265,10 @@ private: | ||
| 265 | // the reference count | 265 | // the reference count |
| 266 | int shared_count; | 266 | int shared_count; |
| 267 | public: | 267 | public: |
| 268 | - // the iovs cache in shared ptr message. | ||
| 269 | - // @see https://github.com/winlinvip/simple-rtmp-server/issues/251 | ||
| 270 | - #ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 271 | - /** | ||
| 272 | - * the mic(msg iovs cache). | ||
| 273 | - * why share the cache in msg? | ||
| 274 | - * all msgs of a source are same for: | ||
| 275 | - * 1. cid, all use the same cid, copy from src msg. | ||
| 276 | - * 2. size, all msg size never changed. | ||
| 277 | - * 3. type, type never changed. | ||
| 278 | - * 4. chunk size, all connections in a vhost use the same chunk size. | ||
| 279 | - * the different: | ||
| 280 | - * 1. time and etime, almost different. | ||
| 281 | - * 2. stream id, maybe different, but almost the same. | ||
| 282 | - * @remark, when reload change the chunk size, clients will be disconnected. | ||
| 283 | - */ | ||
| 284 | - // the c0 shared section for all msgs | ||
| 285 | - // 1. cid, 1B, same. | ||
| 286 | - // 2. [*]time, 3B, not same. | ||
| 287 | - // 3. size, 3B, same. | ||
| 288 | - // 4. type, 1B, same. | ||
| 289 | - // 5. [*]stream id, 4B, not same, little-endian. | ||
| 290 | - // 6. [*]etime, 4B, not same. | ||
| 291 | - // the stared field must be calced in each msg. | ||
| 292 | - char mic_c0[16]; | ||
| 293 | - // the c3 headers. | ||
| 294 | - char mic_c3; | ||
| 295 | - // the calced iovs for all msg, | ||
| 296 | - // we assumpt that the chunk size is not changed for a vhost, | ||
| 297 | - // if do changed, the client will got an error msg and disconnect. | ||
| 298 | - iovec* iovs; | ||
| 299 | - int nb_iovs; | ||
| 300 | - // the msgs source chunk size, | ||
| 301 | - // which is evaluated the iovs first time, | ||
| 302 | - // this cannot be changed. | ||
| 303 | - int chunk_size; | ||
| 304 | - // the number of chunks. | ||
| 305 | - int nb_chunks; | ||
| 306 | - #endif | ||
| 307 | - public: | ||
| 308 | __SrsSharedPtr(); | 268 | __SrsSharedPtr(); |
| 309 | virtual ~__SrsSharedPtr(); | 269 | virtual ~__SrsSharedPtr(); |
| 310 | - public: | ||
| 311 | - #ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 312 | - /** | ||
| 313 | - * for iovs msg cache, calc the iovs. | ||
| 314 | - * @param chunk_size use the specified chunk size to evaluate the iovs. | ||
| 315 | - */ | ||
| 316 | - virtual int mic_evaluate(int chunk_size); | ||
| 317 | - #endif | ||
| 318 | }; | 270 | }; |
| 319 | __SrsSharedPtr* ptr; | 271 | __SrsSharedPtr* ptr; |
| 320 | -private: | ||
| 321 | - // msgs level cache. | ||
| 322 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 323 | - // the c0 private section for this | ||
| 324 | - // 1. time, 3B, not same, not used. | ||
| 325 | - // 2. stream id, 4B, almost the same, little-endian. | ||
| 326 | - // 3. etime, 4B, optional, always same for all chunk when present. | ||
| 327 | - // the stared field must be calced in each msg. | ||
| 328 | - char mic_c0_time[3]; | ||
| 329 | - char mic_c0_sid[4]; | ||
| 330 | - char mic_etime[4]; | ||
| 331 | - // whether etime present. | ||
| 332 | - bool mic_etime_present; | ||
| 333 | -#endif | ||
| 334 | public: | 272 | public: |
| 335 | SrsSharedPtrMessage(); | 273 | SrsSharedPtrMessage(); |
| 336 | virtual ~SrsSharedPtrMessage(); | 274 | virtual ~SrsSharedPtrMessage(); |
| @@ -366,32 +304,17 @@ public: | @@ -366,32 +304,17 @@ public: | ||
| 366 | virtual bool is_audio(); | 304 | virtual bool is_audio(); |
| 367 | virtual bool is_video(); | 305 | virtual bool is_video(); |
| 368 | public: | 306 | public: |
| 369 | -#ifndef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 370 | /** | 307 | /** |
| 371 | * generate the chunk header to cache. | 308 | * generate the chunk header to cache. |
| 372 | * @return the size of header. | 309 | * @return the size of header. |
| 373 | */ | 310 | */ |
| 374 | virtual int chunk_header(char* cache, int nb_cache, bool c0); | 311 | virtual int chunk_header(char* cache, int nb_cache, bool c0); |
| 375 | -#endif | ||
| 376 | public: | 312 | public: |
| 377 | /** | 313 | /** |
| 378 | * copy current shared ptr message, use ref-count. | 314 | * copy current shared ptr message, use ref-count. |
| 379 | * @remark, assert object is created. | 315 | * @remark, assert object is created. |
| 380 | */ | 316 | */ |
| 381 | virtual SrsSharedPtrMessage* copy(); | 317 | virtual SrsSharedPtrMessage* copy(); |
| 382 | -public: | ||
| 383 | -#ifdef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 384 | - /** | ||
| 385 | - * for iovs msg cache, calc the iovs. | ||
| 386 | - * @param chunk_size use the specified chunk size to evaluate the iovs. | ||
| 387 | - */ | ||
| 388 | - virtual int mic_evaluate(int chunk_size); | ||
| 389 | - /** | ||
| 390 | - * dump all iovs, the _nb_iovs must equals to mic_iovs_count(). | ||
| 391 | - * @return the dumped count. -1 if not enough iovs. | ||
| 392 | - */ | ||
| 393 | - virtual int mic_iovs_dump(iovec* iovs, int max_nb_iovs); | ||
| 394 | -#endif | ||
| 395 | }; | 318 | }; |
| 396 | 319 | ||
| 397 | /** | 320 | /** |
| @@ -465,9 +388,6 @@ private: | @@ -465,9 +388,6 @@ private: | ||
| 465 | */ | 388 | */ |
| 466 | iovec* out_iovs; | 389 | iovec* out_iovs; |
| 467 | int nb_out_iovs; | 390 | int nb_out_iovs; |
| 468 | - // if use iovs cache in each msg, | ||
| 469 | - // donot use protocol level c0c3 cache. | ||
| 470 | -#ifndef SRS_PERF_MW_MSG_IOVS_CACHE | ||
| 471 | /** | 391 | /** |
| 472 | * output header cache. | 392 | * output header cache. |
| 473 | * used for type0, 11bytes(or 15bytes with extended timestamp) header. | 393 | * used for type0, 11bytes(or 15bytes with extended timestamp) header. |
| @@ -479,7 +399,6 @@ private: | @@ -479,7 +399,6 @@ private: | ||
| 479 | char out_c0c3_caches[SRS_CONSTS_C0C3_HEADERS_MAX]; | 399 | char out_c0c3_caches[SRS_CONSTS_C0C3_HEADERS_MAX]; |
| 480 | // whether warned user to increase the c0c3 header cache. | 400 | // whether warned user to increase the c0c3 header cache. |
| 481 | bool warned_c0c3_cache_dry; | 401 | bool warned_c0c3_cache_dry; |
| 482 | -#endif | ||
| 483 | /** | 402 | /** |
| 484 | * output chunk size, default to 128, set by config. | 403 | * output chunk size, default to 128, set by config. |
| 485 | */ | 404 | */ |
-
请 注册 或 登录 后发表评论