summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAl Poole <netstar@gmail.com>2017-01-12 14:09:49 -0800
committerCedric BAIL <cedric@osg.samsung.com>2017-01-12 14:37:19 -0800
commit1f9e915b5a001b4f4845defda559434b35588e96 (patch)
treed54da0c896305fab2b89fcf648af6b44ad01a0c0 /src
parent50c9d1aeaa9172e4b6492eabd0da49aafd3523bb (diff)
emotion: add support for obtaining embedded artwork from media files with gstreamer1 backend.
Reviewers: raster, cedric Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4550 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to '')
-rw-r--r--src/lib/emotion/Emotion.h18
-rw-r--r--src/lib/emotion/emotion_modules.c6
-rw-r--r--src/lib/emotion/emotion_modules.h1
-rw-r--r--src/lib/emotion/emotion_private.h3
-rw-r--r--src/lib/emotion/emotion_smart.c20
-rw-r--r--src/modules/emotion/generic/emotion_generic.c3
-rw-r--r--src/modules/emotion/gstreamer/emotion_gstreamer.c3
-rw-r--r--src/modules/emotion/gstreamer1/emotion_gstreamer.c78
-rw-r--r--src/modules/emotion/gstreamer1/emotion_gstreamer.h1
-rw-r--r--src/modules/emotion/libvlc/emotion_libvlc.c3
-rw-r--r--src/modules/emotion/xine/emotion_xine.c3
11 files changed, 131 insertions, 8 deletions
diff --git a/src/lib/emotion/Emotion.h b/src/lib/emotion/Emotion.h
index 3ea786391d..b4914d65a5 100644
--- a/src/lib/emotion/Emotion.h
+++ b/src/lib/emotion/Emotion.h
@@ -196,6 +196,12 @@ enum _Emotion_Meta_Info
196 EMOTION_META_INFO_TRACK_COUNT /**< track count - number of the track in the album */ 196 EMOTION_META_INFO_TRACK_COUNT /**< track count - number of the track in the album */
197}; 197};
198 198
199enum _Emotion_Artwork_Info
200{
201 EMOTION_ARTWORK_IMAGE,
202 EMOTION_ARTWORK_PREVIEW_IMAGE
203};
204
199/** 205/**
200 * @enum _Emotion_Vis 206 * @enum _Emotion_Vis
201 * 207 *
@@ -266,6 +272,7 @@ typedef enum _Emotion_Event Emotion_Event;
266typedef enum _Emotion_Meta_Info Emotion_Meta_Info; /**< Meta info type to be retrieved. */ 272typedef enum _Emotion_Meta_Info Emotion_Meta_Info; /**< Meta info type to be retrieved. */
267typedef enum _Emotion_Vis Emotion_Vis; /**< Type of visualization. */ 273typedef enum _Emotion_Vis Emotion_Vis; /**< Type of visualization. */
268typedef enum _Emotion_Aspect Emotion_Aspect; /**< Aspect ratio option. */ 274typedef enum _Emotion_Aspect Emotion_Aspect; /**< Aspect ratio option. */
275typedef enum _Emotion_Artwork_Info Emotion_Artwork_Info;
269 276
270#define EMOTION_CHANNEL_AUTO -1 277#define EMOTION_CHANNEL_AUTO -1
271#define EMOTION_CHANNEL_DEFAULT 0 278#define EMOTION_CHANNEL_DEFAULT 0
@@ -1341,6 +1348,17 @@ EAPI const char *emotion_webcam_name_get(const Emotion_Webcam *ew);
1341EAPI const char *emotion_webcam_device_get(const Emotion_Webcam *ew); 1348EAPI const char *emotion_webcam_device_get(const Emotion_Webcam *ew);
1342 1349
1343/** 1350/**
1351 * @brief Get the album artwork from file meta data tags.
1352 *
1353 * @param obj The evas object we are working with.
1354 * @param path The local path for the file.
1355 * @param type The metadata location type (GST_IMAGE_PREVIEW_IMAGE or GST_PREVIEW).
1356 *
1357 * @ingroup Emotion_Artwork
1358 */
1359
1360EAPI Evas_Object *emotion_file_meta_artwork_get(const Evas_Object *obj, const char *path, Emotion_Artwork_Info type);
1361/**
1344 * @} 1362 * @}
1345 */ 1363 */
1346 1364
diff --git a/src/lib/emotion/emotion_modules.c b/src/lib/emotion/emotion_modules.c
index 273bb9acc4..719b5d3e85 100644
--- a/src/lib/emotion/emotion_modules.c
+++ b/src/lib/emotion/emotion_modules.c
@@ -791,6 +791,12 @@ emotion_engine_instance_meta_get(const Emotion_Engine_Instance *inst, int meta)
791 EMOTION_ENGINE_INSTANCE_CALL_RET(inst, meta_get, NULL, meta); 791 EMOTION_ENGINE_INSTANCE_CALL_RET(inst, meta_get, NULL, meta);
792} 792}
793 793
794void *
795emotion_engine_instance_meta_artwork_get(const Emotion_Engine_Instance *inst, Evas_Object *img, const char *path, Emotion_Artwork_Info type)
796{
797 EMOTION_ENGINE_INSTANCE_CALL_RET(inst, meta_artwork_get, NULL, img, path, type);
798}
799
794void 800void
795emotion_engine_instance_priority_set(Emotion_Engine_Instance *inst, Eina_Bool priority) 801emotion_engine_instance_priority_set(Emotion_Engine_Instance *inst, Eina_Bool priority)
796{ 802{
diff --git a/src/lib/emotion/emotion_modules.h b/src/lib/emotion/emotion_modules.h
index eb9af156ea..4a0244177d 100644
--- a/src/lib/emotion/emotion_modules.h
+++ b/src/lib/emotion/emotion_modules.h
@@ -129,6 +129,7 @@ struct _Emotion_Engine
129 const char * (*meta_get) (void *ef, int meta); 129 const char * (*meta_get) (void *ef, int meta);
130 void (*priority_set) (void *ef, Eina_Bool priority); 130 void (*priority_set) (void *ef, Eina_Bool priority);
131 Eina_Bool (*priority_get) (void *ef); 131 Eina_Bool (*priority_get) (void *ef);
132 void * (*meta_artwork_get)(void *ef, Evas_Object *img, const char *path, Emotion_Artwork_Info type);
132}; 133};
133 134
134EAPI void *_emotion_video_get(const Evas_Object *obj); 135EAPI void *_emotion_video_get(const Evas_Object *obj);
diff --git a/src/lib/emotion/emotion_private.h b/src/lib/emotion/emotion_private.h
index cb66c6a628..e884dc3448 100644
--- a/src/lib/emotion/emotion_private.h
+++ b/src/lib/emotion/emotion_private.h
@@ -89,6 +89,5 @@ Eina_Bool emotion_engine_instance_eject(Emotion_Engine_Instance *inst);
89const char * emotion_engine_instance_meta_get(const Emotion_Engine_Instance *inst, int meta); 89const char * emotion_engine_instance_meta_get(const Emotion_Engine_Instance *inst, int meta);
90void emotion_engine_instance_priority_set(Emotion_Engine_Instance *inst, Eina_Bool priority); 90void emotion_engine_instance_priority_set(Emotion_Engine_Instance *inst, Eina_Bool priority);
91Eina_Bool emotion_engine_instance_priority_get(const Emotion_Engine_Instance *inst); 91Eina_Bool emotion_engine_instance_priority_get(const Emotion_Engine_Instance *inst);
92 92void * emotion_engine_instance_meta_artwork_get(const Emotion_Engine_Instance *inst, Evas_Object *img, const char *path, Emotion_Artwork_Info type);
93
94#endif 93#endif
diff --git a/src/lib/emotion/emotion_smart.c b/src/lib/emotion/emotion_smart.c
index 8ba69400b7..93cf1975ff 100644
--- a/src/lib/emotion/emotion_smart.c
+++ b/src/lib/emotion/emotion_smart.c
@@ -1262,6 +1262,26 @@ emotion_object_meta_info_get(const Evas_Object *obj, Emotion_Meta_Info meta)
1262 return emotion_engine_instance_meta_get(sd->engine_instance, id); 1262 return emotion_engine_instance_meta_get(sd->engine_instance, id);
1263} 1263}
1264 1264
1265
1266EAPI Evas_Object *
1267emotion_file_meta_artwork_get(const Evas_Object *obj, const char *path, Emotion_Artwork_Info type)
1268{
1269 Efl_Canvas_Video_Data *sd;
1270 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, NULL);
1271 if (!sd->engine_instance) return NULL;
1272
1273 Evas *ev = evas_object_evas_get(obj);
1274 Evas_Object *artwork = evas_object_image_add(ev);
1275
1276 Evas_Object *result = emotion_engine_instance_meta_artwork_get(sd->engine_instance, artwork, path, type);
1277 if (!result) return NULL;
1278
1279 Evas_Load_Error _error = evas_object_image_load_error_get(result);
1280 if (_error != EVAS_LOAD_ERROR_NONE) return NULL;
1281
1282 return result;
1283}
1284
1265EAPI void 1285EAPI void
1266emotion_object_vis_set(Evas_Object *obj, Emotion_Vis visualization) 1286emotion_object_vis_set(Evas_Object *obj, Emotion_Vis visualization)
1267{ 1287{
diff --git a/src/modules/emotion/generic/emotion_generic.c b/src/modules/emotion/generic/emotion_generic.c
index 9b43e87d0a..c3fba86a77 100644
--- a/src/modules/emotion/generic/emotion_generic.c
+++ b/src/modules/emotion/generic/emotion_generic.c
@@ -1721,7 +1721,8 @@ static const Emotion_Engine em_template_engine =
1721 em_eject, /* eject */ 1721 em_eject, /* eject */
1722 em_meta_get, /* meta_get */ 1722 em_meta_get, /* meta_get */
1723 NULL, /* priority_set */ 1723 NULL, /* priority_set */
1724 NULL /* priority_get */ 1724 NULL, /* priority_get */
1725 NULL /* em_meta_artwork_get */
1725}; 1726};
1726 1727
1727static void 1728static void
diff --git a/src/modules/emotion/gstreamer/emotion_gstreamer.c b/src/modules/emotion/gstreamer/emotion_gstreamer.c
index 82770b1590..3810401f53 100644
--- a/src/modules/emotion/gstreamer/emotion_gstreamer.c
+++ b/src/modules/emotion/gstreamer/emotion_gstreamer.c
@@ -1205,7 +1205,8 @@ static const Emotion_Engine em_engine =
1205 em_eject, /* eject */ 1205 em_eject, /* eject */
1206 em_meta_get, /* meta_get */ 1206 em_meta_get, /* meta_get */
1207 em_priority_set, /* priority_set */ 1207 em_priority_set, /* priority_set */
1208 em_priority_get /* priority_get */ 1208 em_priority_get, /* priority_get */
1209 NULL /* em_meta_artwork_get */
1209}; 1210};
1210 1211
1211Eina_Bool 1212Eina_Bool
diff --git a/src/modules/emotion/gstreamer1/emotion_gstreamer.c b/src/modules/emotion/gstreamer1/emotion_gstreamer.c
index bb528d4ca6..5fced21b03 100644
--- a/src/modules/emotion/gstreamer1/emotion_gstreamer.c
+++ b/src/modules/emotion/gstreamer1/emotion_gstreamer.c
@@ -1,7 +1,6 @@
1#ifdef HAVE_CONFIG_H 1#ifdef HAVE_CONFIG_H
2# include "config.h" 2# include "config.h"
3#endif 3#endif
4
5#include "emotion_gstreamer.h" 4#include "emotion_gstreamer.h"
6 5
7int _emotion_gstreamer_log_domain = -1; 6int _emotion_gstreamer_log_domain = -1;
@@ -988,6 +987,80 @@ em_eject(void *video EINA_UNUSED)
988 return 1; 987 return 1;
989} 988}
990 989
990static void
991_img_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
992{
993 GstBuffer *buffer = data;
994
995 gst_buffer_unref(buffer);
996}
997
998void *
999em_meta_artwork_get(void *video, Evas_Object *img, const char *path, Emotion_Artwork_Info type)
1000{
1001 Emotion_Gstreamer *ev = video;
1002 GError *err = NULL;
1003
1004 if (!ev) return NULL;
1005
1006 gst_init(NULL,NULL);
1007
1008 gchar *uri = gst_filename_to_uri(path, NULL);
1009
1010 GstDiscoverer *discoverer = gst_discoverer_new(10 * GST_SECOND, &err);
1011 if (!discoverer) return NULL;
1012 GstDiscovererInfo* info = gst_discoverer_discover_uri(discoverer,
1013 uri, &err);
1014 if (!info) return NULL;
1015
1016 int ret = gst_discoverer_info_get_result(info);
1017 if (ret != GST_DISCOVERER_OK) goto done;
1018
1019 const GstTagList *tags = gst_discoverer_info_get_tags(info);
1020
1021 GstSample *sample;
1022 GstBuffer *buffer;
1023 GstMapInfo map;
1024
1025 const gchar *tag = GST_TAG_PREVIEW_IMAGE;
1026 if (type == EMOTION_ARTWORK_IMAGE) tag = GST_TAG_IMAGE;
1027
1028 if (gst_tag_list_get_sample(tags, tag, &sample))
1029 {
1030 buffer = gst_sample_get_buffer(sample);
1031 if (!buffer)
1032 {
1033 evas_object_del(img);
1034 img = NULL;
1035 goto done;
1036 }
1037
1038 if (gst_buffer_map(gst_buffer_ref(buffer), &map, GST_MAP_READ))
1039 {
1040 Eina_File *f = eina_file_virtualize(path, map.data, map.size, EINA_FALSE);
1041 evas_object_image_mmap_set(img, f, NULL);
1042 eina_file_close(f);
1043 evas_object_event_callback_add(img, EVAS_CALLBACK_DEL, _img_del_cb, buffer);
1044 }
1045 gst_buffer_unref(buffer);
1046 gst_sample_unref(sample);
1047 }
1048 else
1049 {
1050 evas_object_del(img);
1051 img = NULL;
1052 }
1053
1054done:
1055 if (err) g_error_free(err);
1056
1057 gst_discoverer_info_unref(info);
1058 g_free(uri);
1059 g_object_unref(discoverer);
1060
1061 return img;
1062}
1063
991static const char * 1064static const char *
992em_meta_get(void *video, int meta) 1065em_meta_get(void *video, int meta)
993{ 1066{
@@ -1116,7 +1189,8 @@ static const Emotion_Engine em_engine =
1116 em_eject, /* eject */ 1189 em_eject, /* eject */
1117 em_meta_get, /* meta_get */ 1190 em_meta_get, /* meta_get */
1118 NULL, /* priority_set */ 1191 NULL, /* priority_set */
1119 NULL /* priority_get */ 1192 NULL, /* priority_get */
1193 em_meta_artwork_get,
1120}; 1194};
1121 1195
1122Eina_Bool 1196Eina_Bool
diff --git a/src/modules/emotion/gstreamer1/emotion_gstreamer.h b/src/modules/emotion/gstreamer1/emotion_gstreamer.h
index a815590d38..c0293dd11e 100644
--- a/src/modules/emotion/gstreamer1/emotion_gstreamer.h
+++ b/src/modules/emotion/gstreamer1/emotion_gstreamer.h
@@ -9,6 +9,7 @@
9#include <gst/video/navigation.h> 9#include <gst/video/navigation.h>
10#include <gst/audio/audio.h> 10#include <gst/audio/audio.h>
11#include <gst/tag/tag.h> 11#include <gst/tag/tag.h>
12#include <gst/pbutils/pbutils.h>
12 13
13#include <unistd.h> 14#include <unistd.h>
14#include <fcntl.h> 15#include <fcntl.h>
diff --git a/src/modules/emotion/libvlc/emotion_libvlc.c b/src/modules/emotion/libvlc/emotion_libvlc.c
index 31b47c9e5d..b78769382a 100644
--- a/src/modules/emotion/libvlc/emotion_libvlc.c
+++ b/src/modules/emotion/libvlc/emotion_libvlc.c
@@ -1382,7 +1382,8 @@ static const Emotion_Engine em_engine =
1382 em_eject, /* eject */ 1382 em_eject, /* eject */
1383 em_meta_get, /* meta_get */ 1383 em_meta_get, /* meta_get */
1384 NULL, /* priority_set */ 1384 NULL, /* priority_set */
1385 NULL /* priority_get */ 1385 NULL, /* priority_get */
1386 NULL /* em_meta_artwork_get */
1386}; 1387};
1387 1388
1388static void 1389static void
diff --git a/src/modules/emotion/xine/emotion_xine.c b/src/modules/emotion/xine/emotion_xine.c
index b0bca12c1a..852a564c42 100644
--- a/src/modules/emotion/xine/emotion_xine.c
+++ b/src/modules/emotion/xine/emotion_xine.c
@@ -1556,7 +1556,8 @@ static const Emotion_Engine em_engine =
1556 em_eject, /* eject */ 1556 em_eject, /* eject */
1557 em_meta_get, /* meta_get */ 1557 em_meta_get, /* meta_get */
1558 NULL, /* priority_set */ 1558 NULL, /* priority_set */
1559 NULL /* priority_get */ 1559 NULL, /* priority_get */
1560 NULL /* em_meta_artwork_get */
1560}; 1561};
1561 1562
1562Eina_Bool 1563Eina_Bool