From 67d2beb52a1e04434ec1411c8b9af05c2502cd30 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 18 Oct 2019 09:51:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=9B=B8=E5=AF=B9=E8=B7=AF=E5=BE=84=EF=BC=8Chttp?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=9C=8D=E5=8A=A1=E5=99=A8=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E6=A0=B9=E7=9B=AE=E5=BD=95=E7=88=B6=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/ZLToolKit | 2 +- server/FFmpegSource.cpp | 4 ++-- src/Common/config.cpp | 2 +- src/Http/HttpSession.cpp | 7 ++----- src/MediaFile/MediaReader.cpp | 5 +++-- src/MediaFile/MediaRecorder.cpp | 15 +++++++++------ 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 665f53b6..ace77b13 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 665f53b6a4385e2312d3bf09aa305d7e3bf079e6 +Subproject commit ace77b132039d6ef8a97b6dad92115f88821bc45 diff --git a/server/FFmpegSource.cpp b/server/FFmpegSource.cpp index 90805cd5..536bd63d 100644 --- a/server/FFmpegSource.cpp +++ b/server/FFmpegSource.cpp @@ -39,7 +39,7 @@ const char kLog[] = FFmpeg_FIELD"log"; onceToken token([]() { mINI::Instance()[kBin] = trim(System::execute("which ffmpeg")); mINI::Instance()[kCmd] = "%s -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s"; - mINI::Instance()[kLog] = exeDir() + "ffmpeg/ffmpeg.log"; + mINI::Instance()[kLog] = "./ffmpeg/ffmpeg.log"; }); } @@ -64,7 +64,7 @@ void FFmpegSource::play(const string &src_url,const string &dst_url,int timeout_ char cmd[1024] = {0}; snprintf(cmd, sizeof(cmd),ffmpeg_cmd.data(),ffmpeg_bin.data(),src_url.data(),dst_url.data()); - _process.run(cmd,ffmpeg_log); + _process.run(cmd,File::absolutePath("",true,ffmpeg_log)); InfoL << cmd; if(_media_info._host == "127.0.0.1"){ diff --git a/src/Common/config.cpp b/src/Common/config.cpp index 1f6763ac..15540bcd 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -122,7 +122,7 @@ const string kMaxReqCount = HTTP_FIELD"maxReqCount"; const string kCharSet = HTTP_FIELD"charSet"; //http 服务器根目录 -#define HTTP_ROOT_PATH (exeDir() + "httpRoot") +#define HTTP_ROOT_PATH "./httpRoot" const string kRootPath = HTTP_FIELD"rootPath"; //http 404错误提示内容 diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index 02283d04..b794c731 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -375,10 +375,7 @@ static bool checkHls(BroadcastHttpAccessArgs){ return NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaPlayed,args_copy,mediaAuthInvoker,sender); } -void HttpSession::canAccessPath(const string &path_in,bool is_dir,const function &callback_in){ - auto path = path_in; - replace(const_cast(path),"//","/"); - +void HttpSession::canAccessPath(const string &path,bool is_dir,const function &callback_in){ auto callback = [callback_in,this](const string &errMsg,const HttpServerCookie::Ptr &cookie){ try { callback_in(errMsg,cookie); @@ -507,7 +504,7 @@ void HttpSession::Handle_Req_GET(int64_t &content_len) { GET_CONFIG(uint32_t,reqCnt,Http::kMaxReqCount); GET_CONFIG(bool,enableVhost,General::kEnableVhost); GET_CONFIG(string,rootPath,Http::kRootPath); - string strFile = enableVhost ? rootPath + "/" + _mediaInfo._vhost + _parser.Url() :rootPath + _parser.Url(); + auto strFile = File::absolutePath(enableVhost ? _mediaInfo._vhost + _parser.Url() : _parser.Url(), false, rootPath); bool bClose = (strcasecmp(_parser["Connection"].data(),"close") == 0) || ( ++_iReqCnt > reqCnt); do{ diff --git a/src/MediaFile/MediaReader.cpp b/src/MediaFile/MediaReader.cpp index 22683b4e..4bcdcfc7 100644 --- a/src/MediaFile/MediaReader.cpp +++ b/src/MediaFile/MediaReader.cpp @@ -44,10 +44,11 @@ MediaReader::MediaReader(const string &strVhost,const string &strApp, const stri GET_CONFIG(string,recordPath,Record::kFilePath); GET_CONFIG(bool,enableVhost,General::kEnableVhost); if(enableVhost){ - strFileName = recordPath + "/" + strVhost + "/" + strApp + "/" + strId; + strFileName = strVhost + "/" + strApp + "/" + strId; }else{ - strFileName = recordPath + "/" + strApp + "/" + strId; + strFileName = strApp + "/" + strId; } + strFileName = File::absolutePath(strFileName,true,recordPath); } _hMP4File = MP4Read(strFileName.data()); diff --git a/src/MediaFile/MediaRecorder.cpp b/src/MediaFile/MediaRecorder.cpp index 3f348778..467f33cb 100644 --- a/src/MediaFile/MediaRecorder.cpp +++ b/src/MediaFile/MediaRecorder.cpp @@ -56,13 +56,15 @@ MediaRecorder::MediaRecorder(const string &strVhost_tmp, #if defined(ENABLE_HLS) if(enableHls) { string m3u8FilePath; + string params; if(enableVhost){ - m3u8FilePath = hlsPath + "/" + strVhost + "/" + strApp + "/" + strId + "/hls.m3u8"; - _hlsRecorder.reset(new HlsRecorder(m3u8FilePath,string(VHOST_KEY) + "=" + strVhost ,hlsBufSize, hlsDuration, hlsNum)); + m3u8FilePath = strVhost + "/" + strApp + "/" + strId + "/hls.m3u8"; + params = string(VHOST_KEY) + "=" + strVhost; }else{ - m3u8FilePath = hlsPath + "/" + strApp + "/" + strId + "/hls.m3u8"; - _hlsRecorder.reset(new HlsRecorder(m3u8FilePath,"",hlsBufSize, hlsDuration, hlsNum)); + m3u8FilePath = strApp + "/" + strId + "/hls.m3u8"; } + m3u8FilePath = File::absolutePath(m3u8FilePath,true,hlsPath); + _hlsRecorder.reset(new HlsRecorder(m3u8FilePath,params,hlsBufSize, hlsDuration, hlsNum)); } #endif //defined(ENABLE_HLS) @@ -73,10 +75,11 @@ MediaRecorder::MediaRecorder(const string &strVhost_tmp, if(enableMp4){ string mp4FilePath; if(enableVhost){ - mp4FilePath = recordPath + "/" + strVhost + "/" + recordAppName + "/" + strApp + "/" + strId + "/"; + mp4FilePath = strVhost + "/" + recordAppName + "/" + strApp + "/" + strId + "/"; } else { - mp4FilePath = recordPath + "/" + recordAppName + "/" + strApp + "/" + strId + "/"; + mp4FilePath = recordAppName + "/" + strApp + "/" + strId + "/"; } + mp4FilePath = File::absolutePath(mp4FilePath,true,recordPath); _mp4Recorder.reset(new MP4Recorder(mp4FilePath,strVhost,strApp,strId)); } #endif //defined(ENABLE_MP4RECORD)