Revert "for bug #241, merge big chunks for publish, no use."
This reverts commit 6b575977.
正在显示
10 个修改的文件
包含
21 行增加
和
90 行删除
| @@ -288,16 +288,10 @@ void SrsPublishRecvThread::on_thread_start() | @@ -288,16 +288,10 @@ void SrsPublishRecvThread::on_thread_start() | ||
| 288 | { | 288 | { |
| 289 | // we donot set the auto response to false, | 289 | // we donot set the auto response to false, |
| 290 | // for the main thread never send message. | 290 | // for the main thread never send message. |
| 291 | - | ||
| 292 | - // notice the protocol stack to merge chunks to big buffer. | ||
| 293 | - // for example, the buffer is 64KB=512kb, it's 1s buffer for 500kbps video stream. | ||
| 294 | - // so we can use read_fullly(64KB) to merge all chunks in 1s. | ||
| 295 | - // @see https://github.com/winlinvip/simple-rtmp-server/issues/241 | ||
| 296 | - rtmp->set_merge_chunks(true); | ||
| 297 | } | 291 | } |
| 298 | 292 | ||
| 299 | void SrsPublishRecvThread::on_thread_stop() | 293 | void SrsPublishRecvThread::on_thread_stop() |
| 300 | { | 294 | { |
| 301 | - // revert state | ||
| 302 | - rtmp->set_merge_chunks(false); | 295 | + // we donot set the auto response to true, |
| 296 | + // for we donot set to false yet. | ||
| 303 | } | 297 | } |
| @@ -26,10 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -26,10 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 26 | #include <srs_kernel_error.hpp> | 26 | #include <srs_kernel_error.hpp> |
| 27 | #include <srs_kernel_log.hpp> | 27 | #include <srs_kernel_log.hpp> |
| 28 | 28 | ||
| 29 | -// 4096=4KB | ||
| 30 | -// 16384=16KB | ||
| 31 | -// 65536=64KB | ||
| 32 | -#define SOCKET_READ_SIZE 16384 | 29 | +#define SOCKET_READ_SIZE 4096 |
| 33 | 30 | ||
| 34 | ISrsBufferReader::ISrsBufferReader() | 31 | ISrsBufferReader::ISrsBufferReader() |
| 35 | { | 32 | { |
| @@ -41,13 +38,10 @@ ISrsBufferReader::~ISrsBufferReader() | @@ -41,13 +38,10 @@ ISrsBufferReader::~ISrsBufferReader() | ||
| 41 | 38 | ||
| 42 | SrsBuffer::SrsBuffer() | 39 | SrsBuffer::SrsBuffer() |
| 43 | { | 40 | { |
| 44 | - merge_chunks_in_big_buffer = false; | ||
| 45 | - buffer = new char[SOCKET_READ_SIZE]; | ||
| 46 | } | 41 | } |
| 47 | 42 | ||
| 48 | SrsBuffer::~SrsBuffer() | 43 | SrsBuffer::~SrsBuffer() |
| 49 | { | 44 | { |
| 50 | - srs_freep(buffer); | ||
| 51 | } | 45 | } |
| 52 | 46 | ||
| 53 | int SrsBuffer::length() | 47 | int SrsBuffer::length() |
| @@ -94,15 +88,11 @@ int SrsBuffer::grow(ISrsBufferReader* reader, int required_size) | @@ -94,15 +88,11 @@ int SrsBuffer::grow(ISrsBufferReader* reader, int required_size) | ||
| 94 | } | 88 | } |
| 95 | 89 | ||
| 96 | while (length() < required_size) { | 90 | while (length() < required_size) { |
| 91 | + char buffer[SOCKET_READ_SIZE]; | ||
| 92 | + | ||
| 97 | ssize_t nread; | 93 | ssize_t nread; |
| 98 | - if (merge_chunks_in_big_buffer) { | ||
| 99 | - if ((ret = reader->read_fully(buffer, SOCKET_READ_SIZE, &nread)) != ERROR_SUCCESS) { | ||
| 100 | - return ret; | ||
| 101 | - } | ||
| 102 | - } else { | ||
| 103 | - if ((ret = reader->read(buffer, SOCKET_READ_SIZE, &nread)) != ERROR_SUCCESS) { | ||
| 104 | - return ret; | ||
| 105 | - } | 94 | + if ((ret = reader->read(buffer, SOCKET_READ_SIZE, &nread)) != ERROR_SUCCESS) { |
| 95 | + return ret; | ||
| 106 | } | 96 | } |
| 107 | 97 | ||
| 108 | srs_assert((int)nread > 0); | 98 | srs_assert((int)nread > 0); |
| @@ -112,9 +102,4 @@ int SrsBuffer::grow(ISrsBufferReader* reader, int required_size) | @@ -112,9 +102,4 @@ int SrsBuffer::grow(ISrsBufferReader* reader, int required_size) | ||
| 112 | return ret; | 102 | return ret; |
| 113 | } | 103 | } |
| 114 | 104 | ||
| 115 | -void SrsBuffer::set_merge_chunks(bool v) | ||
| 116 | -{ | ||
| 117 | - merge_chunks_in_big_buffer = v; | ||
| 118 | -} | ||
| 119 | - | ||
| 120 | 105 |
| @@ -42,16 +42,7 @@ public: | @@ -42,16 +42,7 @@ public: | ||
| 42 | virtual ~ISrsBufferReader(); | 42 | virtual ~ISrsBufferReader(); |
| 43 | // for protocol/amf0/msg-codec | 43 | // for protocol/amf0/msg-codec |
| 44 | public: | 44 | public: |
| 45 | - /** | ||
| 46 | - * read some bytes of data. | ||
| 47 | - * @param nread, the actually read size, NULL to ignore. | ||
| 48 | - */ | ||
| 49 | virtual int read(void* buf, size_t size, ssize_t* nread) = 0; | 45 | virtual int read(void* buf, size_t size, ssize_t* nread) = 0; |
| 50 | - /** | ||
| 51 | - * read specified size bytes of data | ||
| 52 | - * @param nread, the actually read size, NULL to ignore. | ||
| 53 | - */ | ||
| 54 | - virtual int read_fully(void* buf, size_t size, ssize_t* nread) = 0; | ||
| 55 | }; | 46 | }; |
| 56 | 47 | ||
| 57 | /** | 48 | /** |
| @@ -62,15 +53,6 @@ class SrsBuffer | @@ -62,15 +53,6 @@ class SrsBuffer | ||
| 62 | { | 53 | { |
| 63 | private: | 54 | private: |
| 64 | std::vector<char> data; | 55 | std::vector<char> data; |
| 65 | - /** | ||
| 66 | - * notice the protocol stack to merge chunks to big buffer. | ||
| 67 | - * for example, the buffer is 64KB=512kb, it's 1s buffer for 500kbps video stream. | ||
| 68 | - * so we can use read_fullly(64KB) to merge all chunks in 1s. | ||
| 69 | - * @see https://github.com/winlinvip/simple-rtmp-server/issues/241 | ||
| 70 | - */ | ||
| 71 | - bool merge_chunks_in_big_buffer; | ||
| 72 | - // the socket recv buffer. | ||
| 73 | - char* buffer; | ||
| 74 | public: | 56 | public: |
| 75 | SrsBuffer(); | 57 | SrsBuffer(); |
| 76 | virtual ~SrsBuffer(); | 58 | virtual ~SrsBuffer(); |
| @@ -107,14 +89,6 @@ public: | @@ -107,14 +89,6 @@ public: | ||
| 107 | * @remark, we actually maybe read more than required_size, maybe 4k for example. | 89 | * @remark, we actually maybe read more than required_size, maybe 4k for example. |
| 108 | */ | 90 | */ |
| 109 | virtual int grow(ISrsBufferReader* reader, int required_size); | 91 | virtual int grow(ISrsBufferReader* reader, int required_size); |
| 110 | -public: | ||
| 111 | - /** | ||
| 112 | - * notice the protocol stack to merge chunks to big buffer. | ||
| 113 | - * for example, the buffer is 64KB=512kb, it's 1s buffer for 500kbps video stream. | ||
| 114 | - * so we can use read_fullly(64KB) to merge all chunks in 1s. | ||
| 115 | - * @see https://github.com/winlinvip/simple-rtmp-server/issues/241 | ||
| 116 | - */ | ||
| 117 | - virtual void set_merge_chunks(bool v); | ||
| 118 | }; | 92 | }; |
| 119 | 93 | ||
| 120 | #endif | 94 | #endif |
| @@ -43,16 +43,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -43,16 +43,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 43 | | IBufferReader | | IStatistic | | IBufferWriter | | 43 | | IBufferReader | | IStatistic | | IBufferWriter | |
| 44 | +---------------+ +--------------------+ +---------------+ | 44 | +---------------+ +--------------------+ +---------------+ |
| 45 | | + read() | | + get_recv_bytes() | | + write() | | 45 | | + read() | | + get_recv_bytes() | | + write() | |
| 46 | -| + readfully() | | + get_recv_bytes() | | + writev() | | ||
| 47 | -+------+--------+ +---+--------------+-+ +-------+-------+ | ||
| 48 | - / \ / \ / \ / \ | 46 | ++------+--------+ | + get_recv_bytes() | | + writev() | |
| 47 | + / \ +---+--------------+-+ +-------+-------+ | ||
| 48 | + | / \ / \ / \ | ||
| 49 | | | | | | 49 | | | | | |
| 50 | +------+------------------+-+ +-----+----------------+--+ | 50 | +------+------------------+-+ +-----+----------------+--+ |
| 51 | | IProtocolReader | | IProtocolWriter | | 51 | | IProtocolReader | | IProtocolWriter | |
| 52 | +---------------------------+ +-------------------------+ | 52 | +---------------------------+ +-------------------------+ |
| 53 | -| + set_recv_timeout() | | + set_send_timeout() | | ||
| 54 | -+------------+--------------+ +-------+-----------------+ | ||
| 55 | - / \ / \ | 53 | +| + readfully() | | + set_send_timeout() | |
| 54 | +| + set_recv_timeout() | +-------+-----------------+ | ||
| 55 | ++------------+--------------+ / \ | ||
| 56 | + / \ | | ||
| 56 | | | | 57 | | | |
| 57 | +--+-----------------------------+-+ | 58 | +--+-----------------------------+-+ |
| 58 | | IProtocolReaderWriter | | 59 | | IProtocolReaderWriter | |
| @@ -122,6 +123,13 @@ public: | @@ -122,6 +123,13 @@ public: | ||
| 122 | * get the recv timeout in us. | 123 | * get the recv timeout in us. |
| 123 | */ | 124 | */ |
| 124 | virtual int64_t get_recv_timeout() = 0; | 125 | virtual int64_t get_recv_timeout() = 0; |
| 126 | +// for handshake. | ||
| 127 | +public: | ||
| 128 | + /** | ||
| 129 | + * read specified size bytes of data | ||
| 130 | + * @param nread, the actually read size, NULL to ignore. | ||
| 131 | + */ | ||
| 132 | + virtual int read_fully(void* buf, size_t size, ssize_t* nread) = 0; | ||
| 125 | }; | 133 | }; |
| 126 | 134 | ||
| 127 | /** | 135 | /** |
| @@ -745,11 +745,6 @@ void SrsRtmpServer::set_auto_response(bool v) | @@ -745,11 +745,6 @@ void SrsRtmpServer::set_auto_response(bool v) | ||
| 745 | protocol->set_auto_response(v); | 745 | protocol->set_auto_response(v); |
| 746 | } | 746 | } |
| 747 | 747 | ||
| 748 | -void SrsRtmpServer::set_merge_chunks(bool v) | ||
| 749 | -{ | ||
| 750 | - protocol->set_merge_chunks(v); | ||
| 751 | -} | ||
| 752 | - | ||
| 753 | void SrsRtmpServer::set_recv_timeout(int64_t timeout_us) | 748 | void SrsRtmpServer::set_recv_timeout(int64_t timeout_us) |
| 754 | { | 749 | { |
| 755 | protocol->set_recv_timeout(timeout_us); | 750 | protocol->set_recv_timeout(timeout_us); |
| @@ -343,13 +343,6 @@ public: | @@ -343,13 +343,6 @@ public: | ||
| 343 | */ | 343 | */ |
| 344 | virtual void set_auto_response(bool v); | 344 | virtual void set_auto_response(bool v); |
| 345 | /** | 345 | /** |
| 346 | - * notice the protocol stack to merge chunks to big buffer. | ||
| 347 | - * for example, the buffer is 64KB=512kb, it's 1s buffer for 500kbps video stream. | ||
| 348 | - * so we can use read_fullly(64KB) to merge all chunks in 1s. | ||
| 349 | - * @see https://github.com/winlinvip/simple-rtmp-server/issues/241 | ||
| 350 | - */ | ||
| 351 | - virtual void set_merge_chunks(bool v); | ||
| 352 | - /** | ||
| 353 | * set/get the recv timeout in us. | 346 | * set/get the recv timeout in us. |
| 354 | * if timeout, recv/send message return ERROR_SOCKET_TIMEOUT. | 347 | * if timeout, recv/send message return ERROR_SOCKET_TIMEOUT. |
| 355 | */ | 348 | */ |
| @@ -478,11 +478,6 @@ int SrsProtocol::manual_response_flush() | @@ -478,11 +478,6 @@ int SrsProtocol::manual_response_flush() | ||
| 478 | return ret; | 478 | return ret; |
| 479 | } | 479 | } |
| 480 | 480 | ||
| 481 | -void SrsProtocol::set_merge_chunks(bool v) | ||
| 482 | -{ | ||
| 483 | - in_buffer->set_merge_chunks(v); | ||
| 484 | -} | ||
| 485 | - | ||
| 486 | void SrsProtocol::set_recv_timeout(int64_t timeout_us) | 481 | void SrsProtocol::set_recv_timeout(int64_t timeout_us) |
| 487 | { | 482 | { |
| 488 | return skt->set_recv_timeout(timeout_us); | 483 | return skt->set_recv_timeout(timeout_us); |
| @@ -269,13 +269,6 @@ public: | @@ -269,13 +269,6 @@ public: | ||
| 269 | * @see the auto_response_when_recv and manual_response_queue. | 269 | * @see the auto_response_when_recv and manual_response_queue. |
| 270 | */ | 270 | */ |
| 271 | virtual int manual_response_flush(); | 271 | virtual int manual_response_flush(); |
| 272 | - /** | ||
| 273 | - * notice the protocol stack to merge chunks to big buffer. | ||
| 274 | - * for example, the buffer is 64KB=512kb, it's 1s buffer for 500kbps video stream. | ||
| 275 | - * so we can use read_fullly(64KB) to merge all chunks in 1s. | ||
| 276 | - * @see https://github.com/winlinvip/simple-rtmp-server/issues/241 | ||
| 277 | - */ | ||
| 278 | - virtual void set_merge_chunks(bool v); | ||
| 279 | public: | 272 | public: |
| 280 | /** | 273 | /** |
| 281 | * set/get the recv timeout in us. | 274 | * set/get the recv timeout in us. |
| @@ -199,11 +199,6 @@ int MockBufferReader::read(void* buf, size_t size, ssize_t* nread) | @@ -199,11 +199,6 @@ int MockBufferReader::read(void* buf, size_t size, ssize_t* nread) | ||
| 199 | return ERROR_SUCCESS; | 199 | return ERROR_SUCCESS; |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | -int MockBufferReader::read_fully(void* buf, size_t size, ssize_t* nread) | ||
| 203 | -{ | ||
| 204 | - return read(buf, size, nread); | ||
| 205 | -} | ||
| 206 | - | ||
| 207 | #ifdef ENABLE_UTEST_KERNEL | 202 | #ifdef ENABLE_UTEST_KERNEL |
| 208 | 203 | ||
| 209 | VOID TEST(KernelBufferTest, DefaultObject) | 204 | VOID TEST(KernelBufferTest, DefaultObject) |
| @@ -42,7 +42,6 @@ public: | @@ -42,7 +42,6 @@ public: | ||
| 42 | virtual ~MockBufferReader(); | 42 | virtual ~MockBufferReader(); |
| 43 | public: | 43 | public: |
| 44 | virtual int read(void* buf, size_t size, ssize_t* nread); | 44 | virtual int read(void* buf, size_t size, ssize_t* nread); |
| 45 | - virtual int read_fully(void* buf, size_t size, ssize_t* nread); | ||
| 46 | }; | 45 | }; |
| 47 | 46 | ||
| 48 | class MockSrsFileWriter : public SrsFileWriter | 47 | class MockSrsFileWriter : public SrsFileWriter |
-
请 注册 或 登录 后发表评论