From a024c515363ae6197ad1448e8b631540af36a148 Mon Sep 17 00:00:00 2001 From: wxf Date: Sun, 13 Sep 2020 11:07:19 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AD=A6=E5=91=8A:=20mov?= =?UTF-8?q?ing=20a=20local=20object=20in=20a=20return=20statement=20preven?= =?UTF-8?q?ts=20copy=20elision?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.viva64.com/en/w/v828/ 编译器会对返回本地变量优化([Named] Return Value Optimization (RVO/NRVO)), 无论是 C++11 之前还是之后, 添加 move 后反而会影响该优化. C++ Core Guidelines F.48: Do not return std::move(local) --- src/Record/HlsMakerImp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Record/HlsMakerImp.cpp b/src/Record/HlsMakerImp.cpp index 10521e36..4893687b 100644 --- a/src/Record/HlsMakerImp.cpp +++ b/src/Record/HlsMakerImp.cpp @@ -63,9 +63,9 @@ string HlsMakerImp::onOpenSegment(int index) { WarnL << "create file failed," << segment_path << " " << get_uv_errmsg(); } if (_params.empty()) { - return std::move(segment_name); + return segment_name; } - return std::move(segment_name + "?" + _params); + return segment_name + "?" + _params; } void HlsMakerImp::onDelSegment(int index) { From 188e087fc247452895b69881952a94f14dc19496 Mon Sep 17 00:00:00 2001 From: wxf Date: Sun, 13 Sep 2020 14:08:05 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20hls=20ts=20=E5=88=87?= =?UTF-8?q?=E7=89=87=E5=BD=95=E5=88=B6=E5=AE=8C=E6=88=90=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebHook.cpp | 22 ++++++++++++++++++++++ src/Common/config.cpp | 1 + src/Common/config.h | 4 ++++ src/Record/HlsMaker.cpp | 5 +++++ src/Record/HlsMaker.h | 20 ++++++++++++++++++++ src/Record/HlsMakerImp.cpp | 25 +++++++++++++++++++++++++ src/Record/HlsMakerImp.h | 2 ++ 7 files changed, 79 insertions(+) diff --git a/server/WebHook.cpp b/server/WebHook.cpp index 05943403..64c084e0 100644 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -53,6 +53,7 @@ const string kOnRtspAuth = HOOK_FIELD"on_rtsp_auth"; const string kOnStreamChanged = HOOK_FIELD"on_stream_changed"; const string kOnStreamNotFound = HOOK_FIELD"on_stream_not_found"; const string kOnRecordMp4 = HOOK_FIELD"on_record_mp4"; +const string kOnRecordTs = HOOK_FIELD"on_record_ts"; const string kOnShellLogin = HOOK_FIELD"on_shell_login"; const string kOnStreamNoneReader = HOOK_FIELD"on_stream_none_reader"; const string kOnHttpAccess = HOOK_FIELD"on_http_access"; @@ -70,6 +71,7 @@ onceToken token([](){ mINI::Instance()[kOnStreamChanged] = "https://127.0.0.1/index/hook/on_stream_changed"; mINI::Instance()[kOnStreamNotFound] = "https://127.0.0.1/index/hook/on_stream_not_found"; mINI::Instance()[kOnRecordMp4] = "https://127.0.0.1/index/hook/on_record_mp4"; + mINI::Instance()[kOnRecordTs] = "https://127.0.0.1/index/hook/on_record_ts"; mINI::Instance()[kOnShellLogin] = "https://127.0.0.1/index/hook/on_shell_login"; mINI::Instance()[kOnStreamNoneReader] = "https://127.0.0.1/index/hook/on_stream_none_reader"; mINI::Instance()[kOnHttpAccess] = "https://127.0.0.1/index/hook/on_http_access"; @@ -190,6 +192,7 @@ void installWebHook(){ GET_CONFIG(string,hook_stream_chaned,Hook::kOnStreamChanged); GET_CONFIG(string,hook_stream_not_found,Hook::kOnStreamNotFound); GET_CONFIG(string,hook_record_mp4,Hook::kOnRecordMp4); + GET_CONFIG(string,hook_record_ts,Hook::kOnRecordTs); GET_CONFIG(string,hook_shell_login,Hook::kOnShellLogin); GET_CONFIG(string,hook_stream_none_reader,Hook::kOnStreamNoneReader); GET_CONFIG(string,hook_http_access,Hook::kOnHttpAccess); @@ -361,6 +364,25 @@ void installWebHook(){ }); #endif //ENABLE_MP4 + NoticeCenter::Instance().addListener(nullptr, Broadcast::kBroadcastRecordTs, [](BroadcastRecordTsArgs) { + if (!hook_enable || hook_record_ts.empty()) { + return; + } + ArgsType body; + body["start_time"] = (Json::UInt64)info.ui64StartedTime; + body["time_len"] = (Json::UInt64)info.ui64TimeLen; + body["file_size"] = (Json::UInt64)info.ui64FileSize; + body["file_path"] = info.strFilePath; + body["file_name"] = info.strFileName; + body["folder"] = info.strFolder; + body["url"] = info.strUrl; + body["app"] = info.strAppName; + body["stream"] = info.strStreamId; + body["vhost"] = info.strVhost; + // 执行 hook + do_http_hook(hook_record_ts, body, nullptr); + }); + NoticeCenter::Instance().addListener(nullptr,Broadcast::kBroadcastShellLogin,[](BroadcastShellLoginArgs){ if(!hook_enable || hook_shell_login.empty() || sender.get_peer_ip() == "127.0.0.1"){ invoker(""); diff --git a/src/Common/config.cpp b/src/Common/config.cpp index 69e7ed42..79520970 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -40,6 +40,7 @@ bool loadIniConfig(const char *ini_path){ namespace Broadcast { const string kBroadcastMediaChanged = "kBroadcastMediaChanged"; const string kBroadcastRecordMP4 = "kBroadcastRecordMP4"; +const string kBroadcastRecordTs = "kBroadcastRecoredTs"; const string kBroadcastHttpRequest = "kBroadcastHttpRequest"; const string kBroadcastHttpAccess = "kBroadcastHttpAccess"; const string kBroadcastOnGetRtspRealm = "kBroadcastOnGetRtspRealm"; diff --git a/src/Common/config.h b/src/Common/config.h index 0ebdf980..c3cf643b 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -60,6 +60,10 @@ extern const string kBroadcastMediaChanged; extern const string kBroadcastRecordMP4; #define BroadcastRecordMP4Args const MP4Info &info +// 录制 ts 文件后广播 +extern const string kBroadcastRecordTs; +#define BroadcastRecordTsArgs const TsInfo &info + //收到http api请求广播 extern const string kBroadcastHttpRequest; #define BroadcastHttpRequestArgs const Parser &parser,const HttpSession::HttpResponseInvoker &invoker,bool &consumed,SockInfo &sender diff --git a/src/Record/HlsMaker.cpp b/src/Record/HlsMaker.cpp index ff8ead52..f24a4308 100644 --- a/src/Record/HlsMaker.cpp +++ b/src/Record/HlsMaker.cpp @@ -120,6 +120,11 @@ void HlsMaker::flushLastSegment(uint32_t timestamp, bool eof){ delOldSegment(); makeIndexFile(eof); _last_file_name.clear(); + + onFlushLastSegment(seg_dur); +} + +void HlsMaker::onFlushLastSegment(uint32_t) { } bool HlsMaker::isLive() { diff --git a/src/Record/HlsMaker.h b/src/Record/HlsMaker.h index 37666b93..6b0e82d3 100644 --- a/src/Record/HlsMaker.h +++ b/src/Record/HlsMaker.h @@ -22,6 +22,20 @@ using namespace toolkit; namespace mediakit { +class TsInfo { +public: + time_t ui64StartedTime; // GMT 标准时间,单位秒 + time_t ui64TimeLen; // 录像长度,单位毫秒 + off_t ui64FileSize; // 文件大小,单位 BYTE + string strFilePath; // 文件路径 + string strFileName; // 文件名称 + string strFolder; // 文件夹路径 + string strUrl; // 播放路径 + string strAppName; // 应用名称 + string strStreamId; // 流 ID + string strVhost; // vhost +}; + class HlsMaker { public: /** @@ -85,6 +99,12 @@ protected: */ void flushLastSegment(uint32_t timestamp, bool eof = false); + /** + * 上一个 ts 切片写入完成, 可在这里进行通知处理 + * @param duration 上一个 ts 切片的时长, 单位为毫秒 + */ + virtual void onFlushLastSegment(uint32_t duration); + private: /** * 生成m3u8文件 diff --git a/src/Record/HlsMakerImp.cpp b/src/Record/HlsMakerImp.cpp index 4893687b..f3ac9bb6 100644 --- a/src/Record/HlsMakerImp.cpp +++ b/src/Record/HlsMakerImp.cpp @@ -8,7 +8,10 @@ * may be found in the AUTHORS file in the root of the source tree. */ +#include +#include #include "HlsMakerImp.h" +#include "Thread/WorkThreadPool.h" #include "Util/util.h" #include "Util/uv_errno.h" @@ -28,6 +31,8 @@ HlsMakerImp::HlsMakerImp(const string &m3u8_file, _file_buf.reset(new char[bufSize], [](char *ptr) { delete[] ptr; }); + + _info.strFolder = _path_prefix; } HlsMakerImp::~HlsMakerImp() { @@ -59,6 +64,12 @@ string HlsMakerImp::onOpenSegment(int index) { } } _file = makeFile(segment_path, true); + + _info.ui64StartedTime = ::time(NULL); + _info.strFileName = segment_name; + _info.strFilePath = segment_path; + _info.strUrl = _info.strAppName + "/" + _info.strStreamId + "/" + segment_name; + if (!_file) { WarnL << "create file failed," << segment_path << " " << get_uv_errmsg(); } @@ -97,6 +108,17 @@ void HlsMakerImp::onWriteHls(const char *data, int len) { //DebugL << "\r\n" << string(data,len); } +void HlsMakerImp::onFlushLastSegment(uint32_t duration) { + auto info = _info; + info.ui64TimeLen = duration; + WorkThreadPool::Instance().getExecutor()->async([info]() { + struct stat fileData; + stat(info.strFilePath.data(), &fileData); + const_cast(info).ui64FileSize = fileData.st_size; + NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastRecordTs, info); + }); +} + std::shared_ptr HlsMakerImp::makeFile(const string &file, bool setbuf) { auto file_buf = _file_buf; @@ -113,6 +135,9 @@ std::shared_ptr HlsMakerImp::makeFile(const string &file, bool setbuf) { void HlsMakerImp::setMediaSource(const string &vhost, const string &app, const string &stream_id) { _media_src = std::make_shared(vhost, app, stream_id); + _info.strAppName = app; + _info.strStreamId = stream_id; + _info.strVhost = vhost; } HlsMediaSource::Ptr HlsMakerImp::getMediaSource() const { diff --git a/src/Record/HlsMakerImp.h b/src/Record/HlsMakerImp.h index 7764644f..c914b89f 100644 --- a/src/Record/HlsMakerImp.h +++ b/src/Record/HlsMakerImp.h @@ -54,6 +54,7 @@ protected: void onDelSegment(int index) override; void onWriteSegment(const char *data, int len) override; void onWriteHls(const char *data, int len) override; + void onFlushLastSegment(uint32_t duration) override; private: std::shared_ptr makeFile(const string &file,bool setbuf = false); @@ -66,6 +67,7 @@ private: std::shared_ptr _file; std::shared_ptr _file_buf; HlsMediaSource::Ptr _media_src; + TsInfo _info; map _segment_file_paths; }; From b22a6e3dbd2828fb3f2ceb7858311222ec336087 Mon Sep 17 00:00:00 2001 From: wxf Date: Tue, 15 Sep 2020 17:46:12 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20ts=20=E5=88=87?= =?UTF-8?q?=E7=89=87=E6=98=AF=E5=90=A6=E9=80=9A=E7=9F=A5=E9=80=89=E9=A1=B9?= =?UTF-8?q?,=20=E9=BB=98=E8=AE=A4=E4=B8=BA=E4=B8=8D=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/config.ini | 4 ++++ src/Common/config.cpp | 3 +++ src/Common/config.h | 2 ++ src/Record/HlsMakerImp.cpp | 20 ++++++++++++-------- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/conf/config.ini b/conf/config.ini index 72ca1b43..755222a0 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -66,6 +66,8 @@ segDur=2 segNum=3 #HLS切片从m3u8文件中移除后,继续保留在磁盘上的个数 segRetain=5 +# 是否广播 ts 切片完成通知 +broadcastRecordTs=0 [hook] #在推流时,如果url参数匹对admin_params,那么可以不经过hook鉴权直接推流成功,播放时亦然 @@ -83,6 +85,8 @@ on_play=https://127.0.0.1/index/hook/on_play on_publish=https://127.0.0.1/index/hook/on_publish #录制mp4切片完成事件 on_record_mp4=https://127.0.0.1/index/hook/on_record_mp4 +# 录制 hls ts 切片完成事件 +on_record_ts=https://127.0.0.1/index/hook/on_record_ts #rtsp播放鉴权事件,此事件中比对rtsp的用户名密码 on_rtsp_auth=https://127.0.0.1/index/hook/on_rtsp_auth #rtsp播放是否开启专属鉴权事件,置空则关闭rtsp鉴权。rtsp播放鉴权还支持url方式鉴权 diff --git a/src/Common/config.cpp b/src/Common/config.cpp index 79520970..f26c504d 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -252,6 +252,8 @@ const string kSegmentRetain = HLS_FIELD"segRetain"; const string kFileBufSize = HLS_FIELD"fileBufSize"; //录制文件路径 const string kFilePath = HLS_FIELD"filePath"; +// 是否广播 ts 切片完成通知 +const string kBroadcastRecordTs = HLS_FIELD"broadcastRecordTs"; onceToken token([](){ mINI::Instance()[kSegmentDuration] = 2; @@ -259,6 +261,7 @@ onceToken token([](){ mINI::Instance()[kSegmentRetain] = 5; mINI::Instance()[kFileBufSize] = 64 * 1024; mINI::Instance()[kFilePath] = "./www"; + mINI::Instance()[kBroadcastRecordTs] = false; },nullptr); } //namespace Hls diff --git a/src/Common/config.h b/src/Common/config.h index c3cf643b..3f9869a8 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -285,6 +285,8 @@ extern const string kSegmentRetain; extern const string kFileBufSize; //录制文件路径 extern const string kFilePath; +// 是否广播 ts 切片完成通知 +extern const string kBroadcastRecordTs; } //namespace Hls ////////////Rtp代理相关配置/////////// diff --git a/src/Record/HlsMakerImp.cpp b/src/Record/HlsMakerImp.cpp index f3ac9bb6..0ea5048a 100644 --- a/src/Record/HlsMakerImp.cpp +++ b/src/Record/HlsMakerImp.cpp @@ -109,14 +109,18 @@ void HlsMakerImp::onWriteHls(const char *data, int len) { } void HlsMakerImp::onFlushLastSegment(uint32_t duration) { - auto info = _info; - info.ui64TimeLen = duration; - WorkThreadPool::Instance().getExecutor()->async([info]() { - struct stat fileData; - stat(info.strFilePath.data(), &fileData); - const_cast(info).ui64FileSize = fileData.st_size; - NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastRecordTs, info); - }); + GET_CONFIG(bool, broadcastRecordTs, Hls::kBroadcastRecordTs); + + if (broadcastRecordTs) { + auto info = _info; + info.ui64TimeLen = duration; + WorkThreadPool::Instance().getExecutor()->async([info]() { + struct stat fileData; + stat(info.strFilePath.data(), &fileData); + const_cast(info).ui64FileSize = fileData.st_size; + NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastRecordTs, info); + }); + } } From 748bb8e488f4a1032538676ce96611f5dcd62490 Mon Sep 17 00:00:00 2001 From: wxf Date: Tue, 15 Sep 2020 19:09:26 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=BB=9F=E4=B8=80=20mp4=20=E5=8F=8A=20ts?= =?UTF-8?q?=20=E5=BD=95=E5=83=8F=E4=BF=A1=E6=81=AF=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/source/mk_events_objects.cpp | 22 ++++++++++----------- src/Common/config.h | 4 ++-- src/Record/HlsMakerImp.cpp | 2 +- src/Record/HlsMakerImp.h | 4 +++- src/Record/MP4Recorder.cpp | 4 ++-- src/Record/MP4Recorder.h | 18 +++-------------- src/Record/RecordInfo.h | 34 ++++++++++++++++++++++++++++++++ 7 files changed, 56 insertions(+), 32 deletions(-) create mode 100644 src/Record/RecordInfo.h diff --git a/api/source/mk_events_objects.cpp b/api/source/mk_events_objects.cpp index 72c30ed2..85f0c9df 100644 --- a/api/source/mk_events_objects.cpp +++ b/api/source/mk_events_objects.cpp @@ -18,64 +18,64 @@ #include "Rtsp/RtspSession.h" using namespace mediakit; -///////////////////////////////////////////MP4Info///////////////////////////////////////////// +///////////////////////////////////////////RecordInfo///////////////////////////////////////////// API_EXPORT uint64_t API_CALL mk_mp4_info_get_start_time(const mk_mp4_info ctx){ assert(ctx); - MP4Info *info = (MP4Info *)ctx; + RecordInfo *info = (RecordInfo *)ctx; return info->ui64StartedTime; } API_EXPORT uint64_t API_CALL mk_mp4_info_get_time_len(const mk_mp4_info ctx){ assert(ctx); - MP4Info *info = (MP4Info *)ctx; + RecordInfo *info = (RecordInfo *)ctx; return info->ui64TimeLen; } API_EXPORT uint64_t API_CALL mk_mp4_info_get_file_size(const mk_mp4_info ctx){ assert(ctx); - MP4Info *info = (MP4Info *)ctx; + RecordInfo *info = (RecordInfo *)ctx; return info->ui64FileSize; } API_EXPORT const char* API_CALL mk_mp4_info_get_file_path(const mk_mp4_info ctx){ assert(ctx); - MP4Info *info = (MP4Info *)ctx; + RecordInfo *info = (RecordInfo *)ctx; return info->strFilePath.c_str(); } API_EXPORT const char* API_CALL mk_mp4_info_get_file_name(const mk_mp4_info ctx){ assert(ctx); - MP4Info *info = (MP4Info *)ctx; + RecordInfo *info = (RecordInfo *)ctx; return info->strFileName.c_str(); } API_EXPORT const char* API_CALL mk_mp4_info_get_folder(const mk_mp4_info ctx){ assert(ctx); - MP4Info *info = (MP4Info *)ctx; + RecordInfo *info = (RecordInfo *)ctx; return info->strFolder.c_str(); } API_EXPORT const char* API_CALL mk_mp4_info_get_url(const mk_mp4_info ctx){ assert(ctx); - MP4Info *info = (MP4Info *)ctx; + RecordInfo *info = (RecordInfo *)ctx; return info->strUrl.c_str(); } API_EXPORT const char* API_CALL mk_mp4_info_get_vhost(const mk_mp4_info ctx){ assert(ctx); - MP4Info *info = (MP4Info *)ctx; + RecordInfo *info = (RecordInfo *)ctx; return info->strVhost.c_str(); } API_EXPORT const char* API_CALL mk_mp4_info_get_app(const mk_mp4_info ctx){ assert(ctx); - MP4Info *info = (MP4Info *)ctx; + RecordInfo *info = (RecordInfo *)ctx; return info->strAppName.c_str(); } API_EXPORT const char* API_CALL mk_mp4_info_get_stream(const mk_mp4_info ctx){ assert(ctx); - MP4Info *info = (MP4Info *)ctx; + RecordInfo *info = (RecordInfo *)ctx; return info->strStreamId.c_str(); } diff --git a/src/Common/config.h b/src/Common/config.h index 3f9869a8..7038ad40 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -58,11 +58,11 @@ extern const string kBroadcastMediaChanged; //录制mp4文件成功后广播 extern const string kBroadcastRecordMP4; -#define BroadcastRecordMP4Args const MP4Info &info +#define BroadcastRecordMP4Args const RecordInfo &info // 录制 ts 文件后广播 extern const string kBroadcastRecordTs; -#define BroadcastRecordTsArgs const TsInfo &info +#define BroadcastRecordTsArgs const RecordInfo &info //收到http api请求广播 extern const string kBroadcastHttpRequest; diff --git a/src/Record/HlsMakerImp.cpp b/src/Record/HlsMakerImp.cpp index 0ea5048a..e20658d5 100644 --- a/src/Record/HlsMakerImp.cpp +++ b/src/Record/HlsMakerImp.cpp @@ -117,7 +117,7 @@ void HlsMakerImp::onFlushLastSegment(uint32_t duration) { WorkThreadPool::Instance().getExecutor()->async([info]() { struct stat fileData; stat(info.strFilePath.data(), &fileData); - const_cast(info).ui64FileSize = fileData.st_size; + const_cast(info).ui64FileSize = fileData.st_size; NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastRecordTs, info); }); } diff --git a/src/Record/HlsMakerImp.h b/src/Record/HlsMakerImp.h index c914b89f..cc0b3d31 100644 --- a/src/Record/HlsMakerImp.h +++ b/src/Record/HlsMakerImp.h @@ -16,6 +16,8 @@ #include #include "HlsMaker.h" #include "HlsMediaSource.h" +#include "RecordInfo.h" + using namespace std; namespace mediakit { @@ -67,7 +69,7 @@ private: std::shared_ptr _file; std::shared_ptr _file_buf; HlsMediaSource::Ptr _media_src; - TsInfo _info; + RecordInfo _info; map _segment_file_paths; }; diff --git a/src/Record/MP4Recorder.cpp b/src/Record/MP4Recorder.cpp index 1f247354..a8118333 100644 --- a/src/Record/MP4Recorder.cpp +++ b/src/Record/MP4Recorder.cpp @@ -73,7 +73,7 @@ void MP4Recorder::asyncClose() { auto info = _info; WorkThreadPool::Instance().getExecutor()->async([muxer,strFileTmp,strFile,info]() { //获取文件录制时间,放在关闭mp4之前是为了忽略关闭mp4执行时间 - const_cast(info).ui64TimeLen = ::time(NULL) - info.ui64StartedTime; + const_cast(info).ui64TimeLen = ::time(NULL) - info.ui64StartedTime; //关闭mp4非常耗时,所以要放在后台线程执行 muxer->closeMP4(); //临时文件名改成正式文件名,防止mp4未完成时被访问 @@ -81,7 +81,7 @@ void MP4Recorder::asyncClose() { //获取文件大小 struct stat fileData; stat(strFile.data(), &fileData); - const_cast(info).ui64FileSize = fileData.st_size; + const_cast(info).ui64FileSize = fileData.st_size; /////record 业务逻辑////// NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastRecordMP4,info); }); diff --git a/src/Record/MP4Recorder.h b/src/Record/MP4Recorder.h index 60f3c561..cc73363d 100644 --- a/src/Record/MP4Recorder.h +++ b/src/Record/MP4Recorder.h @@ -20,24 +20,12 @@ #include "Util/TimeTicker.h" #include "Common/MediaSink.h" #include "MP4Muxer.h" +#include "RecordInfo.h" + using namespace toolkit; namespace mediakit { -class MP4Info { -public: - time_t ui64StartedTime; //GMT标准时间,单位秒 - time_t ui64TimeLen;//录像长度,单位秒 - off_t ui64FileSize;//文件大小,单位BYTE - string strFilePath;//文件路径 - string strFileName;//文件名称 - string strFolder;//文件夹路径 - string strUrl;//播放路径 - string strAppName;//应用名称 - string strStreamId;//流ID - string strVhost;//vhost -}; - #ifdef ENABLE_MP4 class MP4Recorder : public MediaSinkInterface{ public: @@ -72,7 +60,7 @@ private: string _strFile; string _strFileTmp; Ticker _createFileTicker; - MP4Info _info; + RecordInfo _info; bool _haveVideo = false; MP4Muxer::Ptr _muxer; list _tracks; diff --git a/src/Record/RecordInfo.h b/src/Record/RecordInfo.h new file mode 100644 index 00000000..30184a6a --- /dev/null +++ b/src/Record/RecordInfo.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved. + * + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). + * + * Use of this source code is governed by MIT license that can be found in the + * LICENSE file in the root of the source tree. All contributing project authors + * may be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef RECORDINFO_H_ +#define RECORDINFO_H_ + +#include "Common/config.h" + +namespace mediakit { + +class RecordInfo { +public: + time_t ui64StartedTime; // GMT 标准时间,单位秒 + time_t ui64TimeLen; // 录像长度,需要注意 mp4 单位是秒,而 hls ts 单位是毫秒 + off_t ui64FileSize; // 文件大小,单位 BYTE + string strFilePath; // 文件路径 + string strFileName; // 文件名称 + string strFolder; // 文件夹路径 + string strUrl; // 播放路径 + string strAppName; // 应用名称 + string strStreamId; // 流 ID + string strVhost; // vhost +}; + +} // namespace mediakit + +#endif // RECORDINFO_H_