diff --git a/.gitignore b/.gitignore index c86b117d..f8f71813 100644 --- a/.gitignore +++ b/.gitignore @@ -88,3 +88,4 @@ compile_commands.json CTestTestfile.cmake _deps .cmake/** +/Common/ffmpeg/* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 371e81b6..c9514608 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,7 +26,16 @@ build:windows: paths: - Common\vcpkg\ script: - - .\install_dependencies_windows.bat + - git submodule update --init + - git submodule update --recursive + - cd Common + - if (!(Test-Path "vcpkg")){git clone https://github.com/microsoft/vcpkg.git} + - cd vcpkg + - git pull | git checkout 18ab4b72a26284f0df28295ce7bf9b21c96f20f4 + - call bootstrap-vcpkg.bat + - vcpkg.exe install openssl --triplet x64-windows --recurse + - cd .. + - cd .. - mkdir BUILD_WINDOWS - cd BUILD_WINDOWS - cmake.exe ../ -DCMAKE_PREFIX_PATH=c:/Qt/5.15.1/msvc2019 -DCMAKE_IGNORE_PATH=C:/Strawberry/c/bin -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE="$(Get-Location)/../Common/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET=x64-windows "-GCodeBlocks - Ninja" -B. diff --git a/Docs/DeveloperSetup.md b/Docs/DeveloperSetup.md index f5110748..181d089d 100644 --- a/Docs/DeveloperSetup.md +++ b/Docs/DeveloperSetup.md @@ -4,7 +4,7 @@ ``` bash git clone --recursive https://gitlab.com/kelteseth/ScreenPlay.git ``` -3. Download the latest [__Qt 5.14__](https://www.qt.io/download-qt-installer). Earlier versions are not supported! +3. Download the latest [__Qt 5.15__](https://www.qt.io/download-qt-installer). Earlier versions are not supported! 4. Start install-dependencies.bat to download dependencies into the Common/ folder ``` bash //Windows @@ -16,15 +16,11 @@ chmod +x install-dependencies.sh .\install-dependencies.sh ``` * This will install these dependencies via __vcpkg__ - * libzippp - * nlohmann-json * openSSL 1.1.1d - * zlib& libzip - * breakpad + * sentry-native * Download these dependencies via __git submodules__ - * stomt-qt-sdk * qt-google-analytics - * qt-breakpad + * Download ffmpeg binaries 5. **Follow the steps below for your OS**. 6. Open the CMakeLists.txt via QtCreator. **This can take some time until QtCreator parses all files!** @@ -52,7 +48,7 @@ chmod +x install-dependencies.sh 2. [Download and install Qt 5 binary installer from qt.io](https://www.qt.io/download-qt-installer) - Install the Maintaince tool - Select the following features to install: - - Qt 5.14.2 + - Qt 5.15.2 - MSVC 2017 64-bit - Qt WebEngine - Developer and Designer Tools @@ -75,14 +71,14 @@ sudo zypper install -t pattern devel_basis 2. [Download and install Qt 5 binary installer from qt.io](https://www.qt.io/download-qt-installer) - Install the Maintaince tool - Select the following features to install: - - Qt 5.14.2 + - Qt 5.15.2 - GCC - Qt WebEngine ### OSX 1. [Download and install Qt 5 binary installer from qt.io](https://www.qt.io/download-qt-installer) - Install the Maintaince tool - Select the following features to install: - - Qt 5.14.2 + - Qt 5.15.2 - Qt WebEngine - Developer and Designer Tools - OpenSSL 1.1.1.c Toolkit diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index cde78505..c437f89c 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -18,13 +18,9 @@ find_package( LinguistTools REQUIRED) -find_package(ZLIB REQUIRED) find_package(OpenSSL REQUIRED) -find_package(libzippp CONFIG REQUIRED) find_package(sentry CONFIG REQUIRED) - - set(src main.cpp app.cpp ../Common/qt-google-analytics/ganalytics.cpp @@ -87,12 +83,13 @@ add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml}) if(WIN32) # Icon target_sources(${PROJECT_NAME} PRIVATE ScreenPlay.rc) + + # Disable console window on Windows + # https://stackoverflow.com/questions/8249028/how-do-i-keep-my-qt-c-program-from-opening-a-console-in-windows + set_property(TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE true) endif() -# Disable console window on Windows -# https://stackoverflow.com/questions/8249028/how-do-i-keep-my-qt-c-program-from-opening-a-console-in-windows -set_property(TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE true) target_compile_definitions(${PROJECT_NAME} PRIVATE "GIT_VERSION=${GIT_VERSION}") @@ -103,7 +100,6 @@ target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Core Qt5::WebEngine - libzippp::libzippp sentry::sentry ScreenPlaySDK ) @@ -115,8 +111,12 @@ target_include_directories(${PROJECT_NAME} file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/assets/fonts) configure_file(assets/fonts/NotoSansCJKkr-Regular.otf ${CMAKE_BINARY_DIR}/bin/assets/fonts COPYONLY) +# Copy ffmpeg. If the ffmpeg files are missing, start the +# install_dependencies_XXX for your system! if(WIN32) - configure_file(${VCPKG_TOOLS_PATH}/sentry-native/crashpad_handler.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffmpeg.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY) else() - configure_file(${VCPKG_TOOLS_PATH}/sentry-native/crashpad_handler ${CMAKE_BINARY_DIR}/bin/ COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffmpeg ${CMAKE_BINARY_DIR}/bin/ COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe ${CMAKE_BINARY_DIR}/bin/ COPYONLY) endif() diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index 0153e492..f32519ea 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -47,7 +47,7 @@ App::App() QGuiApplication::setOrganizationName("ScreenPlay"); QGuiApplication::setOrganizationDomain("screen-play.app"); QGuiApplication::setApplicationName("ScreenPlay"); - QGuiApplication::setApplicationVersion("0.12.0"); + QGuiApplication::setApplicationVersion("0.12.1"); QGuiApplication::setQuitOnLastWindowClosed(false); QFontDatabase::addApplicationFont(":/assets/fonts/LibreBaskerville-Italic.ttf"); diff --git a/ScreenPlay/main.qml b/ScreenPlay/main.qml index 5e62d069..84e1def1 100644 --- a/ScreenPlay/main.qml +++ b/ScreenPlay/main.qml @@ -28,7 +28,7 @@ ApplicationWindow { visible: false width: 1400 height: 788 - title: "ScreenPlay Alpha - V0.12.0" + title: "ScreenPlay Alpha - V0.12.1" minimumHeight: 450 minimumWidth: 1050 onVisibilityChanged: { @@ -96,7 +96,6 @@ ApplicationWindow { pageLoaderCreate.visible = true pageLoaderWorkshop.visible = false pageLoaderCreate.setSource("qrc:/qml/Create/Create.qml") - pageLoaderCreate.item.checkFFMPEG() } else if (name === "Workshop") { if (ScreenPlay.settings.steamVersion) { diff --git a/ScreenPlay/qml.qrc b/ScreenPlay/qml.qrc index 080561c1..9651dd86 100644 --- a/ScreenPlay/qml.qrc +++ b/ScreenPlay/qml.qrc @@ -7,7 +7,6 @@ qml/Create/CreateContentButton.qml qml/Create/Wizards/CreateWallpaper/CreateWallpaperVideoImportConvert.qml qml/Create/Wizards/CreateWallpaper/CreateWallpaperResult.qml - qml/Create/FFMPEGPopup.qml qml/Create/Wizard.qml qml/Create/Wizards/CreateEmptyWidget/CreateEmptyWidget.qml qml/Create/Footer.qml diff --git a/ScreenPlay/qml/Community/Community.qml b/ScreenPlay/qml/Community/Community.qml index 28e79c23..5dc4b958 100644 --- a/ScreenPlay/qml/Community/Community.qml +++ b/ScreenPlay/qml/Community/Community.qml @@ -57,7 +57,6 @@ Item { icon.source: "qrc:/assets/icons/icon_supervisor_account.svg" } CommunityNavItem { - enabled: false text: qsTr("Steam Workshop") openLink: "steam://url/GameHub/672870" icon.source: "qrc:/assets/icons/icon_steam.svg" diff --git a/ScreenPlay/qml/Create/Create.qml b/ScreenPlay/qml/Create/Create.qml index 31d160a5..e8818448 100644 --- a/ScreenPlay/qml/Create/Create.qml +++ b/ScreenPlay/qml/Create/Create.qml @@ -19,20 +19,6 @@ Item { create.state = "in" } - function checkFFMPEG() { - if (!ScreenPlay.util.ffmpegAvailable) { - ffmpegPopup.open() - } - } - - FFMPEGPopup { - id: ffmpegPopup - anchors.centerIn: create - closePolicy: Popup.NoAutoClose - focus: true - modal: true - parent: create - } BackgroundParticleSystem { id: particleSystemWrapper diff --git a/ScreenPlay/qml/Create/FFMPEGPopup.qml b/ScreenPlay/qml/Create/FFMPEGPopup.qml deleted file mode 100644 index e0821fc3..00000000 --- a/ScreenPlay/qml/Create/FFMPEGPopup.qml +++ /dev/null @@ -1,389 +0,0 @@ -import QtQuick 2.12 -import QtQuick.Layouts 1.12 -import QtQuick.Controls 2.12 -import QtQuick.Controls.Material 2.12 -import QtQuick.Particles 2.0 -import QtGraphicalEffects 1.0 - -import ScreenPlay 1.0 -import ScreenPlay.Create 1.0 -import ScreenPlay.QMLUtilities 1.0 - -import "Wizards/CreateWallpaper" - -Popup { - id: ffmpegPopup - height: 600 - padding: 30 - width: 900 - background: Rectangle { - anchors.fill: parent - color: Material.theme === Material.Light ? "white" : Material.background - } - - Connections { - target: ScreenPlay.util - - function onAquireFFMPEGStatusChanged(aquireFFMPEGStatus) { - - switch (aquireFFMPEGStatus) { - case QMLUtilities.Init: - break - case QMLUtilities.Download: - btnNotNow.enabled = false - btnDownload.enabled = false - busyIndicator.running = true - txtStatus.text = qsTr("Begin downloading FFMPEG") - break - case QMLUtilities.DownloadFailed: - btnNotNow.enabled = true - txtStatus.text = qsTr("FFMPEG download failed") - busyIndicator.running = false - break - case QMLUtilities.DownloadSuccessful: - txtStatus.text = qsTr("FFMPEG download successful") - break - case QMLUtilities.Extracting: - txtStatus.text = qsTr("Extracting FFMPEG") - break - case QMLUtilities.ExtractingFailedReadFromBuffer: - btnNotNow.enabled = true - txtStatus.text = qsTr("ERROR extracting ffmpeg from RAM") - busyIndicator.running = false - break - case QMLUtilities.ExtractingFailedFFMPEG: - btnNotNow.enabled = true - txtStatus.text = qsTr("ERROR extracing ffmpeg") - busyIndicator.running = false - break - case QMLUtilities.ExtractingFailedFFMPEGSave: - btnNotNow.enabled = true - txtStatus.text = qsTr("ERROR saving FFMPEG to disk") - busyIndicator.running = false - break - case QMLUtilities.ExtractingFailedFFPROBE: - btnNotNow.enabled = true - txtStatus.text = qsTr("ERROR extracing FFPROBE") - busyIndicator.running = false - break - case QMLUtilities.ExtractingFailedFFPROBESave: - btnNotNow.enabled = true - txtStatus.text = qsTr("ERROR saving FFPROBE to disk") - busyIndicator.running = false - break - case QMLUtilities.ExtractingSuccessful: - txtStatus.text = qsTr("Extraction successful") - break - case QMLUtilities.FinishedSuccessful: - txtStatus.text = qsTr("All done and ready to go!") - busyIndicator.running = false - column.state = "finishedSuccessful" - ScreenPlay.util.setFfmpegAvailable(true) - break - } - } - } - - Popup { - id: closeDialog - width: 400 - height: 250 - background: Rectangle { - anchors.fill: parent - color: Material.theme === Material.Light ? "white" : Material.background - } - Text { - text: qsTr("You cannot create Wallaper without FFMPEG installed!") - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - font.pointSize: 16 - height: 50 - font.family: ScreenPlay.settings.font - anchors.fill: parent - anchors.margins: 50 - wrapMode: Text.WordWrap - color: Material.color(Material.Orange) - } - RowLayout { - height: 30 - anchors { - right: parent.right - bottom: parent.bottom - left: parent.left - margins: 20 - } - - Button { - text: qsTr("Abort") - onClicked: { - ffmpegPopup.close() - closeDialog.close() - ScreenPlay.util.setNavigation("Installed") - } - - Layout.alignment: Qt.AlignRight - } - Button { - text: qsTr("Download FFMPEG") - highlighted: true - onClicked: closeDialog.close() - Layout.alignment: Qt.AlignRight - } - } - - anchors.centerIn: Overlay.overlay - - closePolicy: Popup.NoAutoClose - focus: true - modal: true - } - - ColumnLayout { - id: column - anchors.fill: parent - - Text { - id: txtDownloadFFMPEG - text: qsTr("Before we can start creating content you need to download FFMPEG") - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - font.pointSize: 16 - Layout.fillWidth: true - Layout.preferredHeight: 60 - color: Material.foreground - font.family: ScreenPlay.settings.font - } - - Item { - Layout.fillHeight: true - Layout.fillWidth: true - - Item { - width: parent.width * .33 - anchors { - top: parent.top - bottom: parent.bottom - left: parent.left - } - - Image { - id: imgFFMPEGLogo - source: "qrc:/assets/images/FFmpeg_Logo_new.svg" - width: sourceSize.width - height: sourceSize.height - anchors { - horizontalCenter: parent.horizontalCenter - margins: 20 - top: parent.top - } - } - - BusyIndicator { - id: busyIndicator - anchors.centerIn: parent - running: false - } - - Text { - id: txtStatus - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - font.pointSize: 14 - height: 50 - Layout.fillWidth: true - color: Material.color(Material.Orange) - font.family: ScreenPlay.settings.font - wrapMode: Text.WordWrap - anchors { - top: busyIndicator.bottom - topMargin: 20 - right: parent.right - left: parent.left - } - } - } - - Page { - width: parent.width * .66 - background: Rectangle { - anchors.fill: parent - color: Material.theme === Material.Light ? Material.background : Qt.darker( - Material.background) - radius: 3 - } - padding: 10 - - anchors { - top: parent.top - bottom: parent.bottom - right: parent.right - } - - Flickable { - anchors.fill: parent - clip: true - contentHeight: txtExpander.paintedHeight + 100 - contentWidth: parent.width - ScrollBar.vertical: ScrollBar { - snapMode: ScrollBar.SnapOnRelease - policy: ScrollBar.AlwaysOn - } - - MouseArea { - anchors.fill: parent - id: maHoverEffect - } - - Text { - id: txtExpander - anchors { - fill: parent - margins: 30 - leftMargin: 0 - } - color: Material.foreground - - height: txtExpander.paintedHeight - wrapMode: Text.WordWrap - font.pointSize: 12 - font.family: ScreenPlay.settings.font - onLinkHovered: maHoverEffect.cursorShape = Qt.PointingHandCursor - onLinkActivated: Qt.openUrlExternally(link) - linkColor: Material.color(Material.LightBlue) - text: qsTr("Why do we bother you with this? -

Well its because of copyright and many many patents. -" + "Files like .mp4 or .webm are containers for video and audio. Every audio -" + "and video file is encoded with a certain codec. These can be open source -" + "and free to use like VP8 and the newer VP9 (the one YouTube uses for their webms) -" + "but there are also some proprietary ones like h264 and the successor h265." + " -
-
-" + "\n\n We as software developer now need to deal with stuff like this in a field we -" + "do not have any expertise in. The desicion to enable only free codecs for content was -" + "an easy one but we still need to provide a way for our user to import wallpaper -" + "without a hassle. We do not provide FFMPEG for -" + "converting video and audio with ScreenPlay because we are not allowed to. We let the user download FFMPEG which -" + "is perfectly fine! -
-Sorry for this little inconvenience :)" + " -
-
-
- -IF YOU DO NOT HAVE AN INTERNET CONNECT YOU CAN SIMPLY PUT FFMPEG AND FFPROBE -IN THE SAME FOLDER AS YOUR SCREENPLAY EXECUTABLE! - -
-
-This is usually: -
C:\\Program Files (x86)\\Steam\\steamapps\\common\\ScreenPlay -
-if you installed ScreenPlay via Steam! -
-
-
-" + "~ Kelteseth | Elias Steurer") - } - } - } - } - - RowLayout { - spacing: 20 - Layout.fillWidth: true - Layout.alignment: Qt.AlignBottom - Button { - id: btnDownload - text: qsTr("Download FFMPEG") - onClicked: ScreenPlay.util.downloadFFMPEG() - highlighted: true - Layout.fillWidth: true - } - Button { - id: btnNotNow - text: qsTr("Not now!") - onClicked: closeDialog.open() - Layout.fillWidth: true - } - } - - states: [ - State { - name: "finishedSuccessful" - PropertyChanges { - target: column - opacity: 0 - enabled: false - } - PropertyChanges { - target: successWrapper - opacity: 1 - enabled: true - } - } - ] - - transitions: [ - Transition { - from: "*" - to: "finishedSuccessful" - PropertyAnimation { - target: successWrapper - property: "opacity" - duration: 250 - } - } - ] - } - Item { - id: successWrapper - anchors.fill: parent - anchors.margins: 30 - opacity: 0 - enabled: false - - Text { - id: txtDownloadFFMPEGComplete - text: qsTr("You can now start creating content!") - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - font.pointSize: 16 - height: 50 - Layout.fillWidth: true - color: Material.foreground - font.family: ScreenPlay.settings.font - anchors { - horizontalCenter: parent.horizontalCenter - top: parent.top - topMargin: 30 - } - } - - Image { - id: imgOk - fillMode: Image.PreserveAspectFit - source: "qrc:/assets/icons/icon_done.svg" - width: 180 - height: width - sourceSize: Qt.size(width, width) - anchors.centerIn: parent - smooth: true - } - ColorOverlay { - anchors.fill: imgOk - source: imgOk - color: Material.color(Material.LightGreen) - } - - Button { - text: qsTr("Start!") - highlighted: true - onClicked: ffmpegPopup.close() - anchors { - horizontalCenter: parent.horizontalCenter - top: imgOk.bottom - margins: 30 - } - } - } -} diff --git a/ScreenPlay/qml/Create/ImportContent.qml b/ScreenPlay/qml/Create/ImportContent.qml index cb09cefc..e2194d8a 100644 --- a/ScreenPlay/qml/Create/ImportContent.qml +++ b/ScreenPlay/qml/Create/ImportContent.qml @@ -72,7 +72,7 @@ Item { } Button { - text: ScreenPlay.util.ffmpegAvailable ? qsTr("Import video") : qsTr("FFMPEG Needed for import") + text: qsTr("Import video") anchors { horizontalCenter: parent.horizontalCenter bottom: parent.bottom @@ -84,7 +84,6 @@ Item { icon.color: "white" icon.width: 16 font.family: ScreenPlay.settings.font - enabled: ScreenPlay.util.ffmpegAvailable icon.height: 16 onClicked: fileDialogImportVideo.open() } diff --git a/ScreenPlay/qml/Installed/Installed.qml b/ScreenPlay/qml/Installed/Installed.qml index e4b981b2..32e39f17 100644 --- a/ScreenPlay/qml/Installed/Installed.qml +++ b/ScreenPlay/qml/Installed/Installed.qml @@ -82,6 +82,7 @@ Item { cellHeight: 200 cacheBuffer: 160 interactive: pageInstalled.enabled + snapMode: GridView.SnapToRow anchors { topMargin: 0 rightMargin: 0 @@ -209,7 +210,8 @@ Item { text: qsTr("Open containing folder") icon.source: "qrc:/assets/icons/icon_folder_open.svg" onClicked: { - ScreenPlay.util.openFolderInExplorer(contextMenu.absoluteStoragePath) + ScreenPlay.util.openFolderInExplorer( + contextMenu.absoluteStoragePath) } } MenuItem { diff --git a/ScreenPlay/qml/Installed/InstalledWelcomeScreen.qml b/ScreenPlay/qml/Installed/InstalledWelcomeScreen.qml index 94df7186..7a7a62c8 100644 --- a/ScreenPlay/qml/Installed/InstalledWelcomeScreen.qml +++ b/ScreenPlay/qml/Installed/InstalledWelcomeScreen.qml @@ -82,7 +82,7 @@ Item { Button { id: btnWorkshop text: qsTr("Browse the Steam Workshop") - Material.background: Material.Blue + Material.background: Material.color(Material.Green) Material.foreground: "white" smooth: true font.pointSize: 18 diff --git a/ScreenPlay/src/sdkconnection.cpp b/ScreenPlay/src/sdkconnection.cpp index d320475f..21fd4f41 100644 --- a/ScreenPlay/src/sdkconnection.cpp +++ b/ScreenPlay/src/sdkconnection.cpp @@ -8,17 +8,6 @@ ScreenPlay::SDKConnection::SDKConnection(QLocalSocket* socket, QObject* parent) connect(m_socket, &QLocalSocket::readyRead, this, &SDKConnection::readyRead); } -ScreenPlay::SDKConnection::~SDKConnection() -{ - - // We need to call this manually because - // sometimes it wont close the connection in - // the descructor - m_socket->disconnect(); - m_socket->disconnectFromServer(); - m_socket->close(); -} - void ScreenPlay::SDKConnection::readyRead() { diff --git a/ScreenPlay/src/sdkconnection.h b/ScreenPlay/src/sdkconnection.h index d966d9e7..804777b4 100644 --- a/ScreenPlay/src/sdkconnection.h +++ b/ScreenPlay/src/sdkconnection.h @@ -69,7 +69,6 @@ public: SDKConnection. */ explicit SDKConnection(QLocalSocket* socket, QObject* parent = nullptr); - ~SDKConnection(); QString appID() const { diff --git a/ScreenPlay/src/util.cpp b/ScreenPlay/src/util.cpp index 2f987f18..1b00287a 100644 --- a/ScreenPlay/src/util.cpp +++ b/ScreenPlay/src/util.cpp @@ -16,7 +16,9 @@ Util::Util(QNetworkAccessManager* networkAccessManager, QObject* parent) , m_networkAccessManager { networkAccessManager } { utilPointer = this; - qRegisterMetaType(); + // Fix log access vilation on quit + QObject::connect(QGuiApplication::instance(), &QGuiApplication::aboutToQuit, this, []() { utilPointer = nullptr; }); + qmlRegisterUncreatableType("ScreenPlay.QMLUtilities", 1, 0, "QMLUtilities", "Error only for enums"); // In release mode redirect messages to logging otherwhise we break the nice clickable output :( @@ -27,21 +29,6 @@ Util::Util(QNetworkAccessManager* networkAccessManager, QObject* parent) // This gives us nice clickable output in QtCreator qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}\n Loc: [%{file}:%{line}]"); - - QString path = QApplication::instance()->applicationDirPath() + "/"; - QFile fileFFMPEG; - QFile fileFFPROBE; - -#ifdef Q_OS_WIN - fileFFMPEG.setFileName(path + "ffmpeg.exe"); - fileFFPROBE.setFileName(path + "ffprobe.exe"); -#else - fileFFMPEG.setFileName(path + "ffmpeg"); - fileFFPROBE.setFileName(path + "ffprobe"); -#endif - - if (fileFFMPEG.exists() && fileFFPROBE.exists()) - setFfmpegAvailable(true); } /*! @@ -289,94 +276,6 @@ void Util::Util::requestDataProtection() }); } -/*! - \brief Downloads and extracts ffmpeg static version from https://ffmpeg.zeranoe.com - The progress is tracked via setAquireFFMPEGStatus(AquireFFMPEGStatus); -*/ -void Util::downloadFFMPEG() -{ - QNetworkRequest req; - QString ffmpegVersion { "ffmpeg-4.3.1" }; - -#ifdef Q_OS_WIN - req.setUrl(QUrl("https://ffmpeg.zeranoe.com/builds/win64/static/" + ffmpegVersion + "-win64-static.zip")); -#elif defined(Q_OS_OSX) - req.setUrl(QUrl("https://ffmpeg.zeranoe.com/builds/macos64/static/" + ffmpegVersion + "-macos64-static.zip")); -#endif - setAquireFFMPEGStatus(AquireFFMPEGStatus::Download); - - QNetworkReply* reply = m_networkAccessManager->get(req); - QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, ffmpegVersion]() { - using namespace libzippp; - using namespace std; - - setAquireFFMPEGStatus(AquireFFMPEGStatus::DownloadSuccessful); - - QByteArray download = reply->readAll(); - - auto* archive = ZipArchive::fromBuffer(download.data(), download.size(), ZipArchive::OpenMode::READ_ONLY, true); - - if (archive == nullptr) { - setAquireFFMPEGStatus(AquireFFMPEGStatus::ExtractingFailedReadFromBuffer); - return; - } - - string path = QApplication::instance()->applicationDirPath().toStdString() + "/"; - - ZipEntry entryFFMPEG; - std::string entryFFMPEGPath; -#ifdef Q_OS_WIN - entryFFMPEG = archive->getEntry(ffmpegVersion.toStdString() + "-win64-static/bin/ffmpeg.exe"); - entryFFMPEGPath = path + "ffmpeg.exe"; -#elif defined(Q_OS_OSX) - entryFFMPEG = archive->getEntry(ffmpegVersion.toStdString() +"-macos64-static/bin/ffmpeg"); - entryFFMPEGPath = path + "ffmpeg"; -#endif - - if (entryFFMPEG.isNull()) { - qDebug() << "entryFFMPEG is null. No more entry is available."; - qDebug() << "Download size was: " << download.size() << "bytes"; - - setAquireFFMPEGStatus(AquireFFMPEGStatus::ExtractingFailedFFMPEG); - return; - } - - if (!saveExtractedByteArray(entryFFMPEG, entryFFMPEGPath)) { - qDebug() << "could not save ffmpeg"; - setAquireFFMPEGStatus(AquireFFMPEGStatus::ExtractingFailedFFMPEGSave); - return; - } - - ZipEntry entryFFPROBE; - std::string entryFFPROBEPath; -#ifdef Q_OS_WIN - entryFFPROBE = archive->getEntry(ffmpegVersion.toStdString() + "-win64-static/bin/ffprobe.exe"); - entryFFPROBEPath = path + "ffprobe.exe"; -#elif defined(Q_OS_OSX) - entryFFPROBE = archive->getEntry(ffmpegVersion.toStdString() +"-macos64-static/bin/ffprobe"); - entryFFPROBEPath = path + "ffprobe"; -#endif - if (entryFFPROBE.isNull()) { - qDebug() << "null"; - setAquireFFMPEGStatus(AquireFFMPEGStatus::ExtractingFailedFFPROBE); - return; - } - - if (!saveExtractedByteArray(entryFFPROBE, entryFFPROBEPath)) { - qDebug() << "could not save ffprobe"; - setAquireFFMPEGStatus(AquireFFMPEGStatus::ExtractingFailedFFPROBESave); - return; - } - - setAquireFFMPEGStatus(AquireFFMPEGStatus::FinishedSuccessful); - }); - - QObject::connect(reply, QOverload::of(&QNetworkReply::error), - [this](QNetworkReply::NetworkError code) { - this->setAquireFFMPEGStatus(AquireFFMPEGStatus::DownloadFailed); - }); -} - SearchType::SearchType Util::getSearchTypeFromInstalledType(const InstalledType::InstalledType type) { using InstalledType::InstalledType; @@ -464,26 +363,4 @@ void Util::logToGui(QtMsgType type, const QMessageLogContext& context, const QSt utilPointer->appendDebugMessages(log); } -/*! - \brief Convenient function for the ffmpeg download extraction via libzippp. Extracts a given bytearray - to a given absolute file path and file name. Returns false if extraction or saving wasn't successful. -*/ -bool Util::saveExtractedByteArray(libzippp::ZipEntry& entry, std::string& absolutePathAndName) -{ - std::ofstream ofUnzippedFile(absolutePathAndName, std::ofstream::binary); - - if (ofUnzippedFile) { - if (entry.readContent(ofUnzippedFile) != 0) { - qDebug() << "Error cannot read ffmpeg zip content"; - return false; - } - } else { - qDebug() << "Coud not open ofstream" << QString::fromStdString(absolutePathAndName); - return false; - } - - ofUnzippedFile.close(); - return true; -} - } diff --git a/ScreenPlay/src/util.h b/ScreenPlay/src/util.h index 58b29286..42875d79 100644 --- a/ScreenPlay/src/util.h +++ b/ScreenPlay/src/util.h @@ -58,7 +58,7 @@ #include #include "globalvariables.h" -#include "libzippp.h" + namespace ScreenPlay { @@ -80,39 +80,11 @@ T QStringToEnum(const QString& key, const T defaultValue) class Util : public QObject { Q_OBJECT - Q_PROPERTY(bool ffmpegAvailable READ ffmpegAvailable NOTIFY ffmpegAvailableChanged) - Q_PROPERTY(AquireFFMPEGStatus aquireFFMPEGStatus READ aquireFFMPEGStatus NOTIFY aquireFFMPEGStatusChanged) Q_PROPERTY(QString debugMessages READ debugMessages NOTIFY debugMessagesChanged) public: explicit Util(QNetworkAccessManager* networkAccessManager, QObject* parent = nullptr); - enum class AquireFFMPEGStatus { - Init, - Download, - DownloadFailed, - DownloadSuccessful, - Extracting, - ExtractingFailedReadFromBuffer, - ExtractingFailedFFMPEG, - ExtractingFailedFFMPEGSave, - ExtractingFailedFFPROBE, - ExtractingFailedFFPROBESave, - ExtractingSuccessful, - FinishedSuccessful, - }; - Q_ENUM(AquireFFMPEGStatus) - - bool ffmpegAvailable() const - { - return m_ffmpegAvailable; - } - - AquireFFMPEGStatus aquireFFMPEGStatus() const - { - return m_aquireFFMPEGStatus; - } - QString debugMessages() const { return m_debugMessages; @@ -125,8 +97,6 @@ signals: void setSidebarItem(QString folderName, ScreenPlay::InstalledType::InstalledType type); void allLicenseLoaded(QString licensesText); void allDataProtectionLoaded(QString dataProtectionText); - void ffmpegAvailableChanged(bool ffmpegAvailable); - void aquireFFMPEGStatusChanged(ScreenPlay::Util::AquireFFMPEGStatus aquireFFMPEGStatus); void debugMessagesChanged(QString debugMessages); public slots: @@ -136,8 +106,6 @@ public slots: void requestAllLicenses(); void requestDataProtection(); - void downloadFFMPEG(); - static SearchType::SearchType getSearchTypeFromInstalledType(const InstalledType::InstalledType type); static std::optional getInstalledTypeFromString(const QString& type); static std::optional parseQByteArrayToQJsonObject(const QByteArray& byteArray); @@ -166,24 +134,6 @@ public slots: emit requestToggleWallpaperConfiguration(); } - void setFfmpegAvailable(bool ffmpegAvailable) - { - if (m_ffmpegAvailable == ffmpegAvailable) - return; - - m_ffmpegAvailable = ffmpegAvailable; - emit ffmpegAvailableChanged(m_ffmpegAvailable); - } - - void setAquireFFMPEGStatus(ScreenPlay::Util::AquireFFMPEGStatus aquireFFMPEGStatus) - { - if (m_aquireFFMPEGStatus == aquireFFMPEGStatus) - return; - - m_aquireFFMPEGStatus = aquireFFMPEGStatus; - emit aquireFFMPEGStatusChanged(m_aquireFFMPEGStatus); - } - void appendDebugMessages(QString debugMessages) { if (m_debugMessages.size() > 10000) { @@ -194,14 +144,10 @@ public slots: emit debugMessagesChanged(m_debugMessages); } -private: - bool saveExtractedByteArray(libzippp::ZipEntry& entry, std::string& absolutePathAndName); private: QNetworkAccessManager* m_networkAccessManager { nullptr }; - bool m_ffmpegAvailable { false }; - AquireFFMPEGStatus m_aquireFFMPEGStatus { AquireFFMPEGStatus::Init }; QString m_debugMessages {}; }; diff --git a/install_dependencies_linux_mac.sh b/install_dependencies_linux_mac.sh index ae88c038..47f19c28 100644 --- a/install_dependencies_linux_mac.sh +++ b/install_dependencies_linux_mac.sh @@ -11,7 +11,7 @@ chmod +x bootstrap-vcpkg.sh chmod +x vcpkg if [[ "$OSTYPE" == "darwin"* ]]; then -./vcpkg install zlib libzip libzippp openssl-unix libzip sentry-native --triplet x64-osx --recurse +./vcpkg install openssl-unix sentry-native --triplet x64-osx --recurse else -./vcpkg install zlib libzip libzippp openssl-unix libzip sentry-native --triplet x64-linux --recurse +./vcpkg install openssl-unix sentry-native --triplet x64-linux --recurse fi \ No newline at end of file diff --git a/install_dependencies_windows.bat b/install_dependencies_windows.bat index 597844e3..83abd1ed 100644 --- a/install_dependencies_windows.bat +++ b/install_dependencies_windows.bat @@ -4,7 +4,31 @@ cd Common git clone https://github.com/microsoft/vcpkg.git cd vcpkg git pull -rem master 10.09.2020 - 18ab4b72a26284f0df28295ce7bf9b21c96f20f4 -git checkout 18ab4b72a26284f0df28295ce7bf9b21c96f20f4 +rem master 10.09.2020 - 18ab4b72a26284f0df28295ce7bf9b21c96f20f4 +git checkout 18ab4b72a26284f0df28295ce7bf9b21c96f20f4 call bootstrap-vcpkg.bat -vcpkg.exe install zlib libzip libzippp openssl sentry-native --triplet x64-windows --recurse + +rem Install vcpkg dependencies +vcpkg.exe install openssl sentry-native --triplet x64-windows --recurse + +cd .. +cd .. + +rem Donwload ffmpeg +curl.exe -L https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-4.3.1-full_build.zip --output ffmpeg.zip + +rem Extract ffmpeg. Needs Windows 10 build 17063 or higher! +rem We only need the content of the bin folder +rem --strip-components 2 removes folder +tar -xvf ffmpeg.zip --strip-components 2 ffmpeg-4.3.1-full_build/bin + +rem Remove not used ffplay +DEL ffplay.exe + +rem Move ffmpeg into folder +move /Y ffmpeg.exe Common/ffmpeg +move /Y ffprobe.exe Common/ffmpeg + +DEL ffmpeg.zip + +pause \ No newline at end of file