Skip to content

Commit

Permalink
vcap/pipewire: Buildable without screencast dbus portal stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiatka committed Oct 5, 2023
1 parent 4015350 commit 1cbb716
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
18 changes: 14 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1887,8 +1887,10 @@ if test $pipewire_video_req != no -a $pipewire_common = yes
then
pipewire_video=yes
PIPEWIRE_DISP_OBJS="$PIPEWIRE_COMMON_OBJ src/video_display/pipewire.o"
PIPEWIRE_CAP_OBJS="$PIPEWIRE_COMMON_OBJ src/video_capture/pipewire.o"
PIPEWIRE_CAP_LIBS="$PIPEWIRE_LIBS"
add_module display_pipewire "$PIPEWIRE_DISP_OBJS" "$PIPEWIRE_LIBS"
#TODO: Make pipewire capture buildable without the dbus screencap portal stuff and add it here
#vcap_pipewire module added after screen
fi

if test $pipewire_video_req = yes && test $pipewire_video = no; then
Expand Down Expand Up @@ -1957,18 +1959,20 @@ if test $screen_cap_req != no && test $screen_cap_req != x11; then
PKG_CHECK_MODULES([SCREEN_PW_DEPS], [glib-2.0 gobject-2.0 gio-unix-2.0 ], [found_screen_screen_pw_deps=yes], [found_screen_screen_pw_deps=no])
fi

if test $found_screen_screen_pw_deps = yes && test $pipewire_common = yes; then
if test $found_screen_screen_pw_deps = yes && test $pipewire_video = yes; then
screen_cap=yes
screen_cap_pw=yes
SCREEN_CAP_PIPEWIRE_LIBS="$($PKG_CONFIG --libs glib-2.0) $($PKG_CONFIG --libs gobject-2.0) $($PKG_CONFIG --libs gio-2.0) $($PKG_CONFIG --libs gio-unix-2.0)"

SCREEN_CAP_PIPEWIRE_INC="$($PKG_CONFIG --cflags-only-I glib-2.0) $($PKG_CONFIG --cflags-only-I gobject-2.0) $($PKG_CONFIG --cflags-only-I gio-2.0) $($PKG_CONFIG --cflags-only-I gio-unix-2.0)"
SCREEN_CAP_PIPEWIRE_OBJ="$PIPEWIRE_COMMON_OBJ src/video_capture/pipewire.o src/utils/dbus_portal.o"

INC="$INC $SCREEN_CAP_PIPEWIRE_INC"
CXXFLAGS="$CXXFLAGS $SCREEN_CAP_PIPEWIRE_INC"
AC_DEFINE([HAVE_DBUS_SCREENCAST], [1], [Build with pipewire screencast dbus support])

PIPEWIRE_CAP_LIBS="$PIPEWIRE_CAP_LIBS $SCREEN_CAP_PIPEWIRE_LIBS"
PIPEWIRE_CAP_OBJS="$PIPEWIRE_CAP_OBJS src/utils/dbus_portal.o"

add_module vidcap_screen_pipewire "$SCREEN_CAP_PIPEWIRE_OBJ" "$SCREEN_CAP_PIPEWIRE_LIBS"
screen_modules="${screen_modules:+$screen_modules,}pipewire"
fi

Expand Down Expand Up @@ -1997,6 +2001,12 @@ if test -n "$screen_modules"; then
screen_modules=" ($screen_modules)"
fi

if test $pipewire_video = yes
then
add_module vidcap_pipewire "$PIPEWIRE_CAP_OBJS" "$PIPEWIRE_CAP_LIBS"
fi


# -------------------------------------------------------------------------------------------------
# GLSL DXT
# -------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/Linux-AppImage/AppRun
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ setup_wayland
# ultragrid_aplay_jack.so is not used because it loads JACK with dlopen,
# while portaudio is linked directly to JACK library
set_ld_preload ultragrid_aplay_portaudio.so libjack
set_ld_preload ultragrid_vidcap_screen_pipewire.so libpipewire
set_ld_preload ultragrid_vidcap_pipewire.so libpipewire

if [ -n "${ULTRAGRID_USE_FIREJAIL-}" ] && [ "$ULTRAGRID_USE_FIREJAIL" != 0 ] && [ "$ULTRAGRID_USE_FIREJAIL" != no ]; then
command -v firejail >/dev/null || { echo "Firejail not present in system!"; exit 1; }
Expand Down
3 changes: 2 additions & 1 deletion src/utils/dbus_portal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/


#include <algorithm>
#include <string>
#include <memory>
Expand All @@ -51,9 +52,9 @@

#include "debug.h"
#include "misc.h"

#include "dbus_portal.hpp"


#define MOD_NAME "[dbus] "

namespace {
Expand Down
7 changes: 7 additions & 0 deletions src/utils/dbus_portal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@
#ifndef DBUS_PORTAL_HPP_511c58c91818
#define DBUS_PORTAL_HPP_511c58c91818

#include "config.h"

#ifdef HAVE_DBUS_SCREENCAST

#include <memory>
#include <string>
#include <thread>
#include <stdint.h>


class ScreenCastPortal_impl;

struct ScreenCastPortalResult{
Expand All @@ -62,4 +67,6 @@ class ScreenCastPortal{
std::thread thread;
};

#endif //HAVE_DBUS_SCREENCAST

#endif
11 changes: 10 additions & 1 deletion src/video_capture/pipewire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"

#include <stdlib.h>
#include <string.h>
#include <iostream>
Expand Down Expand Up @@ -85,8 +87,9 @@ struct screen_cast_session {

video_desc desc = {};


#ifdef HAVE_DBUS_SCREENCAST
ScreenCastPortal portal;
#endif

struct {
bool show_cursor = false;
Expand Down Expand Up @@ -511,6 +514,7 @@ static int parse_params(struct vidcap_params *params, screen_cast_session &sessi
return VIDCAP_INIT_OK;
}

#ifdef HAVE_DBUS_SCREENCAST
static int vidcap_screen_pw_init(struct vidcap_params *params, void **state)
{
if (vidcap_params_get_flags(params) & VIDCAP_FLAG_AUDIO_ANY) {
Expand Down Expand Up @@ -542,6 +546,7 @@ static int vidcap_screen_pw_init(struct vidcap_params *params, void **state)
start_pipewire(session);
return VIDCAP_INIT_OK;
}
#endif

static int vidcap_pw_init(struct vidcap_params *params, void **state)
{
Expand Down Expand Up @@ -591,6 +596,8 @@ static struct video_frame *vidcap_screen_pw_grab(void *session_ptr, struct audio
return session.in_flight_frame.get();
}

#ifdef HAVE_DBUS_SCREENCAST

static const struct video_capture_info vidcap_screen_pw_info = {
vidcap_screen_pw_probe,
vidcap_screen_pw_init,
Expand All @@ -601,6 +608,8 @@ static const struct video_capture_info vidcap_screen_pw_info = {

REGISTER_MODULE(screen_pw, &vidcap_screen_pw_info, LIBRARY_CLASS_VIDEO_CAPTURE, VIDEO_CAPTURE_ABI_VERSION);

#endif

static const struct video_capture_info vidcap_pw_info = {
vidcap_screen_pw_probe,
vidcap_pw_init,
Expand Down

0 comments on commit 1cbb716

Please sign in to comment.