+ case GST_MESSAGE_INFO:
+ {
+ gchar *debug;
+ GError *inf;
+
+ gst_message_parse_info (msg, &inf, &debug);
+ g_free (debug);
+ if ( inf->domain == GST_STREAM_ERROR && inf->code == GST_STREAM_ERROR_DECODE )
+ {
+ if ( g_strrstr(sourceName, "videosink") )
+ m_event((iPlayableService*)this, evUser+14);
+ }
+ g_error_free(inf);
+ break;
+ }
+ case GST_MESSAGE_TAG:
+ {
+ GstTagList *tags, *result;
+ gst_message_parse_tag(msg, &tags);
+
+ result = gst_tag_list_merge(m_stream_tags, tags, GST_TAG_MERGE_REPLACE);
+ if (result)
+ {
+ if (m_stream_tags)
+ gst_tag_list_free(m_stream_tags);
+ m_stream_tags = result;
+ }
+
+ 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);
+ int ret = write(fd, GST_BUFFER_DATA(buf_image), GST_BUFFER_SIZE(buf_image));
+ close(fd);
+ eDebug("eServiceMP3::/tmp/.id3coverart %d bytes written ", ret);
+ m_event((iPlayableService*)this, evUser+13);
+ }
+ gst_tag_list_free(tags);
+ m_event((iPlayableService*)this, evUpdatedInfo);
+ break;
+ }
+ case GST_MESSAGE_ASYNC_DONE:
+ {
+ if(GST_MESSAGE_SRC(msg) != GST_OBJECT(m_gst_playbin))
+ break;
+
+ GstTagList *tags;
+ gint i, active_idx, n_video = 0, n_audio = 0, n_text = 0;
+
+ g_object_get (m_gst_playbin, "n-video", &n_video, NULL);
+ g_object_get (m_gst_playbin, "n-audio", &n_audio, NULL);
+ g_object_get (m_gst_playbin, "n-text", &n_text, NULL);
+
+ eDebug("eServiceMP3::async-done - %d video, %d audio, %d subtitle", n_video, n_audio, n_text);
+
+ if ( n_video + n_audio <= 0 )
+ stop();
+
+ active_idx = 0;
+
+ m_audioStreams.clear();
+ m_subtitleStreams.clear();
+
+ for (i = 0; i < n_audio; i++)
+ {
+ audioStream audio;
+ gchar *g_codec, *g_lang;
+ GstPad* pad = 0;
+ g_signal_emit_by_name (m_gst_playbin, "get-audio-pad", i, &pad);
+ GstCaps* caps = gst_pad_get_negotiated_caps(pad);
+ if (!caps)
+ continue;
+ GstStructure* str = gst_caps_get_structure(caps, 0);
+ const gchar *g_type = gst_structure_get_name(str);
+ eDebug("AUDIO STRUCT=%s", g_type);
+ audio.type = gstCheckAudioPad(str);
+ g_codec = g_strdup(g_type);
+ g_lang = g_strdup_printf ("und");
+ g_signal_emit_by_name (m_gst_playbin, "get-audio-tags", i, &tags);
+ if ( tags && gst_is_tag_list(tags) )
+ {
+ gst_tag_list_get_string(tags, GST_TAG_AUDIO_CODEC, &g_codec);
+ gst_tag_list_get_string(tags, GST_TAG_LANGUAGE_CODE, &g_lang);
+ gst_tag_list_free(tags);
+ }
+ audio.language_code = std::string(g_lang);
+ audio.codec = std::string(g_codec);
+ eDebug("eServiceMP3::audio stream=%i codec=%s language=%s", i, g_codec, g_lang);
+ m_audioStreams.push_back(audio);
+ g_free (g_lang);
+ g_free (g_codec);
+ gst_caps_unref(caps);
+ }
+
+ for (i = 0; i < n_text; i++)
+ {
+ gchar *g_lang;
+// gchar *g_type;
+// GstPad* pad = 0;
+// g_signal_emit_by_name (m_gst_playbin, "get-text-pad", i, &pad);
+// GstCaps* caps = gst_pad_get_negotiated_caps(pad);
+// GstStructure* str = gst_caps_get_structure(caps, 0);
+// g_type = gst_structure_get_name(str);
+// g_signal_emit_by_name (m_gst_playbin, "get-text-tags", i, &tags);
+ subtitleStream subs;
+ subs.type = stPlainText;
+ g_lang = g_strdup_printf ("und");
+ if ( tags && gst_is_tag_list(tags) )
+ gst_tag_list_get_string(tags, GST_TAG_LANGUAGE_CODE, &g_lang);
+ subs.language_code = std::string(g_lang);
+ eDebug("eServiceMP3::subtitle stream=%i language=%s"/* type=%s*/, i, g_lang/*, g_type*/);
+ m_subtitleStreams.push_back(subs);
+ g_free (g_lang);
+// g_free (g_type);
+ }
+ m_event((iPlayableService*)this, evUpdatedEventInfo);
+ }
+ case GST_MESSAGE_ELEMENT:
+ {
+ if ( gst_is_missing_plugin_message(msg) )
+ {
+ gchar *description = gst_missing_plugin_message_get_description(msg);
+ if ( description )
+ {
+ m_error_message = "GStreamer plugin " + (std::string)description + " not available!\n";
+ g_free(description);
+ m_event((iPlayableService*)this, evUser+12);
+ }
+ }
+ else if (const GstStructure *msgstruct = gst_message_get_structure(msg))
+ {
+ const gchar *eventname = gst_structure_get_name(msgstruct);
+ if ( eventname )
+ {
+ if (!strcmp(eventname, "eventSizeChanged") || !strcmp(eventname, "eventSizeAvail"))
+ {
+ gst_structure_get_int (msgstruct, "aspect_ratio", &m_aspect);
+ gst_structure_get_int (msgstruct, "width", &m_width);
+ gst_structure_get_int (msgstruct, "height", &m_height);
+ if (strstr(eventname, "Changed"))
+ m_event((iPlayableService*)this, evVideoSizeChanged);
+ }
+ else if (!strcmp(eventname, "eventFrameRateChanged") || !strcmp(eventname, "eventFrameRateAvail"))
+ {
+ gst_structure_get_int (msgstruct, "frame_rate", &m_framerate);
+ if (strstr(eventname, "Changed"))
+ m_event((iPlayableService*)this, evVideoFramerateChanged);
+ }
+ else if (!strcmp(eventname, "eventProgressiveChanged") || !strcmp(eventname, "eventProgressiveAvail"))
+ {
+ gst_structure_get_int (msgstruct, "progressive", &m_progressive);
+ if (strstr(eventname, "Changed"))
+ m_event((iPlayableService*)this, evVideoProgressiveChanged);
+ }
+ }
+ }
+ break;
+ }
+ case GST_MESSAGE_BUFFERING:
+ {
+ GstBufferingMode mode;
+ gst_message_parse_buffering(msg, &(m_bufferInfo.bufferPercent));
+ gst_message_parse_buffering_stats(msg, &mode, &(m_bufferInfo.avgInRate), &(m_bufferInfo.avgOutRate), &(m_bufferInfo.bufferingLeft));
+ m_event((iPlayableService*)this, evBuffering);
+ }
+ default:
+ break;