5
#define EFL_CANVAS_OBJECT_PROTECTED
6
#define EFL_CANVAS_GROUP_PROTECTED
16
#define EFL_INTERNAL_UNSTABLE
17
#include <Evas_Internal.h>
20
#include "emotion_private.h"
22
#include "canvas/evas_canvas_eo.h"
25
# define FMT_UCHAR "%c"
27
# define FMT_UCHAR "%hhu"
30
#define E_SMART_OBJ_GET(smart, o, type) \
33
if (!efl_isa(o, MY_CLASS)) { \
34
ERR("Tried calling on a non-emotion object."); \
37
smart = efl_data_scope_get(o, MY_CLASS); \
41
#define E_SMART_OBJ_GET_RETURN(smart, o, type, ret) \
44
if (!efl_isa(o, MY_CLASS)) { \
45
ERR("Tried calling on a non-emotion object."); \
48
smart = efl_data_scope_get(o, MY_CLASS); \
49
if (!smart) return ret; \
52
#define E_OBJ_NAME "efl_canvas_video"
58
#define MY_CLASS EFL_CANVAS_VIDEO_CLASS
60
typedef struct _Efl_Canvas_Video_Data Efl_Canvas_Video_Data;
61
typedef struct _Emotion_Xattr_Data Emotion_Xattr_Data;
63
struct _Efl_Canvas_Video_Data
65
Emotion_Engine_Instance *engine_instance;
74
Emotion_Xattr_Data *xattr;
107
double remember_jump;
111
Emotion_Module_Options module_options;
113
Emotion_Suspend state;
114
Emotion_Aspect aspect;
116
Ecore_Animator *anim;
121
Eina_Bool remember_play : 1;
123
Eina_Bool seeking : 1;
124
Eina_Bool loaded : 1;
127
struct _Emotion_Xattr_Data
137
static void _mouse_move(void *data, Evas *ev, Evas_Object *obj, void *event_info);
138
static void _mouse_down(void *data, Evas *ev, Evas_Object *obj, void *event_info);
139
static void _pos_set_job(void *data);
140
static void _pixels_get(void *data, Evas_Object *obj);
143
_engine_init(Eo *obj, Efl_Canvas_Video_Data *sd)
145
if (sd->engine_instance) return;
146
sd->engine_instance = emotion_engine_instance_new(sd->engine, obj,
147
&(sd->module_options));
151
_emotion_image_data_zero(Evas_Object *img)
155
data = evas_object_image_data_get(img, 1);
161
evas_object_image_size_get(img, &w, &h);
162
cs = evas_object_image_colorspace_get(img);
163
if (cs == EVAS_COLORSPACE_ARGB8888)
165
if ((cs == EVAS_COLORSPACE_YCBCR422P601_PL) ||
166
(cs == EVAS_COLORSPACE_YCBCR422P709_PL))
167
sz = h * 2 * sizeof(unsigned char *);
168
if (sz != 0) memset(data, 0, sz);
170
evas_object_image_data_set(img, data);
174
_xattr_data_cancel(Emotion_Xattr_Data *xattr)
179
if (xattr->load) eio_file_cancel(xattr->load);
181
if (xattr->save) eio_file_cancel(xattr->save);
187
_xattr_data_unref(Emotion_Xattr_Data *xattr)
189
EINA_REFCOUNT_UNREF(xattr) {} else return;
191
_xattr_data_cancel(xattr);
192
efl_wref_del_safe(&xattr->obj_wref);
197
_clipper_position_size_update(Evas_Object *obj, int x, int y, int w, int h, int vid_w, int vid_h)
199
Efl_Canvas_Video_Data *sd;
200
double scale_w, scale_h;
202
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
204
if (vid_w == 0 || vid_h == 0)
206
evas_object_image_fill_set(sd->obj, 0, 0, 0, 0);
207
evas_object_move(sd->obj, x, y);
208
evas_object_resize(sd->obj, 0, 0);
209
if (!sd->crop.clipper) return;
210
evas_object_move(sd->crop.clipper, x, y);
211
evas_object_resize(sd->crop.clipper, 0, 0);
215
scale_w = (double)w / (double)(vid_w - sd->crop.l - sd->crop.r);
216
scale_h = (double)h / (double)(vid_h - sd->crop.t - sd->crop.b);
218
if (sd->fill.w < 0 && sd->fill.h < 0)
219
evas_object_image_fill_set(sd->obj, 0, 0, vid_w * scale_w, vid_h * scale_h);
221
evas_object_image_fill_set(sd->obj, 0, 0, sd->fill.w * w, sd->fill.h * h);
222
evas_object_resize(sd->obj, vid_w * scale_w, vid_h * scale_h);
223
evas_object_move(sd->obj, x - sd->crop.l * scale_w, y - sd->crop.t * scale_h);
224
if (!sd->crop.clipper) return;
225
evas_object_move(sd->crop.clipper, x, y);
226
evas_object_resize(sd->crop.clipper, w, h);
236
EMOTION_API Evas_Object *
237
emotion_object_add(Evas *evas)
239
evas = evas_find(evas);
240
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(evas, EVAS_CANVAS_CLASS), NULL);
241
return efl_add(MY_CLASS, evas, efl_canvas_object_legacy_ctor(efl_added));
245
_efl_canvas_video_efl_object_constructor(Eo *obj, Efl_Canvas_Video_Data *pd)
247
efl_canvas_group_clipped_set(obj, EINA_TRUE);
248
obj = efl_constructor(efl_super(obj, MY_CLASS));
249
efl_canvas_object_type_set(obj, E_OBJ_NAME);
251
eina_stringshare_replace(&(pd->engine), "gstreamer1");
254
_engine_init(obj, pd);
259
EMOTION_API Evas_Object *
260
emotion_object_image_get(const Evas_Object *obj)
262
Efl_Canvas_Video_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
263
if (!sd) return NULL;
268
_efl_canvas_video_option_set(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *pd, const char *opt, const char *val)
270
Efl_Canvas_Video_Data *sd = pd;
272
if ((!opt) || (!val)) return;
274
if (strcmp(opt, "video") == 0)
276
if (strcmp(val, "off") == 0)
277
sd->module_options.no_video = EINA_TRUE;
278
else if (strcmp(val, "on") == 0)
279
sd->module_options.no_video = EINA_FALSE;
281
sd->module_options.no_video = !!atoi(val);
283
ERR("Deprecated. Use emotion_object_video_mute_set()");
285
else if (strcmp(opt, "audio") == 0)
287
if (strcmp(val, "off") == 0)
288
sd->module_options.no_audio = EINA_TRUE;
289
else if (strcmp(val, "on") == 0)
290
sd->module_options.no_audio = EINA_FALSE;
292
sd->module_options.no_audio = !!atoi(val);
294
ERR("Deprecated. Use emotion_object_audio_mute_set()");
297
ERR("Unsupported %s=%s", opt, val);
300
EOLIAN static Eina_Bool
301
_efl_canvas_video_engine_set(Eo *obj, Efl_Canvas_Video_Data *pd, const char *engine)
303
Efl_Canvas_Video_Data *sd = pd;
306
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
308
if (!engine) engine = "gstreamer1";
309
if (!strcmp(engine, sd->engine)) return EINA_TRUE;
311
eina_stringshare_replace(&(sd->engine), engine);
316
eina_stringshare_del(sd->title);
318
eina_stringshare_del(sd->progress.info);
319
sd->progress.info = NULL;
320
sd->progress.stat = 0.0;
321
eina_stringshare_del(sd->ref.file);
324
sd->spu.button_num = 0;
328
sd->remember_jump = 0;
331
sd->remember_play = 0;
333
if (sd->anim) ecore_animator_del(sd->anim);
336
if (sd->engine_instance) emotion_engine_instance_del(sd->engine_instance);
337
sd->engine_instance = NULL;
338
_engine_init(obj, sd);
339
if (!sd->engine_instance)
347
emotion_object_file_set(obj, file);
348
eina_stringshare_del(file);
355
emotion_object_file_set(Evas_Object *obj, const char *file)
357
return efl_file_simple_load(obj, file, NULL);
360
EOLIAN static Eina_Error
361
_efl_canvas_video_efl_file_file_set(Eo *obj, Efl_Canvas_Video_Data *sd, const char *file)
363
DBG("file=%s", file);
365
eina_stringshare_replace(&sd->file, file);
367
return efl_file_set(efl_super(obj, MY_CLASS), file);
370
EOLIAN static Eina_Bool
371
_efl_canvas_video_efl_file_loaded_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
373
return sd->open && sd->loaded;
377
_efl_canvas_video_efl_file_unload(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
379
if (sd->engine_instance) emotion_engine_instance_file_close(sd->engine_instance);
380
sd->engine_instance = NULL;
381
evas_object_image_data_set(sd->obj, NULL);
382
evas_object_image_size_set(sd->obj, 1, 1);
383
_emotion_image_data_zero(sd->obj);
385
if (sd->anim) ecore_animator_del(sd->anim);
388
_xattr_data_cancel(sd->xattr);
392
EOLIAN static Eina_Error
393
_efl_canvas_video_efl_file_load(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
395
const char *file = sd->file;
396
if (!sd->engine_instance) _engine_init(obj, sd);
397
if (!sd->engine_instance)
399
WRN("No engine chosen. Please set an engine.");
400
return EFL_GFX_IMAGE_LOAD_ERROR_GENERIC;
405
if ((file) && (file[0] != 0))
409
emotion_engine_instance_file_close(sd->engine_instance);
410
evas_object_image_data_set(sd->obj, NULL);
411
evas_object_image_size_set(sd->obj, 1, 1);
412
_emotion_image_data_zero(sd->obj);
417
file2 = eina_vpath_resolve(file);
420
if (!emotion_engine_instance_file_open(sd->engine_instance, file2))
422
WRN("Couldn't open file=%s", sd->file);
423
return EFL_GFX_IMAGE_LOAD_ERROR_GENERIC;
426
DBG("successfully opened file=%s", sd->file);
428
if (sd->play) emotion_engine_instance_play(sd->engine_instance, 0.0);
432
emotion_engine_instance_file_close(sd->engine_instance);
433
evas_object_image_data_set(sd->obj, NULL);
434
evas_object_image_size_set(sd->obj, 1, 1);
435
_emotion_image_data_zero(sd->obj);
438
if (sd->anim) ecore_animator_del(sd->anim);
441
_xattr_data_cancel(sd->xattr);
447
EMOTION_API const char *
448
emotion_object_file_get(const Evas_Object *obj)
450
return efl_file_get(obj);
454
_emotion_aspect_borders_apply(Evas_Object *obj, Efl_Canvas_Video_Data *sd, int w, int h, int iw, int ih)
458
evas_object_geometry_get(obj, &x, &y, NULL, NULL);
461
if ((sd->crop.l == 0) && (sd->crop.r == 0) &&
462
(sd->crop.t == 0) && (sd->crop.b == 0))
464
Evas_Object *old_clipper;
465
if (sd->crop.clipper)
467
old_clipper = evas_object_clip_get(sd->crop.clipper);
468
evas_object_clip_unset(sd->obj);
469
evas_object_clip_set(sd->obj, old_clipper);
470
evas_object_del(sd->crop.clipper);
471
sd->crop.clipper = NULL;
476
if (!sd->crop.clipper)
478
Evas_Object *old_clipper;
479
sd->crop.clipper = evas_object_rectangle_add
480
(evas_object_evas_get(obj));
481
evas_object_smart_member_add(sd->crop.clipper, obj);
482
old_clipper = evas_object_clip_get(sd->obj);
483
evas_object_clip_set(sd->obj, sd->crop.clipper);
484
evas_object_clip_set(sd->crop.clipper, old_clipper);
485
evas_object_show(sd->crop.clipper);
488
_clipper_position_size_update(obj, x, y, w, h, iw, ih);
492
_efl_canvas_video_aspect_border_apply(Evas_Object *obj, Efl_Canvas_Video_Data *sd, int w, int h)
505
iw = (double)ih * ir;
511
ir = (double)iw / ih;
521
if (sd->aspect == EMOTION_ASPECT_KEEP_NONE)
529
else if (sd->aspect == EMOTION_ASPECT_KEEP_WIDTH)
533
else if (sd->aspect == EMOTION_ASPECT_KEEP_HEIGHT)
537
else if (sd->aspect == EMOTION_ASPECT_KEEP_BOTH)
539
if (ir > r) aspect_opt = 1;
542
else if (sd->aspect == EMOTION_ASPECT_CROP)
544
if (ir > r) aspect_opt = 2;
547
else if (sd->aspect == EMOTION_ASPECT_CUSTOM)
561
scale = (double)iw / w;
564
sd->crop.t = sd->crop.b = dh / 2;
566
else if (aspect_opt == 2)
573
scale = (double)ih / h;
576
sd->crop.l = sd->crop.r = dw / 2;
579
_emotion_aspect_borders_apply(obj, sd, w, h, iw, ih);
583
emotion_object_border_set(Evas_Object *obj, int l, int r, int t, int b)
585
Efl_Canvas_Video_Data *sd;
588
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
590
sd->aspect = EMOTION_ASPECT_CUSTOM;
595
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
596
_efl_canvas_video_aspect_border_apply(obj, sd, w, h);
600
emotion_object_border_get(const Evas_Object *obj, int *l, int *r, int *t, int *b)
602
Efl_Canvas_Video_Data *sd;
604
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
612
emotion_object_bg_color_set(Evas_Object *obj, int r, int g, int b, int a)
614
Efl_Canvas_Video_Data *sd;
616
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
617
evas_object_color_set(sd->bg, r, g, b, a);
621
emotion_object_bg_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a)
623
Efl_Canvas_Video_Data *sd;
625
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
626
evas_object_color_get(sd->bg, r, g, b, a);
630
emotion_object_keep_aspect_set(Evas_Object *obj, Emotion_Aspect a)
632
Efl_Canvas_Video_Data *sd;
635
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
636
if (a == sd->aspect) return;
639
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
640
_efl_canvas_video_aspect_border_apply(obj, sd, w, h);
643
EMOTION_API Emotion_Aspect
644
emotion_object_keep_aspect_get(const Evas_Object *obj)
646
Efl_Canvas_Video_Data *sd;
648
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EMOTION_ASPECT_KEEP_NONE);
653
emotion_object_play_set(Evas_Object *obj, Eina_Bool play)
657
efl_player_playing_set(obj, EINA_TRUE);
658
efl_player_paused_set(obj, !play);
661
EOLIAN static Eina_Bool
662
_efl_canvas_video_efl_player_playing_set(Eo *obj, Efl_Canvas_Video_Data *sd, Eina_Bool play)
665
DBG("play=" FMT_UCHAR ", was=" FMT_UCHAR, play, sd->play);
666
if (!sd->engine_instance) return EINA_FALSE;
668
if (!play) sd->pause = EINA_FALSE;
671
sd->remember_play = play;
674
if (play == sd->play) return EINA_TRUE;
676
sd->remember_play = play;
677
if (sd->state != EMOTION_WAKEUP) emotion_object_suspend_set(obj, EMOTION_WAKEUP);
678
if (sd->play) emotion_engine_instance_play(sd->engine_instance, 0.0);
681
emotion_engine_instance_stop(sd->engine_instance);
682
efl_player_playback_position_set(obj, 0.0);
687
EOLIAN static Eina_Bool
688
_efl_canvas_video_efl_player_paused_set(Eo *obj, Efl_Canvas_Video_Data *sd, Eina_Bool paused)
691
DBG("paused=" FMT_UCHAR ", was=" FMT_UCHAR, paused, sd->pause);
692
if (!sd->engine_instance) return EINA_FALSE;
696
if (sd->remember_play)
698
return sd->remember_play;
700
if (!sd->play) return EINA_FALSE;
701
if (paused == sd->pause) return EINA_TRUE;
704
emotion_engine_instance_stop(sd->engine_instance);
707
if (sd->state != EMOTION_WAKEUP) emotion_object_suspend_set(obj, EMOTION_WAKEUP);
708
emotion_engine_instance_play(sd->engine_instance, sd->pos);
714
emotion_object_play_get(const Evas_Object *obj)
716
return efl_player_playing_get(obj) && !efl_player_paused_get(obj);
719
EOLIAN static Eina_Bool
720
_efl_canvas_video_efl_player_playing_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
722
if (!sd->engine_instance) return EINA_FALSE;
726
EOLIAN static Eina_Bool
727
_efl_canvas_video_efl_player_paused_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
729
if (!sd->engine_instance) return EINA_FALSE;
730
if (!sd->play) return EINA_FALSE;
735
emotion_object_position_set(Evas_Object *obj, double sec)
737
efl_player_playback_position_set(obj, sec);
741
_efl_canvas_video_efl_player_playback_position_set(Eo *obj, Efl_Canvas_Video_Data *sd, double sec)
744
if (!sd->engine_instance) return;
745
if (sec < 0.0) sec = 0.0;
748
sd->remember_jump = sec;
751
sd->remember_jump = 0;
754
sd->pos = sd->seek_pos;
755
if (sd->job) ecore_job_del(sd->job);
756
sd->job = ecore_job_add(_pos_set_job, obj);
760
emotion_object_position_get(const Evas_Object *obj)
762
return efl_player_playback_position_get(obj);
766
_efl_canvas_video_efl_player_playback_position_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
768
if (!sd->engine_instance) return 0.0;
769
sd->pos = emotion_engine_instance_pos_get(sd->engine_instance);
774
emotion_object_buffer_size_get(const Evas_Object *obj)
776
Efl_Canvas_Video_Data *sd;
778
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 1.0);
779
if (!sd->engine_instance) return 0.0;
780
return emotion_engine_instance_buffer_size_get(sd->engine_instance);
784
emotion_object_seekable_get(const Evas_Object *obj)
786
return efl_playable_seekable_get(obj);
790
emotion_object_video_handled_get(const Evas_Object *obj)
792
Efl_Canvas_Video_Data *sd;
794
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
795
if (!sd->engine_instance) return EINA_FALSE;
796
return emotion_engine_instance_video_handled(sd->engine_instance);
800
emotion_object_audio_handled_get(const Evas_Object *obj)
802
Efl_Canvas_Video_Data *sd;
804
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
805
if (!sd->engine_instance) return EINA_FALSE;
806
return emotion_engine_instance_audio_handled(sd->engine_instance);
810
emotion_object_play_length_get(const Evas_Object *obj)
812
return efl_playable_length_get(obj);
816
emotion_object_size_get(const Evas_Object *obj, int *iw, int *ih)
820
sz = efl_gfx_image_load_controller_load_size_get(obj);
825
EOLIAN static Eina_Size2D
826
_efl_canvas_video_efl_gfx_image_load_controller_load_size_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
829
return EINA_SIZE2D(sd->video.w, sd->video.h);
833
emotion_object_smooth_scale_set(Evas_Object *obj, Eina_Bool smooth)
835
efl_gfx_image_smooth_scale_set(obj, smooth);
839
_efl_canvas_video_efl_gfx_image_smooth_scale_set(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd, Eina_Bool smooth)
841
evas_object_image_smooth_scale_set(sd->obj, smooth);
845
emotion_object_smooth_scale_get(const Evas_Object *obj)
847
return efl_gfx_image_smooth_scale_get(obj);
850
EOLIAN static Eina_Bool
851
_efl_canvas_video_efl_gfx_image_smooth_scale_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
853
return evas_object_image_smooth_scale_get(sd->obj);
857
emotion_object_ratio_get(const Evas_Object *obj)
859
return efl_gfx_image_ratio_get(obj);
863
_efl_canvas_video_efl_gfx_image_ratio_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
865
if (!sd->engine_instance) return 0.0;
873
emotion_object_event_simple_send(Evas_Object *obj, Emotion_Event ev)
875
Efl_Canvas_Video_Data *sd;
877
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
878
if (!sd->engine_instance) return;
879
emotion_engine_instance_event_feed(sd->engine_instance, ev);
883
emotion_object_audio_volume_set(Evas_Object *obj, double vol)
885
efl_audio_control_volume_set(obj, vol);
889
_efl_canvas_video_efl_audio_control_volume_set(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd, double vol)
892
if (!sd->engine_instance) return;
893
emotion_engine_instance_audio_channel_volume_set(sd->engine_instance, vol);
897
emotion_object_audio_volume_get(const Evas_Object *obj)
899
return efl_audio_control_volume_get(obj);
903
_efl_canvas_video_efl_audio_control_volume_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
905
if (!sd->engine_instance) return 0.0;
906
return emotion_engine_instance_audio_channel_volume_get(sd->engine_instance);
910
emotion_object_audio_mute_set(Evas_Object *obj, Eina_Bool mute)
912
efl_audio_control_mute_set(obj, mute);
916
_efl_canvas_video_efl_audio_control_mute_set(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd, Eina_Bool mute)
918
DBG("mute=" FMT_UCHAR, mute);
919
if (!sd->engine_instance) return;
920
emotion_engine_instance_audio_channel_mute_set(sd->engine_instance, mute);
924
emotion_object_audio_mute_get(const Evas_Object *obj)
926
return efl_audio_control_mute_get(obj);
929
EOLIAN static Eina_Bool
930
_efl_canvas_video_efl_audio_control_mute_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
932
if (!sd->engine_instance) return EINA_FALSE;
933
return emotion_engine_instance_audio_channel_mute_get(sd->engine_instance);
937
emotion_object_audio_channel_count(const Evas_Object *obj)
939
Efl_Canvas_Video_Data *sd;
941
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
942
if (!sd->engine_instance) return 0;
943
return emotion_engine_instance_audio_channel_count(sd->engine_instance);
946
EMOTION_API const char *
947
emotion_object_audio_channel_name_get(const Evas_Object *obj, int channel)
949
Efl_Canvas_Video_Data *sd;
951
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
952
if (!sd->engine_instance) return NULL;
953
return emotion_engine_instance_audio_channel_name_get(sd->engine_instance, channel);
957
emotion_object_audio_channel_set(Evas_Object *obj, int channel)
959
Efl_Canvas_Video_Data *sd;
961
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
962
DBG("channel=%d", channel);
963
if (!sd->engine_instance) return;
964
emotion_engine_instance_audio_channel_set(sd->engine_instance, channel);
968
emotion_object_audio_channel_get(const Evas_Object *obj)
970
Efl_Canvas_Video_Data *sd;
972
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
973
if (!sd->engine_instance) return 0;
974
return emotion_engine_instance_audio_channel_get(sd->engine_instance);
978
emotion_object_video_mute_set(Evas_Object *obj, Eina_Bool mute)
980
Efl_Canvas_Video_Data *sd;
982
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
983
DBG("mute=" FMT_UCHAR, mute);
984
if (!sd->engine_instance) return;
985
emotion_engine_instance_video_channel_mute_set(sd->engine_instance, mute);
989
emotion_object_video_mute_get(const Evas_Object *obj)
991
Efl_Canvas_Video_Data *sd;
993
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
994
if (!sd->engine_instance) return EINA_FALSE;
995
return emotion_engine_instance_video_channel_mute_get(sd->engine_instance);
999
emotion_object_video_subtitle_file_set(Evas_Object *obj, const char *filepath)
1001
Efl_Canvas_Video_Data *sd;
1003
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1004
DBG("subtitle=%s", filepath);
1005
if (!sd->engine_instance) _engine_init(obj, sd);
1006
if (!sd->engine_instance) return;
1007
emotion_engine_instance_video_subtitle_file_set(sd->engine_instance, filepath);
1010
EMOTION_API const char *
1011
emotion_object_video_subtitle_file_get(const Evas_Object *obj)
1013
Efl_Canvas_Video_Data *sd;
1015
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1016
if (!sd->engine_instance) return NULL;
1017
return emotion_engine_instance_video_subtitle_file_get(sd->engine_instance);
1021
emotion_object_video_channel_count(const Evas_Object *obj)
1023
Efl_Canvas_Video_Data *sd;
1025
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1026
if (!sd->engine_instance) return 0;
1027
return emotion_engine_instance_video_channel_count(sd->engine_instance);
1030
EMOTION_API const char *
1031
emotion_object_video_channel_name_get(const Evas_Object *obj, int channel)
1033
Efl_Canvas_Video_Data *sd;
1035
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1036
if (!sd->engine_instance) return NULL;
1037
return emotion_engine_instance_video_channel_name_get(sd->engine_instance, channel);
1041
emotion_object_video_channel_set(Evas_Object *obj, int channel)
1043
Efl_Canvas_Video_Data *sd;
1045
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1046
DBG("channel=%d", channel);
1047
if (!sd->engine_instance) return;
1048
emotion_engine_instance_video_channel_set(sd->engine_instance, channel);
1052
emotion_object_video_channel_get(const Evas_Object *obj)
1054
Efl_Canvas_Video_Data *sd;
1056
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1057
if (!sd->engine_instance) return 0;
1058
return emotion_engine_instance_video_channel_get(sd->engine_instance);
1062
emotion_object_spu_mute_set(Evas_Object *obj, Eina_Bool mute)
1064
Efl_Canvas_Video_Data *sd;
1066
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1067
DBG("mute=" FMT_UCHAR, mute);
1068
if (!sd->engine_instance) return;
1069
emotion_engine_instance_spu_channel_mute_set(sd->engine_instance, mute);
1072
EMOTION_API Eina_Bool
1073
emotion_object_spu_mute_get(const Evas_Object *obj)
1075
Efl_Canvas_Video_Data *sd;
1077
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1078
if (!sd->engine_instance) return EINA_FALSE;
1079
return emotion_engine_instance_spu_channel_mute_get(sd->engine_instance);
1083
emotion_object_spu_channel_count(const Evas_Object *obj)
1085
Efl_Canvas_Video_Data *sd;
1087
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1088
if (!sd->engine_instance) return 0;
1089
return emotion_engine_instance_spu_channel_count(sd->engine_instance);
1092
EMOTION_API const char *
1093
emotion_object_spu_channel_name_get(const Evas_Object *obj, int channel)
1095
Efl_Canvas_Video_Data *sd;
1097
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1098
if (!sd->engine_instance) return NULL;
1099
return emotion_engine_instance_spu_channel_name_get(sd->engine_instance, channel);
1103
emotion_object_spu_channel_set(Evas_Object *obj, int channel)
1105
Efl_Canvas_Video_Data *sd;
1107
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1108
DBG("channel=%d", channel);
1109
if (!sd->engine_instance) return;
1110
emotion_engine_instance_spu_channel_set(sd->engine_instance, channel);
1114
emotion_object_spu_channel_get(const Evas_Object *obj)
1116
Efl_Canvas_Video_Data *sd;
1118
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1119
if (!sd->engine_instance) return 0;
1120
return emotion_engine_instance_spu_channel_get(sd->engine_instance);
1124
emotion_object_chapter_count(const Evas_Object *obj)
1126
Efl_Canvas_Video_Data *sd;
1128
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1129
if (!sd->engine_instance) return 0;
1130
return emotion_engine_instance_chapter_count(sd->engine_instance);
1134
emotion_object_chapter_set(Evas_Object *obj, int chapter)
1136
Efl_Canvas_Video_Data *sd;
1138
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1139
DBG("chapter=%d", chapter);
1140
if (!sd->engine_instance) return;
1141
emotion_engine_instance_chapter_set(sd->engine_instance, chapter);
1145
emotion_object_chapter_get(const Evas_Object *obj)
1147
Efl_Canvas_Video_Data *sd;
1149
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1150
if (!sd->engine_instance) return 0;
1151
return emotion_engine_instance_chapter_get(sd->engine_instance);
1154
EMOTION_API const char *
1155
emotion_object_chapter_name_get(const Evas_Object *obj, int chapter)
1157
Efl_Canvas_Video_Data *sd;
1159
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1160
if (!sd->engine_instance) return NULL;
1161
return emotion_engine_instance_chapter_name_get(sd->engine_instance, chapter);
1165
emotion_object_play_speed_set(Evas_Object *obj, double speed)
1167
Efl_Canvas_Video_Data *sd;
1169
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1170
DBG("speed=%f", speed);
1171
if (!sd->engine_instance) return;
1172
emotion_engine_instance_speed_set(sd->engine_instance, speed);
1176
emotion_object_play_speed_get(const Evas_Object *obj)
1178
Efl_Canvas_Video_Data *sd;
1180
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0.0);
1181
if (!sd->engine_instance) return 0.0;
1182
return emotion_engine_instance_speed_get(sd->engine_instance);
1186
emotion_object_eject(Evas_Object *obj)
1188
Efl_Canvas_Video_Data *sd;
1190
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1191
if (!sd->engine_instance) return;
1192
emotion_engine_instance_eject(sd->engine_instance);
1195
EMOTION_API const char *
1196
emotion_object_title_get(const Evas_Object *obj)
1198
Efl_Canvas_Video_Data *sd;
1200
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1204
EMOTION_API const char *
1205
emotion_object_progress_info_get(const Evas_Object *obj)
1207
Efl_Canvas_Video_Data *sd;
1209
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1210
return sd->progress.info;
1214
emotion_object_progress_status_get(const Evas_Object *obj)
1216
return efl_player_playback_progress_get(obj);
1220
_efl_canvas_video_efl_player_playback_progress_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
1222
return sd->progress.stat;
1226
_efl_canvas_video_efl_player_playback_progress_set(Eo *obj, Efl_Canvas_Video_Data *sd EINA_UNUSED, double progress)
1228
const char *info = emotion_object_progress_info_get((const Evas_Object*)obj);
1229
_emotion_progress_set(obj, (char*)info, progress);
1233
_efl_canvas_video_efl_playable_length_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
1235
if (!sd->engine_instance) return 0.0;
1236
sd->len = emotion_engine_instance_len_get(sd->engine_instance);
1240
EOLIAN static Eina_Bool
1241
_efl_canvas_video_efl_playable_seekable_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
1243
if (!sd->engine_instance) return EINA_FALSE;
1244
return emotion_engine_instance_seekable(sd->engine_instance);
1247
EMOTION_API const char *
1248
emotion_object_ref_file_get(const Evas_Object *obj)
1250
Efl_Canvas_Video_Data *sd;
1252
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1253
return sd->ref.file;
1257
emotion_object_ref_num_get(const Evas_Object *obj)
1259
Efl_Canvas_Video_Data *sd;
1261
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1266
emotion_object_spu_button_count_get(const Evas_Object *obj)
1268
Efl_Canvas_Video_Data *sd;
1270
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1271
return sd->spu.button_num;
1275
emotion_object_spu_button_get(const Evas_Object *obj)
1277
Efl_Canvas_Video_Data *sd;
1279
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1280
return sd->spu.button;
1283
EMOTION_API const char *
1284
emotion_object_meta_info_get(const Evas_Object *obj, Emotion_Meta_Info meta)
1286
Efl_Canvas_Video_Data *sd;
1289
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1290
if (!sd->engine_instance) return NULL;
1293
case EMOTION_META_INFO_TRACK_TITLE:
1294
id = META_TRACK_TITLE;
1296
case EMOTION_META_INFO_TRACK_ARTIST:
1297
id = META_TRACK_ARTIST;
1299
case EMOTION_META_INFO_TRACK_ALBUM:
1300
id = META_TRACK_ALBUM;
1302
case EMOTION_META_INFO_TRACK_YEAR:
1303
id = META_TRACK_YEAR;
1305
case EMOTION_META_INFO_TRACK_GENRE:
1306
id = META_TRACK_GENRE;
1308
case EMOTION_META_INFO_TRACK_COMMENT:
1309
id = META_TRACK_COMMENT;
1311
case EMOTION_META_INFO_TRACK_DISC_ID:
1312
id = META_TRACK_DISCID;
1315
ERR("Unknown meta info id: %d", meta);
1319
return emotion_engine_instance_meta_get(sd->engine_instance, id);
1323
EMOTION_API Evas_Object *
1324
emotion_file_meta_artwork_get(const Evas_Object *obj, const char *path, Emotion_Artwork_Info type)
1326
Efl_Canvas_Video_Data *sd;
1327
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1328
if (!sd->engine_instance) return NULL;
1330
Evas *ev = evas_object_evas_get(obj);
1331
Evas_Object *artwork = evas_object_image_add(ev);
1333
Evas_Object *result = emotion_engine_instance_meta_artwork_get(sd->engine_instance, artwork, path, type);
1334
if (!result) return NULL;
1336
Evas_Load_Error _error = evas_object_image_load_error_get(result);
1337
if (_error != EVAS_LOAD_ERROR_NONE) return NULL;
1343
emotion_object_vis_set(Evas_Object *obj, Emotion_Vis visualization)
1345
Efl_Canvas_Video_Data *sd;
1347
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1348
DBG("visualization=%d", visualization);
1349
if (!sd->engine_instance) return;
1350
emotion_engine_instance_vis_set(sd->engine_instance, visualization);
1353
EMOTION_API Emotion_Vis
1354
emotion_object_vis_get(const Evas_Object *obj)
1356
Efl_Canvas_Video_Data *sd;
1358
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EMOTION_VIS_NONE);
1359
if (!sd->engine_instance) return EMOTION_VIS_NONE;
1360
return emotion_engine_instance_vis_get(sd->engine_instance);
1363
EMOTION_API Eina_Bool
1364
emotion_object_vis_supported(const Evas_Object *obj, Emotion_Vis visualization)
1366
Efl_Canvas_Video_Data *sd;
1368
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EINA_FALSE);
1369
if (!sd->engine_instance) return EINA_FALSE;
1370
return emotion_engine_instance_vis_supported(sd->engine_instance, visualization);
1374
emotion_object_priority_set(Evas_Object *obj, Eina_Bool priority)
1376
Efl_Canvas_Video_Data *sd;
1378
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1379
if (!sd->engine_instance) return;
1380
emotion_engine_instance_priority_set(sd->engine_instance, priority);
1383
EMOTION_API Eina_Bool
1384
emotion_object_priority_get(const Evas_Object *obj)
1386
Efl_Canvas_Video_Data *sd;
1388
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EINA_FALSE);
1389
if (!sd->engine_instance) return EINA_FALSE;
1390
return emotion_engine_instance_priority_get(sd->engine_instance);
1395
_eio_load_xattr_cleanup(Emotion_Xattr_Data *xattr, Eio_File *handler)
1397
if (handler == xattr->load) xattr->load = NULL;
1398
_xattr_data_unref(xattr);
1402
_eio_load_xattr_done(void *data, Eio_File *handler, double xattr_double)
1404
Emotion_Xattr_Data *xattr = data;
1406
emotion_object_position_set(evas_object_smart_parent_get(xattr->obj_wref), xattr_double);
1407
efl_event_callback_call(evas_object_smart_parent_get(xattr->obj_wref), EFL_CANVAS_VIDEO_EVENT_POSITION_LOAD_DONE, NULL);
1408
evas_object_smart_callback_call(evas_object_smart_parent_get(xattr->obj_wref), "position_load,succeed", NULL);
1409
_eio_load_xattr_cleanup(xattr, handler);
1413
_eio_load_xattr_error(void *data, Eio_File *handler, int err EINA_UNUSED)
1415
Emotion_Xattr_Data *xattr = data;
1417
efl_event_callback_call(evas_object_smart_parent_get(xattr->obj_wref), EFL_CANVAS_VIDEO_EVENT_POSITION_LOAD_FAIL, NULL);
1418
evas_object_smart_callback_call(evas_object_smart_parent_get(xattr->obj_wref), "position_load,failed", NULL);
1419
_eio_load_xattr_cleanup(xattr, handler);
1424
emotion_object_last_position_load(Evas_Object *obj)
1426
Efl_Canvas_Video_Data *sd;
1432
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1433
if (!sd->file) return;
1435
if (!strncmp(sd->file, "file://", 7)) tmp = sd->file + 7;
1436
else if (!strstr(sd->file, "://")) tmp = sd->file;
1440
Emotion_Xattr_Data *xattr = sd->xattr;
1442
if (xattr->load) return;
1443
EINA_REFCOUNT_REF(xattr);
1445
xattr->load = eio_file_xattr_double_get(tmp,
1447
_eio_load_xattr_done,
1448
_eio_load_xattr_error,
1451
if (eina_xattr_double_get(tmp, "user.e.time_seek", &xattr))
1453
emotion_object_position_set(obj, xattr);
1454
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_POSITION_LOAD_DONE, NULL);
1455
evas_object_smart_callback_call(obj, "position_load,succeed", NULL);
1459
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_POSITION_LOAD_FAIL, NULL);
1460
evas_object_smart_callback_call(obj, "position_load,failed", NULL);
1467
_eio_save_xattr_cleanup(Emotion_Xattr_Data *xattr, Eio_File *handler)
1469
if (handler == xattr->save) xattr->save = NULL;
1470
_xattr_data_unref(xattr);
1474
_eio_save_xattr_done(void *data, Eio_File *handler)
1476
Emotion_Xattr_Data *xattr = data;
1478
efl_event_callback_call(xattr->obj_wref, EFL_CANVAS_VIDEO_EVENT_POSITION_SAVE_DONE, NULL);
1479
evas_object_smart_callback_call(xattr->obj_wref, "position_save,succeed", NULL);
1480
_eio_save_xattr_cleanup(xattr, handler);
1484
_eio_save_xattr_error(void *data, Eio_File *handler, int err EINA_UNUSED)
1486
Emotion_Xattr_Data *xattr = data;
1488
efl_event_callback_call(xattr->obj_wref, EFL_CANVAS_VIDEO_EVENT_POSITION_SAVE_FAIL, NULL);
1489
evas_object_smart_callback_call(xattr->obj_wref, "position_save,failed", NULL);
1490
_eio_save_xattr_cleanup(xattr, handler);
1495
emotion_object_last_position_save(Evas_Object *obj)
1497
Efl_Canvas_Video_Data *sd;
1500
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1501
if (!sd->file) return;
1503
if (!strncmp(sd->file, "file://", 7)) tmp = sd->file + 7;
1504
else if (!strstr(sd->file, "://")) tmp = sd->file;
1507
Emotion_Xattr_Data *xattr = sd->xattr;
1509
if (xattr->save) return;
1510
EINA_REFCOUNT_REF(xattr);
1512
xattr->save = eio_file_xattr_double_set(tmp,
1514
emotion_object_position_get(obj),
1516
_eio_save_xattr_done,
1517
_eio_save_xattr_error,
1520
if (eina_xattr_double_set(tmp, "user.e.time_seek", emotion_object_position_get(obj), 0))
1522
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_POSITION_SAVE_DONE, NULL);
1523
evas_object_smart_callback_call(obj, "position_save,succeed", NULL);
1527
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_POSITION_SAVE_FAIL, NULL);
1528
evas_object_smart_callback_call(obj, "position_save,failed", NULL);
1534
emotion_object_suspend_set(Evas_Object *obj, Emotion_Suspend state)
1536
Efl_Canvas_Video_Data *sd;
1538
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1541
case EMOTION_WAKEUP:
1545
case EMOTION_DEEP_SLEEP:
1547
case EMOTION_HIBERNATE:
1555
EMOTION_API Emotion_Suspend
1556
emotion_object_suspend_get(Evas_Object *obj)
1558
Efl_Canvas_Video_Data *sd;
1560
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EMOTION_WAKEUP);
1569
_emotion_video_get(const Evas_Object *obj)
1571
Efl_Canvas_Video_Data *sd;
1573
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1574
return emotion_engine_instance_data_get(sd->engine_instance);
1578
_emotion_frame_anim(void *data)
1580
Evas_Object *obj = data;
1581
Efl_Canvas_Video_Data *sd;
1583
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, EINA_FALSE);
1586
evas_object_image_pixels_dirty_set(sd->obj, 1);
1587
_emotion_video_pos_update(obj,
1588
emotion_engine_instance_pos_get(sd->engine_instance),
1589
emotion_engine_instance_len_get(sd->engine_instance));
1590
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_FRAME_DECODE, NULL);
1591
evas_object_smart_callback_call(obj, "frame_decode", NULL);
1596
_emotion_frame_new(Evas_Object *obj)
1598
Efl_Canvas_Video_Data *sd;
1600
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1602
sd->anim = ecore_evas_animator_add(obj, _emotion_frame_anim, obj);
1606
_emotion_video_pos_update(Evas_Object *obj, double pos, double len)
1608
Efl_Canvas_Video_Data *sd;
1609
int npos = 0, nlen = 0;
1611
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1612
if (!EINA_DBL_EQ(pos, sd->pos)) npos = 1;
1613
if (!EINA_DBL_EQ(len, sd->len)) nlen = 1;
1618
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_POSITION_CHANGE, NULL);
1619
evas_object_smart_callback_call(obj, "position_update", NULL);
1623
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_LENGTH_CHANGE, NULL);
1624
evas_object_smart_callback_call(obj, "length_change", NULL);
1629
_emotion_frame_resize(Evas_Object *obj, int w, int h, double ratio)
1631
Efl_Canvas_Video_Data *sd;
1635
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1636
if ((w != sd->video.w) || (h != sd->video.h))
1640
_emotion_image_data_zero(sd->obj);
1643
if (h > 0) tmp = (double)w / (double)h;
1645
if (!EINA_DBL_EQ(ratio, tmp)) tmp = ratio;
1646
if (!EINA_DBL_EQ(tmp, sd->ratio))
1653
evas_object_size_hint_request_set(obj, w, h);
1654
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_FRAME_RESIZE, NULL);
1655
evas_object_smart_callback_call(obj, "frame_resize", NULL);
1656
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1657
_efl_canvas_video_aspect_border_apply(obj, sd, w, h);
1662
_emotion_image_reset(Evas_Object *obj)
1664
Efl_Canvas_Video_Data *sd;
1666
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1667
_emotion_image_data_zero(sd->obj);
1671
_emotion_decode_stop(Evas_Object *obj)
1673
Efl_Canvas_Video_Data *sd;
1675
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1679
evas_object_smart_callback_call(obj, "decode_stop", NULL);
1684
_emotion_open_done(Evas_Object *obj)
1686
Efl_Canvas_Video_Data *sd;
1688
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1691
if (!EINA_DBL_EQ(sd->remember_jump, 0.0))
1692
emotion_object_position_set(obj, sd->remember_jump);
1693
if (sd->remember_play != sd->play)
1696
sd->play = sd->remember_play;
1698
emotion_object_play_set(obj, sd->remember_play);
1700
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_OPEN_DONE, NULL);
1701
evas_object_smart_callback_call(obj, "open_done", NULL);
1705
_emotion_playback_started(Evas_Object *obj)
1707
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_PLAYBACK_START, NULL);
1708
evas_object_smart_callback_call(obj, "playback_started", NULL);
1712
_emotion_playback_finished(Evas_Object *obj)
1714
Efl_Canvas_Video_Data *sd;
1716
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1717
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_PLAYBACK_STOP, NULL);
1718
evas_object_smart_callback_call(obj, "playback_finished", NULL);
1722
_emotion_audio_level_change(Evas_Object *obj)
1724
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_VOLUME_CHANGE, NULL);
1725
evas_object_smart_callback_call(obj, "audio_level_change", NULL);
1729
_emotion_channels_change(Evas_Object *obj)
1731
Efl_Canvas_Video_Data *sd;
1733
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1734
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_CHANNELS_CHANGE, NULL);
1735
evas_object_smart_callback_call(obj, "channels_change", NULL);
1739
_emotion_title_set(Evas_Object *obj, char *title)
1741
Efl_Canvas_Video_Data *sd;
1743
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1744
eina_stringshare_replace(&sd->title, title);
1745
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_TITLE_CHANGE, NULL);
1746
evas_object_smart_callback_call(obj, "title_change", NULL);
1750
_emotion_progress_set(Evas_Object *obj, char *info, double st)
1752
Efl_Canvas_Video_Data *sd;
1754
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1755
eina_stringshare_replace(&sd->progress.info, info);
1756
sd->progress.stat = st;
1757
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_PROGRESS_CHANGE, NULL);
1758
evas_object_smart_callback_call(obj, "progress_change", NULL);
1762
_emotion_file_ref_set(Evas_Object *obj, const char *file, int num)
1764
Efl_Canvas_Video_Data *sd;
1766
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1767
eina_stringshare_replace(&sd->ref.file, file);
1769
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_REF_CHANGE, NULL);
1770
evas_object_smart_callback_call(obj, "ref_change", NULL);
1774
_emotion_spu_button_num_set(Evas_Object *obj, int num)
1776
Efl_Canvas_Video_Data *sd;
1778
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1779
sd->spu.button_num = num;
1780
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_BUTTON_NUM_CHANGE, NULL);
1781
evas_object_smart_callback_call(obj, "button_num_change", NULL);
1785
_emotion_spu_button_set(Evas_Object *obj, int button)
1787
Efl_Canvas_Video_Data *sd;
1789
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1790
sd->spu.button = button;
1791
efl_event_callback_call(obj, EFL_CANVAS_VIDEO_EVENT_BUTTON_CHANGE, NULL);
1792
evas_object_smart_callback_call(obj, "button_change", NULL);
1796
_emotion_seek_done(Evas_Object *obj)
1798
Efl_Canvas_Video_Data *sd;
1800
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1804
if (sd->seek) emotion_object_position_set(obj, sd->seek_pos);
1809
_emotion_frame_refill(Evas_Object *obj, double w, double h)
1811
Efl_Canvas_Video_Data *sd;
1813
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1814
if ((!EINA_DBL_EQ(sd->fill.w, w)) ||
1815
(!EINA_DBL_EQ(sd->fill.h, h)))
1819
evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
1820
if ((w <= 0) || (h <= 0))
1822
double scale_w, scale_h;
1827
scale_w = (double)ow / (double)(sd->video.w - sd->crop.l - sd->crop.r);
1828
scale_h = (double)oh / (double)(sd->video.h - sd->crop.t - sd->crop.b);
1829
evas_object_image_fill_set(sd->obj, 0, 0, scale_w * sd->video.w, scale_h * sd->video.h);
1835
evas_object_image_fill_set(sd->obj, 0, 0, w * ow, h * oh);
1845
_mouse_move(void *data, Evas *ev EINA_UNUSED, Evas_Object *obj, void *event_info)
1847
Evas_Event_Mouse_Move *e;
1848
Efl_Canvas_Video_Data *sd;
1850
Evas_Coord ox, oy, ow, oh;
1854
if (!sd->engine_instance) return;
1855
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
1856
evas_object_image_size_get(obj, &iw, &ih);
1857
if ((iw < 1) || (ih < 1)) return;
1858
x = (((int)e->cur.canvas.x - ox) * iw) / ow;
1859
y = (((int)e->cur.canvas.y - oy) * ih) / oh;
1860
emotion_engine_instance_event_mouse_move_feed(sd->engine_instance, x, y);
1864
_mouse_down(void *data, Evas *ev EINA_UNUSED, Evas_Object *obj, void *event_info)
1866
Evas_Event_Mouse_Down *e;
1867
Efl_Canvas_Video_Data *sd;
1869
Evas_Coord ox, oy, ow, oh;
1873
if (!sd->engine_instance) return;
1874
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
1875
evas_object_image_size_get(obj, &iw, &ih);
1876
if ((iw < 1) || (ih < 1)) return;
1877
x = (((int)e->canvas.x - ox) * iw) / ow;
1878
y = (((int)e->canvas.y - oy) * ih) / oh;
1879
emotion_engine_instance_event_mouse_button_feed(sd->engine_instance, 1, x, y);
1883
_pos_set_job(void *data)
1886
Efl_Canvas_Video_Data *sd;
1889
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1891
if (!sd->engine_instance) return;
1892
if (sd->seeking) return;
1896
emotion_engine_instance_pos_set(sd->engine_instance, sd->seek_pos);
1903
_pixels_get(void *data, Evas_Object *obj)
1906
Efl_Canvas_Video_Data *sd;
1907
Emotion_Format format;
1908
unsigned char *bgra_data;
1911
if (!sd->engine_instance) return;
1912
emotion_engine_instance_video_data_size_get(sd->engine_instance, &w, &h);
1916
evas_object_image_colorspace_set(obj, EVAS_COLORSPACE_YCBCR422P601_PL);
1917
evas_object_image_alpha_set(obj, 0);
1918
evas_object_image_size_set(obj, w, h);
1922
if ((iw <= 1) || (ih <= 1))
1924
_emotion_image_data_zero(sd->obj);
1925
evas_object_image_pixels_dirty_set(obj, 0);
1929
format = emotion_engine_instance_format_get(sd->engine_instance);
1930
if ((format == EMOTION_FORMAT_YV12) || (format == EMOTION_FORMAT_I420))
1932
unsigned char **rows;
1934
evas_object_image_colorspace_set(obj, EVAS_COLORSPACE_YCBCR422P601_PL);
1935
rows = evas_object_image_data_get(obj, 1);
1938
if (emotion_engine_instance_yuv_rows_get(sd->engine_instance, iw, ih,
1941
&rows[ih + (ih / 2)]))
1942
evas_object_image_data_update_add(obj, 0, 0, iw, ih);
1944
evas_object_image_data_set(obj, rows);
1945
evas_object_image_pixels_dirty_set(obj, 0);
1947
else if (format == EMOTION_FORMAT_BGRA)
1949
evas_object_image_colorspace_set(obj, EVAS_COLORSPACE_ARGB8888);
1950
if (emotion_engine_instance_bgra_data_get(sd->engine_instance, &bgra_data))
1952
evas_object_image_data_set(obj, bgra_data);
1953
evas_object_image_pixels_dirty_set(obj, 0);
1964
_efl_canvas_video_efl_canvas_group_group_add(Evas_Object *obj, Efl_Canvas_Video_Data *sd)
1966
Emotion_Xattr_Data *xattr;
1967
unsigned int *pixel;
1972
efl_canvas_group_add(efl_super(obj, MY_CLASS));
1974
sd->state = EMOTION_WAKEUP;
1975
sd->obj = evas_object_image_add(evas_object_evas_get(obj));
1976
sd->bg = evas_object_rectangle_add(evas_object_evas_get(obj));
1977
sd->engine = eina_stringshare_add("gstreamer1");
1978
evas_object_color_set(sd->bg, 0, 0, 0, 0);
1979
evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, sd);
1980
evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, sd);
1981
evas_object_image_pixels_get_callback_set(sd->obj, _pixels_get, sd);
1982
evas_object_smart_member_add(sd->obj, obj);
1983
evas_object_smart_member_add(sd->bg, obj);
1984
evas_object_lower(sd->bg);
1986
sd->spu.button = -1;
1989
evas_object_image_alpha_set(sd->obj, 0);
1990
pixel = evas_object_image_data_get(sd->obj, 1);
1993
*pixel = 0xff000000;
1994
evas_object_image_data_set(obj, pixel);
1996
evas_object_show(sd->obj);
1997
evas_object_show(sd->bg);
1999
xattr = calloc(1, sizeof(*xattr));
2000
EINA_REFCOUNT_INIT(xattr);
2001
efl_wref_add(obj, &xattr->obj_wref);
2006
_efl_canvas_video_efl_canvas_group_group_del(Evas_Object *obj EINA_UNUSED, Efl_Canvas_Video_Data *sd)
2008
if (sd->engine_instance)
2010
emotion_engine_instance_file_close(sd->engine_instance);
2011
emotion_engine_instance_del(sd->engine_instance);
2013
sd->engine_instance = NULL;
2014
if (sd->job) ecore_job_del(sd->job);
2016
if (sd->anim) ecore_animator_del(sd->anim);
2018
eina_stringshare_del(sd->file);
2019
eina_stringshare_del(sd->progress.info);
2020
eina_stringshare_del(sd->ref.file);
2022
sd->progress.info = NULL;
2023
sd->ref.file = NULL;
2024
_xattr_data_unref(sd->xattr);
2025
efl_canvas_group_del(efl_super(obj, MY_CLASS));
2030
_efl_canvas_video_efl_gfx_entity_position_set(Evas_Object *obj, Efl_Canvas_Video_Data *sd, Eina_Position2D pos)
2034
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, pos.x, pos.y))
2037
efl_gfx_entity_position_set(efl_super(obj, MY_CLASS), pos);
2039
sz = efl_gfx_entity_size_get(obj);
2040
_clipper_position_size_update(obj, pos.x, pos.y, sz.w, sz.h, sd->video.w, sd->video.h);
2044
_efl_canvas_video_efl_gfx_entity_size_set(Evas_Object *obj, Efl_Canvas_Video_Data *sd, Eina_Size2D sz)
2046
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, sz.w, sz.h))
2049
efl_gfx_entity_size_set(efl_super(obj, MY_CLASS), sz);
2051
_efl_canvas_video_aspect_border_apply(obj, sd, sz.w, sz.h);
2052
evas_object_resize(sd->bg, sz.w, sz.h);
2057
#define EFL_CANVAS_VIDEO_EXTRA_OPS \
2058
EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_canvas_video)
2061
#include "efl_canvas_video.eo.c"
2062
#include "efl_canvas_video_eo.legacy.c"