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

Improve file writer performance by fwrite with cache. v5.0.133 (#3308)

* SrsFileWriter leverages libc buffer to boost dvr write speed.

* Refactor SrsFileWriter to use libc file functions mockable

* Add utest and refine code.

Co-authored-by: winlin <winlin@vip.126.com>
This commit is contained in:
stone 2023-01-08 12:05:37 +08:00 committed by GitHub
parent fb1790230b
commit 25eb21efe8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 358 additions and 62 deletions

View file

@ -26,6 +26,8 @@ using namespace std;
#include <srs_kernel_mp4.hpp>
#include <srs_app_fragment.hpp>
#define SRS_FWRITE_CACHE_SIZE 65536
SrsDvrSegmenter::SrsDvrSegmenter()
{
req = NULL;
@ -95,6 +97,11 @@ srs_error_t SrsDvrSegmenter::open()
return srs_error_wrap(err, "open file %s", path.c_str());
}
// Set libc file write cache buffer size
if ((err = fs->set_iobuf_size(SRS_FWRITE_CACHE_SIZE)) != srs_success) {
return srs_error_wrap(err, "set iobuf size for file %s", path.c_str());
}
// initialize the encoder.
if ((err = open_encoder()) != srs_success) {
return srs_error_wrap(err, "open encoder");