summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/lib/emotion_smart.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-10 03:43:32 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-10 03:43:32 +0000
commitdfb84c1657bfb14a5236b881193b81f4c0b8a69b (patch)
treeb51b210fc88a21eec8e5907b8bbfe12ebc669f90 /legacy/emotion/src/lib/emotion_smart.c
parent532284dbbe4259a9f2291f44d3eff376849e8031 (diff)
efl: merge emotion.
this one was quite a huge work, but hopefully it's correct. NOTES: * removed vlc generic module, it should go into a separate package. * gstreamer is enabled by default (see --disable-gstreamer) * xine is disabled by default (see --enable-gstreamer) * generic is always built statically if supported * gstreamer and xine can't be configured as static (just lacks command line options, build system supports it) * v4l2 is enabled by default on linux if eeze is built (see --disable-v4l2) * emotion_test moved to src/tests/emotion and depends on EFL_ENABLE_TESTS (--with-tests), but is still installed if enabled. TODO (need your help!): * fix warnings with gstreamer and xine engine * call engine shutdown functions if building as static * remove direct usage of PACKAGE_*_DIR and use eina_prefix * add eina_prefix checkme file as evas and others * add support for $EFL_RUN_IN_TREE * create separate package for emotion_generic_modules * check docs hierarchy (doxygen is segv'in here) SVN revision: 82501
Diffstat (limited to 'legacy/emotion/src/lib/emotion_smart.c')
-rw-r--r--legacy/emotion/src/lib/emotion_smart.c2133
1 files changed, 0 insertions, 2133 deletions
diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c
deleted file mode 100644
index 0546d02aae..0000000000
--- a/legacy/emotion/src/lib/emotion_smart.c
+++ /dev/null
@@ -1,2133 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <Evas.h>
6#include <Ecore.h>
7
8#ifdef HAVE_EIO
9# include <math.h>
10# include <Eio.h>
11#endif
12
13#include "Emotion.h"
14#include "emotion_private.h"
15
16#ifdef _WIN32
17# define FMT_UCHAR "%c"
18#else
19# define FMT_UCHAR "%hhu"
20#endif
21
22#define E_SMART_OBJ_GET(smart, o, type) \
23 { \
24 char *_e_smart_str; \
25 \
26 if (!o) return; \
27 smart = evas_object_smart_data_get(o); \
28 if (!smart) return; \
29 _e_smart_str = (char *)evas_object_type_get(o); \
30 if (!_e_smart_str) return; \
31 if (strcmp(_e_smart_str, type)) return; \
32 }
33
34#define E_SMART_OBJ_GET_RETURN(smart, o, type, ret) \
35 { \
36 char *_e_smart_str; \
37 \
38 if (!o) return ret; \
39 smart = evas_object_smart_data_get(o); \
40 if (!smart) return ret; \
41 _e_smart_str = (char *)evas_object_type_get(o); \
42 if (!_e_smart_str) return ret; \
43 if (strcmp(_e_smart_str, type)) return ret; \
44 }
45
46#define DBG(...) EINA_LOG_DOM_DBG(_log_domain, __VA_ARGS__)
47#define INF(...) EINA_LOG_DOM_INFO(_log_domain, __VA_ARGS__)
48#define WRN(...) EINA_LOG_DOM_WARN(_log_domain, __VA_ARGS__)
49#define ERR(...) EINA_LOG_DOM_ERR(_log_domain, __VA_ARGS__)
50#define CRITICAL(...) EINA_LOG_DOM_CRIT(_log_domain, __VA_ARGS__)
51
52#define E_OBJ_NAME "emotion_object"
53
54typedef struct _Smart_Data Smart_Data;
55
56struct _Smart_Data
57{
58 EINA_REFCOUNT;
59 Emotion_Video_Module *module;
60 void *video_data;
61
62 char *module_name;
63
64 const char *file;
65 Evas_Object *obj;
66 Evas_Object *bg;
67
68 Ecore_Job *job;
69
70 char *title;
71
72#ifdef HAVE_EIO
73 Eio_File *load_xattr;
74 Eio_File *save_xattr;
75#endif
76
77 struct {
78 char *info;
79 double stat;
80 } progress;
81 struct {
82 char *file;
83 int num;
84 } ref;
85 struct {
86 int button_num;
87 int button;
88 } spu;
89 struct {
90 int l; /* left */
91 int r; /* right */
92 int t; /* top */
93 int b; /* bottom */
94 Evas_Object *clipper;
95 } crop;
96
97 struct {
98 int w, h;
99 } video;
100 struct {
101 double w, h;
102 } fill;
103
104 double ratio;
105 double pos;
106 double remember_jump;
107 double seek_pos;
108 double len;
109
110 Emotion_Module_Options module_options;
111
112 Emotion_Suspend state;
113 Emotion_Aspect aspect;
114
115 Ecore_Animator *anim;
116
117 Eina_Bool open : 1;
118 Eina_Bool play : 1;
119 Eina_Bool remember_play : 1;
120 Eina_Bool seek : 1;
121 Eina_Bool seeking : 1;
122};
123
124static void _mouse_move(void *data, Evas *ev, Evas_Object *obj, void *event_info);
125static void _mouse_down(void *data, Evas *ev, Evas_Object *obj, void *event_info);
126static void _pos_set_job(void *data);
127static void _pixels_get(void *data, Evas_Object *obj);
128
129static void _smart_init(void);
130static void _smart_add(Evas_Object * obj);
131static void _smart_del(Evas_Object * obj);
132static void _smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y);
133static void _smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h);
134static void _smart_show(Evas_Object * obj);
135static void _smart_hide(Evas_Object * obj);
136static void _smart_color_set(Evas_Object * obj, int r, int g, int b, int a);
137static void _smart_clip_set(Evas_Object * obj, Evas_Object * clip);
138static void _smart_clip_unset(Evas_Object * obj);
139
140/**********************************/
141/* Globals for the E Video Object */
142/**********************************/
143static Evas_Smart *smart = NULL;
144static Eina_Hash *_backends = NULL;
145static Eina_Array *_modules = NULL;
146static int _log_domain = -1;
147
148static const char *_backend_priority[] = {
149 "gstreamer",
150 "xine",
151 "generic"
152};
153
154static const char SIG_FRAME_DECODE[] = "frame_decode";
155static const char SIG_POSITION_UPDATE[] = "position_update";
156static const char SIG_LENGTH_CHANGE[] = "length_change";
157static const char SIG_FRAME_RESIZE[] = "frame_resize";
158static const char SIG_DECODE_STOP[] = "decode_stop";
159static const char SIG_PLAYBACK_STARTED[] = "playback_started";
160static const char SIG_PLAYBACK_FINISHED[] = "playback_finished";
161static const char SIG_AUDIO_LEVEL_CHANGE[] = "audio_level_change";
162static const char SIG_CHANNELS_CHANGE[] = "channels_change";
163static const char SIG_TITLE_CHANGE[] = "title_change";
164static const char SIG_PROGRESS_CHANGE[] = "progress_change";
165static const char SIG_REF_CHANGE[] = "ref_change";
166static const char SIG_BUTTON_NUM_CHANGE[] = "button_num_change";
167static const char SIG_BUTTON_CHANGE[] = "button_change";
168static const char SIG_OPEN_DONE[] = "open_done";
169static const char SIG_POSITION_SAVE_SUCCEED[] = "position_save,succeed";
170static const char SIG_POSITION_SAVE_FAILED[] = "position_save,failed";
171static const char SIG_POSITION_LOAD_SUCCEED[] = "position_load,succeed";
172static const char SIG_POSITION_LOAD_FAILED[] = "position_load,failed";
173
174static const Evas_Smart_Cb_Description _smart_callbacks[] = {
175 {SIG_FRAME_DECODE, ""},
176 {SIG_POSITION_UPDATE, ""},
177 {SIG_LENGTH_CHANGE, ""},
178 {SIG_FRAME_RESIZE, ""},
179 {SIG_DECODE_STOP, ""},
180 {SIG_PLAYBACK_STARTED, ""},
181 {SIG_PLAYBACK_FINISHED, ""},
182 {SIG_AUDIO_LEVEL_CHANGE, ""},
183 {SIG_CHANNELS_CHANGE, ""},
184 {SIG_TITLE_CHANGE, ""},
185 {SIG_PROGRESS_CHANGE, ""},
186 {SIG_REF_CHANGE, ""},
187 {SIG_BUTTON_NUM_CHANGE, ""},
188 {SIG_BUTTON_CHANGE, ""},
189 {SIG_OPEN_DONE, ""},
190 {NULL, NULL}
191};
192
193static void
194_emotion_image_data_zero(Evas_Object *img)
195{
196 void *data;
197
198 data = evas_object_image_data_get(img, 1);
199 if (data)
200 {
201 int w, h, sz = 0;
202 Evas_Colorspace cs;
203
204 evas_object_image_size_get(img, &w, &h);
205 cs = evas_object_image_colorspace_get(img);
206 if (cs == EVAS_COLORSPACE_ARGB8888)
207 sz = w * h * 4;
208 if ((cs == EVAS_COLORSPACE_YCBCR422P601_PL) ||
209 (cs == EVAS_COLORSPACE_YCBCR422P709_PL))
210 sz = h * 2 * sizeof(unsigned char *);
211 if (sz != 0) memset(data, 0, sz);
212 }
213 evas_object_image_data_set(img, data);
214}
215
216static void
217_emotion_module_close(Emotion_Video_Module *mod, void *video)
218{
219 if (!mod) return;
220 if (mod->plugin->close && video)
221 mod->plugin->close(mod, video);
222 /* FIXME: we can't go dlclosing here as a thread still may be running from
223 * the module - this in theory will leak- but it shouldn't be too bad and
224 * mean that once a module is dlopened() it can't be closed - its refcount
225 * will just keep going up
226 */
227}
228
229static void
230_smart_data_free(Smart_Data *sd)
231{
232 if (sd->video_data) sd->module->file_close(sd->video_data);
233 _emotion_module_close(sd->module, sd->video_data);
234 evas_object_del(sd->obj);
235 evas_object_del(sd->crop.clipper);
236 evas_object_del(sd->bg);
237 eina_stringshare_del(sd->file);
238 free(sd->module_name);
239 if (sd->job) ecore_job_del(sd->job);
240 if (sd->anim) ecore_animator_del(sd->anim);
241 free(sd->progress.info);
242 free(sd->ref.file);
243 free(sd);
244
245 ecore_shutdown();
246}
247
248EAPI Eina_Bool
249_emotion_module_register(const char *name, Emotion_Module_Open mod_open, Emotion_Module_Close mod_close)
250{
251 Eina_Emotion_Plugins *plugin;
252
253 plugin = malloc(sizeof (Eina_Emotion_Plugins));
254 if (!plugin) return EINA_FALSE;
255
256 plugin->open = mod_open;
257 plugin->close = mod_close;
258
259 return eina_hash_add(_backends, name, plugin);
260}
261
262EAPI Eina_Bool
263_emotion_module_unregister(const char *name)
264{
265 return eina_hash_del(_backends, name, NULL);
266}
267
268static const char *
269_emotion_module_open(const char *name, Evas_Object *obj, Emotion_Video_Module **mod, void **video)
270{
271 Eina_Emotion_Plugins *plugin;
272 Smart_Data *sd;
273 unsigned int i = 0;
274
275 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
276 if (!_backends)
277 {
278 ERR("No backend loaded");
279 return NULL;
280 }
281
282 if (!name && getenv("EMOTION_ENGINE"))
283 name = getenv("EMOTION_ENGINE");
284
285 /* FIXME: Always look for a working backend. */
286 retry:
287 if (!name || i > 0)
288 name = _backend_priority[i++];
289
290 plugin = eina_hash_find(_backends, name);
291 if (!plugin)
292 {
293 if (i != 0 && i < (sizeof (_backend_priority) / sizeof (char*)))
294 goto retry;
295
296 ERR("No backend loaded");
297 return EINA_FALSE;
298 }
299
300 if (plugin->open(obj, (const Emotion_Video_Module **) mod, video, &(sd->module_options)))
301 {
302 if (*mod)
303 {
304 (*mod)->plugin = plugin;
305 return name;
306 }
307 }
308
309 if (i != 0 && i < (sizeof (_backend_priority) / sizeof (char*)))
310 goto retry;
311
312 ERR("Unable to load module: %s", name);
313
314 return NULL;
315}
316
317static void
318_clipper_position_size_update(Evas_Object *obj, int x, int y, int w, int h, int vid_w, int vid_h)
319{
320 Smart_Data *sd;
321 double scale_w, scale_h;
322
323 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
324
325 if (vid_w == 0 || vid_h == 0)
326 {
327 evas_object_image_fill_set(sd->obj, 0, 0, 0, 0);
328 evas_object_move(sd->obj, x, y);
329 evas_object_resize(sd->obj, 0, 0);
330 evas_object_move(sd->crop.clipper, x, y);
331 evas_object_resize(sd->crop.clipper, 0, 0);
332 }
333 else
334 {
335 evas_object_move(sd->crop.clipper, x, y);
336 scale_w = (double)w / (double)(vid_w - sd->crop.l - sd->crop.r);
337 scale_h = (double)h / (double)(vid_h - sd->crop.t - sd->crop.b);
338
339 if (sd->fill.w < 0 && sd->fill.h < 0)
340 evas_object_image_fill_set(sd->obj, 0, 0, vid_w * scale_w, vid_h * scale_h);
341 else
342 evas_object_image_fill_set(sd->obj, 0, 0, sd->fill.w * w, sd->fill.h * h);
343 evas_object_resize(sd->obj, vid_w * scale_w, vid_h * scale_h);
344 evas_object_move(sd->obj, x - sd->crop.l * scale_w, y - sd->crop.t * scale_h);
345 evas_object_resize(sd->crop.clipper, w, h);
346 }
347}
348
349/*******************************/
350/* Externally accessible calls */
351/*******************************/
352
353
354
355EAPI Evas_Object *
356emotion_object_add(Evas *evas)
357{
358 _smart_init();
359 return evas_object_smart_add(evas, smart);
360}
361
362EAPI Evas_Object *
363emotion_object_image_get(const Evas_Object *obj)
364{
365 Smart_Data *sd;
366
367 sd = evas_object_smart_data_get(obj);
368 if (!sd) return NULL;
369 return sd->obj;
370}
371
372EAPI void
373emotion_object_module_option_set(Evas_Object *obj, const char *opt, const char *val)
374{
375 Smart_Data *sd;
376
377 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
378 if ((!opt) || (!val)) return;
379
380 if (!strcmp(opt, "player"))
381 eina_stringshare_replace(&sd->module_options.player, val);
382}
383
384EAPI Eina_Bool
385emotion_object_init(Evas_Object *obj, const char *module_filename)
386{
387 Smart_Data *sd;
388 const char *file;
389
390 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
391
392 if ((sd->module_name) && module_filename && (!strcmp(sd->module_name, module_filename)))
393 return EINA_TRUE;
394 free(sd->module_name);
395 sd->module_name = NULL;
396
397 file = sd->file;
398 sd->file = NULL;
399
400 free(sd->title);
401 sd->title = NULL;
402 free(sd->progress.info);
403 sd->progress.info = NULL;
404 sd->progress.stat = 0.0;
405 free(sd->ref.file);
406 sd->ref.file = NULL;
407 sd->ref.num = 0;
408 sd->spu.button_num = 0;
409 sd->spu.button = -1;
410 sd->ratio = 1.0;
411 sd->pos = 0;
412 sd->remember_jump = 0;
413 sd->seek_pos = 0;
414 sd->len = 0;
415 sd->remember_play = 0;
416
417 if (sd->anim) ecore_animator_del(sd->anim);
418 sd->anim = NULL;
419
420 _emotion_module_close(sd->module, sd->video_data);
421 sd->module = NULL;
422 sd->video_data = NULL;
423
424 module_filename = _emotion_module_open(module_filename, obj, &sd->module, &sd->video_data);
425 if (!module_filename)
426 return EINA_FALSE;
427
428 sd->module_name = strdup(module_filename);
429
430 if (file)
431 {
432 emotion_object_file_set(obj, file);
433 eina_stringshare_del(file);
434 }
435
436 return EINA_TRUE;
437}
438
439EAPI Eina_Bool
440emotion_object_file_set(Evas_Object *obj, const char *file)
441{
442 Smart_Data *sd;
443
444 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EINA_FALSE);
445
446 DBG("file=%s", file);
447 if (!sd->module) return EINA_FALSE;
448
449 sd->video.w = 0;
450 sd->video.h = 0;
451 if ((file) && (sd->file) &&
452 ((file == sd->file) || (!strcmp(file, sd->file)))) return EINA_FALSE;
453 if ((file) && (file[0] != 0))
454 {
455 eina_stringshare_replace(&sd->file, file);
456 sd->module->file_close(sd->video_data);
457 evas_object_image_data_set(sd->obj, NULL);
458 evas_object_image_size_set(sd->obj, 1, 1);
459 _emotion_image_data_zero(sd->obj);
460 sd->open = 0;
461 if (!sd->module->file_open(sd->file, obj, sd->video_data))
462 return EINA_FALSE;
463 sd->pos = 0.0;
464 if (sd->play) sd->module->play(sd->video_data, 0.0);
465 }
466 else
467 {
468 if (sd->video_data && sd->module)
469 {
470 sd->module->file_close(sd->video_data);
471 evas_object_image_data_set(sd->obj, NULL);
472 evas_object_image_size_set(sd->obj, 1, 1);
473 _emotion_image_data_zero(sd->obj);
474 }
475 eina_stringshare_replace(&sd->file, NULL);
476 }
477
478 if (sd->anim) ecore_animator_del(sd->anim);
479 sd->anim = NULL;
480
481#ifdef HAVE_EIO
482 /* Only cancel the load_xattr or we will loose ref to time_seek stringshare */
483 if (sd->load_xattr) eio_file_cancel(sd->load_xattr);
484 sd->load_xattr = NULL;
485 if (sd->save_xattr) eio_file_cancel(sd->save_xattr);
486 sd->save_xattr = NULL;
487#endif
488
489 return EINA_TRUE;
490}
491
492EAPI const char *
493emotion_object_file_get(const Evas_Object *obj)
494{
495 Smart_Data *sd;
496
497 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
498 return sd->file;
499}
500
501static void
502_emotion_aspect_borders_apply(Evas_Object *obj, Smart_Data *sd, int w, int h, int iw, int ih)
503{
504 int x, y;
505
506 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
507
508 /* applying calculated borders */
509 if (sd->crop.l == 0 && sd->crop.r == 0 &&
510 sd->crop.t == 0 && sd->crop.b == 0)
511 {
512 Evas_Object *old_clipper;
513 if (sd->crop.clipper)
514 {
515 old_clipper = evas_object_clip_get(sd->crop.clipper);
516 evas_object_clip_unset(sd->obj);
517 evas_object_clip_set(sd->obj, old_clipper);
518 evas_object_del(sd->crop.clipper);
519 sd->crop.clipper = NULL;
520 }
521 }
522 else
523 {
524 if (!sd->crop.clipper)
525 {
526 Evas_Object *old_clipper;
527 sd->crop.clipper = evas_object_rectangle_add(
528 evas_object_evas_get(obj));
529 evas_object_color_set(sd->crop.clipper, 255, 255, 255, 255);
530 evas_object_smart_member_add(sd->crop.clipper, obj);
531 old_clipper = evas_object_clip_get(sd->obj);
532 evas_object_clip_set(sd->obj, sd->crop.clipper);
533 evas_object_clip_set(sd->crop.clipper, old_clipper);
534 if (evas_object_visible_get(sd->obj))
535 evas_object_show(sd->crop.clipper);
536 }
537 }
538 _clipper_position_size_update(obj, x, y, w, h, iw, ih);
539}
540
541static void
542_emotion_object_aspect_border_apply(Evas_Object *obj, Smart_Data *sd, int w, int h)
543{
544 int iw, ih;
545 double ir;
546 double r;
547
548 int aspect_opt = 0;
549
550 iw = sd->video.w;
551 ih = sd->video.h;
552
553 ir = (double)iw / ih;
554 r = (double)w / h;
555
556 /* First check if we should fit the width or height of the video inside the
557 * width/height of the object. This check takes into account the original
558 * aspect ratio and the object aspect ratio, if we are keeping both sizes or
559 * cropping the exceding area.
560 */
561 if (sd->aspect == EMOTION_ASPECT_KEEP_NONE)
562 {
563 sd->crop.l = 0;
564 sd->crop.r = 0;
565 sd->crop.t = 0;
566 sd->crop.b = 0;
567 aspect_opt = 0; // just ignore keep_aspect
568 }
569 else if (sd->aspect == EMOTION_ASPECT_KEEP_WIDTH)
570 {
571 aspect_opt = 1;
572 }
573 else if (sd->aspect == EMOTION_ASPECT_KEEP_HEIGHT)
574 {
575 aspect_opt = 2;
576 }
577 else if (sd->aspect == EMOTION_ASPECT_KEEP_BOTH)
578 {
579 if (ir > r)
580 aspect_opt = 1;
581 else
582 aspect_opt = 2;
583 }
584 else if (sd->aspect == EMOTION_ASPECT_CROP)
585 {
586 if (ir > r)
587 aspect_opt = 2;
588 else
589 aspect_opt = 1;
590 }
591 else if (sd->aspect == EMOTION_ASPECT_CUSTOM)
592 {
593 // nothing to do, just respect the border settings
594 aspect_opt = 0;
595 }
596
597 /* updating borders based on keep_aspect settings */
598 if (aspect_opt == 1) // keep width
599 {
600 int th, dh;
601 double scale;
602
603 sd->crop.l = 0;
604 sd->crop.r = 0;
605 scale = (double)iw / w;
606 th = h * scale;
607 dh = ih - th;
608 sd->crop.t = sd->crop.b = dh / 2;
609 }
610 else if (aspect_opt == 2) // keep height
611 {
612 int tw, dw;
613 double scale;
614
615 sd->crop.t = 0;
616 sd->crop.b = 0;
617 scale = (double)ih / h;
618 tw = w * scale;
619 dw = iw - tw;
620 sd->crop.l = sd->crop.r = dw / 2;
621 }
622
623 _emotion_aspect_borders_apply(obj, sd, w, h, iw, ih);
624}
625
626EAPI void
627emotion_object_border_set(Evas_Object *obj, int l, int r, int t, int b)
628{
629 Smart_Data *sd;
630 int w, h;
631
632 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
633
634 sd->aspect = EMOTION_ASPECT_CUSTOM;
635 sd->crop.l = -l;
636 sd->crop.r = -r;
637 sd->crop.t = -t;
638 sd->crop.b = -b;
639 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
640 _emotion_object_aspect_border_apply(obj, sd, w, h);
641}
642
643EAPI void
644emotion_object_border_get(const Evas_Object *obj, int *l, int *r, int *t, int *b)
645{
646 Smart_Data *sd;
647
648 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
649 *l = -sd->crop.l;
650 *r = -sd->crop.r;
651 *t = -sd->crop.t;
652 *b = -sd->crop.b;
653}
654
655EAPI void
656emotion_object_bg_color_set(Evas_Object *obj, int r, int g, int b, int a)
657{
658 Smart_Data *sd;
659
660 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
661
662 evas_object_color_set(sd->bg, r, g, b, a);
663
664 if (!evas_object_visible_get(obj))
665 return;
666
667 if (a > 0)
668 evas_object_show(sd->bg);
669 else
670 evas_object_hide(sd->bg);
671}
672
673EAPI void
674emotion_object_bg_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a)
675{
676 Smart_Data *sd;
677
678 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
679 evas_object_color_get(sd->bg, r, g, b, a);
680}
681
682EAPI void
683emotion_object_keep_aspect_set(Evas_Object *obj, Emotion_Aspect a)
684{
685 Smart_Data *sd;
686 int w, h;
687
688 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
689
690 if (a == sd->aspect)
691 return;
692
693 sd->aspect = a;
694 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
695 _emotion_object_aspect_border_apply(obj, sd, w, h);
696}
697
698EAPI Emotion_Aspect
699emotion_object_keep_aspect_get(const Evas_Object *obj)
700{
701 Smart_Data *sd;
702
703 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EMOTION_ASPECT_KEEP_NONE);
704
705 return sd->aspect;
706}
707
708EAPI void
709emotion_object_play_set(Evas_Object *obj, Eina_Bool play)
710{
711 Smart_Data *sd;
712
713 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
714 DBG("play=" FMT_UCHAR ", was=" FMT_UCHAR, play, sd->play);
715 if (play == sd->play) return;
716 if (!sd->module) return;
717 if (!sd->video_data) return;
718 if (!sd->open)
719 {
720 sd->remember_play = play;
721 return;
722 }
723 sd->play = play;
724 sd->remember_play = play;
725 if (sd->state != EMOTION_WAKEUP) emotion_object_suspend_set(obj, EMOTION_WAKEUP);
726 if (sd->play) sd->module->play(sd->video_data, sd->pos);
727 else sd->module->stop(sd->video_data);
728}
729
730EAPI Eina_Bool
731emotion_object_play_get(const Evas_Object *obj)
732{
733 Smart_Data *sd;
734
735 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
736 if (!sd->video_data) return EINA_FALSE;
737
738 return sd->play;
739}
740
741EAPI void
742emotion_object_position_set(Evas_Object *obj, double sec)
743{
744 Smart_Data *sd;
745
746 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
747 DBG("sec=%f", sec);
748 if (!sd->module) return;
749 if (!sd->video_data) return;
750 if (!sd->open)
751 {
752 sd->remember_jump = sec;
753 return ;
754 }
755 sd->remember_jump = 0;
756 sd->seek_pos = sec;
757 sd->seek = 1;
758 sd->pos = sd->seek_pos;
759 if (sd->job) ecore_job_del(sd->job);
760 sd->job = ecore_job_add(_pos_set_job, obj);
761}
762
763EAPI double
764emotion_object_position_get(const Evas_Object *obj)
765{
766 Smart_Data *sd;
767
768 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0.0);
769 if (!sd->module) return 0.0;
770 if (!sd->video_data) return 0.0;
771 if (!sd->module->pos_get) return 0.0;
772 sd->pos = sd->module->pos_get(sd->video_data);
773 return sd->pos;
774}
775
776EAPI double
777emotion_object_buffer_size_get(const Evas_Object *obj)
778{
779 Smart_Data *sd;
780
781 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 1.0);
782 if (!sd->module) return 1.0;
783 if (!sd->video_data) return 1.0;
784 if (!sd->module->buffer_size_get) return 1.0;
785 return sd->module->buffer_size_get(sd->video_data);
786}
787
788EAPI Eina_Bool
789emotion_object_seekable_get(const Evas_Object *obj)
790{
791 Smart_Data *sd;
792
793 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
794 if (!sd->module) return EINA_FALSE;
795 if (!sd->video_data) return EINA_FALSE;
796 return sd->module->seekable(sd->video_data);
797}
798
799EAPI Eina_Bool
800emotion_object_video_handled_get(const Evas_Object *obj)
801{
802 Smart_Data *sd;
803
804 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
805 if (!sd->module) return EINA_FALSE;
806 if (!sd->video_data) return EINA_FALSE;
807 return sd->module->video_handled(sd->video_data);
808}
809
810EAPI Eina_Bool
811emotion_object_audio_handled_get(const Evas_Object *obj)
812{
813 Smart_Data *sd;
814
815 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
816 if (!sd->module) return EINA_FALSE;
817 if (!sd->video_data) return EINA_FALSE;
818 return sd->module->audio_handled(sd->video_data);
819}
820
821EAPI double
822emotion_object_play_length_get(const Evas_Object *obj)
823{
824 Smart_Data *sd;
825
826 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0.0);
827 if (!sd->module) return 0.0;
828 if (!sd->video_data) return 0.0;
829 sd->len = sd->module->len_get(sd->video_data);
830 return sd->len;
831}
832
833EAPI void
834emotion_object_size_get(const Evas_Object *obj, int *iw, int *ih)
835{
836 Smart_Data *sd;
837
838 if (iw) *iw = 0;
839 if (ih) *ih = 0;
840 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
841 if (iw) *iw = sd->video.w;
842 if (ih) *ih = sd->video.h;
843}
844
845EAPI void
846emotion_object_smooth_scale_set(Evas_Object *obj, Eina_Bool smooth)
847{
848 Smart_Data *sd;
849
850 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
851 evas_object_image_smooth_scale_set(sd->obj, smooth);
852}
853
854EAPI Eina_Bool
855emotion_object_smooth_scale_get(const Evas_Object *obj)
856{
857 Smart_Data *sd;
858
859 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
860 return evas_object_image_smooth_scale_get(sd->obj);
861}
862
863EAPI double
864emotion_object_ratio_get(const Evas_Object *obj)
865{
866 Smart_Data *sd;
867
868 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 1.0);
869 if (!sd->module) return 0.0;
870 if (!sd->video_data) return 0.0;
871 return sd->ratio;
872}
873
874/*
875 * Send a control event to the DVD.
876 */
877EAPI void
878emotion_object_event_simple_send(Evas_Object *obj, Emotion_Event ev)
879{
880 Smart_Data *sd;
881
882 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
883 if (!sd->module) return;
884 if (!sd->video_data) return;
885 sd->module->event_feed(sd->video_data, ev);
886}
887
888EAPI void
889emotion_object_audio_volume_set(Evas_Object *obj, double vol)
890{
891 Smart_Data *sd;
892
893 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
894 DBG("vol=%f", vol);
895 if (!sd->module) return;
896 if (!sd->video_data) return;
897 sd->module->audio_channel_volume_set(sd->video_data, vol);
898}
899
900EAPI double
901emotion_object_audio_volume_get(const Evas_Object *obj)
902{
903 Smart_Data *sd;
904
905 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 1.0);
906 if (!sd->module) return 0.0;
907 if (!sd->video_data) return 0.0;
908 return sd->module->audio_channel_volume_get(sd->video_data);
909}
910
911EAPI void
912emotion_object_audio_mute_set(Evas_Object *obj, Eina_Bool mute)
913{
914 Smart_Data *sd;
915
916 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
917 DBG("mute=" FMT_UCHAR, mute);
918 if (!sd->module) return;
919 if (!sd->video_data) return;
920 sd->module->audio_channel_mute_set(sd->video_data, mute);
921}
922
923EAPI Eina_Bool
924emotion_object_audio_mute_get(const Evas_Object *obj)
925{
926 Smart_Data *sd;
927
928 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
929 if (!sd->module) return EINA_FALSE;
930 if (!sd->video_data) return EINA_FALSE;
931 return sd->module->audio_channel_mute_get(sd->video_data);
932}
933
934EAPI int
935emotion_object_audio_channel_count(const Evas_Object *obj)
936{
937 Smart_Data *sd;
938
939 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
940 if (!sd->module) return 0;
941 if (!sd->video_data) return 0;
942 return sd->module->audio_channel_count(sd->video_data);
943}
944
945EAPI const char *
946emotion_object_audio_channel_name_get(const Evas_Object *obj, int channel)
947{
948 Smart_Data *sd;
949
950 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
951 if (!sd->module) return NULL;
952 if (!sd->video_data) return NULL;
953 return sd->module->audio_channel_name_get(sd->video_data, channel);
954}
955
956EAPI void
957emotion_object_audio_channel_set(Evas_Object *obj, int channel)
958{
959 Smart_Data *sd;
960
961 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
962 DBG("channel=%d", channel);
963 if (!sd->module) return;
964 if (!sd->video_data) return;
965 sd->module->audio_channel_set(sd->video_data, channel);
966}
967
968EAPI int
969emotion_object_audio_channel_get(const Evas_Object *obj)
970{
971 Smart_Data *sd;
972
973 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
974 if (!sd->module) return 0;
975 if (!sd->video_data) return 0;
976 return sd->module->audio_channel_get(sd->video_data);
977}
978
979EAPI void
980emotion_object_video_mute_set(Evas_Object *obj, Eina_Bool mute)
981{
982 Smart_Data *sd;
983
984 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
985 DBG("mute=" FMT_UCHAR, mute);
986 if (!sd->module) return;
987 if (!sd->video_data) return;
988 sd->module->video_channel_mute_set(sd->video_data, mute);
989}
990
991EAPI Eina_Bool
992emotion_object_video_mute_get(const Evas_Object *obj)
993{
994 Smart_Data *sd;
995
996 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
997 if (!sd->module) return EINA_FALSE;
998 if (!sd->video_data) return EINA_FALSE;
999 return sd->module->video_channel_mute_get(sd->video_data);
1000}
1001
1002EAPI void
1003emotion_object_video_subtitle_file_set(Evas_Object *obj, const char *filepath)
1004{
1005 Smart_Data *sd;
1006
1007 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1008 DBG("subtitle=%s", filepath);
1009 if (!sd->module) return;
1010 if (!sd->video_data) return;
1011 sd->module->video_subtitle_file_set(sd->video_data, filepath);
1012}
1013
1014EAPI const char *
1015emotion_object_video_subtitle_file_get(const Evas_Object *obj)
1016{
1017 Smart_Data *sd;
1018
1019 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1020 if (!sd->module) return EINA_FALSE;
1021 if (!sd->video_data) return EINA_FALSE;
1022 return sd->module->video_subtitle_file_get(sd->video_data);
1023}
1024
1025EAPI int
1026emotion_object_video_channel_count(const Evas_Object *obj)
1027{
1028 Smart_Data *sd;
1029
1030 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1031 if (!sd->module) return EINA_FALSE;
1032 if (!sd->video_data) return EINA_FALSE;
1033 return sd->module->video_channel_count(sd->video_data);
1034}
1035
1036EAPI const char *
1037emotion_object_video_channel_name_get(const Evas_Object *obj, int channel)
1038{
1039 Smart_Data *sd;
1040
1041 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1042 if (!sd->module) return NULL;
1043 if (!sd->video_data) return NULL;
1044 return sd->module->video_channel_name_get(sd->video_data, channel);
1045}
1046
1047EAPI void
1048emotion_object_video_channel_set(Evas_Object *obj, int channel)
1049{
1050 Smart_Data *sd;
1051
1052 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1053 DBG("channel=%d", channel);
1054 if (!sd->module) return;
1055 if (!sd->video_data) return;
1056 sd->module->video_channel_set(sd->video_data, channel);
1057}
1058
1059EAPI int
1060emotion_object_video_channel_get(const Evas_Object *obj)
1061{
1062 Smart_Data *sd;
1063
1064 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1065 if (!sd->module) return 0;
1066 if (!sd->video_data) return 0;
1067 return sd->module->video_channel_get(sd->video_data);
1068}
1069
1070EAPI void
1071emotion_object_spu_mute_set(Evas_Object *obj, Eina_Bool mute)
1072{
1073 Smart_Data *sd;
1074
1075 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1076 DBG("mute=" FMT_UCHAR, mute);
1077 if (!sd->module) return;
1078 if (!sd->video_data) return;
1079 sd->module->spu_channel_mute_set(sd->video_data, mute);
1080}
1081
1082EAPI Eina_Bool
1083emotion_object_spu_mute_get(const Evas_Object *obj)
1084{
1085 Smart_Data *sd;
1086
1087 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1088 if (!sd->module) return EINA_FALSE;
1089 if (!sd->video_data) return EINA_FALSE;
1090 return sd->module->spu_channel_mute_get(sd->video_data);
1091}
1092
1093EAPI int
1094emotion_object_spu_channel_count(const Evas_Object *obj)
1095{
1096 Smart_Data *sd;
1097
1098 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1099 if (!sd->module) return 0;
1100 if (!sd->video_data) return 0;
1101 return sd->module->spu_channel_count(sd->video_data);
1102}
1103
1104EAPI const char *
1105emotion_object_spu_channel_name_get(const Evas_Object *obj, int channel)
1106{
1107 Smart_Data *sd;
1108
1109 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1110 if (!sd->module) return NULL;
1111 if (!sd->video_data) return NULL;
1112 return sd->module->spu_channel_name_get(sd->video_data, channel);
1113}
1114
1115EAPI void
1116emotion_object_spu_channel_set(Evas_Object *obj, int channel)
1117{
1118 Smart_Data *sd;
1119
1120 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1121 DBG("channel=%d", channel);
1122 if (!sd->module) return;
1123 if (!sd->video_data) return;
1124 sd->module->spu_channel_set(sd->video_data, channel);
1125}
1126
1127EAPI int
1128emotion_object_spu_channel_get(const Evas_Object *obj)
1129{
1130 Smart_Data *sd;
1131
1132 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1133 if (!sd->module) return 0;
1134 if (!sd->video_data) return 0;
1135 return sd->module->spu_channel_get(sd->video_data);
1136}
1137
1138EAPI int
1139emotion_object_chapter_count(const Evas_Object *obj)
1140{
1141 Smart_Data *sd;
1142
1143 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1144 if (!sd->module) return 0;
1145 if (!sd->video_data) return 0;
1146 return sd->module->chapter_count(sd->video_data);
1147}
1148
1149EAPI void
1150emotion_object_chapter_set(Evas_Object *obj, int chapter)
1151{
1152 Smart_Data *sd;
1153
1154 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1155 DBG("chapter=%d", chapter);
1156 if (!sd->module) return;
1157 if (!sd->video_data) return;
1158 sd->module->chapter_set(sd->video_data, chapter);
1159}
1160
1161EAPI int
1162emotion_object_chapter_get(const Evas_Object *obj)
1163{
1164 Smart_Data *sd;
1165
1166 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1167 if (!sd->module) return 0;
1168 if (!sd->video_data) return 0;
1169 return sd->module->chapter_get(sd->video_data);
1170}
1171
1172EAPI const char *
1173emotion_object_chapter_name_get(const Evas_Object *obj, int chapter)
1174{
1175 Smart_Data *sd;
1176
1177 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1178 if (!sd->module) return NULL;
1179 if (!sd->video_data) return NULL;
1180 return sd->module->chapter_name_get(sd->video_data, chapter);
1181}
1182
1183EAPI void
1184emotion_object_play_speed_set(Evas_Object *obj, double speed)
1185{
1186 Smart_Data *sd;
1187
1188 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1189 DBG("speed=%f", speed);
1190 if (!sd->module) return;
1191 if (!sd->video_data) return;
1192 sd->module->speed_set(sd->video_data, speed);
1193}
1194
1195EAPI double
1196emotion_object_play_speed_get(const Evas_Object *obj)
1197{
1198 Smart_Data *sd;
1199
1200 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0.0);
1201 if (!sd->module) return 0.0;
1202 if (!sd->video_data) return 0.0;
1203 return sd->module->speed_get(sd->video_data);
1204}
1205
1206EAPI void
1207emotion_object_eject(Evas_Object *obj)
1208{
1209 Smart_Data *sd;
1210
1211 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1212 if (!sd->module) return;
1213 if (!sd->video_data) return;
1214 sd->module->eject(sd->video_data);
1215}
1216
1217EAPI const char *
1218emotion_object_title_get(const Evas_Object *obj)
1219{
1220 Smart_Data *sd;
1221
1222 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1223 return sd->title;
1224}
1225
1226EAPI const char *
1227emotion_object_progress_info_get(const Evas_Object *obj)
1228{
1229 Smart_Data *sd;
1230
1231 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1232 return sd->progress.info;
1233}
1234
1235EAPI double
1236emotion_object_progress_status_get(const Evas_Object *obj)
1237{
1238 Smart_Data *sd;
1239
1240 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0.0);
1241 return sd->progress.stat;
1242}
1243
1244EAPI const char *
1245emotion_object_ref_file_get(const Evas_Object *obj)
1246{
1247 Smart_Data *sd;
1248
1249 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1250 return sd->ref.file;
1251}
1252
1253EAPI int
1254emotion_object_ref_num_get(const Evas_Object *obj)
1255{
1256 Smart_Data *sd;
1257
1258 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1259 return sd->ref.num;
1260}
1261
1262EAPI int
1263emotion_object_spu_button_count_get(const Evas_Object *obj)
1264{
1265 Smart_Data *sd;
1266
1267 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1268 return sd->spu.button_num;
1269}
1270
1271EAPI int
1272emotion_object_spu_button_get(const Evas_Object *obj)
1273{
1274 Smart_Data *sd;
1275
1276 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1277 return sd->spu.button;
1278}
1279
1280EAPI const char *
1281emotion_object_meta_info_get(const Evas_Object *obj, Emotion_Meta_Info meta)
1282{
1283 Smart_Data *sd;
1284
1285 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1286 if (!sd->module) return NULL;
1287 if (!sd->video_data) return NULL;
1288 switch (meta)
1289 {
1290 case EMOTION_META_INFO_TRACK_TITLE:
1291 return sd->module->meta_get(sd->video_data, META_TRACK_TITLE);
1292 case EMOTION_META_INFO_TRACK_ARTIST:
1293 return sd->module->meta_get(sd->video_data, META_TRACK_ARTIST);
1294 case EMOTION_META_INFO_TRACK_ALBUM:
1295 return sd->module->meta_get(sd->video_data, META_TRACK_ALBUM);
1296 case EMOTION_META_INFO_TRACK_YEAR:
1297 return sd->module->meta_get(sd->video_data, META_TRACK_YEAR);
1298 case EMOTION_META_INFO_TRACK_GENRE:
1299 return sd->module->meta_get(sd->video_data, META_TRACK_GENRE);
1300 case EMOTION_META_INFO_TRACK_COMMENT:
1301 return sd->module->meta_get(sd->video_data, META_TRACK_COMMENT);
1302 case EMOTION_META_INFO_TRACK_DISC_ID:
1303 return sd->module->meta_get(sd->video_data, META_TRACK_DISCID);
1304 default:
1305 break;
1306 }
1307 return NULL;
1308}
1309
1310EAPI void
1311emotion_object_vis_set(Evas_Object *obj, Emotion_Vis visualization)
1312{
1313 Smart_Data *sd;
1314
1315 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1316 DBG("visualization=%d", visualization);
1317 if (!sd->module) return;
1318 if (!sd->video_data) return;
1319 if (!sd->module->vis_set) return;
1320 sd->module->vis_set(sd->video_data, visualization);
1321}
1322
1323EAPI Emotion_Vis
1324emotion_object_vis_get(const Evas_Object *obj)
1325{
1326 Smart_Data *sd;
1327
1328 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EMOTION_VIS_NONE);
1329 if (!sd->module) return EMOTION_VIS_NONE;
1330 if (!sd->video_data) return EMOTION_VIS_NONE;
1331 if (!sd->module->vis_get) return EMOTION_VIS_NONE;
1332 return sd->module->vis_get(sd->video_data);
1333}
1334
1335EAPI Eina_Bool
1336emotion_object_vis_supported(const Evas_Object *obj, Emotion_Vis visualization)
1337{
1338 Smart_Data *sd;
1339
1340 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1341 if (!sd->module) return EINA_FALSE;
1342 if (!sd->video_data) return EINA_FALSE;
1343 if (!sd->module->vis_supported) return EINA_FALSE;
1344 return sd->module->vis_supported(sd->video_data, visualization);
1345}
1346
1347EAPI void
1348emotion_object_priority_set(Evas_Object *obj, Eina_Bool priority)
1349{
1350 Smart_Data *sd;
1351
1352 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1353 if (!sd->module) return ;
1354 if (!sd->video_data) return ;
1355 if (!sd->module->priority_set) return ;
1356 sd->module->priority_set(sd->video_data, priority);
1357}
1358
1359EAPI Eina_Bool
1360emotion_object_priority_get(const Evas_Object *obj)
1361{
1362 Smart_Data *sd;
1363
1364 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1365 if (!sd->module) return EINA_FALSE;
1366 if (!sd->video_data) return EINA_FALSE;
1367 if (!sd->module->priority_get) return EINA_FALSE;
1368 return sd->module->priority_get(sd->video_data);
1369}
1370
1371#ifdef HAVE_EIO
1372static void
1373_eio_load_xattr_cleanup(Smart_Data *sd, Eio_File *handler)
1374{
1375 if (handler == sd->load_xattr) sd->load_xattr = NULL;
1376
1377 EINA_REFCOUNT_UNREF(sd)
1378 _smart_data_free(sd);
1379}
1380
1381static void
1382_eio_load_xattr_done(void *data, Eio_File *handler, double xattr_double)
1383{
1384 Smart_Data *sd = data;
1385
1386 emotion_object_position_set(evas_object_smart_parent_get(sd->obj), xattr_double);
1387 evas_object_smart_callback_call(evas_object_smart_parent_get(sd->obj), SIG_POSITION_LOAD_SUCCEED, NULL);
1388 _eio_load_xattr_cleanup(sd, handler);
1389}
1390
1391static void
1392_eio_load_xattr_error(void *data, Eio_File *handler, int err __UNUSED__)
1393{
1394 Smart_Data *sd = data;
1395
1396 evas_object_smart_callback_call(evas_object_smart_parent_get(sd->obj), SIG_POSITION_LOAD_FAILED, NULL);
1397 _eio_load_xattr_cleanup(sd, handler);
1398}
1399#endif
1400
1401EAPI void
1402emotion_object_last_position_load(Evas_Object *obj)
1403{
1404 Smart_Data *sd;
1405 const char *tmp;
1406#ifndef HAVE_EIO
1407 double xattr;
1408#endif
1409
1410 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1411 if (!sd->file) return ;
1412
1413 if (!strncmp(sd->file, "file://", 7))
1414 tmp = sd->file + 7;
1415 else if (!strstr(sd->file, "://"))
1416 tmp = sd->file;
1417 else
1418 return ;
1419
1420#ifdef HAVE_EIO
1421 if (sd->load_xattr) return ;
1422
1423 EINA_REFCOUNT_REF(sd);
1424
1425 sd->load_xattr = eio_file_xattr_double_get(tmp,
1426 "user.e.time_seek",
1427 _eio_load_xattr_done,
1428 _eio_load_xattr_error,
1429 sd);
1430#else
1431 if (eina_xattr_double_get(tmp, "user.e.time_seek", &xattr))
1432 {
1433 emotion_object_position_set(obj, xattr);
1434 evas_object_smart_callback_call(obj, SIG_POSITION_LOAD_SUCCEED, NULL);
1435 }
1436 else
1437 {
1438 evas_object_smart_callback_call(obj, SIG_POSITION_LOAD_FAILED, NULL);
1439 }
1440#endif
1441}
1442
1443#ifdef HAVE_EIO
1444static void
1445_eio_save_xattr_cleanup(Smart_Data *sd, Eio_File *handler)
1446{
1447 if (handler == sd->save_xattr) sd->save_xattr = NULL;
1448
1449 EINA_REFCOUNT_UNREF(sd)
1450 _smart_data_free(sd);
1451}
1452
1453static void
1454_eio_save_xattr_done(void *data, Eio_File *handler)
1455{
1456 Smart_Data *sd = data;
1457
1458 evas_object_smart_callback_call(sd->obj, SIG_POSITION_SAVE_SUCCEED, NULL);
1459 _eio_save_xattr_cleanup(sd, handler);
1460}
1461
1462static void
1463_eio_save_xattr_error(void *data, Eio_File *handler, int err __UNUSED__)
1464{
1465 Smart_Data *sd = data;
1466
1467 evas_object_smart_callback_call(sd->obj, SIG_POSITION_SAVE_FAILED, NULL);
1468 _eio_save_xattr_cleanup(sd, handler);
1469}
1470#endif
1471
1472EAPI void
1473emotion_object_last_position_save(Evas_Object *obj)
1474{
1475 Smart_Data *sd;
1476 const char *tmp;
1477
1478 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1479 if (!sd->file) return ;
1480
1481 if (!strncmp(sd->file, "file://", 7))
1482 tmp = sd->file + 7;
1483 else if (!strstr(sd->file, "://"))
1484 tmp = sd->file;
1485 else
1486 return ;
1487
1488#ifdef HAVE_EIO
1489 if (sd->save_xattr) return ;
1490
1491 EINA_REFCOUNT_REF(sd);
1492
1493 sd->save_xattr = eio_file_xattr_double_set(tmp,
1494 "user.e.time_seek",
1495 emotion_object_position_get(obj),
1496 0,
1497 _eio_save_xattr_done,
1498 _eio_save_xattr_error,
1499 sd);
1500#else
1501 if (eina_xattr_double_set(tmp, "user.e.time_seek", emotion_object_position_get(obj), 0))
1502 evas_object_smart_callback_call(obj, SIG_POSITION_SAVE_SUCCEED, NULL);
1503 else
1504 evas_object_smart_callback_call(obj, SIG_POSITION_SAVE_FAILED, NULL);
1505#endif
1506}
1507
1508EAPI void
1509emotion_object_suspend_set(Evas_Object *obj, Emotion_Suspend state)
1510{
1511 Smart_Data *sd;
1512
1513 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1514 switch (state)
1515 {
1516 case EMOTION_WAKEUP:
1517 /* Restore the rendering pipeline, offset and everything back to play again (this will be called automatically by play_set) */
1518 case EMOTION_SLEEP:
1519 /* This destroy some part of the rendering pipeline */
1520 case EMOTION_DEEP_SLEEP:
1521 /* This destroy all the rendering pipeline and just keep the last rendered image (fullscreen) */
1522 case EMOTION_HIBERNATE:
1523 /* This destroy all the rendering pipeline and keep 1/4 of the last rendered image */
1524 default:
1525 break;
1526 }
1527
1528 sd->state = state;
1529}
1530
1531EAPI Emotion_Suspend
1532emotion_object_suspend_get(Evas_Object *obj)
1533{
1534 Smart_Data *sd;
1535
1536 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EMOTION_WAKEUP);
1537 return sd->state;
1538}
1539
1540/*****************************/
1541/* Utility calls for modules */
1542/*****************************/
1543
1544EAPI void *
1545_emotion_video_get(const Evas_Object *obj)
1546{
1547 Smart_Data *sd;
1548
1549 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1550 return sd->video_data;
1551}
1552
1553static Eina_Bool
1554_emotion_frame_anim(void *data)
1555{
1556 Evas_Object *obj = data;
1557 Smart_Data *sd;
1558
1559 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EINA_FALSE);
1560
1561 evas_object_image_pixels_dirty_set(sd->obj, 1);
1562 evas_object_smart_callback_call(obj, SIG_FRAME_DECODE, NULL);
1563 sd->anim = NULL;
1564
1565 return EINA_FALSE;
1566}
1567
1568EAPI void
1569_emotion_frame_new(Evas_Object *obj)
1570{
1571 Smart_Data *sd;
1572
1573 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1574
1575 if (!sd->anim) sd->anim = ecore_animator_add(_emotion_frame_anim, obj);
1576}
1577
1578EAPI void
1579_emotion_video_pos_update(Evas_Object *obj, double pos, double len)
1580{
1581 Smart_Data *sd;
1582 int npos = 0, nlen = 0;
1583
1584 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1585 if (pos != sd->pos) npos = 1;
1586 if (len != sd->len) nlen = 1;
1587 sd->pos = pos;
1588 sd->len = len;
1589 if (npos) evas_object_smart_callback_call(obj, SIG_POSITION_UPDATE, NULL);
1590 if (nlen) evas_object_smart_callback_call(obj, SIG_LENGTH_CHANGE, NULL);
1591}
1592
1593EAPI void
1594_emotion_frame_resize(Evas_Object *obj, int w, int h, double ratio)
1595{
1596 Smart_Data *sd;
1597 double tmp;
1598 int changed = 0;
1599
1600 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1601 if ((w != sd->video.w) || (h != sd->video.h))
1602 {
1603 sd->video.w = w;
1604 sd->video.h = h;
1605 _emotion_image_data_zero(sd->obj);
1606 changed = 1;
1607 }
1608 if (h > 0) tmp = (double)w / (double)h;
1609 else tmp = 1.0;
1610 if (ratio != tmp) tmp = ratio;
1611 if (tmp != sd->ratio)
1612 {
1613 sd->ratio = tmp;
1614 changed = 1;
1615 }
1616 if (changed)
1617 {
1618 evas_object_size_hint_request_set(obj, w, h);
1619 evas_object_smart_callback_call(obj, SIG_FRAME_RESIZE, NULL);
1620 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1621 _emotion_object_aspect_border_apply(obj, sd, w, h);
1622 }
1623}
1624
1625EAPI void
1626_emotion_image_reset(Evas_Object *obj)
1627{
1628 Smart_Data *sd;
1629
1630 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1631 _emotion_image_data_zero(sd->obj);
1632}
1633
1634EAPI void
1635_emotion_decode_stop(Evas_Object *obj)
1636{
1637 Smart_Data *sd;
1638
1639 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1640 if (sd->play)
1641 {
1642 sd->play = 0;
1643 evas_object_smart_callback_call(obj, SIG_DECODE_STOP, NULL);
1644 }
1645}
1646
1647EAPI void
1648_emotion_open_done(Evas_Object *obj)
1649{
1650 Smart_Data *sd;
1651
1652 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1653 sd->open = 1;
1654
1655 if (sd->remember_jump)
1656 emotion_object_position_set(obj, sd->remember_jump);
1657 if (sd->remember_play != sd->play)
1658 emotion_object_play_set(obj, sd->remember_play);
1659 evas_object_smart_callback_call(obj, SIG_OPEN_DONE, NULL);
1660}
1661
1662EAPI void
1663_emotion_playback_started(Evas_Object *obj)
1664{
1665 evas_object_smart_callback_call(obj, SIG_PLAYBACK_STARTED, NULL);
1666}
1667
1668EAPI void
1669_emotion_playback_finished(Evas_Object *obj)
1670{
1671 evas_object_smart_callback_call(obj, SIG_PLAYBACK_FINISHED, NULL);
1672}
1673
1674EAPI void
1675_emotion_audio_level_change(Evas_Object *obj)
1676{
1677 evas_object_smart_callback_call(obj, SIG_AUDIO_LEVEL_CHANGE, NULL);
1678}
1679
1680EAPI void
1681_emotion_channels_change(Evas_Object *obj)
1682{
1683 Smart_Data *sd;
1684
1685 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1686 evas_object_smart_callback_call(obj, SIG_CHANNELS_CHANGE, NULL);
1687}
1688
1689EAPI void
1690_emotion_title_set(Evas_Object *obj, char *title)
1691{
1692 Smart_Data *sd;
1693
1694 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1695 free(sd->title);
1696 sd->title = strdup(title);
1697 evas_object_smart_callback_call(obj, SIG_TITLE_CHANGE, NULL);
1698}
1699
1700EAPI void
1701_emotion_progress_set(Evas_Object *obj, char *info, double st)
1702{
1703 Smart_Data *sd;
1704
1705 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1706 free(sd->progress.info);
1707 sd->progress.info = strdup(info);
1708 sd->progress.stat = st;
1709 evas_object_smart_callback_call(obj, SIG_PROGRESS_CHANGE, NULL);
1710}
1711
1712EAPI void
1713_emotion_file_ref_set(Evas_Object *obj, const char *file, int num)
1714{
1715 Smart_Data *sd;
1716
1717 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1718 free(sd->ref.file);
1719 sd->ref.file = strdup(file);
1720 sd->ref.num = num;
1721 evas_object_smart_callback_call(obj, SIG_REF_CHANGE, NULL);
1722}
1723
1724EAPI void
1725_emotion_spu_button_num_set(Evas_Object *obj, int num)
1726{
1727 Smart_Data *sd;
1728
1729 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1730 sd->spu.button_num = num;
1731 evas_object_smart_callback_call(obj, SIG_BUTTON_NUM_CHANGE, NULL);
1732}
1733
1734EAPI void
1735_emotion_spu_button_set(Evas_Object *obj, int button)
1736{
1737 Smart_Data *sd;
1738
1739 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1740 sd->spu.button = button;
1741 evas_object_smart_callback_call(obj, SIG_BUTTON_CHANGE, NULL);
1742}
1743
1744EAPI void
1745_emotion_seek_done(Evas_Object *obj)
1746{
1747 Smart_Data *sd;
1748
1749 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1750 if (sd->seeking)
1751 {
1752 sd->seeking = 0;
1753 if (sd->seek) emotion_object_position_set(obj, sd->seek_pos);
1754 }
1755}
1756
1757EAPI void
1758_emotion_frame_refill(Evas_Object *obj, double w, double h)
1759{
1760 Smart_Data *sd;
1761
1762 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1763 if (sd->fill.w != w || sd->fill.h != h)
1764 {
1765 Evas_Coord ow, oh;
1766
1767 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1768 if (w <= 0 || h <= 0)
1769 {
1770 double scale_w, scale_h;
1771
1772 sd->fill.w = -1;
1773 sd->fill.h = -1;
1774
1775 scale_w = (double) ow / (double)(sd->video.w - sd->crop.l - sd->crop.r);
1776 scale_h = (double) oh / (double)(sd->video.h - sd->crop.t - sd->crop.b);
1777
1778 evas_object_image_fill_set(sd->obj, 0, 0, scale_w * sd->video.w, scale_h * sd->video.h);
1779 }
1780 else
1781 {
1782 sd->fill.w = w;
1783 sd->fill.h = h;
1784
1785 evas_object_image_fill_set(sd->obj, 0, 0, w * ow, h * oh);
1786 }
1787 }
1788}
1789
1790/****************************/
1791/* Internal object routines */
1792/****************************/
1793
1794static void
1795_mouse_move(void *data, Evas *ev __UNUSED__, Evas_Object *obj, void *event_info)
1796{
1797 Evas_Event_Mouse_Move *e;
1798 Smart_Data *sd;
1799 int x, y, iw, ih;
1800 Evas_Coord ox, oy, ow, oh;
1801
1802 e = event_info;
1803 sd = data;
1804 if (!sd->module) return;
1805 if (!sd->video_data) return;
1806 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
1807 evas_object_image_size_get(obj, &iw, &ih);
1808 if ((iw < 1) || (ih < 1)) return;
1809 x = (((int)e->cur.canvas.x - ox) * iw) / ow;
1810 y = (((int)e->cur.canvas.y - oy) * ih) / oh;
1811 sd->module->event_mouse_move_feed(sd->video_data, x, y);
1812}
1813
1814static void
1815_mouse_down(void *data, Evas *ev __UNUSED__, Evas_Object *obj, void *event_info)
1816{
1817 Evas_Event_Mouse_Down *e;
1818 Smart_Data *sd;
1819 int x, y, iw, ih;
1820 Evas_Coord ox, oy, ow, oh;
1821
1822 e = event_info;
1823 sd = data;
1824 if (!sd->module) return;
1825 if (!sd->video_data) return;
1826 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
1827 evas_object_image_size_get(obj, &iw, &ih);
1828 if ((iw < 1) || (ih < 1)) return;
1829 x = (((int)e->canvas.x - ox) * iw) / ow;
1830 y = (((int)e->canvas.y - oy) * ih) / oh;
1831 sd->module->event_mouse_button_feed(sd->video_data, 1, x, y);
1832}
1833
1834static void
1835_pos_set_job(void *data)
1836{
1837 Evas_Object *obj;
1838 Smart_Data *sd;
1839
1840 obj = data;
1841 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1842 sd->job = NULL;
1843 if (sd->seeking) return;
1844 if (sd->seek)
1845 {
1846 sd->seeking = 1;
1847 sd->module->pos_set(sd->video_data, sd->seek_pos);
1848 sd->seek = 0;
1849 }
1850}
1851
1852/* called by evas when it needs pixels for the image object */
1853static void
1854_pixels_get(void *data, Evas_Object *obj)
1855{
1856 int iw, ih, w, h;
1857 Smart_Data *sd;
1858 Emotion_Format format;
1859 unsigned char *bgra_data;
1860
1861 sd = data;
1862 sd->module->video_data_size_get(sd->video_data, &w, &h);
1863 w = (w >> 1) << 1;
1864 h = (h >> 1) << 1;
1865
1866 evas_object_image_colorspace_set(obj, EVAS_COLORSPACE_YCBCR422P601_PL);
1867 evas_object_image_alpha_set(obj, 0);
1868 evas_object_image_size_set(obj, w, h);
1869 iw = w;
1870 ih = h;
1871
1872 if ((iw <= 1) || (ih <= 1))
1873 {
1874 _emotion_image_data_zero(sd->obj);
1875 evas_object_image_pixels_dirty_set(obj, 0);
1876 }
1877 else
1878 {
1879 format = sd->module->format_get(sd->video_data);
1880 if ((format == EMOTION_FORMAT_YV12) || (format == EMOTION_FORMAT_I420))
1881 {
1882 unsigned char **rows;
1883
1884 evas_object_image_colorspace_set(obj, EVAS_COLORSPACE_YCBCR422P601_PL);
1885 rows = evas_object_image_data_get(obj, 1);
1886 if (rows)
1887 {
1888 if (sd->module->yuv_rows_get(sd->video_data, iw, ih,
1889 rows,
1890 &rows[ih],
1891 &rows[ih + (ih / 2)]))
1892 evas_object_image_data_update_add(obj, 0, 0, iw, ih);
1893 }
1894 evas_object_image_data_set(obj, rows);
1895 evas_object_image_pixels_dirty_set(obj, 0);
1896 }
1897 else if (format == EMOTION_FORMAT_BGRA)
1898 {
1899 evas_object_image_colorspace_set(obj, EVAS_COLORSPACE_ARGB8888);
1900 if (sd->module->bgra_data_get(sd->video_data, &bgra_data))
1901 {
1902 evas_object_image_data_set(obj, bgra_data);
1903 evas_object_image_pixels_dirty_set(obj, 0);
1904 }
1905 }
1906 }
1907}
1908
1909/*******************************************/
1910/* Internal smart object required routines */
1911/*******************************************/
1912#ifdef EMOTION_STATIC_BUILD_XINE
1913Eina_Bool xine_module_init(void);
1914#endif
1915#ifdef EMOTION_STATIC_BUILD_GSTREAMER
1916Eina_Bool gstreamer_module_init(void);
1917#endif
1918#ifdef EMOTION_STATIC_BUILD_GENERIC
1919Eina_Bool generic_module_init(void);
1920#endif
1921
1922static void
1923_smart_init(void)
1924{
1925 char *path;
1926
1927 if (smart) return;
1928 {
1929 eina_init();
1930
1931 _log_domain = eina_log_domain_register("emotion", EINA_COLOR_LIGHTCYAN);
1932 if (_log_domain < 0)
1933 {
1934 EINA_LOG_CRIT("Could not register log domain 'emotion'");
1935 eina_shutdown();
1936 return;
1937 }
1938
1939 _backends = eina_hash_string_small_new(free);
1940
1941 _modules = eina_module_list_get(NULL, PACKAGE_LIB_DIR "/emotion/", 0, NULL, NULL);
1942
1943 path = eina_module_environment_path_get("HOME", "/.emotion/");
1944 _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
1945 if (path) free(path);
1946
1947 path = eina_module_environment_path_get("EMOTION_MODULES_DIR", "/emotion/");
1948 _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
1949 if (path) free(path);
1950
1951 path = eina_module_symbol_path_get(emotion_object_add, "/emotion/");
1952 _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
1953 if (path) free(path);
1954
1955 if (!_modules)
1956 {
1957 ERR("No module found!");
1958 return;
1959 }
1960
1961 eina_module_list_load(_modules);
1962
1963 /* Init static module */
1964#ifdef EMOTION_STATIC_BUILD_XINE
1965 xine_module_init();
1966#endif
1967#ifdef EMOTION_STATIC_BUILD_GSTREAMER
1968 gstreamer_module_init();
1969#endif
1970#ifdef EMOTION_STATIC_BUILD_GENERIC
1971 generic_module_init();
1972#endif
1973
1974 static Evas_Smart_Class sc =
1975 EVAS_SMART_CLASS_INIT_NAME_VERSION(E_OBJ_NAME);
1976 if (!sc.add)
1977 {
1978 sc.add = _smart_add;
1979 sc.del = _smart_del;
1980 sc.move = _smart_move;
1981 sc.resize = _smart_resize;
1982 sc.show = _smart_show;
1983 sc.hide = _smart_hide;
1984 sc.color_set = _smart_color_set;
1985 sc.clip_set = _smart_clip_set;
1986 sc.clip_unset = _smart_clip_unset;
1987 sc.callbacks = _smart_callbacks;
1988 }
1989 smart = evas_smart_class_new(&sc);
1990 }
1991}
1992
1993static void
1994_smart_add(Evas_Object * obj)
1995{
1996 Smart_Data *sd;
1997 unsigned int *pixel;
1998
1999 sd = calloc(1, sizeof(Smart_Data));
2000 if (!sd) return;
2001 EINA_REFCOUNT_INIT(sd);
2002 sd->state = EMOTION_WAKEUP;
2003 sd->obj = evas_object_image_add(evas_object_evas_get(obj));
2004 sd->bg = evas_object_rectangle_add(evas_object_evas_get(obj));
2005 evas_object_color_set(sd->bg, 0, 0, 0, 0);
2006 evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, sd);
2007 evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, sd);
2008 evas_object_image_pixels_get_callback_set(sd->obj, _pixels_get, sd);
2009 evas_object_smart_member_add(sd->obj, obj);
2010 evas_object_smart_member_add(sd->bg, obj);
2011 evas_object_lower(sd->bg);
2012 sd->ratio = 1.0;
2013 sd->spu.button = -1;
2014 sd->fill.w = -1;
2015 sd->fill.h = -1;
2016 evas_object_image_alpha_set(sd->obj, 0);
2017 pixel = evas_object_image_data_get(sd->obj, 1);
2018 if (pixel)
2019 {
2020 *pixel = 0xff000000;
2021 evas_object_image_data_set(obj, pixel);
2022 }
2023 evas_object_smart_data_set(obj, sd);
2024
2025 ecore_init();
2026}
2027
2028static void
2029_smart_del(Evas_Object * obj)
2030{
2031 Smart_Data *sd;
2032
2033 sd = evas_object_smart_data_get(obj);
2034 if (!sd) return;
2035 EINA_REFCOUNT_UNREF(sd)
2036 _smart_data_free(sd);
2037}
2038
2039static void
2040_smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y)
2041{
2042 Smart_Data *sd;
2043 int w, h;
2044
2045 sd = evas_object_smart_data_get(obj);
2046 if (!sd) return;
2047
2048 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
2049 _clipper_position_size_update(obj, x, y, w, h, sd->video.w, sd->video.h);
2050 evas_object_move(sd->bg, x, y);
2051}
2052
2053static void
2054_smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h)
2055{
2056 Smart_Data *sd;
2057
2058 sd = evas_object_smart_data_get(obj);
2059 if (!sd) return;
2060
2061 _emotion_object_aspect_border_apply(obj, sd, w, h);
2062 evas_object_resize(sd->bg, w, h);
2063}
2064
2065static void
2066_smart_show(Evas_Object * obj)
2067{
2068 Smart_Data *sd;
2069 int a;
2070
2071 sd = evas_object_smart_data_get(obj);
2072 if (!sd) return;
2073 evas_object_show(sd->obj);
2074 if (sd->crop.clipper)
2075 evas_object_show(sd->crop.clipper);
2076
2077 evas_object_color_get(sd->bg, NULL, NULL, NULL, &a);
2078 if (a > 0)
2079 evas_object_show(sd->bg);
2080}
2081
2082static void
2083_smart_hide(Evas_Object * obj)
2084{
2085 Smart_Data *sd;
2086
2087 sd = evas_object_smart_data_get(obj);
2088 if (!sd) return;
2089 evas_object_hide(sd->obj);
2090 if (sd->crop.clipper)
2091 evas_object_hide(sd->crop.clipper);
2092 evas_object_hide(sd->bg);
2093}
2094
2095static void
2096_smart_color_set(Evas_Object * obj, int r, int g, int b, int a)
2097{
2098 Smart_Data *sd;
2099
2100 sd = evas_object_smart_data_get(obj);
2101 if (!sd) return;
2102 evas_object_color_set(sd->obj, r, g, b, a);
2103 evas_object_color_set(sd->crop.clipper, r, g, b, a);
2104}
2105
2106static void
2107_smart_clip_set(Evas_Object * obj, Evas_Object * clip)
2108{
2109 Smart_Data *sd;
2110
2111 sd = evas_object_smart_data_get(obj);
2112 if (!sd) return;
2113 if (sd->crop.clipper)
2114 evas_object_clip_set(sd->crop.clipper, clip);
2115 else
2116 evas_object_clip_set(sd->obj, clip);
2117 evas_object_clip_set(sd->bg, clip);
2118}
2119
2120static void
2121_smart_clip_unset(Evas_Object * obj)
2122{
2123 Smart_Data *sd;
2124
2125 sd = evas_object_smart_data_get(obj);
2126 if (!sd) return;
2127 if (sd->crop.clipper)
2128 evas_object_clip_unset(sd->crop.clipper);
2129 else
2130 evas_object_clip_unset(sd->obj);
2131 evas_object_clip_unset(sd->bg);
2132}
2133