Problem with porting playbin in a pipeline from Gst-0.10 to Gst1.0

Victor henri nadaeck at hotmail.com
Fri Oct 31 20:30:12 PDT 2014


Hello

I have use playbin2 with Gstreamer-0.10 for my app and it could read any kind of file.

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). 

Could please help me with this?

Thank you!

Victor

Here is the code for Gstreamer1.0 (when code for Gstreamer-0.10 is different, it is put after "//") :



#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <gst/gst.h>

#define AUDIOFREQ 44100

int main(int argc, char *argv[]){

    gst_init (NULL, NULL);
    GstElement *src, *audioconvert, *audioconvert2, *audioconvert3, *spectrum, *flacenc, *sink, *equalizer, *equalizer2, *equalizer3, *pipeline, *BP_BRfilter, *playbin;
    GstBus *bus;
    GstCaps *caps;
    GstPad *audiopad;
    GMainLoop *loop;
    float limit = 10000;

    loop = g_main_loop_new(NULL, FALSE);

    pipeline = gst_bin_new ("pipeline");
    g_assert (pipeline);
        
    
    playbin = gst_element_factory_make ("playbin", NULL);
    //GSTREAMER-0.10 : playbin = gst_element_factory_make ("playbin2", NULL);
    g_assert (playbin);
    g_object_set (G_OBJECT (playbin), "uri", "file:///home/victor/Music/main.wav", NULL);
            

        audioconvert = gst_element_factory_make ("audioconvert", NULL);
        g_assert (audioconvert);
        audioconvert2 = gst_element_factory_make ("audioconvert", NULL);
        g_assert (audioconvert2);
        audioconvert3 = gst_element_factory_make ("audioconvert", NULL);
        g_assert (audioconvert3);
        spectrum = gst_element_factory_make ("spectrum", "spectrum");
        g_assert (spectrum);    
        equalizer = gst_element_factory_make ("equalizer-nbands", "equalizer-nbands");
        g_assert (equalizer);
        equalizer2 = gst_element_factory_make ("equalizer-nbands", "equalizer-nbands2");
        g_assert (equalizer2);
        equalizer3 = gst_element_factory_make ("equalizer-nbands", "equalizer-nbands3");
        g_assert (equalizer3);
        BP_BRfilter = gst_element_factory_make ("audiochebband", NULL);
        g_assert (BP_BRfilter);
        g_object_set (G_OBJECT (BP_BRfilter), "upper-frequency", limit, NULL);
        flacenc = gst_element_factory_make ("flacenc", NULL);
        g_assert (flacenc);

        sink = gst_element_factory_make("autoaudiosink", "sink");
        g_assert (sink);

    gst_bin_add_many (GST_BIN (pipeline), audioconvert, equalizer, equalizer2, equalizer3, audioconvert2, BP_BRfilter, audioconvert3, spectrum, flacenc, sink, NULL);

    caps = gst_caps_new_simple ("audio/x-raw", "rate", G_TYPE_INT, AUDIOFREQ, NULL);
    //GSTREAMER-0.10 : caps = gst_caps_new_simple ("audio/x-raw-int", "rate", G_TYPE_INT, AUDIOFREQ, NULL);
    g_assert(caps);

    if (!gst_element_link (audioconvert, equalizer))
    //GSTREAMER-0.10 : if (!gst_element_link_filtered (audioconvert, equalizer, caps))
            {
                fprintf (stderr, "can't link elements 2\n");
                exit (1);
                }


    if (!gst_element_link_many (equalizer, equalizer2, equalizer3, audioconvert2, BP_BRfilter, audioconvert3, spectrum, sink, NULL)) {
                    fprintf (stderr, "can't link elements\n");
                    exit (1);
                    }

    audiopad = gst_element_get_static_pad (audioconvert, "sink");
    gst_element_add_pad (pipeline, gst_ghost_pad_new (NULL, audiopad));
    g_object_set(G_OBJECT(playbin), "audio-sink", pipeline, NULL);
    gst_object_unref (audiopad);

    gst_element_set_state (playbin, GST_STATE_PLAYING);
    g_main_loop_run (loop);

    gst_element_set_state (playbin, GST_STATE_NULL);

}


 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20141101/d10cc812/attachment.html>


More information about the gstreamer-devel mailing list