UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
screen_linux.c File Reference
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
#include <stdlib.h>
#include <string.h>
#include "debug.h"
#include "lib_common.h"
#include "utils/color_out.h"
#include "utils/text.h"
#include "video_capture.h"
Include dependency graph for screen_linux.c:

Go to the source code of this file.

Functions

 REGISTER_MODULE (screen, &vidcap_screen_linux_info, LIBRARY_CLASS_VIDEO_CAPTURE, VIDEO_CAPTURE_ABI_VERSION)
 
static void vidcap_screen_linux_done (void *state)
 
static struct video_frame * vidcap_screen_linux_grab (void *state, struct audio_frame **audio)
 
static int vidcap_screen_linux_init (struct vidcap_params *params, void **state)
 
static void vidcap_screen_linux_probe (struct device_info **cards, int *count, void(**deleter)(void *))
 

Variables

static const struct video_capture_info vidcap_screen_linux_info
 

Detailed Description

Author
Martin Pulec pulec.nosp@m.@ces.nosp@m.net.c.nosp@m.z

X11/PipeWire screen capture abstraction

Definition in file screen_linux.c.

Function Documentation

◆ REGISTER_MODULE()

REGISTER_MODULE ( screen ,
& vidcap_screen_linux_info,
LIBRARY_CLASS_VIDEO_CAPTURE ,
VIDEO_CAPTURE_ABI_VERSION  )

◆ vidcap_screen_linux_done()

static void vidcap_screen_linux_done ( void * state)
static

Definition at line 104 of file screen_linux.c.

105{
106 vidcap_done((struct vidcap *) state);
107}
void ** state
void vidcap_done(struct vidcap *state)
Destroys vidap state.
This struct represents video capture state.

References state, and vidcap_done().

Here is the call graph for this function:

◆ vidcap_screen_linux_grab()

static struct video_frame * vidcap_screen_linux_grab ( void * state,
struct audio_frame ** audio )
static

Definition at line 110 of file screen_linux.c.

111{
112 return vidcap_grab((struct vidcap *) state, audio);
113}
struct audio_frame ** audio
struct video_frame * vidcap_grab(struct vidcap *state, struct audio_frame **audio)
Grabs video frame. This function may block for a short period if waiting for incoming frame....

References audio, state, and vidcap_grab().

Here is the call graph for this function:

◆ vidcap_screen_linux_init()

static int vidcap_screen_linux_init ( struct vidcap_params * params,
void ** state )
static

Definition at line 60 of file screen_linux.c.

61{
62 struct vidcap *device = NULL;
63
64 if (strcmp(vidcap_params_get_fmt(params), "help") == 0) {
65 char desc[] = TRED(TBOLD("screen")) " capture in Linux abstracts X11/PipeWire screen capture and tries to select "
66 "the right implementation. You can also specify directly " TBOLD("screen_x11") " or " TBOLD("screen_pw") ".";
68 color_printf("Compiled modules:");
69#ifdef HAVE_SCREEN_X11
70 color_printf(TBOLD(" X11"));
71#endif
72#ifdef HAVE_SCREEN_PW
73 color_printf(TBOLD(" pipewire"));
74#endif
75 printf("\n\nFollows help for the module that would have been selected:\n\n");
76 }
77
78 struct vidcap_params *params_new = vidcap_params_copy(params);
79 if (getenv("WAYLAND_DISPLAY") != NULL) {
80 vidcap_params_set_driver(params_new, "screen_pw");
81 verbose_msg("Trying to initialize screen_pw\n");
82 int ret = initialize_video_capture(NULL, params_new, &device);
83 if (ret < 0) {
84 error_msg("screen_pw initialization failed\n");
85 } else {
86 vidcap_params_free_struct(params_new);
87 *state = device;
88 return ret;
89 }
90 }
91 verbose_msg("Trying to initialize screen_x11\n");
92 if (getenv("DISPLAY") == NULL) {
93 log_msg(LOG_LEVEL_WARNING, "Trying to initalize screen_x11 but DISPLAY environment variable is not set!\n");
94 }
95 vidcap_params_set_driver(params_new, "screen_x11");
96 int ret = initialize_video_capture(NULL, params_new, &device);
97 vidcap_params_free_struct(params_new);
98
99 *state = device;
100 return ret;
101}
struct video_desc desc
int color_printf(const char *format,...)
#define TRED(x)
Definition color_out.h:75
#define TBOLD(x)
Definition color_out.h:70
void log_msg(int level, const char *format,...)
Definition debug.cpp:130
#define error_msg(...)
Definition debug.h:89
#define verbose_msg(...)
Definition debug.h:90
#define LOG_LEVEL_WARNING
less severe errors
Definition debug.h:60
int initialize_video_capture(struct module *parent, struct vidcap_params *param, struct vidcap **state)
Initializes video capture.
char * wrap_paragraph(char *text)
Definition text.c:204
void vidcap_params_set_driver(struct vidcap_params *params, const char *driver)
void vidcap_params_free_struct(struct vidcap_params *buf)
struct vidcap_params * vidcap_params_copy(const struct vidcap_params *params)
const char * vidcap_params_get_fmt(const struct vidcap_params *params)

References color_printf(), desc, error_msg, initialize_video_capture(), LOG_LEVEL_WARNING, log_msg(), state, TBOLD, TRED, verbose_msg, vidcap_params_copy(), vidcap_params_free_struct(), vidcap_params_get_fmt(), vidcap_params_set_driver(), and wrap_paragraph().

Here is the call graph for this function:

◆ vidcap_screen_linux_probe()

static void vidcap_screen_linux_probe ( struct device_info ** cards,
int * count,
void(** deleter )(void *) )
static

Definition at line 52 of file screen_linux.c.

53{
54 *cards = NULL;
55 *count = 0;
56 *deleter = free;
57}
int void(** deleter)(void *))
int count
Definition hd-rum.c:44

References count, and deleter.

Variable Documentation

◆ vidcap_screen_linux_info

const struct video_capture_info vidcap_screen_linux_info
static
Initial value:
= {
"[screen] ",
}
static int vidcap_screen_linux_init(struct vidcap_params *params, void **state)
static void vidcap_screen_linux_probe(struct device_info **cards, int *count, void(**deleter)(void *))
static struct video_frame * vidcap_screen_linux_grab(void *state, struct audio_frame **audio)
static void vidcap_screen_linux_done(void *state)

Definition at line 115 of file screen_linux.c.