mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-25 23:45:58 +01:00
screencast: limit screencast framerate by output framerate
This commit is contained in:
parent
6438edb7b9
commit
976fa8374d
4 changed files with 11 additions and 6 deletions
|
@ -96,7 +96,7 @@ struct xdpw_screencast_instance {
|
||||||
// wlroots
|
// wlroots
|
||||||
struct zwlr_screencopy_frame_v1 *frame_callback;
|
struct zwlr_screencopy_frame_v1 *frame_callback;
|
||||||
struct xdpw_wlr_output *target_output;
|
struct xdpw_wlr_output *target_output;
|
||||||
uint32_t framerate;
|
uint32_t max_framerate;
|
||||||
struct zwlr_screencopy_frame_v1 *wlr_frame;
|
struct zwlr_screencopy_frame_v1 *wlr_frame;
|
||||||
struct xdpw_frame simple_frame;
|
struct xdpw_frame simple_frame;
|
||||||
bool with_cursor;
|
bool with_cursor;
|
||||||
|
|
|
@ -189,9 +189,9 @@ void xdpw_pwr_stream_create(struct xdpw_screencast_instance *cast) {
|
||||||
SPA_POD_Fraction(&SPA_FRACTION(0, 1)), 0);
|
SPA_POD_Fraction(&SPA_FRACTION(0, 1)), 0);
|
||||||
spa_pod_builder_add(&b, SPA_FORMAT_VIDEO_maxFramerate,
|
spa_pod_builder_add(&b, SPA_FORMAT_VIDEO_maxFramerate,
|
||||||
SPA_POD_CHOICE_RANGE_Fraction(
|
SPA_POD_CHOICE_RANGE_Fraction(
|
||||||
&SPA_FRACTION(cast->framerate, 1),
|
&SPA_FRACTION(cast->max_framerate, 1),
|
||||||
&SPA_FRACTION(1, 1),
|
&SPA_FRACTION(1, 1),
|
||||||
&SPA_FRACTION(cast->framerate, 1)),
|
&SPA_FRACTION(cast->max_framerate, 1)),
|
||||||
0);
|
0);
|
||||||
const struct spa_pod *param = spa_pod_builder_pop(&b, &f);
|
const struct spa_pod *param = spa_pod_builder_pop(&b, &f);
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,12 @@ void xdpw_screencast_instance_init(struct xdpw_screencast_context *ctx,
|
||||||
|
|
||||||
cast->ctx = ctx;
|
cast->ctx = ctx;
|
||||||
cast->target_output = out;
|
cast->target_output = out;
|
||||||
cast->framerate = out->framerate;
|
if (ctx->state->config->screencast_conf.max_fps > 0) {
|
||||||
|
cast->max_framerate = ctx->state->config->screencast_conf.max_fps < (uint32_t)out->framerate ?
|
||||||
|
ctx->state->config->screencast_conf.max_fps : (uint32_t)out->framerate;
|
||||||
|
} else {
|
||||||
|
cast->max_framerate = (uint32_t)out->framerate;
|
||||||
|
}
|
||||||
cast->with_cursor = with_cursor;
|
cast->with_cursor = with_cursor;
|
||||||
cast->refcount = 1;
|
cast->refcount = 1;
|
||||||
logprint(INFO, "xdpw: screencast instance %p has %d references", cast, cast->refcount);
|
logprint(INFO, "xdpw: screencast instance %p has %d references", cast, cast->refcount);
|
||||||
|
|
|
@ -52,7 +52,7 @@ void xdpw_wlr_frame_free(struct xdpw_screencast_instance *cast) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t delay_ns = fps_limit_measure_end(&cast->fps_limit, cast->ctx->state->config->screencast_conf.max_fps);
|
uint64_t delay_ns = fps_limit_measure_end(&cast->fps_limit, cast->max_framerate);
|
||||||
if (delay_ns > 0) {
|
if (delay_ns > 0) {
|
||||||
xdpw_add_timer(cast->ctx->state, delay_ns,
|
xdpw_add_timer(cast->ctx->state, delay_ns,
|
||||||
(xdpw_event_loop_timer_func_t) xdpw_wlr_register_cb, cast);
|
(xdpw_event_loop_timer_func_t) xdpw_wlr_register_cb, cast);
|
||||||
|
@ -144,7 +144,7 @@ static void wlr_frame_buffer_done(void *data,
|
||||||
zwlr_screencopy_frame_v1_copy_with_damage(frame, cast->simple_frame.buffer);
|
zwlr_screencopy_frame_v1_copy_with_damage(frame, cast->simple_frame.buffer);
|
||||||
logprint(TRACE, "wlroots: frame copied");
|
logprint(TRACE, "wlroots: frame copied");
|
||||||
|
|
||||||
fps_limit_measure_start(&cast->fps_limit, cast->ctx->state->config->screencast_conf.max_fps);
|
fps_limit_measure_start(&cast->fps_limit, cast->max_framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wlr_frame_buffer(void *data, struct zwlr_screencopy_frame_v1 *frame,
|
static void wlr_frame_buffer(void *data, struct zwlr_screencopy_frame_v1 *frame,
|
||||||
|
|
Loading…
Reference in a new issue