How to manage my customize clock (GstAudioClock) after seek/flush?

Halley Zhao aihua.halley.zhao at gmail.com
Wed Jun 5 05:49:38 UTC 2019


Hi expert:
  I have a short gst pipeline (appsrc-->videodecode-->videosink), and want
to control the playback pace by an external clock.  in my simple example, I
created a customized GstAudioClock basing on system time. it works for
normal playback.
GstAudioClock *myGstClock = GST_AUDIO_CLOCK(gst_audio_clock_new("MyClock",
(GstAudioClockGetTimeFunc)getMyClockTime, NULL/* user   data */,
NULL/*GDestroyNotify destroy_notify*/));
getMyClockTime() reports played time comparable with video frame timestamp.
code piece see below.

  but, I met issue after seek.
  after seek, I simply update g_anchorTime to the seek_time (0 in my sample
code); thus getMyClockTime always returns currTime comparable with
timestamp of video frame.
   however video frames are dropped before seek_time. because
gst_clock_get_time() always returns monotonically increasing time(not
currTime as I expect).
   I tried to call gst_audio_clock_reset(myGstClock, 0), it doesn't help.

static uint64_t g_anchorTime = -1;
int64_t getTimeNs()
{
    struct timespec t;
    clock_gettime(CLOCK_MONOTONIC, &t);
    int64_t currTime = t.tv_sec;
    currTime = currTime * 1000*1000*1000LL + t.tv_nsec;

    return currTime;
}
GstClockTime getMyClockTime(GstClock * clock, gpointer user_data)
{
    static int dbgCount = 0;

    int64_t currTime = getTimeNs();
    currTime = currTime-g_anchorTime;
    DEBUG("dbgCount: %d, %" PRId64 ", %.3f", dbgCount++, currTime,
currTime/1000/1000/1000.0);

    return currTime;
}

complete sample code see attachment seek.c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20190605/7eb8445a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: seek.c
Type: application/octet-stream
Size: 11616 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20190605/7eb8445a/attachment-0001.obj>


More information about the gstreamer-devel mailing list