- else
- {
- eDebug("mime %s", type);
- if (!strcmp(type, "audio/x-ac3") || !strcmp(type, "audio/ac3"))
- return atAC3;
- else if (!strcmp(type, "audio/x-dts") || !strcmp(type, "audio/dts"))
- return atDTS;
- else if (!strcmp(type, "audio/x-raw-int"))
- return atPCM;
- }
- return atUnknown;
-}
-
-void eServiceMP3::gstCBpadAdded(GstElement *decodebin, GstPad *pad, gpointer user_data)
-{
- const gchar* type;
- GstCaps* caps;
- GstStructure* str;
- caps = gst_pad_get_caps(pad);
- str = gst_caps_get_structure(caps, 0);
- type = gst_structure_get_name(str);
-
- eDebug("A new pad %s:%s was created", GST_OBJECT_NAME (decodebin), GST_OBJECT_NAME (pad));
-
- eServiceMP3 *_this = (eServiceMP3*)user_data;
- GstBin *pipeline = GST_BIN(_this->m_gst_pipeline);
- if (g_strrstr(type,"audio"))
- {
- audioStream audio;
- audio.type = _this->gstCheckAudioPad(str);
- GstElement *switch_audio = gst_bin_get_by_name(pipeline , "switch_audio");
- if ( switch_audio )
- {
- GstPad *sinkpad = gst_element_get_request_pad (switch_audio, "sink%d");
- gst_pad_link(pad, sinkpad);
- audio.pad = sinkpad;
- _this->m_audioStreams.push_back(audio);
-
- if ( _this->m_audioStreams.size() == 1 )
- {
- _this->selectAudioStream(0);
- gst_element_set_state (_this->m_gst_pipeline, GST_STATE_PLAYING);
- }
- else
- g_object_set (G_OBJECT (switch_audio), "select-all", FALSE, NULL);
- }
- else
- {
- gst_pad_link(pad, gst_element_get_static_pad(gst_bin_get_by_name(pipeline,"queue_audio"), "sink"));
- _this->m_audioStreams.push_back(audio);
- }
- }
- if (g_strrstr(type,"video"))
- {
- gst_pad_link(pad, gst_element_get_static_pad(gst_bin_get_by_name(pipeline,"queue_video"), "sink"));
- }
- if (g_strrstr(type,"application/x-ssa") || g_strrstr(type,"application/x-ass"))
- {
- GstElement *switch_subtitles = gst_bin_get_by_name(pipeline,"switch_subtitles");
- if ( !switch_subtitles )
- {
- switch_subtitles = gst_element_factory_make ("input-selector", "switch_subtitles");
- if ( !switch_subtitles )
- return;
- GstElement *parser = gst_element_factory_make("ssaparse", "parse_subtitles");
- GstElement *sink = gst_element_factory_make("fakesink", "sink_subtitles");
- gst_bin_add_many(pipeline, switch_subtitles, parser, sink, NULL);
- gst_element_link(switch_subtitles, parser);
- gst_element_link(parser, sink);
- g_object_set (G_OBJECT(sink), "signal-handoffs", TRUE, NULL);
- g_signal_connect(sink, "handoff", G_CALLBACK(gstCBsubtitleAvail), _this);
- }
- GstPad *sinkpad = gst_element_get_request_pad (switch_subtitles, "sink%d");
- gst_pad_link(pad, sinkpad);
- subtitleStream subs;
- subs.pad = sinkpad;
- _this->m_subtitleStreams.push_back(subs);
- }
-}
-
-void eServiceMP3::gstCBfilterPadAdded(GstElement *filter, GstPad *pad, gpointer user_data)
-{
- eServiceMP3 *_this = (eServiceMP3*)user_data;
- GstElement *decoder = gst_bin_get_by_name(GST_BIN(_this->m_gst_pipeline),"decoder");
- gst_pad_link(pad, gst_element_get_static_pad (decoder, "sink"));
-}
-
-void eServiceMP3::gstCBnewPad(GstElement *decodebin, GstPad *pad, gboolean last, gpointer user_data)
-{
- eServiceMP3 *_this = (eServiceMP3*)user_data;
- GstCaps *caps;
- GstStructure *str;
- GstPad *audiopad;
-
- /* only link once */
- GstElement *audiobin = gst_bin_get_by_name(GST_BIN(_this->m_gst_pipeline),"audiobin");
- audiopad = gst_element_get_static_pad (audiobin, "sink");
- if ( !audiopad || GST_PAD_IS_LINKED (audiopad)) {
- eDebug("audio already linked!");
- g_object_unref (audiopad);
- return;