14 #include "emotion_private.h"
17 # define FMT_UCHAR "%c"
19 # define FMT_UCHAR "%hhu"
22 #define E_SMART_OBJ_GET(smart, o, type) \
27 smart = evas_object_smart_data_get(o); \
29 _e_smart_str = (char *)evas_object_type_get(o); \
30 if (!_e_smart_str) return; \
31 if (strcmp(_e_smart_str, type)) return; \
34 #define E_SMART_OBJ_GET_RETURN(smart, o, type, 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; \
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__)
52 #define E_OBJ_NAME "emotion_object"
54 typedef struct _Smart_Data Smart_Data;
59 Emotion_Video_Module *module;
106 double remember_jump;
110 Emotion_Module_Options module_options;
112 Emotion_Suspend state;
113 Emotion_Aspect aspect;
115 Ecore_Animator *anim;
119 Eina_Bool remember_play : 1;
121 Eina_Bool seeking : 1;
124 static void _mouse_move(void *data, Evas *ev, Evas_Object *obj, void *event_info);
125 static void _mouse_down(void *data, Evas *ev, Evas_Object *obj, void *event_info);
126 static void _pos_set_job(void *data);
127 static void _pixels_get(void *data, Evas_Object *obj);
129 static void _smart_init(void);
130 static void _smart_add(Evas_Object * obj);
131 static void _smart_del(Evas_Object * obj);
132 static void _smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y);
133 static void _smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h);
134 static void _smart_show(Evas_Object * obj);
135 static void _smart_hide(Evas_Object * obj);
136 static void _smart_color_set(Evas_Object * obj, int r, int g, int b, int a);
137 static void _smart_clip_set(Evas_Object * obj, Evas_Object * clip);
138 static void _smart_clip_unset(Evas_Object * obj);
140 /**********************************/
141 /* Globals for the E Video Object */
142 /**********************************/
143 static Evas_Smart *smart = NULL;
144 static Eina_Hash *_backends = NULL;
145 static Eina_Array *_modules = NULL;
146 static int _log_domain = -1;
148 static const char *_backend_priority[] = {
154 static const char SIG_FRAME_DECODE[] = "frame_decode";
155 static const char SIG_POSITION_UPDATE[] = "position_update";
156 static const char SIG_LENGTH_CHANGE[] = "length_change";
157 static const char SIG_FRAME_RESIZE[] = "frame_resize";
158 static const char SIG_DECODE_STOP[] = "decode_stop";
159 static const char SIG_PLAYBACK_STARTED[] = "playback_started";
160 static const char SIG_PLAYBACK_FINISHED[] = "playback_finished";
161 static const char SIG_AUDIO_LEVEL_CHANGE[] = "audio_level_change";
162 static const char SIG_CHANNELS_CHANGE[] = "channels_change";
163 static const char SIG_TITLE_CHANGE[] = "title_change";
164 static const char SIG_PROGRESS_CHANGE[] = "progress_change";
165 static const char SIG_REF_CHANGE[] = "ref_change";
166 static const char SIG_BUTTON_NUM_CHANGE[] = "button_num_change";
167 static const char SIG_BUTTON_CHANGE[] = "button_change";
168 static const char SIG_OPEN_DONE[] = "open_done";
169 static const char SIG_POSITION_SAVE_SUCCEED[] = "position_save,succeed";
170 static const char SIG_POSITION_SAVE_FAILED[] = "position_save,failed";
171 static const char SIG_POSITION_LOAD_SUCCEED[] = "position_load,succeed";
172 static const char SIG_POSITION_LOAD_FAILED[] = "position_load,failed";
174 static 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, ""},
194 _emotion_image_data_zero(Evas_Object *img)
198 data = evas_object_image_data_get(img, 1);
204 evas_object_image_size_get(img, &w, &h);
205 cs = evas_object_image_colorspace_get(img);
206 if (cs == EVAS_COLORSPACE_ARGB8888)
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);
213 evas_object_image_data_set(img, data);
217 _emotion_module_close(Emotion_Video_Module *mod, void *video)
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
230 _smart_data_free(Smart_Data *sd)
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);
249 _emotion_module_register(const char *name, Emotion_Module_Open mod_open, Emotion_Module_Close mod_close)
251 Eina_Emotion_Plugins *plugin;
253 plugin = malloc(sizeof (Eina_Emotion_Plugins));
254 if (!plugin) return EINA_FALSE;
256 plugin->open = mod_open;
257 plugin->close = mod_close;
259 return eina_hash_add(_backends, name, plugin);
263 _emotion_module_unregister(const char *name)
265 return eina_hash_del(_backends, name, NULL);
269 _emotion_module_open(const char *name, Evas_Object *obj, Emotion_Video_Module **mod, void **video)
271 Eina_Emotion_Plugins *plugin;
275 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
278 ERR("No backend loaded");
282 if (!name && getenv("EMOTION_ENGINE"))
283 name = getenv("EMOTION_ENGINE");
285 /* FIXME: Always look for a working backend. */
288 name = _backend_priority[i++];
290 plugin = eina_hash_find(_backends, name);
293 if (i != 0 && i < (sizeof (_backend_priority) / sizeof (char*)))
296 ERR("No backend loaded");
300 if (plugin->open(obj, (const Emotion_Video_Module **) mod, video, &(sd->module_options)))
304 (*mod)->plugin = plugin;
309 if (i != 0 && i < (sizeof (_backend_priority) / sizeof (char*)))
312 ERR("Unable to load module: %s", name);
318 _clipper_position_size_update(Evas_Object *obj, int x, int y, int w, int h, int vid_w, int vid_h)
321 double scale_w, scale_h;
323 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
325 if (vid_w == 0 || vid_h == 0)
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);
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);
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);
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);
349 /*******************************/
350 /* Externally accessible calls */
351 /*******************************/
356 emotion_object_add(Evas *evas)
359 return evas_object_smart_add(evas, smart);
363 emotion_object_image_get(const Evas_Object *obj)
367 sd = evas_object_smart_data_get(obj);
368 if (!sd) return NULL;
373 emotion_object_module_option_set(Evas_Object *obj, const char *opt, const char *val)
377 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
378 if ((!opt) || (!val)) return;
380 if (!strcmp(opt, "player"))
381 eina_stringshare_replace(&sd->module_options.player, val);
385 emotion_object_init(Evas_Object *obj, const char *module_filename)
390 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
392 if ((sd->module_name) && module_filename && (!strcmp(sd->module_name, module_filename)))
394 free(sd->module_name);
395 sd->module_name = NULL;
402 free(sd->progress.info);
403 sd->progress.info = NULL;
404 sd->progress.stat = 0.0;
408 sd->spu.button_num = 0;
412 sd->remember_jump = 0;
415 sd->remember_play = 0;
417 if (sd->anim) ecore_animator_del(sd->anim);
420 _emotion_module_close(sd->module, sd->video_data);
422 sd->video_data = NULL;
424 module_filename = _emotion_module_open(module_filename, obj, &sd->module, &sd->video_data);
425 if (!module_filename)
428 sd->module_name = strdup(module_filename);
432 emotion_object_file_set(obj, file);
433 eina_stringshare_del(file);
440 emotion_object_file_set(Evas_Object *obj, const char *file)
444 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EINA_FALSE);
446 DBG("file=%s", file);
447 if (!sd->module) return EINA_FALSE;
451 if ((file) && (sd->file) &&
452 ((file == sd->file) || (!strcmp(file, sd->file)))) return EINA_FALSE;
453 if ((file) && (file[0] != 0))
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);
461 if (!sd->module->file_open(sd->file, obj, sd->video_data))
464 if (sd->play) sd->module->play(sd->video_data, 0.0);
468 if (sd->video_data && sd->module)
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);
475 eina_stringshare_replace(&sd->file, NULL);
478 if (sd->anim) ecore_animator_del(sd->anim);
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;
493 emotion_object_file_get(const Evas_Object *obj)
497 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
502 _emotion_aspect_borders_apply(Evas_Object *obj, Smart_Data *sd, int w, int h, int iw, int ih)
506 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
508 /* applying calculated borders */
509 if (sd->crop.l == 0 && sd->crop.r == 0 &&
510 sd->crop.t == 0 && sd->crop.b == 0)
512 Evas_Object *old_clipper;
513 if (sd->crop.clipper)
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;
524 if (!sd->crop.clipper)
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);
538 _clipper_position_size_update(obj, x, y, w, h, iw, ih);
542 _emotion_object_aspect_border_apply(Evas_Object *obj, Smart_Data *sd, int w, int h)
553 ir = (double)iw / ih;
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.
561 if (sd->aspect == EMOTION_ASPECT_KEEP_NONE)
567 aspect_opt = 0; // just ignore keep_aspect
569 else if (sd->aspect == EMOTION_ASPECT_KEEP_WIDTH)
573 else if (sd->aspect == EMOTION_ASPECT_KEEP_HEIGHT)
577 else if (sd->aspect == EMOTION_ASPECT_KEEP_BOTH)
584 else if (sd->aspect == EMOTION_ASPECT_CROP)
591 else if (sd->aspect == EMOTION_ASPECT_CUSTOM)
593 // nothing to do, just respect the border settings
597 /* updating borders based on keep_aspect settings */
598 if (aspect_opt == 1) // keep width
605 scale = (double)iw / w;
608 sd->crop.t = sd->crop.b = dh / 2;
610 else if (aspect_opt == 2) // keep height
617 scale = (double)ih / h;
620 sd->crop.l = sd->crop.r = dw / 2;
623 _emotion_aspect_borders_apply(obj, sd, w, h, iw, ih);
627 emotion_object_border_set(Evas_Object *obj, int l, int r, int t, int b)
632 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
634 sd->aspect = EMOTION_ASPECT_CUSTOM;
639 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
640 _emotion_object_aspect_border_apply(obj, sd, w, h);
644 emotion_object_border_get(const Evas_Object *obj, int *l, int *r, int *t, int *b)
648 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
656 emotion_object_bg_color_set(Evas_Object *obj, int r, int g, int b, int a)
660 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
662 evas_object_color_set(sd->bg, r, g, b, a);
664 if (!evas_object_visible_get(obj))
668 evas_object_show(sd->bg);
670 evas_object_hide(sd->bg);
674 emotion_object_bg_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a)
678 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
679 evas_object_color_get(sd->bg, r, g, b, a);
683 emotion_object_keep_aspect_set(Evas_Object *obj, Emotion_Aspect a)
688 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
694 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
695 _emotion_object_aspect_border_apply(obj, sd, w, h);
699 emotion_object_keep_aspect_get(const Evas_Object *obj)
703 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EMOTION_ASPECT_KEEP_NONE);
709 emotion_object_play_set(Evas_Object *obj, Eina_Bool play)
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;
720 sd->remember_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);
731 emotion_object_play_get(const Evas_Object *obj)
735 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
736 if (!sd->video_data) return EINA_FALSE;
742 emotion_object_position_set(Evas_Object *obj, double sec)
746 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
748 if (!sd->module) return;
749 if (!sd->video_data) return;
752 sd->remember_jump = sec;
755 sd->remember_jump = 0;
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);
764 emotion_object_position_get(const Evas_Object *obj)
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);
777 emotion_object_buffer_size_get(const Evas_Object *obj)
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);
789 emotion_object_seekable_get(const Evas_Object *obj)
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);
800 emotion_object_video_handled_get(const Evas_Object *obj)
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);
811 emotion_object_audio_handled_get(const Evas_Object *obj)
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);
822 emotion_object_play_length_get(const Evas_Object *obj)
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);
834 emotion_object_size_get(const Evas_Object *obj, int *iw, int *ih)
840 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
841 if (iw) *iw = sd->video.w;
842 if (ih) *ih = sd->video.h;
846 emotion_object_smooth_scale_set(Evas_Object *obj, Eina_Bool smooth)
850 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
851 evas_object_image_smooth_scale_set(sd->obj, smooth);
855 emotion_object_smooth_scale_get(const Evas_Object *obj)
859 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
860 return evas_object_image_smooth_scale_get(sd->obj);
864 emotion_object_ratio_get(const Evas_Object *obj)
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;
875 * Send a control event to the DVD.
878 emotion_object_event_simple_send(Evas_Object *obj, Emotion_Event ev)
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);
889 emotion_object_audio_volume_set(Evas_Object *obj, double vol)
893 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
895 if (!sd->module) return;
896 if (!sd->video_data) return;
897 sd->module->audio_channel_volume_set(sd->video_data, vol);
901 emotion_object_audio_volume_get(const Evas_Object *obj)
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);
912 emotion_object_audio_mute_set(Evas_Object *obj, Eina_Bool mute)
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);
924 emotion_object_audio_mute_get(const Evas_Object *obj)
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);
935 emotion_object_audio_channel_count(const Evas_Object *obj)
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);
946 emotion_object_audio_channel_name_get(const Evas_Object *obj, int channel)
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);
957 emotion_object_audio_channel_set(Evas_Object *obj, int channel)
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);
969 emotion_object_audio_channel_get(const Evas_Object *obj)
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);
980 emotion_object_video_mute_set(Evas_Object *obj, Eina_Bool mute)
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);
992 emotion_object_video_mute_get(const Evas_Object *obj)
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);
1003 emotion_object_video_channel_count(const Evas_Object *obj)
1007 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1008 if (!sd->module) return EINA_FALSE;
1009 if (!sd->video_data) return EINA_FALSE;
1010 return sd->module->video_channel_count(sd->video_data);
1014 emotion_object_video_channel_name_get(const Evas_Object *obj, int channel)
1018 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1019 if (!sd->module) return NULL;
1020 if (!sd->video_data) return NULL;
1021 return sd->module->video_channel_name_get(sd->video_data, channel);
1025 emotion_object_video_channel_set(Evas_Object *obj, int channel)
1029 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1030 DBG("channel=%d", channel);
1031 if (!sd->module) return;
1032 if (!sd->video_data) return;
1033 sd->module->video_channel_set(sd->video_data, channel);
1037 emotion_object_video_channel_get(const Evas_Object *obj)
1041 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1042 if (!sd->module) return 0;
1043 if (!sd->video_data) return 0;
1044 return sd->module->video_channel_get(sd->video_data);
1048 emotion_object_spu_mute_set(Evas_Object *obj, Eina_Bool mute)
1052 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1053 DBG("mute=" FMT_UCHAR, mute);
1054 if (!sd->module) return;
1055 if (!sd->video_data) return;
1056 sd->module->spu_channel_mute_set(sd->video_data, mute);
1060 emotion_object_spu_mute_get(const Evas_Object *obj)
1064 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1065 if (!sd->module) return EINA_FALSE;
1066 if (!sd->video_data) return EINA_FALSE;
1067 return sd->module->spu_channel_mute_get(sd->video_data);
1071 emotion_object_spu_channel_count(const Evas_Object *obj)
1075 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1076 if (!sd->module) return 0;
1077 if (!sd->video_data) return 0;
1078 return sd->module->spu_channel_count(sd->video_data);
1082 emotion_object_spu_channel_name_get(const Evas_Object *obj, int channel)
1086 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1087 if (!sd->module) return NULL;
1088 if (!sd->video_data) return NULL;
1089 return sd->module->spu_channel_name_get(sd->video_data, channel);
1093 emotion_object_spu_channel_set(Evas_Object *obj, int channel)
1097 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1098 DBG("channel=%d", channel);
1099 if (!sd->module) return;
1100 if (!sd->video_data) return;
1101 sd->module->spu_channel_set(sd->video_data, channel);
1105 emotion_object_spu_channel_get(const Evas_Object *obj)
1109 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1110 if (!sd->module) return 0;
1111 if (!sd->video_data) return 0;
1112 return sd->module->spu_channel_get(sd->video_data);
1116 emotion_object_chapter_count(const Evas_Object *obj)
1120 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1121 if (!sd->module) return 0;
1122 if (!sd->video_data) return 0;
1123 return sd->module->chapter_count(sd->video_data);
1127 emotion_object_chapter_set(Evas_Object *obj, int chapter)
1131 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1132 DBG("chapter=%d", chapter);
1133 if (!sd->module) return;
1134 if (!sd->video_data) return;
1135 sd->module->chapter_set(sd->video_data, chapter);
1139 emotion_object_chapter_get(const Evas_Object *obj)
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_get(sd->video_data);
1150 emotion_object_chapter_name_get(const Evas_Object *obj, int chapter)
1154 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1155 if (!sd->module) return NULL;
1156 if (!sd->video_data) return NULL;
1157 return sd->module->chapter_name_get(sd->video_data, chapter);
1161 emotion_object_play_speed_set(Evas_Object *obj, double speed)
1165 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1166 DBG("speed=%f", speed);
1167 if (!sd->module) return;
1168 if (!sd->video_data) return;
1169 sd->module->speed_set(sd->video_data, speed);
1173 emotion_object_play_speed_get(const Evas_Object *obj)
1177 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0.0);
1178 if (!sd->module) return 0.0;
1179 if (!sd->video_data) return 0.0;
1180 return sd->module->speed_get(sd->video_data);
1184 emotion_object_eject(Evas_Object *obj)
1188 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1189 if (!sd->module) return;
1190 if (!sd->video_data) return;
1191 sd->module->eject(sd->video_data);
1195 emotion_object_title_get(const Evas_Object *obj)
1199 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1204 emotion_object_progress_info_get(const Evas_Object *obj)
1208 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1209 return sd->progress.info;
1213 emotion_object_progress_status_get(const Evas_Object *obj)
1217 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0.0);
1218 return sd->progress.stat;
1222 emotion_object_ref_file_get(const Evas_Object *obj)
1226 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1227 return sd->ref.file;
1231 emotion_object_ref_num_get(const Evas_Object *obj)
1235 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1240 emotion_object_spu_button_count_get(const Evas_Object *obj)
1244 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1245 return sd->spu.button_num;
1249 emotion_object_spu_button_get(const Evas_Object *obj)
1253 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1254 return sd->spu.button;
1258 emotion_object_meta_info_get(const Evas_Object *obj, Emotion_Meta_Info meta)
1262 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1263 if (!sd->module) return NULL;
1264 if (!sd->video_data) return NULL;
1267 case EMOTION_META_INFO_TRACK_TITLE:
1268 return sd->module->meta_get(sd->video_data, META_TRACK_TITLE);
1269 case EMOTION_META_INFO_TRACK_ARTIST:
1270 return sd->module->meta_get(sd->video_data, META_TRACK_ARTIST);
1271 case EMOTION_META_INFO_TRACK_ALBUM:
1272 return sd->module->meta_get(sd->video_data, META_TRACK_ALBUM);
1273 case EMOTION_META_INFO_TRACK_YEAR:
1274 return sd->module->meta_get(sd->video_data, META_TRACK_YEAR);
1275 case EMOTION_META_INFO_TRACK_GENRE:
1276 return sd->module->meta_get(sd->video_data, META_TRACK_GENRE);
1277 case EMOTION_META_INFO_TRACK_COMMENT:
1278 return sd->module->meta_get(sd->video_data, META_TRACK_COMMENT);
1279 case EMOTION_META_INFO_TRACK_DISC_ID:
1280 return sd->module->meta_get(sd->video_data, META_TRACK_DISCID);
1288 emotion_object_vis_set(Evas_Object *obj, Emotion_Vis visualization)
1292 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1293 DBG("visualization=%d", visualization);
1294 if (!sd->module) return;
1295 if (!sd->video_data) return;
1296 if (!sd->module->vis_set) return;
1297 sd->module->vis_set(sd->video_data, visualization);
1301 emotion_object_vis_get(const Evas_Object *obj)
1305 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EMOTION_VIS_NONE);
1306 if (!sd->module) return EMOTION_VIS_NONE;
1307 if (!sd->video_data) return EMOTION_VIS_NONE;
1308 if (!sd->module->vis_get) return EMOTION_VIS_NONE;
1309 return sd->module->vis_get(sd->video_data);
1313 emotion_object_vis_supported(const Evas_Object *obj, Emotion_Vis visualization)
1317 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1318 if (!sd->module) return EINA_FALSE;
1319 if (!sd->video_data) return EINA_FALSE;
1320 if (!sd->module->vis_supported) return EINA_FALSE;
1321 return sd->module->vis_supported(sd->video_data, visualization);
1325 emotion_object_priority_set(Evas_Object *obj, Eina_Bool priority)
1329 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1330 if (!sd->module) return ;
1331 if (!sd->video_data) return ;
1332 if (!sd->module->priority_set) return ;
1333 sd->module->priority_set(sd->video_data, priority);
1337 emotion_object_priority_get(const Evas_Object *obj)
1341 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1342 if (!sd->module) return EINA_FALSE;
1343 if (!sd->video_data) return EINA_FALSE;
1344 if (!sd->module->priority_get) return EINA_FALSE;
1345 return sd->module->priority_get(sd->video_data);
1350 _eio_load_xattr_cleanup(Smart_Data *sd, Eio_File *handler)
1352 if (handler == sd->load_xattr) sd->load_xattr = NULL;
1354 EINA_REFCOUNT_UNREF(sd)
1355 _smart_data_free(sd);
1359 _eio_load_xattr_done(void *data, Eio_File *handler, double xattr_double)
1361 Smart_Data *sd = data;
1363 emotion_object_position_set(evas_object_smart_parent_get(sd->obj), xattr_double);
1364 evas_object_smart_callback_call(evas_object_smart_parent_get(sd->obj), SIG_POSITION_LOAD_SUCCEED, NULL);
1365 _eio_load_xattr_cleanup(sd, handler);
1369 _eio_load_xattr_error(void *data, Eio_File *handler, int err __UNUSED__)
1371 Smart_Data *sd = data;
1373 evas_object_smart_callback_call(evas_object_smart_parent_get(sd->obj), SIG_POSITION_LOAD_FAILED, NULL);
1374 _eio_load_xattr_cleanup(sd, handler);
1379 emotion_object_last_position_load(Evas_Object *obj)
1387 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1388 if (!sd->file) return ;
1390 if (!strncmp(sd->file, "file://", 7))
1392 else if (!strstr(sd->file, "://"))
1398 if (sd->load_xattr) return ;
1400 EINA_REFCOUNT_REF(sd);
1402 sd->load_xattr = eio_file_xattr_double_get(tmp,
1404 _eio_load_xattr_done,
1405 _eio_load_xattr_error,
1408 if (eina_xattr_double_get(tmp, "user.e.time_seek", &xattr))
1410 emotion_object_position_set(obj, xattr);
1411 evas_object_smart_callback_call(obj, SIG_POSITION_LOAD_SUCCEED, NULL);
1415 evas_object_smart_callback_call(obj, SIG_POSITION_LOAD_FAILED, NULL);
1422 _eio_save_xattr_cleanup(Smart_Data *sd, Eio_File *handler)
1424 if (handler == sd->save_xattr) sd->save_xattr = NULL;
1426 EINA_REFCOUNT_UNREF(sd)
1427 _smart_data_free(sd);
1431 _eio_save_xattr_done(void *data, Eio_File *handler)
1433 Smart_Data *sd = data;
1435 evas_object_smart_callback_call(sd->obj, SIG_POSITION_SAVE_SUCCEED, NULL);
1436 _eio_save_xattr_cleanup(sd, handler);
1440 _eio_save_xattr_error(void *data, Eio_File *handler, int err __UNUSED__)
1442 Smart_Data *sd = data;
1444 evas_object_smart_callback_call(sd->obj, SIG_POSITION_SAVE_FAILED, NULL);
1445 _eio_save_xattr_cleanup(sd, handler);
1450 emotion_object_last_position_save(Evas_Object *obj)
1455 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1456 if (!sd->file) return ;
1458 if (!strncmp(sd->file, "file://", 7))
1460 else if (!strstr(sd->file, "://"))
1466 if (sd->save_xattr) return ;
1468 EINA_REFCOUNT_REF(sd);
1470 sd->save_xattr = eio_file_xattr_double_set(tmp,
1472 emotion_object_position_get(obj),
1474 _eio_save_xattr_done,
1475 _eio_save_xattr_error,
1478 if (eina_xattr_double_set(tmp, "user.e.time_seek", emotion_object_position_get(obj), 0))
1479 evas_object_smart_callback_call(obj, SIG_POSITION_SAVE_SUCCEED, NULL);
1481 evas_object_smart_callback_call(obj, SIG_POSITION_SAVE_FAILED, NULL);
1486 emotion_object_suspend_set(Evas_Object *obj, Emotion_Suspend state)
1490 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1493 case EMOTION_WAKEUP:
1494 /* Restore the rendering pipeline, offset and everything back to play again (this will be called automatically by play_set) */
1496 /* This destroy some part of the rendering pipeline */
1497 case EMOTION_DEEP_SLEEP:
1498 /* This destroy all the rendering pipeline and just keep the last rendered image (fullscreen) */
1499 case EMOTION_HIBERNATE:
1500 /* This destroy all the rendering pipeline and keep 1/4 of the last rendered image */
1508 EAPI Emotion_Suspend
1509 motion_object_suspend_get(Evas_Object *obj)
1513 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EMOTION_WAKEUP);
1517 /*****************************/
1518 /* Utility calls for modules */
1519 /*****************************/
1522 _emotion_video_get(const Evas_Object *obj)
1526 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1527 return sd->video_data;
1531 _emotion_frame_anim(void *data)
1533 Evas_Object *obj = data;
1536 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EINA_FALSE);
1538 evas_object_image_pixels_dirty_set(sd->obj, 1);
1539 evas_object_smart_callback_call(obj, SIG_FRAME_DECODE, NULL);
1546 _emotion_frame_new(Evas_Object *obj)
1550 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1552 if (!sd->anim) sd->anim = ecore_animator_add(_emotion_frame_anim, obj);
1556 _emotion_video_pos_update(Evas_Object *obj, double pos, double len)
1559 int npos = 0, nlen = 0;
1561 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1562 if (pos != sd->pos) npos = 1;
1563 if (len != sd->len) nlen = 1;
1566 if (npos) evas_object_smart_callback_call(obj, SIG_POSITION_UPDATE, NULL);
1567 if (nlen) evas_object_smart_callback_call(obj, SIG_LENGTH_CHANGE, NULL);
1571 _emotion_frame_resize(Evas_Object *obj, int w, int h, double ratio)
1577 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1578 if ((w != sd->video.w) || (h != sd->video.h))
1582 _emotion_image_data_zero(sd->obj);
1585 if (h > 0) tmp = (double)w / (double)h;
1587 if (ratio != tmp) tmp = ratio;
1588 if (tmp != sd->ratio)
1595 evas_object_size_hint_request_set(obj, w, h);
1596 evas_object_smart_callback_call(obj, SIG_FRAME_RESIZE, NULL);
1597 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1598 _emotion_object_aspect_border_apply(obj, sd, w, h);
1603 _emotion_image_reset(Evas_Object *obj)
1607 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1608 _emotion_image_data_zero(sd->obj);
1612 _emotion_decode_stop(Evas_Object *obj)
1616 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1620 evas_object_smart_callback_call(obj, SIG_DECODE_STOP, NULL);
1625 _emotion_open_done(Evas_Object *obj)
1629 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1632 if (sd->remember_jump)
1633 emotion_object_position_set(obj, sd->remember_jump);
1634 if (sd->remember_play != sd->play)
1635 emotion_object_play_set(obj, sd->remember_play);
1636 evas_object_smart_callback_call(obj, SIG_OPEN_DONE, NULL);
1640 _emotion_playback_started(Evas_Object *obj)
1642 evas_object_smart_callback_call(obj, SIG_PLAYBACK_STARTED, NULL);
1646 _emotion_playback_finished(Evas_Object *obj)
1648 evas_object_smart_callback_call(obj, SIG_PLAYBACK_FINISHED, NULL);
1652 _emotion_audio_level_change(Evas_Object *obj)
1654 evas_object_smart_callback_call(obj, SIG_AUDIO_LEVEL_CHANGE, NULL);
1658 _emotion_channels_change(Evas_Object *obj)
1662 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1663 evas_object_smart_callback_call(obj, SIG_CHANNELS_CHANGE, NULL);
1667 _emotion_title_set(Evas_Object *obj, char *title)
1671 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1673 sd->title = strdup(title);
1674 evas_object_smart_callback_call(obj, SIG_TITLE_CHANGE, NULL);
1678 _emotion_progress_set(Evas_Object *obj, char *info, double st)
1682 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1683 free(sd->progress.info);
1684 sd->progress.info = strdup(info);
1685 sd->progress.stat = st;
1686 evas_object_smart_callback_call(obj, SIG_PROGRESS_CHANGE, NULL);
1690 _emotion_file_ref_set(Evas_Object *obj, const char *file, int num)
1694 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1696 sd->ref.file = strdup(file);
1698 evas_object_smart_callback_call(obj, SIG_REF_CHANGE, NULL);
1702 _emotion_spu_button_num_set(Evas_Object *obj, int num)
1706 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1707 sd->spu.button_num = num;
1708 evas_object_smart_callback_call(obj, SIG_BUTTON_NUM_CHANGE, NULL);
1712 _emotion_spu_button_set(Evas_Object *obj, int button)
1716 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1717 sd->spu.button = button;
1718 evas_object_smart_callback_call(obj, SIG_BUTTON_CHANGE, NULL);
1722 _emotion_seek_done(Evas_Object *obj)
1726 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1730 if (sd->seek) emotion_object_position_set(obj, sd->seek_pos);
1735 _emotion_frame_refill(Evas_Object *obj, double w, double h)
1739 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1740 if (sd->fill.w != w || sd->fill.h != h)
1744 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1745 if (w <= 0 || h <= 0)
1747 double scale_w, scale_h;
1752 scale_w = (double) ow / (double)(sd->video.w - sd->crop.l - sd->crop.r);
1753 scale_h = (double) oh / (double)(sd->video.h - sd->crop.t - sd->crop.b);
1755 evas_object_image_fill_set(sd->obj, 0, 0, scale_w * sd->video.w, scale_h * sd->video.h);
1762 evas_object_image_fill_set(sd->obj, 0, 0, w * ow, h * oh);
1767 /****************************/
1768 /* Internal object routines */
1769 /****************************/
1772 _mouse_move(void *data, Evas *ev __UNUSED__, Evas_Object *obj, void *event_info)
1774 Evas_Event_Mouse_Move *e;
1777 Evas_Coord ox, oy, ow, oh;
1781 if (!sd->module) return;
1782 if (!sd->video_data) return;
1783 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
1784 evas_object_image_size_get(obj, &iw, &ih);
1785 if ((iw < 1) || (ih < 1)) return;
1786 x = (((int)e->cur.canvas.x - ox) * iw) / ow;
1787 y = (((int)e->cur.canvas.y - oy) * ih) / oh;
1788 sd->module->event_mouse_move_feed(sd->video_data, x, y);
1792 _mouse_down(void *data, Evas *ev __UNUSED__, Evas_Object *obj, void *event_info)
1794 Evas_Event_Mouse_Down *e;
1797 Evas_Coord ox, oy, ow, oh;
1801 if (!sd->module) return;
1802 if (!sd->video_data) return;
1803 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
1804 evas_object_image_size_get(obj, &iw, &ih);
1805 if ((iw < 1) || (ih < 1)) return;
1806 x = (((int)e->canvas.x - ox) * iw) / ow;
1807 y = (((int)e->canvas.y - oy) * ih) / oh;
1808 sd->module->event_mouse_button_feed(sd->video_data, 1, x, y);
1812 _pos_set_job(void *data)
1818 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1820 if (sd->seeking) return;
1824 sd->module->pos_set(sd->video_data, sd->seek_pos);
1829 /* called by evas when it needs pixels for the image object */
1831 _pixels_get(void *data, Evas_Object *obj)
1835 Emotion_Format format;
1836 unsigned char *bgra_data;
1839 sd->module->video_data_size_get(sd->video_data, &w, &h);
1843 evas_object_image_colorspace_set(obj, EVAS_COLORSPACE_YCBCR422P601_PL);
1844 evas_object_image_alpha_set(obj, 0);
1845 evas_object_image_size_set(obj, w, h);
1849 if ((iw <= 1) || (ih <= 1))
1851 _emotion_image_data_zero(sd->obj);
1852 evas_object_image_pixels_dirty_set(obj, 0);
1856 format = sd->module->format_get(sd->video_data);
1857 if ((format == EMOTION_FORMAT_YV12) || (format == EMOTION_FORMAT_I420))
1859 unsigned char **rows;
1861 evas_object_image_colorspace_set(obj, EVAS_COLORSPACE_YCBCR422P601_PL);
1862 rows = evas_object_image_data_get(obj, 1);
1865 if (sd->module->yuv_rows_get(sd->video_data, iw, ih,
1868 &rows[ih + (ih / 2)]))
1869 evas_object_image_data_update_add(obj, 0, 0, iw, ih);
1871 evas_object_image_data_set(obj, rows);
1872 evas_object_image_pixels_dirty_set(obj, 0);
1874 else if (format == EMOTION_FORMAT_BGRA)
1876 evas_object_image_colorspace_set(obj, EVAS_COLORSPACE_ARGB8888);
1877 if (sd->module->bgra_data_get(sd->video_data, &bgra_data))
1879 evas_object_image_data_set(obj, bgra_data);
1880 evas_object_image_pixels_dirty_set(obj, 0);
1886 /*******************************************/
1887 /* Internal smart object required routines */
1888 /*******************************************/
1889 #ifdef EMOTION_STATIC_BUILD_XINE
1890 Eina_Bool xine_module_init(void);
1892 #ifdef EMOTION_STATIC_BUILD_GSTREAMER
1893 Eina_Bool gstreamer_module_init(void);
1895 #ifdef EMOTION_STATIC_BUILD_GENERIC
1896 Eina_Bool generic_module_init(void);
1908 _log_domain = eina_log_domain_register("emotion", EINA_COLOR_LIGHTCYAN);
1909 if (_log_domain < 0)
1911 EINA_LOG_CRIT("Could not register log domain 'emotion'");
1916 _backends = eina_hash_string_small_new(free);
1918 _modules = eina_module_list_get(NULL, PACKAGE_LIB_DIR "/emotion/", 0, NULL, NULL);
1920 path = eina_module_environment_path_get("HOME", "/.emotion/");
1921 _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
1922 if (path) free(path);
1924 path = eina_module_environment_path_get("EMOTION_MODULES_DIR", "/emotion/");
1925 _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
1926 if (path) free(path);
1928 path = eina_module_symbol_path_get(emotion_object_add, "/emotion/");
1929 _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
1930 if (path) free(path);
1934 ERR("No module found!");
1938 eina_module_list_load(_modules);
1940 /* Init static module */
1941 #ifdef EMOTION_STATIC_BUILD_XINE
1944 #ifdef EMOTION_STATIC_BUILD_GSTREAMER
1945 gstreamer_module_init();
1947 #ifdef EMOTION_STATIC_BUILD_GENERIC
1948 generic_module_init();
1951 static Evas_Smart_Class sc =
1952 EVAS_SMART_CLASS_INIT_NAME_VERSION(E_OBJ_NAME);
1955 sc.add = _smart_add;
1956 sc.del = _smart_del;
1957 sc.move = _smart_move;
1958 sc.resize = _smart_resize;
1959 sc.show = _smart_show;
1960 sc.hide = _smart_hide;
1961 sc.color_set = _smart_color_set;
1962 sc.clip_set = _smart_clip_set;
1963 sc.clip_unset = _smart_clip_unset;
1964 sc.callbacks = _smart_callbacks;
1966 smart = evas_smart_class_new(&sc);
1971 _smart_add(Evas_Object * obj)
1974 unsigned int *pixel;
1976 sd = calloc(1, sizeof(Smart_Data));
1978 EINA_REFCOUNT_INIT(sd);
1979 sd->state = EMOTION_WAKEUP;
1980 sd->obj = evas_object_image_add(evas_object_evas_get(obj));
1981 sd->bg = evas_object_rectangle_add(evas_object_evas_get(obj));
1982 evas_object_color_set(sd->bg, 0, 0, 0, 0);
1983 evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, sd);
1984 evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, sd);
1985 evas_object_image_pixels_get_callback_set(sd->obj, _pixels_get, sd);
1986 evas_object_smart_member_add(sd->obj, obj);
1987 evas_object_smart_member_add(sd->bg, obj);
1988 evas_object_lower(sd->bg);
1990 sd->spu.button = -1;
1993 evas_object_image_alpha_set(sd->obj, 0);
1994 pixel = evas_object_image_data_get(sd->obj, 1);
1997 *pixel = 0xff000000;
1998 evas_object_image_data_set(obj, pixel);
2000 evas_object_smart_data_set(obj, sd);
2006 _smart_del(Evas_Object * obj)
2010 sd = evas_object_smart_data_get(obj);
2012 EINA_REFCOUNT_UNREF(sd)
2013 _smart_data_free(sd);
2017 _smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y)
2022 sd = evas_object_smart_data_get(obj);
2025 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
2026 _clipper_position_size_update(obj, x, y, w, h, sd->video.w, sd->video.h);
2027 evas_object_move(sd->bg, x, y);
2031 _smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h)
2035 sd = evas_object_smart_data_get(obj);
2038 _emotion_object_aspect_border_apply(obj, sd, w, h);
2039 evas_object_resize(sd->bg, w, h);
2043 _smart_show(Evas_Object * obj)
2048 sd = evas_object_smart_data_get(obj);
2050 evas_object_show(sd->obj);
2051 if (sd->crop.clipper)
2052 evas_object_show(sd->crop.clipper);
2054 evas_object_color_get(sd->bg, NULL, NULL, NULL, &a);
2056 evas_object_show(sd->bg);
2060 _smart_hide(Evas_Object * obj)
2064 sd = evas_object_smart_data_get(obj);
2066 evas_object_hide(sd->obj);
2067 if (sd->crop.clipper)
2068 evas_object_hide(sd->crop.clipper);
2069 evas_object_hide(sd->bg);
2073 _smart_color_set(Evas_Object * obj, int r, int g, int b, int a)
2077 sd = evas_object_smart_data_get(obj);
2079 evas_object_color_set(sd->obj, r, g, b, a);
2080 evas_object_color_set(sd->crop.clipper, r, g, b, a);
2084 _smart_clip_set(Evas_Object * obj, Evas_Object * clip)
2088 sd = evas_object_smart_data_get(obj);
2090 if (sd->crop.clipper)
2091 evas_object_clip_set(sd->crop.clipper, clip);
2093 evas_object_clip_set(sd->obj, clip);
2094 evas_object_clip_set(sd->bg, clip);
2098 _smart_clip_unset(Evas_Object * obj)
2102 sd = evas_object_smart_data_get(obj);
2104 if (sd->crop.clipper)
2105 evas_object_clip_unset(sd->crop.clipper);
2107 evas_object_clip_unset(sd->obj);
2108 evas_object_clip_unset(sd->bg);