Commit 42204746 authored by Silas Della Contrada's avatar Silas Della Contrada
Browse files

Added basic windows compilation support and rewrote Qt library detection in AVQt/CMakeLists.txt

parent a54119cf
......@@ -20,7 +20,7 @@
#include "filter/DecoderMMAL.h"
#include "filter/EncoderVAAPI.h"
#elif Q_OS_WIN
#elif defined(Q_OS_WIN)
#include "filter/DecoderDXVA2.h"
......@@ -29,4 +29,4 @@
#include "filter/AudioDecoder.h"
#include "filter/DecoderQSV.h"
#include "filter/EncoderQSV.h"
//#include "output/FrameFileSaver.h"
\ No newline at end of file
//#include "output/FrameFileSaver.h"
......@@ -9,6 +9,8 @@ set(CMAKE_AUTOUIC on)
set(CMAKE_INCLUDE_CURRENT_DIR on)
include_directories(F:\\Dev\\mfx_dispatch-master)
#find_package(Qt6 COMPONENTS Core Gui Concurrent Widgets OpenGL OpenGLWidgets)
find_package(Qt5 COMPONENTS Core Gui Concurrent Widgets OpenGL)
......@@ -198,9 +200,9 @@ target_link_libraries(AVQt Qt5::Core Qt5::Gui Qt5::Concurrent Qt5::Widgets Qt5::
target_link_libraries(AVQtStatic Qt5::Core Qt5::Gui Qt5::Concurrent Qt5::Widgets Qt5::OpenGL avformat avfilter avutil avcodec avdevice swscale swresample)
if (WIN32)
target_link_libraries(AVQt opengl32 OpenAL32)
target_link_libraries(AVQtStatic opengl32 OpenAL32)
target_link_libraries(AVQt opengl32 OpenAL32 d3d9 windowsapp user32 kernel32 Dwmapi psapi d3d9 dxguid)
target_link_libraries(AVQtStatic opengl32 OpenAL32 windowsapp user32 kernel32 Dwmapi psapi d3d9 dxguid)
else ()
target_link_libraries(AVQt GL openal EGL GLU va)
target_link_libraries(AVQtStatic GL openal EGL GLU va)
endif ()
\ No newline at end of file
endif ()
#SET(CMAKE_INSTALL_RPATH "$ORIGIN/../AVQt")
#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH on)
#find_package(Qt6 COMPONENTS Core Gui Widgets OpenGL OpenGLWidgets Concurrent)
function(list_transform_prepend var_out var_in prefix)
set(temp "")
foreach (f ${${var_in}})
list(APPEND temp "${prefix}${f}")
endforeach ()
set(${var_out} "${temp}" PARENT_SCOPE)
endfunction()
set(CMAKE_CXX_STANDARD 20)
find_package(Qt5 COMPONENTS Core Gui Widgets OpenGL Concurrent)
find_package(OpenAL)
set(PROJECT_NAME Player)
add_executable(${PROJECT_NAME} main.cpp)
#add_compile_options(-fsanitize=address)
#add_link_options(-fsanitize=address)
set(QT_VERSION "5")
set(CMAKE_PREFIX_PATH F:\\Dev\\Qt\\5.15.2\\msvc2019_64\\lib\\cmake)
add_compile_definitions(ENABLE_QSV_ENCODE)
set(REQUIRED_LIBS Core Gui Concurrent Widgets OpenGL)
if (QT_VERSION EQUAL "6")
LIST(APPEND REQUIRED_LIBS OpenGLWidgets)
endif ()
set(REQUIRED_LIBS_QUALIFIED)
list_transform_prepend(REQUIRED_LIBS_QUALIFIED REQUIRED_LIBS "Qt${QT_VERSION}::")
message("${REQUIRED_LIBS_QUALIFIED}")
add_executable(Player main.cpp)
find_package(Qt${QT_VERSION} COMPONENTS ${REQUIRED_LIBS} REQUIRED)
target_link_libraries(${PROJECT_NAME} ${REQUIRED_LIBS_QUALIFIED})
if (WIN32)
set(DEBUG_SUFFIX)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(DEBUG_SUFFIX "d")
endif ()
set(QT_INSTALL_PATH "${CMAKE_PREFIX_PATH}")
if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
set(QT_INSTALL_PATH "${QT_INSTALL_PATH}/..")
if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
set(QT_INSTALL_PATH "${QT_INSTALL_PATH}/..")
endif ()
endif ()
if (EXISTS "${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
endif ()
foreach (QT_LIB ${REQUIRED_LIBS})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/bin/Qt${QT_VERSION}${QT_LIB}${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>")
endforeach (QT_LIB)
endif ()
#target_link_libraries(Player Qt6::Core Qt6::Gui Qt6::Concurrent Qt6::Widgets Qt6::OpenGLWidgets Qt6::OpenGL avformat avfilter avutil avcodec avdevice swscale swresample AVQtStatic)
target_link_libraries(Player Qt5::Core Qt5::Gui Qt5::Concurrent Qt5::Widgets Qt5::OpenGL avformat avfilter avutil avcodec avdevice swscale swresample AVQtStatic)
#target_link_libraries(Player Qt6::Core Qt6::Gui Qt6::Concurrent Qt6::Widgets Qt6::OpenGLWidgets Qt6::OpenGL avformat avfilter avutil avcodec avdevice swscale swresample AVQt)
target_link_libraries(Player avformat avfilter avutil avcodec avdevice swscale swresample AVQt)
find_package(OpenAL)
if (LINUX)
target_link_libraries(Player openal GL EGL GLU va)
elseif (WIN32)
target_link_libraries(Player OpenAL32 opengl32)
target_link_libraries(Player OpenAL32 opengl32 dxguid d3d9)
endif ()
\ No newline at end of file
......@@ -40,7 +40,6 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
}
int main(int argc, char *argv[]) {
QGuiApplication::setAttribute(Qt::AA_UseOpenGLES);
app = new QApplication(argc, argv);
signal(SIGINT, &signalHandler);
signal(SIGTERM, &signalHandler);
......@@ -64,11 +63,11 @@ int main(int argc, char *argv[]) {
inputFile->open(QIODevice::ReadWrite);
AVQt::Demuxer demuxer(inputFile);
AVQt::AudioDecoder decoder;
AVQt::OpenALAudioOutput output;
// AVQt::AudioDecoder decoder;
// AVQt::OpenALAudioOutput output;
demuxer.registerCallback(&decoder, AVQt::IPacketSource::CB_AUDIO);
decoder.registerCallback(&output);
// demuxer.registerCallback(&decoder, AVQt::IPacketSource::CB_AUDIO);
// decoder.registerCallback(&output);
AVQt::IDecoder *videoDecoder;
AVQt::IEncoder *videoEncoder;
......@@ -77,6 +76,7 @@ int main(int argc, char *argv[]) {
videoEncoder = new AVQt::EncoderQSV(AVQt::IEncoder::CODEC::HEVC, 10 * 1000 * 1000);
#elif defined(Q_OS_WINDOWS)
videoDecoder = new AVQt::DecoderDXVA2();
videoEncoder = new AVQt::EncoderQSV(AVQt::IEncoder::CODEC::HEVC, 10 * 1000 * 1000);
#else
#error "Unsupported OS"
#endif
......@@ -84,7 +84,7 @@ int main(int argc, char *argv[]) {
demuxer.registerCallback(videoDecoder, AVQt::IPacketSource::CB_VIDEO);
#ifdef ENABLE_QSV_ENCODE
videoDecoder->registerCallback(videoEncoder);
// videoDecoder->registerCallback(videoEncoder);
#endif
QFile outputFile("output.mp4");
outputFile.open(QIODevice::ReadWrite | QIODevice::Truncate);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment