From: Seunghun Lee Date: Fri, 13 Mar 2020 08:01:27 +0000 (+0900) Subject: e_info_screen_recorder: set resolution of streamrecorder using size of wl_output. X-Git-Tag: submit/tizen/20200325.071706~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b56c212ec45a9cdee5e340be8118302397d36e1d;p=platform%2Fupstream%2Fenlightenment.git e_info_screen_recorder: set resolution of streamrecorder using size of wl_output. NOTE: Streamrecorder may possibly not support the resolution size of wl_output. Just let it fail in this case, because there is no way to know which resolution is supported by streamrecorder for now. Change-Id: I3c2b5e365af72929727068f5e5ffbf073b69a041 --- diff --git a/configure.ac b/configure.ac index 07ff69ad5c..cd53a21278 100755 --- a/configure.ac +++ b/configure.ac @@ -293,6 +293,7 @@ PKG_CHECK_MODULES(E_INFO, [ eldbus >= ${efl_version} xkbcommon capi-media-streamrecorder + wayland-client ]) PKG_CHECK_EXISTS([xkeyboard-config],[ diff --git a/packaging/enlightenment.spec b/packaging/enlightenment.spec index 37ac686c7c..76d743add7 100644 --- a/packaging/enlightenment.spec +++ b/packaging/enlightenment.spec @@ -57,6 +57,7 @@ BuildRequires: pkgconfig(presentation-time-server) Requires: libwayland-extension-server # for recording video in enlightenment_info +BuildRequires: pkgconfig(wayland-client) BuildRequires: pkgconfig(capi-media-streamrecorder) %if "%{LIBGOMP}" == "use" diff --git a/src/bin/e_info_client_screen_recorder.c b/src/bin/e_info_client_screen_recorder.c index 6bfdab2e62..32b48e4fb1 100644 --- a/src/bin/e_info_client_screen_recorder.c +++ b/src/bin/e_info_client_screen_recorder.c @@ -1,8 +1,8 @@ #include #include #include -#include #include +#include #include "e_info_client_screen_recorder.h" int _log_dom = -1; @@ -13,20 +13,23 @@ int _log_dom = -1; #define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__) #define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__) +typedef struct +{ + int w, h; +} Screen_Recorder_Size; + typedef struct { char filename[PATH_MAX]; int framerate; - struct - { - int w, h; - } resolution; + Screen_Recorder_Size resolution; } Screen_Recorder_Args; streamrecorder_h _stream_recorder; static Eina_Bool _screen_recorder_efl_init(void); static void _screen_recorder_efl_shutdown(void); +static Eina_Bool _screen_recorder_output_size_get(Screen_Recorder_Size *out); static Eina_Bool _screen_recorder_parse_args(int argc, char **argv, Screen_Recorder_Args *args); static Eina_Bool _stream_recorder_run(const char *filename, int framerate, int w, int h); @@ -79,6 +82,12 @@ e_info_client_screen_recorder_run(int argc, char **argv) setenv("XDG_RUNTIME_DIR", "/run", 1); } + if (!_screen_recorder_output_size_get(&args.resolution)) + { + WRN("failed to get output size, use default size (%dx%d)", + args.resolution.w, args.resolution.h); + } + res = _screen_recorder_parse_args(argc, argv, &args); if (!res) { @@ -367,3 +376,115 @@ fail: return EINA_FALSE; } + +static void +_screen_recorder_cb_wl_registry_global(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) +{ + struct wl_output **output; + + if (strcmp(interface, "wl_output") != 0) + return; + + + output = (struct wl_output **)data; + *output = wl_registry_bind(registry, id, &wl_output_interface, version); +} + +static void +_screen_recorder_cb_wl_registry_global_remove(void *data EINA_UNUSED, struct wl_registry *registry EINA_UNUSED, uint32_t name EINA_UNUSED) +{ +} + +static const struct wl_registry_listener _registry_listener = +{ + _screen_recorder_cb_wl_registry_global, + _screen_recorder_cb_wl_registry_global_remove, +}; + +static void +_screen_recorder_cb_wl_output_geometry(void *data EINA_UNUSED, struct wl_output *output EINA_UNUSED, int32_t x EINA_UNUSED, int32_t y EINA_UNUSED, int32_t pw EINA_UNUSED, int32_t ph EINA_UNUSED, int32_t subpixel EINA_UNUSED, const char *make EINA_UNUSED, const char *model EINA_UNUSED, int32_t transform EINA_UNUSED) +{ +} + +static void +_screen_recorder_cb_wl_output_mode(void *data, struct wl_output *output EINA_UNUSED, unsigned int flags, int w, int h, int refresh EINA_UNUSED) +{ + Screen_Recorder_Size *size; + + if (!(flags & WL_OUTPUT_MODE_CURRENT)) + return; + + INF("wl_output.mode: (%dx%d)", w, h); + size = data; + size->w = w; + size->h = h; +} + +static void +_screen_recorder_cb_wl_output_done(void *data EINA_UNUSED, struct wl_output *output EINA_UNUSED) +{ +} + +static void +_screen_recorder_cb_wl_output_scale(void *data EINA_UNUSED, struct wl_output *output EINA_UNUSED, int32_t factor EINA_UNUSED) +{ +} + +static const struct wl_output_listener _output_listener = +{ + _screen_recorder_cb_wl_output_geometry, + _screen_recorder_cb_wl_output_mode, + _screen_recorder_cb_wl_output_done, + _screen_recorder_cb_wl_output_scale, +}; + +static Eina_Bool +_screen_recorder_output_size_get(Screen_Recorder_Size *out) +{ + struct wl_display *display; + struct wl_registry *registry; + struct wl_output *output = NULL; + Screen_Recorder_Size size = {0, }; + Eina_Bool ret = EINA_FALSE; + + display = wl_display_connect(NULL); + if (!display) + { + ERR("failed to connect wl_display"); + return ret; + } + + registry = wl_display_get_registry(display); + if (!registry) + { + ERR("failed to get wl_registry"); + goto err_reg; + } + + wl_registry_add_listener(registry, &_registry_listener, &output); + wl_display_roundtrip(display); + + if (!output) + { + ERR("failed to bind wl_output"); + goto err_output; + } + + wl_output_add_listener(output, &_output_listener, &size); + wl_display_roundtrip(display); + + ret = (size.w != 0); + if (ret) + { + out->w = size.w; + out->h = size.h; + } + + wl_output_destroy(output); +err_output: + wl_registry_destroy(registry); +err_reg: + wl_display_disconnect(display); + + return ret; +}