+
+void eServiceMP3::gstCBsubtitleAvail(GstElement *element, GstBuffer *buffer, GstPad *pad, gpointer user_data)
+{
+ const unsigned char *text = (unsigned char *)GST_BUFFER_DATA(buffer);
+ eDebug("gstCBsubtitleAvail: %s",text);
+ eServiceMP3 *_this = (eServiceMP3*)user_data;
+ if ( _this->m_subtitle_widget )
+ {
+ eDVBTeletextSubtitlePage page;
+ gRGB rgbcol(0xD0,0xD0,0xD0);
+ page.m_elements.push_back(eDVBTeletextSubtitlePageElement(rgbcol, (const char*)text));
+ (_this->m_subtitle_widget)->setPage(page);
+ }
+}
+
+RESULT eServiceMP3::enableSubtitles(eWidget *parent, ePyObject tuple)
+{
+ eDebug("eServiceMP3::enableSubtitles");
+
+ ePyObject entry;
+ int tuplesize = PyTuple_Size(tuple);
+ int pid;
+ gint nb_sources;
+ GstPad *active_pad;
+ GstElement *switch_subtitles = gst_bin_get_by_name(GST_BIN(m_gst_pipeline),"switch_subtitles");
+
+ if (!PyTuple_Check(tuple))
+ goto error_out;
+ if (tuplesize < 1)
+ goto error_out;
+ entry = PyTuple_GET_ITEM(tuple, 1);
+ if (!PyInt_Check(entry))
+ goto error_out;
+ pid = PyInt_AsLong(entry);
+
+ m_subtitle_widget = new eSubtitleWidget(parent);
+ m_subtitle_widget->resize(parent->size()); /* full size */
+
+ if ( !switch_subtitles )
+ {
+ eDebug("can't switch subtitle tracks! gst-plugin-selector needed");
+ return -2;
+ }
+ g_object_get (G_OBJECT (switch_subtitles), "n-pads", &nb_sources, NULL);
+ if ( (unsigned int)pid >= m_subtitleStreams.size() || pid >= nb_sources || (unsigned int)m_currentSubtitleStream >= m_subtitleStreams.size() )
+ return -2;
+ char sinkpad[8];
+ sprintf(sinkpad, "sink%d", pid);
+ g_object_set (G_OBJECT (switch_subtitles), "active-pad", gst_element_get_pad (switch_subtitles, sinkpad), NULL);
+ g_object_get (G_OBJECT (switch_subtitles), "active-pad", &active_pad, NULL);
+ gchar *name;
+ name = gst_pad_get_name (active_pad);
+ eDebug ("switched subtitles to (%s)", name);
+ g_free(name);
+ m_currentSubtitleStream = pid;
+
+ return 0;
+error_out:
+ eDebug("enableSubtitles needs a tuple as 2nd argument!\n"
+ "for gst subtitles (2, subtitle_stream_count)");
+ return -1;
+}
+
+RESULT eServiceMP3::disableSubtitles(eWidget *parent)
+{
+ eDebug("eServiceMP3::disableSubtitles");
+ delete m_subtitle_widget;
+ m_subtitle_widget = 0;
+ return 0;
+}
+
+PyObject *eServiceMP3::getCachedSubtitle()
+{
+ eDebug("eServiceMP3::getCachedSubtitle");
+ Py_RETURN_NONE;
+}
+
+PyObject *eServiceMP3::getSubtitleList()
+{
+ eDebug("eServiceMP3::getSubtitleList");
+
+ ePyObject l = PyList_New(0);
+ int stream_count = 0;
+
+ for (std::vector<subtitleStream>::iterator IterSubtitleStream(m_subtitleStreams.begin()); IterSubtitleStream != m_subtitleStreams.end(); ++IterSubtitleStream)
+ {
+ ePyObject tuple = PyTuple_New(5);
+ PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(2));
+ PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(stream_count));
+ PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(0));
+ PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(0));
+ PyTuple_SET_ITEM(tuple, 4, PyString_FromString((IterSubtitleStream->language_code).c_str()));
+ PyList_Append(l, tuple);
+ Py_DECREF(tuple);
+ stream_count++;
+ }
+
+ return l;
+}
+