Skip to content

Commit 565f29e

Browse files
committed
Revert "for bug #241, merge big chunks for publish, no use."
This reverts commit 6b57597.
1 parent 6b57597 commit 565f29e

10 files changed

+21
-90
lines changed

trunk/src/app/srs_app_recv_thread.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,16 +288,10 @@ void SrsPublishRecvThread::on_thread_start()
288288
{
289289
// we donot set the auto response to false,
290290
// 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);
297291
}
298292

299293
void SrsPublishRecvThread::on_thread_stop()
300294
{
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.
303297
}

trunk/src/kernel/srs_kernel_buffer.cpp

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2626
#include <srs_kernel_error.hpp>
2727
#include <srs_kernel_log.hpp>
2828

29-
// 4096=4KB
30-
// 16384=16KB
31-
// 65536=64KB
32-
#define SOCKET_READ_SIZE 16384
29+
#define SOCKET_READ_SIZE 4096
3330

3431
ISrsBufferReader::ISrsBufferReader()
3532
{
@@ -41,13 +38,10 @@ ISrsBufferReader::~ISrsBufferReader()
4138

4239
SrsBuffer::SrsBuffer()
4340
{
44-
merge_chunks_in_big_buffer = false;
45-
buffer = new char[SOCKET_READ_SIZE];
4641
}
4742

4843
SrsBuffer::~SrsBuffer()
4944
{
50-
srs_freep(buffer);
5145
}
5246

5347
int SrsBuffer::length()
@@ -94,15 +88,11 @@ int SrsBuffer::grow(ISrsBufferReader* reader, int required_size)
9488
}
9589

9690
while (length() < required_size) {
91+
char buffer[SOCKET_READ_SIZE];
92+
9793
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;
10696
}
10797

10898
srs_assert((int)nread > 0);
@@ -112,9 +102,4 @@ int SrsBuffer::grow(ISrsBufferReader* reader, int required_size)
112102
return ret;
113103
}
114104

115-
void SrsBuffer::set_merge_chunks(bool v)
116-
{
117-
merge_chunks_in_big_buffer = v;
118-
}
119-
120105

trunk/src/kernel/srs_kernel_buffer.hpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,7 @@ class ISrsBufferReader
4242
virtual ~ISrsBufferReader();
4343
// for protocol/amf0/msg-codec
4444
public:
45-
/**
46-
* read some bytes of data.
47-
* @param nread, the actually read size, NULL to ignore.
48-
*/
4945
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;
5546
};
5647

5748
/**
@@ -62,15 +53,6 @@ class SrsBuffer
6253
{
6354
private:
6455
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;
7456
public:
7557
SrsBuffer();
7658
virtual ~SrsBuffer();
@@ -107,14 +89,6 @@ class SrsBuffer
10789
* @remark, we actually maybe read more than required_size, maybe 4k for example.
10890
*/
10991
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);
11892
};
11993

12094
#endif

trunk/src/rtmp/srs_protocol_io.hpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4343
| IBufferReader | | IStatistic | | IBufferWriter |
4444
+---------------+ +--------------------+ +---------------+
4545
| + read() | | + get_recv_bytes() | | + write() |
46-
| + readfully() | | + get_recv_bytes() | | + writev() |
47-
+------+--------+ +---+--------------+-+ +-------+-------+
48-
/ \ / \ / \ / \
46+
+------+--------+ | + get_recv_bytes() | | + writev() |
47+
/ \ +---+--------------+-+ +-------+-------+
48+
| / \ / \ / \
4949
| | | |
5050
+------+------------------+-+ +-----+----------------+--+
5151
| IProtocolReader | | IProtocolWriter |
5252
+---------------------------+ +-------------------------+
53-
| + set_recv_timeout() | | + set_send_timeout() |
54-
+------------+--------------+ +-------+-----------------+
55-
/ \ / \
53+
| + readfully() | | + set_send_timeout() |
54+
| + set_recv_timeout() | +-------+-----------------+
55+
+------------+--------------+ / \
56+
/ \ |
5657
| |
5758
+--+-----------------------------+-+
5859
| IProtocolReaderWriter |
@@ -122,6 +123,13 @@ class ISrsProtocolReader : public virtual ISrsBufferReader, public virtual ISrsP
122123
* get the recv timeout in us.
123124
*/
124125
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;
125133
};
126134

127135
/**

trunk/src/rtmp/srs_protocol_rtmp.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -745,11 +745,6 @@ void SrsRtmpServer::set_auto_response(bool v)
745745
protocol->set_auto_response(v);
746746
}
747747

748-
void SrsRtmpServer::set_merge_chunks(bool v)
749-
{
750-
protocol->set_merge_chunks(v);
751-
}
752-
753748
void SrsRtmpServer::set_recv_timeout(int64_t timeout_us)
754749
{
755750
protocol->set_recv_timeout(timeout_us);

trunk/src/rtmp/srs_protocol_rtmp.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,6 @@ class SrsRtmpServer
343343
*/
344344
virtual void set_auto_response(bool v);
345345
/**
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-
/**
353346
* set/get the recv timeout in us.
354347
* if timeout, recv/send message return ERROR_SOCKET_TIMEOUT.
355348
*/

trunk/src/rtmp/srs_protocol_stack.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,6 @@ int SrsProtocol::manual_response_flush()
478478
return ret;
479479
}
480480

481-
void SrsProtocol::set_merge_chunks(bool v)
482-
{
483-
in_buffer->set_merge_chunks(v);
484-
}
485-
486481
void SrsProtocol::set_recv_timeout(int64_t timeout_us)
487482
{
488483
return skt->set_recv_timeout(timeout_us);

trunk/src/rtmp/srs_protocol_stack.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,6 @@ class SrsProtocol
269269
* @see the auto_response_when_recv and manual_response_queue.
270270
*/
271271
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);
279272
public:
280273
/**
281274
* set/get the recv timeout in us.

trunk/src/utest/srs_utest_kernel.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,6 @@ int MockBufferReader::read(void* buf, size_t size, ssize_t* nread)
199199
return ERROR_SUCCESS;
200200
}
201201

202-
int MockBufferReader::read_fully(void* buf, size_t size, ssize_t* nread)
203-
{
204-
return read(buf, size, nread);
205-
}
206-
207202
#ifdef ENABLE_UTEST_KERNEL
208203

209204
VOID TEST(KernelBufferTest, DefaultObject)

trunk/src/utest/srs_utest_kernel.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class MockBufferReader: public ISrsBufferReader
4242
virtual ~MockBufferReader();
4343
public:
4444
virtual int read(void* buf, size_t size, ssize_t* nread);
45-
virtual int read_fully(void* buf, size_t size, ssize_t* nread);
4645
};
4746

4847
class MockSrsFileWriter : public SrsFileWriter

0 commit comments

Comments
 (0)