From 0c4912ff53ae02a75e9fbcfed87afac9030b82da Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aur=C3=A9lien=20COUDERC?= Date: Tue, 3 Dec 2024 16:21:59 +0100 Subject: [PATCH] Import kpipewire_6.2.4.orig.tar.xz [dgit import orig kpipewire_6.2.4.orig.tar.xz] --- .gitignore | 29 + .gitlab-ci.yml | 8 + .kde-ci.yml | 13 + CMakeLists.txt | 54 ++ LICENSES/BSD-3-Clause.txt | 11 + LICENSES/CC0-1.0.txt | 121 +++ LICENSES/LGPL-2.1-only.txt | 175 +++++ LICENSES/LGPL-3.0-only.txt | 304 +++++++ LICENSES/LicenseRef-KDE-Accepted-LGPL.txt | 12 + README.md | 21 + cmake/FindLibdrm.cmake | 105 +++ po/ar/kpipewire6.po | 34 + po/ast/kpipewire6.po | 33 + po/bg/kpipewire6.po | 35 + po/ca/kpipewire6.po | 35 + po/ca@valencia/kpipewire6.po | 35 + po/cs/kpipewire6.po | 33 + po/de/kpipewire6.po | 36 + po/en_GB/kpipewire6.po | 33 + po/eo/kpipewire6.po | 32 + po/es/kpipewire6.po | 35 + po/eu/kpipewire6.po | 36 + po/fi/kpipewire6.po | 33 + po/fr/kpipewire6.po | 30 + po/gl/kpipewire6.po | 33 + po/he/kpipewire6.po | 34 + po/hu/kpipewire6.po | 33 + po/ia/kpipewire6.po | 33 + po/id/kpipewire6.po | 33 + po/is/kpipewire6.po | 33 + po/it/kpipewire6.po | 33 + po/ja/kpipewire6.po | 30 + po/ka/kpipewire6.po | 34 + po/ko/kpipewire6.po | 33 + po/lt/kpipewire6.po | 35 + po/lv/kpipewire6.po | 34 + po/nl/kpipewire6.po | 33 + po/nn/kpipewire6.po | 34 + po/pa/kpipewire6.po | 33 + po/pl/kpipewire6.po | 34 + po/pt/kpipewire6.po | 29 + po/pt_BR/kpipewire6.po | 33 + po/ro/kpipewire6.po | 34 + po/ru/kpipewire6.po | 34 + po/sa/kpipewire6.po | 35 + po/sk/kpipewire6.po | 31 + po/sl/kpipewire6.po | 34 + po/sv/kpipewire6.po | 33 + po/ta/kpipewire6.po | 33 + po/tr/kpipewire6.po | 33 + po/uk/kpipewire6.po | 34 + po/zh_CN/kpipewire6.po | 33 + po/zh_TW/kpipewire6.po | 36 + src/CMakeLists.txt | 200 +++++ src/KPipeWireConfig.cmake.in | 9 + src/Messages.sh | 6 + src/dmabufhandler.cpp | 222 ++++++ src/dmabufhandler.h | 36 + src/encoder.cpp | 455 +++++++++++ src/encoder_p.h | 186 +++++ src/glhelpers.cpp | 177 +++++ src/glhelpers.h | 24 + src/h264vaapiencoder.cpp | 178 +++++ src/h264vaapiencoder_p.h | 27 + src/kpipewiredeclarativeplugin.cpp | 17 + src/kpipewiredeclarativeplugin.h | 17 + src/kpipewirerecorddeclarativeplugin.cpp | 17 + src/kpipewirerecorddeclarativeplugin.h | 17 + src/libopenh264encoder.cpp | 106 +++ src/libopenh264encoder_p.h | 28 + src/libvpxencoder.cpp | 94 +++ src/libvpxencoder_p.h | 24 + src/libvpxvp9encoder.cpp | 122 +++ src/libvpxvp9encoder_p.h | 25 + src/libx264encoder.cpp | 110 +++ src/libx264encoder_p.h | 27 + src/monitors/CMakeLists.txt | 11 + src/monitors/autotests/CMakeLists.txt | 6 + .../autotests/alarm-clock-elapsed.oga | Bin 0 -> 73696 bytes .../autotests/alarm-clock-elapsed.oga.license | 6 + src/monitors/autotests/mediamonitortest.cpp | 179 +++++ src/monitors/autotests/mediamonitortest.qml | 30 + src/monitors/mediamonitor.cpp | 385 +++++++++ src/monitors/mediamonitor.h | 161 ++++ src/pipewirebaseencodedstream.cpp | 266 +++++++ src/pipewirebaseencodedstream.h | 130 +++ src/pipewirecore.cpp | 146 ++++ src/pipewirecore_p.h | 64 ++ src/pipewireencodedstream.cpp | 96 +++ src/pipewireencodedstream.h | 44 ++ src/pipewireencodedstream_p.h | 28 + src/pipewireproduce.cpp | 381 +++++++++ src/pipewireproduce_p.h | 155 ++++ src/pipewirerecord.cpp | 207 +++++ src/pipewirerecord.h | 42 + src/pipewirerecord_p.h | 36 + src/pipewiresourceitem.cpp | 487 ++++++++++++ src/pipewiresourceitem.h | 114 +++ src/pipewiresourcestream.cpp | 743 ++++++++++++++++++ src/pipewiresourcestream.h | 171 ++++ src/pwhelpers.cpp | 69 ++ src/pwhelpers.h | 61 ++ src/vaapiutils.cpp | 267 +++++++ src/vaapiutils_p.h | 52 ++ tests/CMakeLists.txt | 57 ++ tests/HeadlessTest.cpp | 535 +++++++++++++ tests/PlasmaRecordMe.cpp | 237 ++++++ tests/PlasmaRecordMe.h | 72 ++ tests/RecordMe.cpp | 227 ++++++ tests/RecordMe.h | 68 ++ tests/RegionSelector.qml | 45 ++ tests/main.cpp | 44 ++ tests/main.qml | 100 +++ .../org.freedesktop.portal.RemoteDesktop.xml | 415 ++++++++++ tests/org.freedesktop.portal.ScreenCast.xml | 323 ++++++++ ...rg.kde.kpipewireheadlesstest.desktop.cmake | 7 + tests/org.kde.recordme.desktop.cmake | 7 + tests/recordme.qrc | 11 + tests/screencasting.cpp | 147 ++++ tests/screencasting.h | 78 ++ tests/screencastingrequest.cpp | 105 +++ tests/screencastingrequest.h | 64 ++ tests/webcamtest.cpp | 26 + tests/webcamtest.qml | 61 ++ tests/webcamtest.qrc | 10 + tests/xdp-main.cpp | 46 ++ 126 files changed, 11403 insertions(+) create mode 100644 .gitignore create mode 100644 .gitlab-ci.yml create mode 100644 .kde-ci.yml create mode 100644 CMakeLists.txt create mode 100644 LICENSES/BSD-3-Clause.txt create mode 100644 LICENSES/CC0-1.0.txt create mode 100644 LICENSES/LGPL-2.1-only.txt create mode 100644 LICENSES/LGPL-3.0-only.txt create mode 100644 LICENSES/LicenseRef-KDE-Accepted-LGPL.txt create mode 100644 README.md create mode 100644 cmake/FindLibdrm.cmake create mode 100644 po/ar/kpipewire6.po create mode 100644 po/ast/kpipewire6.po create mode 100644 po/bg/kpipewire6.po create mode 100644 po/ca/kpipewire6.po create mode 100644 po/ca@valencia/kpipewire6.po create mode 100644 po/cs/kpipewire6.po create mode 100644 po/de/kpipewire6.po create mode 100644 po/en_GB/kpipewire6.po create mode 100644 po/eo/kpipewire6.po create mode 100644 po/es/kpipewire6.po create mode 100644 po/eu/kpipewire6.po create mode 100644 po/fi/kpipewire6.po create mode 100644 po/fr/kpipewire6.po create mode 100644 po/gl/kpipewire6.po create mode 100644 po/he/kpipewire6.po create mode 100644 po/hu/kpipewire6.po create mode 100644 po/ia/kpipewire6.po create mode 100644 po/id/kpipewire6.po create mode 100644 po/is/kpipewire6.po create mode 100644 po/it/kpipewire6.po create mode 100644 po/ja/kpipewire6.po create mode 100644 po/ka/kpipewire6.po create mode 100644 po/ko/kpipewire6.po create mode 100644 po/lt/kpipewire6.po create mode 100644 po/lv/kpipewire6.po create mode 100644 po/nl/kpipewire6.po create mode 100644 po/nn/kpipewire6.po create mode 100644 po/pa/kpipewire6.po create mode 100644 po/pl/kpipewire6.po create mode 100644 po/pt/kpipewire6.po create mode 100644 po/pt_BR/kpipewire6.po create mode 100644 po/ro/kpipewire6.po create mode 100644 po/ru/kpipewire6.po create mode 100644 po/sa/kpipewire6.po create mode 100644 po/sk/kpipewire6.po create mode 100644 po/sl/kpipewire6.po create mode 100644 po/sv/kpipewire6.po create mode 100644 po/ta/kpipewire6.po create mode 100644 po/tr/kpipewire6.po create mode 100644 po/uk/kpipewire6.po create mode 100644 po/zh_CN/kpipewire6.po create mode 100644 po/zh_TW/kpipewire6.po create mode 100644 src/CMakeLists.txt create mode 100644 src/KPipeWireConfig.cmake.in create mode 100755 src/Messages.sh create mode 100644 src/dmabufhandler.cpp create mode 100644 src/dmabufhandler.h create mode 100644 src/encoder.cpp create mode 100644 src/encoder_p.h create mode 100644 src/glhelpers.cpp create mode 100644 src/glhelpers.h create mode 100644 src/h264vaapiencoder.cpp create mode 100644 src/h264vaapiencoder_p.h create mode 100644 src/kpipewiredeclarativeplugin.cpp create mode 100644 src/kpipewiredeclarativeplugin.h create mode 100644 src/kpipewirerecorddeclarativeplugin.cpp create mode 100644 src/kpipewirerecorddeclarativeplugin.h create mode 100644 src/libopenh264encoder.cpp create mode 100644 src/libopenh264encoder_p.h create mode 100644 src/libvpxencoder.cpp create mode 100644 src/libvpxencoder_p.h create mode 100644 src/libvpxvp9encoder.cpp create mode 100644 src/libvpxvp9encoder_p.h create mode 100644 src/libx264encoder.cpp create mode 100644 src/libx264encoder_p.h create mode 100644 src/monitors/CMakeLists.txt create mode 100644 src/monitors/autotests/CMakeLists.txt create mode 100644 src/monitors/autotests/alarm-clock-elapsed.oga create mode 100644 src/monitors/autotests/alarm-clock-elapsed.oga.license create mode 100644 src/monitors/autotests/mediamonitortest.cpp create mode 100644 src/monitors/autotests/mediamonitortest.qml create mode 100644 src/monitors/mediamonitor.cpp create mode 100644 src/monitors/mediamonitor.h create mode 100644 src/pipewirebaseencodedstream.cpp create mode 100644 src/pipewirebaseencodedstream.h create mode 100644 src/pipewirecore.cpp create mode 100644 src/pipewirecore_p.h create mode 100644 src/pipewireencodedstream.cpp create mode 100644 src/pipewireencodedstream.h create mode 100644 src/pipewireencodedstream_p.h create mode 100644 src/pipewireproduce.cpp create mode 100644 src/pipewireproduce_p.h create mode 100644 src/pipewirerecord.cpp create mode 100644 src/pipewirerecord.h create mode 100644 src/pipewirerecord_p.h create mode 100644 src/pipewiresourceitem.cpp create mode 100644 src/pipewiresourceitem.h create mode 100644 src/pipewiresourcestream.cpp create mode 100644 src/pipewiresourcestream.h create mode 100644 src/pwhelpers.cpp create mode 100644 src/pwhelpers.h create mode 100644 src/vaapiutils.cpp create mode 100644 src/vaapiutils_p.h create mode 100644 tests/CMakeLists.txt create mode 100644 tests/HeadlessTest.cpp create mode 100644 tests/PlasmaRecordMe.cpp create mode 100644 tests/PlasmaRecordMe.h create mode 100644 tests/RecordMe.cpp create mode 100644 tests/RecordMe.h create mode 100644 tests/RegionSelector.qml create mode 100644 tests/main.cpp create mode 100644 tests/main.qml create mode 100644 tests/org.freedesktop.portal.RemoteDesktop.xml create mode 100644 tests/org.freedesktop.portal.ScreenCast.xml create mode 100644 tests/org.kde.kpipewireheadlesstest.desktop.cmake create mode 100644 tests/org.kde.recordme.desktop.cmake create mode 100644 tests/recordme.qrc create mode 100644 tests/screencasting.cpp create mode 100644 tests/screencasting.h create mode 100644 tests/screencastingrequest.cpp create mode 100644 tests/screencastingrequest.h create mode 100644 tests/webcamtest.cpp create mode 100644 tests/webcamtest.qml create mode 100644 tests/webcamtest.qrc create mode 100644 tests/xdp-main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6aada61 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# Ignore the following files +*~ +*.[oa] +*.diff +*.kate-swp +*.kdev4 +.kdev_include_paths +*.kdevelop.pcs +*.moc +*.moc.cpp +*.orig +*.user +.*.swp +.swp.* +Doxyfile +Makefile +avail +random_seed +/build*/ +CMakeLists.txt.user* +*.unc-backup* +.cmake/ +/.clang-format +/compile_commands.json +.clangd +.idea +.vscode +/cmake-build* +.cache diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..f6e2f69 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,8 @@ +# SPDX-FileCopyrightText: None +# SPDX-License-Identifier: CC0-1.0 + +include: + - project: sysadmin/ci-utilities + file: + - /gitlab-templates/linux-qt6.yml + - /gitlab-templates/freebsd-qt6.yml diff --git a/.kde-ci.yml b/.kde-ci.yml new file mode 100644 index 0000000..26f2e17 --- /dev/null +++ b/.kde-ci.yml @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: None +# SPDX-License-Identifier: CC0-1.0 + +Dependencies: +- 'on': ['@all'] + 'require': + 'frameworks/extra-cmake-modules': '@latest-kf6' + 'frameworks/kcoreaddons': '@latest-kf6' + 'frameworks/ki18n': '@latest-kf6' + 'libraries/plasma-wayland-protocols': '@latest-kf6' + 'third-party/wayland': '@latest' +Options: + require-passing-tests-on: [ 'Linux', 'FreeBSD'] diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..149e193 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,54 @@ +cmake_minimum_required(VERSION 3.16) +project(KPipewire VERSION "6.2.4") + +set(KF6_MIN_VERSION "6.5.0") +find_package(ECM ${KF6_MIN_VERSION} REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) +include(KDEInstallDirs) +include(KDECompilerSettings NO_POLICY_SCOPE) +include(KDECMakeSettings) +include(KDEClangFormat) +include(KDEGitCommitHooks) +include(ECMQtDeclareLoggingCategory) + +find_package(Qt6 REQUIRED COMPONENTS DBus Quick) +find_package(KF6 REQUIRED COMPONENTS I18n CoreAddons) + +find_package(EGL REQUIRED) + +pkg_check_modules(PipeWire IMPORTED_TARGET libpipewire-0.3 REQUIRED) + +# ffmpeg, for recording +pkg_check_modules(AVCodec IMPORTED_TARGET libavcodec REQUIRED) +pkg_check_modules(AVUtil IMPORTED_TARGET libavutil REQUIRED) +pkg_check_modules(AVFormat IMPORTED_TARGET libavformat REQUIRED) +pkg_check_modules(AVFilter IMPORTED_TARGET libavfilter REQUIRED) +pkg_check_modules(GBM IMPORTED_TARGET gbm REQUIRED) +pkg_check_modules(SWScale IMPORTED_TARGET libswscale REQUIRED) +find_package(epoxy 1.3 REQUIRED) +find_package(Libdrm 2.4.62 REQUIRED) +pkg_check_modules(LIBVA IMPORTED_TARGET libva REQUIRED) +pkg_check_modules(LIBVA-drm IMPORTED_TARGET libva-drm REQUIRED) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# add clang-format target for all our real source files +file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h) +kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES}) +kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT) + +# Prevent EGL headers from including platform headers, in particular Xlib.h. +add_definitions(-DMESA_EGL_NO_X11_HEADERS) +add_definitions(-DEGL_NO_X11) +add_definitions(-DEGL_NO_PLATFORM_SPECIFIC_TYPES) + +if (BUILD_TESTING) + find_package(PlasmaWaylandProtocols REQUIRED) + include(ECMAddTests) + find_package(Qt6 REQUIRED COMPONENTS Test QuickTest) + add_subdirectory(tests) +endif() +add_subdirectory(src) + +ki18n_install(po) diff --git a/LICENSES/BSD-3-Clause.txt b/LICENSES/BSD-3-Clause.txt new file mode 100644 index 0000000..ea890af --- /dev/null +++ b/LICENSES/BSD-3-Clause.txt @@ -0,0 +1,11 @@ +Copyright (c) . + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/LICENSES/CC0-1.0.txt b/LICENSES/CC0-1.0.txt new file mode 100644 index 0000000..0e259d4 --- /dev/null +++ b/LICENSES/CC0-1.0.txt @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/LICENSES/LGPL-2.1-only.txt b/LICENSES/LGPL-2.1-only.txt new file mode 100644 index 0000000..c9aa530 --- /dev/null +++ b/LICENSES/LGPL-2.1-only.txt @@ -0,0 +1,175 @@ +GNU LESSER GENERAL PUBLIC LICENSE + +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. + +This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. + +To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. + +Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. + +Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. + +When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. + +We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. + +For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. + +In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. + +The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". + +A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. + +(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Library into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. + +However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. + +When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. + +If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: + + a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. + + e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. + + b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). + +To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + one line to give the library's name and an idea of what it does. + Copyright (C) year name of author + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in +the library `Frob' (a library for tweaking knobs) written +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 +Ty Coon, President of Vice +That's all there is to it! diff --git a/LICENSES/LGPL-3.0-only.txt b/LICENSES/LGPL-3.0-only.txt new file mode 100644 index 0000000..513d1c0 --- /dev/null +++ b/LICENSES/LGPL-3.0-only.txt @@ -0,0 +1,304 @@ +GNU LESSER GENERAL PUBLIC LICENSE +Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. + +0. Additional Definitions. + +As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. + +"The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. + +An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. + +A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". + +The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. + +The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. + +1. Exception to Section 3 of the GNU GPL. +You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. + +2. Conveying Modified Versions. +If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: + + a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. + +3. Object Code Incorporating Material from Library Header Files. +The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license document. + +4. Combined Works. +You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: + + a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license document. + + c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. + + e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) + +5. Combined Libraries. +You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. + +6. Revised Versions of the GNU Lesser General Public License. +The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. + +If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. + +GNU GENERAL PUBLIC LICENSE +Version 3, 29 June 2007 + +Copyright © 2007 Free Software Foundation, Inc. + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The GNU General Public License is a free, copyleft license for software and other kinds of works. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. + +Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS + +0. Definitions. + +“This License” refers to version 3 of the GNU General Public License. + +“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. + +“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations. + +To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work. + +A “covered work” means either the unmodified Program or a work based on the Program. + +To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. + +To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. + +1. Source Code. +The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work. + +A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. + +The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. + +The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. + +2. Basic Permissions. +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. + +4. Conveying Verbatim Copies. +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”. + + c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. + +6. Conveying Non-Source Forms. +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + + a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. + + d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. + +7. Additional Terms. +“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or authors of the material; or + + e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. + +All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. + +8. Termination. +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. + +9. Acceptance Not Required for Having Copies. +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. + +11. Patents. +A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”. + +A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. + +12. No Surrender of Others' Freedom. +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. + +13. Use with the GNU Affero General Public License. +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. + +14. Revised Versions of this License. +The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. + +15. Disclaimer of Warranty. +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. Limitation of Liability. +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +17. Interpretation of Sections 15 and 16. +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”. + +You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . + +The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . diff --git a/LICENSES/LicenseRef-KDE-Accepted-LGPL.txt b/LICENSES/LicenseRef-KDE-Accepted-LGPL.txt new file mode 100644 index 0000000..232b3c5 --- /dev/null +++ b/LICENSES/LicenseRef-KDE-Accepted-LGPL.txt @@ -0,0 +1,12 @@ +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 3 of the license or (at your option) any later version +that is accepted by the membership of KDE e.V. (or its successor +approved by the membership of KDE e.V.), which shall act as a +proxy as defined in Section 6 of version 3 of the license. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3a83df7 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# KPipeWire + +Offers a set of convenient classes to use PipeWire (https://pipewire.org/) in Qt projects. + +It is developed in C++ and it's main use target is QML components. + +As it's what's been useful, this framework focuses on graphical PipeWire features. If it was necessary, these could be included. + +## Features + +At the moment we offer two main components: +* KPipeWire: offers the main components to connect to and render PipeWire into your app. +* KPipeWireRecord: using FFmpeg, helps to record a PipeWire video stream into a file. + +## Usage + +You can refer to the `tests/` subdirectory for two examples of rendering Plasma video streams. One through the internal Plasma Wayland protocol and the other using the standard XDG Desktop Portals screencast API. + +## Licence + +This project is licenced under LGPL v2.1+, you can find all the information under `LICENSES/`. diff --git a/cmake/FindLibdrm.cmake b/cmake/FindLibdrm.cmake new file mode 100644 index 0000000..cf6e061 --- /dev/null +++ b/cmake/FindLibdrm.cmake @@ -0,0 +1,105 @@ +#.rst: +# FindLibdrm +# ------- +# +# Try to find libdrm on a Unix system. +# +# This will define the following variables: +# +# ``Libdrm_FOUND`` +# True if (the requested version of) libdrm is available +# ``Libdrm_VERSION`` +# The version of libdrm +# ``Libdrm_LIBRARIES`` +# This can be passed to target_link_libraries() instead of the ``Libdrm::Libdrm`` +# target +# ``Libdrm_INCLUDE_DIRS`` +# This should be passed to target_include_directories() if the target is not +# used for linking +# ``Libdrm_DEFINITIONS`` +# This should be passed to target_compile_options() if the target is not +# used for linking +# +# If ``Libdrm_FOUND`` is TRUE, it will also define the following imported target: +# +# ``Libdrm::Libdrm`` +# The libdrm library +# +# In general we recommend using the imported target, as it is easier to use. +# Bear in mind, however, that if the target is in the link interface of an +# exported library, it must be made available by the package config file. + +#============================================================================= +# SPDX-FileCopyrightText: 2014 Alex Merry +# SPDX-FileCopyrightText: 2014 Martin Gräßlin +# +# SPDX-License-Identifier: BSD-3-Clause +#============================================================================= + +if(CMAKE_VERSION VERSION_LESS 2.8.12) + message(FATAL_ERROR "CMake 2.8.12 is required by FindLibdrm.cmake") +endif() +if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12) + message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindLibdrm.cmake") +endif() + +if(NOT WIN32) + # Use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + find_package(PkgConfig) + pkg_check_modules(PKG_Libdrm QUIET libdrm) + + set(Libdrm_DEFINITIONS ${PKG_Libdrm_CFLAGS_OTHER}) + set(Libdrm_VERSION ${PKG_Libdrm_VERSION}) + + find_path(Libdrm_INCLUDE_DIR + NAMES + xf86drm.h + HINTS + ${PKG_Libdrm_INCLUDE_DIRS} + ) + find_library(Libdrm_LIBRARY + NAMES + drm + HINTS + ${PKG_Libdrm_LIBRARY_DIRS} + ) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Libdrm + FOUND_VAR + Libdrm_FOUND + REQUIRED_VARS + Libdrm_LIBRARY + Libdrm_INCLUDE_DIR + VERSION_VAR + Libdrm_VERSION + ) + + if(Libdrm_FOUND AND NOT TARGET Libdrm::Libdrm) + add_library(Libdrm::Libdrm UNKNOWN IMPORTED) + set_target_properties(Libdrm::Libdrm PROPERTIES + IMPORTED_LOCATION "${Libdrm_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${Libdrm_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${Libdrm_INCLUDE_DIR}" + INTERFACE_INCLUDE_DIRECTORIES "${Libdrm_INCLUDE_DIR}/libdrm" + ) + endif() + + mark_as_advanced(Libdrm_LIBRARY Libdrm_INCLUDE_DIR) + + # compatibility variables + set(Libdrm_LIBRARIES ${Libdrm_LIBRARY}) + set(Libdrm_INCLUDE_DIRS ${Libdrm_INCLUDE_DIR} "${Libdrm_INCLUDE_DIR}/libdrm") + set(Libdrm_VERSION_STRING ${Libdrm_VERSION}) + +else() + message(STATUS "FindLibdrm.cmake cannot find libdrm on Windows systems.") + set(Libdrm_FOUND FALSE) +endif() + +include(FeatureSummary) +set_package_properties(Libdrm PROPERTIES + URL "https://wiki.freedesktop.org/dri/" + DESCRIPTION "Userspace interface to kernel DRM services" +) diff --git a/po/ar/kpipewire6.po b/po/ar/kpipewire6.po new file mode 100644 index 0000000..646925a --- /dev/null +++ b/po/ar/kpipewire6.po @@ -0,0 +1,34 @@ +# Copyright (C) 2024 This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# SPDX-FileCopyrightText: 2022, 2024 Zayed Al-Saidi +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-09-13 19:09+0400\n" +"Last-Translator: Zayed Al-Saidi \n" +"Language-Team: ar\n" +"Language: ar\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " +"&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n" +"X-Generator: Lokalize 23.08.5\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "فشل في إنشاء سياق PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "فشل الاتصال بPipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "فشل في بدء الحلقة الرئيسة لـPipeWire" diff --git a/po/ast/kpipewire6.po b/po/ast/kpipewire6.po new file mode 100644 index 0000000..39a29c7 --- /dev/null +++ b/po/ast/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Enol P. , 2023. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2023-05-03 23:40+0200\n" +"Last-Translator: Enol P. \n" +"Language-Team: \n" +"Language: ast\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 23.04.0\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "" diff --git a/po/bg/kpipewire6.po b/po/bg/kpipewire6.po new file mode 100644 index 0000000..09cd55e --- /dev/null +++ b/po/bg/kpipewire6.po @@ -0,0 +1,35 @@ +# Bulgarian translations for kpipewire package. +# Copyright (C) 2023 This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Automatically generated, 2023. +# Mincho Kondarev , 2023. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2023-08-09 09:56+0200\n" +"Last-Translator: Mincho Kondarev \n" +"Language-Team: \n" +"Language: bg\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 23.04.3\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Неуспешно създаване на PipeWire контекст" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Неуспешно свързване към PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Неуспешно стартиране на основния цикъл PipeWire" diff --git a/po/ca/kpipewire6.po b/po/ca/kpipewire6.po new file mode 100644 index 0000000..ff6b647 --- /dev/null +++ b/po/ca/kpipewire6.po @@ -0,0 +1,35 @@ +# Translation of kpipewire6.po to Catalan +# Copyright (C) 2022 This_file_is_part_of_KDE +# This file is distributed under the license LGPL version 2.1 or +# version 3 or later versions approved by the membership of KDE e.V. +# +# Josep M. Ferrer , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-05-31 13:21+0200\n" +"Last-Translator: Josep M. Ferrer \n" +"Language-Team: Catalan \n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 20.12.0\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Ha fallat en crear el context del PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Ha fallat en connectar amb el PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Ha fallat en iniciar el bucle principal del PipeWire" diff --git a/po/ca@valencia/kpipewire6.po b/po/ca@valencia/kpipewire6.po new file mode 100644 index 0000000..3307645 --- /dev/null +++ b/po/ca@valencia/kpipewire6.po @@ -0,0 +1,35 @@ +# Translation of kpipewire6.po to Catalan (Valencian) +# Copyright (C) 2022 This_file_is_part_of_KDE +# This file is distributed under the license LGPL version 2.1 or +# version 3 or later versions approved by the membership of KDE e.V. +# +# Josep M. Ferrer , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-05-31 13:21+0200\n" +"Last-Translator: Josep M. Ferrer \n" +"Language-Team: Catalan \n" +"Language: ca@valencia\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 20.12.0\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "No s'ha pogut crear el context de PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "No s'ha pogut connectar amb PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "No s'ha pogut iniciar el bucle principal de PipeWire" diff --git a/po/cs/kpipewire6.po b/po/cs/kpipewire6.po new file mode 100644 index 0000000..a03f000 --- /dev/null +++ b/po/cs/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# Vit Pelcak , 2022. +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-06-27 16:26+0200\n" +"Last-Translator: Vit Pelcak \n" +"Language-Team: Czech \n" +"Language: cs\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" +"X-Generator: Lokalize 22.04.2\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Chyba při vytváření kontextu PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Chyba při připojení k PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Chyba při spouÅ¡tění hlavní smyčky PipeWire" diff --git a/po/de/kpipewire6.po b/po/de/kpipewire6.po new file mode 100644 index 0000000..925402f --- /dev/null +++ b/po/de/kpipewire6.po @@ -0,0 +1,36 @@ +# German translations for kpipewire package. +# Copyright (C) 2022 This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# Frederik Schwarzer , 2022. +# SPDX-FileCopyrightText: 2023 Johannes Obermayr +# +# Automatically generated, 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire6\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2023-12-21 17:18+0100\n" +"Last-Translator: Johannes Obermayr \n" +"Language-Team: German \n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Lokalize 23.08.4\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Der PipeWire-Kontext kann nicht erstellt werden" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Fehler beim Verbinden mit PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Die Hauptschleife von PipeWire kann nicht gestartet werden" diff --git a/po/en_GB/kpipewire6.po b/po/en_GB/kpipewire6.po new file mode 100644 index 0000000..9175d8d --- /dev/null +++ b/po/en_GB/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Steve Allewell , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-07-22 15:33+0100\n" +"Last-Translator: Steve Allewell \n" +"Language-Team: British English \n" +"Language: en_GB\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 22.04.3\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Failed to create PipeWire context" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Failed to connect to PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Failed to start main PipeWire loop" diff --git a/po/eo/kpipewire6.po b/po/eo/kpipewire6.po new file mode 100644 index 0000000..df8c930 --- /dev/null +++ b/po/eo/kpipewire6.po @@ -0,0 +1,32 @@ +# translation of kpipewire to Esperanto +# Copyright (C) 2017 Free Software Foundation, Inc. +# Oliver Kellogg , 2023. +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2023-04-28 23:02+0100\n" +"Last-Translator: Oliver Kellogg \n" +"Language-Team: Esperanto \n" +"Language: eo\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Malsukcesis krei PipeWire-kuntekston" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Malsukcesis konekti al PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Malsukcesis startigi ĉefan PipeWire-buklon" diff --git a/po/es/kpipewire6.po b/po/es/kpipewire6.po new file mode 100644 index 0000000..3dfe030 --- /dev/null +++ b/po/es/kpipewire6.po @@ -0,0 +1,35 @@ +# Spanish translations for kpipewire5.po package. +# Copyright (C) 2022 This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Automatically generated, 2022. +# Eloy Cuadra , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire5\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-06-01 03:45+0200\n" +"Last-Translator: Eloy Cuadra \n" +"Language-Team: Spanish \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 22.04.1\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Ha fallado la creación de un contexto de PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Ha fallado la conexión a PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Ha fallado el inicio del bucle principal de PipeWire" diff --git a/po/eu/kpipewire6.po b/po/eu/kpipewire6.po new file mode 100644 index 0000000..653a4a1 --- /dev/null +++ b/po/eu/kpipewire6.po @@ -0,0 +1,36 @@ +# Translation for kpipewire5.po to Euskara/Basque (eu). +# Copyright (C) 2022, This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# KDE euskaratzeko proiektuko arduraduna . +# +# Translators: +# Iñigo Salvador Azurmendi , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-07-28 12:48+0200\n" +"Last-Translator: Iñigo Salvador Azurmendi \n" +"Language-Team: Basque \n" +"Language: eu\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Lokalize 22.04.3\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "«PipeWire» testuingurua sortzea huts egin du" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "«PipeWire»ra konektatzea huts egin du" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "«PipeWire» begizta nagusia abiatzea huts egin du" diff --git a/po/fi/kpipewire6.po b/po/fi/kpipewire6.po new file mode 100644 index 0000000..cde0aef --- /dev/null +++ b/po/fi/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# Tommi Nieminen , 2022. +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-06-11 18:54+0300\n" +"Last-Translator: Tommi Nieminen \n" +"Language-Team: Finnish \n" +"Language: fi\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Lokalize 21.12.3\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "PipeWire-kontekstin luominen epäonnistui" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "PipeWireen yhdistäminen epäonnistui" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "PipeWire-pääsilmukan käynnistäminen epäonnistui" diff --git a/po/fr/kpipewire6.po b/po/fr/kpipewire6.po new file mode 100644 index 0000000..382e5e7 --- /dev/null +++ b/po/fr/kpipewire6.po @@ -0,0 +1,30 @@ +# SPDX-FileCopyrightText: 2022, 2024 Xavier Besnard +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-06-05 11:29+0200\n" +"Last-Translator: Xavier Besnard \n" +"Language-Team: French >\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Generator: Lokalize 23.08.5\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Impossible de créer un contexte pour PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Impossible de se connecter à PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Impossible de démarrer une boucle pour PipeWire" diff --git a/po/gl/kpipewire6.po b/po/gl/kpipewire6.po new file mode 100644 index 0000000..1668af7 --- /dev/null +++ b/po/gl/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) 2024 This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# SPDX-FileCopyrightText: 2024 Adrián Chaves (Gallaecio) +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2023-04-24 07:46+0200\n" +"Last-Translator: Adrián Chaves (Gallaecio) \n" +"Language-Team: Proxecto Trasno (proxecto@trasno.gal)\n" +"Language: gl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 24.08.3\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Non foi posíbel crear o contexto de PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Non foi posíbel conectar a PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Non foi posíbel iniciar o bucle principal de PipeWire" diff --git a/po/he/kpipewire6.po b/po/he/kpipewire6.po new file mode 100644 index 0000000..4487bb7 --- /dev/null +++ b/po/he/kpipewire6.po @@ -0,0 +1,34 @@ +# Copyright (C) 2024 This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# SPDX-FileCopyrightText: 2024 Yaron Shahrabani +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2024-03-19 07:52+0200\n" +"Last-Translator: Yaron Shahrabani \n" +"Language-Team: צוות התרגום של KDE ישראל\n" +"Language: he\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=4; plural=(n == 1) ? 0 : ((n == 2) ? 1 : ((n > 10 && " +"n % 10 == 0) ? 2 : 3));\n" +"X-Generator: Lokalize 23.08.5\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "יצירת הקשר PipeWire נכשל" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "ההתחברות ל־PipeWire נכשלה" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "הפעלת לולאת ה־PipeWire הראשית נכשלה" diff --git a/po/hu/kpipewire6.po b/po/hu/kpipewire6.po new file mode 100644 index 0000000..f7b3a17 --- /dev/null +++ b/po/hu/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) 2024 This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# SPDX-FileCopyrightText: 2024 Kristof Kiszel +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2024-01-05 21:18+0100\n" +"Last-Translator: Kristof Kiszel \n" +"Language-Team: Hungarian \n" +"Language: hu\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Lokalize 23.08.4\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Nem sikerült létrehozni a PipeWire környezetet" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Nem sikerült kapcsolódni a PipeWire-hoz" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Nem sikerült elindítani a fő PipeWire hurkot" diff --git a/po/ia/kpipewire6.po b/po/ia/kpipewire6.po new file mode 100644 index 0000000..abc4ad7 --- /dev/null +++ b/po/ia/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# giovanni , 2023. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2023-03-16 10:56+0100\n" +"Last-Translator: giovanni \n" +"Language-Team: Interlingua \n" +"Language: ia\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 21.12.1\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Il falleva a crear contexto de PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Il falleva a connecter con PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Falleva a initiar loop principal de PipeWire" diff --git a/po/id/kpipewire6.po b/po/id/kpipewire6.po new file mode 100644 index 0000000..1775d49 --- /dev/null +++ b/po/id/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# Wantoyèk , 2023. +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2023-05-30 20:40+0700\n" +"Last-Translator: Wantoyèk \n" +"Language-Team: Indonesian \n" +"Language: id\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Lokalize 23.04.0\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Gagal membuat PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Gagal menyambungkan ke PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Gagal memulai loop PipeWire utama" diff --git a/po/is/kpipewire6.po b/po/is/kpipewire6.po new file mode 100644 index 0000000..c81caef --- /dev/null +++ b/po/is/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Sveinn í Felli , 2024. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2024-02-19 09:52+0000\n" +"Last-Translator: Sveinn í Felli \n" +"Language-Team: Icelandic\n" +"Language: is\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 22.04.3\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Mistókst að útbúa PipeWire samhengi" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Mistókst að tengjast við PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Mistókst að ræsa aðal PipeWire-lúppu" diff --git a/po/it/kpipewire6.po b/po/it/kpipewire6.po new file mode 100644 index 0000000..6ab775a --- /dev/null +++ b/po/it/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) 2024 This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# SPDX-FileCopyrightText: 2022, 2024 Vincenzo Reale +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-05-31 14:02+0200\n" +"Last-Translator: Vincenzo Reale \n" +"Language-Team: Italian \n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Lokalize 24.08.2\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Creazione del contesto PipeWire non riuscita" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Connessione a PipeWire non riuscita" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Avvio del ciclo principale di PipeWire non riuscito" diff --git a/po/ja/kpipewire6.po b/po/ja/kpipewire6.po new file mode 100644 index 0000000..8d7c353 --- /dev/null +++ b/po/ja/kpipewire6.po @@ -0,0 +1,30 @@ +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-06-04 21:24-0700\n" +"Last-Translator: Japanese KDE translation team \n" +"Language-Team: Japanese \n" +"Language: ja\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Accelerator-Marker: &\n" +"X-Text-Markup: kde4\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "" diff --git a/po/ka/kpipewire6.po b/po/ka/kpipewire6.po new file mode 100644 index 0000000..3c389e2 --- /dev/null +++ b/po/ka/kpipewire6.po @@ -0,0 +1,34 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-09-14 07:49+0200\n" +"Last-Translator: Temuri Doghonadze \n" +"Language-Team: Georgian \n" +"Language: ka\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 3.1.1\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "PipeWire-ის კონტექსტის შექმნის შეცდოა" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "PipeWire-სთან მიერთების შეცდომა" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "PipeWire-ის მთავარი მარყუჟის დაწყების შეცდომა" diff --git a/po/ko/kpipewire6.po b/po/ko/kpipewire6.po new file mode 100644 index 0000000..4b483ea --- /dev/null +++ b/po/ko/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# Shinjo Park , 2022. +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-07-13 15:41+0200\n" +"Last-Translator: Shinjo Park \n" +"Language-Team: Korean \n" +"Language: ko\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Lokalize 21.12.3\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "PipeWire 콘텍스트를 만들 수 없음" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "PipeWire 콘텍스트에 연결할 수 없음" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "주 PipeWire 루프를 시작할 수 없음" diff --git a/po/lt/kpipewire6.po b/po/lt/kpipewire6.po new file mode 100644 index 0000000..107ea2b --- /dev/null +++ b/po/lt/kpipewire6.po @@ -0,0 +1,35 @@ +# Lithuanian translations for kpipewire package. +# Copyright (C) 2023 This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# Automatically generated, 2023. +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2024-01-16 00:38+0200\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: lt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : n%10>=2 && (n%100<10 || n" +"%100>=20) ? 1 : n%10==0 || (n%100>10 && n%100<20) ? 2 : 3);\n" +"X-Generator: Poedit 3.0.1\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Nepavyko sukurti PipeWire konteksto" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Nepavyko prisijungti prie PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Nepavyko paleisti pagrindinio PipeWire ciklo" diff --git a/po/lv/kpipewire6.po b/po/lv/kpipewire6.po new file mode 100644 index 0000000..2fb6f3a --- /dev/null +++ b/po/lv/kpipewire6.po @@ -0,0 +1,34 @@ +# Copyright (C) 2024 This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# SPDX-FileCopyrightText: 2024 Toms TrasÅ«ns +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2024-02-15 08:41+0200\n" +"Last-Translator: Toms TrasÅ«ns \n" +"Language-Team: Latvian \n" +"Language: lv\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : " +"2);\n" +"X-Generator: Lokalize 23.08.4\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Neizdevās izveidot „PipeWire“ kontekstu" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Neizdevās savienoties ar „PipeWire“" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Neizdevās uzsākt „PipeWire“ ciklu" diff --git a/po/nl/kpipewire6.po b/po/nl/kpipewire6.po new file mode 100644 index 0000000..2056394 --- /dev/null +++ b/po/nl/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Freek de Kruijf , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-05-31 16:34+0200\n" +"Last-Translator: Freek de Kruijf \n" +"Language-Team: \n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 22.04.1\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Aanmaken van PipeWire-context is mislukt" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Verbinden met PipeWire is mislukt" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Starten van hoofd PipeWire-loop is mislukt" diff --git a/po/nn/kpipewire6.po b/po/nn/kpipewire6.po new file mode 100644 index 0000000..1499b8c --- /dev/null +++ b/po/nn/kpipewire6.po @@ -0,0 +1,34 @@ +# Translation of kpipewire6 to Norwegian Nynorsk +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-06-19 13:56+0200\n" +"Last-Translator: Karl Ove Hufthammer \n" +"Language-Team: Norwegian Nynorsk \n" +"Language: nn\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 24.11.70\n" +"X-Environment: kde\n" +"X-Accelerator-Marker: &\n" +"X-Text-Markup: kde4\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Klarte ikkje oppretta PipeWire-kontekst" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Klarte ikkje kopla til PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Klarte ikkje starta hovudlykkje for PipeWire" diff --git a/po/pa/kpipewire6.po b/po/pa/kpipewire6.po new file mode 100644 index 0000000..a8d7575 --- /dev/null +++ b/po/pa/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# A S Alam , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-06-11 08:49-0700\n" +"Last-Translator: A S Alam \n" +"Language-Team: Punjabi \n" +"Language: pa\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 21.12.2\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "ਪਾਈਪਵਾਇਰ ਭਾਗ ਬਣਾਉਣ ਲਈ ਅਸਫ਼ਲ" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "ਪਾਈਪਵਾਇਰ ਨਾਲ ਕਨੈਕਟ ਕਰਨ ਲਈ ਅਸਫ਼ਲ" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "ਮੁੱਖ ਪਾਈਪਵਾਇਰ ਲੂਪ ਸ਼ੁਰੂ ਕਰਨ ਲਈ ਅਸਫ਼ਲ" diff --git a/po/pl/kpipewire6.po b/po/pl/kpipewire6.po new file mode 100644 index 0000000..2516801 --- /dev/null +++ b/po/pl/kpipewire6.po @@ -0,0 +1,34 @@ +# Copyright (C) 2024 This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# SPDX-FileCopyrightText: 2022, 2024 Łukasz Wojniłowicz +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-06-05 11:21+0200\n" +"Last-Translator: Łukasz Wojniłowicz \n" +"Language-Team: Polish \n" +"Language: pl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" +"X-Generator: Lokalize 23.08.5\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Nie udało się utworzyć kontekstu PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Nie udało się połączyć z PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Nie udało się uruchomić głównej pętli PipeWire" diff --git a/po/pt/kpipewire6.po b/po/pt/kpipewire6.po new file mode 100644 index 0000000..227fd56 --- /dev/null +++ b/po/pt/kpipewire6.po @@ -0,0 +1,29 @@ +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-06-03 18:06+0100\n" +"Last-Translator: José Nuno Coelho Pires \n" +"Language-Team: Portuguese \n" +"Language: pt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-POFile-SpellExtra: PipeWire\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Não foi possível criar um contexto do PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Não foi possível contactar o PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Não foi possível iniciar o ciclo principal do PipeWire" diff --git a/po/pt_BR/kpipewire6.po b/po/pt_BR/kpipewire6.po new file mode 100644 index 0000000..604ee2a --- /dev/null +++ b/po/pt_BR/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Luiz Fernando Ranghetti , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-07-12 16:19-0300\n" +"Last-Translator: Luiz Fernando Ranghetti \n" +"Language-Team: Portuguese \n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Generator: Lokalize 21.12.3\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Falha ao criar o contexto PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Falha ao conectar ao PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Falha ao iniciar o loop principal do PipeWire" diff --git a/po/ro/kpipewire6.po b/po/ro/kpipewire6.po new file mode 100644 index 0000000..5060a40 --- /dev/null +++ b/po/ro/kpipewire6.po @@ -0,0 +1,34 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# Sergiu Bivol , 2024. +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-06-01 15:37+0100\n" +"Last-Translator: Sergiu Bivol \n" +"Language-Team: Romanian \n" +"Language: ro\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < " +"20)) ? 1 : 2;\n" +"X-Generator: Lokalize 21.12.3\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Crearea contextului PipeWire a eșuat" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Conectarea la PipeWire a eșuat" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Pornirea buclei principale PipeWire a eșuat" diff --git a/po/ru/kpipewire6.po b/po/ru/kpipewire6.po new file mode 100644 index 0000000..a25dcb2 --- /dev/null +++ b/po/ru/kpipewire6.po @@ -0,0 +1,34 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Olesya Gerasimenko , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-10-31 15:53+0300\n" +"Last-Translator: Olesya Gerasimenko \n" +"Language-Team: Basealt Translation Team\n" +"Language: ru\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=4; plural=n==1 ? 3 : n%10==1 && n%100!=11 ? 0 : n" +"%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Lokalize 22.04.3\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Не удалось создать контекст PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Не удалось подключиться к PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Не удалось запустить основной цикл PipeWire" diff --git a/po/sa/kpipewire6.po b/po/sa/kpipewire6.po new file mode 100644 index 0000000..596a4f3 --- /dev/null +++ b/po/sa/kpipewire6.po @@ -0,0 +1,35 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2023-09-21 23:23+0530\n" +"Last-Translator: \n" +"Language-Team: Sanskrit \n" +"Language: sa\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 3.3.2\n" +"X-Poedit-SourceCharset: UTF-8\n" +"Plural-Forms: nplurals=2; plural=(n>2);\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "PipeWire सन्दर्भं निर्मातुं असफलम्" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "PipeWire इत्यनेन सह सम्बद्धं कर्तुं असफलम्" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "मुख्यं PipeWire पाशं आरभ्यतुं असफलम्" diff --git a/po/sk/kpipewire6.po b/po/sk/kpipewire6.po new file mode 100644 index 0000000..75de36f --- /dev/null +++ b/po/sk/kpipewire6.po @@ -0,0 +1,31 @@ +# translation of kpipewire5.po to Slovak +# Roman Paholík , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire5\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-06-01 20:03+0200\n" +"Last-Translator: Roman Paholik \n" +"Language-Team: Slovak \n" +"Language: sk\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 22.04.1\n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Zlyhalo vytvorenie kontextu PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Zlyhalo pripojenie na PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Zlyhalo spustenie hlavnej slučky PipeWire" diff --git a/po/sl/kpipewire6.po b/po/sl/kpipewire6.po new file mode 100644 index 0000000..a377ad3 --- /dev/null +++ b/po/sl/kpipewire6.po @@ -0,0 +1,34 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Matjaž Jeran , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-06-01 07:51+0200\n" +"Last-Translator: Matjaž Jeran \n" +"Language-Team: Slovenian \n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n" +"%100==4 ? 3 : 0);\n" +"X-Generator: Lokalize 21.12.2\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Kreiranje konteksta PipeWire ni uspelo" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Priklop na PipeWire ni uspel" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Zagon glavne zanke PipeWire ni uspel" diff --git a/po/sv/kpipewire6.po b/po/sv/kpipewire6.po new file mode 100644 index 0000000..4d2521a --- /dev/null +++ b/po/sv/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Stefan Asserhäll , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-05-31 16:57+0200\n" +"Last-Translator: Stefan Asserhäll \n" +"Language-Team: Swedish \n" +"Language: sv\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 20.08.1\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Misslyckades skapa PipeWire-sammanhang" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Misslyckades ansluta till PipeWire-sammanhang" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Misslyckades starta PipeWire-huvudsnurra" diff --git a/po/ta/kpipewire6.po b/po/ta/kpipewire6.po new file mode 100644 index 0000000..8d9b1d6 --- /dev/null +++ b/po/ta/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Kishore G , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-07-05 21:45+0530\n" +"Last-Translator: Kishore G \n" +"Language-Team: Tamil \n" +"Language: ta\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Lokalize 22.04.2\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "PipeWire-க்கு இணைப்பை உண்டாக்க முடியவில்லை" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "" diff --git a/po/tr/kpipewire6.po b/po/tr/kpipewire6.po new file mode 100644 index 0000000..6bd2399 --- /dev/null +++ b/po/tr/kpipewire6.po @@ -0,0 +1,33 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Emir SARI , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-06-19 09:59+0300\n" +"Last-Translator: Emir SARI \n" +"Language-Team: Turkish \n" +"Language: tr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Generator: Lokalize 22.04.2\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "PipeWire bağlamı oluşturulamadı" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "PipeWire'a bağlanamadı" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Ana PipeWire döngüsü başlatılamadı" diff --git a/po/uk/kpipewire6.po b/po/uk/kpipewire6.po new file mode 100644 index 0000000..297a66d --- /dev/null +++ b/po/uk/kpipewire6.po @@ -0,0 +1,34 @@ +# Copyright (C) YEAR This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Yuri Chornoivan , 2022. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2022-05-31 08:48+0300\n" +"Last-Translator: Yuri Chornoivan \n" +"Language-Team: Ukrainian \n" +"Language: uk\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=4; plural=n==1 ? 3 : n%10==1 && n%100!=11 ? 0 : n" +"%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Lokalize 20.12.0\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "Не вдалося створити контекст PipeWire" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "Не вдалося встановити з'єднання із PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "Не вдалося запустити основний цикл PipeWire" diff --git a/po/zh_CN/kpipewire6.po b/po/zh_CN/kpipewire6.po new file mode 100644 index 0000000..b1efb86 --- /dev/null +++ b/po/zh_CN/kpipewire6.po @@ -0,0 +1,33 @@ +msgid "" +msgstr "" +"Project-Id-Version: kdeorg\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2024-04-22 15:58\n" +"Last-Translator: \n" +"Language-Team: Chinese Simplified\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Crowdin-Project: kdeorg\n" +"X-Crowdin-Project-ID: 269464\n" +"X-Crowdin-Language: zh-CN\n" +"X-Crowdin-File: /kf6-stable/messages/kpipewire/kpipewire6.pot\n" +"X-Crowdin-File-ID: 51424\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "创建 PipeWire 环境信息失败" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "无法连接到 PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "无法启动 PipeWire 主循环" diff --git a/po/zh_TW/kpipewire6.po b/po/zh_TW/kpipewire6.po new file mode 100644 index 0000000..5d623d8 --- /dev/null +++ b/po/zh_TW/kpipewire6.po @@ -0,0 +1,36 @@ +# Chinese translations for kpipewire package +# kpipewire 套件的正體中文翻譯. +# Copyright (C) 2022 This file is copyright: +# This file is distributed under the same license as the kpipewire package. +# +# Automatically generated, 2022. +# Kisaragi Hiu , 2023. +msgid "" +msgstr "" +"Project-Id-Version: kpipewire\n" +"Report-Msgid-Bugs-To: https://bugs.kde.org\n" +"POT-Creation-Date: 2023-09-25 01:41+0000\n" +"PO-Revision-Date: 2023-03-06 22:02+0900\n" +"Last-Translator: Kisaragi Hiu \n" +"Language-Team: Traditional Chinese \n" +"Language: zh_TW\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Lokalize 22.12.2\n" + +#: pipewirecore.cpp:98 +#, kde-format +msgid "Failed to create PipeWire context" +msgstr "無法建立 PipeWire 內文" + +#: pipewirecore.cpp:115 +#, kde-format +msgid "Failed to connect to PipeWire" +msgstr "無法連線到 PipeWire" + +#: pipewirecore.cpp:122 +#, kde-format +msgid "Failed to start main PipeWire loop" +msgstr "無法啟動 PipeWire 主迴圈" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..3126528 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,200 @@ +include(ECMGenerateExportHeader) +include(ECMQmlModule) +include(ECMGenerateHeaders) +include(ECMSetupVersion) + +add_definitions(-DTRANSLATION_DOMAIN=\"kpipewire6\") + +add_library(KPipeWire) + +ecm_qt_declare_logging_category(kpipewire_SRCS + HEADER logging.h + IDENTIFIER PIPEWIRE_LOGGING + CATEGORY_NAME kpipewire_logging + DEFAULT_SEVERITY Warning + DESCRIPTION "PipeWire components for KDE" + EXPORT KPipeWire) +ecm_qt_declare_logging_category(kpipewire_SRCS + HEADER logging_vaapi.h + IDENTIFIER PIPEWIREVAAPI_LOGGING + CATEGORY_NAME kpipewire_vaapi_logging + DEFAULT_SEVERITY Warning + DESCRIPTION "PipeWire components for KDE - VAAPI related messages" + EXPORT KPipeWire) +ecm_qt_declare_logging_category(kpipewiredmabuf_SRCS + HEADER logging_dmabuf.h + IDENTIFIER PIPEWIREDMABUF_LOGGING + CATEGORY_NAME kpipewire_dmabuf_logging + DEFAULT_SEVERITY Warning + DESCRIPTION "PipeWire and DMABuf components for KDE" + EXPORT KPipeWireDmaBuf) +ecm_qt_declare_logging_category(kpipewirerecord_SRCS + HEADER logging_record.h + IDENTIFIER PIPEWIRERECORD_LOGGING + CATEGORY_NAME kpipewire_record_logging + DEFAULT_SEVERITY Warning + DESCRIPTION "PipeWire and FFmpeg components for KDE" + EXPORT KPipeWireRecord) +ecm_qt_declare_logging_category(kpipewirerecord_SRCS + HEADER logging_libav.h + IDENTIFIER PIPEWIRELIBAV_LOGGING + CATEGORY_NAME kpipewire_libav_logging + DEFAULT_SEVERITY Warning + DESCRIPTION "PipeWire components for KDE - libav log output" + DEFAULT_SEVERITY Info) + +ecm_qt_install_logging_categories( + EXPORT KPipeWire + FILE kpipewire.categories + DESTINATION "${KDE_INSTALL_LOGGINGCATEGORIESDIR}" +) + +ecm_qt_install_logging_categories( + EXPORT KPipeWireRecord + FILE kpipewirerecord.categories + DESTINATION "${KDE_INSTALL_LOGGINGCATEGORIESDIR}" +) + +target_sources(KPipeWire PRIVATE + pipewirecore.cpp + pipewiresourceitem.cpp + pipewiresourcestream.cpp + glhelpers.cpp + pwhelpers.cpp + vaapiutils.cpp + ${kpipewire_SRCS} +) + +# these are features pipewire use extensively and make it hard to look at compile logs +target_compile_options(KPipeWire PUBLIC -Wno-gnu-statement-expression-from-macro-expansion -Wno-zero-as-null-pointer-constant -Wno-c99-extensions -Wno-cast-align) + +target_link_libraries(KPipeWire PRIVATE Qt::Quick Qt::GuiPrivate KF6::I18n + KF6::CoreAddons PkgConfig::PipeWire epoxy::epoxy PkgConfig::GBM Libdrm::Libdrm PkgConfig::LIBVA PkgConfig::LIBVA-drm) + +target_link_libraries(KPipeWire PRIVATE EGL::EGL) + +target_include_directories(KPipeWire PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + PUBLIC "$" ${PipeWire_INCLUDE_DIRS} + INTERFACE "$") +set_target_properties(KPipeWire PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + ) + +ecm_generate_export_header(KPipeWire + BASE_NAME KPipeWire + VERSION ${PROJECT_VERSION} +) + +ecm_generate_headers(KPipeWire_HEADERS + HEADER_NAMES + PipeWireSourceStream + PipeWireSourceItem + REQUIRED_HEADERS KPipeWire_HEADERS +) + +install(FILES + ${KPipeWire_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/kpipewire_export.h + DESTINATION ${KDE_INSTALL_INCLUDEDIR}/KPipeWire COMPONENT Devel +) + +add_library(KPipeWireDmaBuf dmabufhandler.cpp ${kpipewiredmabuf_SRCS}) +target_link_libraries(KPipeWireDmaBuf PUBLIC KPipeWire + PRIVATE Qt::Core Qt::Gui PkgConfig::GBM + epoxy::epoxy Libdrm::Libdrm Qt::GuiPrivate +) + +set_target_properties(KPipeWireDmaBuf PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + ) + +ecm_generate_export_header(KPipeWireDmaBuf + BASE_NAME KPipeWireDmaBuf + VERSION ${PROJECT_VERSION} +) + +ecm_generate_headers(KPipeWireDmaBuf_HEADERS + HEADER_NAMES + DmaBufHandler + REQUIRED_HEADERS KPipeWireDmaBuf_HEADERS +) + +install(FILES + ${KPipeWireDmaBuf_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/kpipewiredmabuf_export.h + DESTINATION ${KDE_INSTALL_INCLUDEDIR}/KPipeWire COMPONENT Devel +) + +add_library(KPipeWireRecord ${kpipewirerecord_SRCS} + pipewirebaseencodedstream.cpp + pipewireencodedstream.cpp + pipewirerecord.cpp + pipewireproduce.cpp + encoder.cpp + h264vaapiencoder.cpp + libx264encoder.cpp + libopenh264encoder.cpp + libvpxencoder.cpp + libvpxvp9encoder.cpp +) +target_link_libraries(KPipeWireRecord PUBLIC KPipeWire + PRIVATE Qt::Core Qt::Gui KF6::CoreAddons KPipeWireDmaBuf + PkgConfig::AVCodec PkgConfig::AVUtil PkgConfig::AVFormat PkgConfig::AVFilter PkgConfig::GBM PkgConfig::SWScale + epoxy::epoxy Libdrm::Libdrm Qt::GuiPrivate +) + +ecm_generate_headers(KPipeWireRecord_HEADERS + HEADER_NAMES + PipeWireRecord + PipeWireEncodedStream + PipeWireBaseEncodedStream + REQUIRED_HEADERS KPipeWireRecord_HEADERS +) +set_target_properties(KPipeWireRecord PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + ) + +install(FILES + ${KPipeWireRecord_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/kpipewire_version.h + DESTINATION ${KDE_INSTALL_INCLUDEDIR}/KPipeWire COMPONENT Devel +) + +install(TARGETS KPipeWire KPipeWireRecord KPipeWireDmaBuf EXPORT KPipeWireTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) + + +ecm_setup_version(PROJECT VARIABLE_PREFIX KPIPEWIRE + VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kpipewire_version.h" + PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KPipeWireConfigVersion.cmake" + SOVERSION ${PROJECT_VERSION_MAJOR}) + +set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KPipeWire") +install(EXPORT KPipeWireTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KPipeWireTargets.cmake NAMESPACE K::) + +configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/KPipeWireConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/KPipeWireConfig.cmake" + INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} + ) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KPipeWireConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/KPipeWireConfigVersion.cmake" + DESTINATION "${CMAKECONFIG_INSTALL_DIR}" + COMPONENT Devel ) + + +################# +# Declarative + +ecm_add_qml_module(KPipeWireDeclarative URI "org.kde.pipewire" VERSION 1.0) +target_sources(KPipeWireDeclarative PRIVATE kpipewiredeclarativeplugin.cpp) +target_link_libraries(KPipeWireDeclarative PRIVATE KPipeWire Qt::Quick) +ecm_finalize_qml_module(KPipeWireDeclarative DESTINATION ${KDE_INSTALL_QMLDIR}) + +ecm_add_qml_module(KPipeWireRecordDeclarative URI "org.kde.pipewire.record" VERSION 1.0) +target_sources(KPipeWireRecordDeclarative PRIVATE kpipewirerecorddeclarativeplugin.cpp) +target_link_libraries(KPipeWireRecordDeclarative PRIVATE KPipeWire KPipeWireRecord Qt::Quick) +ecm_finalize_qml_module(KPipeWireRecordDeclarative DESTINATION ${KDE_INSTALL_QMLDIR}) + +add_subdirectory(monitors) diff --git a/src/KPipeWireConfig.cmake.in b/src/KPipeWireConfig.cmake.in new file mode 100644 index 0000000..a3cffd6 --- /dev/null +++ b/src/KPipeWireConfig.cmake.in @@ -0,0 +1,9 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) +find_dependency(Qt6Core @REQUIRED_QT_VERSION@) +find_dependency(Qt6Gui @REQUIRED_QT_VERSION@) + + +include("${CMAKE_CURRENT_LIST_DIR}/KPipeWireTargets.cmake") +@PACKAGE_INCLUDE_QCHTARGETS@ diff --git a/src/Messages.sh b/src/Messages.sh new file mode 100755 index 0000000..c3a53d4 --- /dev/null +++ b/src/Messages.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +# Extract strings from all source files. +# If your framework depends on KI18n, use $XGETTEXT. If it uses Qt translation +# system, use $EXTRACT_TR_STRINGS. +$XGETTEXT `find . -name \*.cpp -o -name \*.h` -o $podir/kpipewire6.pot diff --git a/src/dmabufhandler.cpp b/src/dmabufhandler.cpp new file mode 100644 index 0000000..b25462a --- /dev/null +++ b/src/dmabufhandler.cpp @@ -0,0 +1,222 @@ +// SPDX-FileCopyrightText: 2022 Aleix Pol i Gonzalez +// SPDX-License-Identifier: Apache-2.0 + +#include "dmabufhandler.h" +#include "glhelpers.h" +#include +#include +#include +#include +#include +#include +#include + +static QByteArray fetchRenderNode() +{ + int max_devices = drmGetDevices2(0, nullptr, 0); + if (max_devices <= 0) { + qCWarning(PIPEWIREDMABUF_LOGGING) << "drmGetDevices2() has not found any devices (errno=" << -max_devices << ")"; + return "/dev/dri/renderD128"; + } + + std::vector devices(max_devices); + int ret = drmGetDevices2(0, devices.data(), max_devices); + if (ret < 0) { + qCWarning(PIPEWIREDMABUF_LOGGING) << "drmGetDevices2() returned an error " << ret; + return "/dev/dri/renderD128"; + } + + QByteArray render_node; + + for (const drmDevicePtr &device : devices) { + if (device->available_nodes & (1 << DRM_NODE_RENDER)) { + render_node = device->nodes[DRM_NODE_RENDER]; + break; + } + } + + drmFreeDevices(devices.data(), ret); + return render_node; +} + +DmaBufHandler::DmaBufHandler() +{ +} + +DmaBufHandler::~DmaBufHandler() +{ + if (m_drmFd) { + close(m_drmFd); + } +} + +void DmaBufHandler::setupEgl() +{ + if (m_eglInitialized) { + return; + } + + m_egl.display = static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("egldisplay")); + + // Use eglGetPlatformDisplayEXT() to get the display pointer + // if the implementation supports it. + if (!epoxy_has_egl_extension(m_egl.display, "EGL_EXT_platform_base") || !epoxy_has_egl_extension(m_egl.display, "EGL_MESA_platform_gbm")) { + qCWarning(PIPEWIREDMABUF_LOGGING) << "One of required EGL extensions is missing"; + return; + } + + if (m_egl.display == EGL_NO_DISPLAY) { + m_egl.display = eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_KHR, (void *)EGL_DEFAULT_DISPLAY, nullptr); + } + if (m_egl.display == EGL_NO_DISPLAY) { + const QByteArray renderNode = fetchRenderNode(); + m_drmFd = open(renderNode.constData(), O_RDWR); + + if (m_drmFd < 0) { + qCWarning(PIPEWIREDMABUF_LOGGING) << "Failed to open drm render node" << renderNode << "with error: " << strerror(errno); + return; + } + + m_gbmDevice = gbm_create_device(m_drmFd); + + if (!m_gbmDevice) { + qCWarning(PIPEWIREDMABUF_LOGGING) << "Cannot create GBM device: " << strerror(errno); + return; + } + m_egl.display = eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, m_gbmDevice, nullptr); + } + + if (m_egl.display == EGL_NO_DISPLAY) { + qCWarning(PIPEWIREDMABUF_LOGGING) << "Error during obtaining EGL display: " << GLHelpers::formatGLError(eglGetError()); + return; + } + + EGLint major, minor; + if (eglInitialize(m_egl.display, &major, &minor) == EGL_FALSE) { + qCWarning(PIPEWIREDMABUF_LOGGING) << "Error during eglInitialize: " << GLHelpers::formatGLError(eglGetError()); + return; + } + + if (eglBindAPI(EGL_OPENGL_API) == EGL_FALSE) { + qCWarning(PIPEWIREDMABUF_LOGGING) << "bind OpenGL API failed"; + return; + } + + EGLConfig configs; + auto createConfig = [&] { + static const EGLint configAttribs[] = { + EGL_SURFACE_TYPE, + EGL_WINDOW_BIT, + EGL_RED_SIZE, + 8, + EGL_GREEN_SIZE, + 8, + EGL_BLUE_SIZE, + 8, + EGL_RENDERABLE_TYPE, + EGL_OPENGL_BIT, + EGL_CONFIG_CAVEAT, + EGL_NONE, + EGL_NONE, + }; + + EGLint count = 333; + if (eglChooseConfig(m_egl.display, configAttribs, &configs, 1, &count) == EGL_FALSE) { + qCWarning(PIPEWIREDMABUF_LOGGING) << "choose config failed"; + return false; + } + // if (count != 1) { + qCWarning(PIPEWIREDMABUF_LOGGING) << "eglChooseConfig returned this many configs:" << count; + // return false; + // } + return true; + }; + + bool b = createConfig(); + static const EGLint configAttribs[] = {EGL_CONTEXT_OPENGL_DEBUG, EGL_TRUE, EGL_NONE}; + Q_ASSERT(configs); + m_egl.context = eglCreateContext(m_egl.display, b ? configs : EGL_NO_CONFIG_KHR, EGL_NO_CONTEXT, configAttribs); + + Q_ASSERT(b); + Q_ASSERT(m_egl.context); + if (m_egl.context == EGL_NO_CONTEXT) { + qCWarning(PIPEWIREDMABUF_LOGGING) << "Couldn't create EGL context: " << GLHelpers::formatEGLError(eglGetError()); + return; + } + + qCDebug(PIPEWIREDMABUF_LOGGING) << "Egl initialization succeeded"; + qCDebug(PIPEWIREDMABUF_LOGGING) << QStringLiteral("EGL version: %1.%2").arg(major).arg(minor); + + m_eglInitialized = true; +} + +GLenum closestGLType(const QImage &image) +{ + switch (image.format()) { + case QImage::Format_RGB888: + return GL_RGB; + case QImage::Format_BGR888: + return GL_BGR; + case QImage::Format_RGB32: + case QImage::Format_RGBX8888: + case QImage::Format_RGBA8888: + case QImage::Format_RGBA8888_Premultiplied: + return GL_RGBA; + default: + qDebug() << "cannot convert QImage format to GLType" << image.format(); + return GL_RGBA; + } +} + +bool DmaBufHandler::downloadFrame(QImage &qimage, const PipeWireFrame &frame) +{ + Q_ASSERT(frame.dmabuf); + const QSize streamSize = {frame.dmabuf->width, frame.dmabuf->height}; + Q_ASSERT(qimage.size() == streamSize); + setupEgl(); + if (!m_eglInitialized) { + return false; + } + + if (!eglMakeCurrent(m_egl.display, EGL_NO_SURFACE, EGL_NO_SURFACE, m_egl.context)) { + qCWarning(PIPEWIREDMABUF_LOGGING) << "Failed to make context current" << GLHelpers::formatEGLError(eglGetError()); + return false; + } + EGLImageKHR image = + GLHelpers::createImage(m_egl.display, *frame.dmabuf, PipeWireSourceStream::spaVideoFormatToDrmFormat(frame.format), qimage.size(), m_gbmDevice); + + if (image == EGL_NO_IMAGE_KHR) { + qCWarning(PIPEWIREDMABUF_LOGGING) << "Failed to record frame: Error creating EGLImageKHR - " << GLHelpers::formatEGLError(eglGetError()); + return false; + } + + GLHelpers::initDebugOutput(); + // create GL 2D texture for framebuffer + GLuint texture; + GLuint fbo; + glGenTextures(1, &texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glBindTexture(GL_TEXTURE_2D, texture); + + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + texture, 0); + if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + glDeleteFramebuffers(1, &fbo); + glDeleteTextures(1, &texture); + eglDestroyImageKHR(m_egl.display, image); + return false; + } + + glReadPixels(0, 0, frame.dmabuf->width, frame.dmabuf->height, closestGLType(qimage), GL_UNSIGNED_BYTE, qimage.bits()); + + glDeleteFramebuffers(1, &fbo); + glDeleteTextures(1, &texture); + eglDestroyImageKHR(m_egl.display, image); + return true; +} diff --git a/src/dmabufhandler.h b/src/dmabufhandler.h new file mode 100644 index 0000000..50186b2 --- /dev/null +++ b/src/dmabufhandler.h @@ -0,0 +1,36 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol i Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#ifndef DMABUFHANDLER_H +#define DMABUFHANDLER_H + +#include "kpipewiredmabuf_export.h" +#include "pipewiresourcestream.h" +#include +#include + +class KPIPEWIREDMABUF_EXPORT DmaBufHandler +{ +public: + DmaBufHandler(); + ~DmaBufHandler(); + + bool downloadFrame(QImage &image, const PipeWireFrame &frame); + +private: + void setupEgl(); + bool m_eglInitialized = false; + qint32 m_drmFd = 0; // for GBM buffer mmap + gbm_device *m_gbmDevice = nullptr; // for passed GBM buffer retrieval + + struct EGLStruct { + EGLDisplay display = EGL_NO_DISPLAY; + EGLContext context = EGL_NO_CONTEXT; + }; + EGLStruct m_egl; +}; + +#endif // DMABUFHANDLER_H diff --git a/src/encoder.cpp b/src/encoder.cpp new file mode 100644 index 0000000..43adb3c --- /dev/null +++ b/src/encoder.cpp @@ -0,0 +1,455 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + SPDX-FileCopyrightText: 2023 Marco Martin + SPDX-FileCopyrightText: 2023 Arjen Hiemstra + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "encoder_p.h" + +#include + +extern "C" { +#include +#include +#include +#include +#include +#include +#include +#include +} + +#include + +#include "vaapiutils_p.h" + +#include "logging_record.h" + +#undef av_err2str +// The one provided by libav fails to compile on GCC due to passing data from the function scope outside +char str[AV_ERROR_MAX_STRING_SIZE]; +char *av_err2str(int errnum) +{ + return av_make_error_string(str, AV_ERROR_MAX_STRING_SIZE, errnum); +} + +static AVPixelFormat convertQImageFormatToAVPixelFormat(QImage::Format format) +{ + // Listing those handed by SpaToQImageFormat + switch (format) { + case QImage::Format_RGB888: + return AV_PIX_FMT_RGB24; + case QImage::Format_BGR888: + return AV_PIX_FMT_BGR24; + case QImage::Format_RGBX8888: + case QImage::Format_RGBA8888_Premultiplied: + return AV_PIX_FMT_RGBA; + case QImage::Format_RGB32: + case QImage::Format_ARGB32: + return AV_PIX_FMT_RGB32; + default: + qDebug() << "Unexpected pixel format" << format; + return AV_PIX_FMT_RGB32; + } +} + +static int percentageToFrameQuality(quint8 quality) +{ + return std::max(1, int(FF_LAMBDA_MAX - (quality / 100.0) * FF_LAMBDA_MAX)); +} + +Encoder::Encoder(PipeWireProduce *produce) + : QObject(nullptr) + , m_produce(produce) +{ +} + +Encoder::~Encoder() +{ + if (m_avFilterGraph) { + avfilter_graph_free(&m_avFilterGraph); + } + + if (m_avCodecContext) { + avcodec_close(m_avCodecContext); + av_free(m_avCodecContext); + } +} + +std::pair Encoder::encodeFrame(int maximumFrames) +{ + auto frame = av_frame_alloc(); + if (!frame) { + qFatal("Failed to allocate memory"); + } + + int filtered = 0; + int queued = 0; + + for (;;) { + if (auto result = av_buffersink_get_frame(m_outputFilter, frame); result < 0) { + if (result != AVERROR_EOF && result != AVERROR(EAGAIN)) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Failed receiving filtered frame:" << av_err2str(result); + } + break; + } + + filtered++; + + if (queued + 1 < maximumFrames) { + auto ret = -1; + { + std::lock_guard guard(m_avCodecMutex); + ret = avcodec_send_frame(m_avCodecContext, frame); + } + if (ret < 0) { + if (ret != AVERROR_EOF && ret != AVERROR(EAGAIN)) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Error sending a frame for encoding:" << av_err2str(ret); + } + break; + } + queued++; + } else { + qCWarning(PIPEWIRERECORD_LOGGING) << "Encode queue is full, discarding filtered frame" << frame->pts; + } + av_frame_unref(frame); + } + + av_frame_free(&frame); + + return std::make_pair(filtered, queued); +} + +int Encoder::receivePacket() +{ + auto packet = av_packet_alloc(); + if (!packet) { + qFatal("Failed to allocate memory"); + } + + int received = 0; + + for (;;) { + auto ret = -1; + { + std::lock_guard guard(m_avCodecMutex); + ret = avcodec_receive_packet(m_avCodecContext, packet); + } + if (ret < 0) { + if (ret != AVERROR_EOF && ret != AVERROR(EAGAIN)) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Error encoding a frame: " << av_err2str(ret); + } + av_packet_unref(packet); + break; + } + + received++; + + m_produce->processPacket(packet); + av_packet_unref(packet); + } + + av_packet_free(&packet); + + return received; +} + +void Encoder::finish() +{ + std::lock_guard guard(m_avCodecMutex); + avcodec_send_frame(m_avCodecContext, nullptr); +} + +AVCodecContext *Encoder::avCodecContext() const +{ + return m_avCodecContext; +} + +void Encoder::setQuality(std::optional quality) +{ + m_quality = quality; + if (m_avCodecContext) { + m_avCodecContext->global_quality = percentageToAbsoluteQuality(quality); + } +} + +bool Encoder::supportsHardwareEncoding() +{ + return !VaapiUtils::instance()->devicePath().isEmpty(); +} + +void Encoder::setEncodingPreference(PipeWireBaseEncodedStream::EncodingPreference preference) +{ + m_encodingPreference = preference; +} + +void Encoder::applyEncodingPreference(AVDictionary *options) +{ + switch (m_encodingPreference) { + case PipeWireBaseEncodedStream::EncodingPreference::NoPreference: + av_dict_set(&options, "preset", "veryfast", 0); + break; + case PipeWireBaseEncodedStream::EncodingPreference::Quality: + av_dict_set(&options, "preset", "medium", 0); + break; + case PipeWireBaseEncodedStream::EncodingPreference::Speed: + av_dict_set(&options, "preset", "ultrafast", 0); + av_dict_set(&options, "tune", "zerolatency", 0); + break; + case PipeWireBaseEncodedStream::EncodingPreference::Size: + av_dict_set(&options, "preset", "slow", 0); + break; + default: // Same as NoPreference + av_dict_set(&options, "preset", "veryfast", 0); + break; + } +} + +SoftwareEncoder::SoftwareEncoder(PipeWireProduce *produce) + : Encoder(produce) +{ +} + +bool SoftwareEncoder::filterFrame(const PipeWireFrame &frame) +{ + auto size = m_produce->m_stream->size(); + + QImage image; + if (frame.dmabuf) { + image = QImage(m_produce->m_stream->size(), QImage::Format_RGBA8888_Premultiplied); + if (!m_dmaBufHandler.downloadFrame(image, frame)) { + m_produce->m_stream->renegotiateModifierFailed(frame.format, frame.dmabuf->modifier); + return false; + } + } else if (frame.dataFrame) { + image = frame.dataFrame->toImage(); + } else { + return false; + } + + AVFrame *avFrame = av_frame_alloc(); + if (!avFrame) { + qFatal("Failed to allocate memory"); + } + avFrame->format = convertQImageFormatToAVPixelFormat(image.format()); + avFrame->width = size.width(); + avFrame->height = size.height(); + if (m_quality) { + avFrame->quality = percentageToFrameQuality(m_quality.value()); + } + + av_frame_get_buffer(avFrame, 32); + + const std::uint8_t *buffers[] = {image.constBits(), nullptr}; + const int strides[] = {static_cast(image.bytesPerLine()), 0, 0, 0}; + + av_image_copy(avFrame->data, avFrame->linesize, buffers, strides, static_cast(avFrame->format), size.width(), size.height()); + + if (frame.presentationTimestamp) { + avFrame->pts = m_produce->framePts(frame.presentationTimestamp); + } + + if (auto result = av_buffersrc_add_frame(m_inputFilter, avFrame); result < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Failed to submit frame for filtering"; + } + + return true; +} + +bool SoftwareEncoder::createFilterGraph(const QSize &size) +{ + m_avFilterGraph = avfilter_graph_alloc(); + if (!m_avFilterGraph) { + qFatal("Failed to allocate memory"); + } + + int ret = avfilter_graph_create_filter(&m_inputFilter, + avfilter_get_by_name("buffer"), + "in", + "width=1:height=1:pix_fmt=rgba:time_base=1/1", + nullptr, + m_avFilterGraph); + if (ret < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Failed to create the buffer filter"; + return false; + } + + auto parameters = av_buffersrc_parameters_alloc(); + if (!parameters) { + qFatal("Failed to allocate memory"); + } + + parameters->format = AV_PIX_FMT_RGBA; + parameters->width = size.width(); + parameters->height = size.height(); + parameters->time_base = {1, 1000}; + + av_buffersrc_parameters_set(m_inputFilter, parameters); + av_free(parameters); + parameters = nullptr; + + ret = avfilter_graph_create_filter(&m_outputFilter, avfilter_get_by_name("buffersink"), "out", nullptr, nullptr, m_avFilterGraph); + if (ret < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not create buffer output filter"; + return false; + } + + auto inputs = avfilter_inout_alloc(); + if (!inputs) { + qFatal("Failed to allocate memory"); + } + inputs->name = av_strdup("in"); + inputs->filter_ctx = m_inputFilter; + inputs->pad_idx = 0; + inputs->next = nullptr; + + auto outputs = avfilter_inout_alloc(); + if (!outputs) { + qFatal("Failed to allocate memory"); + } + outputs->name = av_strdup("out"); + outputs->filter_ctx = m_outputFilter; + outputs->pad_idx = 0; + outputs->next = nullptr; + + ret = avfilter_graph_parse(m_avFilterGraph, m_filterGraphToParse.toUtf8().data(), outputs, inputs, NULL); + if (ret < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Failed creating filter graph"; + return false; + } + + ret = avfilter_graph_config(m_avFilterGraph, nullptr); + if (ret < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Failed configuring filter graph"; + return false; + } + + return true; +} + +HardwareEncoder::HardwareEncoder(PipeWireProduce *produce) + : Encoder(produce) +{ +} + +HardwareEncoder::~HardwareEncoder() +{ + if (m_drmFramesContext) { + av_free(m_drmFramesContext); + } + + if (m_drmContext) { + av_free(m_drmContext); + } +} + +bool HardwareEncoder::filterFrame(const PipeWireFrame &frame) +{ + if (!frame.dmabuf) { + return false; + } + + auto attribs = frame.dmabuf.value(); + + auto drmFrame = av_frame_alloc(); + if (!drmFrame) { + qFatal("Failed to allocate memory"); + } + drmFrame->format = AV_PIX_FMT_DRM_PRIME; + drmFrame->width = attribs.width; + drmFrame->height = attribs.height; + if (m_quality) { + drmFrame->quality = percentageToFrameQuality(m_quality.value()); + } + + auto frameDesc = new AVDRMFrameDescriptor; + frameDesc->nb_layers = 1; + frameDesc->layers[0].nb_planes = attribs.planes.count(); + frameDesc->layers[0].format = attribs.format; + for (int i = 0; i < attribs.planes.count(); ++i) { + const auto &plane = attribs.planes[i]; + frameDesc->layers[0].planes[i].object_index = 0; + frameDesc->layers[0].planes[i].offset = plane.offset; + frameDesc->layers[0].planes[i].pitch = plane.stride; + } + frameDesc->nb_objects = 1; + frameDesc->objects[0].fd = attribs.planes[0].fd; + frameDesc->objects[0].format_modifier = attribs.modifier; + frameDesc->objects[0].size = attribs.width * attribs.height * 4; + + drmFrame->data[0] = reinterpret_cast(frameDesc); + drmFrame->buf[0] = av_buffer_create(reinterpret_cast(frameDesc), sizeof(*frameDesc), av_buffer_default_free, nullptr, 0); + if (frame.presentationTimestamp) { + drmFrame->pts = m_produce->framePts(frame.presentationTimestamp); + } + + if (auto result = av_buffersrc_add_frame(m_inputFilter, drmFrame); result < 0) { + qCDebug(PIPEWIRERECORD_LOGGING) << "Failed sending frame for encoding" << av_err2str(result); + av_frame_unref(drmFrame); + return false; + } + + av_frame_free(&drmFrame); + return true; +} + +QByteArray HardwareEncoder::checkVaapi(const QSize &size) +{ + auto utils = VaapiUtils::instance(); + if (utils->devicePath().isEmpty()) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Hardware encoding is not supported on this device."; + return QByteArray{}; + } + + auto minSize = utils->minimumSize(); + if (size.width() < minSize.width() || size.height() < minSize.height()) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Requested size" << size << "less than minimum supported hardware size" << minSize; + return QByteArray{}; + } + + auto maxSize = utils->maximumSize(); + if (size.width() > maxSize.width() || size.height() > maxSize.height()) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Requested size" << size << "exceeds maximum supported hardware size" << maxSize; + return QByteArray{}; + } + + return utils->devicePath(); +} + +bool HardwareEncoder::createDrmContext(const QSize &size) +{ + auto path = checkVaapi(size); + if (path.isEmpty()) { + return false; + } + + int err = av_hwdevice_ctx_create(&m_drmContext, AV_HWDEVICE_TYPE_DRM, path.data(), NULL, AV_HWFRAME_MAP_READ); + if (err < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Failed to create DRM device. Error" << av_err2str(err); + return false; + } + + m_drmFramesContext = av_hwframe_ctx_alloc(m_drmContext); + if (!m_drmFramesContext) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Failed to create DRM frames context"; + return false; + } + + auto framesContext = reinterpret_cast(m_drmFramesContext->data); + framesContext->format = AV_PIX_FMT_DRM_PRIME; + framesContext->sw_format = AV_PIX_FMT_0BGR; + framesContext->width = size.width(); + framesContext->height = size.height(); + + if (auto result = av_hwframe_ctx_init(m_drmFramesContext); result < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Failed initializing DRM frames context" << av_err2str(result); + av_buffer_unref(&m_drmFramesContext); + return false; + } + + return true; +} + +#include "moc_encoder_p.cpp" diff --git a/src/encoder_p.h b/src/encoder_p.h new file mode 100644 index 0000000..1acd254 --- /dev/null +++ b/src/encoder_p.h @@ -0,0 +1,186 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + SPDX-FileCopyrightText: 2023 Marco Martin + SPDX-FileCopyrightText: 2023 Arjen Hiemstra + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include + +#include + +#include "dmabufhandler.h" +#include "pipewireproduce_p.h" + +extern "C" { +#include "libavcodec/avcodec.h" +#include "libavfilter/avfilter.h" +} + +#undef av_err2str +// The one provided by libav fails to compile on GCC due to passing data from the function scope outside +char *av_err2str(int errnum); + +struct PipeWireFrame; +class PipeWireProduce; + +/** + * Base class for objects that encapsulate encoder logic and state. + */ +class Encoder : public QObject +{ + Q_OBJECT +public: + enum class H264Profile { Baseline, Main, High }; + + /** + * Constructor. + * + * @param produce The PipeWireProduce instance that owns this encoder. + */ + Encoder(PipeWireProduce *produce); + ~Encoder() override; + + /** + * Initialize and setup the encoder. + * + * @param size The size of the stream being encoded. + * + * @return true if initailization was succesful, false if not. + */ + virtual bool initialize(const QSize &size) = 0; + /** + * Process a PipeWire frame and pass it to libav for filtering. + * + * @param frame The frame to process. + * + * @note This method will be called on its own thread. + */ + virtual bool filterFrame(const PipeWireFrame &frame) = 0; + /** + * Get the next finished frames from the libav filter chain and queue them for encoding. + * + * @param maximumFrames The maximum number of frames that can be queued for encoding. + * + * @return A pair with the number of frames removed from the filter chain as first entry + * and the number of frames queued for encoding as the second entry. + * + * @note This method will be called on its own thread. + */ + virtual std::pair encodeFrame(int maximumFrames); + /** + * Get the next encoded frames from libav and pass them to PipeWireProduce. + * + * @return The number of encoded frames that were received. + * + * @note This method will be called on its own thread. + */ + virtual int receivePacket(); + /** + * End encoding and perform any necessary cleanup. + */ + virtual void finish(); + + /** + * Return the AVCodecContext for this encoder. + */ + AVCodecContext *avCodecContext() const; + + /** + * Set the quality level, from 0 (lowest) to 100 (highest). + * + * Internally this will be converted to an encoder-specific quality value. + */ + void setQuality(std::optional quality); + + static bool supportsHardwareEncoding(); + + void setEncodingPreference(PipeWireBaseEncodedStream::EncodingPreference preference); + +protected: + virtual int percentageToAbsoluteQuality(const std::optional &quality) = 0; + + PipeWireProduce *m_produce; + + AVCodecContext *m_avCodecContext = nullptr; + std::mutex m_avCodecMutex; + + AVFilterGraph *m_avFilterGraph = nullptr; + AVFilterContext *m_inputFilter = nullptr; + AVFilterContext *m_outputFilter = nullptr; + + std::optional m_quality; + PipeWireBaseEncodedStream::EncodingPreference m_encodingPreference; + virtual void applyEncodingPreference(AVDictionary *options); +}; + +/** + * Encoder subclass that can be used as base class for software encoders. + */ +class SoftwareEncoder : public Encoder +{ +public: + SoftwareEncoder(PipeWireProduce *produce); + + bool filterFrame(const PipeWireFrame &frame) override; + +protected: + /** + * Create a default filter graph that converts from RGBA to YUV420P. + * + * @param size The size of the stream to encode. + */ + bool createFilterGraph(const QSize &size); + + /** + * The filter graph to be passed to FFmpeg to parse. + * + * Adjust this if you need to insert any extra filters in between input and + * output filters. + * + * Make sure that the output format of the filter graph is yuv420p. + */ + QString m_filterGraphToParse = QStringLiteral("format=pix_fmts=yuv420p"); + DmaBufHandler m_dmaBufHandler; +}; + +/** + * Encoder subclass that can be used as base class for hardware encoders. + */ +class HardwareEncoder : public Encoder +{ +public: + HardwareEncoder(PipeWireProduce *produce); + ~HardwareEncoder() override; + + bool filterFrame(const PipeWireFrame &frame) override; + +protected: + /** + * Check if VAAPI is supported for a given size stream. + * + * @param size The size of the stream to check. + * + * @return The path to a device node that can encode this stream. If + * the stream cannot be encoded by the current hardware, an + * empty QByteArray will be returned. + */ + QByteArray checkVaapi(const QSize &size); + /** + * Create the libav contexts for the DRM subsystem. + * + * These contexts are used when doing import of dma-buf based frames. + * + * @param path The path to a device node where the frames are. + * @param size The size of the frames. + * + * @return true if the contexts were successfully created, false if not. + */ + bool createDrmContext(const QSize &size); + + AVBufferRef *m_drmContext = nullptr; + AVBufferRef *m_drmFramesContext = nullptr; +}; diff --git a/src/glhelpers.cpp b/src/glhelpers.cpp new file mode 100644 index 0000000..bf95ce0 --- /dev/null +++ b/src/glhelpers.cpp @@ -0,0 +1,177 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "glhelpers.h" +#include +#include +#include +#include +#include +#include + +#include + +namespace GLHelpers +{ + +void initDebugOutputOnce() +{ + auto callback = [](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const GLvoid *userParam) { + Q_UNUSED(source) + Q_UNUSED(severity) + Q_UNUSED(userParam) + while (length && std::isspace(message[length - 1])) { + --length; + } + + switch (type) { + case GL_DEBUG_TYPE_ERROR: + case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: + qCWarning(PIPEWIRE_LOGGING, "%#x: %.*s", id, length, message); + break; + + case GL_DEBUG_TYPE_OTHER: + case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: + case GL_DEBUG_TYPE_PORTABILITY: + case GL_DEBUG_TYPE_PERFORMANCE: + default: + qCDebug(PIPEWIRE_LOGGING, "%#x: %.*s", id, length, message); + break; + } + }; + glDebugMessageCallback(callback, nullptr); + glEnable(GL_DEBUG_OUTPUT); +} + +static std::once_flag initDebugOnce; +void initDebugOutput() +{ + if (!PIPEWIRE_LOGGING().isDebugEnabled()) { + return; + } + + if (!eglGetCurrentDisplay()) { + // Epoxy gets very confused and it will crash + return; + } + + std::call_once(initDebugOnce, initDebugOutputOnce); +} + +#define ENUM_STRING(x) case x: return #x; + +QByteArray formatGLError(GLenum err) +{ + switch (err) { + ENUM_STRING(GL_NO_ERROR) + ENUM_STRING(GL_INVALID_ENUM) + ENUM_STRING(GL_INVALID_VALUE) + ENUM_STRING(GL_INVALID_OPERATION) + ENUM_STRING(GL_STACK_OVERFLOW) + ENUM_STRING(GL_STACK_UNDERFLOW) + ENUM_STRING(GL_OUT_OF_MEMORY) + default: + return QByteArray("0x") + QByteArray::number(err, 16); + } +} + +QByteArray formatEGLError(GLenum err) +{ + switch (err) { + ENUM_STRING(EGL_SUCCESS) + ENUM_STRING(EGL_BAD_DISPLAY) + ENUM_STRING(EGL_BAD_CONTEXT) + ENUM_STRING(EGL_BAD_PARAMETER) + ENUM_STRING(EGL_BAD_MATCH) + ENUM_STRING(EGL_BAD_ACCESS) + ENUM_STRING(EGL_BAD_ALLOC) + ENUM_STRING(EGL_BAD_CONFIG) + default: + return QByteArray("0x") + QByteArray::number(err, 16); + } +} + +EGLImage createImage(EGLDisplay display, const DmaBufAttributes &dmabufAttribs, uint32_t format, const QSize &size, gbm_device *gbmDevice) +{ + Q_ASSERT(!size.isEmpty()); + gbm_bo *imported = nullptr; + if (gbmDevice) { + gbm_import_fd_data importInfo = {static_cast(dmabufAttribs.planes[0].fd), + static_cast(size.width()), + static_cast(size.height()), + static_cast(dmabufAttribs.planes[0].stride), + GBM_BO_FORMAT_ARGB8888}; + imported = gbm_bo_import(gbmDevice, GBM_BO_IMPORT_FD, &importInfo, GBM_BO_USE_SCANOUT); + if (!imported) { + qCWarning(PIPEWIRE_LOGGING) << "Failed to process buffer: Cannot import passed GBM fd - " << strerror(errno); + return EGL_NO_IMAGE_KHR; + } + } + + const bool hasModifiers = dmabufAttribs.modifier != DRM_FORMAT_MOD_INVALID; + + static int lastSize = 37; // 37 is what we get on a normal system with working dmabuf, it's just a reasonable default + QList attribs; + attribs.reserve(lastSize); + attribs << EGL_WIDTH << size.width() << EGL_HEIGHT << size.height() << EGL_LINUX_DRM_FOURCC_EXT << EGLint(format) + + << EGL_DMA_BUF_PLANE0_FD_EXT << dmabufAttribs.planes[0].fd << EGL_DMA_BUF_PLANE0_OFFSET_EXT << EGLint(dmabufAttribs.planes[0].offset) + << EGL_DMA_BUF_PLANE0_PITCH_EXT << EGLint(dmabufAttribs.planes[0].stride); + + if (hasModifiers) { + attribs << EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT << EGLint(dmabufAttribs.modifier & 0xffffffff) << EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT + << EGLint(dmabufAttribs.modifier >> 32); + } + + if (dmabufAttribs.planes.count() > 1) { + attribs << EGL_DMA_BUF_PLANE1_FD_EXT << dmabufAttribs.planes[1].fd << EGL_DMA_BUF_PLANE1_OFFSET_EXT << EGLint(dmabufAttribs.planes[1].offset) + << EGL_DMA_BUF_PLANE1_PITCH_EXT << EGLint(dmabufAttribs.planes[1].stride); + + if (hasModifiers) { + attribs << EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT << EGLint(dmabufAttribs.modifier & 0xffffffff) << EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT + << EGLint(dmabufAttribs.modifier >> 32); + } + } + + if (dmabufAttribs.planes.count() > 2) { + attribs << EGL_DMA_BUF_PLANE2_FD_EXT << dmabufAttribs.planes[2].fd << EGL_DMA_BUF_PLANE2_OFFSET_EXT << EGLint(dmabufAttribs.planes[2].offset) + << EGL_DMA_BUF_PLANE2_PITCH_EXT << EGLint(dmabufAttribs.planes[2].stride); + + if (hasModifiers) { + attribs << EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT << EGLint(dmabufAttribs.modifier & 0xffffffff) << EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT + << EGLint(dmabufAttribs.modifier >> 32); + } + } + + if (dmabufAttribs.planes.count() > 3) { + attribs << EGL_DMA_BUF_PLANE3_FD_EXT << dmabufAttribs.planes[3].fd << EGL_DMA_BUF_PLANE3_OFFSET_EXT << EGLint(dmabufAttribs.planes[3].offset) + << EGL_DMA_BUF_PLANE3_PITCH_EXT << EGLint(dmabufAttribs.planes[3].stride); + + if (hasModifiers) { + attribs << EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT << EGLint(dmabufAttribs.modifier & 0xffffffff) << EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT + << EGLint(dmabufAttribs.modifier >> 32); + } + } + + attribs << EGL_NONE; + lastSize = attribs.size(); + + static auto eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); + + /* MESA says: + * "If is EGL_LINUX_DMA_BUF_EXT, must be a valid display, + * must be EGL_NO_CONTEXT..." + */ + EGLImage ret = eglCreateImageKHR(display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, imported, attribs.data()); + if (ret == EGL_NO_IMAGE_KHR) { + qCWarning(PIPEWIRE_LOGGING) << "invalid image" << GLHelpers::formatEGLError(eglGetError()); + } + if (imported) { + gbm_bo_destroy(imported); + } + return ret; +} +} diff --git a/src/glhelpers.h b/src/glhelpers.h new file mode 100644 index 0000000..5cc07fa --- /dev/null +++ b/src/glhelpers.h @@ -0,0 +1,24 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include "pipewiresourcestream.h" +#include +#include +#include + +typedef unsigned int GLenum; + +namespace GLHelpers +{ + +KPIPEWIRE_EXPORT void initDebugOutput(); +KPIPEWIRE_EXPORT QByteArray formatGLError(GLenum err); +KPIPEWIRE_EXPORT QByteArray formatEGLError(GLenum err); + +KPIPEWIRE_EXPORT EGLImage createImage(EGLDisplay display, const DmaBufAttributes &attribs, uint32_t format, const QSize &size, gbm_device *device); +} diff --git a/src/h264vaapiencoder.cpp b/src/h264vaapiencoder.cpp new file mode 100644 index 0000000..cf315f3 --- /dev/null +++ b/src/h264vaapiencoder.cpp @@ -0,0 +1,178 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + SPDX-FileCopyrightText: 2023 Marco Martin + SPDX-FileCopyrightText: 2023 Arjen Hiemstra + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "h264vaapiencoder_p.h" + +#include + +extern "C" { +#include +#include +#include +} + +#include "logging_record.h" + +H264VAAPIEncoder::H264VAAPIEncoder(H264Profile profile, PipeWireProduce *produce) + : HardwareEncoder(produce) + , m_profile(profile) +{ +} + +bool H264VAAPIEncoder::initialize(const QSize &size) +{ + if (!createDrmContext(size)) { + return false; + } + + m_avFilterGraph = avfilter_graph_alloc(); + if (!m_avFilterGraph) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not create filter graph"; + return false; + } + + int ret = avfilter_graph_create_filter(&m_inputFilter, + avfilter_get_by_name("buffer"), + "in", + "width=1:height=1:pix_fmt=drm_prime:time_base=1/1", + nullptr, + m_avFilterGraph); + if (ret < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Failed to create the buffer filter"; + return false; + } + + auto parameters = av_buffersrc_parameters_alloc(); + if (!parameters) { + qFatal("Failed to allocate memory"); + } + + parameters->format = AV_PIX_FMT_DRM_PRIME; + parameters->width = size.width(); + parameters->height = size.height(); + parameters->time_base = {1, 1000}; + parameters->hw_frames_ctx = m_drmFramesContext; + + av_buffersrc_parameters_set(m_inputFilter, parameters); + av_free(parameters); + parameters = nullptr; + + ret = avfilter_graph_create_filter(&m_outputFilter, avfilter_get_by_name("buffersink"), "out", nullptr, nullptr, m_avFilterGraph); + if (ret < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not create buffer output filter"; + return false; + } + + auto inputs = avfilter_inout_alloc(); + if (!inputs) { + qFatal("Failed to allocate memory"); + } + inputs->name = av_strdup("in"); + inputs->filter_ctx = m_inputFilter; + inputs->pad_idx = 0; + inputs->next = nullptr; + + auto outputs = avfilter_inout_alloc(); + if (!outputs) { + qFatal("Failed to allocate memory"); + } + outputs->name = av_strdup("out"); + outputs->filter_ctx = m_outputFilter; + outputs->pad_idx = 0; + outputs->next = nullptr; + + ret = avfilter_graph_parse(m_avFilterGraph, "hwmap=mode=direct:derive_device=vaapi,scale_vaapi=format=nv12:mode=fast", outputs, inputs, NULL); + if (ret < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Failed creating filter graph"; + return false; + } + + for (auto i = 0u; i < m_avFilterGraph->nb_filters; ++i) { + m_avFilterGraph->filters[i]->hw_device_ctx = av_buffer_ref(m_drmContext); + } + + ret = avfilter_graph_config(m_avFilterGraph, nullptr); + if (ret < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Failed configuring filter graph"; + return false; + } + + auto codec = avcodec_find_encoder_by_name("h264_vaapi"); + if (!codec) { + qCWarning(PIPEWIRERECORD_LOGGING) << "h264_vaapi codec not found"; + return false; + } + + m_avCodecContext = avcodec_alloc_context3(codec); + if (!m_avCodecContext) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not allocate video codec context"; + return false; + } + + Q_ASSERT(!size.isEmpty()); + m_avCodecContext->width = size.width(); + m_avCodecContext->height = size.height(); + m_avCodecContext->max_b_frames = 0; + m_avCodecContext->gop_size = 100; + m_avCodecContext->pix_fmt = AV_PIX_FMT_VAAPI; + m_avCodecContext->time_base = AVRational{1, 1000}; + + if (m_quality) { + m_avCodecContext->global_quality = percentageToAbsoluteQuality(m_quality); + } else { + m_avCodecContext->global_quality = 35; + } + + switch (m_profile) { + case H264Profile::Baseline: + m_avCodecContext->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE; + break; + case H264Profile::Main: + m_avCodecContext->profile = FF_PROFILE_H264_MAIN; + break; + case H264Profile::High: + m_avCodecContext->profile = FF_PROFILE_H264_HIGH; + break; + } + + AVDictionary *options = nullptr; + // av_dict_set_int(&options, "threads", qMin(16, QThread::idealThreadCount()), 0); + applyEncodingPreference(options); + + // Assign the right hardware context for encoding frames. + // We rely on FFmpeg for creating the VAAPI hardware context as part of + // `avfilter_graph_parse()`. The codec context needs the VAAPI context to be + // able to encode properly, so get that from the output filter. + m_avCodecContext->hw_frames_ctx = av_buffer_ref(av_buffersink_get_hw_frames_ctx(m_outputFilter)); + + if (int result = avcodec_open2(m_avCodecContext, codec, &options); result < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not open codec" << av_err2str(ret); + return false; + } + + return true; +} + +int H264VAAPIEncoder::percentageToAbsoluteQuality(const std::optional &quality) +{ + if (!quality) { + return -1; + } + + constexpr int MinQuality = 51 + 6 * 6; + return std::max(1, int(MinQuality - (m_quality.value() / 100.0) * MinQuality)); +} + +void H264VAAPIEncoder::applyEncodingPreference(AVDictionary *options) +{ + HardwareEncoder::applyEncodingPreference(options); + // Disable motion estimation, not great while dragging windows but speeds up encoding by an order of magnitude + av_dict_set(&options, "flags", "+mv4", 0); + // Disable in-loop filtering + av_dict_set(&options, "-flags", "+loop", 0); +} diff --git a/src/h264vaapiencoder_p.h b/src/h264vaapiencoder_p.h new file mode 100644 index 0000000..9a22650 --- /dev/null +++ b/src/h264vaapiencoder_p.h @@ -0,0 +1,27 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + SPDX-FileCopyrightText: 2023 Marco Martin + SPDX-FileCopyrightText: 2023 Arjen Hiemstra + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "encoder_p.h" + +/** + * A hardware encoder that uses VAAPI to encode to H264. + */ +class H264VAAPIEncoder : public HardwareEncoder +{ +public: + H264VAAPIEncoder(H264Profile profile, PipeWireProduce *produce); + + bool initialize(const QSize &size) override; + +protected: + int percentageToAbsoluteQuality(const std::optional &quality) override; + void applyEncodingPreference(AVDictionary *options) override; + +private: + H264Profile m_profile = H264Profile::Main; +}; diff --git a/src/kpipewiredeclarativeplugin.cpp b/src/kpipewiredeclarativeplugin.cpp new file mode 100644 index 0000000..2b290fd --- /dev/null +++ b/src/kpipewiredeclarativeplugin.cpp @@ -0,0 +1,17 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "kpipewiredeclarativeplugin.h" + +#include "pipewiresourceitem.h" +#include "pipewirerecord.h" + +void KPipewireDeclarativePlugin::registerTypes(const char *uri) +{ + qmlRegisterType(uri, 0, 1, "PipeWireSourceItem"); +} + +#include "moc_kpipewiredeclarativeplugin.cpp" diff --git a/src/kpipewiredeclarativeplugin.h b/src/kpipewiredeclarativeplugin.h new file mode 100644 index 0000000..7771dcd --- /dev/null +++ b/src/kpipewiredeclarativeplugin.h @@ -0,0 +1,17 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include + +class KPipewireDeclarativePlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") +public: + void registerTypes(const char *uri) override; +}; diff --git a/src/kpipewirerecorddeclarativeplugin.cpp b/src/kpipewirerecorddeclarativeplugin.cpp new file mode 100644 index 0000000..e5861f9 --- /dev/null +++ b/src/kpipewirerecorddeclarativeplugin.cpp @@ -0,0 +1,17 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "kpipewirerecorddeclarativeplugin.h" + +#include "pipewirerecord.h" +#include + +void KPipewireRecordDeclarativePlugin::registerTypes(const char *uri) +{ + qmlRegisterType(uri, 0, 1, "PipeWireRecord"); +} + +#include "moc_kpipewirerecorddeclarativeplugin.cpp" diff --git a/src/kpipewirerecorddeclarativeplugin.h b/src/kpipewirerecorddeclarativeplugin.h new file mode 100644 index 0000000..882ff2c --- /dev/null +++ b/src/kpipewirerecorddeclarativeplugin.h @@ -0,0 +1,17 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include + +class KPipewireRecordDeclarativePlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") +public: + void registerTypes(const char *uri) override; +}; diff --git a/src/libopenh264encoder.cpp b/src/libopenh264encoder.cpp new file mode 100644 index 0000000..6d4c6a1 --- /dev/null +++ b/src/libopenh264encoder.cpp @@ -0,0 +1,106 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + SPDX-FileCopyrightText: 2023 Marco Martin + SPDX-FileCopyrightText: 2023 Arjen Hiemstra + SPDX-FileCopyrightText: 2024 Fabian Vogt + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "libopenh264encoder_p.h" + +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +#include "logging_record.h" + +LibOpenH264Encoder::LibOpenH264Encoder(H264Profile profile, PipeWireProduce *produce) + : SoftwareEncoder(produce) + , m_profile(profile) +{ +} + +bool LibOpenH264Encoder::initialize(const QSize &size) +{ + createFilterGraph(size); + + auto codec = avcodec_find_encoder_by_name("libopenh264"); + if (!codec) { + qCWarning(PIPEWIRERECORD_LOGGING) << "libopenh264 codec not found"; + return false; + } + + m_avCodecContext = avcodec_alloc_context3(codec); + if (!m_avCodecContext) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not allocate video codec context"; + return false; + } + + Q_ASSERT(!size.isEmpty()); + m_avCodecContext->width = size.width(); + m_avCodecContext->height = size.height(); + m_avCodecContext->max_b_frames = 0; + m_avCodecContext->gop_size = 100; + m_avCodecContext->pix_fmt = AV_PIX_FMT_YUV420P; + m_avCodecContext->time_base = AVRational{1, 1000}; + + if (m_quality) { + // "q" here stands for "quantization", but that effectively impacts quality. + m_avCodecContext->qmin = m_avCodecContext->qmax = percentageToAbsoluteQuality(m_quality); + } + + switch (m_profile) { + case H264Profile::Baseline: + // libopenh264 only does constrained baseline. + // There's a bug in the ffmpeg -> openh264 interface though: + // ffmpeg expects CONSTRAINED_BASELINE from the application and + // passes that through, but libopenh264 only allows BASELINE. + // Until that bug is fixed there'll always be a warning that the + // profile is not supported (https://github.com/cisco/openh264/issues/3613) + m_avCodecContext->profile = FF_PROFILE_H264_CONSTRAINED_BASELINE; + break; + case H264Profile::Main: + m_avCodecContext->profile = FF_PROFILE_H264_MAIN; + break; + case H264Profile::High: + m_avCodecContext->profile = FF_PROFILE_H264_HIGH; + break; + } + + AVDictionary *options = nullptr; + av_dict_set_int(&options, "threads", qMin(16, QThread::idealThreadCount()), 0); + applyEncodingPreference(options); + + if (int result = avcodec_open2(m_avCodecContext, codec, &options); result < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not open codec" << av_err2str(result); + return false; + } + + return true; +} + +int LibOpenH264Encoder::percentageToAbsoluteQuality(const std::optional &quality) +{ + if (!quality) { + return -1; + } + + // 1-51 (incl.), lower is better + return 51 - (m_quality.value() / 100.0) * 50; +} + +void LibOpenH264Encoder::applyEncodingPreference(AVDictionary *options) +{ + SoftwareEncoder::applyEncodingPreference(options); + // Disable motion estimation, not great while dragging windows but speeds up encoding by an order of magnitude + av_dict_set(&options, "flags", "+mv4", 0); + // Disable in-loop filtering + av_dict_set_int(&options, "loopfilter", 0, 0); +} diff --git a/src/libopenh264encoder_p.h b/src/libopenh264encoder_p.h new file mode 100644 index 0000000..fdacf14 --- /dev/null +++ b/src/libopenh264encoder_p.h @@ -0,0 +1,28 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + SPDX-FileCopyrightText: 2023 Marco Martin + SPDX-FileCopyrightText: 2023 Arjen Hiemstra + SPDX-FileCopyrightText: 2024 Fabian Vogt + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "encoder_p.h" + +/** + * A software encoder that uses ffmpeg + libopenh264 to encode to H.264. + */ +class LibOpenH264Encoder : public SoftwareEncoder +{ +public: + LibOpenH264Encoder(H264Profile profile, PipeWireProduce *produce); + + bool initialize(const QSize &size) override; + +protected: + int percentageToAbsoluteQuality(const std::optional &quality) override; + void applyEncodingPreference(AVDictionary *options) override; + +private: + H264Profile m_profile = H264Profile::Main; +}; diff --git a/src/libvpxencoder.cpp b/src/libvpxencoder.cpp new file mode 100644 index 0000000..d0cc9ea --- /dev/null +++ b/src/libvpxencoder.cpp @@ -0,0 +1,94 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + SPDX-FileCopyrightText: 2023 Marco Martin + SPDX-FileCopyrightText: 2023 Arjen Hiemstra + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "libvpxencoder_p.h" + +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +#include "logging_record.h" + +LibVpxEncoder::LibVpxEncoder(PipeWireProduce *produce) + : SoftwareEncoder(produce) +{ +} + +bool LibVpxEncoder::initialize(const QSize &size) +{ + createFilterGraph(size); + + auto codec = avcodec_find_encoder_by_name("libvpx"); + if (!codec) { + qCWarning(PIPEWIRERECORD_LOGGING) << "libvpx codec not found"; + return false; + } + + m_avCodecContext = avcodec_alloc_context3(codec); + if (!m_avCodecContext) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not allocate video codec context"; + return false; + } + m_avCodecContext->bit_rate = size.width() * size.height() * 2; + + Q_ASSERT(!size.isEmpty()); + m_avCodecContext->width = size.width(); + m_avCodecContext->height = size.height(); + m_avCodecContext->max_b_frames = 0; + m_avCodecContext->gop_size = 100; + m_avCodecContext->pix_fmt = AV_PIX_FMT_YUV420P; + m_avCodecContext->time_base = AVRational{1, 1000}; + m_avCodecContext->global_quality = 35; + + if (m_quality) { + m_avCodecContext->global_quality = percentageToAbsoluteQuality(m_quality); + } else { + m_avCodecContext->global_quality = 35; + } + + AVDictionary *options = nullptr; + applyEncodingPreference(options); + + if (int result = avcodec_open2(m_avCodecContext, codec, &options); result < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not open codec" << av_err2str(result); + return false; + } + + return true; +} + +int LibVpxEncoder::percentageToAbsoluteQuality(const std::optional &quality) +{ + if (!quality) { + return -1; + } + + constexpr int MinQuality = 63; + return std::max(1, int(MinQuality - (m_quality.value() / 100.0) * MinQuality)); +} + +void LibVpxEncoder::applyEncodingPreference(AVDictionary *options) +{ + av_dict_set_int(&options, "threads", qMin(16, QThread::idealThreadCount()), 0); + av_dict_set(&options, "preset", "veryfast", 0); + av_dict_set(&options, "tune-content", "screen", 0); + av_dict_set(&options, "deadline", "realtime", 0); + // In theory a lower number should be faster, but the opposite seems to be true + // av_dict_set(&options, "quality", "40", 0); + // Disable motion estimation, not great while dragging windows but speeds up encoding by an order of magnitude + av_dict_set(&options, "flags", "+mv4", 0); + // Disable in-loop filtering + av_dict_set(&options, "-flags", "+loop", 0); + av_dict_set(&options, "crf", "45", 0); +} diff --git a/src/libvpxencoder_p.h b/src/libvpxencoder_p.h new file mode 100644 index 0000000..22fcae8 --- /dev/null +++ b/src/libvpxencoder_p.h @@ -0,0 +1,24 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + SPDX-FileCopyrightText: 2023 Marco Martin + SPDX-FileCopyrightText: 2023 Arjen Hiemstra + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "encoder_p.h" + +/** + * A software encoder that uses libvpx to encode to VP8. + */ +class LibVpxEncoder : public SoftwareEncoder +{ +public: + LibVpxEncoder(PipeWireProduce *produce); + + bool initialize(const QSize &size) override; + +protected: + int percentageToAbsoluteQuality(const std::optional &quality) override; + void applyEncodingPreference(AVDictionary *options) override; +}; diff --git a/src/libvpxvp9encoder.cpp b/src/libvpxvp9encoder.cpp new file mode 100644 index 0000000..d3ce94b --- /dev/null +++ b/src/libvpxvp9encoder.cpp @@ -0,0 +1,122 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + SPDX-FileCopyrightText: 2023 Marco Martin + SPDX-FileCopyrightText: 2023 Arjen Hiemstra + SPDX-FileCopyrightText: 2023 Noah Davis + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "libvpxvp9encoder_p.h" + +#include "pipewireproduce_p.h" + +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +#include "logging_record.h" + +LibVpxVp9Encoder::LibVpxVp9Encoder(PipeWireProduce *produce) + : SoftwareEncoder(produce) +{ +} + +bool LibVpxVp9Encoder::initialize(const QSize &size) +{ + createFilterGraph(size); + + auto codec = avcodec_find_encoder_by_name("libvpx-vp9"); + if (!codec) { + qCWarning(PIPEWIRERECORD_LOGGING) << "libvpx-vp9 codec not found"; + return false; + } + + m_avCodecContext = avcodec_alloc_context3(codec); + if (!m_avCodecContext) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not allocate video codec context"; + return false; + } + + Q_ASSERT(!size.isEmpty()); + m_avCodecContext->width = size.width(); + m_avCodecContext->height = size.height(); + m_avCodecContext->pix_fmt = AV_PIX_FMT_YUV420P; + m_avCodecContext->time_base = AVRational{1, 1000}; + + AVDictionary *options = nullptr; + + applyEncodingPreference(options); + + const auto area = size.width() * size.height(); + // m_avCodecContext->framerate is not set, so we use m_produce->maxFramerate() instead. + const auto maxFramerate = m_produce->maxFramerate(); + const auto fps = qreal(maxFramerate.numerator) / std::max(quint32(1), maxFramerate.denominator); + + m_avCodecContext->gop_size = fps * 2; + + // TODO: Make bitrate depend on the framerate? More frames is more data. + // maxFramerate can apparently be changed while recording, so keep that in mind. + m_avCodecContext->bit_rate = std::round(area * 2); + m_avCodecContext->rc_min_rate = std::round(area); + m_avCodecContext->rc_max_rate = std::round(area * 3); + + m_avCodecContext->rc_buffer_size = m_avCodecContext->bit_rate; + + m_avCodecContext->thread_count = QThread::idealThreadCount(); + + if (int result = avcodec_open2(m_avCodecContext, codec, &options); result < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not open codec" << av_err2str(result); + return false; + } + + return true; +} + +int LibVpxVp9Encoder::percentageToAbsoluteQuality(const std::optional &quality) +{ + if (!quality) { + return -1; + } + + constexpr int MinQuality = 63; + return std::max(1, int(MinQuality - (m_quality.value() / 100.0) * MinQuality)); +} + +void LibVpxVp9Encoder::applyEncodingPreference(AVDictionary *options) +{ + // We're probably capturing a screen + av_dict_set(&options, "tune-content", "screen", 0); + + // Lower crf is higher quality. Max 0, min 63. libvpx-vp9 doesn't use global_quality. + int crf = 31; + if (m_quality) { + crf = percentageToAbsoluteQuality(m_quality); + } + m_avCodecContext->qmin = std::clamp(crf / 2, 0, crf); + m_avCodecContext->qmax = std::clamp(qRound(crf * 1.5), crf, 63); + av_dict_set_int(&options, "crf", crf, 0); + + // 0-4 are for Video-On-Demand with the good or best deadline. + // Don't use best, it's not worth it. + // 5-8 are for streaming with the realtime deadline. + // Lower is higher quality. + int cpuUsed = 5 + std::max(1, int(3 - std::round(m_quality.value_or(50) / 100.0 * 3))); + av_dict_set_int(&options, "cpu-used", cpuUsed, 0); + av_dict_set(&options, "deadline", "realtime", 0); + + // The value is interpreted as being equivalent to log2(realNumberOfColumns), + // so 3 is 8 columns. 6 is the max amount of columns. 2 is the max amount of rows. + av_dict_set(&options, "tile-columns", "6", 0); + av_dict_set(&options, "tile-rows", "2", 0); + + // This should make things faster, but it only seems to consume 100MB more RAM. + // av_dict_set(&options, "row-mt", "1", 0); + av_dict_set(&options, "frame-parallel", "1", 0); +} diff --git a/src/libvpxvp9encoder_p.h b/src/libvpxvp9encoder_p.h new file mode 100644 index 0000000..c200827 --- /dev/null +++ b/src/libvpxvp9encoder_p.h @@ -0,0 +1,25 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + SPDX-FileCopyrightText: 2023 Marco Martin + SPDX-FileCopyrightText: 2023 Arjen Hiemstra + SPDX-FileCopyrightText: 2023 Noah Davis + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "encoder_p.h" + +/** + * A software encoder that uses libvpx-vp9 to encode to VP9. + */ +class LibVpxVp9Encoder : public SoftwareEncoder +{ +public: + LibVpxVp9Encoder(PipeWireProduce *produce); + + bool initialize(const QSize &size) override; + +protected: + int percentageToAbsoluteQuality(const std::optional &quality) override; + void applyEncodingPreference(AVDictionary *options) override; +}; diff --git a/src/libx264encoder.cpp b/src/libx264encoder.cpp new file mode 100644 index 0000000..9101164 --- /dev/null +++ b/src/libx264encoder.cpp @@ -0,0 +1,110 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + SPDX-FileCopyrightText: 2023 Marco Martin + SPDX-FileCopyrightText: 2023 Arjen Hiemstra + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "libx264encoder_p.h" + +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +#include "logging_record.h" + +using namespace Qt::StringLiterals; + +LibX264Encoder::LibX264Encoder(H264Profile profile, PipeWireProduce *produce) + : SoftwareEncoder(produce) + , m_profile(profile) +{ + // Adjust the filter graph to ensure we are using an even frame size using a + // pad filter. Otherwise the size adjustment below will insert a row/column + // of garbage instead of black. + m_filterGraphToParse = u"pad=ceil(iw/2)*2:ceil(ih/2)*2,format=pix_fmts=yuv420p"_s; +} + +bool LibX264Encoder::initialize(const QSize &size) +{ + createFilterGraph(size); + + auto codec = avcodec_find_encoder_by_name("libx264"); + if (!codec) { + qCWarning(PIPEWIRERECORD_LOGGING) << "libx264 codec not found"; + return false; + } + + m_avCodecContext = avcodec_alloc_context3(codec); + if (!m_avCodecContext) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not allocate video codec context"; + return false; + } + + Q_ASSERT(!size.isEmpty()); + // Important: libx264 rejects streams with sizes that are not even. So to + // ensure we don't get errors, we need to ensure the size we set here is + // even. We also insert a pad filter into the filter chain above to ensure + // we don't end up padding with garbage. + m_avCodecContext->width = std::ceil(size.width() / 2) * 2; + m_avCodecContext->height = std::ceil(size.height() / 2) * 2; + m_avCodecContext->max_b_frames = 0; + m_avCodecContext->gop_size = 100; + m_avCodecContext->pix_fmt = AV_PIX_FMT_YUV420P; + m_avCodecContext->time_base = AVRational{1, 1000}; + + if (m_quality) { + m_avCodecContext->global_quality = percentageToAbsoluteQuality(m_quality); + } else { + m_avCodecContext->global_quality = 35; + } + + switch (m_profile) { + case H264Profile::Baseline: + m_avCodecContext->profile = FF_PROFILE_H264_BASELINE; + break; + case H264Profile::Main: + m_avCodecContext->profile = FF_PROFILE_H264_MAIN; + break; + case H264Profile::High: + m_avCodecContext->profile = FF_PROFILE_H264_HIGH; + break; + } + + AVDictionary *options = nullptr; + av_dict_set_int(&options, "threads", qMin(16, QThread::idealThreadCount()), 0); + applyEncodingPreference(options); + + if (int result = avcodec_open2(m_avCodecContext, codec, &options); result < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not open codec" << av_err2str(result); + return false; + } + + return true; +} + +int LibX264Encoder::percentageToAbsoluteQuality(const std::optional &quality) +{ + if (!quality) { + return -1; + } + + constexpr int MinQuality = 51 + 6 * 6; + return std::max(1, int(MinQuality - (m_quality.value() / 100.0) * MinQuality)); +} + +void LibX264Encoder::applyEncodingPreference(AVDictionary *options) +{ + SoftwareEncoder::applyEncodingPreference(options); + // Disable motion estimation, not great while dragging windows but speeds up encoding by an order of magnitude + av_dict_set(&options, "flags", "+mv4", 0); + // Disable in-loop filtering + av_dict_set(&options, "-flags", "+loop", 0); +} diff --git a/src/libx264encoder_p.h b/src/libx264encoder_p.h new file mode 100644 index 0000000..c8b877c --- /dev/null +++ b/src/libx264encoder_p.h @@ -0,0 +1,27 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + SPDX-FileCopyrightText: 2023 Marco Martin + SPDX-FileCopyrightText: 2023 Arjen Hiemstra + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "encoder_p.h" + +/** + * A software encoder that uses libx264 to encode to H264. + */ +class LibX264Encoder : public SoftwareEncoder +{ +public: + LibX264Encoder(H264Profile profile, PipeWireProduce *produce); + + bool initialize(const QSize &size) override; + +protected: + int percentageToAbsoluteQuality(const std::optional &quality) override; + void applyEncodingPreference(AVDictionary *options) override; + +private: + H264Profile m_profile = H264Profile::Main; +}; diff --git a/src/monitors/CMakeLists.txt b/src/monitors/CMakeLists.txt new file mode 100644 index 0000000..a1c8b7f --- /dev/null +++ b/src/monitors/CMakeLists.txt @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2023 Fushan Wen +# SPDX-License-Identifier: BSD-3-Clause + +ecm_add_qml_module(KPipeWireMonitorDeclarative URI "org.kde.pipewire.monitor" GENERATE_PLUGIN_SOURCE VERSION 1.0) +target_sources(KPipeWireMonitorDeclarative PRIVATE mediamonitor.cpp) +target_link_libraries(KPipeWireMonitorDeclarative PRIVATE Qt::Quick PkgConfig::PipeWire KPipeWire) +ecm_finalize_qml_module(KPipeWireMonitorDeclarative) + +if(BUILD_TESTING) + add_subdirectory(autotests) +endif() diff --git a/src/monitors/autotests/CMakeLists.txt b/src/monitors/autotests/CMakeLists.txt new file mode 100644 index 0000000..4141c50 --- /dev/null +++ b/src/monitors/autotests/CMakeLists.txt @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2023 Fushan Wen +# SPDX-License-Identifier: BSD-3-Clause + +find_program(pwplay_PATH pw-play REQUIRED) +find_program(pipewire_PATH pipewire REQUIRED) +ecm_add_test(mediamonitortest.cpp LINK_LIBRARIES Qt::Test Qt::Quick Qt::Qml) diff --git a/src/monitors/autotests/alarm-clock-elapsed.oga b/src/monitors/autotests/alarm-clock-elapsed.oga new file mode 100644 index 0000000000000000000000000000000000000000..a253702a5f65c375457b5d7fb08a4ec06476b9d0 GIT binary patch literal 73696 zcmeFYcT^K!+bBArhAJRnXc_`iLZSo$f}jQn9h8#95I`Xmse&L_(a=LE(nN|V(u7bX zNKr(Z1gT2z3ZjAtcEy6io#5|%zxRCStaI*KXWjqqUXz(Udv<-w-cQSs6DJ%2F5sVZ zBJ+naC%c3HeGgKn=_;G#X?Jiv77Z{>TCBb=81PMnqy@J)_OCte)A`QH-v z-<}k}3S{44pFKxHPQU|vsidv`;g)bMO-+5xeVY25?jXE>E2|rukRSjQEWy~o*|fn_ zA^?a1fSa9soP}bnqyy(hr7On4 zz+1e0NVnqc>mh>3vVtfTIO8VjN8hOKNcV{#b}5l;7FohM^mzsI`6;{LgQM9h8XTw6@{7#gYx4L6#o{4y8#fVI0qCv1Zy6O zeH>~CUgoFqJ()HGUv0Mi3ke*w0{{*q&psvJ146?AJrbgGH1xnksO-i4n@|RDM z!M09=xr=4@CBa-mW}a&OeZt@V{vnI%Rb7BuwY|-xqKNb3Z+=zaJ3bl>K+| z!GU;lpM-VgN5Laf_^6VKrHUClPhSzuD8O{97w=3?F|#U6{VO$(#7u-SAQhu@Kq^kIU%U}ot#9F9Qa?`7 zD9LoNQZM<-Q6N&`o~cHBGFwa%mmSipejDV9|3utJ<)`8bL;rC-{UmQMu^YUGw9t;) z2Z#jX(eOa0Yhg2uv96P0a}yDB6UoPS#Qk@|`ZwnQAk)Nb@nj}73G?`R^kHLxzX<*p z=bVy!oF?CsrfglSY&(n^_>4XB1v|9e)E;Z=DCIgN6*eO6<*4gAqT@9}^coBInriTJ zZj5kh_=jQsvd!E?*ne;iheZ(jDK9P3dH#!Y3e-{-^iq^8)0LglRnBFdNXRYExv^Yc zDEQwv$A@t{n{k`YSfZz>C1m*~!s(ylz57e?#p6#-K`FfE{QhchCndLi0$9^%M`s_i=Sjo`^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I=v({%$*oJNRm{W7wwAa-+amTZ^^(JDW1F zC#!B)8B`T5I}3Zi?4&$vH2Fb!`^m(-(@)uJ2&-~Q8X11bhrLz#@Vv)mxplwY+R$5n zm~8*1<*nbRGcI`QOn-3~*dL+ud%d`(;Q1QOlyu$w z@PyJ~rDSVC`sw-W&(8HF-dq=kPW3`nG478v(k@@PS|q>a;q`BCb_IPw96GT1o11B) zp!3mcWY(>m$NSb^tT{|2rl(=rXM#8puTP(+yuTS)Dg9x0TjKjDi`2GH(9t|$SX`jm<6THvdZJU zDj8_raOa-XLW>OzcXs2J?_6?RDw}i3+QM2dF}}q=?v=pCSG|u?1=g#mtnYbz`lIsO}wLM|G3#pC9f|L^N-_l`mIxsrrlSZkv!}KeaBVXK=T_iayXH zPp&h}Z;1c%VWG(+AwjMi;aD)K_nnN+2weK&@x|nh4tOvct*B$)*!XGj z%Z%Q0yDdDUnGp0P84LLi^Iwl!^N;-T9NpeaBgM+bXQY@tw!A&FU;!7rytHjwXhhF) z*pbEg+lRR8kJKwwjrBg*IdnrUKg_}Jp24PrGxN8618hR4`VRUm#rOX4_GAWRWxXv} zlw^A^6&djer}iBBxYfBGnn+w5Jvc$O%)Mqmn6|g$*4f$cy7>1Yw%sR-bk*#4M;}EU zMM)pUY5YUr?F3UehynX>r-~{*)0;Xn3i1xa7kH-gtvwS`Vink2K@QnzKyYsO2F4Ie zfIRP>*?4(-)ZO8Zg^!xg6ZgHfnbtOs883PGaZ`m`qn=NM4R*`jGncOtdWSS0>OC1( zp2_|kT@X&bOOe$WJ9Z +SPDX-FileCopyrightText: 2008 Lennart Poettering +SPDX-FileCopyrightText: 2008 Patryk Zawadzki +SPDX-FileCopyrightText: 2008 Alexander Larsson +SPDX-FileCopyrightText: 2008 Frans Englich diff --git a/src/monitors/autotests/mediamonitortest.cpp b/src/monitors/autotests/mediamonitortest.cpp new file mode 100644 index 0000000..56f9939 --- /dev/null +++ b/src/monitors/autotests/mediamonitortest.cpp @@ -0,0 +1,179 @@ +/* + SPDX-FileCopyrightText: 2023 Fushan Wen + + SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#define QT_FORCE_ASSERTS 1 + +#include +#include +#include +#include +#include +#include + +namespace +{ +template +[[nodiscard]] T evaluate(QObject *scope, const QString &expression) +{ + QQmlExpression expr(qmlContext(scope), scope, expression); + QVariant result = expr.evaluate(); + Q_ASSERT_X(!expr.hasError(), "MediaMonitorTest", qUtf8Printable(expr.error().toString())); + return result.value(); +} + +template<> +void evaluate(QObject *scope, const QString &expression) +{ + QQmlExpression expr(qmlContext(scope), scope, expression); + expr.evaluate(); + Q_ASSERT_X(!expr.hasError(), "MediaMonitorTest", qUtf8Printable(expr.error().toString())); +} + +bool initView(QQuickView *view, const QString &urlStr) +{ + view->setSource(QUrl(urlStr)); + + QSignalSpy statusSpy(view, &QQuickView::statusChanged); + if (view->status() == QQuickView::Loading) { + statusSpy.wait(); + } else if (view->status() != QQuickView::Ready) { + qCritical() << "Not loading" << view->errors(); + return false; + } + + if (view->status() != QQuickView::Ready) { + qCritical() << view->errors(); + return false; + } + + return true; +} +} + +class MediaMonitorTest : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + /** + * Loads MediaMonitor in QML, and tests it can monitor music streams + */ + void test_MediaMonitor(); +}; + +void MediaMonitorTest::test_MediaMonitor() +{ + QProcess pipewire; + QProcess pipewire_pulse; + QProcess wireplumber; + QProcess pactl; + QScopeGuard guard([&pipewire, &pipewire_pulse, &wireplumber, &pactl] { + if (qEnvironmentVariableIsSet("KDECI_BUILD")) { + pactl.setArguments({QStringLiteral("unload-module"), QStringLiteral("module-null-sink")}); + pactl.start(); + QVERIFY2(pactl.waitForFinished(), pactl.readAllStandardError().constData()); + } + if (wireplumber.state() == QProcess::Running) { + wireplumber.terminate(); + } + if (pipewire_pulse.state() == QProcess::Running) { + pipewire_pulse.terminate(); + } + if (pipewire.state() == QProcess::Running) { + pipewire.terminate(); + } + }); + + QProcess pidof; + pidof.start(QStringLiteral("pidof"), {QStringLiteral("pipewire")}); + pidof.waitForFinished(); + if (QString::fromUtf8(pidof.readAllStandardOutput()).toInt() == 0) { + pipewire.start(QStringLiteral("pipewire")); + QVERIFY2(pipewire.waitForStarted(), pipewire.readAllStandardError().constData()); + wireplumber.start(QStringLiteral("wireplumber")); +#ifdef Q_OS_LINUX + QVERIFY2(wireplumber.waitForStarted(), wireplumber.readAllStandardError().constData()); +#endif + QTest::qWait(1000); + pipewire_pulse.start(QStringLiteral("pipewire-pulse")); + QVERIFY2(pipewire_pulse.waitForStarted(), pipewire_pulse.readAllStandardError().constData()); + } + + // Dummy output + if (qEnvironmentVariableIsSet("KDECI_BUILD")) { + pactl.setProgram(QStringLiteral("pactl")); + pactl.setArguments({QStringLiteral("load-module"), + QStringLiteral("module-null-sink"), + QStringLiteral("sink_name=DummyOutput"), + QStringLiteral("sink_properties=node.nick=DummyOutput")}); + pactl.start(); + QVERIFY2(pactl.waitForFinished(), pipewire.readAllStandardError().constData()); + } + + QQuickView view; + QByteArray errorMessage; + QVERIFY(initView(&view, QFINDTESTDATA(QStringLiteral("mediamonitortest.qml")))); + + QQuickItem *rootObject = view.rootObject(); + QSignalSpy countSpy(rootObject, SIGNAL(countChanged())); + + QProcess player; + player.setProgram(QStringLiteral("pw-play")); + player.setArguments({QStringLiteral("-v"), QFINDTESTDATA(QStringLiteral("alarm-clock-elapsed.oga"))}); + player.start(); + QVERIFY2(player.waitForStarted(), player.readAllStandardError().constData()); + + if (evaluate(rootObject, QStringLiteral("root.count")) == 0) { + countSpy.wait(); + } + + QVERIFY(evaluate(rootObject, QStringLiteral("monitor.detectionAvailable"))); + QCOMPARE(evaluate(rootObject, QStringLiteral("root.count")), 1); + const int runningInt = evaluate(rootObject, QStringLiteral("Monitor.NodeState.Running")); + const int suspendedInt = evaluate(rootObject, QStringLiteral("Monitor.NodeState.Suspended")); + QTRY_COMPARE(evaluate(rootObject, QStringLiteral("root.state")), wireplumber.state() == QProcess::Running ? runningInt : suspendedInt); + + // Changing role will trigger reconnecting + QObject *monitor = evaluate(rootObject, QStringLiteral("monitor")); + QVERIFY(monitor); + QSignalSpy detectionAvailableChangedSpy(monitor, SIGNAL(detectionAvailableChanged())); + QSignalSpy roleChangedSpy(monitor, SIGNAL(roleChanged())); + evaluate(rootObject, QStringLiteral("monitor.role = Monitor.MediaMonitor.Camera")); + if (roleChangedSpy.empty()) { + QVERIFY(roleChangedSpy.wait()); + } + QVERIFY(evaluate(rootObject, QStringLiteral("monitor.detectionAvailable"))); + QCOMPARE(detectionAvailableChangedSpy.size(), 2); // True -> False -> True + QCOMPARE(evaluate(rootObject, QStringLiteral("root.count")), 0); + + // Change back to Music role + roleChangedSpy.clear(); + detectionAvailableChangedSpy.clear(); + evaluate(rootObject, QStringLiteral("monitor.role = Monitor.MediaMonitor.Music")); + if (roleChangedSpy.empty()) { + QVERIFY(roleChangedSpy.wait()); + } + QVERIFY(evaluate(rootObject, QStringLiteral("monitor.detectionAvailable"))); + QCOMPARE(detectionAvailableChangedSpy.size(), 2); // True -> False -> True + if (evaluate(rootObject, QStringLiteral("root.count")) == 0) { + QVERIFY(countSpy.wait()); + } + QCOMPARE(evaluate(rootObject, QStringLiteral("root.count")), 1); + + // Now close the player, and check if the count changes + player.terminate(); + if (evaluate(rootObject, QStringLiteral("root.count")) > 0) { + QVERIFY(countSpy.wait()); + } + QCOMPARE(evaluate(rootObject, QStringLiteral("root.count")), 0); + + pipewire.terminate(); + QTRY_VERIFY(!evaluate(rootObject, QStringLiteral("monitor.detectionAvailable"))); +} + +QTEST_MAIN(MediaMonitorTest) + +#include "mediamonitortest.moc" diff --git a/src/monitors/autotests/mediamonitortest.qml b/src/monitors/autotests/mediamonitortest.qml new file mode 100644 index 0000000..54fbaf4 --- /dev/null +++ b/src/monitors/autotests/mediamonitortest.qml @@ -0,0 +1,30 @@ +/* + SPDX-FileCopyrightText: 2023 Fushan Wen + + SPDX-License-Identifier: GPL-2.0-or-later +*/ + +pragma ComponentBehavior: Bound + +import QtQuick +import org.kde.pipewire.monitor as Monitor + +Item { + id: root + readonly property alias monitor: monitor + readonly property alias count: repeater.count + property int state: -1 + Instantiator { + id: repeater + model: Monitor.MediaMonitor { + id: monitor + role: Monitor.MediaMonitor.Music + } + Binding { + required property int state + target: root + property: "state" + value: state + } + } +} diff --git a/src/monitors/mediamonitor.cpp b/src/monitors/mediamonitor.cpp new file mode 100644 index 0000000..ce44409 --- /dev/null +++ b/src/monitors/mediamonitor.cpp @@ -0,0 +1,385 @@ +/* + SPDX-FileCopyrightText: 2023 Collabora Ltd. + SPDX-FileCopyrightText: 2023 Fushan Wen + + SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "mediamonitor.h" + +#include + +#include +#include + +#include "pipewirecore_p.h" + +namespace +{ +struct Node { + MediaMonitor *monitor; + QString deviceName; + QString objectSerial; + NodeState::State state = NodeState::Error; + spa_hook proxyListener; + spa_hook objectListener; +}; + +void updateProp(const spa_dict *props, const char *key, QString &prop, int role, QList &changedRoles) +{ + const char *new_prop = spa_dict_lookup(props, key); + if (!new_prop) { + return; + } + if (QString newProp = QString::fromUtf8(new_prop); prop != newProp) { + prop = std::move(newProp); + changedRoles << role; + } +} +} + +pw_registry_events MediaMonitor::s_pwRegistryEvents = { + .version = PW_VERSION_REGISTRY_EVENTS, + .global = &MediaMonitor::onRegistryEventGlobal, + .global_remove = &MediaMonitor::onRegistryEventGlobalRemove, +}; + +pw_proxy_events MediaMonitor::s_pwProxyEvents = { + .version = PW_VERSION_PROXY_EVENTS, + .destroy = &MediaMonitor::onProxyDestroy, +}; + +pw_node_events MediaMonitor::s_pwNodeEvents = { + .version = PW_VERSION_NODE_EVENTS, + .info = &MediaMonitor::onNodeEventInfo, +}; + +MediaMonitor::MediaMonitor(QObject *parent) + : QAbstractListModel(parent) +{ + connect(this, &QAbstractListModel::rowsInserted, this, &MediaMonitor::countChanged); + connect(this, &QAbstractListModel::rowsRemoved, this, &MediaMonitor::countChanged); + connect(this, &QAbstractListModel::modelReset, this, &MediaMonitor::countChanged); + + m_reconnectTimer.setSingleShot(true); + m_reconnectTimer.setInterval(5000); + connect(&m_reconnectTimer, &QTimer::timeout, this, &MediaMonitor::connectToCore); +} + +MediaMonitor::~MediaMonitor() +{ + m_inDestructor = true; + disconnectFromCore(); +} + +QVariant MediaMonitor::data(const QModelIndex &index, int role) const +{ + if (!checkIndex(index, CheckIndexOption::IndexIsValid)) { + return {}; + } + + pw_proxy *const proxy = m_nodeList.at(index.row()).get(); + const Node *const node = static_cast(pw_proxy_get_user_data(proxy)); + + switch (role) { + case Qt::DisplayRole: + return node->deviceName; + case StateRole: + return node->state; + case ObjectSerialRole: + return node->objectSerial; + default: + return QVariant(); + } +} + +int MediaMonitor::rowCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : m_nodeList.size(); +} + +QHash MediaMonitor::roleNames() const +{ + return { + {Qt::DisplayRole, QByteArrayLiteral("display")}, + {StateRole, QByteArrayLiteral("state")}, + {ObjectSerialRole, QByteArrayLiteral("objectSerial")}, + }; +} + +MediaRole::Role MediaMonitor::role() const +{ + return m_role; +} + +void MediaMonitor::setRole(MediaRole::Role newRole) +{ + if (m_role == newRole) { + return; + } + Q_ASSERT(newRole >= MediaRole::Unknown && newRole <= MediaRole::Last); + m_role = std::clamp(newRole, MediaRole::Unknown, MediaRole::Last); + + if (m_reconnectTimer.isActive()) { + Q_EMIT roleChanged(); + return; + } + + disconnectFromCore(); + connectToCore(); + + Q_EMIT roleChanged(); +} + +bool MediaMonitor::detectionAvailable() const +{ + return m_detectionAvailable; +} + +int MediaMonitor::runningCount() const +{ + return m_runningCount; +} + +int MediaMonitor::idleCount() const +{ + return m_idleCount; +} + +void MediaMonitor::connectToCore() +{ + Q_ASSERT(!m_registry); + if (!m_componentReady || m_role == MediaRole::Unknown) { + return; + } + + if (!m_pwCore) { + m_pwCore = PipeWireCore::fetch(0); + } + if (!m_pwCore->error().isEmpty()) { + qDebug() << "received error while creating the stream" << m_pwCore->error() << "Media monitor will not work."; + m_pwCore.clear(); + m_reconnectTimer.start(); + return; + } + + m_registry = pw_core_get_registry(**m_pwCore.get(), PW_VERSION_REGISTRY, 0); + pw_registry_add_listener(m_registry, &m_registryListener, &s_pwRegistryEvents, this /*user data*/); + + m_detectionAvailable = true; + Q_EMIT detectionAvailableChanged(); + + connect(m_pwCore.get(), &PipeWireCore::pipeBroken, this, &MediaMonitor::onPipeBroken); +} + +void MediaMonitor::onPipeBroken() +{ + m_registry = nullptr; // When pipe is broken, the registered object is also gone + disconnectFromCore(); + reconnectOnIdle(); +} + +void MediaMonitor::onRegistryEventGlobal(void *data, uint32_t id, uint32_t /*permissions*/, const char *type, uint32_t /*version*/, const spa_dict *props) +{ + auto monitor = static_cast(data); + + if (!props || !(spa_streq(type, PW_TYPE_INTERFACE_Node))) { + return; + } + + static const QMetaEnum metaEnum = QMetaEnum::fromType(); + if (const char *prop_str = spa_dict_lookup(props, PW_KEY_MEDIA_ROLE); !prop_str || (strcmp(prop_str, metaEnum.valueToKey(monitor->m_role)) != 0)) { + return; + } + + auto proxy = static_cast(pw_registry_bind(monitor->m_registry, id, PW_TYPE_INTERFACE_Node, PW_VERSION_NODE, sizeof(Node))); + auto node = static_cast(pw_proxy_get_user_data(proxy)); + node->monitor = monitor; + readProps(props, proxy, false); + + monitor->beginInsertRows(QModelIndex(), monitor->m_nodeList.size(), monitor->m_nodeList.size()); + monitor->m_nodeList.emplace_back(proxy); + monitor->endInsertRows(); + + pw_proxy_add_listener(proxy, &node->proxyListener, &s_pwProxyEvents, node); + pw_proxy_add_object_listener(proxy, &node->objectListener, &s_pwNodeEvents, node); +} + +void MediaMonitor::onRegistryEventGlobalRemove(void *data, uint32_t id) +{ + auto monitor = static_cast(data); + const auto proxyIt = std::find_if(monitor->m_nodeList.cbegin(), monitor->m_nodeList.cend(), [id](const auto &proxy) { + return pw_proxy_get_bound_id(proxy.get()) == id; + }); + if (proxyIt == monitor->m_nodeList.cend()) { + return; + } + const int row = std::distance(monitor->m_nodeList.cbegin(), proxyIt); + monitor->beginRemoveRows(QModelIndex(), row, row); + monitor->m_nodeList.erase(proxyIt); + monitor->endRemoveRows(); +} + +void MediaMonitor::onProxyDestroy(void *data) +{ + auto node = static_cast(data); + spa_hook_remove(&node->proxyListener); + spa_hook_remove(&node->objectListener); +} + +void MediaMonitor::onNodeEventInfo(void *data, const pw_node_info *info) +{ + auto node = static_cast(data); + + NodeState::State newState; + switch (info->state) { + case PW_NODE_STATE_ERROR: + newState = NodeState::Error; + break; + case PW_NODE_STATE_CREATING: + newState = NodeState::Creating; + break; + case PW_NODE_STATE_SUSPENDED: + newState = NodeState::Suspended; + break; + case PW_NODE_STATE_IDLE: + newState = NodeState::Idle; + break; + case PW_NODE_STATE_RUNNING: + newState = NodeState::Running; + break; + default: + Q_ASSERT_X(false, "MediaMonitor", "Unknown node state"); + return; + } + + const auto proxyIt = std::find_if(node->monitor->m_nodeList.cbegin(), node->monitor->m_nodeList.cend(), [data](const auto &proxy) { + return pw_proxy_get_user_data(proxy.get()) == data; + }); + if (node->state != newState) { + node->state = newState; + const int row = std::distance(node->monitor->m_nodeList.cbegin(), proxyIt); + const QModelIndex idx = node->monitor->index(row, 0); + node->monitor->dataChanged(idx, idx, {StateRole}); + } + + readProps(info->props, proxyIt->get(), true); + node->monitor->updateState(); +} + +void MediaMonitor::readProps(const spa_dict *props, pw_proxy *proxy, bool emitSignal) +{ + auto node = static_cast(pw_proxy_get_user_data(proxy)); + QList changedRoles; + + updateProp(props, PW_KEY_NODE_NICK, node->deviceName, Qt::DisplayRole, changedRoles); + if (node->deviceName.isEmpty()) { + changedRoles.clear(); + updateProp(props, PW_KEY_NODE_NAME, node->deviceName, Qt::DisplayRole, changedRoles); + } + if (node->deviceName.isEmpty()) { + changedRoles.clear(); + updateProp(props, PW_KEY_NODE_DESCRIPTION, node->deviceName, Qt::DisplayRole, changedRoles); + } + + updateProp(props, PW_KEY_OBJECT_SERIAL, node->objectSerial, ObjectSerialRole, changedRoles); + + if (emitSignal && !changedRoles.empty()) { + const auto proxyIt = std::find_if(node->monitor->m_nodeList.cbegin(), node->monitor->m_nodeList.cend(), [proxy](const auto &p) { + return p.get() == proxy; + }); + const int row = std::distance(node->monitor->m_nodeList.cbegin(), proxyIt); + const QModelIndex idx = node->monitor->index(row, 0); + node->monitor->dataChanged(idx, idx, changedRoles); + } +} + +void MediaMonitor::classBegin() +{ +} + +void MediaMonitor::componentComplete() +{ + m_componentReady = true; + connectToCore(); +} + +void MediaMonitor::disconnectFromCore() +{ + if (!m_pwCore) { + return; + } + + if (m_runningCount) { + m_runningCount = 0; + Q_EMIT runningCountChanged(); + } + + if (m_idleCount) { + m_idleCount = 0; + Q_EMIT idleCountChanged(); + } + + m_detectionAvailable = false; + Q_EMIT detectionAvailableChanged(); + + if (!m_inDestructor) { + beginResetModel(); + m_nodeList.clear(); + endResetModel(); + } + + if (m_registry) { + pw_proxy_destroy(reinterpret_cast(m_registry)); + spa_hook_remove(&m_registryListener); + m_registry = nullptr; + } + disconnect(m_pwCore.get(), &PipeWireCore::pipeBroken, this, &MediaMonitor::onPipeBroken); +} + +void MediaMonitor::reconnectOnIdle() +{ + if (m_reconnectTimer.isActive()) { + return; + } + + static unsigned retryCount = 0; + if (retryCount > 100) { + qWarning() << "Camera indicator receives too many errors. Aborting..."; + return; + } + ++retryCount; + m_reconnectTimer.start(); +} + +void MediaMonitor::updateState() +{ + int newIdleCount = 0; + int newRunningCount = 0; + for (const auto &proxy : m_nodeList) { + switch (static_cast(pw_proxy_get_user_data(proxy.get()))->state) { + case NodeState::Idle: + ++newIdleCount; + break; + case NodeState::Running: + ++newRunningCount; + break; + default: + break; + } + } + + const bool idleChanged = m_idleCount != newIdleCount; + m_idleCount = newIdleCount; + const bool runningChanged = m_runningCount != newRunningCount; + m_runningCount = newRunningCount; + + if (idleChanged) { + Q_EMIT idleCountChanged(); + } + if (runningChanged) { + Q_EMIT runningCountChanged(); + } +} + +#include "moc_mediamonitor.cpp" diff --git a/src/monitors/mediamonitor.h b/src/monitors/mediamonitor.h new file mode 100644 index 0000000..d806fb5 --- /dev/null +++ b/src/monitors/mediamonitor.h @@ -0,0 +1,161 @@ +/* + SPDX-FileCopyrightText: 2023 Fushan Wen + + SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#pragma once + +#include +#include +#include +#include +#include + +#include + +class PipeWireCore; + +namespace MediaRole +{ +Q_NAMESPACE +QML_ELEMENT +// Match PW_KEY_MEDIA_ROLE +enum Role : int { + Unknown = -1, + Movie, + Music, + Camera, + Screen, + Communication, + Game, + Notification, + DSP, + Production, + Accessibility, + Test, + Last = Test, +}; +Q_ENUM_NS(Role) +} + +namespace NodeState +{ +Q_NAMESPACE +QML_ELEMENT +// Match enum pw_node_state +enum State : int { + Error = -1, /**< error state */ + Creating = 0, /**< the node is being created */ + Suspended = 1, /**< the node is suspended, the device might be closed */ + Idle = 2, /**< the node is running but there is no active port */ + Running = 3, /**< the node is running */ +}; +Q_ENUM_NS(State) +} + +class MediaMonitor : public QAbstractListModel, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + QML_ELEMENT + + /** + * Role for media streams. Only media streams with their @p PW_KEY_MEDIA_ROLE matching @p role will be monitored. + * @default MediaRole::Unknown + */ + Q_PROPERTY(MediaRole::Role role READ role WRITE setRole NOTIFY roleChanged) + + /** + * Whether this monitor is able to detect apps using Pipewire for media access + */ + Q_PROPERTY(bool detectionAvailable READ detectionAvailable NOTIFY detectionAvailableChanged) + + /** + * Total count of media streams with the given role on the system + */ + Q_PROPERTY(int count READ rowCount NOTIFY countChanged) + + /** + * The number of media streams that are currently used by applications + */ + Q_PROPERTY(int runningCount READ runningCount NOTIFY runningCountChanged) + + /** + * The number of media streams that are in idle state. + */ + Q_PROPERTY(int idleCount READ idleCount NOTIFY idleCountChanged) + +public: + enum Role { + StateRole = Qt::UserRole + 1, + ObjectSerialRole, + }; + Q_ENUM(Role); + + explicit MediaMonitor(QObject *parent = nullptr); + ~MediaMonitor() override; + + QVariant data(const QModelIndex &index, int role) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QHash roleNames() const override; + + MediaRole::Role role() const; + void setRole(MediaRole::Role newRole); + + bool detectionAvailable() const; + int runningCount() const; + int idleCount() const; + +Q_SIGNALS: + void roleChanged(); + void detectionAvailableChanged(); + void countChanged(); + void runningCountChanged(); + void idleCountChanged(); + +private Q_SLOTS: + void connectToCore(); + void onPipeBroken(); + +private: + struct ProxyDeleter { + void operator()(pw_proxy *proxy) const + { + MediaMonitor::onProxyDestroy(pw_proxy_get_user_data(proxy)); + pw_proxy_destroy(proxy); + } + }; + + static void onRegistryEventGlobal(void *data, uint32_t id, uint32_t permissions, const char *type, uint32_t version, const spa_dict *props); + static void onRegistryEventGlobalRemove(void *data, uint32_t id); + static void onProxyDestroy(void *data); + static void onNodeEventInfo(void *data, const pw_node_info *info); + + static void readProps(const spa_dict *props, pw_proxy *proxy, bool emitSignal); + + void classBegin() override; + void componentComplete() override; + + void disconnectFromCore(); + void reconnectOnIdle(); + void updateState(); + + static pw_registry_events s_pwRegistryEvents; + static pw_proxy_events s_pwProxyEvents; + static pw_node_events s_pwNodeEvents; + + bool m_componentReady = false; + MediaRole::Role m_role = MediaRole::Unknown; + bool m_detectionAvailable = false; + int m_runningCount = 0; + int m_idleCount = 0; + + QSharedPointer m_pwCore; + pw_registry *m_registry = nullptr; + spa_hook m_registryListener; + std::vector> m_nodeList; + QTimer m_reconnectTimer; + + bool m_inDestructor = false; +}; diff --git a/src/pipewirebaseencodedstream.cpp b/src/pipewirebaseencodedstream.cpp new file mode 100644 index 0000000..814d8d9 --- /dev/null +++ b/src/pipewirebaseencodedstream.cpp @@ -0,0 +1,266 @@ +/* + SPDX-FileCopyrightText: 2022-2023 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "pipewirebaseencodedstream.h" + +#include +#include +#include +#include + +extern "C" { +#include +#include +} +#include + +#include "pipewireproduce_p.h" +#include "vaapiutils_p.h" + +struct PipeWireEncodedStreamPrivate { + uint m_nodeId = 0; + std::optional m_fd; + Fraction m_maxFramerate; + int m_maxPendingFrames = 50; + bool m_active = false; + PipeWireBaseEncodedStream::Encoder m_encoder; + std::optional m_quality; + PipeWireBaseEncodedStream::EncodingPreference m_encodingPreference; + + std::unique_ptr m_produceThread; + std::unique_ptr m_produce; +}; + +PipeWireBaseEncodedStream::State PipeWireBaseEncodedStream::state() const +{ + if (isActive()) { + return Recording; + } else if (d->m_produceThread && d->m_produce->m_deactivated && d->m_produceThread->isRunning()) { + return Rendering; + } + + return Idle; +} + +PipeWireBaseEncodedStream::PipeWireBaseEncodedStream(QObject *parent) + : QObject(parent) + , d(new PipeWireEncodedStreamPrivate) +{ + d->m_encoder = suggestedEncoders().value(0, NoEncoder); + + const auto &category = PIPEWIRELIBAV_LOGGING(); + if (category.isDebugEnabled()) { + av_log_set_level(AV_LOG_DEBUG); + } else if (category.isInfoEnabled()) { + av_log_set_level(AV_LOG_INFO); + } else if (category.isWarningEnabled()) { + av_log_set_level(AV_LOG_WARNING); + } else { + av_log_set_level(AV_LOG_ERROR); + } +} + +PipeWireBaseEncodedStream::~PipeWireBaseEncodedStream() +{ + setActive(false); + + if (d->m_fd) { + close(*d->m_fd); + } +} + +void PipeWireBaseEncodedStream::setNodeId(uint nodeId) +{ + if (nodeId == d->m_nodeId) + return; + + d->m_nodeId = nodeId; + refresh(); + Q_EMIT nodeIdChanged(nodeId); +} + +void PipeWireBaseEncodedStream::setFd(uint fd) +{ + if (fd == d->m_fd) + return; + + if (d->m_fd) { + close(*d->m_fd); + } + d->m_fd = fd; + refresh(); + Q_EMIT fdChanged(fd); +} + +Fraction PipeWireBaseEncodedStream::maxFramerate() const +{ + if (d->m_maxFramerate) { + return d->m_maxFramerate; + } + return Fraction{60, 1}; +} + +void PipeWireBaseEncodedStream::setMaxFramerate(const Fraction &framerate) +{ + if (d->m_maxFramerate == framerate) { + return; + } + d->m_maxFramerate = framerate; + + if (d->m_produce) { + d->m_produce->setMaxFramerate(d->m_maxFramerate); + } + + Q_EMIT maxFramerateChanged(); +} + +void PipeWireBaseEncodedStream::setMaxFramerate(quint32 numerator, quint32 denominator) +{ + setMaxFramerate({numerator, denominator}); +} + +void PipeWireBaseEncodedStream::setMaxPendingFrames(int maxPendingFrames) +{ + if (d->m_maxPendingFrames == maxPendingFrames) { + return; + } + if (d->m_produce) { + d->m_produce->setMaxPendingFrames(maxPendingFrames); + } + d->m_maxPendingFrames = maxPendingFrames; + Q_EMIT maxPendingFramesChanged(); +} + +int PipeWireBaseEncodedStream::maxBufferSize() const +{ + return d->m_maxPendingFrames; +} + +void PipeWireBaseEncodedStream::setActive(bool active) +{ + if (d->m_active == active) + return; + + d->m_active = active; + refresh(); + Q_EMIT activeChanged(active); +} + +std::optional PipeWireBaseEncodedStream::quality() const +{ + return d->m_quality; +} + +void PipeWireBaseEncodedStream::setQuality(quint8 quality) +{ + d->m_quality = quality; + if (d->m_produce) { + d->m_produce->setQuality(d->m_quality); + } +} + +void PipeWireBaseEncodedStream::refresh() +{ + if (d->m_produceThread) { + QMetaObject::invokeMethod(d->m_produce.get(), &PipeWireProduce::deactivate, Qt::QueuedConnection); + d->m_produceThread->wait(); + + d->m_produce.reset(); + d->m_produceThread.reset(); + } + + if (d->m_active && d->m_nodeId > 0) { + d->m_produceThread = std::make_unique(); + d->m_produceThread->setObjectName("PipeWireProduce::input"); + d->m_produce = makeProduce(); + d->m_produce->setQuality(d->m_quality); + d->m_produce->setMaxPendingFrames(d->m_maxPendingFrames); + d->m_produce->setEncodingPreference(d->m_encodingPreference); + d->m_produce->moveToThread(d->m_produceThread.get()); + d->m_produceThread->start(); + QMetaObject::invokeMethod(d->m_produce.get(), &PipeWireProduce::initialize, Qt::QueuedConnection); + } + + Q_EMIT stateChanged(); +} + +void PipeWireBaseEncodedStream::setEncoder(Encoder encoder) +{ + if (d->m_encoder == encoder || !suggestedEncoders().contains(encoder)) { + return; + } + d->m_encoder = encoder; + Q_EMIT encoderChanged(); +} + +PipeWireBaseEncodedStream::Encoder PipeWireBaseEncodedStream::encoder() const +{ + return d->m_encoder; +} + +QList PipeWireBaseEncodedStream::suggestedEncoders() const +{ + auto vaapi = VaapiUtils::instance(); + + QList ret = {PipeWireBaseEncodedStream::VP8, + PipeWireBaseEncodedStream::VP9, + PipeWireBaseEncodedStream::H264Main, + PipeWireBaseEncodedStream::H264Baseline}; + auto removeUnavailableEncoders = [&vaapi](const PipeWireBaseEncodedStream::Encoder &encoder) { + switch (encoder) { + case PipeWireBaseEncodedStream::VP8: + if (vaapi->supportsProfile(VAProfileVP8Version0_3) && avcodec_find_encoder_by_name("vp8_vaapi")) { + return false; + } else { + return !avcodec_find_encoder_by_name("libvpx"); + } + case PipeWireBaseEncodedStream::VP9: + return !avcodec_find_encoder_by_name("libvpx-vp9"); + case PipeWireBaseEncodedStream::H264Main: + case PipeWireBaseEncodedStream::H264Baseline: + if (vaapi->supportsProfile(encoder == PipeWireBaseEncodedStream::H264Main ? VAProfileH264Main : VAProfileH264ConstrainedBaseline) + && avcodec_find_encoder_by_name("h264_vaapi")) { + return false; + } else { + return !(avcodec_find_encoder_by_name("libx264") || avcodec_find_encoder_by_name("libopenh264")); + } + default: + return true; + } + }; + ret.removeIf(removeUnavailableEncoders); + return ret; +} + +void PipeWireBaseEncodedStream::setEncodingPreference(PipeWireBaseEncodedStream::EncodingPreference preference) +{ + d->m_encodingPreference = preference; + if (d->m_produce) { + d->m_produce->setEncodingPreference(d->m_encodingPreference); + } +} + +PipeWireBaseEncodedStream::EncodingPreference PipeWireBaseEncodedStream::encodingPreference() +{ + return d->m_encodingPreference; +} + +bool PipeWireBaseEncodedStream::isActive() const +{ + return d->m_active; +} + +uint PipeWireBaseEncodedStream::nodeId() const +{ + return d->m_nodeId; +} + +uint PipeWireBaseEncodedStream::fd() const +{ + return d->m_fd.value_or(0); +} + +#include "moc_pipewirebaseencodedstream.cpp" diff --git a/src/pipewirebaseencodedstream.h b/src/pipewirebaseencodedstream.h new file mode 100644 index 0000000..1b2f13f --- /dev/null +++ b/src/pipewirebaseencodedstream.h @@ -0,0 +1,130 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include + +#include + +struct Fraction; +struct PipeWireEncodedStreamPrivate; +class PipeWireProduce; + +class KPIPEWIRE_EXPORT PipeWireBaseEncodedStream : public QObject +{ + Q_OBJECT + /// Specify the pipewire node id that we want to record + Q_PROPERTY(uint nodeId READ nodeId WRITE setNodeId NOTIFY nodeIdChanged) + /** + * Specifies the file descriptor we are connected to, if none 0 will be returned + * + * Transfers the ownership of the fd, will close it when it's done with it. + */ + Q_PROPERTY(uint fd READ fd WRITE setFd NOTIFY fdChanged) + Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) + Q_PROPERTY(State state READ state NOTIFY stateChanged) + Q_PROPERTY(Encoder encoder READ encoder WRITE setEncoder NOTIFY encoderChanged) + +public: + enum Encoder { + NoEncoder, + VP8, + VP9, + H264Main, + H264Baseline, + }; + Q_ENUM(Encoder) + + PipeWireBaseEncodedStream(QObject *parent = nullptr); + ~PipeWireBaseEncodedStream() override; + + void setNodeId(uint nodeId); + uint nodeId() const; + + void setFd(uint fd); + uint fd() const; + + Fraction maxFramerate() const; + void setMaxFramerate(const Fraction &framerate); + void setMaxFramerate(quint32 numerator, quint32 denominator = 1); + + /** + * Defines how many frames are kept in the encoding buffer. + * New frames after the buffer is full will be dropped. + * + * This needs to be high enough for intra-frame analysis. + * The default value is 50. + * + * There is a minimum value of 3. + */ + void setMaxPendingFrames(int maxBufferSize); + int maxBufferSize() const; + + bool isActive() const; + void setActive(bool active); + + /** + * The quality used for encoding. + */ + std::optional quality() const; + /** + * Set the quality to use for encoding. + * + * This uses a range of 0-100 as a percentage, with 0 being lowest quality + * and 100 being highest. This is internally converted to a value relevant to + * the encoder. + * + * @param quality The quality level to use. + */ + void setQuality(quint8 quality); + + enum State { + Idle, //< ready to get started + Recording, //< actively recording + Rendering, //< recording is over but there are still frames being processed. + }; + Q_ENUM(State) + State state() const; + + /** + * Set the FFmpeg @p encoder that will be used to create the video + * + * They can be inspected using: + * ffmpeg -encoders | grep "^ V" + */ + void setEncoder(Encoder encoder); + Encoder encoder() const; + + /// Returns the encoders that are tested to work, sorted by preference + QList suggestedEncoders() const; + + enum EncodingPreference { + NoPreference, ///< Default settings, good for most usecases + Quality, ///< A bit slower than default, but more consistent bitrate, use for high quality + Speed, ///< Encode as fast as possible and use zerolatency tune, good for streaming + Size, ///< Slowest encoding but reduces the size of the file + }; + Q_ENUM(EncodingPreference); + void setEncodingPreference(EncodingPreference profile); + +Q_SIGNALS: + void activeChanged(bool active); + void nodeIdChanged(uint nodeId); + void fdChanged(uint fd); + void errorFound(const QString &error); + void maxFramerateChanged(); + void maxPendingFramesChanged(); + void stateChanged(); + void encoderChanged(); + +protected: + virtual std::unique_ptr makeProduce() = 0; + EncodingPreference encodingPreference(); + + void refresh(); + QScopedPointer d; +}; diff --git a/src/pipewirecore.cpp b/src/pipewirecore.cpp new file mode 100644 index 0000000..82c3e18 --- /dev/null +++ b/src/pipewirecore.cpp @@ -0,0 +1,146 @@ +/* + SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez + SPDX-FileContributor: Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "pipewirecore_p.h" + +#include +#include +#include +#include +#include +#include + +#include "logging.h" + +pw_core_events PipeWireCore::s_pwCoreEvents = { + .version = PW_VERSION_CORE_EVENTS, + .info = &PipeWireCore::onCoreInfo, + .done = nullptr, + .ping = nullptr, + .error = &PipeWireCore::onCoreError, + .remove_id = nullptr, + .bound_id = nullptr, + .add_mem = nullptr, + .remove_mem = nullptr, +}; + +PipeWireCore::PipeWireCore() +{ + static std::once_flag pwInitOnce; + std::call_once(pwInitOnce, [] { pw_init(nullptr, nullptr); }); +} + +void PipeWireCore::onCoreError(void *data, uint32_t id, int seq, int res, const char *message) +{ + Q_UNUSED(seq) + + qCWarning(PIPEWIRE_LOGGING) << "PipeWire remote error: " << res << message; + if (id == PW_ID_CORE) { + PipeWireCore *pw = static_cast(data); + Q_EMIT pw->pipewireFailed(QString::fromUtf8(message)); + + if (res == -EPIPE) { + // Broken pipe, need reconnecting + if (pw->m_pwCore) { + Q_EMIT pw->pipeBroken(); + spa_hook_remove(&pw->m_coreListener); + pw_core_disconnect(pw->m_pwCore); + pw->init_core(); + } + } + } +} + +void PipeWireCore::onCoreInfo(void *data, const struct pw_core_info *info) +{ + PipeWireCore *pw = static_cast(data); + pw->m_serverVersion = QVersionNumber::fromString(QString::fromUtf8(info->version)); +} + +PipeWireCore::~PipeWireCore() +{ + if (m_pwMainLoop) { + pw_loop_leave(m_pwMainLoop); + } + + if (m_pwCore) { + pw_core_disconnect(m_pwCore); + } + + if (m_pwContext) { + pw_context_destroy(m_pwContext); + } + + if (m_pwMainLoop) { + pw_loop_destroy(m_pwMainLoop); + } +} + +bool PipeWireCore::init(int fd) +{ + m_pwMainLoop = pw_loop_new(nullptr); + pw_loop_enter(m_pwMainLoop); + + QSocketNotifier *notifier = new QSocketNotifier(pw_loop_get_fd(m_pwMainLoop), QSocketNotifier::Read, this); + connect(notifier, &QSocketNotifier::activated, this, [this] { + int result = pw_loop_iterate(m_pwMainLoop, 0); + if (result < 0) + qCWarning(PIPEWIRE_LOGGING) << "pipewire_loop_iterate failed: " << spa_strerror(result); + }); + + m_pwContext = pw_context_new(m_pwMainLoop, nullptr, 0); + if (!m_pwContext) { + qCWarning(PIPEWIRE_LOGGING) << "Failed to create PipeWire context"; + m_error = i18n("Failed to create PipeWire context"); + return false; + } + + m_fd = fd; + + return init_core(); +} + +bool PipeWireCore::init_core() +{ + if (m_fd > 0) { + m_pwCore = pw_context_connect_fd(m_pwContext, m_fd, nullptr, 0); + } else { + m_pwCore = pw_context_connect(m_pwContext, nullptr, 0); + } + if (!m_pwCore) { + m_error = i18n("Failed to connect to PipeWire"); + qCWarning(PIPEWIRE_LOGGING) << "error:" << m_error << m_fd; + return false; + } + + if (pw_loop_iterate(m_pwMainLoop, 0) < 0) { + qCWarning(PIPEWIRE_LOGGING) << "Failed to start main PipeWire loop"; + m_error = i18n("Failed to start main PipeWire loop"); + return false; + } + + pw_core_add_listener(m_pwCore, &m_coreListener, &s_pwCoreEvents, this); + return true; +} + +QSharedPointer PipeWireCore::fetch(int fd) +{ + static QThreadStorage>> global; + QSharedPointer ret = global.localData().value(fd).toStrongRef(); + if (!ret) { + ret.reset(new PipeWireCore); + if (ret->init(fd)) { + global.localData().insert(fd, ret); + } + } + return ret; +} + +QString PipeWireCore::error() const +{ + return m_error; +} diff --git a/src/pipewirecore_p.h b/src/pipewirecore_p.h new file mode 100644 index 0000000..183b0d5 --- /dev/null +++ b/src/pipewirecore_p.h @@ -0,0 +1,64 @@ +/* + SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez + SPDX-FileContributor: Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include +#include +#include + +#include + +class KPIPEWIRE_EXPORT PipeWireCore : public QObject +{ + Q_OBJECT +public: + PipeWireCore(); + + static void onCoreError(void *data, uint32_t id, int seq, int res, const char *message); + static void onCoreInfo(void *data, const struct pw_core_info *info); + + ~PipeWireCore(); + + bool init(int fd); + bool init_core(); + QString error() const; + QVersionNumber serverVersion() const + { + return m_serverVersion; + } + + pw_loop *loop() const + { + return m_pwMainLoop; + } + + pw_core *operator*() const + { + return m_pwCore; + }; + static QSharedPointer fetch(int fd); + +private: + int m_fd = 0; + pw_core *m_pwCore = nullptr; + pw_context *m_pwContext = nullptr; + pw_loop *m_pwMainLoop = nullptr; + spa_hook m_coreListener; + QString m_error; + QVersionNumber m_serverVersion; + + static pw_core_events s_pwCoreEvents; + +Q_SIGNALS: + void pipewireFailed(const QString &message); + + /** + * Clients should disconnect from the core and reconnect to it on receiving this signal + */ + void pipeBroken(); +}; diff --git a/src/pipewireencodedstream.cpp b/src/pipewireencodedstream.cpp new file mode 100644 index 0000000..72d9ee7 --- /dev/null +++ b/src/pipewireencodedstream.cpp @@ -0,0 +1,96 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "pipewireencodedstream.h" +#include "pipewireencodedstream_p.h" +#include "pipewireproduce_p.h" +#include + +extern "C" { +#include +} + +class PipeWirePacketPrivate +{ +public: + PipeWirePacketPrivate(bool isKey, const QByteArray &data) + : isKey(isKey) + , data(data) + { + } + + const bool isKey; + const QByteArray data; +}; + +PipeWireEncodedStream::Packet::Packet(bool isKey, const QByteArray &data) + : d(std::make_shared(isKey, data)) +{ +} + +QByteArray PipeWireEncodedStream::Packet::data() const +{ + return d->data; +} + +bool PipeWireEncodedStream::Packet::isKeyFrame() const +{ + return d->isKey; +} + +PipeWireEncodeProduce::PipeWireEncodeProduce(PipeWireBaseEncodedStream::Encoder encoder, + uint nodeId, + uint fd, + const Fraction &framerate, + PipeWireEncodedStream *stream) + : PipeWireProduce(encoder, nodeId, fd, framerate) + , m_encodedStream(stream) +{ +} + +void PipeWireEncodeProduce::processPacket(AVPacket *packet) +{ + if (!packet) { + return; + } + + Q_EMIT newPacket(PipeWireEncodedStream::Packet(packet->flags & AV_PKT_FLAG_KEY, QByteArray(reinterpret_cast(packet->data), packet->size))); +} + +void PipeWireEncodeProduce::processFrame(const PipeWireFrame &frame) +{ + if (m_size != m_stream->size()) { + m_size = m_stream->size(); + Q_EMIT m_encodedStream->sizeChanged(m_size); + } + + PipeWireProduce::processFrame(frame); + if (frame.cursor && m_cursor != *frame.cursor) { + m_cursor = *frame.cursor; + Q_EMIT m_encodedStream->cursorChanged(m_cursor); + } +} + +PipeWireEncodedStream::PipeWireEncodedStream(QObject *parent) + : PipeWireBaseEncodedStream(parent) +{ +} + +PipeWireEncodedStream::~PipeWireEncodedStream() = default; + +std::unique_ptr PipeWireEncodedStream::makeProduce() +{ + auto produce = new PipeWireEncodeProduce(encoder(), nodeId(), fd(), maxFramerate(), this); + connect(produce, &PipeWireEncodeProduce::newPacket, this, &PipeWireEncodedStream::newPacket); + connect(this, &PipeWireEncodedStream::maxFramerateChanged, produce, [this, produce]() { + produce->setMaxFramerate(maxFramerate()); + }); + return std::unique_ptr(produce); +} + +#include "moc_pipewireencodedstream_p.cpp" + +#include "moc_pipewireencodedstream.cpp" diff --git a/src/pipewireencodedstream.h b/src/pipewireencodedstream.h new file mode 100644 index 0000000..6cac471 --- /dev/null +++ b/src/pipewireencodedstream.h @@ -0,0 +1,44 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include + +#include "pipewirebaseencodedstream.h" +#include + +struct PipeWireCursor; +class PipeWirePacketPrivate; + +class KPIPEWIRE_EXPORT PipeWireEncodedStream : public PipeWireBaseEncodedStream +{ + Q_OBJECT +public: + PipeWireEncodedStream(QObject *parent = nullptr); + ~PipeWireEncodedStream() override; + + class Packet + { + public: + Packet(bool isKey, const QByteArray &data); + + /// Whether the packet represents a key frame + bool isKeyFrame() const; + QByteArray data() const; + + std::shared_ptr d; + }; + +Q_SIGNALS: + /// will be emitted when the stream initializes as well as when the value changes + void sizeChanged(const QSize &size); + void cursorChanged(const PipeWireCursor &cursor); + void newPacket(const Packet &packet); + +protected: + std::unique_ptr makeProduce() override; +}; diff --git a/src/pipewireencodedstream_p.h b/src/pipewireencodedstream_p.h new file mode 100644 index 0000000..89c20e7 --- /dev/null +++ b/src/pipewireencodedstream_p.h @@ -0,0 +1,28 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include "pipewireencodedstream.h" +#include "pipewireproduce_p.h" + +class PipeWireEncodeProduce : public PipeWireProduce +{ + Q_OBJECT +public: + PipeWireEncodeProduce(PipeWireBaseEncodedStream::Encoder encoder, uint nodeId, uint fd, const Fraction &framerate, PipeWireEncodedStream *stream); + + void processPacket(AVPacket *packet) override; + void processFrame(const PipeWireFrame &frame) override; + +Q_SIGNALS: + void newPacket(const PipeWireEncodedStream::Packet &packetData); + +private: + PipeWireEncodedStream *const m_encodedStream; + QSize m_size; + PipeWireCursor m_cursor; +}; diff --git a/src/pipewireproduce.cpp b/src/pipewireproduce.cpp new file mode 100644 index 0000000..19bbb74 --- /dev/null +++ b/src/pipewireproduce.cpp @@ -0,0 +1,381 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "pipewireproduce_p.h" + +#include +#include +#include +#include + +#include +#include +#include + +#include "h264vaapiencoder_p.h" +#include "libopenh264encoder_p.h" +#include "libvpxencoder_p.h" +#include "libvpxvp9encoder_p.h" +#include "libx264encoder_p.h" + +extern "C" { +#include +} + +Q_DECLARE_METATYPE(std::optional); +Q_DECLARE_METATYPE(std::optional); + +PipeWireProduce::PipeWireProduce(PipeWireBaseEncodedStream::Encoder encoderType, uint nodeId, uint fd, const Fraction &framerate) + : QObject() + , m_nodeId(nodeId) + , m_encoderType(encoderType) + , m_fd(fd) + , m_frameRate(framerate) +{ + qRegisterMetaType>(); + qRegisterMetaType>(); +} + +PipeWireProduce::~PipeWireProduce() +{ +} + +void PipeWireProduce::initialize() +{ + m_stream.reset(new PipeWireSourceStream(nullptr)); + m_stream->setMaxFramerate(m_frameRate); + + // The check in supportsHardwareEncoding() is insufficient to fully + // determine if we actually support hardware encoding the current stream, + // but to determine that we need the stream size, which we don't get until + // after we've created the stream, but creating the stream sets important + // parameters that require the correct usage hint to be set. So use the + // insufficient check to set the hint, assuming that we still get a working + // stream when we use the wrong hint with software encoding. + m_stream->setUsageHint(Encoder::supportsHardwareEncoding() ? PipeWireSourceStream::UsageHint::EncodeHardware + : PipeWireSourceStream::UsageHint::EncodeSoftware); + + bool created = m_stream->createStream(m_nodeId, m_fd); + if (!created || !m_stream->error().isEmpty()) { + qCWarning(PIPEWIRERECORD_LOGGING) << "failed to set up stream for" << m_nodeId << m_stream->error(); + m_error = m_stream->error(); + m_stream.reset(nullptr); + return; + } + connect(m_stream.get(), &PipeWireSourceStream::streamParametersChanged, this, &PipeWireProduce::setupStream); +} + +Fraction PipeWireProduce::maxFramerate() const +{ + return m_maxFramerate; +} + +void PipeWireProduce::setMaxFramerate(const Fraction &framerate) +{ + m_maxFramerate = framerate; + if (m_stream) { + m_stream->setMaxFramerate(framerate); + } +} + +int PipeWireProduce::maxPendingFrames() const +{ + return m_maxPendingFrames; +} + +void PipeWireProduce::setMaxPendingFrames(int newMaxBufferSize) +{ + if (newMaxBufferSize < 3) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Maxmimum pending frame count of " << newMaxBufferSize << " requested. Value must be 3 or higher."; + newMaxBufferSize = 3; + } + m_maxPendingFrames = newMaxBufferSize; +} + +void PipeWireProduce::setupStream() +{ + qCDebug(PIPEWIRERECORD_LOGGING) << "Setting up stream"; + disconnect(m_stream.get(), &PipeWireSourceStream::streamParametersChanged, this, &PipeWireProduce::setupStream); + + m_encoder = makeEncoder(); + if (!m_encoder) { + qCWarning(PIPEWIRERECORD_LOGGING) << "No encoder could be created"; + return; + } + + connect(m_stream.get(), &PipeWireSourceStream::stateChanged, this, &PipeWireProduce::stateChanged); + if (!setupFormat()) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not set up the producing thread"; + return; + } + + connect(m_stream.data(), &PipeWireSourceStream::frameReceived, this, &PipeWireProduce::processFrame); + + m_passthroughThread = std::thread([this]() { + m_passthroughRunning = true; + while (m_passthroughRunning) { + std::unique_lock lock(m_passthroughMutex); + m_passthroughCondition.wait(lock); + + if (!m_passthroughRunning) { + break; + } + + auto [filtered, queued] = m_encoder->encodeFrame(m_maxPendingFrames - m_pendingEncodeFrames); + m_pendingFilterFrames -= filtered; + m_pendingEncodeFrames += queued; + + m_outputCondition.notify_all(); + } + }); + pthread_setname_np(m_passthroughThread.native_handle(), "PipeWireProduce::passthrough"); + + m_outputThread = std::thread([this]() { + m_outputRunning = true; + while (m_outputRunning) { + std::unique_lock lock(m_outputMutex); + m_outputCondition.wait(lock); + + if (!m_outputRunning) { + break; + } + + auto received = m_encoder->receivePacket(); + m_pendingEncodeFrames -= received; + + // Notify the produce thread that the count of processed frames has + // changed and it can do cleanup if needed, making sure that that + // handling is done on the right thread. + QMetaObject::invokeMethod(this, &PipeWireProduce::handleEncodedFramesChanged, Qt::QueuedConnection); + } + }); + pthread_setname_np(m_outputThread.native_handle(), "PipeWireProduce::output"); +} + +void PipeWireProduce::deactivate() +{ + m_deactivated = true; + + auto streamState = PW_STREAM_STATE_PAUSED; + if (m_stream) { + streamState = m_stream->state(); + m_stream->setActive(false); + } + + // If we have not been initialized properly before, ensure we still run any + // cleanup code and exit the thread, otherwise we risk applications not closing + // properly. + if (!m_encoder || streamState != PW_STREAM_STATE_STREAMING) { + QMetaObject::invokeMethod(this, &PipeWireProduce::destroy, Qt::QueuedConnection); + } +} + +void PipeWireProduce::destroy() +{ + // Ensure we cleanup the PipeWireSourceStream while in the same thread we + // created it in. + Q_ASSERT_X(QThread::currentThread() == thread(), "PipeWireProduce", "destroy() called from a different thread than PipeWireProduce's thread"); + + if (!m_stream) { + return; + } + + if (m_passthroughThread.joinable()) { + m_passthroughRunning = false; + m_passthroughCondition.notify_all(); + m_passthroughThread.join(); + } + + if (m_outputThread.joinable()) { + m_outputRunning = false; + m_outputCondition.notify_all(); + m_outputThread.join(); + } + + m_stream.reset(); + + qCDebug(PIPEWIRERECORD_LOGGING) << "finished"; + cleanup(); + QThread::currentThread()->quit(); +} + +void PipeWireProduce::setQuality(const std::optional &quality) +{ + m_quality = quality; + if (m_encoder) { + m_encoder->setQuality(quality); + } +} + +void PipeWireProduce::setEncodingPreference(const PipeWireBaseEncodedStream::EncodingPreference &encodingPreference) +{ + m_encodingPreference = encodingPreference; + + if (m_encoder) { + m_encoder->setEncodingPreference(encodingPreference); + } +} + +void PipeWireProduce::processFrame(const PipeWireFrame &frame) +{ + auto f = frame; + + if (frame.cursor) { + m_cursor.position = frame.cursor->position; + m_cursor.hotspot = frame.cursor->hotspot; + if (!frame.cursor->texture.isNull()) { + m_cursor.dirty = true; + m_cursor.texture = frame.cursor->texture; + } + } + + auto pts = framePts(frame.presentationTimestamp); + if (m_previousPts >= 0 && pts <= m_previousPts) { + return; + } + + auto frameTime = 1000.0 / (m_maxFramerate.numerator / m_maxFramerate.denominator); + if ((pts - m_previousPts) < frameTime) { + return; + } + + if (m_pendingFilterFrames + 1 > m_maxPendingFrames) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Filter queue is full, dropping frame" << pts; + return; + } + + aboutToEncode(f); + if (!m_encoder->filterFrame(f)) { + return; + } + + m_pendingFilterFrames++; + m_previousPts = pts; + + m_passthroughCondition.notify_all(); +} + +void PipeWireProduce::stateChanged(pw_stream_state state) +{ + if (state != PW_STREAM_STATE_PAUSED || !m_deactivated) { + return; + } + if (!m_stream) { + qCDebug(PIPEWIRERECORD_LOGGING) << "finished without a stream"; + return; + } + + disconnect(m_stream.data(), &PipeWireSourceStream::frameReceived, this, &PipeWireProduce::processFrame); + + if (m_pendingFilterFrames <= 0 && m_pendingEncodeFrames <= 0) { + // If we have nothing pending, cleanup immediately. + m_encoder->finish(); + + // We want to clean up the source stream while in the input thread, but we + // need to do so while not handling any PipeWire callback as that risks + // crashing because we're stil executing PipeWire handling code. + QMetaObject::invokeMethod(this, &PipeWireProduce::destroy, Qt::QueuedConnection); + } else { + // If we have pending frames, wait with cleanup until all frames have been processed. + qCDebug(PIPEWIRERECORD_LOGGING) << "Waiting for frame queues to empty, still pending filter" << m_pendingFilterFrames << "encode" + << m_pendingEncodeFrames; + m_passthroughCondition.notify_all(); + } +} + +void PipeWireProduce::handleEncodedFramesChanged() +{ + if (!m_deactivated) { + return; + } + + // If we're deactivating but still have frames in the queue, we want to + // flush everything. Since at that point we are not receiving new frames, we + // need a different trigger to make the filtering thread process frames. + // Triggering here means the filter thread runs as fast as the encode thread + // can process the frames. + m_passthroughCondition.notify_all(); + + if (m_pendingFilterFrames <= 0) { + m_encoder->finish(); + + if (m_pendingEncodeFrames <= 0) { + destroy(); + } + } +} + +std::unique_ptr PipeWireProduce::makeEncoder() +{ + auto forcedEncoder = qEnvironmentVariable("KPIPEWIRE_FORCE_ENCODER"); + if (!forcedEncoder.isNull()) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Forcing encoder to" << forcedEncoder; + } + + auto size = m_stream->size(); + + switch (m_encoderType) { + case PipeWireBaseEncodedStream::H264Baseline: + case PipeWireBaseEncodedStream::H264Main: { + auto profile = m_encoderType == PipeWireBaseEncodedStream::H264Baseline ? Encoder::H264Profile::Baseline : Encoder::H264Profile::Main; + + if (forcedEncoder.isNull() || forcedEncoder == u"h264_vaapi") { + auto hardwareEncoder = std::make_unique(profile, this); + hardwareEncoder->setQuality(m_quality); + hardwareEncoder->setEncodingPreference(m_encodingPreference); + if (hardwareEncoder->initialize(size)) { + return hardwareEncoder; + } + } + + if (forcedEncoder.isNull() || forcedEncoder == u"libx264") { + auto softwareEncoder = std::make_unique(profile, this); + softwareEncoder->setQuality(m_quality); + softwareEncoder->setEncodingPreference(m_encodingPreference); + if (softwareEncoder->initialize(size)) { + return softwareEncoder; + } + } + + // Try libopenh264 last, it's slower and has less features. + if (forcedEncoder.isNull() || forcedEncoder == u"libopenh264") { + auto softwareEncoder = std::make_unique(profile, this); + softwareEncoder->setQuality(m_quality); + softwareEncoder->setEncodingPreference(m_encodingPreference); + if (softwareEncoder->initialize(size)) { + return softwareEncoder; + } + } + break; + } + case PipeWireBaseEncodedStream::VP8: { + if (forcedEncoder.isNull() || forcedEncoder == u"libvpx") { + auto encoder = std::make_unique(this); + encoder->setQuality(m_quality); + if (encoder->initialize(size)) { + return encoder; + } + } + break; + } + case PipeWireBaseEncodedStream::VP9: { + if (forcedEncoder.isNull() || forcedEncoder == u"libvpx-vp9") { + auto encoder = std::make_unique(this); + encoder->setQuality(m_quality); + if (encoder->initialize(size)) { + return encoder; + } + } + break; + } + default: + qCWarning(PIPEWIRERECORD_LOGGING) << "Unknown encoder type" << m_encoderType; + } + + return nullptr; +} + +#include "moc_pipewireproduce_p.cpp" diff --git a/src/pipewireproduce_p.h b/src/pipewireproduce_p.h new file mode 100644 index 0000000..0d59c10 --- /dev/null +++ b/src/pipewireproduce_p.h @@ -0,0 +1,155 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include +#include + +extern "C" { +#include +#include +#include +#include +} + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "pipewirebaseencodedstream.h" +#include "pipewiresourcestream.h" + +struct AVCodec; +struct AVCodecContext; +struct AVFrame; +struct AVPacket; + +struct AVFilterContext; +struct AVFilterGraph; + +class CustomAVFrame; +class Encoder; +class PipeWireReceiveEncodedThread; + +class PipeWireProduce : public QObject +{ + Q_OBJECT +public: + PipeWireProduce(PipeWireBaseEncodedStream::Encoder encoderType, uint nodeId, uint fd, const Fraction &framerate); + ~PipeWireProduce() override; + + virtual void initialize(); + + QString error() const + { + return m_error; + } + + Fraction maxFramerate() const; + void setMaxFramerate(const Fraction &framerate); + + int maxPendingFrames() const; + void setMaxPendingFrames(int newMaxBufferSize); + + virtual int64_t framePts(const std::optional &presentationTimestamp) + { + return std::chrono::duration_cast(presentationTimestamp.value()).count(); + } + + virtual void processPacket(AVPacket *packet) = 0; + virtual bool setupFormat() + { + return true; + } + virtual void cleanup() + { + } + + void stateChanged(pw_stream_state state); + void setupStream(); + virtual void processFrame(const PipeWireFrame &frame); + void render(const QImage &image, const PipeWireFrame &frame); + virtual void aboutToEncode(PipeWireFrame &frame) + { + Q_UNUSED(frame); + } + + void deactivate(); + + void destroy(); + + void setQuality(const std::optional &quality); + + void setEncodingPreference(const PipeWireBaseEncodedStream::EncodingPreference &encodingPreference); + + void handleEncodedFramesChanged(); + + const uint m_nodeId; + QScopedPointer m_stream; + QString m_error; + + PipeWireBaseEncodedStream::Encoder m_encoderType; + QByteArray m_encoderName; + std::unique_ptr m_encoder; + + uint m_fd; + Fraction m_frameRate; + + std::optional m_quality; + + PipeWireBaseEncodedStream::EncodingPreference m_encodingPreference; + + struct { + QImage texture; + std::optional position; + QPoint hotspot; + bool dirty = false; + } m_cursor; + + std::thread m_passthroughThread; + std::thread m_outputThread; + // Can't use jthread directly as it's not available in libc++ yet, + // so manually handle the stop source. + std::atomic_bool m_passthroughRunning = false; + std::atomic_bool m_outputRunning = false; + + std::condition_variable m_passthroughCondition; + std::mutex m_passthroughMutex; + std::condition_variable m_outputCondition; + std::mutex m_outputMutex; + + std::atomic_bool m_deactivated = false; + + int64_t m_previousPts = -1; + + std::atomic_int m_pendingFilterFrames = 0; + std::atomic_int m_pendingEncodeFrames = 0; + + // Controls how many frames we can push into ffmpeg's encoding stream + std::atomic_int m_maxPendingFrames = 50; + + Fraction m_maxFramerate = {60, 1}; + +Q_SIGNALS: + void producedFrames(); + +private: + void initFiltersVaapi(); + void initFiltersSoftware(); + std::unique_ptr makeEncoder(); +}; diff --git a/src/pipewirerecord.cpp b/src/pipewirerecord.cpp new file mode 100644 index 0000000..ddec3d8 --- /dev/null +++ b/src/pipewirerecord.cpp @@ -0,0 +1,207 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "pipewirerecord.h" +#include "encoder_p.h" +#include "glhelpers.h" +#include "pipewirerecord_p.h" +#include + +#include +#include +#include +#include + +#include + +#include +extern "C" { +#include +#include +#include +} + +#undef av_err2str + +#ifdef av_ts2str +#undef av_ts2str +char buf[AV_TS_MAX_STRING_SIZE]; +#define av_ts2str(ts) av_ts_make_string(buf, ts) +#endif // av_ts2str + +#ifdef av_ts2timestr +#undef av_ts2timestr +char timebuf[AV_TS_MAX_STRING_SIZE]; +#define av_ts2timestr(ts, tb) av_ts_make_time_string(timebuf, ts, tb) +#endif // av_ts2timestr + +static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt) +{ + AVRational *time_base = &fmt_ctx->streams[pkt->stream_index]->time_base; + + qCDebug(PIPEWIRERECORD_LOGGING, + "pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s " + "stream_index:%d", + av_ts2str(pkt->pts), + av_ts2timestr(pkt->pts, time_base), + av_ts2str(pkt->dts), + av_ts2timestr(pkt->dts, time_base), + av_ts2str(pkt->duration), + av_ts2timestr(pkt->duration, time_base), + pkt->stream_index); +} + +PipeWireRecord::PipeWireRecord(QObject *parent) + : PipeWireBaseEncodedStream(parent) + , d(new PipeWireRecordPrivate) +{ +} + +PipeWireRecord::~PipeWireRecord() = default; + +void PipeWireRecord::setOutput(const QString &_output) +{ + const QString output = KShell::tildeExpand(_output); + + if (d->m_output == output) + return; + + d->m_output = output; + refresh(); + Q_EMIT outputChanged(output); +} + +QString PipeWireRecord::output() const +{ + return d->m_output; +} + +QString PipeWireRecord::extension() const +{ + static QHash s_extensions = { + {PipeWireBaseEncodedStream::H264Main, QStringLiteral("mp4")}, + {PipeWireBaseEncodedStream::H264Baseline, QStringLiteral("mp4")}, + {PipeWireBaseEncodedStream::VP8, QStringLiteral("webm")}, + {PipeWireBaseEncodedStream::VP9, QStringLiteral("webm")}, + }; + return s_extensions.value(encoder()); +} + +PipeWireRecordProduce::PipeWireRecordProduce(PipeWireBaseEncodedStream::Encoder encoder, uint nodeId, uint fd, const Fraction &framerate, const QString &output) + : PipeWireProduce(encoder, nodeId, fd, framerate) + , m_output(output) +{ +} + +bool PipeWireRecordProduce::setupFormat() +{ + avformat_alloc_output_context2(&m_avFormatContext, nullptr, nullptr, m_output.toUtf8().constData()); + if (!m_avFormatContext) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not deduce output format from file: using WebM." << m_output; + avformat_alloc_output_context2(&m_avFormatContext, nullptr, "webm", m_output.toUtf8().constData()); + } + if (!m_avFormatContext) { + qCDebug(PIPEWIRERECORD_LOGGING) << "could not set stream up"; + return false; + } + + const Fraction framerate = m_stream->framerate(); + int ret = avio_open(&m_avFormatContext->pb, QFile::encodeName(m_output).constData(), AVIO_FLAG_WRITE); + if (ret < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not open" << m_output << av_err2str(ret); + return false; + } + + auto avStream = avformat_new_stream(m_avFormatContext, nullptr); + avStream->start_time = 0; + if (framerate) { + avStream->r_frame_rate.num = framerate.numerator; + avStream->r_frame_rate.den = framerate.denominator; + avStream->avg_frame_rate.num = framerate.numerator; + avStream->avg_frame_rate.den = framerate.denominator; + } + + ret = avcodec_parameters_from_context(avStream->codecpar, m_encoder->avCodecContext()); + if (ret < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Error occurred when passing the codec:" << av_err2str(ret); + return false; + } + + ret = avformat_write_header(m_avFormatContext, nullptr); + if (ret < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Error occurred when writing header:" << av_err2str(ret); + return false; + } + + return true; +} + +void PipeWireRecordProduce::processFrame(const PipeWireFrame &frame) +{ + PipeWireProduce::processFrame(frame); + if (frame.cursor && !frame.dmabuf && !frame.dataFrame && m_frameWithoutMetadataCursor.dataFrame) { + m_encoder->filterFrame(m_frameWithoutMetadataCursor); + } +} + +void PipeWireRecordProduce::aboutToEncode(PipeWireFrame &frame) +{ + if (!frame.dataFrame) { + return; + } + + if (m_cursor.position && !m_cursor.texture.isNull()) { + auto image = frame.dataFrame->toImage(); + // Do not copy the image if it's already ours + if (m_frameWithoutMetadataCursor.dataFrame->cleanup != frame.dataFrame->cleanup) { + m_frameWithoutMetadataCursor.dataFrame = frame.dataFrame->copy(); + } + QPainter p(&image); + p.drawImage(*m_cursor.position, m_cursor.texture); + } +} + +void PipeWireRecordProduce::processPacket(AVPacket *packet) +{ + packet->stream_index = (*m_avFormatContext->streams)->index; + av_packet_rescale_ts(packet, m_encoder->avCodecContext()->time_base, (*m_avFormatContext->streams)->time_base); + log_packet(m_avFormatContext, packet); + auto ret = av_interleaved_write_frame(m_avFormatContext, packet); + if (ret < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Error while writing output packet:" << av_err2str(ret); + } +} + +std::unique_ptr PipeWireRecord::makeProduce() +{ + return std::make_unique(encoder(), nodeId(), fd(), maxFramerate(), d->m_output); +} + +int64_t PipeWireRecordProduce::framePts(const std::optional &presentationTimestamp) +{ + const auto current = std::chrono::duration_cast(*presentationTimestamp).count(); + if ((*m_avFormatContext->streams)->start_time == 0) { + (*m_avFormatContext->streams)->start_time = current; + } + + return current - (*m_avFormatContext->streams)->start_time; +} + +void PipeWireRecordProduce::cleanup() +{ + if (m_avFormatContext) { + if (auto result = av_write_trailer(m_avFormatContext); result < 0) { + qCWarning(PIPEWIRERECORD_LOGGING) << "Could not write trailer"; + } + + avio_closep(&m_avFormatContext->pb); + avformat_free_context(m_avFormatContext); + } +} + +#include "moc_pipewirerecord.cpp" + +#include "moc_pipewirerecord_p.cpp" diff --git a/src/pipewirerecord.h b/src/pipewirerecord.h new file mode 100644 index 0000000..190a8e5 --- /dev/null +++ b/src/pipewirerecord.h @@ -0,0 +1,42 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include + +#include "pipewirebaseencodedstream.h" +#include + +struct PipeWireRecordPrivate; + +class KPIPEWIRE_EXPORT PipeWireRecord : public PipeWireBaseEncodedStream +{ + Q_OBJECT + Q_PROPERTY(QString output READ output WRITE setOutput NOTIFY outputChanged) + Q_PROPERTY(QString extension READ extension NOTIFY encoderChanged) +public: + PipeWireRecord(QObject *parent = nullptr); + ~PipeWireRecord() override; + + QString output() const; + void setOutput(const QString &output); + QString extension() const; + + // Only for compatibility with 5.27 + KPIPEWIRE_DEPRECATED QString currentExtension() const + { + return extension(); + } + +Q_SIGNALS: + void outputChanged(const QString &output); + +private: + std::unique_ptr makeProduce() override; + + QScopedPointer d; +}; diff --git a/src/pipewirerecord_p.h b/src/pipewirerecord_p.h new file mode 100644 index 0000000..cf0227a --- /dev/null +++ b/src/pipewirerecord_p.h @@ -0,0 +1,36 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once +#include "pipewireproduce_p.h" +#include + +struct gbm_device; +struct AVFormatContext; +class PipeWireProduce; + +class PipeWireRecordProduce : public PipeWireProduce +{ + Q_OBJECT +public: + PipeWireRecordProduce(PipeWireBaseEncodedStream::Encoder encoder, uint nodeId, uint fd, const Fraction &framerate, const QString &output); + + void processFrame(const PipeWireFrame &frame) override; + void processPacket(AVPacket *packet) override; + int64_t framePts(const std::optional &presentationTimestamp) override; + void aboutToEncode(PipeWireFrame &frame) override; + bool setupFormat() override; + void cleanup() override; + +private: + const QString m_output; + AVFormatContext *m_avFormatContext = nullptr; + PipeWireFrame m_frameWithoutMetadataCursor; +}; + +struct PipeWireRecordPrivate { + QString m_output; +}; diff --git a/src/pipewiresourceitem.cpp b/src/pipewiresourceitem.cpp new file mode 100644 index 0000000..9f540e7 --- /dev/null +++ b/src/pipewiresourceitem.cpp @@ -0,0 +1,487 @@ +/* + Render a PipeWire stream into a QtQuick scene as a standard Item + SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "pipewiresourceitem.h" +#include "glhelpers.h" +#include "logging.h" +#include "pipewiresourcestream.h" +#include "pwhelpers.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +static void pwInit() +{ + pw_init(nullptr, nullptr); +} +Q_COREAPP_STARTUP_FUNCTION(pwInit); + +class PipeWireSourceItemPrivate +{ +public: + uint m_nodeId = 0; + std::optional m_fd; + std::function m_createNextTexture; + std::unique_ptr m_stream; + std::unique_ptr m_texture; + + EGLImage m_image = nullptr; + bool m_needsRecreateTexture = false; + bool m_allowDmaBuf = true; + bool m_ready = false; + + struct { + QImage texture; + std::optional position; + QPoint hotspot; + bool dirty = false; + } m_cursor; + std::optional m_damage; +}; + +class DiscardEglPixmapRunnable : public QRunnable +{ +public: + DiscardEglPixmapRunnable(EGLImageKHR image, QOpenGLTexture *texture) + : m_image(image) + , m_texture(texture) + { + } + + void run() override + { + if (m_image != EGL_NO_IMAGE_KHR) { + eglDestroyImageKHR(eglGetCurrentDisplay(), m_image); + } + + delete m_texture; + } + +private: + const EGLImageKHR m_image; + QOpenGLTexture *m_texture; +}; + +PipeWireSourceItem::PipeWireSourceItem(QQuickItem *parent) + : QQuickItem(parent) + , d(new PipeWireSourceItemPrivate) +{ + setFlag(ItemHasContents, true); +} + +PipeWireSourceItem::~PipeWireSourceItem() +{ + if (d->m_fd) { + close(*d->m_fd); + } +} + +void PipeWireSourceItem::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) +{ + switch (change) { + case ItemVisibleHasChanged: + if (!isVisible()) { + setReady(false); + } + if (d->m_stream) { + d->m_stream->setActive(isVisible()); + } + break; + case ItemSceneChange: + d->m_needsRecreateTexture = true; + releaseResources(); + break; + default: + break; + } + + QQuickItem::itemChange(change, data); +} + +void PipeWireSourceItem::releaseResources() +{ + if (window() && (d->m_image || d->m_texture)) { + window()->scheduleRenderJob(new DiscardEglPixmapRunnable(d->m_image, d->m_texture.release()), QQuickWindow::NoStage); + d->m_image = EGL_NO_IMAGE_KHR; + } +} + +void PipeWireSourceItem::setFd(uint fd) +{ + if (fd == d->m_fd) + return; + + if (d->m_fd) { + close(*d->m_fd); + } + d->m_fd = fd; + refresh(); + Q_EMIT fdChanged(fd); +} + +void PipeWireSourceItem::resetFd() +{ + if (!d->m_fd.has_value()) { + return; + } + + setReady(false); + close(*d->m_fd); + d->m_fd.reset(); + d->m_stream.reset(nullptr); + d->m_createNextTexture = [] { + return nullptr; + }; + Q_EMIT streamSizeChanged(); +} + +void PipeWireSourceItem::refresh() +{ + setReady(false); + + if (!isComponentComplete()) { + return; + } + + if (d->m_nodeId == 0) { + releaseResources(); + d->m_stream.reset(nullptr); + Q_EMIT streamSizeChanged(); + + d->m_createNextTexture = [] { + return nullptr; + }; + } else { + d->m_stream.reset(new PipeWireSourceStream(this)); + d->m_stream->setAllowDmaBuf(d->m_allowDmaBuf); + Q_EMIT streamSizeChanged(); + connect(d->m_stream.get(), &PipeWireSourceStream::streamParametersChanged, this, &PipeWireSourceItem::streamSizeChanged); + connect(d->m_stream.get(), &PipeWireSourceStream::streamParametersChanged, this, &PipeWireSourceItem::usingDmaBufChanged); + + d->m_stream->createStream(d->m_nodeId, d->m_fd.value_or(0)); + if (!d->m_stream->error().isEmpty()) { + d->m_stream.reset(nullptr); + d->m_nodeId = 0; + return; + } + d->m_stream->setActive(isVisible()); + + connect(d->m_stream.get(), &PipeWireSourceStream::frameReceived, this, &PipeWireSourceItem::processFrame); + connect(d->m_stream.get(), &PipeWireSourceStream::stateChanged, this, &PipeWireSourceItem::stateChanged); + } + Q_EMIT stateChanged(); +} + +void PipeWireSourceItem::setNodeId(uint nodeId) +{ + if (nodeId == d->m_nodeId) + return; + + d->m_nodeId = nodeId; + refresh(); + Q_EMIT nodeIdChanged(nodeId); +} + +class PipeWireRenderNode : public QSGNode +{ +public: + QSGImageNode *screenNode(QQuickWindow *window) + { + if (!m_screenNode) { + m_screenNode = window->createImageNode(); + appendChildNode(m_screenNode); + } + return m_screenNode; + } + QSGImageNode *cursorNode(QQuickWindow *window) + { + if (!m_cursorNode) { + m_cursorNode = window->createImageNode(); + appendChildNode(m_cursorNode); + } + return m_cursorNode; + } + + QSGImageNode *damageNode(QQuickWindow *window) + { + if (!m_damageNode) { + m_damageNode = window->createImageNode(); + appendChildNode(m_damageNode); + } + return m_damageNode; + } + + void discardCursor() + { + if (m_cursorNode) { + removeChildNode(m_cursorNode); + delete m_cursorNode; + m_cursorNode = nullptr; + } + } + + void discardDamage() + { + if (m_damageNode) { + removeChildNode(m_damageNode); + delete m_damageNode; + m_damageNode = nullptr; + } + } + +private: + QSGImageNode *m_screenNode = nullptr; + QSGImageNode *m_cursorNode = nullptr; + QSGImageNode *m_damageNode = nullptr; +}; + +QSGNode *PipeWireSourceItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *) +{ + if (Q_UNLIKELY(!d->m_createNextTexture)) { + return node; + } + + auto texture = d->m_createNextTexture(); + if (!texture) { + delete node; + return nullptr; + } + + auto pwNode = static_cast(node); + if (!pwNode) { + pwNode = new PipeWireRenderNode; + } + + QSGImageNode *screenNode = pwNode->screenNode(window()); + screenNode->setTexture(texture); + screenNode->setOwnsTexture(true); + + const auto br = boundingRect().toRect(); + QRect rect({0, 0}, texture->textureSize().scaled(br.size(), Qt::KeepAspectRatio)); + rect.moveCenter(br.center()); + screenNode->setRect(rect); + + if (!d->m_cursor.position.has_value() || d->m_cursor.texture.isNull()) { + pwNode->discardCursor(); + } else { + QSGImageNode *cursorNode = pwNode->cursorNode(window()); + if (d->m_cursor.dirty || !cursorNode->texture()) { + cursorNode->setTexture(window()->createTextureFromImage(d->m_cursor.texture)); + cursorNode->setOwnsTexture(true); + d->m_cursor.dirty = false; + } + const qreal scale = qreal(rect.width()) / texture->textureSize().width(); + cursorNode->setRect(QRectF{rect.topLeft() + (d->m_cursor.position.value() * scale), d->m_cursor.texture.size() * scale}); + Q_ASSERT(cursorNode->texture()); + } + + if (!d->m_damage || d->m_damage->isEmpty()) { + pwNode->discardDamage(); + } else { + auto *damageNode = pwNode->damageNode(window()); + QImage damageImage(texture->textureSize(), QImage::Format_RGBA64_Premultiplied); + damageImage.fill(Qt::transparent); + QPainter p(&damageImage); + p.setBrush(Qt::red); + for (auto rect : *d->m_damage) { + p.drawRect(rect); + } + damageNode->setTexture(window()->createTextureFromImage(damageImage)); + damageNode->setOwnsTexture(true); + damageNode->setRect(rect); + Q_ASSERT(damageNode->texture()); + } + return pwNode; +} + +QString PipeWireSourceItem::error() const +{ + return d->m_stream->error(); +} + +void PipeWireSourceItem::processFrame(const PipeWireFrame &frame) +{ + d->m_damage = frame.damage; + + if (frame.cursor) { + d->m_cursor.position = frame.cursor->position; + d->m_cursor.hotspot = frame.cursor->hotspot; + if (!frame.cursor->texture.isNull()) { + d->m_cursor.dirty = true; + d->m_cursor.texture = frame.cursor->texture; + } + } else { + d->m_cursor.position = std::nullopt; + d->m_cursor.hotspot = {}; + } + + if (frame.dmabuf) { + updateTextureDmaBuf(*frame.dmabuf, frame.format); + } else if (frame.dataFrame) { + updateTextureImage(frame.dataFrame); + } + + if (window() && window()->isVisible()) { + update(); + } +} + +void PipeWireSourceItem::updateTextureDmaBuf(const DmaBufAttributes &attribs, spa_video_format format) +{ + if (!window()) { + qCWarning(PIPEWIRE_LOGGING) << "Window not available" << this; + return; + } + + const auto openglContext = static_cast(window()->rendererInterface()->getResource(window(), QSGRendererInterface::OpenGLContextResource)); + if (!openglContext || !d->m_stream) { + qCWarning(PIPEWIRE_LOGGING) << "need a window and a context" << window(); + return; + } + + d->m_createNextTexture = [this, format, attribs]() -> QSGTexture * { + const EGLDisplay display = static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("egldisplay")); + if (d->m_image) { + eglDestroyImageKHR(display, d->m_image); + } + const auto size = d->m_stream->size(); + d->m_image = GLHelpers::createImage(display, attribs, PipeWireSourceStream::spaVideoFormatToDrmFormat(format), size, nullptr); + if (d->m_image == EGL_NO_IMAGE_KHR) { + d->m_stream->renegotiateModifierFailed(format, attribs.modifier); + return nullptr; + } + if (!d->m_texture) { + d->m_texture.reset(new QOpenGLTexture(QOpenGLTexture::Target2D)); + bool created = d->m_texture->create(); + Q_ASSERT(created); + } + + GLHelpers::initDebugOutput(); + d->m_texture->bind(); + + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)d->m_image); + + d->m_texture->setWrapMode(QOpenGLTexture::ClampToEdge); + d->m_texture->setMinMagFilters(QOpenGLTexture::Linear, QOpenGLTexture::Linear); + d->m_texture->release(); + d->m_texture->setSize(size.width(), size.height()); + + int textureId = d->m_texture->textureId(); + QQuickWindow::CreateTextureOption textureOption = + format == SPA_VIDEO_FORMAT_ARGB || format == SPA_VIDEO_FORMAT_BGRA ? QQuickWindow::TextureHasAlphaChannel : QQuickWindow::TextureIsOpaque; + return QNativeInterface::QSGOpenGLTexture::fromNative(textureId, window(), size, textureOption); + }; + + setReady(true); +} + +void PipeWireSourceItem::updateTextureImage(const std::shared_ptr &data) +{ + if (!window()) { + qCWarning(PIPEWIRE_LOGGING) << "pass"; + return; + } + + d->m_createNextTexture = [this, data] { + return window()->createTextureFromImage(data->toImage(), QQuickWindow::TextureIsOpaque); + }; + + setReady(true); +} + +void PipeWireSourceItem::componentComplete() +{ + QQuickItem::componentComplete(); + if (d->m_nodeId != 0) { + refresh(); + } +} + +PipeWireSourceItem::StreamState PipeWireSourceItem::state() const +{ + if (!d->m_stream) { + return StreamState::Unconnected; + } + switch (d->m_stream->state()) { + case PW_STREAM_STATE_ERROR: + return StreamState::Error; + case PW_STREAM_STATE_UNCONNECTED: + return StreamState::Unconnected; + case PW_STREAM_STATE_CONNECTING: + return StreamState::Connecting; + case PW_STREAM_STATE_PAUSED: + return StreamState::Paused; + case PW_STREAM_STATE_STREAMING: + return StreamState::Streaming; + default: + return StreamState::Error; + } +} + +uint PipeWireSourceItem::fd() const +{ + return d->m_fd.value_or(0); +} + +uint PipeWireSourceItem::nodeId() const +{ + return d->m_nodeId; +} + +QSize PipeWireSourceItem::streamSize() const +{ + if (!d->m_stream) { + return QSize(); + } + return d->m_stream->size(); +} + +bool PipeWireSourceItem::usingDmaBuf() const +{ + return d->m_stream && d->m_stream->usingDmaBuf(); +} + +bool PipeWireSourceItem::allowDmaBuf() const +{ + return d->m_stream && d->m_stream->allowDmaBuf(); +} + +void PipeWireSourceItem::setAllowDmaBuf(bool allowed) +{ + d->m_allowDmaBuf = allowed; + if (d->m_stream) { + d->m_stream->setAllowDmaBuf(allowed); + } +} + +void PipeWireSourceItem::setReady(bool ready) +{ + if (d->m_ready != ready) { + d->m_ready = ready; + Q_EMIT readyChanged(); + } +} + +bool PipeWireSourceItem::isReady() const +{ + return d->m_ready; +} + +#include "moc_pipewiresourceitem.cpp" diff --git a/src/pipewiresourceitem.h b/src/pipewiresourceitem.h new file mode 100644 index 0000000..962581e --- /dev/null +++ b/src/pipewiresourceitem.h @@ -0,0 +1,114 @@ +/* + Render a PipeWire stream into a QtQuick scene as a standard Item + SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +struct DmaBufAttributes; +class PipeWireSourceStream; +struct PipeWireFrame; +class PipeWireFrameData; +class QSGTexture; +class QOpenGLTexture; +typedef void *EGLImage; + +class PipeWireSourceItemPrivate; + +class KPIPEWIRE_EXPORT PipeWireSourceItem : public QQuickItem +{ + Q_OBJECT + + /// Returns where the streams current state + Q_PROPERTY(StreamState state READ state NOTIFY stateChanged) + + /// Specify the pipewire node id that we want to play + Q_PROPERTY(uint nodeId READ nodeId WRITE setNodeId NOTIFY nodeIdChanged) + + /** + * Specifies the file descriptor we are connected to, if none 0 will be returned + * + * Transfers the ownership of the fd, will close it when it's done with it. + */ + Q_PROPERTY(uint fd READ fd WRITE setFd NOTIFY fdChanged RESET resetFd) + + /** + * Returns the size of the source being rendered + * @note: This won't be updated until the first frame is recieved + */ + Q_PROPERTY(QSize streamSize READ streamSize NOTIFY streamSizeChanged) + + /** + * Allows disabling the dmabuf streams + */ + Q_PROPERTY(bool allowDmaBuf READ allowDmaBuf WRITE setAllowDmaBuf) + + Q_PROPERTY(bool usingDmaBuf READ usingDmaBuf NOTIFY usingDmaBufChanged) + + /** + * Specifies whether the first frame has been received and there's something to display. + */ + Q_PROPERTY(bool ready READ isReady NOTIFY readyChanged) + +public: + enum class StreamState { Error, Unconnected, Connecting, Paused, Streaming }; + Q_ENUM(StreamState); + + PipeWireSourceItem(QQuickItem *parent = nullptr); + ~PipeWireSourceItem() override; + + QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *data) override; + Q_SCRIPTABLE QString error() const; + + void setNodeId(uint nodeId); + uint nodeId() const; + + void setFd(uint fd); + void resetFd(); + uint fd() const; + + QSize streamSize() const; + + bool usingDmaBuf() const; + bool allowDmaBuf() const; + void setAllowDmaBuf(bool allowed); + + bool isReady() const; + + void componentComplete() override; + void releaseResources() override; + + StreamState state() const; + +Q_SIGNALS: + void nodeIdChanged(uint nodeId); + void fdChanged(uint fd); + void streamSizeChanged(); + void stateChanged(); + void usingDmaBufChanged(); + void readyChanged(); + +private: + void itemChange(ItemChange change, const ItemChangeData &data) override; + void processFrame(const PipeWireFrame &frame); + void updateTextureDmaBuf(const DmaBufAttributes &attribs, spa_video_format format); + void updateTextureImage(const std::shared_ptr &data); + void refresh(); + void setReady(bool ready); + + QScopedPointer d; +}; diff --git a/src/pipewiresourcestream.cpp b/src/pipewiresourcestream.cpp new file mode 100644 index 0000000..3da6c2a --- /dev/null +++ b/src/pipewiresourcestream.cpp @@ -0,0 +1,743 @@ +/* + SPDX-FileCopyrightText: 2018-2020 Red Hat Inc + SPDX-FileCopyrightText: 2020-2021 Aleix Pol Gonzalez + SPDX-FileContributor: Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "pipewiresourcestream.h" +#include "glhelpers.h" +#include "logging.h" +#include "pipewirecore_p.h" +#include "pwhelpers.h" +#include "vaapiutils_p.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#undef Status + +#if !PW_CHECK_VERSION(0, 3, 29) +#define SPA_POD_PROP_FLAG_MANDATORY (1u << 3) +#endif +#if !PW_CHECK_VERSION(0, 3, 33) +#define SPA_POD_PROP_FLAG_DONT_FIXATE (1u << 4) +#endif + +#define CURSOR_BPP 4 +#define CURSOR_META_SIZE(w, h) (sizeof(struct spa_meta_cursor) + sizeof(struct spa_meta_bitmap) + w * h * CURSOR_BPP) + +pw_stream_events pwStreamEvents = {}; + +struct PipeWireSourceStreamPrivate +{ + QSharedPointer pwCore; + pw_stream *pwStream = nullptr; + spa_hook streamListener; + + uint32_t pwNodeId = 0; + std::optional m_currentPresentationTimestamp; + + QAtomicInt m_stopped = false; + pw_stream_state m_state = PW_STREAM_STATE_UNCONNECTED; + + spa_video_info_raw videoFormat; + QString m_error; + bool m_allowDmaBuf = true; + bool m_usingDmaBuf = false; + + QHash> m_availableModifiers; + spa_source *m_renegotiateEvent = nullptr; + + bool m_withDamage = false; + Fraction maxFramerate; + + PipeWireSourceStream::UsageHint usageHint = PipeWireSourceStream::UsageHint::Render; +}; + +static const QVersionNumber pwClientVersion = QVersionNumber::fromString(QString::fromUtf8(pw_get_library_version())); +static const QVersionNumber kDmaBufMinVersion = {0, 3, 24}; +static const QVersionNumber kDmaBufModifierMinVersion = {0, 3, 33}; +static const QVersionNumber kDropSingleModifierMinVersion = {0, 3, 40}; + +uint32_t PipeWireSourceStream::spaVideoFormatToDrmFormat(spa_video_format spa_format) +{ + switch (spa_format) { + case SPA_VIDEO_FORMAT_RGBA: + return DRM_FORMAT_ABGR8888; + case SPA_VIDEO_FORMAT_RGBx: + return DRM_FORMAT_XBGR8888; + case SPA_VIDEO_FORMAT_BGRA: + return DRM_FORMAT_ARGB8888; + case SPA_VIDEO_FORMAT_BGRx: + return DRM_FORMAT_XRGB8888; + case SPA_VIDEO_FORMAT_BGR: + return DRM_FORMAT_BGR888; + case SPA_VIDEO_FORMAT_RGB: + return DRM_FORMAT_RGB888; + case SPA_VIDEO_FORMAT_xBGR: + return DRM_FORMAT_RGBX8888; + case SPA_VIDEO_FORMAT_ABGR: + return DRM_FORMAT_RGBA8888; + case SPA_VIDEO_FORMAT_GRAY8: + return DRM_FORMAT_R8; + default: + qCWarning(PIPEWIRE_LOGGING) << "cannot convert spa format to fourcc" << spa_format; + return DRM_FORMAT_INVALID; + } +} + +static QString drmFormatName(uint32_t format) +{ + return QString::asprintf("%c%c%c%c %s-endian (0x%08x)", + QLatin1Char(format & 0xff).toLatin1(), + QLatin1Char((format >> 8) & 0xff).toLatin1(), + QLatin1Char((format >> 16) & 0xff).toLatin1(), + QLatin1Char((format >> 24) & 0x7f).toLatin1(), + format & DRM_FORMAT_BIG_ENDIAN ? "big" : "little", + format); +} + +spa_video_format drmFormatToSpaVideoFormat(uint32_t drm_format) +{ + switch (drm_format) { + case DRM_FORMAT_ABGR8888: + return SPA_VIDEO_FORMAT_RGBA; + case DRM_FORMAT_XBGR8888: + return SPA_VIDEO_FORMAT_RGBx; + case DRM_FORMAT_ARGB8888: + return SPA_VIDEO_FORMAT_BGRA; + case DRM_FORMAT_XRGB8888: + return SPA_VIDEO_FORMAT_BGRx; + case DRM_FORMAT_BGR888: + return SPA_VIDEO_FORMAT_BGR; + case DRM_FORMAT_RGB888: + return SPA_VIDEO_FORMAT_RGB; + case DRM_FORMAT_YUYV: + return SPA_VIDEO_FORMAT_YUY2; + case DRM_FORMAT_R8: + return SPA_VIDEO_FORMAT_GRAY8; + default: + qCWarning(PIPEWIRE_LOGGING) << "cannot convert drm format to spa" << drmFormatName(drm_format); + return SPA_VIDEO_FORMAT_UNKNOWN; + } +} + +static QHash> queryDmaBufModifiers(EGLDisplay display, const QList &formats, PipeWireSourceStream::UsageHint usageHint) +{ + QHash> ret; + ret.reserve(formats.size()); + const bool hasEglImageDmaBufImportExt = epoxy_has_egl_extension(display, "EGL_EXT_image_dma_buf_import"); + static auto eglQueryDmaBufModifiersEXT = (PFNEGLQUERYDMABUFMODIFIERSEXTPROC)eglGetProcAddress("eglQueryDmaBufModifiersEXT"); + static auto eglQueryDmaBufFormatsEXT = (PFNEGLQUERYDMABUFFORMATSEXTPROC)eglGetProcAddress("eglQueryDmaBufFormatsEXT"); + + EGLint count = 0; + EGLBoolean successFormats = eglQueryDmaBufFormatsEXT(display, 0, nullptr, &count); + + QList drmFormats(count); + successFormats &= eglQueryDmaBufFormatsEXT(display, count, reinterpret_cast(drmFormats.data()), &count); + if (!successFormats) + qCWarning(PIPEWIRE_LOGGING) << "Failed to query DMA-BUF formats."; + + const QList mods = hasEglImageDmaBufImportExt ? QList{DRM_FORMAT_MOD_INVALID} : QList{}; + if (!eglQueryDmaBufFormatsEXT || !eglQueryDmaBufModifiersEXT || !hasEglImageDmaBufImportExt || !successFormats) { + for (spa_video_format format : formats) { + ret[format] = mods; + } + return ret; + } + + for (spa_video_format format : formats) { + uint32_t drm_format = PipeWireSourceStream::spaVideoFormatToDrmFormat(format); + if (drm_format == DRM_FORMAT_INVALID) { + qCDebug(PIPEWIRE_LOGGING) << "Failed to find matching DRM format." << format; + continue; + } + + if (std::find(drmFormats.begin(), drmFormats.end(), drm_format) == drmFormats.end()) { + qCDebug(PIPEWIRE_LOGGING) << "Format " << drmFormatName(drm_format) << " not supported for modifiers."; + ret[format] = mods; + continue; + } + + successFormats = eglQueryDmaBufModifiersEXT(display, drm_format, 0, nullptr, nullptr, &count); + if (!successFormats) { + qCWarning(PIPEWIRE_LOGGING) << "Failed to query DMA-BUF modifier count."; + ret[format] = mods; + continue; + } + + QList queriedModifiers(count); + QList externalOnly(count); + if (count > 0) { + if (!eglQueryDmaBufModifiersEXT(display, drm_format, count, queriedModifiers.data(), externalOnly.data(), &count)) { + qCWarning(PIPEWIRE_LOGGING) << "Failed to query DMA-BUF modifiers."; + } + } + + QList usableModifiers; + usableModifiers.reserve(count + 1); + if (usageHint == PipeWireSourceStream::UsageHint::EncodeHardware) { + auto vaapi = VaapiUtils::instance(); + for (int i = 0; i < queriedModifiers.size(); ++i) { + if (externalOnly[i]) { + continue; + } + const uint64_t modifier = queriedModifiers[i]; + if (vaapi->supportsModifier(drm_format, modifier)) { + usableModifiers.append(modifier); + } + } + } else { + for (int i = 0; i < queriedModifiers.size(); ++i) { + if (!externalOnly[i]) { + usableModifiers.append(queriedModifiers[i]); + } + } + } + + if (!usableModifiers.isEmpty()) { + // Support modifier-less buffers + usableModifiers.push_back(DRM_FORMAT_MOD_INVALID); + } + + ret[format] = usableModifiers; + } + return ret; +} + +void PipeWireSourceStream::onStreamStateChanged(void *data, pw_stream_state old, pw_stream_state state, const char *error_message) +{ + PipeWireSourceStream *pw = static_cast(data); + qCDebug(PIPEWIRE_LOGGING) << "state changed" << pw_stream_state_as_string(old) << "->" << pw_stream_state_as_string(state) << error_message; + pw->d->m_state = state; + Q_EMIT pw->stateChanged(state, old); + + switch (state) { + case PW_STREAM_STATE_ERROR: + qCWarning(PIPEWIRE_LOGGING) << "Stream error: " << error_message; + break; + case PW_STREAM_STATE_PAUSED: + Q_EMIT pw->streamReady(); + break; + case PW_STREAM_STATE_STREAMING: + Q_EMIT pw->startStreaming(); + break; + case PW_STREAM_STATE_CONNECTING: + break; + case PW_STREAM_STATE_UNCONNECTED: + if (!pw->d->m_stopped) { + Q_EMIT pw->stopStreaming(); + } + break; + } +} + +void PipeWireSourceStream::onRenegotiate(void *data, uint64_t) +{ + PipeWireSourceStream *pw = static_cast(data); + uint8_t buffer[4096]; + spa_pod_builder podBuilder = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); + auto params = pw->createFormatsParams(podBuilder); + pw_stream_update_params(pw->d->pwStream, params.data(), params.size()); +} + +void PipeWireSourceStream::renegotiateModifierFailed(spa_video_format format, quint64 modifier) +{ + if (d->pwCore->serverVersion() >= kDropSingleModifierMinVersion) { + const int removed = d->m_availableModifiers[format].removeAll(modifier); + if (removed == 0) { + d->m_allowDmaBuf = false; + } + } else { + d->m_allowDmaBuf = false; + } + qCDebug(PIPEWIRE_LOGGING) << "renegotiating, modifier didn't work" << format << modifier << "now only offering" << d->m_availableModifiers[format].count(); + pw_loop_signal_event(d->pwCore->loop(), d->m_renegotiateEvent); +} + +static spa_pod * +buildFormat(spa_pod_builder *builder, spa_video_format format, const QList &modifiers, bool withDontFixate, const Fraction &requestedMaxFramerate) +{ + spa_pod_frame f[2]; + const spa_rectangle pw_min_screen_bounds{1, 1}; + const spa_rectangle pw_max_screen_bounds{UINT32_MAX, UINT32_MAX}; + + spa_pod_builder_push_object(builder, &f[0], SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat); + spa_pod_builder_add(builder, SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video), 0); + spa_pod_builder_add(builder, SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw), 0); + spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_format, SPA_POD_Id(format), 0); + spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_size, SPA_POD_CHOICE_RANGE_Rectangle(&pw_min_screen_bounds, &pw_min_screen_bounds, &pw_max_screen_bounds), 0); + if (requestedMaxFramerate) { + auto defFramerate = SPA_FRACTION(0, 1); + auto minFramerate = SPA_FRACTION(1, 1); + auto maxFramerate = SPA_FRACTION(requestedMaxFramerate.numerator, requestedMaxFramerate.denominator); + spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction(&defFramerate), 0); + spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction(&maxFramerate, &minFramerate, &maxFramerate), 0); + } else { + auto defFramerate = SPA_FRACTION(0, 1); + auto maxFramerate = SPA_FRACTION(1200, 1); + spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_framerate, SPA_POD_CHOICE_RANGE_Fraction(&defFramerate, &defFramerate, &maxFramerate), 0); + } + + if (!modifiers.isEmpty()) { + // SPA_POD_PROP_FLAG_DONT_FIXATE can be used with PipeWire >= 0.3.33 + if (withDontFixate) { + spa_pod_builder_prop(builder, SPA_FORMAT_VIDEO_modifier, SPA_POD_PROP_FLAG_MANDATORY | SPA_POD_PROP_FLAG_DONT_FIXATE); + } else { + spa_pod_builder_prop(builder, SPA_FORMAT_VIDEO_modifier, SPA_POD_PROP_FLAG_MANDATORY); + } + spa_pod_builder_push_choice(builder, &f[1], SPA_CHOICE_Enum, 0); + // mofifiers from the array + for (auto it = modifiers.begin(); it != modifiers.end(); it++) { + spa_pod_builder_long(builder, *it); + if (it == modifiers.begin()) { + spa_pod_builder_long(builder, *it); + } + } + spa_pod_builder_pop(builder, &f[1]); + } + + return static_cast(spa_pod_builder_pop(builder, &f[0])); +} + +static const int videoDamageRegionCount = 16; + +void PipeWireSourceStream::onStreamParamChanged(void *data, uint32_t id, const struct spa_pod *format) +{ + if (!format || id != SPA_PARAM_Format) { + return; + } + + PipeWireSourceStream *pw = static_cast(data); + spa_format_video_raw_parse(format, &pw->d->videoFormat); + + uint8_t paramsBuffer[1024]; + spa_pod_builder pod_builder = SPA_POD_BUILDER_INIT(paramsBuffer, sizeof(paramsBuffer)); + + // When SPA_FORMAT_VIDEO_modifier is present we can use DMA-BUFs as + // the server announces support for it. + // See https://github.com/PipeWire/pipewire/blob/master/doc/dma-buf.dox + + pw->d->m_usingDmaBuf = pw->d->m_allowDmaBuf && spa_pod_find_prop(format, nullptr, SPA_FORMAT_VIDEO_modifier); + Q_ASSERT(pw->d->m_allowDmaBuf || !pw->d->m_usingDmaBuf); + const auto bufferTypes = + pw->d->m_usingDmaBuf ? (1 << SPA_DATA_DmaBuf) | (1 << SPA_DATA_MemFd) | (1 << SPA_DATA_MemPtr) : (1 << SPA_DATA_MemFd) | (1 << SPA_DATA_MemPtr); + + QVarLengthArray params = { + (spa_pod *)spa_pod_builder_add_object(&pod_builder, + SPA_TYPE_OBJECT_ParamBuffers, + SPA_PARAM_Buffers, + SPA_PARAM_BUFFERS_buffers, + SPA_POD_CHOICE_RANGE_Int(3, 2, 16), + SPA_PARAM_BUFFERS_align, + SPA_POD_Int(16), + SPA_PARAM_BUFFERS_dataType, + SPA_POD_CHOICE_FLAGS_Int(bufferTypes)), + (spa_pod *)spa_pod_builder_add_object(&pod_builder, + SPA_TYPE_OBJECT_ParamMeta, + SPA_PARAM_Meta, + SPA_PARAM_META_type, + SPA_POD_Id(SPA_META_Header), + SPA_PARAM_META_size, + SPA_POD_Int(sizeof(struct spa_meta_header))), + (spa_pod *)spa_pod_builder_add_object(&pod_builder, + SPA_TYPE_OBJECT_ParamMeta, + SPA_PARAM_Meta, + SPA_PARAM_META_type, + SPA_POD_Id(SPA_META_Cursor), + SPA_PARAM_META_size, + SPA_POD_CHOICE_RANGE_Int(CURSOR_META_SIZE(64, 64), CURSOR_META_SIZE(1, 1), CURSOR_META_SIZE(1024, 1024))), + }; + + if (pw->d->m_withDamage) { + params.append((spa_pod *)spa_pod_builder_add_object(&pod_builder, + SPA_TYPE_OBJECT_ParamMeta, + SPA_PARAM_Meta, + SPA_PARAM_META_type, + SPA_POD_Id(SPA_META_VideoDamage), + SPA_PARAM_META_size, + SPA_POD_CHOICE_RANGE_Int(sizeof(struct spa_meta_region) * videoDamageRegionCount, + sizeof(struct spa_meta_region) * 1, + sizeof(struct spa_meta_region) * videoDamageRegionCount))); + } + + pw_stream_update_params(pw->d->pwStream, params.data(), params.count()); + Q_EMIT pw->streamParametersChanged(); +} + +static void onProcess(void *data) +{ + PipeWireSourceStream *stream = static_cast(data); + stream->process(); +} + +PipeWireFrameData::PipeWireFrameData(spa_video_format format, void *data, QSize size, qint32 stride, PipeWireFrameCleanupFunction *cleanup) + : format(format) + , data(data) + , size(size) + , stride(stride) + , cleanup(cleanup) +{ + cleanup->ref(); +} + +PipeWireFrameData::~PipeWireFrameData() +{ + PipeWireFrameCleanupFunction::unref(cleanup); +} + +QSize PipeWireSourceStream::size() const +{ + return QSize(d->videoFormat.size.width, d->videoFormat.size.height); +} + +pw_stream_state PipeWireSourceStream::state() const +{ + return d->m_state; +} + +std::optional< std::chrono::nanoseconds > PipeWireSourceStream::currentPresentationTimestamp() const +{ + return d->m_currentPresentationTimestamp; +} + +QString PipeWireSourceStream::error() const +{ + return d->m_error; +} + +PipeWireSourceStream::PipeWireSourceStream(QObject *parent) + : QObject(parent) + , d(new PipeWireSourceStreamPrivate) +{ + pwStreamEvents.version = PW_VERSION_STREAM_EVENTS; + pwStreamEvents.process = &onProcess; + pwStreamEvents.state_changed = &PipeWireSourceStream::onStreamStateChanged; + pwStreamEvents.param_changed = &PipeWireSourceStream::onStreamParamChanged; + pwStreamEvents.destroy = &PipeWireSourceStream::onDestroy; +} + +PipeWireSourceStream::~PipeWireSourceStream() +{ + d->m_stopped = true; + if (d->m_renegotiateEvent) { + pw_loop_destroy_source(d->pwCore->loop(), d->m_renegotiateEvent); + } + if (d->pwStream) { + pw_stream_destroy(d->pwStream); + } +} + +Fraction PipeWireSourceStream::framerate() const +{ + if (d->pwStream) { + return {d->videoFormat.max_framerate.num, d->videoFormat.max_framerate.denom}; + } + + return {0, 1}; +} + +void PipeWireSourceStream::setMaxFramerate(const Fraction &framerate) +{ + d->maxFramerate = framerate; + + if (d->pwStream) { + pw_loop_signal_event(d->pwCore->loop(), d->m_renegotiateEvent); + } +} + +uint PipeWireSourceStream::nodeId() +{ + return d->pwNodeId; +} + +PipeWireSourceStream::UsageHint PipeWireSourceStream::usageHint() const +{ + return d->usageHint; +} + +void PipeWireSourceStream::setUsageHint(UsageHint hint) +{ + d->usageHint = hint; +} + +QList PipeWireSourceStream::createFormatsParams(spa_pod_builder podBuilder) +{ + const auto pwServerVersion = d->pwCore->serverVersion(); + static constexpr auto formats = { + SPA_VIDEO_FORMAT_RGBx, + SPA_VIDEO_FORMAT_RGBA, + SPA_VIDEO_FORMAT_BGRx, + SPA_VIDEO_FORMAT_BGRA, + SPA_VIDEO_FORMAT_RGB, + SPA_VIDEO_FORMAT_BGR, + SPA_VIDEO_FORMAT_xBGR, + SPA_VIDEO_FORMAT_ABGR, + SPA_VIDEO_FORMAT_GRAY8, + }; + QList params; + params.reserve(formats.size() * 2); + const EGLDisplay display = static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("egldisplay")); + + d->m_allowDmaBuf = d->m_allowDmaBuf && (pwServerVersion.isNull() || (pwClientVersion >= kDmaBufMinVersion && pwServerVersion >= kDmaBufMinVersion)); + const bool withDontFixate = d->m_allowDmaBuf && (pwServerVersion.isNull() || (pwClientVersion >= kDmaBufModifierMinVersion && pwServerVersion >= kDmaBufModifierMinVersion)); + + if (!d->m_allowDmaBuf && d->usageHint == UsageHint::EncodeHardware) { + qCWarning(PIPEWIRE_LOGGING) << "DMABUF is unsupported but hardware encoding is requested, which requires DMABUF import. This will not work correctly."; + } + + if (d->m_availableModifiers.isEmpty()) { + static const auto availableModifiers = queryDmaBufModifiers(display, formats, d->usageHint); + d->m_availableModifiers = availableModifiers; + } + + for (auto it = d->m_availableModifiers.constBegin(), itEnd = d->m_availableModifiers.constEnd(); it != itEnd; ++it) { + if (d->m_allowDmaBuf && !it->isEmpty()) { + params += buildFormat(&podBuilder, it.key(), it.value(), withDontFixate, d->maxFramerate); + } + + params += buildFormat(&podBuilder, it.key(), {}, withDontFixate, d->maxFramerate); + } + + // BUG 492400: Workaround for pipewire < 0.3.49 https://github.com/PipeWire/pipewire/commit/8646117374df6fa3b73f63f9b35cda78a6aaa2f4 + params.removeAll(nullptr); + return params; +} + +bool PipeWireSourceStream::createStream(uint nodeid, int fd) +{ + d->m_availableModifiers.clear(); + d->pwCore = PipeWireCore::fetch(fd); + if (!d->pwCore->error().isEmpty()) { + qCDebug(PIPEWIRE_LOGGING) << "received error while creating the stream" << d->pwCore->error(); + d->m_error = d->pwCore->error(); + return false; + } + + connect(d->pwCore.data(), &PipeWireCore::pipewireFailed, this, &PipeWireSourceStream::coreFailed); + + if (objectName().isEmpty()) { + setObjectName(QStringLiteral("plasma-screencast-%1").arg(nodeid)); + } + + const auto pwServerVersion = d->pwCore->serverVersion(); + d->pwStream = pw_stream_new(**d->pwCore, objectName().toUtf8().constData(), nullptr); + d->pwNodeId = nodeid; + pw_stream_add_listener(d->pwStream, &d->streamListener, &pwStreamEvents, this); + + d->m_renegotiateEvent = pw_loop_add_event(d->pwCore->loop(), onRenegotiate, this); + + uint8_t buffer[4096]; + spa_pod_builder podBuilder = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); + auto params = createFormatsParams(podBuilder); + pw_stream_flags s = (pw_stream_flags)(PW_STREAM_FLAG_DONT_RECONNECT | PW_STREAM_FLAG_AUTOCONNECT); + if (pw_stream_connect(d->pwStream, PW_DIRECTION_INPUT, d->pwNodeId, s, params.data(), params.size()) != 0) { + qCWarning(PIPEWIRE_LOGGING) << "Could not connect to stream"; + pw_stream_destroy(d->pwStream); + d->pwStream = nullptr; + return false; + } + qCDebug(PIPEWIRE_LOGGING) << "created successfully" << nodeid; + return true; +} + +void PipeWireSourceStream::handleFrame(struct pw_buffer *buffer) +{ + spa_buffer *spaBuffer = buffer->buffer; + + PipeWireFrame frame; + frame.format = d->videoFormat.format; + + struct spa_meta_header *header = (struct spa_meta_header *)spa_buffer_find_meta_data(spaBuffer, SPA_META_Header, sizeof(*header)); + if (header) { + if (header->flags & SPA_META_HEADER_FLAG_CORRUPTED) { + qCDebug(PIPEWIRE_LOGGING) << "buffer is corrupt"; + return; + } + + d->m_currentPresentationTimestamp = std::chrono::nanoseconds(header->pts); + frame.presentationTimestamp = std::chrono::nanoseconds(header->pts); + frame.sequential = header->seq; + } else { + d->m_currentPresentationTimestamp = std::chrono::steady_clock::now().time_since_epoch(); + frame.presentationTimestamp = d->m_currentPresentationTimestamp; + } + + if (spa_meta *vd = spa_buffer_find_meta(spaBuffer, SPA_META_VideoDamage)) { + frame.damage = QRegion(); + spa_meta_region *mr; + spa_meta_for_each(mr, vd) + { + *frame.damage += QRect(mr->region.position.x, mr->region.position.y, mr->region.size.width, mr->region.size.height); + } + } + + { // process cursor + struct spa_meta_cursor *cursor = static_cast(spa_buffer_find_meta_data(spaBuffer, SPA_META_Cursor, sizeof(*cursor))); + if (cursor && spa_meta_cursor_is_valid(cursor)) { + struct spa_meta_bitmap *bitmap = nullptr; + + if (cursor->bitmap_offset) + bitmap = SPA_MEMBER(cursor, cursor->bitmap_offset, struct spa_meta_bitmap); + + QImage cursorTexture; + if (bitmap && bitmap->size.width > 0 && bitmap->size.height > 0) { + const size_t bufferSize = bitmap->stride * bitmap->size.height * 4; + void *bufferData = malloc(bufferSize); + memcpy(bufferData, SPA_MEMBER(bitmap, bitmap->offset, uint8_t), bufferSize); + cursorTexture = PWHelpers::SpaBufferToQImage(static_cast(bufferData), + bitmap->size.width, + bitmap->size.height, + bitmap->stride, + spa_video_format(bitmap->format), + new PipeWireFrameCleanupFunction([bufferData] { + free(bufferData); + })); + } + frame.cursor = {{cursor->position.x, cursor->position.y}, {cursor->hotspot.x, cursor->hotspot.y}, cursorTexture}; + } + } + + if (spaBuffer->datas->chunk->flags == SPA_CHUNK_FLAG_CORRUPTED) { + // do not get a frame + qCDebug(PIPEWIRE_LOGGING) << "skipping empty buffer" << spaBuffer->datas->chunk->size << spaBuffer->datas->chunk->flags; + } else if (spaBuffer->datas->type == SPA_DATA_MemFd) { + if (spaBuffer->datas->chunk->size == 0) { + qCDebug(PIPEWIRE_LOGGING) << "skipping empty memfd buffer"; + } else { + const uint32_t mapEnd = spaBuffer->datas->maxsize + spaBuffer->datas->mapoffset; + uint8_t *map = static_cast(mmap(nullptr, mapEnd, PROT_READ, MAP_PRIVATE, spaBuffer->datas->fd, 0)); + + if (map == MAP_FAILED) { + qCWarning(PIPEWIRE_LOGGING) << "Failed to mmap the memory: " << strerror(errno); + return; + } + auto cleanup = [map, mapEnd]() { + munmap(map, mapEnd); + }; + frame.dataFrame = std::make_shared(d->videoFormat.format, + map, + QSize(d->videoFormat.size.width, d->videoFormat.size.height), + spaBuffer->datas->chunk->stride, + new PipeWireFrameCleanupFunction(cleanup)); + } + } else if (spaBuffer->datas->type == SPA_DATA_DmaBuf) { + DmaBufAttributes attribs; + attribs.planes.reserve(spaBuffer->n_datas); + attribs.format = spaVideoFormatToDrmFormat(d->videoFormat.format); + attribs.modifier = d->videoFormat.modifier; + attribs.width = d->videoFormat.size.width; + attribs.height = d->videoFormat.size.height; + + for (uint i = 0; i < spaBuffer->n_datas; ++i) { + const auto &data = spaBuffer->datas[i]; + + DmaBufPlane plane; + plane.fd = data.fd; + plane.stride = data.chunk->stride; + plane.offset = data.chunk->offset; + attribs.planes += plane; + } + Q_ASSERT(!attribs.planes.isEmpty()); + frame.dmabuf = attribs; + } else if (spaBuffer->datas->type == SPA_DATA_MemPtr) { + if (spaBuffer->datas->chunk->size == 0) { + qCDebug(PIPEWIRE_LOGGING) << "skipping empty memptr buffer"; + } else { + frame.dataFrame = std::make_shared(d->videoFormat.format, + spaBuffer->datas->data, + QSize(d->videoFormat.size.width, d->videoFormat.size.height), + spaBuffer->datas->chunk->stride, + nullptr); + } + } else { + if (spaBuffer->datas->type == SPA_ID_INVALID) { + qCWarning(PIPEWIRE_LOGGING) << "invalid buffer type"; + } else { + qCWarning(PIPEWIRE_LOGGING) << "unsupported buffer type" << spaBuffer->datas->type; + } + frame.dataFrame = {}; + } + + Q_EMIT frameReceived(frame); +} + +void PipeWireSourceStream::coreFailed(const QString &errorMessage) +{ + qCDebug(PIPEWIRE_LOGGING) << "received error message" << errorMessage; + d->m_error = errorMessage; + Q_EMIT stopStreaming(); +} + +void PipeWireSourceStream::process() +{ +#if !PW_CHECK_VERSION(0, 3, 73) + if (Q_UNLIKELY(!d->pwStream)) { + // Assuming it's caused by https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3314 + qCDebug(PIPEWIRE_LOGGING) << "stream was terminated before processing buffer"; + return; + } +#endif + + pw_buffer *buf = pw_stream_dequeue_buffer(d->pwStream); + if (!buf) { + qCDebug(PIPEWIRE_LOGGING) << "out of buffers"; + return; + } + + handleFrame(buf); + + pw_stream_queue_buffer(d->pwStream, buf); +} + +void PipeWireSourceStream::setActive(bool active) +{ + Q_ASSERT(d->pwStream); + pw_stream_set_active(d->pwStream, active); +} + +void PipeWireSourceStream::setDamageEnabled(bool withDamage) +{ + d->m_withDamage = withDamage; +} + +bool PipeWireSourceStream::usingDmaBuf() const +{ + return d->m_usingDmaBuf; +} + +bool PipeWireSourceStream::allowDmaBuf() const +{ + return d->m_allowDmaBuf; +} + +void PipeWireSourceStream::setAllowDmaBuf(bool allowed) +{ + d->m_allowDmaBuf = allowed; +} + +void PipeWireSourceStream::onDestroy(void *data) +{ + // When PipeWire restarts the stream will auto-delete. Make sure we don't have dangling pointers! + auto pw = static_cast(data); + pw->d->pwStream = nullptr; +} + +#include "moc_pipewiresourcestream.cpp" diff --git a/src/pipewiresourcestream.h b/src/pipewiresourcestream.h new file mode 100644 index 0000000..871d668 --- /dev/null +++ b/src/pipewiresourcestream.h @@ -0,0 +1,171 @@ +/* + SPDX-FileCopyrightText: 2018-2020 Red Hat Inc + SPDX-FileCopyrightText: 2020-2021 Aleix Pol Gonzalez + SPDX-FileContributor: Jan Grulich + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#undef Status + +class PipeWireFrameCleanupFunction; +class PipeWireCore; +struct gbm_device; + +typedef void *EGLDisplay; + +struct DmaBufPlane { + int fd; ///< The dmabuf file descriptor + uint32_t offset; ///< The offset from the start of buffer + uint32_t stride; ///< The distance from the start of a row to the next row in bytes +}; + +struct DmaBufAttributes { + int width = 0; + int height = 0; + uint32_t format = 0; + uint64_t modifier = 0; ///< The layout modifier + + QList planes; +}; + +struct PipeWireCursor { + QPoint position; + QPoint hotspot; + QImage texture; + bool operator!=(const PipeWireCursor &other) const + { + return !operator==(other); + }; + bool operator==(const PipeWireCursor &other) const + { + return position == other.position && hotspot == other.hotspot && texture == other.texture; + } +}; + +class KPIPEWIRE_EXPORT PipeWireFrameData +{ + Q_DISABLE_COPY(PipeWireFrameData) +public: + PipeWireFrameData(spa_video_format format, void *data, QSize size, qint32 stride, PipeWireFrameCleanupFunction *cleanup); + ~PipeWireFrameData(); + + QImage toImage() const; + std::shared_ptr copy() const; + + const spa_video_format format; + void *const data = nullptr; + const QSize size; + const qint32 stride = 0; + PipeWireFrameCleanupFunction *const cleanup = nullptr; +}; + +struct KPIPEWIRE_EXPORT PipeWireFrame { + spa_video_format format; + std::optional sequential; + std::optional presentationTimestamp; + std::optional dmabuf; + std::optional damage; + std::optional cursor; + std::shared_ptr dataFrame; +}; + +struct Fraction { + bool operator==(const Fraction &other) const + { + return numerator == other.numerator && denominator == other.denominator; + } + explicit operator bool() const + { + return isValid(); + } + bool isValid() const + { + return denominator > 0; + } + quint32 numerator = 0; + quint32 denominator = 0; +}; + +struct PipeWireSourceStreamPrivate; + +class KPIPEWIRE_EXPORT PipeWireSourceStream : public QObject +{ + Q_OBJECT +public: + /** + * A hint to indicate how this stream will be used. + * + * By default this will be set to Render. + */ + enum class UsageHint { + Render, ///< Stream is intended mainly for reading pixel data and rendering directly to screen. + EncodeSoftware, ///< Stream is intended mainly for encoding video using software encoding. + EncodeHardware, ///< Stream is intended mainly for encoding video using hardware encoding. + }; + + explicit PipeWireSourceStream(QObject *parent = nullptr); + ~PipeWireSourceStream(); + + Fraction framerate() const; + void setMaxFramerate(const Fraction &framerate); + uint nodeId(); + QString error() const; + + QSize size() const; + pw_stream_state state() const; + bool createStream(uint nodeid, int fd); + void setActive(bool active); + void setDamageEnabled(bool withDamage); + + UsageHint usageHint() const; + void setUsageHint(UsageHint hint); + + void handleFrame(struct pw_buffer *buffer); + void process(); + void renegotiateModifierFailed(spa_video_format format, quint64 modifier); + + std::optional currentPresentationTimestamp() const; + + static uint32_t spaVideoFormatToDrmFormat(spa_video_format spa_format); + + bool usingDmaBuf() const; + bool allowDmaBuf() const; + void setAllowDmaBuf(bool allowed); + +Q_SIGNALS: + void streamReady(); + void startStreaming(); + void stopStreaming(); + void streamParametersChanged(); + void frameReceived(const PipeWireFrame &frame); + void stateChanged(pw_stream_state state, pw_stream_state oldState); + +private: + static void onStreamParamChanged(void *data, uint32_t id, const struct spa_pod *format); + static void onStreamStateChanged(void *data, pw_stream_state old, pw_stream_state state, const char *error_message); + static void onRenegotiate(void *data, uint64_t); + static void onDestroy(void *data); + QList createFormatsParams(spa_pod_builder podBuilder); + + void coreFailed(const QString &errorMessage); + QScopedPointer d; +}; diff --git a/src/pwhelpers.cpp b/src/pwhelpers.cpp new file mode 100644 index 0000000..a02896e --- /dev/null +++ b/src/pwhelpers.cpp @@ -0,0 +1,69 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "pwhelpers.h" +#include "logging.h" + +QImage::Format SpaToQImageFormat(quint32 format) +{ + switch (format) { + case SPA_VIDEO_FORMAT_BGRx: + case SPA_VIDEO_FORMAT_BGRA: + return QImage::Format_RGBA8888_Premultiplied; // Handled in SpaBufferToQImage + case SPA_VIDEO_FORMAT_ABGR: + case SPA_VIDEO_FORMAT_xBGR: + return QImage::Format_ARGB32; // Handled in SpaBufferToQImage + case SPA_VIDEO_FORMAT_BGR: + return QImage::Format_BGR888; + case SPA_VIDEO_FORMAT_RGBx: + return QImage::Format_RGBX8888; + case SPA_VIDEO_FORMAT_RGB: + return QImage::Format_RGB888; + case SPA_VIDEO_FORMAT_RGBA: + return QImage::Format_RGBA8888_Premultiplied; + case SPA_VIDEO_FORMAT_GRAY8: + return QImage::Format_Grayscale8; + default: + qCWarning(PIPEWIRE_LOGGING) << "cannot convert spa format to QImage" << format; + return QImage::Format_RGB32; + } +} + +QImage PWHelpers::SpaBufferToQImage(const uchar *data, int width, int height, qsizetype bytesPerLine, spa_video_format format, PipeWireFrameCleanupFunction *c) +{ + c->ref(); + switch (format) { + case SPA_VIDEO_FORMAT_BGRx: + case SPA_VIDEO_FORMAT_BGRA: + case SPA_VIDEO_FORMAT_xBGR: + case SPA_VIDEO_FORMAT_ABGR: { + // This is needed because QImage does not support BGRA + // This is obviously a much slower path, it makes sense to avoid it as much as possible + return QImage(data, width, height, bytesPerLine, SpaToQImageFormat(format), &PipeWireFrameCleanupFunction::unref, c).rgbSwapped(); + } + case SPA_VIDEO_FORMAT_GRAY8: + case SPA_VIDEO_FORMAT_RGBx: + case SPA_VIDEO_FORMAT_RGB: + case SPA_VIDEO_FORMAT_RGBA: + default: + return QImage(data, width, height, bytesPerLine, SpaToQImageFormat(format), &PipeWireFrameCleanupFunction::unref, c); + } +} + +QImage PipeWireFrameData::toImage() const +{ + return PWHelpers::SpaBufferToQImage(static_cast(data), size.width(), size.height(), stride, format, cleanup); +} + +std::shared_ptr PipeWireFrameData::copy() const +{ + const uint bufferSize = size.height() * stride * 4; + auto newMap = malloc(bufferSize); + memcpy(newMap, data, bufferSize); + return std::make_shared(format, newMap, size, stride, new PipeWireFrameCleanupFunction([newMap] { + free(newMap); + })); +} diff --git a/src/pwhelpers.h b/src/pwhelpers.h new file mode 100644 index 0000000..50dd889 --- /dev/null +++ b/src/pwhelpers.h @@ -0,0 +1,61 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include "pipewiresourcestream.h" +#include +#include +#include + +typedef unsigned int GLenum; + +/** + * The @class PipeWireFrameCleanupFunction is used to track the lifetime of a pipewire frame. + * + * It is used to have a ref-counted class that will call the cleanup function when + * it's left with no references. + * This is useful so that it can be passed to QImage() if necessary without having to + * track if the QImage itself outlives the buffer. + */ +class PipeWireFrameCleanupFunction +{ + Q_DISABLE_COPY(PipeWireFrameCleanupFunction) +public: + PipeWireFrameCleanupFunction(std::function cleanup) + : m_ref(0) + , m_cleanup(cleanup) + { + } + + void ref() + { + m_ref++; + } + static void unref(void *x) + { + if (!x) { + return; + } + auto self = static_cast(x); + self->m_ref--; + if (self->m_ref == 0) { + self->m_cleanup(); + delete self; + } + } + +private: + QAtomicInt m_ref; + std::function m_cleanup; +}; + +namespace PWHelpers +{ + +KPIPEWIRE_EXPORT QImage +SpaBufferToQImage(const uchar *data, int width, int height, qsizetype bytesPerLine, spa_video_format format, PipeWireFrameCleanupFunction *cleanup); +} diff --git a/src/vaapiutils.cpp b/src/vaapiutils.cpp new file mode 100644 index 0000000..4414df2 --- /dev/null +++ b/src/vaapiutils.cpp @@ -0,0 +1,267 @@ +/* + SPDX-FileCopyrightText: 2023 Marco Martin + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "vaapiutils_p.h" +#include + +#include + +extern "C" { +#include +#include +#include +#include +#include +} + +VaapiUtils::VaapiUtils(VaapiUtils::Private) +{ + int max_devices = drmGetDevices2(0, nullptr, 0); + if (max_devices <= 0) { + qCWarning(PIPEWIREVAAPI_LOGGING) << "drmGetDevices2() has not found any devices (errno=" << -max_devices << ")"; + return; + } + + std::vector devices(max_devices); + int ret = drmGetDevices2(0, devices.data(), max_devices); + if (ret < 0) { + qCWarning(PIPEWIREVAAPI_LOGGING) << "drmGetDevices2() returned an error " << ret; + return; + } + + for (const drmDevicePtr &device : devices) { + if (device->available_nodes & (1 << DRM_NODE_RENDER)) { + QByteArray fullPath = device->nodes[DRM_NODE_RENDER]; + if (supportsH264(fullPath)) { + m_devicePath = fullPath; + break; + } + } + } + + drmFreeDevices(devices.data(), ret); + + if (m_devicePath.isEmpty()) { + qCWarning(PIPEWIREVAAPI_LOGGING) << "DRM device not found"; + } +} + +VaapiUtils::~VaapiUtils() +{ +} + +bool VaapiUtils::supportsProfile(VAProfile profile) +{ + if (m_devicePath.isEmpty()) { + return false; + } + bool ret = false; + + int drmFd = -1; + + VADisplay vaDpy = openDevice(&drmFd, m_devicePath); + if (!vaDpy) { + return false; + } + + ret = supportsProfile(profile, vaDpy, m_devicePath); + + closeDevice(&drmFd, vaDpy); + + return ret; +} + +bool VaapiUtils::supportsH264(const QByteArray &path) const +{ + if (path.isEmpty()) { + return false; + } + bool ret = false; + + int drmFd = -1; + + VADisplay vaDpy = openDevice(&drmFd, path); + if (!vaDpy) { + return false; + } + + const char *driver = vaQueryVendorString(vaDpy); + qCWarning(PIPEWIREVAAPI_LOGGING) << "VAAPI:" << driver << "in use for device" << path; + + ret = supportsProfile(VAProfileH264ConstrainedBaseline, vaDpy, path) || supportsProfile(VAProfileH264Main, vaDpy, path) + || supportsProfile(VAProfileH264High, vaDpy, path); + + querySizeConstraints(vaDpy); + + closeDevice(&drmFd, vaDpy); + + return ret; +} + +QByteArray VaapiUtils::devicePath() +{ + return m_devicePath; +} + +QSize VaapiUtils::minimumSize() const +{ + return m_minSize; +} + +QSize VaapiUtils::maximumSize() const +{ + return m_maxSize; +} + +bool VaapiUtils::supportsModifier(uint32_t /*format*/, uint64_t modifier) +{ + // For now, we have no way of querying VAAPI for what modifiers are + // actually supported for encoding. So assume we can only support linear + // buffers for now, even though some cards may actually also support + // other formats. + // + // As of 8/4/24, we know that on AMD chips using the RadeonSI driver, frames + // using "Delta Color Compression" modifier will be rejected by the driver. + // Also, Intel chips using the Interl iHD Media driver will accept any + // modifier but internally force using LINEAR so any modifier other than + // LINEAR should be rejected. + // + // See https://github.com/intel/libva/pull/589 for discussion surrounding + // API in LibVA for querying supported modifiers. + return modifier == DRM_FORMAT_MOD_LINEAR; +} + +std::shared_ptr VaapiUtils::instance() +{ + static std::shared_ptr instance = std::make_shared(VaapiUtils::Private{}); + return instance; +} + +VADisplay VaapiUtils::openDevice(int *fd, const QByteArray &path) +{ + VADisplay vaDpy; + + if (path.isEmpty()) { + return NULL; + } + + *fd = open(path.data(), O_RDWR); + if (*fd < 0) { + qCWarning(PIPEWIREVAAPI_LOGGING) << "VAAPI: Failed to open device" << path; + return NULL; + } + + vaDpy = vaGetDisplayDRM(*fd); + if (!vaDpy) { + qCWarning(PIPEWIREVAAPI_LOGGING) << "VAAPI: Failed to initialize DRM display"; + return NULL; + } + + if (vaDisplayIsValid(vaDpy) == 0) { + qCWarning(PIPEWIREVAAPI_LOGGING) << "Invalid VA display"; + vaTerminate(vaDpy); + return NULL; + } + + int major, minor; + VAStatus va_status = vaInitialize(vaDpy, &major, &minor); + + if (va_status != VA_STATUS_SUCCESS) { + qCWarning(PIPEWIREVAAPI_LOGGING) << "VAAPI: Failed to initialize display"; + return NULL; + } + + qCInfo(PIPEWIREVAAPI_LOGGING) << "VAAPI: API version" << major << "." << minor; + qCInfo(PIPEWIREVAAPI_LOGGING) << "VAAPI: Display initialized"; + + return vaDpy; +} + +void VaapiUtils::closeDevice(int *fd, VADisplay dpy) +{ + vaTerminate(dpy); + if (*fd < 0) { + return; + } + + close(*fd); + *fd = -1; +} + +bool VaapiUtils::supportsProfile(VAProfile profile, VADisplay dpy, const QByteArray &path) +{ + uint32_t ret = rateControlForProfile(profile, VAEntrypointEncSlice, dpy, path); + + if (ret & VA_RC_CBR || ret & VA_RC_CQP || ret & VA_RC_VBR) { + return true; + } else { + ret = rateControlForProfile(profile, VAEntrypointEncSliceLP, dpy, path); + + if (ret & VA_RC_CBR || ret & VA_RC_CQP || ret & VA_RC_VBR) { + return true; + } + } + + return false; +} + +uint32_t VaapiUtils::rateControlForProfile(VAProfile profile, VAEntrypoint entrypoint, VADisplay dpy, const QByteArray &path) +{ + VAStatus va_status; + VAConfigAttrib attrib[1]; + attrib->type = VAConfigAttribRateControl; + + va_status = vaGetConfigAttributes(dpy, profile, entrypoint, attrib, 1); + + switch (va_status) { + case VA_STATUS_SUCCESS: + return attrib->value; + case VA_STATUS_ERROR_UNSUPPORTED_PROFILE: + qCWarning(PIPEWIREVAAPI_LOGGING) << "VAAPI: profile" << profile << "is not supported by the device" << path; + return 0; + case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT: + qCWarning(PIPEWIREVAAPI_LOGGING) << "VAAPI: entrypoint" << entrypoint << "of profile" << profile << "is not supported by the device" << path; + return 0; + default: + qCWarning(PIPEWIREVAAPI_LOGGING) << "VAAPI: Fail to get RC attribute from the" << profile << entrypoint << "of the device" << path; + return 0; + } +} + +void VaapiUtils::querySizeConstraints(VADisplay dpy) const +{ + VAConfigID config; + if (auto status = vaCreateConfig(dpy, VAProfileH264ConstrainedBaseline, VAEntrypointEncSlice, nullptr, 0, &config); status != VA_STATUS_SUCCESS) { + return; + } + + VASurfaceAttrib attrib[8]; + uint32_t attribCount = 8; + + auto status = vaQuerySurfaceAttributes(dpy, config, attrib, &attribCount); + if (status == VA_STATUS_SUCCESS) { + for (uint32_t i = 0; i < attribCount; ++i) { + switch (attrib[i].type) { + case VASurfaceAttribMinWidth: + m_minSize.setWidth(attrib[i].value.value.i); + break; + case VASurfaceAttribMinHeight: + m_minSize.setHeight(attrib[i].value.value.i); + break; + case VASurfaceAttribMaxWidth: + m_maxSize.setWidth(attrib[i].value.value.i); + break; + case VASurfaceAttribMaxHeight: + m_maxSize.setHeight(attrib[i].value.value.i); + break; + default: + break; + } + } + } + + vaDestroyConfig(dpy, config); +} diff --git a/src/vaapiutils_p.h b/src/vaapiutils_p.h new file mode 100644 index 0000000..ab82ea2 --- /dev/null +++ b/src/vaapiutils_p.h @@ -0,0 +1,52 @@ +/* + SPDX-FileCopyrightText: 2023 Marco Martin + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include +#include + +extern "C" { +#include +} + +#include "kpipewire_export.h" + +class KPIPEWIRE_EXPORT VaapiUtils +{ + // Utility struct to tag constructor as private while still allowing it to + // be used by make_shared(). + struct Private { + }; + +public: + VaapiUtils(Private); + ~VaapiUtils(); + + bool supportsProfile(VAProfile profile); + + QByteArray devicePath(); + + QSize minimumSize() const; + QSize maximumSize() const; + + bool supportsModifier(uint32_t format, uint64_t modifier); + + static std::shared_ptr instance(); + +private: + static VADisplay openDevice(int *fd, const QByteArray &path); + static void closeDevice(int *fd, VADisplay dpy); + bool supportsH264(const QByteArray &path) const; + void querySizeConstraints(VADisplay dpy) const; + static bool supportsProfile(VAProfile profile, VADisplay dpy, const QByteArray &path); + static uint32_t rateControlForProfile(VAProfile profile, VAEntrypoint entrypoint, VADisplay dpy, const QByteArray &path); + + QByteArray m_devicePath; + + mutable QSize m_minSize; + mutable QSize m_maxSize = QSize{std::numeric_limits::max(), std::numeric_limits::max()}; +}; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..8b10222 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,57 @@ +find_package(Qt6 REQUIRED COMPONENTS WaylandClient) +find_package(Wayland REQUIRED COMPONENTS Client) + +add_library(PipeWireScreencastingTest STATIC screencasting.cpp screencastingrequest.cpp) + +qt_add_dbus_interface( + SRCS + org.freedesktop.portal.ScreenCast.xml + xdp_dbus_screencast_interface +) + +qt_add_dbus_interface( + SRCS + org.freedesktop.portal.RemoteDesktop.xml + xdp_dbus_remotedesktop_interface +) + +if (Qt6_VERSION VERSION_GREATER_EQUAL "6.8.0") + set(private_code_option "PRIVATE_CODE") +endif() +qt6_generate_wayland_protocol_client_sources(PipeWireScreencastingTest + ${private_code_option} + FILES ${PLASMA_WAYLAND_PROTOCOLS_DIR}/zkde-screencast-unstable-v1.xml +) + +target_link_libraries(PipeWireScreencastingTest PUBLIC Wayland::Client Qt::DBus Qt::GuiPrivate KPipeWire Qt::WaylandClient) + +add_executable(recordme main.cpp recordme.qrc PlasmaRecordMe.cpp) +target_link_libraries(recordme PipeWireScreencastingTest Qt::Quick) + +add_executable(kpipewireheadlesstest HeadlessTest.cpp ${SRCS}) +target_link_libraries(kpipewireheadlesstest PipeWireScreencastingTest KPipeWireDmaBuf KPipeWireRecord KF6::CoreAddons) + +######### + +qt_add_dbus_interface( + XDP_SRCS + org.freedesktop.portal.ScreenCast.xml + xdp_dbus_screencast_interface +) + +add_executable(xdp-recordme xdp-main.cpp recordme.qrc ${XDP_SRCS} RecordMe.cpp) +target_link_libraries(xdp-recordme Qt::DBus Qt::Quick KPipeWire Qt::GuiPrivate Wayland::Client Qt::WaylandClient ) + +option(INSTALL_TESTS "The recordme test needs installing, disabled by default for convenience" OFF) +if(INSTALL_TESTS) + configure_file(org.kde.recordme.desktop.cmake ${CMAKE_CURRENT_BINARY_DIR}/org.kde.recordme.desktop @ONLY) + configure_file(org.kde.kpipewireheadlesstest.desktop.cmake ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kpipewireheadlesstest.desktop @ONLY) + + install(TARGETS recordme kpipewireheadlesstest DESTINATION ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.recordme.desktop DESTINATION ${KDE_INSTALL_APPDIR}) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kpipewireheadlesstest.desktop DESTINATION ${KDE_INSTALL_APPDIR}) + install(TARGETS xdp-recordme DESTINATION ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) +endif() + +add_executable(webcamtest webcamtest.cpp webcamtest.qml webcamtest.qrc) +target_link_libraries(webcamtest Qt::Quick KPipeWire) diff --git a/tests/HeadlessTest.cpp b/tests/HeadlessTest.cpp new file mode 100644 index 0000000..33db742 --- /dev/null +++ b/tests/HeadlessTest.cpp @@ -0,0 +1,535 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include +#include +#include +#include +#include + +#include "screencasting.h" +#include "xdp_dbus_remotedesktop_interface.h" +#include "xdp_dbus_screencast_interface.h" +#include +#include +#include +#include +#include + +using namespace Qt::StringLiterals; + +static bool s_encodedStream = false; +static std::optional s_framerate; +static std::optional s_encoder; +static Screencasting::CursorMode s_cursorMode = Screencasting::Embedded; + +static QString createHandleToken() +{ + return QStringLiteral("kpipewireheadlesstest%1").arg(QRandomGenerator::global()->generate()); +} + +void createStream(int nodeId, std::optional fd = {}) +{ + if (s_encodedStream) { + auto encoded = new PipeWireEncodedStream(qGuiApp); + encoded->setNodeId(nodeId); + if (fd) { + encoded->setFd(*fd); + } + if (s_framerate) { + encoded->setMaxFramerate(*s_framerate); + } + if (s_encoder) { + PipeWireBaseEncodedStream::Encoder enc = PipeWireBaseEncodedStream::NoEncoder; + if (s_encoder.value() == QByteArray("H264Main")) { + enc = PipeWireBaseEncodedStream::H264Main; + } else if (s_encoder.value() == QByteArray("H264Baseline")) { + enc = PipeWireBaseEncodedStream::H264Baseline; + } else if (s_encoder.value() == QByteArray("VP8")) { + enc = PipeWireBaseEncodedStream::VP8; + } else if (s_encoder.value() == QByteArray("VP9")) { + enc = PipeWireBaseEncodedStream::VP9; + } + encoded->setEncoder(enc); + } + encoded->setActive(true); + QObject::connect(encoded, &PipeWireEncodedStream::newPacket, qGuiApp, [](const PipeWireEncodedStream::Packet &packet) { + qDebug() << "packet received" << packet.data().size() << "key:" << packet.isKeyFrame(); + }); + QObject::connect(encoded, &PipeWireEncodedStream::cursorChanged, qGuiApp, [](const PipeWireCursor &cursor) { + qDebug() << "cursor received. position:" << cursor.position << "hotspot:" << cursor.hotspot << "image:" << cursor.texture; + }); + QObject::connect(KSignalHandler::self(), &KSignalHandler::signalReceived, encoded, [encoded] { + encoded->setActive(false); + exit(0); + }); + return; + } + auto pwStream = new PipeWireSourceStream(qGuiApp); + pwStream->setAllowDmaBuf(false); + if (s_framerate) { + pwStream->setMaxFramerate(*s_framerate); + } + if (!pwStream->createStream(nodeId, 0)) { + qWarning() << "failed!" << pwStream->error(); + exit(1); + } + + auto handler = std::make_shared(); + QObject::connect(pwStream, &PipeWireSourceStream::frameReceived, qGuiApp, [handler, pwStream](const PipeWireFrame &frame) { + if (frame.dmabuf) { + QImage qimage(pwStream->size(), QImage::Format_RGBA8888); + if (!handler->downloadFrame(qimage, frame)) { + qDebug() << "failed to download frame"; + pwStream->renegotiateModifierFailed(frame.format, frame.dmabuf->modifier); + } else { + qDebug() << "dmabuf" << frame.format; + } + } else if (frame.dataFrame) { + qDebug() << "image" << frame.dataFrame->format << frame.format; + } else { + qDebug() << "no-frame"; + } + }); + QObject::connect(KSignalHandler::self(), &KSignalHandler::signalReceived, pwStream, [pwStream] { + pwStream->setActive(false); + exit(0); + }); +} + +void processStream(ScreencastingStream *stream) +{ + QObject::connect(stream, &ScreencastingStream::created, qGuiApp, [](int nodeId) { + createStream(nodeId); + }); +} + +void checkPlasmaScreens() +{ + auto screencasting = new Screencasting(qGuiApp); + for (auto screen : qGuiApp->screens()) { + auto stream = screencasting->createOutputStream(screen->name(), s_cursorMode); + processStream(stream); + } +} + +void checkPlasmaWorkspace() +{ + auto screencasting = new Screencasting(qGuiApp); + QRegion region; + for (auto screen : qGuiApp->screens()) { + region |= screen->geometry(); + } + auto stream = screencasting->createRegionStream(region.boundingRect(), 1, s_cursorMode); + processStream(stream); +} + +using Stream = struct { + uint nodeId; + QVariantMap map; +}; +using Streams = QList; + +Q_DECLARE_METATYPE(Stream); +Q_DECLARE_METATYPE(Streams); + +const QDBusArgument &operator>>(const QDBusArgument &arg, Stream &stream) +{ + arg.beginStructure(); + arg >> stream.nodeId; + + arg.beginMap(); + while (!arg.atEnd()) { + QString key; + QVariant map; + arg.beginMapEntry(); + arg >> key >> map; + arg.endMapEntry(); + stream.map.insert(key, map); + } + arg.endMap(); + arg.endStructure(); + + return arg; +} + +class XdpScreenCast : public QObject +{ + Q_OBJECT +public: + XdpScreenCast(QObject *parent) + : QObject(parent) + { + initDbus(); + } + + void initDbus() + { + dbusXdpScreenCastService.reset(new OrgFreedesktopPortalScreenCastInterface(QStringLiteral("org.freedesktop.portal.Desktop"), + QStringLiteral("/org/freedesktop/portal/desktop"), + QDBusConnection::sessionBus())); + + qInfo() << "Initializing D-Bus connectivity with XDG Desktop Portal" << dbusXdpScreenCastService->version(); + Q_ASSERT(dbusXdpScreenCastService->isValid()); + + // create session + auto sessionParameters = + QVariantMap{{QStringLiteral("session_handle_token"), createHandleToken()}, {QStringLiteral("handle_token"), createHandleToken()}}; + auto sessionReply = dbusXdpScreenCastService->CreateSession(sessionParameters); + sessionReply.waitForFinished(); + if (!sessionReply.isValid()) { + qWarning() << "Couldn't initialize XDP-KDE screencast session" << sessionReply.error(); + exit(1); + return; + } + + qInfo() << "DBus session created: " << sessionReply.value().path() + << QDBusConnection::sessionBus().connect(QString(), + sessionReply.value().path(), + QStringLiteral("org.freedesktop.portal.Request"), + QStringLiteral("Response"), + this, + SLOT(handleSessionCreated(uint, QVariantMap))); + } + +public Q_SLOTS: + void handleSessionCreated(quint32 code, const QVariantMap &results) + { + if (code != 0) { + qWarning() << "Failed to create session: " << code; + exit(1); + return; + } + + sessionPath = QDBusObjectPath(results.value(QStringLiteral("session_handle")).toString()); + + // select sources for the session + const QVariantMap sourcesParameters = {{QLatin1String("handle_token"), createHandleToken()}, + {QLatin1String("types"), dbusXdpScreenCastService->availableSourceTypes()}, + {QLatin1String("multiple"), false}, + {QLatin1String("cursor_mode"), uint(2 /*Embedded*/)}}; + auto selectorReply = dbusXdpScreenCastService->SelectSources(sessionPath, sourcesParameters); + selectorReply.waitForFinished(); + if (!selectorReply.isValid()) { + qWarning() << "Couldn't select devices for the remote-desktop session"; + exit(1); + return; + } + QDBusConnection::sessionBus().connect(QString(), + selectorReply.value().path(), + QStringLiteral("org.freedesktop.portal.Request"), + QStringLiteral("Response"), + this, + SLOT(handleSourcesSelected(uint, QVariantMap))); + } + + void handleSourcesSelected(quint32 code, const QVariantMap &) + { + if (code != 0) { + qWarning() << "Failed to select sources: " << code; + exit(1); + return; + } + + // start session + auto startParameters = QVariantMap{{QStringLiteral("handle_token"), createHandleToken()}}; + auto startReply = dbusXdpScreenCastService->Start(sessionPath, QString(), startParameters); + startReply.waitForFinished(); + QDBusConnection::sessionBus().connect(QString(), + startReply.value().path(), + QStringLiteral("org.freedesktop.portal.Request"), + QStringLiteral("Response"), + this, + SLOT(handleRemoteDesktopStarted(uint, QVariantMap))); + } + + void handleRemoteDesktopStarted(quint32 code, const QVariantMap &results) + { + if (code != 0) { + qWarning() << "Failed to start screencast: " << code; + exit(1); + return; + } + + // there should be only one stream + const Streams streams = qdbus_cast(results.value(QStringLiteral("streams"))); + if (streams.isEmpty()) { + // maybe we should check deeper with qdbus_cast but this suffices for now + qWarning() << "Failed to get screencast streams"; + exit(1); + return; + } + + const QVariantMap startParameters = { + { QLatin1String("handle_token"), createHandleToken() } + }; + + auto streamReply = dbusXdpScreenCastService->OpenPipeWireRemote(sessionPath, startParameters); + streamReply.waitForFinished(); + if (!streamReply.isValid()) { + qWarning() << "Couldn't open pipewire remote for the screen-casting session"; + exit(1); + return; + } + + auto pipewireFd = streamReply.value(); + if (!pipewireFd.isValid()) { + qWarning() << "Couldn't get pipewire connection file descriptor"; + exit(1); + return; + } + const uint fd = pipewireFd.takeFileDescriptor(); + for (auto x : streams) { + createStream(x.nodeId, fd); + } + } + +private: + QScopedPointer dbusXdpScreenCastService; + QDBusObjectPath sessionPath; +}; + +class XdpRemoteDesktop : public QObject +{ + Q_OBJECT +public: + XdpRemoteDesktop(QObject *parent) + : QObject(parent) + { + initDbus(); + } + + void initDbus() + { + dbusXdpScreenCastService.reset(new OrgFreedesktopPortalScreenCastInterface(QStringLiteral("org.freedesktop.portal.Desktop"), + QStringLiteral("/org/freedesktop/portal/desktop"), + QDBusConnection::sessionBus())); + dbusXdpRemoteDesktopService.reset(new OrgFreedesktopPortalRemoteDesktopInterface(QStringLiteral("org.freedesktop.portal.Desktop"), + QStringLiteral("/org/freedesktop/portal/desktop"), + QDBusConnection::sessionBus())); + + qInfo() << "Initializing D-Bus connectivity with XDG Desktop Portal" << dbusXdpScreenCastService->version(); + Q_ASSERT(dbusXdpScreenCastService->isValid()); + Q_ASSERT(dbusXdpRemoteDesktopService->isValid()); + + // create session + auto sessionParameters = + QVariantMap{{QStringLiteral("session_handle_token"), createHandleToken()}, {QStringLiteral("handle_token"), createHandleToken()}}; + auto sessionReply = dbusXdpRemoteDesktopService->CreateSession(sessionParameters); + sessionReply.waitForFinished(); + if (!sessionReply.isValid()) { + qWarning() << "Couldn't initialize XDP-KDE screencast session" << sessionReply.error(); + exit(1); + return; + } + + qInfo() << "DBus session created: " << sessionReply.value().path() + << QDBusConnection::sessionBus().connect(QString(), + sessionReply.value().path(), + QStringLiteral("org.freedesktop.portal.Request"), + QStringLiteral("Response"), + this, + SLOT(handleSessionCreated(uint, QVariantMap))); + } + +public Q_SLOTS: + void handleSessionCreated(quint32 code, const QVariantMap &results) + { + if (code != 0) { + qWarning() << "Failed to create session: " << code; + exit(1); + return; + } + + sessionPath = QDBusObjectPath(results.value(QStringLiteral("session_handle")).toString()); + + // select sources for the session + auto selectionOptions = QVariantMap{// We have to specify it's an uint, otherwise xdg-desktop-portal will not forward it to backend implementation + {QStringLiteral("types"), QVariant::fromValue(7)}, // request all (KeyBoard, Pointer, TouchScreen) + {QStringLiteral("handle_token"), createHandleToken()}}; + auto selectorReply = dbusXdpRemoteDesktopService->SelectDevices(sessionPath, selectionOptions); + selectorReply.waitForFinished(); + if (!selectorReply.isValid()) { + qWarning() << "Couldn't select devices for the remote-desktop session"; + exit(1); + return; + } + QDBusConnection::sessionBus().connect(QString(), + selectorReply.value().path(), + QStringLiteral("org.freedesktop.portal.Request"), + QStringLiteral("Response"), + this, + SLOT(handleDevicesSelected(uint, QVariantMap))); + } + + void handleDevicesSelected(quint32 code, const QVariantMap &results) + { + Q_UNUSED(results) + if (code != 0) { + qWarning() << "Failed to select devices: " << code; + exit(1); + return; + } + + // select sources for the session + auto selectionOptions = QVariantMap{{QStringLiteral("types"), QVariant::fromValue(7)}, + {QStringLiteral("multiple"), false}, + {QStringLiteral("handle_token"), createHandleToken()}}; + auto selectorReply = dbusXdpScreenCastService->SelectSources(sessionPath, selectionOptions); + selectorReply.waitForFinished(); + if (!selectorReply.isValid()) { + qWarning() << "Couldn't select sources for the screen-casting session"; + exit(1); + return; + } + QDBusConnection::sessionBus().connect(QString(), + selectorReply.value().path(), + QStringLiteral("org.freedesktop.portal.Request"), + QStringLiteral("Response"), + this, + SLOT(handleSourcesSelected(uint, QVariantMap))); + } + + void handleSourcesSelected(quint32 code, const QVariantMap &) + { + if (code != 0) { + qWarning() << "Failed to select sources: " << code; + exit(1); + return; + } + + // start session + auto startParameters = QVariantMap{{QStringLiteral("handle_token"), createHandleToken()}}; + auto startReply = dbusXdpRemoteDesktopService->Start(sessionPath, QString(), startParameters); + startReply.waitForFinished(); + QDBusConnection::sessionBus().connect(QString(), + startReply.value().path(), + QStringLiteral("org.freedesktop.portal.Request"), + QStringLiteral("Response"), + this, + SLOT(handleRemoteDesktopStarted(uint, QVariantMap))); + } + + void handleRemoteDesktopStarted(quint32 code, const QVariantMap &results) + { + if (code != 0) { + qWarning() << "Failed to start screencast: " << code; + exit(1); + return; + } + + if (results.value(QStringLiteral("devices")).toUInt() == 0) { + qWarning() << "No devices were granted" << results; + exit(1); + return; + } + + // there should be only one stream + const Streams streams = qdbus_cast(results.value(QStringLiteral("streams"))); + if (streams.isEmpty()) { + // maybe we should check deeper with qdbus_cast but this suffices for now + qWarning() << "Failed to get screencast streams"; + exit(1); + return; + } + + auto streamReply = dbusXdpScreenCastService->OpenPipeWireRemote(sessionPath, QVariantMap()); + streamReply.waitForFinished(); + if (!streamReply.isValid()) { + qWarning() << "Couldn't open pipewire remote for the screen-casting session"; + exit(1); + return; + } + + auto pipewireFd = streamReply.value(); + if (!pipewireFd.isValid()) { + qWarning() << "Couldn't get pipewire connection file descriptor"; + exit(1); + return; + } + + const uint fd = pipewireFd.takeFileDescriptor(); + for (auto x : streams) { + createStream(x.nodeId, fd); + } + } + +private: + QScopedPointer dbusXdpScreenCastService; + QScopedPointer dbusXdpRemoteDesktopService; + QDBusObjectPath sessionPath; +}; + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + { + QCommandLineParser parser; + const QMap cursorOptions = { + {QStringLiteral("hidden"), Screencasting::CursorMode::Hidden}, + {QStringLiteral("embedded"), Screencasting::CursorMode::Embedded}, + {QStringLiteral("metadata"), Screencasting::CursorMode::Metadata}, + }; + + QCommandLineOption cursorOption(QStringLiteral("cursor"), + QStringList(cursorOptions.keys()).join(QStringLiteral(", ")), + QStringLiteral("mode"), + QStringLiteral("metadata")); + + KSignalHandler::self()->watchSignal(SIGTERM); + KSignalHandler::self()->watchSignal(SIGINT); + + QCommandLineOption useXdpRD(QStringLiteral("xdp-remotedesktop"), QStringLiteral("Uses the XDG Desktop Portal RemoteDesktop interface")); + parser.addOption(useXdpRD); + QCommandLineOption useXdpSC(QStringLiteral("xdp-screencast"), QStringLiteral("Uses the XDG Desktop Portal ScreenCast interface")); + parser.addOption(useXdpSC); + QCommandLineOption useWorkspace(QStringLiteral("workspace"), QStringLiteral("Uses the Plasma screencasting workspace feed")); + parser.addOption(useWorkspace); + QCommandLineOption encodedStream(QStringLiteral("encoded"), QStringLiteral("Reports encoded streams with PipeWireEncodedStream")); + parser.addOption(encodedStream); + QCommandLineOption streamEncoder(QStringLiteral("encoder"), + QStringLiteral("Which encoding to use with PipeWireEncodedStream"), + u"encoding"_s, + u"libvpx"_s); + parser.addOption(streamEncoder); + QCommandLineOption streamFramerate(QStringLiteral("framerate"), + QStringLiteral("Makes sure a framerate is requested (format 30/1 would mean 30fps)"), + QStringLiteral("num/denom")); + parser.addOption(streamFramerate); + parser.addOption(cursorOption); + parser.addHelpOption(); + parser.process(app); + + s_cursorMode = cursorOptions[parser.value(cursorOption).toLower()]; + s_encodedStream = parser.isSet(encodedStream); + if (parser.isSet(streamEncoder)) { + s_encoder = parser.value(streamEncoder).toUtf8(); + } + if (parser.isSet(streamFramerate)) { + const auto framerateString = parser.value(streamFramerate).split(u'/'); + if (framerateString.count() != 2) { + qWarning() << "wrong framerate" << framerateString; + return 1; + } + s_framerate = {framerateString.constFirst().toUInt(), framerateString.constLast().toUInt()}; + } + + if (parser.isSet(useXdpRD)) { + new XdpRemoteDesktop(&app); + } else if (parser.isSet(useXdpSC)) { + new XdpScreenCast(&app); + } else if (parser.isSet(useWorkspace)) { + checkPlasmaWorkspace(); + } else { + checkPlasmaScreens(); + } + } + + return app.exec(); +} + +#include "HeadlessTest.moc" diff --git a/tests/PlasmaRecordMe.cpp b/tests/PlasmaRecordMe.cpp new file mode 100644 index 0000000..486f6ec --- /dev/null +++ b/tests/PlasmaRecordMe.cpp @@ -0,0 +1,237 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "PlasmaRecordMe.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +PlasmaRecordMe::PlasmaRecordMe(Screencasting::CursorMode cursorMode, const QStringList &sources, bool doSelection, QObject *parent) + : QObject(parent) + , m_cursorMode(cursorMode) + , m_durationTimer(new QTimer(this)) + , m_sources(sources) + , m_engine(new QQmlApplicationEngine(this)) +{ + connect(m_engine, &QQmlEngine::quit, qGuiApp, &QCoreApplication::quit); + m_engine->setInitialProperties({ + { QStringLiteral("app"), QVariant::fromValue(this) }, + }); + m_engine->load(QUrl(QStringLiteral("qrc:/main.qml"))); + + m_screencasting = new Screencasting(this); + + m_durationTimer->setSingleShot(true); + + for (auto screen : qGuiApp->screens()) { + addScreen(screen); + } + connect(qGuiApp, &QGuiApplication::screenAdded, this, &PlasmaRecordMe::addScreen); + + if (m_sources.isEmpty() || m_sources.contains(QLatin1String("region"))) { + connect(this, &PlasmaRecordMe::workspaceChanged, this, [this] { + qDeleteAll(m_workspaceStreams); + m_workspaceStreams += m_screencasting->createRegionStream(m_workspace, 1, m_cursorMode); + m_workspaceStreams += m_screencasting->createRegionStream(m_workspace, 1, m_cursorMode); + start(m_workspaceStreams[0], true); + start(m_workspaceStreams[1], false); + }); + } + + if (doSelection) { + requestSelection(); + } + + for (const auto &source : m_sources) { + bool ok = false; + auto node = source.toInt(&ok); + if (ok) { + startNode(node); + } + } + + for (auto screen : qGuiApp->screens()) { + m_workspace |= screen->geometry(); + } + Q_EMIT workspaceChanged(); +} + +PlasmaRecordMe::~PlasmaRecordMe() +{ +} + +bool PlasmaRecordMe::matches(const QString &value) +{ + if (m_sources.isEmpty()) { + return true; + } + + for (const auto &source : m_sources) { + const QRegularExpression rx(source); + if (rx.match(value).hasMatch()) { + return true; + } + } + return false; +} + +void PlasmaRecordMe::addWindow(const QVariantList &uuid, const QString &appId) +{ + if (matches(appId) && uuid.size() > 0) { + QString uuidString = uuid.at(0).value(); + auto stream = m_screencasting->createWindowStream(uuidString, m_cursorMode); + stream->setObjectName(appId); + start(stream, true); + stream = m_screencasting->createWindowStream(uuidString, m_cursorMode); + stream->setObjectName(appId); + start(stream, false); + } +} + +void PlasmaRecordMe::addStream(int nodeid, const QString &displayText, int fd, bool allowDmaBuf) +{ + const auto roots = m_engine->rootObjects(); + for (auto root : roots) { + auto mo = root->metaObject(); + mo->invokeMethod(root, + "addStream", + Q_ARG(QVariant, QVariant::fromValue(nodeid)), + Q_ARG(QVariant, displayText), + Q_ARG(QVariant, fd), + Q_ARG(QVariant, allowDmaBuf)); + } +} + +void PlasmaRecordMe::startNode(int node) +{ + addStream(node, QStringLiteral("raw node %1").arg(node), 0, true); +} + +void PlasmaRecordMe::addScreen(QScreen *screen) +{ + auto f = [this, screen] { + start(m_screencasting->createOutputStream(screen, m_cursorMode), false); + start(m_screencasting->createOutputStream(screen, m_cursorMode), true); + }; + if (matches(screen->name())) { + connect(this, &PlasmaRecordMe::cursorModeChanged, screen, f); + f(); + } else if (matches(screen->model())) { + connect(this, &PlasmaRecordMe::cursorModeChanged, screen, f); + f(); + } +} + +void PlasmaRecordMe::start(ScreencastingStream *stream, bool allowDmaBuf) +{ + qDebug() << "start" << stream; + connect(stream, &ScreencastingStream::failed, this, [this] (const QString &error) { + qWarning() << "stream failed" << error;const auto roots = m_engine->rootObjects(); + for (auto root : roots) { + auto mo = root->metaObject(); + mo->invokeMethod(root, "showPassiveNotification", Qt::QueuedConnection, Q_ARG(QVariant, QVariant(error)) + , Q_ARG(QVariant, {}) + , Q_ARG(QVariant, {}) + , Q_ARG(QVariant, {}) + ); + } + }); + connect(stream, &ScreencastingStream::closed, this, [this, stream] { + auto nodeId = stream->property("nodeid").toInt(); + qDebug() << "bye bye" << stream << nodeId; + + const auto roots = m_engine->rootObjects(); + for (auto root : roots) { + auto mo = root->metaObject(); + mo->invokeMethod(root, "removeStream", Qt::QueuedConnection, Q_ARG(QVariant, QVariant::fromValue(nodeId))); + } + }); + connect(stream, &ScreencastingStream::created, this, [this, stream, allowDmaBuf](quint32 nodeId) { + stream->setProperty("nodeid", nodeId); + qDebug() << "starting..." << nodeId; + addStream(nodeId, stream->objectName(), 0, allowDmaBuf); + }); + connect(this, &PlasmaRecordMe::cursorModeChanged, stream, &ScreencastingStream::closed); +} + +void PlasmaRecordMe::setDuration(int duration) +{ + m_durationTimer->setInterval(duration); +} + +void PlasmaRecordMe::createVirtualMonitor() +{ + m_screencasting->createVirtualMonitorStream(QStringLiteral("recordme"), {1920, 1080}, 1, m_cursorMode); +} + +void PlasmaRecordMe::setRegionPressed(const QString &screenName, int x, int y) +{ + const auto screens = QGuiApplication::screens(); + auto screenIt = std::find_if(screens.begin(), screens.end(), [&screenName](auto screen) { + return screen->name() == screenName; + }); + m_region.setTopLeft((*screenIt)->geometry().topLeft() + QPoint{x, y}); +} + +void PlasmaRecordMe::setRegionMoved(const QString &screenName, int x, int y) +{ + const auto screens = QGuiApplication::screens(); + auto screenIt = std::find_if(screens.begin(), screens.end(), [&screenName](auto screen) { + return screen->name() == screenName; + }); + m_region.setBottomRight((*screenIt)->geometry().topLeft() + QPoint{x, y}); + Q_EMIT regionChanged(m_region); +} + +void PlasmaRecordMe::setRegionReleased(const QString &screenName, int x, int y) +{ + setRegionMoved(screenName, x, y); + m_region = m_region.normalized(); + Q_EMIT regionFinal(m_region); +} + +void PlasmaRecordMe::requestSelection() +{ + for (auto *screen : qApp->screens()) { + auto view = new QQuickView(m_engine, nullptr); + view->setScreen(screen); + view->setInitialProperties({{QStringLiteral("app"), QVariant::fromValue(this)}}); + view->setSource(QUrl(QStringLiteral("qrc:/RegionSelector.qml"))); + view->setColor(Qt::transparent); + view->showFullScreen(); + connect(this, &PlasmaRecordMe::regionFinal, view, &QQuickView::deleteLater); + } + + connect(this, &PlasmaRecordMe::regionFinal, this, [this](const QRect ®ion) { + for (auto stream : m_regionStreams) { + Q_EMIT stream->closed(); + } + qDeleteAll(m_regionStreams); + m_regionStreams += m_screencasting->createRegionStream(region, 1, m_cursorMode); + m_regionStreams += m_screencasting->createRegionStream(region, 1, m_cursorMode); + start(m_regionStreams[0], true); + start(m_regionStreams[1], false); + }); +} + +QRect PlasmaRecordMe::region() const +{ + return m_region.normalized(); +} + +#include "moc_PlasmaRecordMe.cpp" diff --git a/tests/PlasmaRecordMe.h b/tests/PlasmaRecordMe.h new file mode 100644 index 0000000..4b2317f --- /dev/null +++ b/tests/PlasmaRecordMe.h @@ -0,0 +1,72 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include +#include +#include +#include + +class QQmlApplicationEngine; +class QTimer; +class QScreen; +class Screencasting; + +namespace KWayland { + namespace Client { + class Registry; + class PlasmaWindowManagement; + class Output; + class XdgOutputManager; + } +} +class ScreencastingStream; +class OrgFreedesktopPortalScreenCastInterface; + +class PlasmaRecordMe : public QObject +{ + Q_OBJECT + Q_PROPERTY(QRect region READ region NOTIFY regionChanged) +public: + PlasmaRecordMe(Screencasting::CursorMode cursorMode, const QStringList &sources, bool doSelection, QObject *parent = nullptr); + ~PlasmaRecordMe() override; + + void setDuration(int duration); + + QRect region() const; + Q_SCRIPTABLE void addWindow(const QVariantList &uuid, const QString &appId); + Q_SCRIPTABLE void createVirtualMonitor(); + Q_SCRIPTABLE void requestSelection(); + Q_SCRIPTABLE void setRegionPressed(const QString &screen, int x, int y); + Q_SCRIPTABLE void setRegionMoved(const QString &screen, int x, int y); + Q_SCRIPTABLE void setRegionReleased(const QString &screen, int x, int y); + +Q_SIGNALS: + void cursorModeChanged(Screencasting::CursorMode cursorMode); + void workspaceChanged(); + void regionFinal(const QRect ®ion); + void regionChanged(const QRect ®ion); + +private: + void startNode(int node); + void start(ScreencastingStream *stream, bool allowDmaBuf); + void addScreen(QScreen *screen); + void addStream(int nodeid, const QString &displayText, int fd, bool allowDmaBuf); + bool matches(const QString &source); + + const Screencasting::CursorMode m_cursorMode; + QTimer* const m_durationTimer; + const QStringList m_sources; + KWayland::Client::PlasmaWindowManagement* m_management = nullptr; + Screencasting* m_screencasting = nullptr; + QQmlApplicationEngine* m_engine; + QList m_workspaceStreams; + QList m_regionStreams; + QRect m_workspace; + + QRect m_region; +}; diff --git a/tests/RecordMe.cpp b/tests/RecordMe.cpp new file mode 100644 index 0000000..560c7d4 --- /dev/null +++ b/tests/RecordMe.cpp @@ -0,0 +1,227 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "RecordMe.h" +#include +#include +#include +#include + +#include "xdp_dbus_screencast_interface.h" + +Q_DECLARE_METATYPE(Stream) + +QDebug operator<<(QDebug debug, const Stream& plug) +{ + QDebugStateSaver saver(debug); + debug.nospace() << "Stream(id: " << plug.id << ", opts: " << plug.opts << ')'; + return debug; +} + + +const QDBusArgument &operator<<(const QDBusArgument &argument, const Stream &/*stream*/) +{ + argument.beginStructure(); +// argument << stream.id << stream.opts; + argument.endStructure(); + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, Stream &stream) +{ + argument.beginStructure(); + argument >> stream.id >> stream.opts; + argument.endStructure(); + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, QList &stream) +{ + argument.beginArray(); + while ( !argument.atEnd() ) { + Stream element; + argument >> element; + stream.append( element ); + } + argument.endArray(); + return argument; +} + +RecordMe::RecordMe(QObject* parent) + : QObject(parent) + , iface(new OrgFreedesktopPortalScreenCastInterface( + QLatin1String("org.freedesktop.portal.Desktop"), QLatin1String("/org/freedesktop/portal/desktop"), QDBusConnection::sessionBus(), this)) + , m_durationTimer(new QTimer(this)) + , m_handleToken(QStringLiteral("RecordMe%1").arg(QRandomGenerator::global()->generate())) + , m_engine(new QQmlApplicationEngine(this)) +{ + m_engine->rootContext()->setContextProperty(QStringLiteral("app"), this); + m_engine->load(QUrl(QStringLiteral("qrc:/main.qml"))); + + // create session + const auto sessionParameters = QVariantMap { + { QLatin1String("session_handle_token"), m_handleToken }, + { QLatin1String("handle_token"), m_handleToken } + }; + auto sessionReply = iface->CreateSession(sessionParameters); + sessionReply.waitForFinished(); + if (!sessionReply.isValid()) { + qWarning("Couldn't initialize the remote control session"); + exit(1); + return; + } + + const bool ret = QDBusConnection::sessionBus().connect(QString(), + sessionReply.value().path(), + QLatin1String("org.freedesktop.portal.Request"), + QLatin1String("Response"), + this, + SLOT(response(uint, QVariantMap))); + if (!ret) { + qWarning() << "failed to create session"; + exit(2); + return; + } + + qDBusRegisterMetaType(); + qDBusRegisterMetaType>(); + + m_durationTimer->setSingleShot(true); +} + +RecordMe::~RecordMe() = default; + +void RecordMe::init(const QDBusObjectPath& path) +{ + m_path = path; + { + uint32_t cursor_mode; + if (iface->availableCursorModes() & Metadata) { + cursor_mode = Metadata; + } else { + cursor_mode = Hidden; + } + QVariantMap sourcesParameters = {{QLatin1String("handle_token"), m_handleToken}, + {QLatin1String("types"), iface->availableSourceTypes()}, + {QLatin1String("multiple"), false}, // for now? + {QLatin1String("cursor_mode"), uint(cursor_mode)}, + {QLatin1String("persist_mode"), uint(m_persistMode)}}; + + if (!m_restoreToken.isEmpty()) { + sourcesParameters[QLatin1String("restore_token")] = m_restoreToken; + } + + auto reply = iface->SelectSources(m_path, sourcesParameters); + reply.waitForFinished(); + + if (reply.isError()) { + qWarning() << "Could not select sources" << reply.error(); + exit(1); + return; + } + qDebug() << "select sources done" << reply.value().path(); + } +} + +void RecordMe::response(uint code, const QVariantMap& results) +{ + if (code > 0) { + qWarning() << "error!!!" << code << results; + exit(666); + return; + } + + if (results.contains(QLatin1String("restore_token"))) { + qDebug() << "Restore token:" << results[QLatin1String("restore_token")].toString(); + } + + const auto streamsIt = results.constFind(QStringLiteral("streams")); + if (streamsIt != results.constEnd()) { + QList streams; + streamsIt->value() >> streams; + + handleStreams(streams); + return; + } + + const auto handleIt = results.constFind(QStringLiteral("session_handle")); + if (handleIt != results.constEnd()) { + init(QDBusObjectPath(handleIt->toString())); + return; + } + + qDebug() << "params" << results << code; + if (results.isEmpty()) { + start(); + return; + } +} + +void RecordMe::start() +{ + const QVariantMap startParameters = { + { QLatin1String("handle_token"), m_handleToken } + }; + + auto reply = iface->Start(m_path, QStringLiteral("org.freedesktop.RecordMe"), startParameters); + reply.waitForFinished(); + + if (reply.isError()) { + qWarning() << "Could not start stream" << reply.error(); + exit(1); + return; + } + qDebug() << "started!" << reply.value().path(); +} + +void RecordMe::handleStreams(const QList &streams) +{ + const QVariantMap startParameters = { + { QLatin1String("handle_token"), m_handleToken } + }; + + auto reply = iface->OpenPipeWireRemote(m_path, startParameters); + reply.waitForFinished(); + + if (reply.isError()) { + qWarning() << "Could not start stream" << reply.error(); + exit(1); + return; + } + + const int fd = reply.value().takeFileDescriptor(); + + const auto roots = m_engine->rootObjects(); + for (const auto &stream : streams) { + for (auto root : roots) { + auto mo = root->metaObject(); + qDebug() << "feeding..." << stream.id << fd; + mo->invokeMethod(root, + "addStream", + Q_ARG(QVariant, QVariant::fromValue(stream.id)), + Q_ARG(QVariant, m_handleToken), + Q_ARG(QVariant, fd), + Q_ARG(QVariant, true)); + } + } +} + +void RecordMe::setPersistMode(PersistMode persistMode) +{ + m_persistMode = persistMode; +} + +void RecordMe::setRestoreToken(const QString &restoreToken) +{ + m_restoreToken = restoreToken; +} + +void RecordMe::setDuration(int duration) +{ + m_durationTimer->setInterval(duration); +} + +#include "moc_RecordMe.cpp" diff --git a/tests/RecordMe.h b/tests/RecordMe.h new file mode 100644 index 0000000..94f79b6 --- /dev/null +++ b/tests/RecordMe.h @@ -0,0 +1,68 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include +#include + +class QTimer; +class QQmlApplicationEngine; + +struct Stream { + uint id; + QVariantMap opts; +}; + +class OrgFreedesktopPortalScreenCastInterface; + +class RecordMe : public QObject +{ + Q_OBJECT +public: + RecordMe(QObject* parent = nullptr); + ~RecordMe() override; + + enum CursorModes { + Hidden = 1, + Embedded = 2, + Metadata = 4 + }; + Q_ENUM(CursorModes); + + enum SourceTypes { + Monitor = 1, + Window = 2 + }; + Q_ENUM(SourceTypes); + + enum PersistMode { + NoPersist = 0, + PersistWhileRunning = 1, + PersistUntilRevoked = 2, + }; + Q_ENUM(PersistMode) + + void setDuration(int duration); + void setPersistMode(PersistMode persistMode); + void setRestoreToken(const QString &restoreToken); + +public Q_SLOTS: + void response(uint code, const QVariantMap &results); + +private: + void init(const QDBusObjectPath &path); + void handleStreams(const QList &streams); + void start(); + + OrgFreedesktopPortalScreenCastInterface *iface; + QDBusObjectPath m_path; + QTimer* const m_durationTimer; + const QString m_handleToken; + QQmlApplicationEngine* m_engine; + PersistMode m_persistMode = NoPersist; + QString m_restoreToken; +}; diff --git a/tests/RegionSelector.qml b/tests/RegionSelector.qml new file mode 100644 index 0000000..a6b8329 --- /dev/null +++ b/tests/RegionSelector.qml @@ -0,0 +1,45 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +import QtQuick 2.15 +import QtQuick.Window 2.15 + +Item +{ + Rectangle { + anchors.fill: parent + color: "black" + opacity: 0.1 + } + anchors.fill: parent + required property QtObject app + + MouseArea { + anchors.fill: parent + onPressed: app.setRegionPressed(Screen.name, mouse.x, mouse.y) + onReleased: { + app.setRegionReleased(Screen.name, mouse.x, mouse.y) + } + readonly property point mousePosition: Qt.point(mouseX, mouseY) + onMousePositionChanged: { + app.setRegionMoved(Screen.name, mouseX, mouseY) + } + } + + Rectangle { + color: "blue" + opacity: 0.5 + x: app.region.x - Screen.virtualX + y: app.region.y - Screen.virtualY + width: app.region.width + height: app.region.height + } + + Keys.onEscapePressed: { + Qt.quit() + } +} + diff --git a/tests/main.cpp b/tests/main.cpp new file mode 100644 index 0000000..1b7d5d0 --- /dev/null +++ b/tests/main.cpp @@ -0,0 +1,44 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "PlasmaRecordMe.h" +#include +#include + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + { + QCommandLineParser parser; + QCommandLineOption duration(QStringLiteral("duration"), QStringLiteral("seconds length of the video"), QStringLiteral("duration")); + const QMap cursorOptions = { + {QStringLiteral("hidden"), Screencasting::CursorMode::Hidden}, + {QStringLiteral("embedded"), Screencasting::CursorMode::Embedded}, + {QStringLiteral("metadata"), Screencasting::CursorMode::Metadata}, + }; + + QCommandLineOption cursor(QStringLiteral("cursor"), + QStringList(cursorOptions.keys()).join(QStringLiteral(", ")), + QStringLiteral("mode"), + QStringLiteral("metadata")); + + QCommandLineOption selection(QStringLiteral("selection"), QStringLiteral("Select a region to show")); + parser.addPositionalArgument(QStringLiteral("source"), QStringLiteral("name of the output/window that you want to see")); + parser.addOption(duration); + parser.addOption(cursor); + parser.addOption(selection); + parser.addHelpOption(); + parser.process(app); + + PlasmaRecordMe *me = new PlasmaRecordMe(cursorOptions[parser.value(cursor).toLower()], parser.positionalArguments(), parser.isSet(selection), &app); + if (parser.isSet(duration)) { + me->setDuration(parser.value(duration).toInt() * 1000); + } + } + + return app.exec(); +} diff --git a/tests/main.qml b/tests/main.qml new file mode 100644 index 0000000..aa284ef --- /dev/null +++ b/tests/main.qml @@ -0,0 +1,100 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +import QtQuick 2.1 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.1 +import org.kde.kirigami 2.15 as Kirigami +import org.kde.taskmanager + +import org.kde.pipewire 0.1 as PipeWire + +Kirigami.ApplicationWindow +{ + id: root + width: 500 + height: 500 + visible: true + property QtObject app + + function addStream(nodeid, displayText, fd, allowDmaBuf) { + if (fd == null) + fd = 0; + rep.model.append({nodeId: nodeid, uuid: "", display: displayText, fd: fd, allowDmaBuf: allowDmaBuf }) + } + function removeStream(nodeid) { + for(var i=0; i { + app.addWindow(object.uuid, object.appId) + } + } + + ColumnLayout { + id: pipes + anchors.fill: parent + + Button { + text: "Add Virtual Monitor" + onClicked: app.createVirtualMonitor() + } + + Button { + text: "Add Region" + onClicked: app.requestSelection() + } + + ListView { + id: rep + + Layout.fillWidth: true + Layout.fillHeight: true + + clip: true + model: ListModel {} + delegate: RowLayout { + Kirigami.Icon { + source: sourceItem.usingDmaBuf ? "speedometer" : "delete" + } + + Button { + text: sourceItem.visible ? "Pause" : "Resume" + icon.name: sourceItem.visible ? "media-playback-pause" : "media-playback-start" + onClicked: sourceItem.visible = !sourceItem.visible; + } + + Label { + text: model.display + } + + PipeWire.PipeWireSourceItem { + id: sourceItem + + Layout.preferredWidth: Kirigami.Units.gridUnit * 16 + Layout.preferredHeight: Kirigami.Units.gridUnit * 8 + + nodeId: model.nodeId + fd: model.fd + allowDmaBuf: model.allowDmaBuf + } + } + } + } +} diff --git a/tests/org.freedesktop.portal.RemoteDesktop.xml b/tests/org.freedesktop.portal.RemoteDesktop.xml new file mode 100644 index 0000000..055e64d --- /dev/null +++ b/tests/org.freedesktop.portal.RemoteDesktop.xml @@ -0,0 +1,415 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.freedesktop.portal.ScreenCast.xml b/tests/org.freedesktop.portal.ScreenCast.xml new file mode 100644 index 0000000..6b7054f --- /dev/null +++ b/tests/org.freedesktop.portal.ScreenCast.xml @@ -0,0 +1,323 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/org.kde.kpipewireheadlesstest.desktop.cmake b/tests/org.kde.kpipewireheadlesstest.desktop.cmake new file mode 100644 index 0000000..1725a37 --- /dev/null +++ b/tests/org.kde.kpipewireheadlesstest.desktop.cmake @@ -0,0 +1,7 @@ +[Desktop Entry] +Name=PlasmaHeadlessTest +Exec=@CMAKE_INSTALL_PREFIX@/bin/kpipewireheadlesstest +Icon=camera-video +Type=Application +X-KDE-Wayland-Interfaces=zkde_screencast_unstable_v1 + diff --git a/tests/org.kde.recordme.desktop.cmake b/tests/org.kde.recordme.desktop.cmake new file mode 100644 index 0000000..7d6624e --- /dev/null +++ b/tests/org.kde.recordme.desktop.cmake @@ -0,0 +1,7 @@ +[Desktop Entry] +Name=RecordMe +Exec=@CMAKE_INSTALL_PREFIX@/bin/recordme +Icon=camera-video +Type=Application +X-KDE-Wayland-Interfaces=org_kde_plasma_window_management,zkde_screencast_unstable_v1 + diff --git a/tests/recordme.qrc b/tests/recordme.qrc new file mode 100644 index 0000000..2701a8a --- /dev/null +++ b/tests/recordme.qrc @@ -0,0 +1,11 @@ + + + + main.qml + RegionSelector.qml + + diff --git a/tests/screencasting.cpp b/tests/screencasting.cpp new file mode 100644 index 0000000..1407e86 --- /dev/null +++ b/tests/screencasting.cpp @@ -0,0 +1,147 @@ +/* + SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "screencasting.h" +#include "logging.h" +#include "qwayland-zkde-screencast-unstable-v1.h" +#include +#include +#include +#include +#include +#include +#include + +using namespace KWayland::Client; + +class ScreencastingStreamPrivate : public QtWayland::zkde_screencast_stream_unstable_v1 +{ +public: + ScreencastingStreamPrivate(ScreencastingStream *q) + : q(q) + { + } + ~ScreencastingStreamPrivate() + { + if (isInitialized()) { + close(); + } + q->deleteLater(); + } + + void zkde_screencast_stream_unstable_v1_created(uint32_t node) override + { + m_nodeId = node; + Q_EMIT q->created(node); + } + + void zkde_screencast_stream_unstable_v1_closed() override + { + Q_EMIT q->closed(); + } + + void zkde_screencast_stream_unstable_v1_failed(const QString &error) override + { + Q_EMIT q->failed(error); + } + + std::optional m_nodeId; + QPointer q; +}; + +ScreencastingStream::ScreencastingStream(QObject *parent) + : QObject(parent) + , d(new ScreencastingStreamPrivate(this)) +{ +} + +ScreencastingStream::~ScreencastingStream() = default; + +quint32 ScreencastingStream::nodeId() const +{ + Q_ASSERT(d->m_nodeId.has_value()); + return *d->m_nodeId; +} + +class ScreencastingPrivate : public QWaylandClientExtensionTemplate, public QtWayland::zkde_screencast_unstable_v1 +{ +public: + ScreencastingPrivate(Screencasting *q) + : QWaylandClientExtensionTemplate(ZKDE_SCREENCAST_UNSTABLE_V1_STREAM_REGION_SINCE_VERSION) + , q(q) + { + initialize(); + + if (!isInitialized()) { + qWarning() << "Remember requesting the interface on your desktop file: X-KDE-Wayland-Interfaces=zkde_screencast_unstable_v1"; + } + Q_ASSERT(isInitialized()); + } + + ~ScreencastingPrivate() + { + destroy(); + } + + Screencasting *const q; +}; + +Screencasting::Screencasting(QObject *parent) + : QObject(parent) + , d(new ScreencastingPrivate(this)) +{ +} + +Screencasting::~Screencasting() = default; + +ScreencastingStream *Screencasting::createOutputStream(const QString &outputName, Screencasting::CursorMode mode) +{ + for (auto screen : qGuiApp->screens()) { + if (screen->name() == outputName) { + return createOutputStream(screen, mode); + } + } + return nullptr; +} + +ScreencastingStream *Screencasting::createOutputStream(QScreen *screen, CursorMode mode) +{ + wl_output *output = (wl_output *)QGuiApplication::platformNativeInterface()->nativeResourceForScreen("output", screen); + auto stream = new ScreencastingStream(this); + stream->setObjectName(screen->name()); + stream->d->init(d->stream_output(output, mode)); + return stream; +} + +ScreencastingStream *Screencasting::createRegionStream(const QRect &geometry, qreal scaling, CursorMode mode) +{ + Q_ASSERT(d->QWaylandClientExtension::version() >= ZKDE_SCREENCAST_UNSTABLE_V1_STREAM_REGION_SINCE_VERSION); + auto stream = new ScreencastingStream(this); + stream->setObjectName(QStringLiteral("region-%1,%2 (%3x%4)").arg(geometry.x()).arg(geometry.y()).arg(geometry.width()).arg(geometry.height())); + stream->d->init(d->stream_region(geometry.x(), geometry.y(), geometry.width(), geometry.height(), wl_fixed_from_double(scaling), mode)); + return stream; +} + +ScreencastingStream *Screencasting::createWindowStream(const QString &uuid, CursorMode mode) +{ + auto stream = new ScreencastingStream(this); + stream->d->init(d->stream_window(uuid, mode)); + return stream; +} + +ScreencastingStream *Screencasting::createVirtualMonitorStream(const QString &name, const QSize &size, qreal scale, CursorMode mode) +{ + auto stream = new ScreencastingStream(this); + stream->d->init(d->stream_virtual_output(name, size.width(), size.height(), wl_fixed_from_double(scale), mode)); + return stream; +} + +void Screencasting::destroy() +{ + d.reset(nullptr); +} + +#include "moc_screencasting.cpp" diff --git a/tests/screencasting.h b/tests/screencasting.h new file mode 100644 index 0000000..8d50480 --- /dev/null +++ b/tests/screencasting.h @@ -0,0 +1,78 @@ +/* + SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include +#include +#include +#include + +#include + +class QScreen; +struct zkde_screencast_unstable_v1; + +namespace KWayland +{ +namespace Client +{ +class PlasmaWindow; +} +} + +class ScreencastingPrivate; +class ScreencastingSourcePrivate; +class ScreencastingStreamPrivate; +class KPIPEWIRE_EXPORT ScreencastingStream : public QObject +{ + Q_OBJECT +public: + ScreencastingStream(QObject *parent); + ~ScreencastingStream() override; + + quint32 nodeId() const; + +Q_SIGNALS: + void created(quint32 nodeid); + void failed(const QString &error); + void closed(); + +private: + friend class Screencasting; + QScopedPointer d; +}; + +class KPIPEWIRE_EXPORT Screencasting : public QObject +{ + Q_OBJECT +public: + explicit Screencasting(QObject *parent = nullptr); + ~Screencasting() override; + + enum CursorMode { + Hidden = 1, + Embedded = 2, + Metadata = 4, + }; + Q_ENUM(CursorMode); + + ScreencastingStream *createOutputStream(const QString &outputName, CursorMode mode); + ScreencastingStream *createOutputStream(QScreen *screen, CursorMode mode); + ScreencastingStream *createRegionStream(const QRect ®ion, qreal scaling, CursorMode mode); + ScreencastingStream *createWindowStream(const QString &uuid, CursorMode mode); + ScreencastingStream *createVirtualMonitorStream(const QString &name, const QSize &size, qreal scale, CursorMode mode); + + void destroy(); + +Q_SIGNALS: + void initialized(); + void removed(); + void sourcesChanged(); + +private: + QScopedPointer d; +}; diff --git a/tests/screencastingrequest.cpp b/tests/screencastingrequest.cpp new file mode 100644 index 0000000..bfc9042 --- /dev/null +++ b/tests/screencastingrequest.cpp @@ -0,0 +1,105 @@ +/* + SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "screencastingrequest.h" +#include "logging.h" + +#include +#include +#include +#include + +struct ScreencastingRequestPrivate { + QPointer m_stream; + QString m_uuid; + QString m_outputName; + quint32 m_nodeId = 0; +}; + +ScreencastingRequest::ScreencastingRequest(QObject *parent) + : QObject(parent) + , d(new ScreencastingRequestPrivate) +{ +} + +ScreencastingRequest::~ScreencastingRequest() = default; + +quint32 ScreencastingRequest::nodeId() const +{ + return d->m_nodeId; +} + +void ScreencastingRequest::setUuid(const QString &uuid) +{ + if (d->m_uuid == uuid) { + return; + } + + d->m_stream->deleteLater(); + setNodeid(0); + + d->m_uuid = uuid; + Q_EMIT uuidChanged(uuid); + + if (!d->m_uuid.isEmpty()) { + auto screencasting = new Screencasting(this); + auto stream = screencasting->createWindowStream(d->m_uuid, Screencasting::CursorMode::Hidden); + adopt(stream); + } +} + +void ScreencastingRequest::setOutputName(const QString &outputName) +{ + if (d->m_outputName == outputName) { + return; + } + + setNodeid(0); + d->m_outputName = outputName; + Q_EMIT outputNameChanged(outputName); + + if (!d->m_outputName.isEmpty()) { + auto screencasting = new Screencasting(this); + auto stream = screencasting->createOutputStream(d->m_outputName, Screencasting::CursorMode::Hidden); + adopt(stream); + stream->setObjectName(d->m_outputName); + } +} + +void ScreencastingRequest::adopt(ScreencastingStream *stream) +{ + connect(stream, &ScreencastingStream::created, this, &ScreencastingRequest::setNodeid); + connect(stream, &ScreencastingStream::failed, this, [](const QString &error) { + qWarning() << "error creating screencast" << error; + }); + connect(stream, &ScreencastingStream::closed, this, [this, stream] { + if (stream->nodeId() == d->m_nodeId) { + setNodeid(0); + } + }); +} + +void ScreencastingRequest::setNodeid(uint nodeId) +{ + if (nodeId == d->m_nodeId) { + return; + } + + d->m_nodeId = nodeId; + Q_EMIT nodeIdChanged(nodeId); +} + +QString ScreencastingRequest::uuid() const +{ + return d->m_uuid; +} + +QString ScreencastingRequest::outputName() const +{ + return d->m_outputName; +} + +#include "moc_screencastingrequest.cpp" diff --git a/tests/screencastingrequest.h b/tests/screencastingrequest.h new file mode 100644 index 0000000..8d6c23c --- /dev/null +++ b/tests/screencastingrequest.h @@ -0,0 +1,64 @@ +/* + SPDX-FileCopyrightText: 2020 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#pragma once + +#include "screencasting.h" +#include + +#include + +class ScreencastingStream; +struct ScreencastingRequestPrivate; + +/** + * Allows us to request a stream for a window identified by its universally + * unique identifier. + * + * We will get a PipeWire node id that can be fed to any pipewire player, be it + * the PipeWireSourceItem, GStreamer's pipewiresink or any other. + */ +class KPIPEWIRE_EXPORT ScreencastingRequest : public QObject +{ + Q_OBJECT + /** + * The unique identifier of the window we want to cast. + * + * @see PlasmaWindow::uuid + * @see PlasmaWindow::stackingOrderUuids + * @see PlasmaWindowModel::Uuid + * @see TasksModel::WinIdList + */ + Q_PROPERTY(QString uuid READ uuid WRITE setUuid NOTIFY uuidChanged) + + /** + * The output name as define in Screen.name + */ + Q_PROPERTY(QString outputName READ outputName WRITE setOutputName NOTIFY outputNameChanged) + + /** The offered nodeId to give to a source */ + Q_PROPERTY(quint32 nodeId READ nodeId NOTIFY nodeIdChanged) +public: + ScreencastingRequest(QObject *parent = nullptr); + ~ScreencastingRequest(); + + void setUuid(const QString &uuid); + QString uuid() const; + void setOutputName(const QString &outputName); + QString outputName() const; + quint32 nodeId() const; + +Q_SIGNALS: + void nodeIdChanged(quint32 nodeId); + void uuidChanged(const QString &uuid); + void outputNameChanged(const QString &outputNames); + +private: + void adopt(ScreencastingStream *stream); + void setNodeid(uint nodeId); + + QScopedPointer d; +}; diff --git a/tests/webcamtest.cpp b/tests/webcamtest.cpp new file mode 100644 index 0000000..7bf7e46 --- /dev/null +++ b/tests/webcamtest.cpp @@ -0,0 +1,26 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include +#include +#include + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + { + QCommandLineParser parser; + parser.addHelpOption(); + parser.process(app); + + auto engine = new QQmlApplicationEngine(&app); + QObject::connect(engine, &QQmlEngine::quit, qGuiApp, &QCoreApplication::quit); + engine->load(QUrl(QStringLiteral("qrc:/webcamtest.qml"))); + } + + return app.exec(); +} diff --git a/tests/webcamtest.qml b/tests/webcamtest.qml new file mode 100644 index 0000000..55bca98 --- /dev/null +++ b/tests/webcamtest.qml @@ -0,0 +1,61 @@ +/* + SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import org.kde.kirigami as Kirigami +import org.kde.pipewire.monitor as PWMonitor +import org.kde.pipewire as PipeWire +import org.kde.pipewire.record as PWR + +Kirigami.ApplicationWindow +{ + id: root + width: 500 + height: 500 + visible: true + property QtObject app + + pageStack.initialPage: Kirigami.Page { + ColumnLayout { + anchors.fill: parent + + Repeater { + id: rep + model: PWMonitor.MediaMonitor { + role: PWMonitor.MediaMonitor.Camera + } + + delegate: Item { + Layout.fillWidth: true + Layout.fillHeight: true + PipeWire.PipeWireSourceItem { + nodeId: model.objectSerial + fd: model.fd + anchors.fill: parent + } + + Label { + text: model.display + " xxx " + model.objectSerial + } + PWR.PipeWireRecord { + id: rec + nodeId: model.objectSerial + fd: model.fd + active: recButton.checked + output: "/tmp/banana.webm" + } + Button { + id: recButton + icon.name: "media-record" + checkable: true + } + } + } + } + } +} diff --git a/tests/webcamtest.qrc b/tests/webcamtest.qrc new file mode 100644 index 0000000..9579c54 --- /dev/null +++ b/tests/webcamtest.qrc @@ -0,0 +1,10 @@ + + + + webcamtest.qml + + diff --git a/tests/xdp-main.cpp b/tests/xdp-main.cpp new file mode 100644 index 0000000..0b6e404 --- /dev/null +++ b/tests/xdp-main.cpp @@ -0,0 +1,46 @@ +/* + SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "RecordMe.h" +#include +#include + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + { + QCommandLineParser parser; + QCommandLineOption duration(QStringLiteral("duration"), QStringLiteral("seconds length of the video"), QStringLiteral("duration")); + parser.addOption(duration); + + QCommandLineOption persistMode(QStringLiteral("persistMode"), + QStringLiteral("persistMode. Integer value as per the DBus specification"), + QStringLiteral("persistMode")); + parser.addOption(persistMode); + + QCommandLineOption restoreToken(QStringLiteral("restoreToken"), QStringLiteral("Restore token"), QStringLiteral("restoreToken")); + parser.addOption(restoreToken); + + parser.addHelpOption(); + parser.process(app); + + RecordMe *me = new RecordMe(&app); + if (parser.isSet(duration)) { + me->setDuration(parser.value(duration).toInt() * 1000); + } + if (parser.isSet(persistMode)) { + int rawPersitValue = parser.value(persistMode).toInt(); + auto mode = static_cast(rawPersitValue); + me->setPersistMode(mode); + } + if (parser.isSet(restoreToken)) { + me->setRestoreToken(parser.value(restoreToken)); + } + } + + return app.exec(); +} -- 2.30.2