RTSP seek issue with custom client

Nicolas Dufresne nicolas.dufresne at collabora.com
Sun Nov 1 18:45:10 PST 2015


Le dimanche 01 novembre 2015 à 11:57 -0800, suspension a écrit :
> Hi
> 
> I have set-up a generic gstreamer client using the below code. It
> accepts a
> pipeline in the gst-launch format and runts the pipeline in a
> separate
> thread. I have removed some code that are related to setting a custom
> window
> handle because I thought it has nothing to do with the issue I am
> facing
> now.
> 
> Basically, the run method spawns a separate thread which starts in
> the
> function playback. This function uses the passed pipeline to create
> gst
> pipeline and set its state to GST_STATE_READY. The thread that calls
> run
> (which is the program's main thread) sets the pipeline status to
> playing
> after pipeline is started. The same thread at a later time calls
> gst_element_seek_simple with a valid time to seek the position. This
> call
> almost always result in a hang in both the client and the server.
> However if
> I use gst-play-1.0 as the client seek works. What am I doing wrong
> here?
> 
> void playback(int argc, char* argv[])
> {
>     std::cerr << "starting loop thread" << std::endl;
>     GError* error = NULL;
> 
>     /* init */
> 
>     gst_init(&argc, &argv);
> 
>     std::cerr << "gst init done" << std::endl;
>     loop = g_main_loop_new(NULL, FALSE);
>     if (loop == NULL) {
>         std::cerr << "Failed to create the main loop" << std::endl;
>         loop_error = true;
>         return;
>     }
> 
>     std::cerr << "gst creating loop done" << std::endl;
>     pipeline = gst_parse_launch(argv[1], &error);
>     std::cerr << "gst pipeline parsed" << std::endl;
> 
>     if (pipeline == NULL || error != NULL) {
>         std::cerr << "Failed to create the pipeline" << std::endl;
>         loop_error = true;
>         return;
>     }
> 
>     gst_element_set_state(pipeline, GST_STATE_READY);
> 
>     std::cerr << "gst pipeline created" << std::endl;
>     done = true;
>     std::cerr << "gst starting the pipeline loop" << std::endl;
>     g_main_loop_run(loop);
>     std::cerr << "gst pipeline loop exited" << std::endl;
> }
> 
> 
> int run(int argc, char* argv[])
> { 
>     std::thread playback_thread(playback, argc, argv);
> 
>     std::cerr << "Waiting for the loop to be ready" << std::endl;
>     // wait until loop
>     while (!done) {
>        
>  std::this_thread::sleep_for(std::chrono::microseconds(1000000));
>     }
> 
>    // after sometime set the status to playing 
>    gst_element_set_state(pipeline, GST_STATE_PLAYING);

At this point the pipeline it is not guarantie that the pipeline is
ready to be seeked. Check the return value of this call, you may get
 GST_STATE_CHANGE_ASYNC, in which case you should wait for the
ASYNC_DONE message before seeking. As a quick test, just put a sleep
here, which will likely make it work.

> 
> 
>     // wait for a user command to seek
>    GstSeekFlags flags = GST_SEEK_FLAG_FLUSH;            
>    gst_element_seek_simple(pipeline, GST_FORMAT_TIME, flags,
> GST_SECOND *
> seek_pos);
> }
> 
> 
> 
> --
> View this message in context: http://gstreamer-devel.966125.n4.nabble
> .com/RTSP-seek-issue-with-custom-client-tp4674360.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20151101/6f4d316e/attachment.sig>


More information about the gstreamer-devel mailing list