Quellcode durchsuchen

修复linux下编译问题

huihui vor 4 Monaten
Ursprung
Commit
865fea9b57

+ 5 - 1
CMakeLists.txt

@@ -139,8 +139,12 @@ include_directories(${PRO_CODE_INC})
 #         Qt5::Core Qt5::Widgets Qt5::Network Qt5::WebSockets Qt5::Concurrent
 #         core gui network sql concurrent xml axcontainer)
 
+if (WIN32)
+    target_link_libraries(${PROJECT_NAME}
+        WS2_32.lib AdvAPI32.lib winmm.lib User32.lib GDI32.lib Strmiids.lib)
+endif()
+
 target_link_libraries(${PROJECT_NAME}
-        WS2_32.lib AdvAPI32.lib winmm.lib User32.lib GDI32.lib Strmiids.lib
         Qt5::Core Qt5::Widgets Qt5::Network  Qt5::Concurrent)
 #target_link_libraries(${PROJECT_NAME}
 #        -lavformat

+ 4 - 1
module/VideoPlayer/lib/CMakeLists.txt

@@ -8,9 +8,12 @@ set(SDL2_BRANCH_NAME   "V2.0.2")
 
 if(UNIX)
     message("current platform: Linux ")
-    # set(FFMPEG_BRANCH_NAME "V4.3.1-Linux")
+    set(FFMPEG_BRANCH_NAME "V4.3.1-linux")
+    set(SDL2_BRANCH_NAME   "V2.0.12-linux")
 elseif(WIN32)
     message("current platform: Windows ")
+    set(FFMPEG_BRANCH_NAME "V4.3.1-windows")
+    set(SDL2_BRANCH_NAME   "V2.0.2-windows")
 endif() # WIN32
 
 ### 拉取用到的库文件 ###

+ 1 - 0
module/VideoPlayer/src/PcmPlayer/PcmPlayer.h

@@ -4,6 +4,7 @@
 #include <thread>
 #include <list>
 #include <mutex>
+#include <condition_variable>
 
 #include "frame/AudioFrame/PCMFrame.h"
 

+ 3 - 3
module/VideoPlayer/src/VideoPlayer/VideoPlayer.cpp

@@ -10,7 +10,7 @@
 
 #include <stdio.h>
 #include <iostream>
-#include <QDebug>
+
 VideoPlayer::VideoPlayer()
 {
     m_state = VideoPlayer::Stop;
@@ -126,7 +126,7 @@ bool VideoPlayer::pause()
 
     m_state = VideoPlayer::Pause;
 
-    emit doPlayerStateChanged(VideoPlayer::Pause, mVideoStream != nullptr, mAudioStream != nullptr);
+    doPlayerStateChanged(VideoPlayer::Pause, mVideoStream != nullptr, mAudioStream != nullptr);
 
     return true;
 }
@@ -644,7 +644,7 @@ std::cout<<" video:"<<pFormatCtx->streams[videoStream]->duration<<" "<<pFormatCt
         {
             mIsReadFinished = true;
             mIsReadError = true;
-qDebug("%s av_read_frame failed \n", __FUNCTION__);
+            printf("%s av_read_frame failed \n", __FUNCTION__);
 //            if (mIsQuit)
 //            {
 //                break; //解码线程也执行完了 可以退出了

+ 1 - 4
module/VideoPlayer/src/VideoPlayer/VideoPlayer.h

@@ -7,9 +7,6 @@
 #ifndef VIDEOPLAYER_H
 #define VIDEOPLAYER_H
 
-#include <QObject>
-#include <QImage>
-
 #include <thread>
 
 extern "C"
@@ -58,7 +55,7 @@ extern "C"
  * 播放器类,纯c++实现,方便移植,与界面的交互通过回调函数的方式实现
  */
 
-class VideoPlayer : public Thread
+class VideoPlayer : public Util::Thread
 {
 public:
     enum State

+ 1 - 1
module/VideoPlayer/src/VideoPlayer/VideoPlayer_VideoThread.cpp

@@ -293,7 +293,7 @@ void VideoPlayer::decodeVideoThread()
 
         if (avcodec_send_packet(pCodecCtx, pkt) != 0)
         {
-           qDebug("input AVPacket to decoder failed!\n");
+           printf("input AVPacket to decoder failed!\n");
            av_packet_unref(pkt);
            continue;
         }

+ 2 - 1
module/VideoPlayer/src/util/thread.cpp

@@ -3,7 +3,7 @@
 #include <stdio.h>
 
 using namespace std;
-
+namespace Util {
 Thread::Thread()
     : m_thread(nullptr),
       m_is_pause(false),
@@ -161,3 +161,4 @@ void Thread::threadFunc()
     
     // cout << "exit thread:" << this_thread::get_id() << endl;
 }
+}

+ 5 - 0
module/VideoPlayer/src/util/thread.h

@@ -3,9 +3,12 @@
 
 #include <thread>
 #include <atomic>
+#include <functional>
 #include <mutex>
 #include <condition_variable>
 
+namespace Util {
+
 class Thread
 {
 public:
@@ -62,4 +65,6 @@ protected:
 
 };
 
+}
+
 #endif // THREAD_H