1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

for bug #241, merge big chunks for publish, no use.

This commit is contained in:
winlin 2014-12-02 22:26:04 +08:00
parent 463e1fbc41
commit 6b57597718
10 changed files with 90 additions and 21 deletions

View file

@ -26,7 +26,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_kernel_error.hpp>
#include <srs_kernel_log.hpp>
#define SOCKET_READ_SIZE 4096
// 4096=4KB
// 16384=16KB
// 65536=64KB
#define SOCKET_READ_SIZE 16384
ISrsBufferReader::ISrsBufferReader()
{
@ -38,10 +41,13 @@ ISrsBufferReader::~ISrsBufferReader()
SrsBuffer::SrsBuffer()
{
merge_chunks_in_big_buffer = false;
buffer = new char[SOCKET_READ_SIZE];
}
SrsBuffer::~SrsBuffer()
{
srs_freep(buffer);
}
int SrsBuffer::length()
@ -88,11 +94,15 @@ int SrsBuffer::grow(ISrsBufferReader* reader, int required_size)
}
while (length() < required_size) {
char buffer[SOCKET_READ_SIZE];
ssize_t nread;
if ((ret = reader->read(buffer, SOCKET_READ_SIZE, &nread)) != ERROR_SUCCESS) {
return ret;
if (merge_chunks_in_big_buffer) {
if ((ret = reader->read_fully(buffer, SOCKET_READ_SIZE, &nread)) != ERROR_SUCCESS) {
return ret;
}
} else {
if ((ret = reader->read(buffer, SOCKET_READ_SIZE, &nread)) != ERROR_SUCCESS) {
return ret;
}
}
srs_assert((int)nread > 0);
@ -102,4 +112,9 @@ int SrsBuffer::grow(ISrsBufferReader* reader, int required_size)
return ret;
}
void SrsBuffer::set_merge_chunks(bool v)
{
merge_chunks_in_big_buffer = v;
}