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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Halley Zhao
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


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

seek.c (15K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Halley Zhao
my question are:
1. if it is by-design that gst_clock_get_time() reports monotonically increasing time; why video frames are blocked by basesink after seek backwards?
2. how should I 'reset' GstClock/GstAudioClock after flush/seek, I found gst_audio_reset() doesn't work as expected.


Halley Zhao <[hidden email]> 于2019年6月5日周三 下午1:49写道:
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


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel