完成FLV复用器改造

优化代码结构
This commit is contained in:
xiongziliang
2018-08-31 14:13:00 +08:00
parent ef9ebc89e0
commit 732eb2d197
15 changed files with 74 additions and 68 deletions

View File

@@ -21,9 +21,6 @@ void FlvMuxer::start(const RtmpMediaSource::Ptr &media) {
if(!media){
throw std::runtime_error("RtmpMediaSource 无效");
}
if(!media->ready()){
throw std::runtime_error("RtmpMediaSource 未准备好");
}
onWriteFlvHeader(media);
@@ -176,6 +173,7 @@ void FlvRecorder::startRecord(const string &vhost, const string &app, const stri
}
void FlvRecorder::startRecord(const RtmpMediaSource::Ptr &media, const string &file_path) {
lock_guard<recursive_mutex> lck(_file_mtx);
//开辟文件写缓存
std::shared_ptr<char> fileBuf(new char[FILE_BUF_SIZE],[](char *ptr){
if(ptr){
@@ -183,7 +181,7 @@ void FlvRecorder::startRecord(const RtmpMediaSource::Ptr &media, const string &f
}
});
//新建文件
std::shared_ptr<FILE> _file(File::createfile_file(file_path.data(),"wb"),[fileBuf](FILE *fp){
_file.reset(File::createfile_file(file_path.data(),"wb"),[fileBuf](FILE *fp){
if(fp){
fflush(fp);
fclose(fp);
@@ -221,6 +219,12 @@ std::shared_ptr<FlvMuxer> FlvRecorder::getSharedPtr() {
return shared_from_this();
}
FlvRecorder::FlvRecorder() {
}
FlvRecorder::~FlvRecorder() {
}
}//namespace Rtmp
}//namespace ZL