<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hello<br><br>I have use playbin2 with Gstreamer-0.10 for my app and it could read any kind of file.<br><br>I want to port it to Gstreamer1.0. I have made some adjustments, as I could find from the doc. It can read only wave files now, but not .flac or .mp3 files! I have every possible plugins installed (I think). <br><br>Could please help me with this?<br><br>Thank you!<br><br>Victor<br><br>Here is the code for Gstreamer1.0 (when code for Gstreamer-0.10 is different, it is put after "//") :<br><br><br><br>#include <stdlib.h><br>#include <stdio.h><br>#include <string.h><br>#include <gst/gst.h><br><br>#define AUDIOFREQ 44100<br><br>int main(int argc, char *argv[]){<br><br> gst_init (NULL, NULL);<br> GstElement *src, *audioconvert, *audioconvert2, *audioconvert3, *spectrum, *flacenc, *sink, *equalizer, *equalizer2, *equalizer3, *pipeline, *BP_BRfilter, *playbin;<br> GstBus *bus;<br> GstCaps *caps;<br> GstPad *audiopad;<br> GMainLoop *loop;<br> float limit = 10000;<br><br> loop = g_main_loop_new(NULL, FALSE);<br><br> pipeline = gst_bin_new ("pipeline");<br> g_assert (pipeline);<br> <br> <br> playbin = gst_element_factory_make ("playbin", NULL);<br> //GSTREAMER-0.10 : playbin = gst_element_factory_make ("playbin2", NULL);<br> g_assert (playbin);<br> g_object_set (G_OBJECT (playbin), "uri", "file:///home/victor/Music/main.wav", NULL);<br> <br><br> audioconvert = gst_element_factory_make ("audioconvert", NULL);<br> g_assert (audioconvert);<br> audioconvert2 = gst_element_factory_make ("audioconvert", NULL);<br> g_assert (audioconvert2);<br> audioconvert3 = gst_element_factory_make ("audioconvert", NULL);<br> g_assert (audioconvert3);<br> spectrum = gst_element_factory_make ("spectrum", "spectrum");<br> g_assert (spectrum); <br> equalizer = gst_element_factory_make ("equalizer-nbands", "equalizer-nbands");<br> g_assert (equalizer);<br> equalizer2 = gst_element_factory_make ("equalizer-nbands", "equalizer-nbands2");<br> g_assert (equalizer2);<br> equalizer3 = gst_element_factory_make ("equalizer-nbands", "equalizer-nbands3");<br> g_assert (equalizer3);<br> BP_BRfilter = gst_element_factory_make ("audiochebband", NULL);<br> g_assert (BP_BRfilter);<br> g_object_set (G_OBJECT (BP_BRfilter), "upper-frequency", limit, NULL);<br> flacenc = gst_element_factory_make ("flacenc", NULL);<br> g_assert (flacenc);<br><br> sink = gst_element_factory_make("autoaudiosink", "sink");<br> g_assert (sink);<br><br> gst_bin_add_many (GST_BIN (pipeline), audioconvert, equalizer, equalizer2, equalizer3, audioconvert2, BP_BRfilter, audioconvert3, spectrum, flacenc, sink, NULL);<br><br> caps = gst_caps_new_simple ("audio/x-raw", "rate", G_TYPE_INT, AUDIOFREQ, NULL);<br> //GSTREAMER-0.10 : caps = gst_caps_new_simple ("audio/x-raw-int", "rate", G_TYPE_INT, AUDIOFREQ, NULL);<br> g_assert(caps);<br><br> if (!gst_element_link (audioconvert, equalizer))<br> //GSTREAMER-0.10 : if (!gst_element_link_filtered (audioconvert, equalizer, caps))<br> {<br> fprintf (stderr, "can't link elements 2\n");<br> exit (1);<br> }<br><br><br> if (!gst_element_link_many (equalizer, equalizer2, equalizer3, audioconvert2, BP_BRfilter, audioconvert3, spectrum, sink, NULL)) {<br> fprintf (stderr, "can't link elements\n");<br> exit (1);<br> }<br><br> audiopad = gst_element_get_static_pad (audioconvert, "sink");<br> gst_element_add_pad (pipeline, gst_ghost_pad_new (NULL, audiopad));<br> g_object_set(G_OBJECT(playbin), "audio-sink", pipeline, NULL);<br> gst_object_unref (audiopad);<br><br> gst_element_set_state (playbin, GST_STATE_PLAYING);<br> g_main_loop_run (loop);<br><br> gst_element_set_state (playbin, GST_STATE_NULL);<br><br>}<br><br><br> </div></body>
</html>