[gst-devel] How do I clean a pipeline to start/stop it several times?

ldac ldacvs at gmail.com
Wed Jul 15 13:43:16 CEST 2009


    Hi all,

I have programmed a C application where I capture video, then I encode 
it, and finally I stream it using an udpsink element. It works, but if I 
stop the pipeline (sending it EOS) and then start it again, I get old 
video, when it should be alive. How can I clean absolutely the pipeline 
to avoid this?

    My code is something like this:
   
        ...
        // Create the elements
        pipeline = gst_pipeline_new( "pipe" );
        video_src = gst_element_factory_make( "mfw_v4lsrc", 
"video-source" );
        video_enc = gst_element_factory_make( "mfw_vpuencoder", 
"video-encoder" );
        sink = gst_element_factory_make( "udpsink", "sink" );
        // Add the elements to the pipeline
        gst_bin_add_many( GST_BIN( pipeline ), video_src, video_enc, 
sink, NULL );
        gst_element_link_with_filter( video_src, video_enc, &settings );
        gst_element_link( video_enc, sink );
        ...
        // Start/Stop the video stream
        while ( 1 )
        {
             if ( do_stream )  
             {
                 gst_element_set_state( pipeline, GST_STATE_PLAYING );
                 g_main_loop_run( loop );
                 gst_element_set_state( pipeline, GST_STATE_NULL );
             }
             else
                sleep( 1 );
        }
        ...

    Another function changes the variable 'do_stream' to true/false, and 
send also the EOS signal to the pipeline when required.

    So, specifically, my question is: What do I clean my pipeline when 
stopped to start again with the buffers and everything clean? Do I have 
to delete the pipeline object and do I have to create and link all the 
pipeline again?

    Thank you very much.
    All the best.
    LD.






More information about the gstreamer-devel mailing list