+ eDebug("SERVICEMP3 construct!");
+
+ m_gst_pipeline = gst_pipeline_new ("audio-player");
+ if (!m_gst_pipeline)
+ eWarning("failed to create pipeline");
+
+ source = gst_element_factory_make ("filesrc", "file-source");
+ if (!source)
+ eWarning("failed to create filesrc");
+
+ decoder = gst_element_factory_make ("decodebin", "decoder");
+ if (!decoder)
+ eWarning("failed to create decodebin decoder");
+
+ conv = gst_element_factory_make ("audioconvert", "converter");
+ if (!conv)
+ eWarning("failed to create audioconvert");
+
+ flt = gst_element_factory_make ("capsfilter", "flt");
+ if (!flt)
+ eWarning("failed to create capsfilter");
+
+ /* workaround for [3des]' driver bugs: */
+ if (flt)
+ {
+ GstCaps *caps = gst_caps_new_simple("audio/x-raw-int", "endianness", G_TYPE_INT, 4321, 0);
+ g_object_set (G_OBJECT (flt), "caps", caps, 0);
+ gst_caps_unref(caps);
+ }
+
+ sink = gst_element_factory_make ("alsasink", "alsa-output");
+ if (!sink)
+ eWarning("failed to create osssink");
+
+ if (m_gst_pipeline && source && decoder && conv && sink)
+ {
+ gst_bus_set_sync_handler(gst_pipeline_get_bus (GST_PIPELINE (m_gst_pipeline)), gstBusSyncHandler, this);
+
+ g_object_set (G_OBJECT (source), "location", filename, NULL);
+ g_signal_connect (decoder, "new-decoded-pad", G_CALLBACK(gstCBnewPad), this);
+
+ /* gst_bin will take the 'floating references' */
+ gst_bin_add_many (GST_BIN (m_gst_pipeline),
+ source, decoder, NULL);
+
+ gst_element_link(source, decoder);
+
+ /* create audio bin */
+ m_gst_audio = gst_bin_new ("audiobin");
+ GstPad *audiopad = gst_element_get_pad (conv, "sink");
+
+ gst_bin_add_many(GST_BIN(m_gst_audio), conv, flt, sink, 0);
+ gst_element_link_many(conv, flt, sink, 0);
+ gst_element_add_pad(m_gst_audio, gst_ghost_pad_new ("sink", audiopad));
+ gst_object_unref(audiopad);
+
+ gst_bin_add (GST_BIN(m_gst_pipeline), m_gst_audio);
+ } else
+ {
+ if (m_gst_pipeline)
+ gst_object_unref(GST_OBJECT(m_gst_pipeline));
+ if (source)
+ gst_object_unref(GST_OBJECT(source));
+ if (decoder)
+ gst_object_unref(GST_OBJECT(decoder));
+ if (conv)
+ gst_object_unref(GST_OBJECT(conv));
+ if (sink)
+ gst_object_unref(GST_OBJECT(sink));
+ eDebug("sorry, can't play.");
+ }
+
+ gst_element_set_state (m_gst_pipeline, GST_STATE_PLAYING);