- 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;
- }
-
- /* check media type */
- caps = gst_pad_get_caps (pad);
- str = gst_caps_get_structure (caps, 0);
- eDebug("gst new pad! %s", gst_structure_get_name (str));
-
- if (!g_strrstr (gst_structure_get_name (str), "audio")) {
- gst_caps_unref (caps);
- gst_object_unref (audiopad);
- return;
- }
-
- gst_caps_unref (caps);
- gst_pad_link (pad, audiopad);
-}
-
-void eServiceMP3::gstCBunknownType(GstElement *decodebin, GstPad *pad, GstCaps *caps, gpointer user_data)
-{
- GstStructure *str;
-
- /* check media type */
- caps = gst_pad_get_caps (pad);
- str = gst_caps_get_structure (caps, 0);
- eDebug("unknown type: %s - this can't be decoded.", gst_structure_get_name (str));
- gst_caps_unref (caps);