From d138a1fe73a596e50652ea4880ad7977e6a0922e Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 8 Dec 2024 02:52:58 +0100 Subject: Add card path to --info, add card path and vendor to --list-capture-options if known to speed up the command --- include/utils.h | 5 ++- src/capture/kms.c | 4 +- src/main.cpp | 121 ++++++++++++++++++++++++++++++++++++------------------ src/utils.c | 28 +++++++------ 4 files changed, 102 insertions(+), 56 deletions(-) diff --git a/include/utils.h b/include/utils.h index d3af640..d8fa99a 100644 --- a/include/utils.h +++ b/include/utils.h @@ -41,9 +41,9 @@ bool generate_random_characters_standard_alphabet(char *buffer, int buffer_size) typedef void (*active_monitor_callback)(const gsr_monitor *monitor, void *userdata); void for_each_active_monitor_output_x11_not_cached(Display *display, active_monitor_callback callback, void *userdata); -void for_each_active_monitor_output(const gsr_egl *egl, gsr_connection_type connection_type, active_monitor_callback callback, void *userdata); +void for_each_active_monitor_output(const gsr_window *window, const char *card_path, gsr_connection_type connection_type, active_monitor_callback callback, void *userdata); bool get_monitor_by_name(const gsr_egl *egl, gsr_connection_type connection_type, const char *name, gsr_monitor *monitor); -gsr_monitor_rotation drm_monitor_get_display_server_rotation(const gsr_egl *egl, const gsr_monitor *monitor); +gsr_monitor_rotation drm_monitor_get_display_server_rotation(const gsr_window *window, const gsr_monitor *monitor); int get_connector_type_by_name(const char *name); drm_connector_type_count* drm_connector_types_get_index(drm_connector_type_count *type_counts, int *num_type_counts, int connector_type); @@ -52,6 +52,7 @@ uint32_t monitor_identifier_from_type_and_count(int monitor_type_index, int moni bool gl_get_gpu_info(gsr_egl *egl, gsr_gpu_info *info); bool gl_driver_version_greater_than(const gsr_egl *egl, int major, int minor, int patch); +bool try_card_has_valid_plane(const char *card_path); /* |output| should be at least 128 bytes in size */ bool gsr_get_valid_card_path(gsr_egl *egl, char *output, bool is_monitor_capture); /* |render_path| should be at least 128 bytes in size */ diff --git a/src/capture/kms.c b/src/capture/kms.c index d692929..27ddec4 100644 --- a/src/capture/kms.c +++ b/src/capture/kms.c @@ -196,7 +196,7 @@ static int gsr_capture_kms_start(gsr_capture *cap, AVCodecContext *video_codec_c self->params.display_to_capture, strlen(self->params.display_to_capture), 0, }; - for_each_active_monitor_output(self->params.egl, connection_type, monitor_callback, &monitor_callback_userdata); + for_each_active_monitor_output(self->params.egl->window, self->params.egl->card_path, connection_type, monitor_callback, &monitor_callback_userdata); if(!get_monitor_by_name(self->params.egl, connection_type, self->params.display_to_capture, &monitor)) { fprintf(stderr, "gsr error: gsr_capture_kms_start: failed to find monitor by name \"%s\"\n", self->params.display_to_capture); @@ -205,7 +205,7 @@ static int gsr_capture_kms_start(gsr_capture *cap, AVCodecContext *video_codec_c } monitor.name = self->params.display_to_capture; - self->monitor_rotation = drm_monitor_get_display_server_rotation(self->params.egl, &monitor); + self->monitor_rotation = drm_monitor_get_display_server_rotation(self->params.egl->window, &monitor); self->capture_pos = monitor.pos; /* Monitor size is already rotated on x11 when the monitor is rotated, no need to apply it ourselves */ diff --git a/src/main.cpp b/src/main.cpp index 119da89..fbdb6b1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1069,7 +1069,7 @@ static void open_video_hardware(AVCodecContext *codec_context, VideoQuality vide static void usage_header() { const bool inside_flatpak = getenv("FLATPAK_ID") != NULL; const char *program_name = inside_flatpak ? "flatpak run --command=gpu-screen-recorder com.dec05eba.gpu_screen_recorder" : "gpu-screen-recorder"; - printf("usage: %s -w [-c ] [-s WxH] -f [-a ] [-q ] [-r ] [-k h264|hevc|av1|vp8|vp9|hevc_hdr|av1_hdr|hevc_10bit|av1_10bit] [-ac aac|opus|flac] [-ab ] [-oc yes|no] [-fm cfr|vfr|content] [-bm auto|qp|vbr|cbr] [-cr limited|full] [-df yes|no] [-sc ] [-cursor yes|no] [-keyint ] [-restore-portal-session yes|no] [-portal-session-token-filepath filepath] [-encoder gpu|cpu] [-o ] [-v yes|no] [--version] [-h|--help]\n", program_name); + printf("usage: %s -w [-c ] [-s WxH] -f [-a ] [-q ] [-r ] [-k h264|hevc|av1|vp8|vp9|hevc_hdr|av1_hdr|hevc_10bit|av1_10bit] [-ac aac|opus|flac] [-ab ] [-oc yes|no] [-fm cfr|vfr|content] [-bm auto|qp|vbr|cbr] [-cr limited|full] [-df yes|no] [-sc ] [-cursor yes|no] [-keyint ] [-restore-portal-session yes|no] [-portal-session-token-filepath filepath] [-encoder gpu|cpu] [-o ] [--list-capture-options [card_path] [vendor]] [--list-audio-devices] [--list-application-audio] [-v yes|no] [--version] [-h|--help]\n", program_name); fflush(stdout); } @@ -1204,6 +1204,7 @@ static void usage_full() { printf(" window\n"); printf(" DP-1|1920x1080\n"); printf(" The