mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
Revert "for bug #241, merge big chunks for publish, no use."
This reverts commit 6b57597718
.
This commit is contained in:
parent
6b57597718
commit
565f29ed6c
10 changed files with 21 additions and 90 deletions
|
@ -288,16 +288,10 @@ void SrsPublishRecvThread::on_thread_start()
|
||||||
{
|
{
|
||||||
// we donot set the auto response to false,
|
// we donot set the auto response to false,
|
||||||
// for the main thread never send message.
|
// for the main thread never send message.
|
||||||
|
|
||||||
// notice the protocol stack to merge chunks to big buffer.
|
|
||||||
// for example, the buffer is 64KB=512kb, it's 1s buffer for 500kbps video stream.
|
|
||||||
// so we can use read_fullly(64KB) to merge all chunks in 1s.
|
|
||||||
// @see https://github.com/winlinvip/simple-rtmp-server/issues/241
|
|
||||||
rtmp->set_merge_chunks(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsPublishRecvThread::on_thread_stop()
|
void SrsPublishRecvThread::on_thread_stop()
|
||||||
{
|
{
|
||||||
// revert state
|
// we donot set the auto response to true,
|
||||||
rtmp->set_merge_chunks(false);
|
// for we donot set to false yet.
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <srs_kernel_error.hpp>
|
#include <srs_kernel_error.hpp>
|
||||||
#include <srs_kernel_log.hpp>
|
#include <srs_kernel_log.hpp>
|
||||||
|
|
||||||
// 4096=4KB
|
#define SOCKET_READ_SIZE 4096
|
||||||
// 16384=16KB
|
|
||||||
// 65536=64KB
|
|
||||||
#define SOCKET_READ_SIZE 16384
|
|
||||||
|
|
||||||
ISrsBufferReader::ISrsBufferReader()
|
ISrsBufferReader::ISrsBufferReader()
|
||||||
{
|
{
|
||||||
|
@ -41,13 +38,10 @@ ISrsBufferReader::~ISrsBufferReader()
|
||||||
|
|
||||||
SrsBuffer::SrsBuffer()
|
SrsBuffer::SrsBuffer()
|
||||||
{
|
{
|
||||||
merge_chunks_in_big_buffer = false;
|
|
||||||
buffer = new char[SOCKET_READ_SIZE];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsBuffer::~SrsBuffer()
|
SrsBuffer::~SrsBuffer()
|
||||||
{
|
{
|
||||||
srs_freep(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsBuffer::length()
|
int SrsBuffer::length()
|
||||||
|
@ -94,15 +88,11 @@ int SrsBuffer::grow(ISrsBufferReader* reader, int required_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (length() < required_size) {
|
while (length() < required_size) {
|
||||||
|
char buffer[SOCKET_READ_SIZE];
|
||||||
|
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
if (merge_chunks_in_big_buffer) {
|
if ((ret = reader->read(buffer, SOCKET_READ_SIZE, &nread)) != ERROR_SUCCESS) {
|
||||||
if ((ret = reader->read_fully(buffer, SOCKET_READ_SIZE, &nread)) != ERROR_SUCCESS) {
|
return ret;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((ret = reader->read(buffer, SOCKET_READ_SIZE, &nread)) != ERROR_SUCCESS) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_assert((int)nread > 0);
|
srs_assert((int)nread > 0);
|
||||||
|
@ -112,9 +102,4 @@ int SrsBuffer::grow(ISrsBufferReader* reader, int required_size)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsBuffer::set_merge_chunks(bool v)
|
|
||||||
{
|
|
||||||
merge_chunks_in_big_buffer = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,16 +42,7 @@ public:
|
||||||
virtual ~ISrsBufferReader();
|
virtual ~ISrsBufferReader();
|
||||||
// for protocol/amf0/msg-codec
|
// for protocol/amf0/msg-codec
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
* read some bytes of data.
|
|
||||||
* @param nread, the actually read size, NULL to ignore.
|
|
||||||
*/
|
|
||||||
virtual int read(void* buf, size_t size, ssize_t* nread) = 0;
|
virtual int read(void* buf, size_t size, ssize_t* nread) = 0;
|
||||||
/**
|
|
||||||
* read specified size bytes of data
|
|
||||||
* @param nread, the actually read size, NULL to ignore.
|
|
||||||
*/
|
|
||||||
virtual int read_fully(void* buf, size_t size, ssize_t* nread) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,15 +53,6 @@ class SrsBuffer
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::vector<char> data;
|
std::vector<char> data;
|
||||||
/**
|
|
||||||
* notice the protocol stack to merge chunks to big buffer.
|
|
||||||
* for example, the buffer is 64KB=512kb, it's 1s buffer for 500kbps video stream.
|
|
||||||
* so we can use read_fullly(64KB) to merge all chunks in 1s.
|
|
||||||
* @see https://github.com/winlinvip/simple-rtmp-server/issues/241
|
|
||||||
*/
|
|
||||||
bool merge_chunks_in_big_buffer;
|
|
||||||
// the socket recv buffer.
|
|
||||||
char* buffer;
|
|
||||||
public:
|
public:
|
||||||
SrsBuffer();
|
SrsBuffer();
|
||||||
virtual ~SrsBuffer();
|
virtual ~SrsBuffer();
|
||||||
|
@ -107,14 +89,6 @@ public:
|
||||||
* @remark, we actually maybe read more than required_size, maybe 4k for example.
|
* @remark, we actually maybe read more than required_size, maybe 4k for example.
|
||||||
*/
|
*/
|
||||||
virtual int grow(ISrsBufferReader* reader, int required_size);
|
virtual int grow(ISrsBufferReader* reader, int required_size);
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* notice the protocol stack to merge chunks to big buffer.
|
|
||||||
* for example, the buffer is 64KB=512kb, it's 1s buffer for 500kbps video stream.
|
|
||||||
* so we can use read_fullly(64KB) to merge all chunks in 1s.
|
|
||||||
* @see https://github.com/winlinvip/simple-rtmp-server/issues/241
|
|
||||||
*/
|
|
||||||
virtual void set_merge_chunks(bool v);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -43,16 +43,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
| IBufferReader | | IStatistic | | IBufferWriter |
|
| IBufferReader | | IStatistic | | IBufferWriter |
|
||||||
+---------------+ +--------------------+ +---------------+
|
+---------------+ +--------------------+ +---------------+
|
||||||
| + read() | | + get_recv_bytes() | | + write() |
|
| + read() | | + get_recv_bytes() | | + write() |
|
||||||
| + readfully() | | + get_recv_bytes() | | + writev() |
|
+------+--------+ | + get_recv_bytes() | | + writev() |
|
||||||
+------+--------+ +---+--------------+-+ +-------+-------+
|
/ \ +---+--------------+-+ +-------+-------+
|
||||||
/ \ / \ / \ / \
|
| / \ / \ / \
|
||||||
| | | |
|
| | | |
|
||||||
+------+------------------+-+ +-----+----------------+--+
|
+------+------------------+-+ +-----+----------------+--+
|
||||||
| IProtocolReader | | IProtocolWriter |
|
| IProtocolReader | | IProtocolWriter |
|
||||||
+---------------------------+ +-------------------------+
|
+---------------------------+ +-------------------------+
|
||||||
| + set_recv_timeout() | | + set_send_timeout() |
|
| + readfully() | | + set_send_timeout() |
|
||||||
+------------+--------------+ +-------+-----------------+
|
| + set_recv_timeout() | +-------+-----------------+
|
||||||
/ \ / \
|
+------------+--------------+ / \
|
||||||
|
/ \ |
|
||||||
| |
|
| |
|
||||||
+--+-----------------------------+-+
|
+--+-----------------------------+-+
|
||||||
| IProtocolReaderWriter |
|
| IProtocolReaderWriter |
|
||||||
|
@ -122,6 +123,13 @@ public:
|
||||||
* get the recv timeout in us.
|
* get the recv timeout in us.
|
||||||
*/
|
*/
|
||||||
virtual int64_t get_recv_timeout() = 0;
|
virtual int64_t get_recv_timeout() = 0;
|
||||||
|
// for handshake.
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* read specified size bytes of data
|
||||||
|
* @param nread, the actually read size, NULL to ignore.
|
||||||
|
*/
|
||||||
|
virtual int read_fully(void* buf, size_t size, ssize_t* nread) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -745,11 +745,6 @@ void SrsRtmpServer::set_auto_response(bool v)
|
||||||
protocol->set_auto_response(v);
|
protocol->set_auto_response(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtmpServer::set_merge_chunks(bool v)
|
|
||||||
{
|
|
||||||
protocol->set_merge_chunks(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsRtmpServer::set_recv_timeout(int64_t timeout_us)
|
void SrsRtmpServer::set_recv_timeout(int64_t timeout_us)
|
||||||
{
|
{
|
||||||
protocol->set_recv_timeout(timeout_us);
|
protocol->set_recv_timeout(timeout_us);
|
||||||
|
|
|
@ -343,13 +343,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void set_auto_response(bool v);
|
virtual void set_auto_response(bool v);
|
||||||
/**
|
/**
|
||||||
* notice the protocol stack to merge chunks to big buffer.
|
|
||||||
* for example, the buffer is 64KB=512kb, it's 1s buffer for 500kbps video stream.
|
|
||||||
* so we can use read_fullly(64KB) to merge all chunks in 1s.
|
|
||||||
* @see https://github.com/winlinvip/simple-rtmp-server/issues/241
|
|
||||||
*/
|
|
||||||
virtual void set_merge_chunks(bool v);
|
|
||||||
/**
|
|
||||||
* set/get the recv timeout in us.
|
* set/get the recv timeout in us.
|
||||||
* if timeout, recv/send message return ERROR_SOCKET_TIMEOUT.
|
* if timeout, recv/send message return ERROR_SOCKET_TIMEOUT.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -478,11 +478,6 @@ int SrsProtocol::manual_response_flush()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsProtocol::set_merge_chunks(bool v)
|
|
||||||
{
|
|
||||||
in_buffer->set_merge_chunks(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrsProtocol::set_recv_timeout(int64_t timeout_us)
|
void SrsProtocol::set_recv_timeout(int64_t timeout_us)
|
||||||
{
|
{
|
||||||
return skt->set_recv_timeout(timeout_us);
|
return skt->set_recv_timeout(timeout_us);
|
||||||
|
|
|
@ -269,13 +269,6 @@ public:
|
||||||
* @see the auto_response_when_recv and manual_response_queue.
|
* @see the auto_response_when_recv and manual_response_queue.
|
||||||
*/
|
*/
|
||||||
virtual int manual_response_flush();
|
virtual int manual_response_flush();
|
||||||
/**
|
|
||||||
* notice the protocol stack to merge chunks to big buffer.
|
|
||||||
* for example, the buffer is 64KB=512kb, it's 1s buffer for 500kbps video stream.
|
|
||||||
* so we can use read_fullly(64KB) to merge all chunks in 1s.
|
|
||||||
* @see https://github.com/winlinvip/simple-rtmp-server/issues/241
|
|
||||||
*/
|
|
||||||
virtual void set_merge_chunks(bool v);
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* set/get the recv timeout in us.
|
* set/get the recv timeout in us.
|
||||||
|
|
|
@ -199,11 +199,6 @@ int MockBufferReader::read(void* buf, size_t size, ssize_t* nread)
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MockBufferReader::read_fully(void* buf, size_t size, ssize_t* nread)
|
|
||||||
{
|
|
||||||
return read(buf, size, nread);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENABLE_UTEST_KERNEL
|
#ifdef ENABLE_UTEST_KERNEL
|
||||||
|
|
||||||
VOID TEST(KernelBufferTest, DefaultObject)
|
VOID TEST(KernelBufferTest, DefaultObject)
|
||||||
|
|
|
@ -42,7 +42,6 @@ public:
|
||||||
virtual ~MockBufferReader();
|
virtual ~MockBufferReader();
|
||||||
public:
|
public:
|
||||||
virtual int read(void* buf, size_t size, ssize_t* nread);
|
virtual int read(void* buf, size_t size, ssize_t* nread);
|
||||||
virtual int read_fully(void* buf, size_t size, ssize_t* nread);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockSrsFileWriter : public SrsFileWriter
|
class MockSrsFileWriter : public SrsFileWriter
|
||||||
|
|
Loading…
Reference in a new issue