diff options
Diffstat (limited to 'src/capture/kms.c')
-rw-r--r-- | src/capture/kms.c | 228 |
1 files changed, 121 insertions, 107 deletions
diff --git a/src/capture/kms.c b/src/capture/kms.c index fcf3b85..2cbd757 100644 --- a/src/capture/kms.c +++ b/src/capture/kms.c @@ -2,6 +2,7 @@ #include "../../include/utils.h" #include "../../include/color_conversion.h" #include "../../include/cursor.h" +#include "../../include/window/window.h" #include "../../kms/client/kms_client.h" #include <stdlib.h> @@ -13,9 +14,9 @@ #include <xf86drm.h> #include <libdrm/drm_fourcc.h> -#include <libavcodec/avcodec.h> #include <libavutil/mastering_display_metadata.h> -#include <libavformat/avformat.h> + +#define FIND_CRTC_BY_NAME_TIMEOUT_SECONDS 2.0 #define HDMI_STATIC_METADATA_TYPE1 0 #define HDMI_EOTF_SMPTE_ST2084 2 @@ -52,16 +53,14 @@ typedef struct { bool is_x11; gsr_cursor x11_cursor; - AVCodecContext *video_codec_context; - bool performance_error_shown; - bool fast_path_failed; - //int drm_fd; //uint64_t prev_sequence; //bool damaged; vec2i prev_target_pos; vec2i prev_plane_size; + + double last_time_monitor_check; } gsr_capture_kms; static void gsr_capture_kms_cleanup_kms_fds(gsr_capture_kms *self) { @@ -109,18 +108,22 @@ static int max_int(int a, int b) { } static void gsr_capture_kms_create_input_texture_ids(gsr_capture_kms *self) { + const float border_color[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + self->params.egl->glGenTextures(1, &self->input_texture_id); self->params.egl->glBindTexture(GL_TEXTURE_2D, self->input_texture_id); - self->params.egl->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - self->params.egl->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + self->params.egl->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + self->params.egl->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + self->params.egl->glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, border_color); self->params.egl->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); self->params.egl->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); self->params.egl->glBindTexture(GL_TEXTURE_2D, 0); self->params.egl->glGenTextures(1, &self->external_input_texture_id); self->params.egl->glBindTexture(GL_TEXTURE_EXTERNAL_OES, self->external_input_texture_id); - self->params.egl->glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - self->params.egl->glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + self->params.egl->glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + self->params.egl->glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + self->params.egl->glTexParameterfv(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_BORDER_COLOR, border_color); self->params.egl->glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); self->params.egl->glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); self->params.egl->glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0); @@ -130,8 +133,9 @@ static void gsr_capture_kms_create_input_texture_ids(gsr_capture_kms *self) { self->params.egl->glGenTextures(1, &self->cursor_texture_id); self->params.egl->glBindTexture(cursor_texture_id_target, self->cursor_texture_id); - self->params.egl->glTexParameteri(cursor_texture_id_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - self->params.egl->glTexParameteri(cursor_texture_id_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + self->params.egl->glTexParameteri(cursor_texture_id_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + self->params.egl->glTexParameteri(cursor_texture_id_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + self->params.egl->glTexParameterfv(cursor_texture_id_target, GL_TEXTURE_BORDER_COLOR, border_color); self->params.egl->glTexParameteri(cursor_texture_id_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); self->params.egl->glTexParameteri(cursor_texture_id_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); self->params.egl->glBindTexture(cursor_texture_id_target, 0); @@ -171,7 +175,7 @@ static vec2i rotate_capture_size_if_rotated(gsr_capture_kms *self, vec2i capture return capture_size; } -static int gsr_capture_kms_start(gsr_capture *cap, AVCodecContext *video_codec_context, AVFrame *frame) { +static int gsr_capture_kms_start(gsr_capture *cap, gsr_capture_metadata *capture_metadata) { gsr_capture_kms *self = cap->priv; gsr_capture_kms_create_input_texture_ids(self); @@ -183,17 +187,19 @@ static int gsr_capture_kms_start(gsr_capture *cap, AVCodecContext *video_codec_c if(kms_init_res != 0) return kms_init_res; - self->is_x11 = gsr_egl_get_display_server(self->params.egl) == GSR_DISPLAY_SERVER_X11; + self->is_x11 = gsr_window_get_display_server(self->params.egl->window) == GSR_DISPLAY_SERVER_X11; const gsr_connection_type connection_type = self->is_x11 ? GSR_CONNECTION_X11 : GSR_CONNECTION_DRM; - if(self->is_x11) - gsr_cursor_init(&self->x11_cursor, self->params.egl, self->params.egl->x11.dpy); + if(self->is_x11) { + Display *display = gsr_window_get_display(self->params.egl->window); + gsr_cursor_init(&self->x11_cursor, self->params.egl, display); + } MonitorCallbackUserdata monitor_callback_userdata = { &self->monitor_id, 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); @@ -202,7 +208,8 @@ 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); + vec2i monitor_position = {0, 0}; + drm_monitor_get_display_server_data(self->params.egl->window, &monitor, &self->monitor_rotation, &monitor_position); self->capture_pos = monitor.pos; /* Monitor size is already rotated on x11 when the monitor is rotated, no need to apply it ourselves */ @@ -211,27 +218,19 @@ static int gsr_capture_kms_start(gsr_capture *cap, AVCodecContext *video_codec_c else self->capture_size = rotate_capture_size_if_rotated(self, monitor.size); - /* Disable vsync */ - self->params.egl->eglSwapInterval(self->params.egl->egl_display, 0); - - if(self->params.output_resolution.x == 0 && self->params.output_resolution.y == 0) { - self->params.output_resolution = self->capture_size; - video_codec_context->width = FFALIGN(self->capture_size.x, 2); - video_codec_context->height = FFALIGN(self->capture_size.y, 2); - } else { + if(self->params.output_resolution.x > 0 && self->params.output_resolution.y > 0) { self->params.output_resolution = scale_keep_aspect_ratio(self->capture_size, self->params.output_resolution); - video_codec_context->width = FFALIGN(self->params.output_resolution.x, 2); - video_codec_context->height = FFALIGN(self->params.output_resolution.y, 2); + capture_metadata->width = self->params.output_resolution.x; + capture_metadata->height = self->params.output_resolution.y; + } else if(self->params.region_size.x > 0 && self->params.region_size.y > 0) { + capture_metadata->width = self->params.region_size.x; + capture_metadata->height = self->params.region_size.y; + } else { + capture_metadata->width = self->capture_size.x; + capture_metadata->height = self->capture_size.y; } - self->fast_path_failed = self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD && !gl_driver_version_greater_than(self->params.egl, 24, 0, 9); - if(self->fast_path_failed) - fprintf(stderr, "gsr warning: gsr_capture_kms_start: your amd driver (mesa) version is known to be buggy (<= version 24.0.9), falling back to opengl copy\n"); - - frame->width = video_codec_context->width; - frame->height = video_codec_context->height; - - self->video_codec_context = video_codec_context; + self->last_time_monitor_check = clock_get_monotonic_seconds(); return 0; } @@ -240,7 +239,7 @@ static void gsr_capture_kms_on_event(gsr_capture *cap, gsr_egl *egl) { if(!self->is_x11) return; - XEvent *xev = gsr_egl_get_event_data(egl); + XEvent *xev = gsr_window_get_event_data(egl->window); gsr_cursor_on_event(&self->x11_cursor, xev); } @@ -265,16 +264,6 @@ static void gsr_capture_kms_on_event(gsr_capture *cap, gsr_egl *egl) { // } // } -static float monitor_rotation_to_radians(gsr_monitor_rotation rot) { - switch(rot) { - case GSR_MONITOR_ROT_0: return 0.0f; - case GSR_MONITOR_ROT_90: return M_PI_2; - case GSR_MONITOR_ROT_180: return M_PI; - case GSR_MONITOR_ROT_270: return M_PI + M_PI_2; - } - return 0.0f; -} - static gsr_kms_response_item* find_drm_by_connector_id(gsr_kms_response *kms_response, uint32_t connector_id) { for(int i = 0; i < kms_response->num_items; ++i) { if(kms_response->items[i].connector_id == connector_id && !kms_response->items[i].is_cursor) @@ -425,7 +414,7 @@ static gsr_kms_response_item* find_monitor_drm(gsr_capture_kms *self, bool *capt } // Will never happen on wayland unless the target monitor has been disconnected - if(!drm_fd) { + if(!drm_fd && self->is_x11) { drm_fd = find_largest_drm(&self->kms_response); *capture_is_combined_plane = true; } @@ -440,7 +429,7 @@ static gsr_kms_response_item* find_cursor_drm_if_on_monitor(gsr_capture_kms *sel return cursor_drm_fd; } -static void render_drm_cursor(gsr_capture_kms *self, gsr_color_conversion *color_conversion, const gsr_kms_response_item *cursor_drm_fd, vec2i target_pos, float texture_rotation, vec2i output_size) { +static void render_drm_cursor(gsr_capture_kms *self, gsr_color_conversion *color_conversion, const gsr_kms_response_item *cursor_drm_fd, vec2i target_pos, vec2i output_size, vec2i framebuffer_size) { const vec2d scale = { self->capture_size.x == 0 ? 0 : (double)output_size.x / (double)self->capture_size.x, self->capture_size.y == 0 ? 0 : (double)output_size.y / (double)self->capture_size.y @@ -455,25 +444,28 @@ static void render_drm_cursor(gsr_capture_kms *self, gsr_color_conversion *color break; case GSR_MONITOR_ROT_90: cursor_pos = swap_vec2i(cursor_pos); - cursor_pos.x = self->capture_size.x - cursor_pos.x; + cursor_pos.x = framebuffer_size.x - cursor_pos.x; // TODO: Remove this horrible hack cursor_pos.x -= cursor_size.x; break; case GSR_MONITOR_ROT_180: - cursor_pos.x = self->capture_size.x - cursor_pos.x; - cursor_pos.y = self->capture_size.y - cursor_pos.y; + cursor_pos.x = framebuffer_size.x - cursor_pos.x; + cursor_pos.y = framebuffer_size.y - cursor_pos.y; // TODO: Remove this horrible hack cursor_pos.x -= cursor_size.x; cursor_pos.y -= cursor_size.y; break; case GSR_MONITOR_ROT_270: cursor_pos = swap_vec2i(cursor_pos); - cursor_pos.y = self->capture_size.y - cursor_pos.y; + cursor_pos.y = framebuffer_size.y - cursor_pos.y; // TODO: Remove this horrible hack cursor_pos.y -= cursor_size.y; break; } + cursor_pos.x -= self->params.region_position.x; + cursor_pos.y -= self->params.region_position.y; + cursor_pos.x *= scale.x; cursor_pos.y *= scale.y; @@ -510,8 +502,8 @@ static void render_drm_cursor(gsr_capture_kms *self, gsr_color_conversion *color gsr_color_conversion_draw(color_conversion, self->cursor_texture_id, cursor_pos, (vec2i){cursor_size.x * scale.x, cursor_size.y * scale.y}, - (vec2i){0, 0}, cursor_size, - texture_rotation, cursor_texture_id_is_external, GSR_SOURCE_COLOR_RGB); + (vec2i){0, 0}, cursor_size, cursor_size, + gsr_monitor_rotation_to_rotation(self->monitor_rotation), cursor_texture_id_is_external, GSR_SOURCE_COLOR_RGB); self->params.egl->glDisable(GL_SCISSOR_TEST); } @@ -525,7 +517,8 @@ static void render_x11_cursor(gsr_capture_kms *self, gsr_color_conversion *color self->capture_size.y == 0 ? 0 : (double)output_size.y / (double)self->capture_size.y }; - gsr_cursor_tick(&self->x11_cursor, DefaultRootWindow(self->params.egl->x11.dpy)); + Display *display = gsr_window_get_display(self->params.egl->window); + gsr_cursor_tick(&self->x11_cursor, DefaultRootWindow(display)); const vec2i cursor_pos = { target_pos.x + (self->x11_cursor.position.x - self->x11_cursor.hotspot.x - capture_pos.x) * scale.x, @@ -537,8 +530,8 @@ static void render_x11_cursor(gsr_capture_kms *self, gsr_color_conversion *color gsr_color_conversion_draw(color_conversion, self->x11_cursor.texture_id, cursor_pos, (vec2i){self->x11_cursor.size.x * scale.x, self->x11_cursor.size.y * scale.y}, - (vec2i){0, 0}, self->x11_cursor.size, - 0.0f, false, GSR_SOURCE_COLOR_RGB); + (vec2i){0, 0}, self->x11_cursor.size, self->x11_cursor.size, + GSR_ROT_0, false, GSR_SOURCE_COLOR_RGB); self->params.egl->glDisable(GL_SCISSOR_TEST); } @@ -551,7 +544,47 @@ static void gsr_capture_kms_update_capture_size_change(gsr_capture_kms *self, gs } } -static int gsr_capture_kms_capture(gsr_capture *cap, AVFrame *frame, gsr_color_conversion *color_conversion) { +static void gsr_capture_kms_update_connector_ids(gsr_capture_kms *self) { + const double now = clock_get_monotonic_seconds(); + if(now - self->last_time_monitor_check < FIND_CRTC_BY_NAME_TIMEOUT_SECONDS) + return; + + self->last_time_monitor_check = now; + /* TODO: Assume for now that there is only 1 framebuffer for all monitors and it doesn't change */ + if(self->is_x11) + return; + + self->monitor_id.num_connector_ids = 0; + const gsr_connection_type connection_type = self->is_x11 ? GSR_CONNECTION_X11 : GSR_CONNECTION_DRM; + // MonitorCallbackUserdata monitor_callback_userdata = { + // &self->monitor_id, + // self->params.display_to_capture, strlen(self->params.display_to_capture), + // 0, + // }; + // for_each_active_monitor_output(self->params.egl->window, self->params.egl->card_path, connection_type, monitor_callback, &monitor_callback_userdata); + + gsr_monitor monitor; + if(!get_monitor_by_name(self->params.egl, connection_type, self->params.display_to_capture, &monitor)) { + fprintf(stderr, "gsr error: gsr_capture_kms_update_connector_ids: failed to find monitor by name \"%s\"\n", self->params.display_to_capture); + return; + } + + self->monitor_id.num_connector_ids = 1; + self->monitor_id.connector_ids[0] = monitor.connector_id; + + monitor.name = self->params.display_to_capture; + vec2i monitor_position = {0, 0}; + drm_monitor_get_display_server_data(self->params.egl->window, &monitor, &self->monitor_rotation, &monitor_position); + + self->capture_pos = monitor.pos; + /* Monitor size is already rotated on x11 when the monitor is rotated, no need to apply it ourselves */ + if(self->is_x11) + self->capture_size = monitor.size; + else + self->capture_size = rotate_capture_size_if_rotated(self, monitor.size); +} + +static int gsr_capture_kms_capture(gsr_capture *cap, gsr_capture_metadata *capture_metadata, gsr_color_conversion *color_conversion) { gsr_capture_kms *self = cap->priv; gsr_capture_kms_cleanup_kms_fds(self); @@ -570,6 +603,8 @@ static int gsr_capture_kms_capture(gsr_capture *cap, AVFrame *frame, gsr_color_c return -1; } + gsr_capture_kms_update_connector_ids(self); + bool capture_is_combined_plane = false; const gsr_kms_response_item *drm_fd = find_monitor_drm(self, &capture_is_combined_plane); if(!drm_fd) { @@ -580,62 +615,39 @@ static int gsr_capture_kms_capture(gsr_capture *cap, AVFrame *frame, gsr_color_c if(drm_fd->has_hdr_metadata && self->params.hdr && hdr_metadata_is_supported_format(&drm_fd->hdr_metadata)) gsr_kms_set_hdr_metadata(self, drm_fd); - if(!self->performance_error_shown && self->monitor_rotation != GSR_MONITOR_ROT_0 && video_codec_context_is_vaapi(self->video_codec_context) && self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD) { - self->performance_error_shown = true; - fprintf(stderr,"gsr warning: gsr_capture_kms_capture: the monitor you are recording is rotated, composition will have to be used." - " If you are experience performance problems in the video then record a single window on X11 or use portal capture option instead\n"); - } - self->capture_size = rotate_capture_size_if_rotated(self, (vec2i){ drm_fd->src_w, drm_fd->src_h }); + const vec2i original_frame_size = self->capture_size; + if(self->params.region_size.x > 0 && self->params.region_size.y > 0) + self->capture_size = self->params.region_size; const bool is_scaled = self->params.output_resolution.x > 0 && self->params.output_resolution.y > 0; vec2i output_size = is_scaled ? self->params.output_resolution : self->capture_size; output_size = scale_keep_aspect_ratio(self->capture_size, output_size); - const float texture_rotation = monitor_rotation_to_radians(self->monitor_rotation); - const vec2i target_pos = { max_int(0, frame->width / 2 - output_size.x / 2), max_int(0, frame->height / 2 - output_size.y / 2) }; + const vec2i target_pos = { max_int(0, capture_metadata->width / 2 - output_size.x / 2), max_int(0, capture_metadata->height / 2 - output_size.y / 2) }; gsr_capture_kms_update_capture_size_change(self, color_conversion, target_pos, drm_fd); vec2i capture_pos = self->capture_pos; if(!capture_is_combined_plane) capture_pos = (vec2i){drm_fd->x, drm_fd->y}; - self->params.egl->glFlush(); - self->params.egl->glFinish(); - - /* Fast opengl free path */ - if(!self->fast_path_failed && self->monitor_rotation == GSR_MONITOR_ROT_0 && video_codec_context_is_vaapi(self->video_codec_context) && self->params.egl->gpu_info.vendor == GSR_GPU_VENDOR_AMD) { - int fds[4]; - uint32_t offsets[4]; - uint32_t pitches[4]; - uint64_t modifiers[4]; - for(int i = 0; i < drm_fd->num_dma_bufs; ++i) { - fds[i] = drm_fd->dma_buf[i].fd; - offsets[i] = drm_fd->dma_buf[i].offset; - pitches[i] = drm_fd->dma_buf[i].pitch; - modifiers[i] = drm_fd->modifier; - } - if(!vaapi_copy_drm_planes_to_video_surface(self->video_codec_context, frame, (vec2i){capture_pos.x, capture_pos.y}, self->capture_size, target_pos, output_size, drm_fd->pixel_format, (vec2i){drm_fd->width, drm_fd->height}, fds, offsets, pitches, modifiers, drm_fd->num_dma_bufs)) { - fprintf(stderr, "gsr error: gsr_capture_kms_capture: vaapi_copy_drm_planes_to_video_surface failed, falling back to opengl copy. Please report this as an issue at https://github.com/dec05eba/gpu-screen-recorder-issues\n"); - self->fast_path_failed = true; - } - } else { - self->fast_path_failed = true; - } + capture_pos.x += self->params.region_position.x; + capture_pos.y += self->params.region_position.y; - if(self->fast_path_failed) { - EGLImage image = gsr_capture_kms_create_egl_image_with_fallback(self, drm_fd); - if(image) { - gsr_capture_kms_bind_image_to_input_texture_with_fallback(self, image); - self->params.egl->eglDestroyImage(self->params.egl->egl_display, image); - } + //self->params.egl->glFlush(); + //self->params.egl->glFinish(); - gsr_color_conversion_draw(color_conversion, self->external_texture_fallback ? self->external_input_texture_id : self->input_texture_id, - target_pos, output_size, - capture_pos, self->capture_size, - texture_rotation, self->external_texture_fallback, GSR_SOURCE_COLOR_RGB); + EGLImage image = gsr_capture_kms_create_egl_image_with_fallback(self, drm_fd); + if(image) { + gsr_capture_kms_bind_image_to_input_texture_with_fallback(self, image); + self->params.egl->eglDestroyImage(self->params.egl->egl_display, image); } + gsr_color_conversion_draw(color_conversion, self->external_texture_fallback ? self->external_input_texture_id : self->input_texture_id, + target_pos, output_size, + capture_pos, self->capture_size, original_frame_size, + gsr_monitor_rotation_to_rotation(self->monitor_rotation), self->external_texture_fallback, GSR_SOURCE_COLOR_RGB); + if(self->params.record_cursor) { gsr_kms_response_item *cursor_drm_fd = find_cursor_drm_if_on_monitor(self, drm_fd->connector_id, capture_is_combined_plane); // The cursor is handled by x11 on x11 instead of using the cursor drm plane because on prime systems with a dedicated nvidia gpu @@ -643,15 +655,18 @@ static int gsr_capture_kms_capture(gsr_capture *cap, AVFrame *frame, gsr_color_c // TODO: This doesn't work properly with software cursor on x11 since it will draw the x11 cursor on top of the cursor already in the framebuffer. // Detect if software cursor is used on x11 somehow. if(self->is_x11) { - const vec2i cursor_monitor_offset = self->capture_pos; + vec2i cursor_monitor_offset = self->capture_pos; + cursor_monitor_offset.x += self->params.region_position.x; + cursor_monitor_offset.y += self->params.region_position.y; render_x11_cursor(self, color_conversion, cursor_monitor_offset, target_pos, output_size); } else if(cursor_drm_fd) { - render_drm_cursor(self, color_conversion, cursor_drm_fd, target_pos, texture_rotation, output_size); + const vec2i framebuffer_size = rotate_capture_size_if_rotated(self, (vec2i){ drm_fd->src_w, drm_fd->src_h }); + render_drm_cursor(self, color_conversion, cursor_drm_fd, target_pos, output_size, framebuffer_size); } } - self->params.egl->glFlush(); - self->params.egl->glFinish(); + //self->params.egl->glFlush(); + //self->params.egl->glFinish(); gsr_capture_kms_cleanup_kms_fds(self); @@ -690,8 +705,8 @@ static bool gsr_capture_kms_set_hdr_metadata(gsr_capture *cap, AVMasteringDispla mastering_display_metadata->min_luminance = av_make_q(self->hdr_metadata.hdmi_metadata_type1.min_display_mastering_luminance, 10000); mastering_display_metadata->max_luminance = av_make_q(self->hdr_metadata.hdmi_metadata_type1.max_display_mastering_luminance, 1); - mastering_display_metadata->has_primaries = mastering_display_metadata->display_primaries[0][0].num > 0; - mastering_display_metadata->has_luminance = mastering_display_metadata->max_luminance.num > 0; + mastering_display_metadata->has_primaries = true; + mastering_display_metadata->has_luminance = true; return true; } @@ -706,8 +721,7 @@ static bool gsr_capture_kms_set_hdr_metadata(gsr_capture *cap, AVMasteringDispla // self->damaged = false; // } -static void gsr_capture_kms_destroy(gsr_capture *cap, AVCodecContext *video_codec_context) { - (void)video_codec_context; +static void gsr_capture_kms_destroy(gsr_capture *cap) { gsr_capture_kms *self = cap->priv; if(cap->priv) { gsr_capture_kms_stop(self); |