Merge branch 'feat/flatpak'

This commit is contained in:
Guillaume Meunier
2024-08-31 13:39:24 +02:00
12 changed files with 263 additions and 124 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ jobs:
# TODO: replace with version > v6.3 when it's released
- uses: flatpak/flatpak-github-actions/flatpak-builder@b8be6bc0ede43cb3a2cc55895654312b14f84a0d
with:
manifest-path: flatpak/org.meumeu.wivrn-server.yml
manifest-path: flatpak/io.github.wivrn.wivrn.yml
bundle: wivrn-server.flatpak
upload-artifact: false
+13 -1
View File
@@ -26,7 +26,8 @@ include("cmake/AutoOption.cmake")
option(WIVRN_USE_SYSTEM_FREETYPE "Use system FreeType" ON)
auto_option(WIVRN_USE_SYSTEM_BOOST "Use system Boost headers" AUTO)
auto_option(WIVRN_USE_SYSTEM_OPENXR "Use system OpenXR headers" AUTO)
auto_option(WIVRN_USE_SYSTEMD "Use libsystemd, required to show pretty hostname" AUTO)
auto_option(WIVRN_USE_SYSTEMD "Use libsystemd, either libsystemd or glib is required to show pretty hostname" AUTO)
auto_option(WIVRN_USE_GLIB "Use glib, required to show pretty hostname inside a flatpak container" OFF)
option(WIVRN_USE_ANDROID_VALIDATION_LAYER "Download the android version of the Vulkan validation layer" OFF)
option(WIVRN_BUILD_CLIENT "Build WiVRn client" OFF)
option(WIVRN_BUILD_SERVER "Build WiVRn server" ON)
@@ -140,6 +141,17 @@ if (WIVRN_BUILD_SERVER)
find_package(Eigen3 REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(CLI11 REQUIRED)
if (WIVRN_USE_GLIB STREQUAL "AUTO")
pkg_check_modules(glib2 IMPORTED_TARGET glib-2.0 gio-2.0)
if(glib2_FOUND)
set(WIVRN_USE_GLIB ON)
else()
set(WIVRN_USE_GLIB OFF)
endif()
elseif (WIVRN_USE_GLIB)
pkg_check_modules(glib2 REQUIRED IMPORTED_TARGET glib-2.0 gio-2.0)
endif()
endif()
if (WIVRN_BUILD_CLIENT AND NOT ANDROID)
+2 -2
View File
@@ -57,11 +57,11 @@ task "generatePngs"() {
}
android {
namespace "org.meumeu.wivrn"
namespace "io.github.wivrn.client"
ndkVersion "26.1.10909125"
defaultConfig {
applicationId "org.meumeu.wivrn"
applicationId "io.github.wivrn.client"
// for Vulkan, need at least 24
// for AImage_getHardwareBuffer, API 26
minSdkVersion 29
+1
View File
@@ -24,6 +24,7 @@
#cmakedefine WIVRN_USE_X264
#cmakedefine WIVRN_USE_SYSTEMD
#cmakedefine WIVRN_USE_GLIB
#cmakedefine WIVRN_USE_PIPEWIRE
#cmakedefine WIVRN_USE_PULSEAUDIO
+9
View File
@@ -0,0 +1,9 @@
[Desktop Entry]
Name=WiVRn server
Comment=Play your PC VR games on a standalone headset
GenericName=WiVRn server
Exec=launch-wivrn-server
Icon=io.github.wivrn.wivrn
Type=Application
Categories=ConsoleOnly
Terminal=true
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="console-application">
<id>io.github.wivrn.wivrn</id>
<name>WiVRn server</name>
<metadata_license>FSFAP</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<summary>Play your PC VR games on a standalone headset</summary>
<description>
<p>WiVRn allows you to run your VR games from your PC and play them from a standalone headset.</p>
<p>You will need to install the WiVRn client on your headset from the APK on Github.</p>
<p>Supported headsets:</p>
<ul>
<li>Meta Quest 1</li>
<li>Meta Quest 2</li>
<li>Meta Quest 3</li>
<li>Meta Quest Pro</li>
<li>Pico Neo 3</li>
<li>Pico Neo 4</li>
<li>HTC Vive Focus 3</li>
<li>HTC Vive XR Elite</li>
</ul>
<p>Features:</p>
<ul>
<li>Supports OpenXR and OpenVR applications</li>
<li>Controller tracking, hand tracking, eye gaze tracking (if supported by the headset)</li>
<li>Audio streaming and microphone</li>
<li>Video streaming with H264 / HEVC compression</li>
<li>Hardware accelerated compression with VAAPI or NVENC</li>
<li>Software compression with x264</li>
</ul>
</description>
<developer id="io.github.wivrn.wivrn">
<name>Guillaume Meunier, Patrick Nicolas et al</name>
</developer>
<branding>
<color type="primary" scheme_preference="light">#F6F5F5</color>
<color type="primary" scheme_preference="dark">#424242</color>
</branding>
<launchable type="desktop-id">io.github.wivrn.wivrn.desktop</launchable>
<url type="homepage">https://wivrn.github.io</url>
<url type="vcs-browser">https://www.github.com/WiVRn/WiVRn</url>
<url type="bugtracker">https://github.com/WiVRn/WiVRn/issues</url>
<icon type="stock">io.github.wivrn.wivrn</icon>
<provides>
<binary>launch-wivrn-server</binary>
</provides>
<content_rating type="oars-1.1" />
<releases>
<release version="0.18" date="2024-08-13">
<url type="details">https://github.com/WiVRn/WiVRn/releases/tag/v0.18</url>
<description>
<ul>
<li>The standard APK is now compatible with Pico headsets</li>
<li>Fixes for position on start and reconnect</li>
<li>Support for EXT_eye_gaze_interaction by @galister</li>
<li>Better support for libmonado, now discoverable in manifest</li>
<li>Server can now be distributed as a flatpak</li>
</ul>
</description>
</release>
<release version="0.17" date="2024-07-14">
<url type="details">https://github.com/WiVRn/WiVRn/releases/tag/v0.17</url>
<description>
<ul>
<li>Add systemd hardening options by @Pandapip1</li>
<li>update monado to 24.0.0 by @galister</li>
<li>Update building doc by @SanyaNya</li>
<li>Multiple tweaks for controller tracking, audio resync</li>
<li>Minor performance improvements</li>
</ul>
</description>
</release>
</releases>
</component>
@@ -1,19 +1,42 @@
id: org.meumeu.wivrn-server
id: io.github.wivrn.wivrn
runtime: org.freedesktop.Platform
runtime-version: '23.08'
sdk: org.freedesktop.Sdk
command: launch-wivrn-server
add-extensions:
org.freedesktop.Platform.VAAPI.Intel:
version: '23.08'
directory: lib/dri
add-ld-path: lib
subdirectories: true
no-autodownload: true
autodelete: true
cleanup-commands:
- mkdir -p ${FLATPAK_DEST}/lib/dri
finish-args:
# X11 + XShm access
- --share=ipc
- --socket=fallback-x11
# Wayland access
- --socket=wayland
# GPU acceleration
- --device=dri
# Needs to talk to the network
- --share=network
# Announce WiVRn via avahi
- --system-talk-name=org.freedesktop.Avahi
# Allow getting the pretty hostname
- --system-talk-name=org.freedesktop.hostname1
# Pipewire
- --filesystem=xdg-run/pipewire-0
# Set the active OpenXR / OpenVR runtime
- --filesystem=xdg-config/openxr:create
- --filesystem=xdg-config/openvr:create
# Let outside application access the WiVRn socket
- --filesystem=xdg-run/wivrn:create
cleanup:
- /lib/pkgconfig
- /share/pkgconfig
- /include
- /share/man
- /share/cmake
- /share/gir-1.0
- /lib/girepository-1.0
- /lib/systemd
- '*.a'
- '*.la'
modules:
- name: libavahi-client
@@ -72,7 +95,9 @@ modules:
- make install
cleanup:
- /share/ffmpeg
- /bin/ffmpeg
- /bin/ffplay
- /bin/ffprobe
sources:
- type: git
url: https://gitlab.com/freedesktop-sdk/mirrors/ffmpeg/ffmpeg.git
@@ -122,6 +147,7 @@ modules:
- -DWIVRN_USE_X264=ON
- -DWIVRN_USE_NVENC=ON
- -DWIVRN_USE_PULSEAUDIO=OFF
- -DWIVRN_USE_GLIB=ON
- -DFETCHCONTENT_FULLY_DISCONNECTED=ON
- -DFETCHCONTENT_BASE_DIR=deps
- -DXRT_IPC_MSG_SOCK_FILENAME=wivrn/comp_ipc
@@ -157,7 +183,7 @@ modules:
- name: launcher
buildsystem: simple
build-commands:
- install -Dm755 launch-wivrn-server.sh ${FLATPAK_DEST}/bin/launch-wivrn-server
- install -Dm755 launch-wivrn-server.sh ${FLATPAK_DEST}/bin/launch-wivrn-server
sources:
- type: script
dest-filename: launch-wivrn-server.sh
@@ -166,46 +192,3 @@ modules:
- sed -ne 's#app-path=\(.*\)#{"runtime":["\1/OpenComposite"],"version":1}#p' /.flatpak-info > $XDG_CONFIG_HOME/openvr/openvrpaths.vrpath
- chmod -w $XDG_CONFIG_HOME/openvr/openvrpaths.vrpath
- wivrn-server
- name: appdata
buildsystem: simple
build-commands:
- install -Dm644 org.meumeu.wivrn-server.appdata.xml -t ${FLATPAK_DEST}/share/appdata
sources:
- type: file
path: org.meumeu.wivrn-server.appdata.xml
cleanup:
- /lib/pkgconfig
- /share/pkgconfig
- /include
- /share/man
- /share/cmake
- /share/gir-1.0
- /lib/girepository-1.0
- /lib/systemd
- '*.a'
- '*.la'
finish-args:
# X11 + XShm access
- --share=ipc
- --socket=fallback-x11
# Wayland access
- --socket=wayland
# GPU acceleration if needed
- --device=dri
# Needs to talk to the network
- --share=network
# Announce WiVRn via avahi
# - --system-talk-name=org.freedesktop.Avahi
# Allow getting the pretty hostname
# - --system-talk-name=org.freedesktop.hostname1
- --socket=system-bus # workaround bug between sd-bus (https://github.com/systemd/systemd/issues/16610) and xdg-dbus-proxy (https://github.com/flatpak/xdg-dbus-proxy/issues/21)
# Pipewire
- --filesystem=xdg-run/pipewire-0
# Set the active OpenXR / OpenVR runtime
- --filesystem=xdg-config/openxr:create
- --filesystem=xdg-config/openvr:create
# Let outside application access the WiVRn socket
- --filesystem=xdg-run/wivrn:create
@@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="console-application">
<id>org.meumeu.wivrn-server</id>
<name>WiVRn server</name>
<metadata_license>FSFAP</metadata_license>
<project_license>GPL-3.0+</project_license>
<summary>The WiVRn server</summary>
<description><p>Server component of the WiVRn OpenXR streaming system</p></description>
<developer id="org.meumeu.wivrn-server">
<name>Guillaume Meunier, Patrick Nicolas et al</name>
</developer>
<!-- <launchable type="desktop-id">org.meumeu.wivrn-server.desktop</launchable> -->
<url type="homepage">https://www.github.org/Meumeu/WiVRn</url>
<provides>
<binary>launch-wivrn-server</binary>
</provides>
<content_rating type="oars-1.1" />
<releases>
<release version="0.18" date="2024-08-13">
<url type="details">https://github.com/Meumeu/WiVRn/releases/tag/v0.18</url>
<description>
<ul>
<li>The standard APK is now compatible with Pico headsets</li>
<li>Fixes for position on start and reconnect</li>
<li>Support for EXT_eye_gaze_interaction by @galister</li>
<li>Better support for libmonado, now discoverable in manifest</li>
<li>Server can now be distributed as a flatpak</li>
</ul>
</description>
</release>
<release version="0.17" date="2024-07-14">
<url type="details">https://github.com/Meumeu/WiVRn/releases/tag/v0.17</url>
<description>
<ul>
<li>Add systemd hardening options by @Pandapip1</li>
<li>update monado to 24.0.0 by @galister</li>
<li>Update building doc by @SanyaNya</li>
<li>Multiple tweaks for controller tracking, audio resync</li>
<li>Minor performance improvements</li>
</ul>
</description>
</release>
</releases>
</component>
-9
View File
@@ -1,9 +0,0 @@
[Desktop Entry]
Name=WiVRn server
Comment=TBD
GenericName=TBD
Exec=launch-wivrn-server
Icon=org.meumeu.wivrn
Type=Application
Categories=ConsoleOnly
Keywords=wivrn;
+19 -2
View File
@@ -164,6 +164,10 @@ target_link_libraries(
nlohmann_json::nlohmann_json
)
if(WIVRN_USE_GLIB)
target_link_libraries( wivrn-server PRIVATE PkgConfig::glib2)
endif()
configure_file(dist/wivrn.service.in wivrn.service)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/wivrn.service
DESTINATION lib/systemd/user/)
@@ -182,9 +186,9 @@ set_target_properties(${RUNTIME_TARGET} PROPERTIES EXCLUDE_FROM_ALL FALSE)
set(_extra_args)
if(WIVRN_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH)
set(_extra_args ABSOLUTE_RUNTIME_PATH)
set(_extra_args ABSOLUTE_RUNTIME_PATH)
else()
set(_extra_args RUNTIME_DIR_RELATIVE_TO_MANIFEST ../../../${CMAKE_INSTALL_LIBDIR}/wivrn)
set(_extra_args RUNTIME_DIR_RELATIVE_TO_MANIFEST ../../../${CMAKE_INSTALL_LIBDIR}/wivrn)
endif()
generate_openxr_runtime_manifest_at_install(
@@ -199,3 +203,16 @@ install(TARGETS ${RUNTIME_TARGET} monado
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}/wivrn
COMPONENT Runtime)
install(FILES ../flatpak/io.github.wivrn.wivrn.metainfo.xml
DESTINATION share/metainfo
)
install(FILES ../images/wivrn.svg
DESTINATION share/icons/hicolor/scalable/apps
RENAME io.github.wivrn.wivrn.svg
)
install(FILES ../flatpak/io.github.wivrn.wivrn.desktop
DESTINATION share/applications
)
+58 -3
View File
@@ -5,13 +5,61 @@
#include "util/u_logging.h"
#include "wivrn_config.h"
#ifdef WIVRN_USE_SYSTEMD
#ifdef WIVRN_USE_GLIB
#include <gio/gio.h>
#elif defined(WIVRN_USE_SYSTEMD)
#include <systemd/sd-bus.h>
#endif
std::string hostname()
static std::string _hostname()
{
#ifdef WIVRN_USE_SYSTEMD
#ifdef WIVRN_USE_GLIB
GError * error = NULL;
GDBusConnection * con = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (!con)
{
U_LOG_W("Failed to connect to system bus: %s", error->message);
}
else
{
for (auto property: {"PrettyHostname", "StaticHostname", "Hostname"})
{
GVariant * result = g_dbus_connection_call_sync(con,
"org.freedesktop.hostname1",
"/org/freedesktop/hostname1",
"org.freedesktop.DBus.Properties",
"Get",
g_variant_new("(ss)", "org.freedesktop.hostname1", property),
G_VARIANT_TYPE("(v)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
if (error)
continue;
GVariant * property_value;
g_variant_get(result, "(v)", &property_value);
const char * hostname = g_variant_get_string(property_value, NULL);
if (hostname && strcmp(hostname, ""))
{
std::string s = hostname;
g_variant_unref(property_value);
g_variant_unref(result);
g_object_unref(con);
return s;
}
g_variant_unref(property_value);
g_variant_unref(result);
}
g_object_unref(con);
}
#elif defined(WIVRN_USE_SYSTEMD)
sd_bus * bus;
if (sd_bus_default_system(&bus) < 0)
{
@@ -52,3 +100,10 @@ std::string hostname()
U_LOG_W("Failed to get hostname");
return "no-hostname";
}
std::string hostname()
{
// Accessing hostname in child process fails with glib
static std::string result = _hostname();
return result;
}
+38 -1
View File
@@ -18,6 +18,7 @@
#include "wivrn_sockets.h"
#include <CLI/CLI.hpp>
#include <filesystem>
#include <iostream>
#include <memory>
#include <poll.h>
@@ -123,11 +124,47 @@ void waitpid_verbose(pid_t pid, const std::string & name)
}
}
static std::filesystem::path flatpak_app_path()
{
const std::string key("app-path=");
std::string line;
std::ifstream info("/.flatpak-info");
while (std::getline(info, line))
{
if (line.starts_with(key))
{
std::filesystem::path path = line.substr(key.size());
while (path != "" and path != path.parent_path() and path.filename() != "io.github.wivrn.wivrn")
path = path.parent_path();
return path;
}
}
return "/";
}
static std::string steam_command()
{
std::string pressure_vessel_filesystems_rw = "$XDG_RUNTIME_DIR/" XRT_IPC_MSG_SOCK_FILENAME;
// Check if in a flatpak
if (std::filesystem::exists("/.flatpak-info"))
{
std::string app_path = flatpak_app_path().string();
// /usr and /var are remapped by steam
if (app_path.starts_with("/usr") or app_path.starts_with("/var"))
pressure_vessel_filesystems_rw += ":" + app_path;
}
return "PRESSURE_VESSEL_FILESYSTEMS_RW=" + pressure_vessel_filesystems_rw + " %command%";
}
int inner_main(int argc, char * argv[], bool use_systemd)
{
std::cerr << "WiVRn " << xrt::drivers::wivrn::git_version << " starting" << std::endl;
std::string command = "PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/" XRT_IPC_MSG_SOCK_FILENAME " %command%";
std::string command = steam_command();
if (auto p = active_runtime::manifest_path().string(); p.starts_with("/usr"))
command = "XR_RUNTIME_JSON=/run/host" + p + " " + command;