+GstCaps* eServiceMP3::gstGhostpadGetCAPS (GstPad * pad)
+{
+ eDebug("eServiceMP3::gstGhostpadGetCAPS");
+ return gst_static_pad_template_get_caps(&subsinktemplate);
+// return gst_pad_get_pad_template_caps(pad);
+// return get_pad_template_caps(pad);
+// GstCaps* caps = gst_caps_from_string("text/plain; text/x-pango-markup; video/x-dvd-subpicture");
+// return caps;
+}
+
+void eServiceMP3::gstCBsubtitleCAPS(GObject *obj, GParamSpec *pspec, gpointer user_data)
+{
+ eDebug("gstCBsubtitleCAPS:: signal::caps callback obj=%p", obj);
+
+ eServiceMP3 *_this = (eServiceMP3*)user_data;
+ eDebug("gstCBsubtitleCAPS:: m_currentSubtitleStream=%i, m_subtitleStreams.size()=%i", _this->m_currentSubtitleStream, _this->m_subtitleStreams.size());
+
+ if ( _this->m_currentSubtitleStream >= (int)_this->m_subtitleStreams.size() )
+ {
+ eDebug("return invalid stream count");
+ return;
+ }
+
+ subtitleStream subs = _this->m_subtitleStreams[_this->m_currentSubtitleStream];
+
+ if ( subs.type == stUnknown )
+ {
+ GstTagList *tags;
+ eDebug("gstCBsubtitleCAPS::m_subtitleStreams[%i].type == stUnknown...", _this->m_currentSubtitleStream);
+
+ gchar *g_lang;
+ g_signal_emit_by_name (_this->m_gst_playbin, "get-text-tags", _this->m_currentSubtitleStream, &tags);
+
+ 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);
+
+ subs.type = getSubtitleType(GST_PAD(obj));
+
+ _this->m_subtitleStreams[_this->m_currentSubtitleStream] = subs;
+
+ g_free (g_lang);
+ }
+
+ gstCBsubtitleLink(subs.type, _this);
+}
+
+void eServiceMP3::gstCBsubtitleLink(subtype_t type, gpointer user_data)
+{
+ eServiceMP3 *_this = (eServiceMP3*)user_data;
+
+ if ( type == stVOB )
+ {
+ GstPad *ghostpad = gst_element_get_static_pad(_this->m_gst_subtitlebin, "sink");
+ GstElement *dvdsubdec = gst_bin_get_by_name(GST_BIN(_this->m_gst_subtitlebin), "vobsubtitle_decoder");
+ GstPad *subdecsinkpad = gst_element_get_static_pad (dvdsubdec, "sink");
+ int ret = gst_ghost_pad_set_target((GstGhostPad*)ghostpad, subdecsinkpad);
+ GstElement *appsink = gst_bin_get_by_name(GST_BIN(_this->m_gst_subtitlebin), "subtitle_sink");
+ ret += gst_element_link(dvdsubdec, appsink);
+ eDebug("gstCBsubtitleLink:: dvdsubdec=%p, subdecsinkpad=%p, ghostpad=%p, set target & link=%i", dvdsubdec, subdecsinkpad, ghostpad, ret);
+ }
+ else if ( type < stVOB && type > stUnknown )
+ {
+ GstPad *ghostpad = gst_element_get_static_pad(_this->m_gst_subtitlebin, "sink");
+ GstElement *appsink = gst_bin_get_by_name(GST_BIN(_this->m_gst_subtitlebin), "subtitle_sink");
+ GstPad *appsinkpad = gst_element_get_static_pad (appsink, "sink");
+ GstElement *dvdsubdec = gst_bin_get_by_name(GST_BIN(_this->m_gst_subtitlebin), "vobsubtitle_decoder");
+ gst_element_unlink(dvdsubdec, appsink);
+ int ret = gst_ghost_pad_set_target((GstGhostPad*)ghostpad, appsinkpad);
+ eDebug("gstCBsubtitleLink:: appsink=%p, appsinkpad=%p, ghostpad=%p, set target=%i", appsink, appsinkpad, ghostpad, ret);
+ }
+ else
+ {
+ eDebug("gstCBsubtitleLink:: unsupported subtitles");
+ }
+}
+
+gboolean eServiceMP3::gstCBsubtitleDrop(GstPad *pad, GstBuffer *buffer, gpointer user_data)
+{
+ eDebug("gstCBsubtitleDrop");
+
+ gint64 buf_pos = GST_BUFFER_TIMESTAMP(buffer);
+ gint64 duration_ns = GST_BUFFER_DURATION(buffer);
+ size_t len = GST_BUFFER_SIZE(buffer);
+
+ unsigned char line[len+1];
+ memcpy(line, GST_BUFFER_DATA(buffer), len);
+ line[len] = 0;
+ eDebug("dropping buffer '%s' ", line);
+ return false;
+}
+
+