[vala] oggdemux and dynamic pads

hasardel emmanuel.pouthier at gmail.com
Tue Jul 10 00:47:17 PDT 2012


Hi,

I develop a media player with gstreamer in Vala.
The media player moves to the next video when EOS is emitted.

I have a segmentation fault on third reading.

Where is the error ?
Is it possible to use the gstreamer pipeline several times ?


TestOggDemux.vala :
--------------------------------

using Gst;

public class TestOggDemux
{
    private Pipeline pipeline;
    private Element fileSrc;
    private Element queueVorbis;
    private Element queueTheora;
    private bool videoIndex = true;
    
    public TestOggDemux()
    {
        //création de la pipeline movie
        pipeline = new Pipeline("TestOggDemux");

        //création des éléments de la pipeline
        fileSrc = ElementFactory.make("filesrc", "TestOggDemux_FileSrc");
        var oggDemux = ElementFactory.make("oggdemux",
"TestOggDemux_OggDemux");
        queueVorbis = ElementFactory.make("queue",
"TestOggDemux_QueueVorbis");
        var vorbisDec = ElementFactory.make("vorbisdec",
"TestOggDemux_VorbisDec");
        var autoAudioSink = ElementFactory.make("autoaudiosink",
"TestOggDemux_AutoAudioSink");
        queueTheora = ElementFactory.make("queue",
"TestOggDemux_QueueTheora");
        var theoraDec = ElementFactory.make("theoradec",
"TestOggDemux_TheoraDec");
        var xvImageSink = ElementFactory.make("xvimagesink",
"TestOggDemux_XVImageSink");
        
        //ajout des éléments à la pipeline
        pipeline.add_many(fileSrc, oggDemux, queueVorbis, vorbisDec,
autoAudioSink, queueTheora, theoraDec, xvImageSink);
        
        //linkage des éléments de la pipeline
        fileSrc.link(oggDemux);
        oggDemux.pad_added.connect(on_pad_added);
        queueVorbis.link(vorbisDec);
        vorbisDec.link(autoAudioSink);
        queueTheora.link(theoraDec);
        theoraDec.link(xvImageSink);
        
        //configuration de la pipeline
        fileSrc.set("location", "1.ogg");
        
        //ajout d'un bus de message à la pipeline
        var bus = pipeline.get_bus();
        bus.add_watch(on_bus_callback);
        
        //le pipeline est ready
        pipeline.set_state(State.PLAYING);
    }
    
    private void on_pad_added(Element element, Pad pad)
    {
        string mime = pad.caps.get_structure(0).get_name();
    
        if (mime == "audio/x-vorbis")
        {
            pad.link(queueVorbis.get_static_pad("sink"));
        }

        if (mime == "video/x-theora")
        {
            pad.link(queueTheora.get_static_pad("sink"));
        }
    }
    
    private bool on_bus_callback(Bus bus, Message message)
    {
        if (message.type == MessageType.ERROR)
        {
            stdout.printf("message error\n");
        }
        else if (message.type == MessageType.EOS)
        {            
            stdout.printf("end of stream\n");
            pipeline.set_state(State.NULL);
            videoIndex = !videoIndex;
            if (videoIndex)
            {
                fileSrc.set("location", "1.ogg");
            }
            else
            {
                fileSrc.set("location", "2.ogg");
            }
            pipeline.set_state(State.PLAYING);        
        }
    
        return true;
    }
    
    public static int main(string[] args)
    {
        Gst.init(ref args);
        
        new TestOggDemux();
        
        new MainLoop().run();
        
        return 0;
    }
}


--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/vala-oggdemux-and-dynamic-pads-tp4655550.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list