diff --git a/CMakeLists.txt b/CMakeLists.txt index 94ff9e64..6d50a6cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ if (NOT WIN32) list(REMOVE_ITEM ToolKit_src_list ${ToolKit_Root}/win32/getopt.c) else() #防止Windows.h包含Winsock.h - add_definitions(-DWIN32_LEAN_AND_MEAN) + add_definitions(-DWIN32_LEAN_AND_MEAN -DMP4V2_NO_STDINT_DEFS) endif () #添加两个静态库 diff --git a/ZLToolKit b/ZLToolKit index 48065ffc..8cb7e825 160000 --- a/ZLToolKit +++ b/ZLToolKit @@ -1 +1 @@ -Subproject commit 48065ffcac0fd7bfa115d62d6f1abb9decc1a3c9 +Subproject commit 8cb7e825d9bb8b71992411632569938b897ec033 diff --git a/src/MediaFile/Mp4Maker.cpp b/src/MediaFile/Mp4Maker.cpp index 6ff2b715..300bdfb0 100644 --- a/src/MediaFile/Mp4Maker.cpp +++ b/src/MediaFile/Mp4Maker.cpp @@ -26,13 +26,13 @@ #ifdef ENABLE_MP4V2 -#include #include #include "Common/config.h" #include "Mp4Maker.h" #include "MediaRecorder.h" #include "Util/File.h" #include "Util/mini.h" +#include "Util/util.h" #include "Util/NoticeCenter.h" using namespace ZL::Util; @@ -43,20 +43,17 @@ namespace MediaFile { string timeStr(const char *fmt) { std::tm tm_snapshot; auto time = ::time(NULL); -#if defined(WIN32) - localtime_s(&tm_snapshot, &time); // thread-safe? - std::ostringstream oss; - oss << std::put_time(const_cast(&tm_snapshot), fmt); - return oss.str(); +#if defined(_WIN32) + localtime_s(&tm_snapshot, &time); // thread-safe #else localtime_r(&time, &tm_snapshot); // POSIX +#endif const size_t size = 1024; char buffer[size]; auto success = std::strftime(buffer, size, fmt, &tm_snapshot); if (0 == success) return string(fmt); return buffer; -#endif } Mp4Maker::Mp4Maker(const string& strPath, @@ -171,7 +168,11 @@ void Mp4Maker::createFile() { + strTime + ".mp4"; //----record 业务逻辑----// +#if !defined(_WIN32) File::createfile_path(strFileTmp.data(), S_IRWXO | S_IRWXG | S_IRWXU); +#else + File::createfile_path(strFileTmp.data(), 0); +#endif m_hMp4 = MP4Create(strFileTmp.data()); if (m_hMp4 == MP4_INVALID_FILE_HANDLE) { WarnL << "创建MP4文件失败:" << strFileTmp;