From 6e8d19704eb57feadcfc80d027ee80bc704024cc Mon Sep 17 00:00:00 2001 From: monktan Date: Wed, 18 Nov 2020 12:00:23 +0800 Subject: [PATCH] Refactoring log --- src/Record/HlsMakerImp.cpp | 20 ++++++++++++-------- src/Rtmp/RtmpProtocol.cpp | 1 + src/Rtp/RtpSession.cpp | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Record/HlsMakerImp.cpp b/src/Record/HlsMakerImp.cpp index 778ed783..626ba0fb 100644 --- a/src/Record/HlsMakerImp.cpp +++ b/src/Record/HlsMakerImp.cpp @@ -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 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) { diff --git a/src/Rtmp/RtmpProtocol.cpp b/src/Rtmp/RtmpProtocol.cpp index 55f45092..deb9aebc 100644 --- a/src/Rtmp/RtmpProtocol.cpp +++ b/src/Rtmp/RtmpProtocol.cpp @@ -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); diff --git a/src/Rtp/RtpSession.cpp b/src/Rtp/RtpSession.cpp index 21fb5e2d..97b62155 100644 --- a/src/Rtp/RtpSession.cpp +++ b/src/Rtp/RtpSession.cpp @@ -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) {