Przeglądaj źródła

新增支持qtcreator编译时自动下载库文件

huihui 3 tygodni temu
rodzic
commit
8dddb9b2be

+ 4 - 2
module/VideoPlayer/VideoPlayer.pri

@@ -6,6 +6,7 @@ INCLUDEPATH += $$PWD/src \
 
 SOURCES +=  \
     $$PWD/src/VideoPlayer/VideoPlayer.cpp \
+    $$PWD/src/frame/AudioFrame/AACFrame.cpp \
     $$PWD/src/frame/VideoFrame/VideoEncodedFrame.cpp \
     $$PWD/src/frame/VideoFrame/VideoFrame.cpp \
     $$PWD/src/frame/AudioFrame/PCMFrame.cpp \
@@ -17,11 +18,12 @@ SOURCES +=  \
     $$PWD/src/frame/VideoFrame/VideoRawFrame.cpp \
     $$PWD/src/frame/nalu/nalu.cpp \
     $$PWD/src/util/thread.cpp \
-    $$PWD/src/types.cpp
+    $$PWD/src/util/util.cpp
 
 HEADERS  += \
     $$PWD/src/PcmPlayer/PcmPlayer.h \
     $$PWD/src/VideoPlayer/VideoPlayer.h \
+    $$PWD/src/frame/AudioFrame/AACFrame.h \
     $$PWD/src/frame/VideoFrame/VideoEncodedFrame.h \
     $$PWD/src/frame/VideoFrame/VideoFrame.h \
     $$PWD/src/frame/AudioFrame/PCMFrame.h \
@@ -33,7 +35,7 @@ HEADERS  += \
     $$PWD/src/frame/nalu/h265.h \
     $$PWD/src/frame/nalu/nalu.h \
     $$PWD/src/util/thread.h \
-    $$PWD/src/types.h
+    $$PWD/src/util/util.h
 
 ### lib ### Begin
     include($$PWD/lib/lib.pri)

+ 31 - 42
module/VideoPlayer/lib/lib.pri

@@ -1,51 +1,40 @@
 INCLUDEPATH += $$PWD
 
-include($$PWD/ffmpeg/ffmpeg.pri)
-include($$PWD/SDL2/SDL2.pri)
-
-#win32{
-
-#    INCLUDEPATH += $$PWD/win/ffmpeg/include \
-#                   $$PWD/win/SDL2/include
-
-#    contains(QT_ARCH, i386) {
-#        message("32-bit")
+FFMPEG_BRANCH_NAME="V4.3.1"
+SDL2_BRANCH_NAME="V2.0.2"
 
-#        LIBS += -L$$PWD/win/ffmpeg/lib/x86 -lavcodec -lavdevice -lavfilter -lavformat -lavutil -lpostproc -lswresample -lswscale
-#        LIBS += -L$$PWD/win/SDL2/lib/x86 -lSDL2
-#    } else {
-#        message("64-bit")
-
-#        LIBS += -L$$PWD/win/ffmpeg/lib/x64 -lavcodec -lavdevice -lavfilter -lavformat -lavutil -lpostproc -lswresample -lswscale
-#        LIBS += -L$$PWD/win/SDL2/lib/x64 -lSDL2
-#    }
-
-#}
+win32{
+    message("current platform: Windows ")
+    FFMPEG_BRANCH_NAME="V4.3.1-windows"
+    SDL2_BRANCH_NAME="V2.0.2-windows"
+}
 
 unix{
-
-    INCLUDEPATH += $$PWD/linux/ffmpeg/include \
-                   $$PWD/linux/SDL2/include/SDL2
-
-    contains(QT_ARCH, i386) {
-        message("32-bit, 请自行编译32位库!")
-    } else {
-        message("64-bit")
-
-        LIBS += -L$$PWD/linux/ffmpeg/lib  -lavformat  -lavcodec -lavdevice -lavfilter -lavutil -lswresample -lswscale
-        LIBS += -L$$PWD/linux/SDL2/lib -lSDL2
-
-        LIBS += -lpthread -ldl
-    }
-
-#QMAKE_POST_LINK 表示编译后执行内容
-#QMAKE_PRE_LINK 表示编译前执行内容
-
-#解压库文件
-#QMAKE_PRE_LINK += "cd $$PWD/lib/linux && tar xvzf ffmpeg.tar.gz "
-system("cd $$PWD/lib/linux && tar xvzf ffmpeg.tar.gz")
-system("cd $$PWD/lib/linux && tar xvzf SDL2.tar.gz")
+    message("current platform: Linux ")
+    FFMPEG_BRANCH_NAME="V4.3.1-linux"
+    SDL2_BRANCH_NAME="V2.0.12-linux"
+}
+    
+
+#自动下载ffmpeg库文件
+FILE_TO_CHECK=$$PWD/ffmpeg
+!exists($$FILE_TO_CHECK) {
+    message("File $$FILE_TO_CHECK does not exist. Cloning from Git repository...")
+    system(git clone https://gitee.com/devlib/ffmpeg-dev.git ffmpeg -b $$FFMPEG_BRANCH_NAME)
+} else {
+    message("File $$FILE_TO_CHECK exists.")
+}
 
 
+#自动下载SDL库文件
+FILE_TO_CHECK=$$PWD/SDL2
+!exists($$FILE_TO_CHECK) {
+    message("File $$FILE_TO_CHECK does not exist. Cloning from Git repository...")
+    system(git clone https://gitee.com/devlib/SDL2-dev.git SDL2 -b $$SDL2_BRANCH_NAME)
+} else {
+    message("File $$FILE_TO_CHECK exists.")
 }
 
+
+include($$PWD/ffmpeg/ffmpeg.pri)
+include($$PWD/SDL2/SDL2.pri)

BIN
module/VideoPlayer/lib/linux/SDL2.tar.gz


BIN
module/VideoPlayer/lib/linux/ffmpeg.tar.gz


+ 41 - 2
module/VideoPlayer/src/util/util.cpp

@@ -30,7 +30,40 @@ void mSleep(int mSecond)
 
 namespace Util
 {
-    
+
+#ifdef WIN32
+#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
+  #define DELTA_EPOCH_IN_MICROSECS  11644473600000000Ui64
+#else
+  #define DELTA_EPOCH_IN_MICROSECS  11644473600000000ULL
+#endif
+int gettimeofday(struct timeval* tv, int* /*tz*/) 
+{
+    FILETIME ft;
+    unsigned __int64 tmpres = 0;
+
+    if( tv )
+    {
+        GetSystemTimeAsFileTime( &ft );
+
+        tmpres |= ft.dwHighDateTime;
+        tmpres <<= 32;
+        tmpres |= ft.dwLowDateTime;
+
+        tmpres /= 10;
+
+        tmpres -= DELTA_EPOCH_IN_MICROSECS;
+
+        tv->tv_sec = (time_t)(tmpres / 1000000UL);
+        tv->tv_usec = (int)(tmpres % 1000000UL);
+
+        return 0;
+    }
+
+    return -1;
+}
+#endif
+
 uint64_t GetUtcTime()
 {
     /* 获取本地utc时间 */
@@ -79,7 +112,7 @@ uint64_t GetTodayUtcTime()
     tUTC->tm_sec = 0;
     uint64_t timestamp = (uint64_t)mktime(tUTC) * 1000;
 #else
-    uint64_t timestamp = (AppConfig::GetUtcTime() - tUTC->tm_hour * 3600000 - tUTC->tm_min * 60000 - tUTC->tm_sec * 1000);
+    uint64_t timestamp = (GetUtcTime() - tUTC->tm_hour * 3600000 - tUTC->tm_min * 60000 - tUTC->tm_sec * 1000);
 #endif
 
     return timestamp;
@@ -108,7 +141,13 @@ std::string getLocalTimeInStringFormat()
     struct timeval tv;
     char time_now[128] = {0};
     gettimeofday(&tv, NULL);
+
+#ifdef WIN32
+    time_t t = static_cast<time_t>(tv.tv_sec);
+    localtime_s(&nowtime, &t);
+#else
     localtime_r(&tv.tv_sec, &nowtime);
+#endif
 
     sprintf(time_now, "%4d%02d%02d%02d%02d%02d%03d",
             nowtime.tm_year + 1900,