Refactoring log

This commit is contained in:
monktan
2020-11-18 12:00:23 +08:00
parent ccd96f676c
commit 6e8d19704e
3 changed files with 14 additions and 9 deletions

View File

@@ -33,13 +33,20 @@ HlsMakerImp::HlsMakerImp(const string &m3u8_file,
_ui64StartedTime = ::time(nullptr);
_info.folder = _path_prefix;
InfoL << "create HlsMakerImp, this: " << (long)this
<< ", type: " << record_type
<< ", seg_number: " << seg_number
<< ", m3u8_file: " << m3u8_file;
}
HlsMakerImp::~HlsMakerImp() {
InfoL << "destroy HlsMakerImp, this: " << (long)this;
clearCache();
}
void HlsMakerImp::clearCache() {
InfoL << "isLive: " << isLive();
//录制完了
flushLastSegment(true);
if(isLive()){
@@ -122,7 +129,6 @@ void HlsMakerImp::onWriteHls(const char *data, int len) {
} else{
WarnL << "create hls file failed," << _path_hls << " " << get_uv_errmsg();
}
//DebugL << "\r\n" << string(data,len);
}
std::shared_ptr<FILE> HlsMakerImp::makeFile(const string &file,bool setbuf) {
@@ -143,30 +149,28 @@ void HlsMakerImp::onWriteRecordM3u8(const char *header, int hlen,const char *bod
string mode = "r+";
if (access(_path_hls.c_str(), 0) == -1) {
exist = false;
WarnL << "hls m3u8 not exist" << _path_hls;
mode = "w+";
}else{
WarnL << "hls m3u8 exist" << _path_hls;
}
auto hls = makeRecordM3u8(_path_hls, mode);
InfoL << "makeFile hls " << hls;
if(hls){
fwrite(header, hlen,1,hls.get());
if (exist) {
fseek(hls.get(),-15L,SEEK_END);
}
fwrite(body, blen,1,hls.get());
hls.reset();
if(_media_src){
_media_src->registHls(true);
}
} else{
WarnL << "create hls file falied," << _path_hls << " " << get_uv_errmsg();
WarnL << "create hls file falied, " << _path_hls << " " << get_uv_errmsg();
}
DebugL << "\r\n" << string(body,blen);
DebugL << "_path_hls " << _path_hls;
//DebugL << "\r\n" << string(body, blen);
//DebugL << "_path_hls: " << _path_hls;
}
void HlsMakerImp::onFlushLastSegment(uint32_t duration_ms) {

View File

@@ -199,6 +199,7 @@ void RtmpProtocol::sendRtmp(uint8_t type, uint32_t stream_index, const std::stri
}
void RtmpProtocol::sendRtmp(uint8_t type, uint32_t stream_index, const Buffer::Ptr &buf, uint32_t stamp, int chunk_id){
//InfoL << "this: " << (long)this << ", stream_index: " << stream_index << ", stamp: " << stamp << ", chunk_id: " << chunk_id;
if (chunk_id < 2 || chunk_id > 63) {
auto strErr = StrPrinter << "不支持发送该类型的块流 ID:" << chunk_id << endl;
throw std::runtime_error(strErr);

View File

@@ -57,7 +57,7 @@ void RtpSession::onManager() {
}
void RtpSession::onRtpPacket(const char *data, uint64_t len) {
if (len > 1024 * 2) {
if (len > 1024 * 4) {
throw SockException(Err_shutdown, "rtp包长度异常发送端可能缓存溢出并覆盖");
}
if (!_process) {