正在显示
3 个修改的文件
包含
10 行增加
和
15 行删除
| @@ -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 "0" | 32 | #define VERSION_MAJOR "0" |
| 33 | #define VERSION_MINOR "9" | 33 | #define VERSION_MINOR "9" |
| 34 | -#define VERSION_REVISION "39" | 34 | +#define VERSION_REVISION "40" |
| 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION | 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION |
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "srs" | 37 | #define RTMP_SIG_SRS_KEY "srs" |
| @@ -424,12 +424,10 @@ int SrsProtocol::send_message(ISrsMessage* msg) | @@ -424,12 +424,10 @@ int SrsProtocol::send_message(ISrsMessage* msg) | ||
| 424 | // always write the header event payload is empty. | 424 | // always write the header event payload is empty. |
| 425 | do { | 425 | do { |
| 426 | // generate the header. | 426 | // generate the header. |
| 427 | - char* pheader = NULL; | ||
| 428 | - int header_size = 0; | 427 | + char* pheader = out_header_cache; |
| 429 | 428 | ||
| 430 | if (p == (char*)msg->payload) { | 429 | if (p == (char*)msg->payload) { |
| 431 | // write new chunk stream header, fmt is 0 | 430 | // write new chunk stream header, fmt is 0 |
| 432 | - pheader = out_header_fmt0; | ||
| 433 | *pheader++ = 0x00 | (msg->get_perfer_cid() & 0x3F); | 431 | *pheader++ = 0x00 | (msg->get_perfer_cid() & 0x3F); |
| 434 | 432 | ||
| 435 | // chunk message header, 11 bytes | 433 | // chunk message header, 11 bytes |
| @@ -470,12 +468,8 @@ int SrsProtocol::send_message(ISrsMessage* msg) | @@ -470,12 +468,8 @@ int SrsProtocol::send_message(ISrsMessage* msg) | ||
| 470 | *pheader++ = pp[1]; | 468 | *pheader++ = pp[1]; |
| 471 | *pheader++ = pp[0]; | 469 | *pheader++ = pp[0]; |
| 472 | } | 470 | } |
| 473 | - | ||
| 474 | - header_size = pheader - out_header_fmt0; | ||
| 475 | - pheader = out_header_fmt0; | ||
| 476 | } else { | 471 | } else { |
| 477 | // write no message header chunk stream, fmt is 3 | 472 | // write no message header chunk stream, fmt is 3 |
| 478 | - pheader = out_header_fmt3; | ||
| 479 | *pheader++ = 0xC0 | (msg->get_perfer_cid() & 0x3F); | 473 | *pheader++ = 0xC0 | (msg->get_perfer_cid() & 0x3F); |
| 480 | 474 | ||
| 481 | // chunk extended timestamp header, 0 or 4 bytes, big-endian | 475 | // chunk extended timestamp header, 0 or 4 bytes, big-endian |
| @@ -499,9 +493,6 @@ int SrsProtocol::send_message(ISrsMessage* msg) | @@ -499,9 +493,6 @@ int SrsProtocol::send_message(ISrsMessage* msg) | ||
| 499 | *pheader++ = pp[1]; | 493 | *pheader++ = pp[1]; |
| 500 | *pheader++ = pp[0]; | 494 | *pheader++ = pp[0]; |
| 501 | } | 495 | } |
| 502 | - | ||
| 503 | - header_size = pheader - out_header_fmt3; | ||
| 504 | - pheader = out_header_fmt3; | ||
| 505 | } | 496 | } |
| 506 | 497 | ||
| 507 | // sendout header and payload by writev. | 498 | // sendout header and payload by writev. |
| @@ -509,9 +500,13 @@ int SrsProtocol::send_message(ISrsMessage* msg) | @@ -509,9 +500,13 @@ int SrsProtocol::send_message(ISrsMessage* msg) | ||
| 509 | int payload_size = msg->size - (p - (char*)msg->payload); | 500 | int payload_size = msg->size - (p - (char*)msg->payload); |
| 510 | payload_size = srs_min(payload_size, out_chunk_size); | 501 | payload_size = srs_min(payload_size, out_chunk_size); |
| 511 | 502 | ||
| 503 | + // always has header | ||
| 504 | + int header_size = pheader - out_header_cache; | ||
| 505 | + srs_assert(header_size > 0); | ||
| 506 | + | ||
| 512 | // send by writev | 507 | // send by writev |
| 513 | iovec iov[2]; | 508 | iovec iov[2]; |
| 514 | - iov[0].iov_base = pheader; | 509 | + iov[0].iov_base = out_header_cache; |
| 515 | iov[0].iov_len = header_size; | 510 | iov[0].iov_len = header_size; |
| 516 | iov[1].iov_base = p; | 511 | iov[1].iov_base = p; |
| 517 | iov[1].iov_len = payload_size; | 512 | iov[1].iov_len = payload_size; |
| @@ -106,7 +106,8 @@ class ISrsMessage; | @@ -106,7 +106,8 @@ class ISrsMessage; | ||
| 106 | * 4bytes timestamp header, | 106 | * 4bytes timestamp header, |
| 107 | * that is, 1+4=5bytes. | 107 | * that is, 1+4=5bytes. |
| 108 | */ | 108 | */ |
| 109 | -#define RTMP_MAX_FMT3_HEADER_SIZE 5 | 109 | +// always use fmt0 as cache. |
| 110 | +//#define RTMP_MAX_FMT3_HEADER_SIZE 5 | ||
| 110 | 111 | ||
| 111 | /** | 112 | /** |
| 112 | * the protocol provides the rtmp-message-protocol services, | 113 | * the protocol provides the rtmp-message-protocol services, |
| @@ -141,8 +142,7 @@ private: | @@ -141,8 +142,7 @@ private: | ||
| 141 | AckWindowSize in_ack_size; | 142 | AckWindowSize in_ack_size; |
| 142 | // peer out | 143 | // peer out |
| 143 | private: | 144 | private: |
| 144 | - char out_header_fmt0[RTMP_MAX_FMT0_HEADER_SIZE]; | ||
| 145 | - char out_header_fmt3[RTMP_MAX_FMT3_HEADER_SIZE]; | 145 | + char out_header_cache[RTMP_MAX_FMT0_HEADER_SIZE]; |
| 146 | int32_t out_chunk_size; | 146 | int32_t out_chunk_size; |
| 147 | public: | 147 | public: |
| 148 | /** | 148 | /** |
-
请 注册 或 登录 后发表评论