diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 8611e88c..f564c7ed 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 8611e88c2eda178973662dcfe180691ff1d8ba35 +Subproject commit f564c7ed27f141a3b5f08d239970b24d700a1244 diff --git a/src/Http/HttpFileManager.cpp b/src/Http/HttpFileManager.cpp index dd2647a1..0e603e81 100644 --- a/src/Http/HttpFileManager.cpp +++ b/src/Http/HttpFileManager.cpp @@ -298,12 +298,6 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st return true; } -//字符串是否以xx结尾 -static bool end_of(const string &str, const string &substr){ - auto pos = str.rfind(substr); - return pos != string::npos && pos == str.size() - substr.size(); -}; - //拦截hls的播放请求 static bool emitHlsPlayed(const Parser &parser, const MediaInfo &mediaInfo, const HttpSession::HttpAccessPathInvoker &invoker,TcpSession &sender){ //访问的hls.m3u8结尾,我们转换成kBroadcastMediaPlayed事件 @@ -488,7 +482,7 @@ static string pathCat(const string &a, const string &b){ * @param cb 回调对象 */ static void accessFile(TcpSession &sender, const Parser &parser, const MediaInfo &mediaInfo, const string &strFile, const HttpFileManager::invoker &cb) { - bool is_hls = end_of(strFile, kHlsSuffix); + bool is_hls = end_with(strFile, kHlsSuffix); bool file_exist = File::is_file(strFile.data()); if (!is_hls && !file_exist) { //文件不存在且不是hls,那么直接返回404 diff --git a/src/Player/PlayerBase.cpp b/src/Player/PlayerBase.cpp index 775f38d5..c29c4c27 100644 --- a/src/Player/PlayerBase.cpp +++ b/src/Player/PlayerBase.cpp @@ -17,12 +17,6 @@ using namespace toolkit; namespace mediakit { -//字符串是否以xx结尾 -static bool end_of(const string &str, const string &substr){ - auto pos = str.rfind(substr); - return pos != string::npos && pos == str.size() - substr.size(); -} - PlayerBase::Ptr PlayerBase::createPlayer(const EventPoller::Ptr &poller,const string &url_in) { static auto releasePlayer = [](PlayerBase *ptr){ onceToken token(nullptr,[&](){ @@ -54,7 +48,7 @@ PlayerBase::Ptr PlayerBase::createPlayer(const EventPoller::Ptr &poller,const st return PlayerBase::Ptr(new RtmpPlayerImp(poller),releasePlayer); } - if ((strcasecmp("http",prefix.data()) == 0 || strcasecmp("https",prefix.data()) == 0) && end_of(url, ".m3u8")) { + if ((strcasecmp("http",prefix.data()) == 0 || strcasecmp("https",prefix.data()) == 0) && end_with(url, ".m3u8")) { return PlayerBase::Ptr(new HlsPlayerImp(poller),releasePlayer); } diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index 6f7a6a65..cdc44293 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -126,12 +126,6 @@ void RtspSession::onRecv(const Buffer::Ptr &buf) { } } -//字符串是否以xx结尾 -static inline bool end_of(const string &str, const string &substr){ - auto pos = str.rfind(substr); - return pos != string::npos && pos == str.size() - substr.size(); -} - void RtspSession::onWholeRtspPacket(Parser &parser) { string method = parser.Method(); //提取出请求命令字 _cseq = atoi(parser["CSeq"].data()); @@ -224,7 +218,7 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) { } auto full_url = parser.FullUrl(); - if(end_of(full_url,".sdp")){ + if(end_with(full_url,".sdp")){ //去除.sdp后缀,防止EasyDarwin推流器强制添加.sdp后缀 full_url = full_url.substr(0,full_url.length() - 4); _media_info.parse(full_url);