seek stop problem

Sergei Vorobyov sergei.vorobyov at facilitylabs.com
Wed Mar 21 06:29:43 PDT 2012


Greetings,

I am experiencing the following problem with stopping the playback in:

for (;;) {

/* random position ps in nanoseconds (out of 10 possibilities 0,
5000000000, 10000000000, ..., 45000000000) is generated */

event = gst_event_new_seek (1.0,
				  GST_FORMAT_TIME,
				  GST_SEEK_FLAG_FLUSH,
				  GST_SEEK_TYPE_SET, ps,
				  GST_SEEK_TYPE_SET, ps + 5 * GST_SECOND);

result = gst_element_send_event(pipeline, event);

/* see the insert below */

g_main_loop_run (loop);

}

My intention is to play a random 5-sec segment.

The seek to the initial position ps is accurate, but the playback does
not stop after 5 secs as intended (and specified in the APIs); it goes
to the very end, until EOS is generated, caught in my callback
function, which calls

if (msg_type & GST_MESSAGE_EOS) {
      g_print ("EOS message\n");
      g_main_loop_quit (loop);
      return TRUE;
}

I checked and caught all signals in my callback function, and
SEGMENT_DONE or anything relevant never occur, except EOS in the very
end.

I tried another possibility. Rather than relying on (non-working)
terminating ... GST_SEEK_TYPE_SET, ps + 5 * GST_SECOND); above

I inserted, before g_main_loop_run (loop); instead /* see the insert below */

the following timeout call

g_timeout_add_seconds (5, (GSourceFunc) cb_end_stream, pipeline);

with the trivial callback

gboolean cb_end_stream (GstElement *pipeline)
{
  g_main_loop_quit(loop);
  return FALSE;
}

Now, it stops the playback accurately, always after 5 secs, but
initial position seeks sometimes err (usually 10 secs later than
asked).

Maybe I forgot to mention that my pipeline is constructed using the
gnlcomposition out of ten 5-second pieces concatenated in the 50 sec
stream, which test-plays correctly and smoothly.

I would appreciate any hints and help.

PS:

maybe I need to rewind the pipe withing the callback function, without
ever calling g_main_loop_quit (loop) in my callbacks? Currently I am
looping over the g_main_loop_run:

for (;;) {
...
g_main_loop_run (loop);

}

Many thanks!


More information about the gstreamer-devel mailing list