+GstPad* eServiceMP3::gstCreateSubtitleSink(eServiceMP3* _this, subtype_t type)
+{
+ GstBin *pipeline = GST_BIN(_this->m_gst_pipeline);
+ GstElement *switch_subparse = gst_bin_get_by_name(pipeline,"switch_subparse");
+ if ( !switch_subparse )
+ {
+ switch_subparse = gst_element_factory_make ("input-selector", "switch_subparse");
+ GstElement *sink = gst_element_factory_make("fakesink", "sink_subtitles");
+ gst_bin_add_many(pipeline, switch_subparse, sink, NULL);
+ gst_element_link(switch_subparse, sink);
+ g_object_set (G_OBJECT(sink), "signal-handoffs", TRUE, NULL);
+ g_object_set (G_OBJECT(sink), "sync", TRUE, NULL);
+ g_object_set (G_OBJECT(sink), "async", FALSE, NULL);
+ g_signal_connect(sink, "handoff", G_CALLBACK(_this->gstCBsubtitleAvail), _this);
+
+ // order is essential since requested sink pad names can't be explicitely chosen
+ GstElement *switch_substream_plain = gst_element_factory_make ("input-selector", "switch_substream_plain");
+ gst_bin_add(pipeline, switch_substream_plain);
+ GstPad *sinkpad_plain = gst_element_get_request_pad (switch_subparse, "sink%d");
+ gst_pad_link(gst_element_get_pad (switch_substream_plain, "src"), sinkpad_plain);
+
+ GstElement *switch_substream_ssa = gst_element_factory_make ("input-selector", "switch_substream_ssa");
+ GstElement *ssaparse = gst_element_factory_make("ssaparse", "ssaparse");
+ gst_bin_add_many(pipeline, switch_substream_ssa, ssaparse, NULL);
+ GstPad *sinkpad_ssa = gst_element_get_request_pad (switch_subparse, "sink%d");
+ gst_element_link(switch_substream_ssa, ssaparse);
+ gst_pad_link(gst_element_get_pad (ssaparse, "src"), sinkpad_ssa);
+
+ GstElement *switch_substream_srt = gst_element_factory_make ("input-selector", "switch_substream_srt");
+ GstElement *srtparse = gst_element_factory_make("subparse", "srtparse");
+ gst_bin_add_many(pipeline, switch_substream_srt, srtparse, NULL);
+ GstPad *sinkpad_srt = gst_element_get_request_pad (switch_subparse, "sink%d");
+ gst_element_link(switch_substream_srt, srtparse);
+ gst_pad_link(gst_element_get_pad (srtparse, "src"), sinkpad_srt);
+ g_object_set (G_OBJECT(srtparse), "subtitle-encoding", "ISO-8859-15", NULL);
+ }
+
+ switch (type)
+ {
+ case stSSA:
+ return gst_element_get_request_pad (gst_bin_get_by_name(pipeline,"switch_substream_ssa"), "sink%d");
+ case stSRT:
+ return gst_element_get_request_pad (gst_bin_get_by_name(pipeline,"switch_substream_srt"), "sink%d");
+ case stPlainText:
+ default:
+ break;
+ }
+ return gst_element_get_request_pad (gst_bin_get_by_name(pipeline,"switch_substream_plain"), "sink%d");
+}
+