[gst-devel] pipeline synchronization

Edward Hervey bilboed at gmail.com
Thu May 13 09:04:59 CEST 2010


On Wed, 2010-05-12 at 23:25 -0700, dodo.r84 wrote:
> Hi all,
> I'm working on gstreamer java.
> In my scenario I added a custom module that perform cyphering.
> This module is positioned just after the video demuxer.
> I need to cypher my stream with different keys every "x" seconds. (X is read
> from DB and should correspond to the PTS).
> 
> In order to synchronize to these "x" seconds I am trying to pause the
> pipeline, set the cypher module with new key and play the pipeline again for
> every key.

  Hi, you might find it *much* easier if you were to actually do your
synchronisation against the buffer timestamps rather than the clock.

  In your cypher element, store the newsegment in a GstSegment, and then
for each buffer calculate the running_time of that buffer
(gst_segment_get_running_time(segment, GST_BUFFER_TIMESTAMP(buf))).

  And then every 5s, you can apply your new key. If it's the application
that needs to provide the new key, then you can emit a message on the
bus that your application catches *synchronously* on the bus (see GstBus
sync handlers in the docs) and can then set the new key.

  This assumes the demuxer properly sets timestamps on the outgoing
buffers of course, but should be the case (and remember the buffer
timestamps are PTS, so in the case of H264 will be out of order).

    Edward

> 
> E.g.
> We have First key from 0 to 4999 millisec, Seconf key from 5000 to 10000
> millisec.
> How can I know when the pipeline reaches 4999 millisec?
> I tryed to use the seek operation from 0 to 4999, when it ends the EOS
> Listener (Bus.EOS()) catches it and I pause the pipeline.
> Inside Bus.EOS() I do the seek for the second key.
> 
> The problem is that time is not synchronized. (e.g. after first key, inside
> Bus.EOS() time is already 5020).
> 
> I have also tryed with a while operation: while(pipeline.isPlaying()). In
> this loop I look at the queryPosition() and when it gets over 4999, I pause
> the pipeline, set the module with new key and so on...
> 
> The problem is the same.
> 
> Can you give me any ideas?
> 
> Thanks in advance.
> 
> Dodo 






More information about the gstreamer-devel mailing list