summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/lib/emotion_smart.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2004-06-18 15:38:03 +0000
committerCarsten Haitzler <raster@rasterman.com>2004-06-18 15:38:03 +0000
commit7f3528ec27a1419b927542e6ab3eff62e69aadd4 (patch)
tree95ddf197be0bf244f723478cdeab0e6d09f68adc /legacy/emotion/src/lib/emotion_smart.c
parente1704a29b526ca419f7d85bcc8a2dac3596be2e4 (diff)
it had to happen sooner or later... in in in... we go! :)
SVN revision: 10537
Diffstat (limited to '')
-rw-r--r--legacy/emotion/src/lib/emotion_smart.c944
1 files changed, 944 insertions, 0 deletions
diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c
new file mode 100644
index 0000000000..d29a47e44c
--- /dev/null
+++ b/legacy/emotion/src/lib/emotion_smart.c
@@ -0,0 +1,944 @@
1#include "Emotion.h"
2#include "emotion_private.h"
3#include <dlfcn.h>
4
5#define E_SMART_OBJ_GET(smart, o, type) \
6 { \
7 char *_e_smart_str; \
8 \
9 if (!o) return; \
10 smart = evas_object_smart_data_get(o); \
11 if (!smart) return; \
12 _e_smart_str = (char *)evas_object_type_get(o); \
13 if (!_e_smart_str) return; \
14 if (strcmp(_e_smart_str, type)) return; \
15 }
16
17#define E_SMART_OBJ_GET_RETURN(smart, o, type, ret) \
18 { \
19 char *_e_smart_str; \
20 \
21 if (!o) return ret; \
22 smart = evas_object_smart_data_get(o); \
23 if (!smart) return ret; \
24 _e_smart_str = (char *)evas_object_type_get(o); \
25 if (!_e_smart_str) return ret; \
26 if (strcmp(_e_smart_str, type)) return ret; \
27 }
28
29#define E_OBJ_NAME "emotion_object"
30
31typedef struct _Smart_Data Smart_Data;
32
33struct _Smart_Data
34{
35 Emotion_Video_Module *module;
36 void *video;
37
38 char *file;
39 Evas_Object *obj;
40 double ratio;
41 double pos;
42 double seek_pos;
43 double len;
44
45 Ecore_Job *job;
46
47 unsigned char play : 1;
48 unsigned char seek : 1;
49};
50
51static void _mouse_move(void *data, Evas *ev, Evas_Object *obj, void *event_info);
52static void _mouse_down(void *data, Evas *ev, Evas_Object *obj, void *event_info);
53static void _pos_set_job(void *data);
54static void _pixels_get(void *data, Evas_Object *obj);
55
56static void _smart_init(void);
57static void _smart_add(Evas_Object * obj);
58static void _smart_del(Evas_Object * obj);
59static void _smart_layer_set(Evas_Object * obj, int layer);
60static void _smart_raise(Evas_Object * obj);
61static void _smart_lower(Evas_Object * obj);
62static void _smart_stack_above(Evas_Object * obj, Evas_Object * above);
63static void _smart_stack_below(Evas_Object * obj, Evas_Object * below);
64static void _smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y);
65static void _smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h);
66static void _smart_show(Evas_Object * obj);
67static void _smart_hide(Evas_Object * obj);
68static void _smart_color_set(Evas_Object * obj, int r, int g, int b, int a);
69static void _smart_clip_set(Evas_Object * obj, Evas_Object * clip);
70static void _smart_clip_unset(Evas_Object * obj);
71
72/**********************************/
73/* Globals for the E Video Object */
74/**********************************/
75static Evas_Smart *smart = NULL;
76
77static Emotion_Video_Module *
78_emotion_module_open(const char *name)
79{
80 void *handle;
81 char buf[4096];
82
83 snprintf(buf, sizeof(buf), "%s/%s", PACKAGE_LIB_DIR"/emotion/", name);
84 handle = dlopen(buf, RTLD_NOW | RTLD_GLOBAL);
85 if (handle)
86 {
87 Emotion_Video_Module *(*func_module_open) (void);
88
89 func_module_open = dlsym(handle, "module_open");
90 if (func_module_open)
91 {
92 Emotion_Video_Module *mod;
93
94 mod = func_module_open();
95 if (mod)
96 {
97 mod->handle = handle;
98 return mod;
99 }
100 }
101 dlclose(handle);
102 }
103 return NULL;
104}
105
106static void
107_emotion_module_close(Emotion_Video_Module *mod)
108{
109 void *handle;
110 void (*module_close) (Emotion_Video_Module *module);
111
112 handle = mod->handle;
113 module_close = dlsym(handle, "module_close");
114 if (module_close) module_close(mod);
115 dlclose(handle);
116}
117
118/*******************************/
119/* Externally accessible calls */
120/*******************************/
121Evas_Object *
122emotion_object_add(Evas *evas)
123{
124 _smart_init();
125 return evas_object_smart_add(evas, smart);
126}
127
128void
129emotion_object_file_set(Evas_Object *obj, const char *file)
130{
131 Smart_Data *sd;
132
133 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
134
135 if ((file) && (sd->file) && (!strcmp(file, sd->file))) return;
136 if (sd->file) free(sd->file);
137 sd->file = NULL;
138
139 if (file)
140 {
141 int w, h;
142
143 sd->file = strdup(file);
144 if (sd->video) sd->module->file_close(sd->video);
145 if (sd->module) _emotion_module_close(sd->module);
146 sd->module = _emotion_module_open("emotion_decoder_xine.so");
147 if (!sd->module) return;
148 sd->video = sd->module->file_open(sd->file, obj);
149 if (sd->video)
150 {
151 sd->module->size_get(sd->video, &w, &h);
152 evas_object_image_size_set(sd->obj, w, h);
153 sd->ratio = sd->module->ratio_get(sd->video);
154 sd->pos = 0.0;
155 if (sd->play) sd->module->play(sd->video, 0.0);
156 }
157 }
158 else
159 {
160 if (sd->video)
161 {
162 sd->module->file_close(sd->video);
163 evas_object_image_size_set(sd->obj, 0, 0);
164 }
165 if (sd->module) _emotion_module_close(sd->module);
166 sd->module = NULL;
167 }
168}
169
170const char *
171emotion_object_file_get(Evas_Object *obj)
172{
173 Smart_Data *sd;
174
175 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
176 return sd->file;
177}
178
179void
180emotion_object_play_set(Evas_Object *obj, Evas_Bool play)
181{
182 Smart_Data *sd;
183
184 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
185 if (((play) && (sd->play)) || ((!play) && (!sd->play))) return;
186 if (!sd->module) return;
187 if (!sd->video) return;
188 sd->play = play;
189 if (sd->play) sd->module->play(sd->video, sd->pos);
190 else sd->module->stop(sd->video);
191}
192
193Evas_Bool
194emotion_object_play_get(Evas_Object *obj)
195{
196 Smart_Data *sd;
197
198 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
199 if (!sd->video) return 0;
200 return sd->play;
201}
202
203void
204emotion_object_position_set(Evas_Object *obj, double sec)
205{
206 Smart_Data *sd;
207 int frame;
208
209 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
210 if (!sd->module) return;
211 if (!sd->video) return;
212 sd->seek_pos = sec;
213 sd->seek = 1;
214 sd->pos = sd->seek_pos;
215 if (sd->job) ecore_job_del(sd->job);
216 sd->job = ecore_job_add(_pos_set_job, obj);
217}
218
219double
220emotion_object_position_get(Evas_Object *obj)
221{
222 Smart_Data *sd;
223
224 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0.0);
225 if (!sd->module) return 0.0;
226 if (!sd->video) return 0.0;
227 return sd->pos;
228}
229
230Evas_Bool
231emotion_object_seekable_get(Evas_Object *obj)
232{
233 Smart_Data *sd;
234
235 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
236 if (!sd->module) return 0;
237 if (!sd->video) return 0;
238 return sd->module->seekable(sd->video);
239}
240
241double
242emotion_object_play_length_get(Evas_Object *obj)
243{
244 Smart_Data *sd;
245
246 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0.0);
247 if (!sd->module) return 0.0;
248 if (!sd->video) return 0.0;
249 sd->len = sd->module->len_get(sd->video);
250 return sd->len;
251}
252
253void
254emotion_object_size_get(Evas_Object *obj, int *iw, int *ih)
255{
256 Smart_Data *sd;
257
258 if (iw) *iw = 0;
259 if (ih) *ih = 0;
260 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
261 evas_object_image_size_get(sd->obj, iw, ih);
262}
263
264void
265emotion_object_smooth_scale_set(Evas_Object *obj, Evas_Bool smooth)
266{
267 Smart_Data *sd;
268
269 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
270 evas_object_image_smooth_scale_set(sd->obj, smooth);
271}
272
273Evas_Bool
274emotion_object_smooth_scale_get(Evas_Object *obj)
275{
276 Smart_Data *sd;
277
278 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
279 return evas_object_image_smooth_scale_get(sd->obj);
280}
281
282double
283emotion_object_ratio_get(Evas_Object *obj)
284{
285 Smart_Data *sd;
286
287 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 1.0);
288 if (!sd->module) return 0.0;
289 if (!sd->video) return 0.0;
290 return sd->ratio;
291}
292
293void
294emotion_object_event_simple_send(Evas_Object *obj, Emotion_Event ev)
295{
296 Smart_Data *sd;
297
298 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
299 if (!sd->module) return;
300 if (!sd->video) return;
301 sd->module->event_feed(sd->video, ev);
302}
303
304void
305emotion_object_audio_volume_set(Evas_Object *obj, double vol)
306{
307 Smart_Data *sd;
308
309 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
310 if (!sd->module) return;
311 if (!sd->video) return;
312 sd->module->audio_channel_volume_set(sd->video, vol);
313}
314
315double
316emotion_object_audio_volume_get(Evas_Object *obj)
317{
318 Smart_Data *sd;
319
320 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 1.0);
321 if (!sd->module) return 0.0;
322 if (!sd->video) return 0.0;
323 return sd->module->audio_channel_volume_get(sd->video);
324}
325
326void
327emotion_object_audio_mute_set(Evas_Object *obj, Evas_Bool mute)
328{
329 Smart_Data *sd;
330
331 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
332 if (!sd->module) return;
333 if (!sd->video) return;
334 sd->module->audio_channel_mute_set(sd->video, mute);
335}
336
337Evas_Bool
338emotion_object_audio_mute_get(Evas_Object *obj)
339{
340 Smart_Data *sd;
341
342 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
343 if (!sd->module) return 0;
344 if (!sd->video) return 0;
345 return sd->module->audio_channel_mute_get(sd->video);
346}
347
348int
349emotion_object_audio_channel_count(Evas_Object *obj)
350{
351 Smart_Data *sd;
352
353 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
354 if (!sd->module) return 0;
355 if (!sd->video) return 0;
356 return sd->module->audio_channel_count(sd->video);
357}
358
359const char *
360emotion_object_audio_channel_name_get(Evas_Object *obj, int channel)
361{
362 Smart_Data *sd;
363
364 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
365 if (!sd->module) return NULL;
366 if (!sd->video) return NULL;
367 return sd->module->audio_channel_name_get(sd->video, channel);
368}
369
370void
371emotion_object_audio_channel_set(Evas_Object *obj, int channel)
372{
373 Smart_Data *sd;
374
375 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
376 if (!sd->module) return;
377 if (!sd->video) return;
378 sd->module->audio_channel_set(sd->video, channel);
379}
380
381int
382emotion_object_audio_channel_get(Evas_Object *obj)
383{
384 Smart_Data *sd;
385
386 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
387 if (!sd->module) return 0;
388 if (!sd->video) return 0;
389 return sd->module->audio_channel_get(sd->video);
390}
391
392void
393emotion_object_video_mute_set(Evas_Object *obj, Evas_Bool mute)
394{
395 Smart_Data *sd;
396
397 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
398 if (!sd->module) return;
399 if (!sd->video) return;
400 sd->module->video_channel_mute_set(sd->video, mute);
401}
402
403Evas_Bool
404emotion_object_video_mute_get(Evas_Object *obj)
405{
406 Smart_Data *sd;
407
408 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
409 if (!sd->module) return 0;
410 if (!sd->video) return 0;
411 return sd->module->video_channel_mute_get(sd->video);
412}
413
414int
415emotion_object_video_channel_count(Evas_Object *obj)
416{
417 Smart_Data *sd;
418
419 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
420 if (!sd->module) return 0;
421 if (!sd->video) return 0;
422 return sd->module->video_channel_count(sd->video);
423}
424
425const char *
426emotion_object_video_channel_name_get(Evas_Object *obj, int channel)
427{
428 Smart_Data *sd;
429
430 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
431 if (!sd->module) return NULL;
432 if (!sd->video) return NULL;
433 return sd->module->video_channel_name_get(sd->video, channel);
434}
435
436void
437emotion_object_video_channel_set(Evas_Object *obj, int channel)
438{
439 Smart_Data *sd;
440
441 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
442 if (!sd->module) return;
443 if (!sd->video) return;
444 sd->module->video_channel_set(sd->video, channel);
445}
446
447int
448emotion_object_video_channel_get(Evas_Object *obj)
449{
450 Smart_Data *sd;
451
452 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
453 if (!sd->module) return 0;
454 if (!sd->video) return 0;
455 return sd->module->video_channel_get(sd->video);
456}
457
458void
459emotion_object_spu_mute_set(Evas_Object *obj, Evas_Bool mute)
460{
461 Smart_Data *sd;
462
463 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
464 if (!sd->module) return;
465 if (!sd->video) return;
466 sd->module->spu_channel_mute_set(sd->video, mute);
467}
468
469Evas_Bool
470emotion_object_spu_mute_get(Evas_Object *obj)
471{
472 Smart_Data *sd;
473
474 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
475 if (!sd->module) return 0;
476 if (!sd->video) return 0;
477 return sd->module->spu_channel_mute_get(sd->video);
478}
479
480int
481emotion_object_spu_channel_count(Evas_Object *obj)
482{
483 Smart_Data *sd;
484
485 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
486 if (!sd->module) return 0;
487 if (!sd->video) return 0;
488 return sd->module->spu_channel_count(sd->video);
489}
490
491const char *
492emotion_object_spu_channel_name_get(Evas_Object *obj, int channel)
493{
494 Smart_Data *sd;
495
496 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
497 if (!sd->module) return NULL;
498 if (!sd->video) return NULL;
499 return sd->module->spu_channel_name_get(sd->video, channel);
500}
501
502void
503emotion_object_spu_channel_set(Evas_Object *obj, int channel)
504{
505 Smart_Data *sd;
506
507 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
508 if (!sd->module) return;
509 if (!sd->video) return;
510 sd->module->spu_channel_set(sd->video, channel);
511}
512
513int
514emotion_object_spu_channel_get(Evas_Object *obj)
515{
516 Smart_Data *sd;
517
518 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
519 if (!sd->module) return 0;
520 if (!sd->video) return 0;
521 return sd->module->spu_channel_get(sd->video);
522}
523
524int
525emotion_object_chapter_count(Evas_Object *obj)
526{
527 Smart_Data *sd;
528
529 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
530 if (!sd->module) return 0;
531 if (!sd->video) return 0;
532 return sd->module->chapter_count(sd->video);
533}
534
535void
536emotion_object_chapter_set(Evas_Object *obj, int chapter)
537{
538 Smart_Data *sd;
539
540 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
541 if (!sd->module) return;
542 if (!sd->video) return;
543 sd->module->chapter_set(sd->video, chapter);
544}
545
546int
547emotion_object_chapter_get(Evas_Object *obj)
548{
549 Smart_Data *sd;
550
551 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
552 if (!sd->module) return 0;
553 if (!sd->video) return 0;
554 return sd->module->chapter_get(sd->video);
555}
556
557const char *
558emotion_object_chapter_name_get(Evas_Object *obj, int chapter)
559{
560 Smart_Data *sd;
561
562 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
563 if (!sd->module) return NULL;
564 if (!sd->video) return NULL;
565 return sd->module->chapter_name_get(sd->video, chapter);
566}
567
568void
569emotion_object_play_speed_set(Evas_Object *obj, double speed)
570{
571 Smart_Data *sd;
572
573 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
574 if (!sd->module) return;
575 if (!sd->video) return;
576 sd->module->speed_set(sd->video, speed);
577}
578
579double
580emotion_object_play_speed_get(Evas_Object *obj)
581{
582 Smart_Data *sd;
583
584 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0.0);
585 if (!sd->module) return 0.0;
586 if (!sd->video) return 0.0;
587 return sd->module->speed_get(sd->video);
588}
589
590void
591emotion_object_eject(Evas_Object *obj)
592{
593 Smart_Data *sd;
594
595 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
596 if (!sd->module) return;
597 if (!sd->video) return;
598 sd->module->eject(sd->video);
599}
600
601
602
603
604
605/*****************************/
606/* Utility calls for modules */
607/*****************************/
608
609void *
610_emotion_video_get(Evas_Object *obj)
611{
612 Smart_Data *sd;
613
614 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
615 return sd->video;
616}
617
618void
619_emotion_frame_new(Evas_Object *obj)
620{
621 Smart_Data *sd;
622
623 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
624 evas_object_image_pixels_dirty_set(sd->obj, 1);
625}
626
627void
628_emotion_video_pos_update(Evas_Object *obj, double pos, double len)
629{
630 Smart_Data *sd;
631 int npos = 0, nlen = 0;
632
633 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
634 if (pos != sd->pos) npos = 1;
635 if (len != sd->len) nlen = 1;
636 sd->pos = pos;
637 sd->len = len;
638 if (npos) evas_object_smart_callback_call(obj, "frame_decode", NULL);
639 if (nlen) evas_object_smart_callback_call(obj, "length_change", NULL);
640}
641
642void
643_emotion_frame_resize(Evas_Object *obj, int w, int h, double ratio)
644{
645 Smart_Data *sd;
646 int iw, ih;
647 int changed = 0;
648
649 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
650 evas_object_image_size_get(sd->obj, &iw, &ih);
651 if ((w != iw) || (h != ih))
652 {
653 evas_object_image_size_set(sd->obj, w, h);
654 changed = 1;
655 }
656 if (ratio != sd->ratio)
657 {
658 sd->ratio = ratio;
659 changed = 1;
660 }
661 if (changed) evas_object_smart_callback_call(obj, "frame_resize", NULL);
662}
663
664
665/****************************/
666/* Internal object routines */
667/****************************/
668
669static void
670_mouse_move(void *data, Evas *ev, Evas_Object *obj, void *event_info)
671{
672 Evas_Event_Mouse_Move *e;
673 Smart_Data *sd;
674 int x, y, iw, ih;
675 Evas_Coord ox, oy, ow, oh;
676
677 e = event_info;
678 sd = data;
679 if (!sd->module) return;
680 if (!sd->video) return;
681 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
682 evas_object_image_size_get(obj, &iw, &ih);
683 if ((iw < 1) || (ih < 1)) return;
684 x = (((int)e->cur.canvas.x - ox) * iw) / ow;
685 y = (((int)e->cur.canvas.y - oy) * ih) / oh;
686 sd->module->event_mouse_move_feed(sd->video, x, y);
687}
688
689static void
690_mouse_down(void *data, Evas *ev, Evas_Object *obj, void *event_info)
691{
692 Evas_Event_Mouse_Down *e;
693 Smart_Data *sd;
694 int x, y, iw, ih;
695 Evas_Coord ox, oy, ow, oh;
696
697 e = event_info;
698 sd = data;
699 if (!sd->module) return;
700 if (!sd->video) return;
701 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
702 evas_object_image_size_get(obj, &iw, &ih);
703 if ((iw < 1) || (ih < 1)) return;
704 x = (((int)e->canvas.x - ox) * iw) / ow;
705 y = (((int)e->canvas.y - oy) * ih) / oh;
706 sd->module->event_mouse_button_feed(sd->video, 1, x, y);
707}
708
709static void
710_pos_set_job(void *data)
711{
712 Evas_Object *obj;
713 Smart_Data *sd;
714
715 obj = data;
716 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
717 sd->job = NULL;
718 if (sd->seek)
719 {
720 sd->module->pos_set(sd->video, sd->seek_pos);
721 sd->seek = 0;
722 }
723}
724
725/* called by evas when it needs pixels for the image object */
726static void
727_pixels_get(void *data, Evas_Object *obj)
728{
729 Evas_Pixel_Import_Source ps;
730 int iw, ih, w, h;
731 int i;
732 unsigned char **rows;
733 Smart_Data *sd;
734
735 sd = data;
736 evas_object_image_size_get(obj, &iw, &ih);
737 sd->module->yuv_size_get(sd->video, &w, &h);
738 if ((w != iw) || (h != ih))
739 {
740 evas_object_image_size_set(obj, w, h);
741 iw = w;
742 ih = h;
743 }
744 ps.format = EVAS_PIXEL_FORMAT_YUV420P_601;
745 ps.w = iw;
746 ps.h = ih;
747
748 ps.rows = malloc(ps.h * 2 * sizeof(void *));
749 if (!ps.rows)
750 {
751 sd->module->frame_done(sd->video);
752 return;
753 }
754
755
756 rows = (unsigned char **)ps.rows;
757
758 if (sd->module->yuv_rows_get(sd->video, iw, ih,
759 rows,
760 &rows[ps.h],
761 &rows[ps.h + (ps.h / 2)]))
762 evas_object_image_pixels_import(obj, &ps);
763 evas_object_image_pixels_dirty_set(obj, 0);
764 free(ps.rows);
765 sd->module->frame_done(sd->video);
766}
767
768/*******************************************/
769/* Internal smart object required routines */
770/*******************************************/
771static void
772_smart_init(void)
773{
774 if (smart) return;
775 smart = evas_smart_new(E_OBJ_NAME,
776 _smart_add,
777 _smart_del,
778 _smart_layer_set,
779 _smart_raise,
780 _smart_lower,
781 _smart_stack_above,
782 _smart_stack_below,
783 _smart_move,
784 _smart_resize,
785 _smart_show,
786 _smart_hide,
787 _smart_color_set,
788 _smart_clip_set,
789 _smart_clip_unset,
790 NULL);
791}
792
793static void
794_smart_add(Evas_Object * obj)
795{
796 Smart_Data *sd;
797
798 sd = calloc(1, sizeof(Smart_Data));
799 if (!sd) return;
800 sd->obj = evas_object_image_add(evas_object_evas_get(obj));
801 evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, sd);
802 evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, sd);
803 evas_object_image_pixels_get_callback_set(sd->obj, _pixels_get, sd);
804 evas_object_smart_member_add(sd->obj, obj);
805 sd->ratio = 1.0;
806 evas_object_image_alpha_set(sd->obj, 0);
807 evas_object_smart_data_set(obj, sd);
808}
809
810static void
811_smart_del(Evas_Object * obj)
812{
813 Smart_Data *sd;
814
815 sd = evas_object_smart_data_get(obj);
816 if (!sd) return;
817 if (sd->video) sd->module->file_close(sd->video);
818 if (sd->module) _emotion_module_close(sd->module);
819 evas_object_del(sd->obj);
820 if (sd->file) free(sd->file);
821 if (sd->job) ecore_job_del(sd->job);
822 free(sd);
823}
824
825static void
826_smart_layer_set(Evas_Object * obj, int layer)
827{
828 Smart_Data *sd;
829
830 sd = evas_object_smart_data_get(obj);
831 if (!sd) return;
832 evas_object_layer_set(sd->obj, layer);
833}
834
835static void
836_smart_raise(Evas_Object * obj)
837{
838 Smart_Data *sd;
839
840 sd = evas_object_smart_data_get(obj);
841 if (!sd) return;
842 evas_object_raise(sd->obj);
843}
844
845static void
846_smart_lower(Evas_Object * obj)
847{
848 Smart_Data *sd;
849
850 sd = evas_object_smart_data_get(obj);
851 evas_object_lower(sd->obj);
852}
853
854static void
855_smart_stack_above(Evas_Object * obj, Evas_Object * above)
856{
857 Smart_Data *sd;
858
859 sd = evas_object_smart_data_get(obj);
860 if (!sd) return;
861 evas_object_stack_above(sd->obj, above);
862}
863
864static void
865_smart_stack_below(Evas_Object * obj, Evas_Object * below)
866{
867 Smart_Data *sd;
868
869 sd = evas_object_smart_data_get(obj);
870 if (!sd) return;
871 evas_object_stack_below(sd->obj, below);
872}
873
874static void
875_smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y)
876{
877 Smart_Data *sd;
878
879 sd = evas_object_smart_data_get(obj);
880 if (!sd) return;
881 evas_object_move(sd->obj, x, y);
882}
883
884static void
885_smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h)
886{
887 Smart_Data *sd;
888
889 sd = evas_object_smart_data_get(obj);
890 if (!sd) return;
891 evas_object_image_fill_set(sd->obj, 0, 0, w, h);
892 evas_object_resize(sd->obj, w, h);
893}
894
895static void
896_smart_show(Evas_Object * obj)
897{
898 Smart_Data *sd;
899
900 sd = evas_object_smart_data_get(obj);
901 if (!sd) return;
902 evas_object_show(sd->obj);
903
904}
905
906static void
907_smart_hide(Evas_Object * obj)
908{
909 Smart_Data *sd;
910
911 sd = evas_object_smart_data_get(obj);
912 if (!sd) return;
913 evas_object_hide(sd->obj);
914}
915
916static void
917_smart_color_set(Evas_Object * obj, int r, int g, int b, int a)
918{
919 Smart_Data *sd;
920
921 sd = evas_object_smart_data_get(obj);
922 if (!sd) return;
923 evas_object_color_set(sd->obj, r, g, b, a);
924}
925
926static void
927_smart_clip_set(Evas_Object * obj, Evas_Object * clip)
928{
929 Smart_Data *sd;
930
931 sd = evas_object_smart_data_get(obj);
932 if (!sd) return;
933 evas_object_clip_set(sd->obj, clip);
934}
935
936static void
937_smart_clip_unset(Evas_Object * obj)
938{
939 Smart_Data *sd;
940
941 sd = evas_object_smart_data_get(obj);
942 if (!sd) return;
943 evas_object_clip_unset(sd->obj);
944}