正在显示
13 个修改的文件
包含
43 行增加
和
120 行删除
| @@ -474,7 +474,7 @@ int SrsEdgeForwarder::cycle() | @@ -474,7 +474,7 @@ int SrsEdgeForwarder::cycle() | ||
| 474 | 474 | ||
| 475 | SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_EDGE); | 475 | SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_EDGE); |
| 476 | 476 | ||
| 477 | - SrsSharedPtrMessageArray msgs(SYS_MAX_EDGE_SEND_MSGS); | 477 | + SrsMessageArray msgs(SYS_MAX_EDGE_SEND_MSGS); |
| 478 | 478 | ||
| 479 | while (pthread->can_loop()) { | 479 | while (pthread->can_loop()) { |
| 480 | if (send_error_code != ERROR_SUCCESS) { | 480 | if (send_error_code != ERROR_SUCCESS) { |
| @@ -526,7 +526,7 @@ int SrsEdgeForwarder::cycle() | @@ -526,7 +526,7 @@ int SrsEdgeForwarder::cycle() | ||
| 526 | // @remark, becareful, all msgs must be free explicitly, | 526 | // @remark, becareful, all msgs must be free explicitly, |
| 527 | // free by send_and_free_message or srs_freep. | 527 | // free by send_and_free_message or srs_freep. |
| 528 | for (int i = 0; i < count; i++) { | 528 | for (int i = 0; i < count; i++) { |
| 529 | - SrsSharedPtrMessage* msg = msgs.msgs[i]; | 529 | + SrsMessage* msg = msgs.msgs[i]; |
| 530 | 530 | ||
| 531 | srs_assert(msg); | 531 | srs_assert(msg); |
| 532 | msgs.msgs[i] = NULL; | 532 | msgs.msgs[i] = NULL; |
| @@ -381,7 +381,7 @@ int SrsForwarder::forward() | @@ -381,7 +381,7 @@ int SrsForwarder::forward() | ||
| 381 | 381 | ||
| 382 | SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_FORWARDER); | 382 | SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_FORWARDER); |
| 383 | 383 | ||
| 384 | - SrsSharedPtrMessageArray msgs(SYS_MAX_FORWARD_SEND_MSGS); | 384 | + SrsMessageArray msgs(SYS_MAX_FORWARD_SEND_MSGS); |
| 385 | 385 | ||
| 386 | // update sequence header | 386 | // update sequence header |
| 387 | // TODO: FIXME: maybe need to zero the sequence header timestamp. | 387 | // TODO: FIXME: maybe need to zero the sequence header timestamp. |
| @@ -442,7 +442,7 @@ int SrsForwarder::forward() | @@ -442,7 +442,7 @@ int SrsForwarder::forward() | ||
| 442 | // @remark, becareful, all msgs must be free explicitly, | 442 | // @remark, becareful, all msgs must be free explicitly, |
| 443 | // free by send_and_free_message or srs_freep. | 443 | // free by send_and_free_message or srs_freep. |
| 444 | for (int i = 0; i < count; i++) { | 444 | for (int i = 0; i < count; i++) { |
| 445 | - SrsSharedPtrMessage* msg = msgs.msgs[i]; | 445 | + SrsMessage* msg = msgs.msgs[i]; |
| 446 | 446 | ||
| 447 | srs_assert(msg); | 447 | srs_assert(msg); |
| 448 | msgs.msgs[i] = NULL; | 448 | msgs.msgs[i] = NULL; |
| @@ -517,7 +517,7 @@ int SrsRtmpConn::playing(SrsSource* source) | @@ -517,7 +517,7 @@ int SrsRtmpConn::playing(SrsSource* source) | ||
| 517 | 517 | ||
| 518 | // initialize other components | 518 | // initialize other components |
| 519 | SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PLAY_USER); | 519 | SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PLAY_USER); |
| 520 | - SrsSharedPtrMessageArray msgs(SYS_CONSTS_MAX_PLAY_SEND_MSGS); | 520 | + SrsMessageArray msgs(SYS_CONSTS_MAX_PLAY_SEND_MSGS); |
| 521 | bool user_specified_duration_to_stop = (req->duration > 0); | 521 | bool user_specified_duration_to_stop = (req->duration > 0); |
| 522 | int64_t starttime = -1; | 522 | int64_t starttime = -1; |
| 523 | 523 | ||
| @@ -574,7 +574,7 @@ int SrsRtmpConn::playing(SrsSource* source) | @@ -574,7 +574,7 @@ int SrsRtmpConn::playing(SrsSource* source) | ||
| 574 | // we start to collect the durations for each message. | 574 | // we start to collect the durations for each message. |
| 575 | if (user_specified_duration_to_stop) { | 575 | if (user_specified_duration_to_stop) { |
| 576 | for (int i = 0; i < count; i++) { | 576 | for (int i = 0; i < count; i++) { |
| 577 | - SrsSharedPtrMessage* msg = msgs.msgs[i]; | 577 | + SrsMessage* msg = msgs.msgs[i]; |
| 578 | 578 | ||
| 579 | // foreach msg, collect the duration. | 579 | // foreach msg, collect the duration. |
| 580 | // @remark: never use msg when sent it, for the protocol sdk will free it. | 580 | // @remark: never use msg when sent it, for the protocol sdk will free it. |
| @@ -192,7 +192,7 @@ int SrsMessageQueue::enqueue(SrsSharedPtrMessage* msg) | @@ -192,7 +192,7 @@ int SrsMessageQueue::enqueue(SrsSharedPtrMessage* msg) | ||
| 192 | return ret; | 192 | return ret; |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | -int SrsMessageQueue::dump_packets(int max_count, SrsSharedPtrMessage** pmsgs, int& count) | 195 | +int SrsMessageQueue::dump_packets(int max_count, SrsMessage** pmsgs, int& count) |
| 196 | { | 196 | { |
| 197 | int ret = ERROR_SUCCESS; | 197 | int ret = ERROR_SUCCESS; |
| 198 | 198 | ||
| @@ -207,7 +207,7 @@ int SrsMessageQueue::dump_packets(int max_count, SrsSharedPtrMessage** pmsgs, in | @@ -207,7 +207,7 @@ int SrsMessageQueue::dump_packets(int max_count, SrsSharedPtrMessage** pmsgs, in | ||
| 207 | pmsgs[i] = msgs[i]; | 207 | pmsgs[i] = msgs[i]; |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | - SrsSharedPtrMessage* last = msgs[count - 1]; | 210 | + SrsMessage* last = msgs[count - 1]; |
| 211 | av_start_time = last->header.timestamp; | 211 | av_start_time = last->header.timestamp; |
| 212 | 212 | ||
| 213 | if (count == (int)msgs.size()) { | 213 | if (count == (int)msgs.size()) { |
| @@ -332,7 +332,7 @@ int SrsConsumer::enqueue(SrsSharedPtrMessage* msg, bool atc, int tba, int tbv, S | @@ -332,7 +332,7 @@ int SrsConsumer::enqueue(SrsSharedPtrMessage* msg, bool atc, int tba, int tbv, S | ||
| 332 | return ret; | 332 | return ret; |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | -int SrsConsumer::dump_packets(int max_count, SrsSharedPtrMessage** pmsgs, int& count) | 335 | +int SrsConsumer::dump_packets(int max_count, SrsMessage** pmsgs, int& count) |
| 336 | { | 336 | { |
| 337 | srs_assert(max_count > 0); | 337 | srs_assert(max_count > 0); |
| 338 | 338 |
| @@ -132,7 +132,7 @@ public: | @@ -132,7 +132,7 @@ public: | ||
| 132 | * @count the count in array, output param. | 132 | * @count the count in array, output param. |
| 133 | * @max_count the max count to dequeue, must be positive. | 133 | * @max_count the max count to dequeue, must be positive. |
| 134 | */ | 134 | */ |
| 135 | - virtual int dump_packets(int max_count, SrsSharedPtrMessage** pmsgs, int& count); | 135 | + virtual int dump_packets(int max_count, SrsMessage** pmsgs, int& count); |
| 136 | private: | 136 | private: |
| 137 | /** | 137 | /** |
| 138 | * remove a gop from the front. | 138 | * remove a gop from the front. |
| @@ -187,7 +187,7 @@ public: | @@ -187,7 +187,7 @@ public: | ||
| 187 | * @count the count in array, output param. | 187 | * @count the count in array, output param. |
| 188 | * @max_count the max count to dequeue, must be positive. | 188 | * @max_count the max count to dequeue, must be positive. |
| 189 | */ | 189 | */ |
| 190 | - virtual int dump_packets(int max_count, SrsSharedPtrMessage** pmsgs, int& count); | 190 | + virtual int dump_packets(int max_count, SrsMessage** pmsgs, int& count); |
| 191 | /** | 191 | /** |
| 192 | * when client send the pause message. | 192 | * when client send the pause message. |
| 193 | */ | 193 | */ |
| @@ -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 16 | 34 | +#define VERSION_REVISION 17 |
| 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" |
| @@ -25,11 +25,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -25,11 +25,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 25 | 25 | ||
| 26 | #include <srs_protocol_stack.hpp> | 26 | #include <srs_protocol_stack.hpp> |
| 27 | 27 | ||
| 28 | -SrsSharedPtrMessageArray::SrsSharedPtrMessageArray(int _size) | 28 | +SrsMessageArray::SrsMessageArray(int _size) |
| 29 | { | 29 | { |
| 30 | srs_assert(_size > 0); | 30 | srs_assert(_size > 0); |
| 31 | 31 | ||
| 32 | - msgs = new SrsSharedPtrMessage*[_size]; | 32 | + msgs = new SrsMessage*[_size]; |
| 33 | size = _size; | 33 | size = _size; |
| 34 | 34 | ||
| 35 | // initialize | 35 | // initialize |
| @@ -38,11 +38,11 @@ SrsSharedPtrMessageArray::SrsSharedPtrMessageArray(int _size) | @@ -38,11 +38,11 @@ SrsSharedPtrMessageArray::SrsSharedPtrMessageArray(int _size) | ||
| 38 | } | 38 | } |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | -SrsSharedPtrMessageArray::~SrsSharedPtrMessageArray() | 41 | +SrsMessageArray::~SrsMessageArray() |
| 42 | { | 42 | { |
| 43 | // cleanup | 43 | // cleanup |
| 44 | for (int i = 0; i < size; i++) { | 44 | for (int i = 0; i < size; i++) { |
| 45 | - SrsSharedPtrMessage* msg = msgs[i]; | 45 | + SrsMessage* msg = msgs[i]; |
| 46 | srs_freep(msg); | 46 | srs_freep(msg); |
| 47 | } | 47 | } |
| 48 | 48 |
| @@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 30 | 30 | ||
| 31 | #include <srs_core.hpp> | 31 | #include <srs_core.hpp> |
| 32 | 32 | ||
| 33 | -class SrsSharedPtrMessage; | 33 | +class SrsMessage; |
| 34 | 34 | ||
| 35 | /** | 35 | /** |
| 36 | * the class to auto free the shared ptr message array. | 36 | * the class to auto free the shared ptr message array. |
| @@ -39,7 +39,7 @@ class SrsSharedPtrMessage; | @@ -39,7 +39,7 @@ class SrsSharedPtrMessage; | ||
| 39 | * then send each message and set to NULL. | 39 | * then send each message and set to NULL. |
| 40 | * @remark: when error, the message array will free the msg not sent out. | 40 | * @remark: when error, the message array will free the msg not sent out. |
| 41 | */ | 41 | */ |
| 42 | -class SrsSharedPtrMessageArray | 42 | +class SrsMessageArray |
| 43 | { | 43 | { |
| 44 | public: | 44 | public: |
| 45 | /** | 45 | /** |
| @@ -47,17 +47,17 @@ public: | @@ -47,17 +47,17 @@ public: | ||
| 47 | * for instance, msg= msgs.msgs[i], msgs.msgs[i]=NULL, send(msg), | 47 | * for instance, msg= msgs.msgs[i], msgs.msgs[i]=NULL, send(msg), |
| 48 | * where send(msg) will always send and free it. | 48 | * where send(msg) will always send and free it. |
| 49 | */ | 49 | */ |
| 50 | - SrsSharedPtrMessage** msgs; | 50 | + SrsMessage** msgs; |
| 51 | int size; | 51 | int size; |
| 52 | public: | 52 | public: |
| 53 | /** | 53 | /** |
| 54 | * create msg array, initialize array to NULL ptrs. | 54 | * create msg array, initialize array to NULL ptrs. |
| 55 | */ | 55 | */ |
| 56 | - SrsSharedPtrMessageArray(int _size); | 56 | + SrsMessageArray(int _size); |
| 57 | /** | 57 | /** |
| 58 | * free the msgs not sent out(not NULL). | 58 | * free the msgs not sent out(not NULL). |
| 59 | */ | 59 | */ |
| 60 | - virtual ~SrsSharedPtrMessageArray(); | 60 | + virtual ~SrsMessageArray(); |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | #endif | 63 | #endif |
| @@ -771,7 +771,7 @@ int SrsRtmpServer::send_and_free_message(SrsMessage* msg, int stream_id) | @@ -771,7 +771,7 @@ int SrsRtmpServer::send_and_free_message(SrsMessage* msg, int stream_id) | ||
| 771 | return protocol->send_and_free_message(msg, stream_id); | 771 | return protocol->send_and_free_message(msg, stream_id); |
| 772 | } | 772 | } |
| 773 | 773 | ||
| 774 | -int SrsRtmpServer::send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, int stream_id) | 774 | +int SrsRtmpServer::send_and_free_messages(SrsMessage** msgs, int nb_msgs, int stream_id) |
| 775 | { | 775 | { |
| 776 | return protocol->send_and_free_messages(msgs, nb_msgs, stream_id); | 776 | return protocol->send_and_free_messages(msgs, nb_msgs, stream_id); |
| 777 | } | 777 | } |
| @@ -378,7 +378,7 @@ public: | @@ -378,7 +378,7 @@ public: | ||
| 378 | * @remark performance issue, to support 6k+ 250kbps client, | 378 | * @remark performance issue, to support 6k+ 250kbps client, |
| 379 | * @see https://github.com/winlinvip/simple-rtmp-server/issues/194 | 379 | * @see https://github.com/winlinvip/simple-rtmp-server/issues/194 |
| 380 | */ | 380 | */ |
| 381 | - virtual int send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, int stream_id); | 381 | + virtual int send_and_free_messages(SrsMessage** msgs, int nb_msgs, int stream_id); |
| 382 | /** | 382 | /** |
| 383 | * send the RTMP packet and always free it. | 383 | * send the RTMP packet and always free it. |
| 384 | * user must never free or use the packet after this method, | 384 | * user must never free or use the packet after this method, |
| @@ -413,7 +413,7 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) | @@ -413,7 +413,7 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) | ||
| 413 | // each chunk consumers atleast 2 iovs | 413 | // each chunk consumers atleast 2 iovs |
| 414 | srs_assert(nb_out_iovs >= 2); | 414 | srs_assert(nb_out_iovs >= 2); |
| 415 | 415 | ||
| 416 | - warned_c0c3_caches = false; | 416 | + warned_c0c3_cry = false; |
| 417 | } | 417 | } |
| 418 | 418 | ||
| 419 | SrsProtocol::~SrsProtocol() | 419 | SrsProtocol::~SrsProtocol() |
| @@ -547,65 +547,7 @@ int SrsProtocol::decode_message(SrsMessage* msg, SrsPacket** ppacket) | @@ -547,65 +547,7 @@ int SrsProtocol::decode_message(SrsMessage* msg, SrsPacket** ppacket) | ||
| 547 | return ret; | 547 | return ret; |
| 548 | } | 548 | } |
| 549 | 549 | ||
| 550 | -int SrsProtocol::do_send_message(SrsMessage* msg) | ||
| 551 | -{ | ||
| 552 | - int ret = ERROR_SUCCESS; | ||
| 553 | - | ||
| 554 | - // ignore empty message. | ||
| 555 | - if (!msg->payload || msg->size <= 0) { | ||
| 556 | - srs_info("ignore empty message."); | ||
| 557 | - return ret; | ||
| 558 | - } | ||
| 559 | - | ||
| 560 | - // we donot use the complex basic header, | ||
| 561 | - // ensure the basic header is 1bytes. | ||
| 562 | - if (msg->header.perfer_cid < 2) { | ||
| 563 | - srs_warn("change the chunk_id=%d to default=%d", | ||
| 564 | - msg->header.perfer_cid, RTMP_CID_ProtocolControl); | ||
| 565 | - msg->header.perfer_cid = RTMP_CID_ProtocolControl; | ||
| 566 | - } | ||
| 567 | - | ||
| 568 | - // p set to current write position, | ||
| 569 | - // it's ok when payload is NULL and size is 0. | ||
| 570 | - char* p = msg->payload; | ||
| 571 | - char* pend = msg->payload + msg->size; | ||
| 572 | - | ||
| 573 | - // always write the header event payload is empty. | ||
| 574 | - while (p < pend) { | ||
| 575 | - // always has header | ||
| 576 | - int nbh = 0; | ||
| 577 | - char* header = NULL; | ||
| 578 | - generate_chunk_header(out_c0c3_cache, &msg->header, p == msg->payload, &nbh, &header); | ||
| 579 | - srs_assert(nbh > 0); | ||
| 580 | - | ||
| 581 | - // header iov | ||
| 582 | - out_iov[0].iov_base = header; | ||
| 583 | - out_iov[0].iov_len = nbh; | ||
| 584 | - | ||
| 585 | - // payload iov | ||
| 586 | - int payload_size = pend - p; | ||
| 587 | - if (payload_size > out_chunk_size) { | ||
| 588 | - payload_size = out_chunk_size; | ||
| 589 | - } | ||
| 590 | - out_iov[1].iov_base = p; | ||
| 591 | - out_iov[1].iov_len = payload_size; | ||
| 592 | - | ||
| 593 | - // send by writev | ||
| 594 | - // sendout header and payload by writev. | ||
| 595 | - // decrease the sys invoke count to get higher performance. | ||
| 596 | - if ((ret = skt->writev(out_iov, 2, NULL)) != ERROR_SUCCESS) { | ||
| 597 | - srs_error("send with writev failed. ret=%d", ret); | ||
| 598 | - return ret; | ||
| 599 | - } | ||
| 600 | - | ||
| 601 | - // consume sendout bytes. | ||
| 602 | - p += payload_size; | ||
| 603 | - } | ||
| 604 | - | ||
| 605 | - return ret; | ||
| 606 | -} | ||
| 607 | - | ||
| 608 | -int SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msgs) | 550 | +int SrsProtocol::do_send_messages(SrsMessage** msgs, int nb_msgs) |
| 609 | { | 551 | { |
| 610 | int ret = ERROR_SUCCESS; | 552 | int ret = ERROR_SUCCESS; |
| 611 | 553 | ||
| @@ -686,10 +628,10 @@ int SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msgs) | @@ -686,10 +628,10 @@ int SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msgs) | ||
| 686 | int c0c3_left = SRS_CONSTS_C0C3_HEADERS_MAX - c0c3_cache_index; | 628 | int c0c3_left = SRS_CONSTS_C0C3_HEADERS_MAX - c0c3_cache_index; |
| 687 | if (c0c3_left < SRS_CONSTS_RTMP_MAX_FMT0_HEADER_SIZE) { | 629 | if (c0c3_left < SRS_CONSTS_RTMP_MAX_FMT0_HEADER_SIZE) { |
| 688 | // only warn once for a connection. | 630 | // only warn once for a connection. |
| 689 | - if (!warned_c0c3_caches) { | 631 | + if (!warned_c0c3_cry) { |
| 690 | srs_warn("c0c3 cache header too small, recoment to %d", | 632 | srs_warn("c0c3 cache header too small, recoment to %d", |
| 691 | SRS_CONSTS_C0C3_HEADERS_MAX + SRS_CONSTS_RTMP_MAX_FMT0_HEADER_SIZE); | 633 | SRS_CONSTS_C0C3_HEADERS_MAX + SRS_CONSTS_RTMP_MAX_FMT0_HEADER_SIZE); |
| 692 | - warned_c0c3_caches = true; | 634 | + warned_c0c3_cry = true; |
| 693 | } | 635 | } |
| 694 | 636 | ||
| 695 | // when c0c3 cache dry, | 637 | // when c0c3 cache dry, |
| @@ -977,21 +919,10 @@ int SrsProtocol::do_decode_message(SrsMessageHeader& header, SrsStream* stream, | @@ -977,21 +919,10 @@ int SrsProtocol::do_decode_message(SrsMessageHeader& header, SrsStream* stream, | ||
| 977 | 919 | ||
| 978 | int SrsProtocol::send_and_free_message(SrsMessage* msg, int stream_id) | 920 | int SrsProtocol::send_and_free_message(SrsMessage* msg, int stream_id) |
| 979 | { | 921 | { |
| 980 | - // always not NULL msg. | ||
| 981 | - srs_assert(msg); | ||
| 982 | - | ||
| 983 | - // update the stream id in header. | ||
| 984 | - msg->header.stream_id = stream_id; | ||
| 985 | - | ||
| 986 | - // donot use the auto free to free the msg, | ||
| 987 | - // for performance issue. | ||
| 988 | - int ret = do_send_message(msg); | ||
| 989 | - srs_freep(msg); | ||
| 990 | - | ||
| 991 | - return ret; | 922 | + return send_and_free_messages(&msg, 1, stream_id); |
| 992 | } | 923 | } |
| 993 | 924 | ||
| 994 | -int SrsProtocol::send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, int stream_id) | 925 | +int SrsProtocol::send_and_free_messages(SrsMessage** msgs, int nb_msgs, int stream_id) |
| 995 | { | 926 | { |
| 996 | // always not NULL msg. | 927 | // always not NULL msg. |
| 997 | srs_assert(msgs); | 928 | srs_assert(msgs); |
| @@ -1052,7 +983,7 @@ int SrsProtocol::send_and_free_packet(SrsPacket* packet, int stream_id) | @@ -1052,7 +983,7 @@ int SrsProtocol::send_and_free_packet(SrsPacket* packet, int stream_id) | ||
| 1052 | 983 | ||
| 1053 | // donot use the auto free to free the msg, | 984 | // donot use the auto free to free the msg, |
| 1054 | // for performance issue. | 985 | // for performance issue. |
| 1055 | - ret = do_send_message(msg); | 986 | + ret = do_send_messages(&msg, 1); |
| 1056 | if (ret == ERROR_SUCCESS) { | 987 | if (ret == ERROR_SUCCESS) { |
| 1057 | ret = on_send_packet(msg, packet); | 988 | ret = on_send_packet(msg, packet); |
| 1058 | } | 989 | } |
| @@ -212,24 +212,21 @@ private: | @@ -212,24 +212,21 @@ private: | ||
| 212 | // peer out | 212 | // peer out |
| 213 | private: | 213 | private: |
| 214 | /** | 214 | /** |
| 215 | - * output header cache. | ||
| 216 | - * used for type0, 11bytes(or 15bytes with extended timestamp) header. | ||
| 217 | - * or for type3, 1bytes(or 5bytes with extended timestamp) header. | ||
| 218 | - */ | ||
| 219 | - char out_c0c3_cache[SRS_CONSTS_RTMP_MAX_FMT0_HEADER_SIZE]; | ||
| 220 | - /** | ||
| 221 | - * output iovec cache. | ||
| 222 | - */ | ||
| 223 | - iovec out_iov[2]; | ||
| 224 | - /** | ||
| 225 | * cache for multiple messages send | 215 | * cache for multiple messages send |
| 226 | */ | 216 | */ |
| 227 | iovec* out_iovs; | 217 | iovec* out_iovs; |
| 228 | int nb_out_iovs; | 218 | int nb_out_iovs; |
| 229 | - // the c0c3 cache cannot be realloc. | 219 | + /** |
| 220 | + * output header cache. | ||
| 221 | + * used for type0, 11bytes(or 15bytes with extended timestamp) header. | ||
| 222 | + * or for type3, 1bytes(or 5bytes with extended timestamp) header. | ||
| 223 | + * the c0c3 caches must use unit SRS_CONSTS_RTMP_MAX_FMT0_HEADER_SIZE bytes. | ||
| 224 | + * | ||
| 225 | + * @remark, the c0c3 cache cannot be realloc. | ||
| 226 | + */ | ||
| 230 | char out_c0c3_caches[SRS_CONSTS_C0C3_HEADERS_MAX]; | 227 | char out_c0c3_caches[SRS_CONSTS_C0C3_HEADERS_MAX]; |
| 231 | // whether warned user to increase the c0c3 header cache. | 228 | // whether warned user to increase the c0c3 header cache. |
| 232 | - bool warned_c0c3_caches; | 229 | + bool warned_c0c3_cry; |
| 233 | /** | 230 | /** |
| 234 | * output chunk size, default to 128, set by config. | 231 | * output chunk size, default to 128, set by config. |
| 235 | */ | 232 | */ |
| @@ -293,7 +290,7 @@ public: | @@ -293,7 +290,7 @@ public: | ||
| 293 | * @param nb_msgs, the size of msgs to send out. | 290 | * @param nb_msgs, the size of msgs to send out. |
| 294 | * @param stream_id, the stream id of packet to send over, 0 for control message. | 291 | * @param stream_id, the stream id of packet to send over, 0 for control message. |
| 295 | */ | 292 | */ |
| 296 | - virtual int send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, int stream_id); | 293 | + virtual int send_and_free_messages(SrsMessage** msgs, int nb_msgs, int stream_id); |
| 297 | /** | 294 | /** |
| 298 | * send the RTMP packet and always free it. | 295 | * send the RTMP packet and always free it. |
| 299 | * user must never free or use the packet after this method, | 296 | * user must never free or use the packet after this method, |
| @@ -363,15 +360,10 @@ public: | @@ -363,15 +360,10 @@ public: | ||
| 363 | } | 360 | } |
| 364 | private: | 361 | private: |
| 365 | /** | 362 | /** |
| 366 | - * send out the message, donot free it, | ||
| 367 | - * the caller must free the param msg. | ||
| 368 | - */ | ||
| 369 | - virtual int do_send_message(SrsMessage* msg); | ||
| 370 | - /** | ||
| 371 | * send out the messages, donot free it, | 363 | * send out the messages, donot free it, |
| 372 | * the caller must free the param msgs. | 364 | * the caller must free the param msgs. |
| 373 | */ | 365 | */ |
| 374 | - virtual int do_send_messages(SrsSharedPtrMessage** msgs, int nb_msgs); | 366 | + virtual int do_send_messages(SrsMessage** msgs, int nb_msgs); |
| 375 | /** | 367 | /** |
| 376 | * generate the chunk header for msg. | 368 | * generate the chunk header for msg. |
| 377 | * @param mh, the header of msg to send. | 369 | * @param mh, the header of msg to send. |
| @@ -529,7 +529,7 @@ VOID TEST(ProtocolMsgArrayTest, MessageArray) | @@ -529,7 +529,7 @@ VOID TEST(ProtocolMsgArrayTest, MessageArray) | ||
| 529 | EXPECT_EQ(0, msg.count()); | 529 | EXPECT_EQ(0, msg.count()); |
| 530 | 530 | ||
| 531 | if (true) { | 531 | if (true) { |
| 532 | - SrsSharedPtrMessageArray arr(3); | 532 | + SrsMessageArray arr(3); |
| 533 | 533 | ||
| 534 | arr.msgs[0] = msg.copy(); | 534 | arr.msgs[0] = msg.copy(); |
| 535 | EXPECT_EQ(1, msg.count()); | 535 | EXPECT_EQ(1, msg.count()); |
| @@ -543,7 +543,7 @@ VOID TEST(ProtocolMsgArrayTest, MessageArray) | @@ -543,7 +543,7 @@ VOID TEST(ProtocolMsgArrayTest, MessageArray) | ||
| 543 | EXPECT_EQ(0, msg.count()); | 543 | EXPECT_EQ(0, msg.count()); |
| 544 | 544 | ||
| 545 | if (true) { | 545 | if (true) { |
| 546 | - SrsSharedPtrMessageArray arr(3); | 546 | + SrsMessageArray arr(3); |
| 547 | 547 | ||
| 548 | arr.msgs[0] = msg.copy(); | 548 | arr.msgs[0] = msg.copy(); |
| 549 | EXPECT_EQ(1, msg.count()); | 549 | EXPECT_EQ(1, msg.count()); |
-
请 注册 或 登录 后发表评论