diff options
author | Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com> | 2018-01-07 05:46:07 +0900 |
---|---|---|
committer | Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com> | 2018-01-07 05:48:01 +0900 |
commit | c72c3355f7ebffe9d1b2ed91f31d95a427b5cf3f (patch) | |
tree | a9aebb7b216d499e2e885dea2508bfd09b313e12 | |
parent | d03590991d2c7104e7cd4b2a18e710008b2759ab (diff) |
[CES2018] Hack to display corver art of AACsandbox/ruke47/ces2018
Quick hack to support both GST_TAG_PREVIEW_IMAGE and GST_TAG_IMAGE
Change-Id: I43e33f64ef55af08304055223b1deb407c8b242d
Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
-rw-r--r-- | binding/afm-mediaplayer-binding.c | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c index 478ba0e..ef94a26 100644 --- a/binding/afm-mediaplayer-binding.c +++ b/binding/afm-mediaplayer-binding.c @@ -429,49 +429,34 @@ static void controls(struct afb_req request) static gchar *get_album_art(GstTagList *tags) { - GstSample *sample = NULL; - int num = gst_tag_list_get_tag_size(tags, GST_TAG_IMAGE); - guint i; + GstSample *sample; + gboolean have_sample; - for (i = 0; i < num ; i++) { - const GValue *value; - GstStructure *caps; - int type; + have_sample = gst_tag_list_get_sample(tags, GST_TAG_PREVIEW_IMAGE, &sample); + if (!have_sample) + have_sample = gst_tag_list_get_sample(tags, GST_TAG_IMAGE, &sample); - value = gst_tag_list_get_value_index(tags, GST_TAG_IMAGE, i); - if (value == NULL) - break; - - sample = gst_value_get_sample(value); - caps = gst_caps_get_structure(gst_sample_get_caps(sample), 0); - gst_structure_get_enum(caps, "image-type", - GST_TYPE_TAG_IMAGE_TYPE, &type); - - if (type == GST_TAG_IMAGE_TYPE_FRONT_COVER) - break; - } - - if (sample) { - GstBuffer *buffer = gst_sample_get_buffer(sample); - GstMapInfo map; - gchar *data, *mime_type, *image; + if (have_sample) { + GstBuffer *buffer = gst_sample_get_buffer(sample); + GstMapInfo map; + gchar *data, *mime_type, *image; - if (!gst_buffer_map (buffer, &map, GST_MAP_READ)) - return NULL; + if (!gst_buffer_map (buffer, &map, GST_MAP_READ)) + return NULL; - image = g_base64_encode(map.data, map.size); - mime_type = g_content_type_guess(NULL, map.data, map.size, NULL); + image = g_base64_encode(map.data, map.size); + mime_type = g_content_type_guess(NULL, map.data, map.size, NULL); - data = g_strconcat("data:", mime_type, ";base64,", image, NULL); + data = g_strconcat("data:", mime_type, ";base64,", image, NULL); - g_free(image); - g_free(mime_type); - gst_buffer_unmap(buffer, &map); + g_free(image); + g_free(mime_type); + gst_buffer_unmap(buffer, &map); - return data; - } + return data; + } - return NULL; + return NULL; } static void metadata(struct afb_req request) |