diff --git a/api/include/mk_common.h b/api/include/mk_common.h index c9657a9a..6363d22e 100755 --- a/api/include/mk_common.h +++ b/api/include/mk_common.h @@ -17,12 +17,12 @@ #ifndef MediaKitApi_STATIC #if defined(MediaKitApi_EXPORTS) - #define API_EXPORT __declspec(dllexport) - #else - #define API_EXPORT __declspec(dllimport) - #endif + #define API_EXPORT __declspec(dllexport) + #else + #define API_EXPORT __declspec(dllimport) + #endif - #define API_CALL __cdecl + #define API_CALL __cdecl #else #define API_EXPORT #define API_CALL diff --git a/src/Common/Device.h b/src/Common/Device.h index 2e2d61f5..a2129d98 100644 --- a/src/Common/Device.h +++ b/src/Common/Device.h @@ -43,9 +43,9 @@ public: class AudioInfo { public: CodecId codecId = CodecAAC; - int iChannel; - int iSampleBit; - int iSampleRate; + int iChannel; + int iSampleBit; + int iSampleRate; }; /** diff --git a/src/Extension/Factory.cpp b/src/Extension/Factory.cpp index 037c5f98..4bdc7c43 100644 --- a/src/Extension/Factory.cpp +++ b/src/Extension/Factory.cpp @@ -226,7 +226,7 @@ RtmpCodec::Ptr Factory::getRtmpCodecByTrack(const Track::Ptr &track) { case CodecH264 : return std::make_shared(track); case CodecAAC : return std::make_shared(track); case CodecH265 : return std::make_shared(track); - case CodecG711A : + case CodecG711A : case CodecG711U : return std::make_shared(track); default : WarnL << "暂不支持该CodecId:" << track->getCodecName(); return nullptr; } diff --git a/src/Extension/Opus.cpp b/src/Extension/Opus.cpp index e4e15a57..e9dea37d 100644 --- a/src/Extension/Opus.cpp +++ b/src/Extension/Opus.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). diff --git a/src/Extension/Opus.h b/src/Extension/Opus.h index b763a2da..17e28c06 100644 --- a/src/Extension/Opus.h +++ b/src/Extension/Opus.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). diff --git a/src/Http/HlsParser.cpp b/src/Http/HlsParser.cpp index 613dcb59..6dce3837 100644 --- a/src/Http/HlsParser.cpp +++ b/src/Http/HlsParser.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). diff --git a/src/Http/HlsParser.h b/src/Http/HlsParser.h index f33b46d0..7a0ed7fe 100644 --- a/src/Http/HlsParser.h +++ b/src/Http/HlsParser.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). diff --git a/src/Http/HlsPlayer.cpp b/src/Http/HlsPlayer.cpp index 16111752..d1b78186 100644 --- a/src/Http/HlsPlayer.cpp +++ b/src/Http/HlsPlayer.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). diff --git a/src/Http/HlsPlayer.h b/src/Http/HlsPlayer.h index d9cf9766..bfeed863 100644 --- a/src/Http/HlsPlayer.h +++ b/src/Http/HlsPlayer.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). diff --git a/src/Http/HttpTSPlayer.cpp b/src/Http/HttpTSPlayer.cpp index 5c02c174..fb525f11 100644 --- a/src/Http/HttpTSPlayer.cpp +++ b/src/Http/HttpTSPlayer.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). diff --git a/src/Http/HttpTSPlayer.h b/src/Http/HttpTSPlayer.h index ec1aa129..6b12a453 100644 --- a/src/Http/HttpTSPlayer.h +++ b/src/Http/HttpTSPlayer.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). diff --git a/src/Record/MP4.cpp b/src/Record/MP4.cpp index 571efa16..a0152ef1 100644 --- a/src/Record/MP4.cpp +++ b/src/Record/MP4.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). diff --git a/src/Record/MP4.h b/src/Record/MP4.h index 15e201f9..b76362a9 100644 --- a/src/Record/MP4.h +++ b/src/Record/MP4.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). diff --git a/src/Record/MP4Demuxer.cpp b/src/Record/MP4Demuxer.cpp index f157f9a5..7b0fadd4 100644 --- a/src/Record/MP4Demuxer.cpp +++ b/src/Record/MP4Demuxer.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). diff --git a/src/Record/MP4Demuxer.h b/src/Record/MP4Demuxer.h index a626d05c..5565cc22 100644 --- a/src/Record/MP4Demuxer.h +++ b/src/Record/MP4Demuxer.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index c1baafa2..b2e8e088 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -737,22 +737,22 @@ void RtspSession::handleReq_Play(const Parser &parser) { } bool useBuf = true; - _enableSendRtp = false; + _enableSendRtp = false; float iStartTime = 0; - if (strRange.size() && !_bFirstPlay) { + if (strRange.size() && !_bFirstPlay) { //这个是seek操作 - auto strStart = FindField(strRange.data(), "npt=", "-"); - if (strStart == "now") { - strStart = "0"; - } - iStartTime = 1000 * atof(strStart.data()); - InfoP(this) << "rtsp seekTo(ms):" << iStartTime; - useBuf = !pMediaSrc->seekTo(iStartTime); - }else if(pMediaSrc->totalReaderCount() == 0){ - //第一个消费者 - pMediaSrc->seekTo(0); - } - _bFirstPlay = false; + auto strStart = FindField(strRange.data(), "npt=", "-"); + if (strStart == "now") { + strStart = "0"; + } + iStartTime = 1000 * atof(strStart.data()); + InfoP(this) << "rtsp seekTo(ms):" << iStartTime; + useBuf = !pMediaSrc->seekTo(iStartTime); + }else if(pMediaSrc->totalReaderCount() == 0){ + //第一个消费者 + pMediaSrc->seekTo(0); + } + _bFirstPlay = false; _StrPrinter rtp_info; for(auto &track : _aTrackInfo){ @@ -772,10 +772,10 @@ void RtspSession::handleReq_Play(const Parser &parser) { rtp_info.pop_back(); - sendRtspResponse("200 OK", - {"Range", StrPrinter << "npt=" << setiosflags(ios::fixed) << setprecision(2) << (useBuf? pMediaSrc->getTimeStamp(TrackInvalid) / 1000.0 : iStartTime / 1000), - "RTP-Info",rtp_info - }); + sendRtspResponse("200 OK", + {"Range", StrPrinter << "npt=" << setiosflags(ios::fixed) << setprecision(2) << (useBuf? pMediaSrc->getTimeStamp(TrackInvalid) / 1000.0 : iStartTime / 1000), + "RTP-Info",rtp_info + }); _enableSendRtp = true; setSocketFlags(); diff --git a/tests/bom.cpp b/tests/bom.cpp index 46f1e1a8..d541858b 100644 --- a/tests/bom.cpp +++ b/tests/bom.cpp @@ -61,40 +61,6 @@ public: } }; -void get_file_path(const char *path, const char *file_name, char *file_path) { - strcpy(file_path, path); - if (file_path[strlen(file_path) - 1] != '/') { - strcat(file_path, "/"); - } - strcat(file_path, file_name); -} - -template -void for_each_file(const char *path, FUNC &&func){ - DIR *dir; - dirent *dir_info; - char file_path[PATH_MAX]; - if (File::is_file(path)) { - func(path); - return; - } - if (File::is_dir(path)) { - if ((dir = opendir(path)) == NULL) { - closedir(dir); - return; - } - while ((dir_info = readdir(dir)) != NULL) { - if (File::is_special_dir(dir_info->d_name)) { - continue; - } - get_file_path(path, dir_info->d_name, file_path); - for_each_file(file_path,std::forward(func)); - } - closedir(dir); - return; - } -} - static const char s_bom[] = "\xEF\xBB\xBF"; void add_or_rm_bom(const char *file,bool rm_bom){ @@ -159,23 +125,26 @@ int main(int argc, char *argv[]) { bool no_filter = filter_set.find("*") != filter_set.end(); //设置日志 Logger::Instance().add(std::make_shared()); - path = File::absolutePath(path, ""); - for_each_file(path.data(),[&](const char *path){ - if(!no_filter){ + File::scanDir(path, [&](const string &path, bool isDir) { + if (isDir) { + return true; + } + if (!no_filter) { //开启了过滤器 - auto pos = strstr(path,"."); - if(pos == nullptr){ + auto pos = strstr(path.data(), "."); + if (pos == nullptr) { //没有后缀 - return; + return true; } auto ext = pos + 1; - if(filter_set.find(ext) == filter_set.end()){ + if (filter_set.find(ext) == filter_set.end()) { //后缀不匹配 - return; + return true; } } //该文件匹配 - process_file(path,rm_bom); - }); + process_file(path.data(), rm_bom); + return true; + }, true); return 0; } diff --git a/tests/tab.cpp b/tests/tab.cpp index 7382f75d..98acd45e 100644 --- a/tests/tab.cpp +++ b/tests/tab.cpp @@ -128,8 +128,6 @@ int main(int argc, char *argv[]) { bool no_filter = filter_set.find("*") != filter_set.end(); //设置日志 Logger::Instance().add(std::make_shared()); - path = File::absolutePath(path, ""); - DebugL << path; File::scanDir(path, [&](const string &path, bool isDir) { if (isDir) { return true; diff --git a/tests/test_player.cpp b/tests/test_player.cpp index 8ca20d82..5417030d 100644 --- a/tests/test_player.cpp +++ b/tests/test_player.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). diff --git a/tests/test_rtp.cpp b/tests/test_rtp.cpp index 58686f2c..a6b25b58 100644 --- a/tests/test_rtp.cpp +++ b/tests/test_rtp.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).