aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/capture/portal.c12
-rw-r--r--src/damage.c6
-rw-r--r--src/main.cpp25
-rw-r--r--src/pipewire.c16
4 files changed, 48 insertions, 11 deletions
diff --git a/src/capture/portal.c b/src/capture/portal.c
index f134179..95470c1 100644
--- a/src/capture/portal.c
+++ b/src/capture/portal.c
@@ -374,6 +374,16 @@ static bool gsr_capture_portal_uses_external_image(gsr_capture *cap) {
return true;
}
+static bool gsr_capture_portal_is_damaged(gsr_capture *cap) {
+ gsr_capture_portal *self = cap->priv;
+ return gsr_pipewire_is_damaged(&self->pipewire);
+}
+
+static void gsr_capture_portal_clear_damage(gsr_capture *cap) {
+ gsr_capture_portal *self = cap->priv;
+ gsr_pipewire_clear_damage(&self->pipewire);
+}
+
static void gsr_capture_portal_destroy(gsr_capture *cap, AVCodecContext *video_codec_context) {
(void)video_codec_context;
gsr_capture_portal *cap_portal = cap->priv;
@@ -411,6 +421,8 @@ gsr_capture* gsr_capture_portal_create(const gsr_capture_portal_params *params)
.capture_end = gsr_capture_portal_capture_end,
.get_source_color = gsr_capture_portal_get_source_color,
.uses_external_image = gsr_capture_portal_uses_external_image,
+ .is_damaged = gsr_capture_portal_is_damaged,
+ .clear_damage = gsr_capture_portal_clear_damage,
.destroy = gsr_capture_portal_destroy,
.priv = cap_portal
};
diff --git a/src/damage.c b/src/damage.c
index 168ed6b..868a2e6 100644
--- a/src/damage.c
+++ b/src/damage.c
@@ -130,8 +130,10 @@ bool gsr_damage_set_target_monitor(gsr_damage *self, const char *monitor_name) {
}
memset(&self->monitor, 0, sizeof(self->monitor));
- if(!get_monitor_by_name(self->egl, GSR_CONNECTION_X11, monitor_name, &self->monitor))
- fprintf(stderr, "gsr warning: gsr_damage_set_target_monitor: failed to find monitor: %s\n", monitor_name);
+ if(strcmp(monitor_name, "screen") != 0 && strcmp(monitor_name, "screen-direct") != 0 && strcmp(monitor_name, "screen-direct-force") != 0) {
+ if(!get_monitor_by_name(self->egl, GSR_CONNECTION_X11, monitor_name, &self->monitor))
+ fprintf(stderr, "gsr warning: gsr_damage_set_target_monitor: failed to find monitor: %s\n", monitor_name);
+ }
if(self->window)
XSelectInput(self->egl->x11.dpy, self->window, 0);
diff --git a/src/main.cpp b/src/main.cpp
index 736817f..7687b07 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -980,7 +980,7 @@ static void usage_full() {
fprintf(stderr, "\n");
fprintf(stderr, " -fm Framerate mode. Should be either 'cfr' (constant frame rate), 'vfr' (variable frame rate) or 'content'. Optional, set to 'vfr' by default.\n");
fprintf(stderr, " 'vfr' is recommended for recording for less issue with very high system load but some applications such as video editors may not support it properly.\n");
- fprintf(stderr, " 'content' is currently only supported on X11. The 'content' option matches the recording frame rate to the captured content.\n");
+ fprintf(stderr, " 'content' is currently only supported on X11 or when using portal capture option. The 'content' option matches the recording frame rate to the captured content.\n");
fprintf(stderr, "\n");
fprintf(stderr, " -bm Bitrate mode. Should be either 'auto', 'qp' (constant quality) or 'vbr' (variable bitrate). Optional, set to 'auto' by default which defaults to 'qp' on all devices\n");
fprintf(stderr, " except steam deck that has broken drivers and doesn't support qp.\n");
@@ -2678,8 +2678,9 @@ int main(int argc, char **argv) {
}
std::string window_str = args["-w"].value();
+ const bool is_portal_capture = strcmp(window_str.c_str(), "portal") == 0;
- if(!restore_portal_session && strcmp(window_str.c_str(), "portal") == 0) {
+ if(!restore_portal_session && is_portal_capture) {
fprintf(stderr, "gsr info: option '-w portal' was used without '-restore-portal-session yes'. The previous screencast session will be ignored\n");
}
@@ -2704,7 +2705,7 @@ int main(int argc, char **argv) {
disable_prime_run();
}
- if(strcmp(window_str.c_str(), "portal") == 0 && is_using_prime_run()) {
+ if(is_portal_capture && is_using_prime_run()) {
fprintf(stderr, "Warning: use of prime-run with -w portal option is currently not supported. Disabling prime-run\n");
disable_prime_run();
}
@@ -2714,7 +2715,7 @@ int main(int argc, char **argv) {
_exit(1);
}
- const bool is_monitor_capture = strcmp(window_str.c_str(), "focused") != 0 && strcmp(window_str.c_str(), "portal") != 0 && contains_non_hex_number(window_str.c_str());
+ const bool is_monitor_capture = strcmp(window_str.c_str(), "focused") != 0 && !is_portal_capture && contains_non_hex_number(window_str.c_str());
gsr_egl egl;
if(!gsr_egl_load(&egl, dpy, wayland, is_monitor_capture)) {
fprintf(stderr, "gsr error: failed to load opengl\n");
@@ -2771,8 +2772,8 @@ int main(int argc, char **argv) {
usage();
}
- if(framerate_mode == FramerateMode::CONTENT && wayland) {
- fprintf(stderr, "Error: -fm 'content' is currently only supported on X11 and when capturing a single window.\n");
+ if(framerate_mode == FramerateMode::CONTENT && wayland && !is_portal_capture) {
+ fprintf(stderr, "Error: -fm 'content' is currently only supported on X11 or when using portal capture option\n");
usage();
}
@@ -3342,10 +3343,14 @@ int main(int argc, char **argv) {
break;
}
- const bool damaged = !use_damage_tracking || gsr_damage_is_damaged(&damage);
- if(damaged) {
+ bool damaged = false;
+ if(capture->is_damaged)
+ damaged = capture->is_damaged(capture);
+ else
+ damaged = !use_damage_tracking || gsr_damage_is_damaged(&damage);
+
+ if(damaged)
++damage_fps_counter;
- }
++fps_counter;
double time_now = clock_get_monotonic_seconds();
@@ -3365,6 +3370,8 @@ int main(int argc, char **argv) {
const double num_frames_seconds = num_frames * target_fps;
if((damaged || num_frames_seconds >= damage_timeout_seconds) && !paused/* && fps_counter < fps + 100*/) {
gsr_damage_clear(&damage);
+ if(capture->clear_damage)
+ capture->clear_damage(capture);
egl.glClear(0);
gsr_capture_capture(capture, video_frame, &color_conversion);
diff --git a/src/pipewire.c b/src/pipewire.c
index 8751b7d..30e2c00 100644
--- a/src/pipewire.c
+++ b/src/pipewire.c
@@ -129,6 +129,8 @@ static void on_process_cb(void *user_data) {
self->dmabuf_data[i].offset = buffer->datas[i].chunk->offset;
self->dmabuf_data[i].stride = buffer->datas[i].chunk->stride;
}
+
+ self->damaged = true;
} else {
// TODO:
}
@@ -745,3 +747,17 @@ bool gsr_pipewire_map_texture(gsr_pipewire *self, gsr_texture_map texture_map, g
pthread_mutex_unlock(&self->mutex);
return true;
}
+
+bool gsr_pipewire_is_damaged(gsr_pipewire *self) {
+ bool damaged = false;
+ pthread_mutex_lock(&self->mutex);
+ damaged = self->damaged;
+ pthread_mutex_unlock(&self->mutex);
+ return damaged;
+}
+
+void gsr_pipewire_clear_damage(gsr_pipewire *self) {
+ pthread_mutex_lock(&self->mutex);
+ self->damaged = false;
+ pthread_mutex_unlock(&self->mutex);
+}