summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/lib
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2011-06-23 14:58:11 +0000
committerCedric BAIL <cedric.bail@free.fr>2011-06-23 14:58:11 +0000
commit3c8eb1b62b540b434c1260939f131c4ba498448f (patch)
tree034b7f2f56673bfec160c4f84cafe18fecd35649 /legacy/emotion/src/lib
parent28c4f6f8f5519bf9331f1efd9043cb540d02d3cd (diff)
emotion: add a way to test if a file could be played by emotion.
SVN revision: 60637
Diffstat (limited to 'legacy/emotion/src/lib')
-rw-r--r--legacy/emotion/src/lib/Emotion.h8
-rw-r--r--legacy/emotion/src/lib/emotion_private.h3
-rw-r--r--legacy/emotion/src/lib/emotion_smart.c135
3 files changed, 140 insertions, 6 deletions
diff --git a/legacy/emotion/src/lib/Emotion.h b/legacy/emotion/src/lib/Emotion.h
index 009e39101e..9a2b4f8136 100644
--- a/legacy/emotion/src/lib/Emotion.h
+++ b/legacy/emotion/src/lib/Emotion.h
@@ -174,8 +174,14 @@ EAPI void emotion_object_vis_set (Evas_Object *obj, Emotio
174EAPI Emotion_Vis emotion_object_vis_get (const Evas_Object *obj); 174EAPI Emotion_Vis emotion_object_vis_get (const Evas_Object *obj);
175EAPI Eina_Bool emotion_object_vis_supported (const Evas_Object *obj, Emotion_Vis visualization); 175EAPI Eina_Bool emotion_object_vis_supported (const Evas_Object *obj, Emotion_Vis visualization);
176 176
177EAPI Eina_Bool emotion_object_extension_can_play_get(const Evas_Object *obj, const char *file);
178EAPI Eina_Bool emotion_object_extension_can_play_fast_get(const Evas_Object *obj, const char *file);
179
180EAPI Eina_Bool emotion_object_extension_may_play_fast_get(const char *file);
181EAPI Eina_Bool emotion_object_extension_may_play_get(const char *file);
182
177#ifdef __cplusplus 183#ifdef __cplusplus
178} 184}
179#endif 185#endif
180 186
181#endif 187#endif
diff --git a/legacy/emotion/src/lib/emotion_private.h b/legacy/emotion/src/lib/emotion_private.h
index 3fae9684b2..cedf978579 100644
--- a/legacy/emotion/src/lib/emotion_private.h
+++ b/legacy/emotion/src/lib/emotion_private.h
@@ -109,6 +109,7 @@ struct _Emotion_Video_Module
109 double (*speed_get) (void *ef); 109 double (*speed_get) (void *ef);
110 int (*eject) (void *ef); 110 int (*eject) (void *ef);
111 const char * (*meta_get) (void *ef, int meta); 111 const char * (*meta_get) (void *ef, int meta);
112 Eina_Bool (*can_play_get) (const void *ef, const char *file);
112 113
113 Eina_Emotion_Plugins *plugin; 114 Eina_Emotion_Plugins *plugin;
114}; 115};
@@ -131,6 +132,8 @@ EAPI void _emotion_spu_button_num_set(Evas_Object *obj, int num);
131EAPI void _emotion_spu_button_set(Evas_Object *obj, int button); 132EAPI void _emotion_spu_button_set(Evas_Object *obj, int button);
132EAPI void _emotion_seek_done(Evas_Object *obj); 133EAPI void _emotion_seek_done(Evas_Object *obj);
133 134
135EAPI Eina_Bool _emotion_object_extension_can_play_generic_get(const void *data __UNUSED__, const char *file);
136
134EAPI Eina_Bool _emotion_module_register(const char *name, Emotion_Module_Open open, Emotion_Module_Close close); 137EAPI Eina_Bool _emotion_module_register(const char *name, Emotion_Module_Open open, Emotion_Module_Close close);
135EAPI Eina_Bool _emotion_module_unregister(const char *name); 138EAPI Eina_Bool _emotion_module_unregister(const char *name);
136 139
diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c
index 5fdbc33319..bdee730b32 100644
--- a/legacy/emotion/src/lib/emotion_smart.c
+++ b/legacy/emotion/src/lib/emotion_smart.c
@@ -184,7 +184,7 @@ _emotion_module_open(const char *name, Evas_Object *obj, Emotion_Video_Module **
184{ 184{
185 Eina_Emotion_Plugins *plugin; 185 Eina_Emotion_Plugins *plugin;
186 Smart_Data *sd; 186 Smart_Data *sd;
187 unsigned int index = 0; 187 unsigned int i = 0;
188 188
189 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0); 189 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
190 if (!_backends) 190 if (!_backends)
@@ -198,13 +198,13 @@ _emotion_module_open(const char *name, Evas_Object *obj, Emotion_Video_Module **
198 198
199 /* FIXME: Always look for a working backend. */ 199 /* FIXME: Always look for a working backend. */
200 retry: 200 retry:
201 if (!name || index > 0) 201 if (!name || i > 0)
202 name = _backend_priority[index++]; 202 name = _backend_priority[i++];
203 203
204 plugin = eina_hash_find(_backends, name); 204 plugin = eina_hash_find(_backends, name);
205 if (!plugin) 205 if (!plugin)
206 { 206 {
207 if (index != 0 && index < (sizeof (_backend_priority) / sizeof (char*))) 207 if (i != 0 && i < (sizeof (_backend_priority) / sizeof (char*)))
208 goto retry; 208 goto retry;
209 209
210 ERR("No backend loaded"); 210 ERR("No backend loaded");
@@ -220,7 +220,7 @@ _emotion_module_open(const char *name, Evas_Object *obj, Emotion_Video_Module **
220 } 220 }
221 } 221 }
222 222
223 if (index != 0 && index < (sizeof (_backend_priority) / sizeof (char*))) 223 if (i != 0 && i < (sizeof (_backend_priority) / sizeof (char*)))
224 goto retry; 224 goto retry;
225 225
226 ERR("Unable to load module: %s", name); 226 ERR("Unable to load module: %s", name);
@@ -991,12 +991,137 @@ emotion_object_vis_supported(const Evas_Object *obj, Emotion_Vis visualization)
991 return sd->module->vis_supported(sd->video, visualization); 991 return sd->module->vis_supported(sd->video, visualization);
992} 992}
993 993
994EAPI Eina_Bool
995emotion_object_extension_can_play_fast_get(const Evas_Object *obj, const char *file)
996{
997 const Smart_Data *sd;
998
999 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
1000 if (!sd->module) return EINA_FALSE;
1001 if (!sd->video) return EINA_FALSE;
1002 if (!sd->module->can_play_get) return EINA_FALSE;
1003 return sd->module->can_play_get(sd->video, file);
1004}
1005
1006EAPI Eina_Bool
1007emotion_object_extension_can_play_get(const Evas_Object *obj, const char *file)
1008{
1009 const char *tmp;
1010 Eina_Bool result;
994 1011
1012 tmp = eina_stringshare_add(file);
1013 result = emotion_object_extension_can_play_fast_get(obj, tmp);
1014 eina_stringshare_del(tmp);
1015
1016 return result;
1017}
1018
1019EAPI Eina_Bool
1020emotion_object_extension_may_play_fast_get(const char *file)
1021{
1022 if (!file) return EINA_FALSE;
1023 return _emotion_object_extension_can_play_generic_get(NULL, file);
1024}
1025
1026EAPI Eina_Bool
1027emotion_object_extension_may_play_get(const char *file)
1028{
1029 const char *tmp;
1030 Eina_Bool result;
1031
1032 if (!file) return EINA_FALSE;
1033 tmp = eina_stringshare_add(file);
1034 result = emotion_object_extension_may_play_fast_get(tmp);
1035 eina_stringshare_del(tmp);
1036
1037 return result;
1038}
995 1039
996/*****************************/ 1040/*****************************/
997/* Utility calls for modules */ 1041/* Utility calls for modules */
998/*****************************/ 1042/*****************************/
999 1043
1044struct ext_match_s
1045{
1046 unsigned int length;
1047 const char *extension;
1048};
1049
1050#define MATCHING(Ext) \
1051 { sizeof (Ext), Ext }
1052
1053static const struct ext_match_s matchs[] =
1054{ /* map extensions to know if it's a emotion playable content for good first-guess tries */
1055 MATCHING(".264"),
1056 MATCHING(".3g2"),
1057 MATCHING(".3gp"),
1058 MATCHING(".3gp2"),
1059 MATCHING(".3gpp"),
1060 MATCHING(".3gpp2"),
1061 MATCHING(".3p2"),
1062 MATCHING(".asf"),
1063 MATCHING(".avi"),
1064 MATCHING(".bdm"),
1065 MATCHING(".bdmv"),
1066 MATCHING(".clpi"),
1067 MATCHING(".clp"),
1068 MATCHING(".fla"),
1069 MATCHING(".flv"),
1070 MATCHING(".m1v"),
1071 MATCHING(".m2v"),
1072 MATCHING(".m2t"),
1073 MATCHING(".m4v"),
1074 MATCHING(".mkv"),
1075 MATCHING(".mov"),
1076 MATCHING(".mp2"),
1077 MATCHING(".mp2ts"),
1078 MATCHING(".mp4"),
1079 MATCHING(".mpe"),
1080 MATCHING(".mpeg"),
1081 MATCHING(".mpg"),
1082 MATCHING(".mpl"),
1083 MATCHING(".mpls"),
1084 MATCHING(".mts"),
1085 MATCHING(".mxf"),
1086 MATCHING(".nut"),
1087 MATCHING(".nuv"),
1088 MATCHING(".ogg"),
1089 MATCHING(".ogm"),
1090 MATCHING(".ogv"),
1091 MATCHING(".rm"),
1092 MATCHING(".rmj"),
1093 MATCHING(".rmm"),
1094 MATCHING(".rms"),
1095 MATCHING(".rmx"),
1096 MATCHING(".rmvb"),
1097 MATCHING(".swf"),
1098 MATCHING(".ts"),
1099 MATCHING(".weba"),
1100 MATCHING(".webm"),
1101 MATCHING(".wmv")
1102};
1103
1104EAPI Eina_Bool
1105_emotion_object_extension_can_play_generic_get(const void *data __UNUSED__, const char *file)
1106{
1107 unsigned int length;
1108 unsigned int i;
1109
1110 length = eina_stringshare_strlen(file) + 1;
1111 if (length < 5) return EINA_FALSE;
1112
1113 for (i = 0; i < sizeof (matchs) / sizeof (struct ext_match_s); ++i)
1114 {
1115 if (matchs[i].length > length) continue;
1116
1117 if (!strcasecmp(matchs[i].extension,
1118 file + length - matchs[i].length))
1119 return EINA_TRUE;
1120 }
1121
1122 return EINA_FALSE;
1123}
1124
1000EAPI void * 1125EAPI void *
1001_emotion_video_get(const Evas_Object *obj) 1126_emotion_video_get(const Evas_Object *obj)
1002{ 1127{