summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@yahoo.com>2018-08-22 21:56:51 +0300
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2018-08-22 21:59:42 +0300
commit5ffc8ec640f325ab31c339f306888b3bf30dea5a (patch)
treee31aef76eb4713514fec4bf0366f9a1a88bdb767
parent1551b5358f7b04b1381220406c9999f35d0b4440 (diff)
Player: send back screenshot data when remotely requested
When the external injection is used (scenario injected by an external tool via Eina Debug) and a screenshot is required, the data is sent to the injector.
-rw-r--r--src/bin/player.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/bin/player.c b/src/bin/player.c
index 72b9d40..e7d3dfe 100644
--- a/src/bin/player.c
+++ b/src/bin/player.c
@@ -101,6 +101,13 @@ foo(Eina_Debug_Session *session, int srcid, void *buffer, int size) \
101 __s; \ 101 __s; \
102}) 102})
103 103
104#define STORE_INT(_buf, __i) \
105({ \
106 int __si = SWAP_32(__i); \
107 memcpy(_buf, &__si, sizeof(int)); \
108 _buf += sizeof(int); \
109})
110
104typedef enum 111typedef enum
105{ 112{
106 FTYPE_UNKNOWN, 113 FTYPE_UNKNOWN,
@@ -130,6 +137,10 @@ static int _cur_shot_id = 0;
130static Eina_Bool _shot_needed = EINA_FALSE; 137static Eina_Bool _shot_needed = EINA_FALSE;
131static Eina_Bool _scan_objects = EINA_FALSE, _disable_shots = EINA_FALSE; 138static Eina_Bool _scan_objects = EINA_FALSE, _disable_shots = EINA_FALSE;
132 139
140static Eina_Debug_Session *_last_debug_session = NULL;
141static int _last_debug_src_cid = 0;
142static int _take_shot_op = EINA_DEBUG_OPCODE_INVALID;
143
133static Eina_Bool _stabilization_timer_cb(void *); 144static Eina_Bool _stabilization_timer_cb(void *);
134 145
135static Eina_Bool _exit_required = EINA_FALSE; 146static Eina_Bool _exit_required = EINA_FALSE;
@@ -222,6 +233,16 @@ _evas_render_post_cb(void *data EINA_UNUSED, const Efl_Event *event)
222 ex_shot->pixels = NULL; 233 ex_shot->pixels = NULL;
223 _printf(1, "Shot taken (in %s).\n", _dest); 234 _printf(1, "Shot taken (in %s).\n", _dest);
224 } 235 }
236 else if (_dest_type == FTYPE_REMOTE)
237 {
238 int len = sizeof(int) + sizeof(int) + ex_shot->w * ex_shot->h * 4;
239 char *buf = alloca(len);
240 char *tmp = buf;
241 STORE_INT(tmp, ex_shot->w);
242 STORE_INT(tmp, ex_shot->h);
243 memcpy(tmp, ex_shot->pixels, ex_shot->w * ex_shot->h * 4);
244 eina_debug_session_send(_last_debug_session, _last_debug_src_cid, _take_shot_op, buf, len);
245 }
225 } 246 }
226 exactness_image_free(ex_shot); 247 exactness_image_free(ex_shot);
227 efl_key_data_set(event->object, "_shot", NULL); 248 efl_key_data_set(event->object, "_shot", NULL);
@@ -262,6 +283,10 @@ _shot_do(Evas *e)
262 _dest_unit->nb_shots++; 283 _dest_unit->nb_shots++;
263 e_data = ex_img; 284 e_data = ex_img;
264 } 285 }
286 else if (_dest_type == FTYPE_REMOTE)
287 {
288 e_data = e;
289 }
265 } 290 }
266 efl_key_data_set(e, "_shot", e_data); 291 efl_key_data_set(e, "_shot", e_data);
267 _shot_needed = EINA_TRUE; 292 _shot_needed = EINA_TRUE;
@@ -687,11 +712,13 @@ _main_loop_key_up_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNU
687} 712}
688 713
689static void 714static void
690_main_loop_take_shot_cb(Eina_Debug_Session *session EINA_UNUSED, int srcid EINA_UNUSED, void *buffer, int size EINA_UNUSED) 715_main_loop_take_shot_cb(Eina_Debug_Session *session, int srcid, void *buffer, int size EINA_UNUSED)
691{ 716{
692 char *buf = buffer; 717 char *buf = buffer;
693 int n_evas = EXTRACT_INT(buf); 718 int n_evas = EXTRACT_INT(buf);
694 _feed_event(EXACTNESS_ACTION_TAKE_SHOT, n_evas, NULL); 719 _feed_event(EXACTNESS_ACTION_TAKE_SHOT, n_evas, NULL);
720 _last_debug_session = session;
721 _last_debug_src_cid = srcid;
695} 722}
696 723
697static void 724static void
@@ -738,7 +765,7 @@ EINA_DEBUG_OPCODES_ARRAY_DEFINE(_debug_ops,
738 {"Exactness/Actions/Multi Move", NULL, &_multi_move_cb}, 765 {"Exactness/Actions/Multi Move", NULL, &_multi_move_cb},
739 {"Exactness/Actions/Key Down", NULL, &_key_down_cb}, 766 {"Exactness/Actions/Key Down", NULL, &_key_down_cb},
740 {"Exactness/Actions/Key Up", NULL, &_key_up_cb}, 767 {"Exactness/Actions/Key Up", NULL, &_key_up_cb},
741 {"Exactness/Actions/Take Shot", NULL, &_take_shot_cb}, 768 {"Exactness/Actions/Take Shot", &_take_shot_op, &_take_shot_cb},
742 {"Exactness/Actions/EFL Event", NULL, &_efl_event_cb}, 769 {"Exactness/Actions/EFL Event", NULL, &_efl_event_cb},
743 {"Exactness/Actions/Stabilize", NULL, &_stabilize_cb}, 770 {"Exactness/Actions/Stabilize", NULL, &_stabilize_cb},
744 {"Exactness/Actions/Finish", NULL, &_finish_cb}, 771 {"Exactness/Actions/Finish", NULL, &_finish_cb},
@@ -1034,7 +1061,11 @@ int main(int argc, char **argv)
1034 fprintf(stderr, "Cannot inject events from a source file and from outside simultaneously\n"); 1061 fprintf(stderr, "Cannot inject events from a source file and from outside simultaneously\n");
1035 goto end; 1062 goto end;
1036 } 1063 }
1037 if (external_injection) _src_type = FTYPE_REMOTE; 1064 if (external_injection)
1065 {
1066 _src_type = FTYPE_REMOTE;
1067 if (_dest_type == FTYPE_UNKNOWN) _dest_type = FTYPE_REMOTE;
1068 }
1038 if (src) 1069 if (src)
1039 { 1070 {
1040 _src_filename = eina_stringshare_add(src); 1071 _src_filename = eina_stringshare_add(src);