Преглед изворни кода

V2.1.4

1.添加linux支持
huihui пре 5 година
родитељ
комит
6ccd0d813f

+ 8 - 0
README.md

@@ -83,3 +83,11 @@ Qt5.6.2(vs2013/mingw) + ffmpeg4.1 + SDL2
 1.修复上个版本加入FunctionTransfer类引起的播放器停止出现死锁,导致卡死的问题  
 1.修复上个版本加入FunctionTransfer类引起的播放器停止出现死锁,导致卡死的问题  
 2.修复部分电脑SDL打开失败的问题。  
 2.修复部分电脑SDL打开失败的问题。  
 3.修复部分音频文件播放快速播放完毕的问题。  
 3.修复部分音频文件播放快速播放完毕的问题。  
+
+【V2.1.4】 2019-10-24  
+Qt5.6.2(vs2013/mingw) + ffmpeg4.1 + SDL2  
+1.新增linux支持,程序可以在linux下直接编译使用了。 
+注: 
+1)程序代码使用的编码是gbk.  
+2)已经编译好的库为centos6.5(64位)下编译的,如需32位的库请自行编译。 
+

BIN
bin32/VideoPlayer.exe


BIN
bin32/VideoPlayer.pdb


+ 26 - 0
module/VideoPlayer/VideoPlayer.pri

@@ -46,4 +46,30 @@ win32{
 
 
 }
 }
 
 
+unix{
+    contains(QT_ARCH, i386) {
+        message("32-bit, 请自行编译32位库!")
+    } else {
+        message("64-bit")
+        INCLUDEPATH += $$PWD/lib/linux/ffmpeg/include \
+                       $$PWD/lib/linux/SDL2/include/SDL2 \
+                       $$PWD/src
+
+        LIBS += -L$$PWD/lib/linux/ffmpeg/lib  -lavformat  -lavcodec -lavdevice -lavfilter -lavutil -lswresample -lswscale
+        LIBS += -L$$PWD/lib/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")
+
+
+}
+
 
 

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


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


+ 7 - 2
module/VideoPlayer/src/VideoPlayer/VideoPlayer.cpp

@@ -6,7 +6,7 @@
 
 
 #include "VideoPlayer.h"
 #include "VideoPlayer.h"
 
 
-#include "audio/PcmVolumeControl.h"
+#include "Audio/PcmVolumeControl.h"
 
 
 #include <stdio.h>
 #include <stdio.h>
 
 
@@ -22,6 +22,8 @@ VideoPlayer::VideoPlayer()
     mAudioID = 0;
     mAudioID = 0;
     mIsMute = false;
     mIsMute = false;
 
 
+    mIsNeedPause = false;
+
     mVolume = 1;
     mVolume = 1;
 }
 }
 
 
@@ -53,6 +55,7 @@ bool VideoPlayer::startPlay(const std::string &filePath)
     }
     }
 
 
     mIsQuit = false;
     mIsQuit = false;
+    mIsPause = false;
 
 
     if (!filePath.empty())
     if (!filePath.empty())
         mFilePath = filePath;
         mFilePath = filePath;
@@ -98,6 +101,8 @@ bool VideoPlayer::play()
 
 
 bool VideoPlayer::pause()
 bool VideoPlayer::pause()
 {
 {
+    fprintf(stderr, "%s mIsPause=%d \n", __FUNCTION__, mIsPause);
+
     mIsPause = true;
     mIsPause = true;
 
 
     if (mPlayerState != VideoPlayer_Playing)
     if (mPlayerState != VideoPlayer_Playing)
@@ -428,7 +433,7 @@ void VideoPlayer::readVideoFile()
     doPlayerStateChanged(VideoPlayer_Playing, mVideoStream != nullptr, mAudioStream != nullptr);
     doPlayerStateChanged(VideoPlayer_Playing, mVideoStream != nullptr, mAudioStream != nullptr);
 
 
     mVideoStartTime = av_gettime();
     mVideoStartTime = av_gettime();
-fprintf(stderr, "%s mIsQuit=%d \n", __FUNCTION__, mIsQuit);
+fprintf(stderr, "%s mIsQuit=%d mIsPause=%d \n", __FUNCTION__, mIsQuit, mIsPause);
     while (1)
     while (1)
     {
     {
         if (mIsQuit)
         if (mIsQuit)

+ 5 - 8
module/VideoPlayer/src/main.cpp

@@ -8,19 +8,16 @@
 #include <QApplication>
 #include <QApplication>
 #include <QTextCodec>
 #include <QTextCodec>
 
 
-#include "videoplayer/VideoPlayerWidget.h"
+#include "VideoPlayer/VideoPlayer.h"
 
 
 #undef main
 #undef main
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
-    QApplication a(argc, argv);
+    VideoPlayer *mPlayer = new VideoPlayer();
+//    mPlayer->setVideoPlayerCallBack(this);
 
 
-    QTextCodec *codec = QTextCodec::codecForName("GBK");
-    QTextCodec::setCodecForLocale(codec);
+    mPlayer->startPlay("F:/test.rmvb");
 
 
-    VideoPlayerWidget w;
-    w.show();
-
-    return a.exec();
+    return 0;
 }
 }
 
 

+ 1 - 1
src/AppConfig.cpp

@@ -43,7 +43,7 @@ void Sleep(long mSeconds)
 
 
 QString AppConfig::APPID = "{a1db97ad-b8ed-11e9-a297-0235d2b38928}";
 QString AppConfig::APPID = "{a1db97ad-b8ed-11e9-a297-0235d2b38928}";
 int AppConfig::VERSION = 1;
 int AppConfig::VERSION = 1;
-QString AppConfig::VERSION_NAME = "2.1.3";
+QString AppConfig::VERSION_NAME = "2.1.4";
 
 
 MainWindow *AppConfig::gMainWindow = NULL;
 MainWindow *AppConfig::gMainWindow = NULL;
 QRect AppConfig::gMainWindowRect;
 QRect AppConfig::gMainWindowRect;

+ 1 - 1
src/MainWindow.cpp

@@ -33,7 +33,7 @@ MainWindow::MainWindow(QWidget *parent) :
     VideoPlayer::initPlayer();
     VideoPlayer::initPlayer();
 
 
     setWindowFlags(Qt::FramelessWindowHint);//|Qt::WindowStaysOnTopHint);  //使窗口的标题栏隐藏
     setWindowFlags(Qt::FramelessWindowHint);//|Qt::WindowStaysOnTopHint);  //使窗口的标题栏隐藏
-    setAttribute(Qt::WA_TranslucentBackground);
+//    setAttribute(Qt::WA_TranslucentBackground);
 
 
     //因为VideoPlayer::PlayerState是自定义的类型 要跨线程传递需要先注册一下
     //因为VideoPlayer::PlayerState是自定义的类型 要跨线程传递需要先注册一下
     qRegisterMetaType<VideoPlayerState>();
     qRegisterMetaType<VideoPlayerState>();