#include <unistd.h>
#include <Eina.h>
#include <Ecore.h>
-#include <Ecore_Input.h>
#include <streamrecorder.h>
+#include <wayland-client.h>
#include "e_info_client_screen_recorder.h"
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);
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)
{
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;
+}