- GstBuffer *buf_image;
- buf_image = gst_value_get_buffer (gv_image);
- int fd = open("/tmp/.id3coverart", O_CREAT|O_WRONLY|O_TRUNC, 0644);
- int ret = write(fd, GST_BUFFER_DATA(buf_image), GST_BUFFER_SIZE(buf_image));
- close(fd);
- m_event((iPlayableService*)this, evUser+13);
+ GstTagList *tags, *result;
+ gst_message_parse_tag(msg, &tags);
+
+ result = gst_tag_list_merge(m_stream_tags, tags, GST_TAG_MERGE_PREPEND);
+ if (result)
+ {
+ if (m_stream_tags)
+ gst_tag_list_free(m_stream_tags);
+ m_stream_tags = result;
+ }
+
+ gchar *g_audiocodec;
+ if ( gst_tag_list_get_string(tags, GST_TAG_AUDIO_CODEC, &g_audiocodec) && m_audioStreams.size() == 0 )
+ {
+ GstPad* pad = gst_element_get_pad (GST_ELEMENT(source), "src");
+ GstCaps* caps = gst_pad_get_caps(pad);
+ GstStructure* str = gst_caps_get_structure(caps, 0);
+ if ( !str )
+ break;
+ audioStream audio;
+ audio.type = gstCheckAudioPad(str);
+ m_audioStreams.push_back(audio);
+ }
+
+ const GValue *gv_image = gst_tag_list_get_value_index(tags, GST_TAG_IMAGE, 0);
+ if ( gv_image )
+ {
+ GstBuffer *buf_image;
+ buf_image = gst_value_get_buffer (gv_image);
+ int fd = open("/tmp/.id3coverart", O_CREAT|O_WRONLY|O_TRUNC, 0644);
+ write(fd, GST_BUFFER_DATA(buf_image), GST_BUFFER_SIZE(buf_image));
+ close(fd);
+ m_event((iPlayableService*)this, evUser+13);
+ }
+
+ gst_tag_list_free(tags);
+ m_event((iPlayableService*)this, evUpdatedInfo);
+ break;