1 From 725eeebe45149c1340d68a24da50b301955146fc Mon Sep 17 00:00:00 2001
2 From: Harunobu Kurokawa <harunobu.kurokawa.dn@renesas.com>
3 Date: Sat, 10 Jun 2017 11:23:02 +0900
4 Subject: [PATCH] gst-record: switch to gettime function to CLOCK_MONOTONIC
6 When system time is changed (e.g. from NTP) and buffer duration
7 is bigger, the gst-record stops. It should use the CLOCK_MONOTONIC time.
9 This patch is updated from
10 https://gerrit.automotivelinux.org/gerrit/#/c/9417/
12 Signed-off-by: Harunobu Kurokawa <harunobu.kurokawa.dn@renesas.com>
14 src/gst-recorder.c | 14 +++++++++-----
15 1 file changed, 9 insertions(+), 5 deletions(-)
17 diff --git a/src/gst-recorder.c b/src/gst-recorder.c
18 index 441e294..ed1526d 100644
19 --- a/src/gst-recorder.c
20 +++ b/src/gst-recorder.c
21 @@ -102,8 +102,9 @@ struct gst_recorder {
26 GstClockTime timestamp;
27 - uint32_t ts_last_frame;
28 + GstClockTime ts_last_frame;
32 @@ -1036,6 +1037,9 @@ gst_recorder_create(struct gst_recorder_settings *settings)
36 + /* set clock time */
37 + r->clock = gst_element_get_clock (GST_ELEMENT_CAST (r->appsrc));
39 weston_log("gst_recorder_create done\n");
42 @@ -1071,15 +1075,15 @@ gst_recorder_destroy(struct gst_recorder *r)
44 gst_recorder_set_timestamp(struct gst_recorder *r, GstBuffer *buffer)
46 - uint32_t cur_time = weston_compositor_get_time();
47 + GstClockTime cur_time = gst_clock_get_time(r->clock);
49 if (r->timestamp == 0) {
50 /* first frame assume around DEFAULT_FPS FPS */
51 GST_BUFFER_DURATION(buffer) = gst_util_uint64_scale_int(1, GST_SECOND, DEFAULT_FPS);
53 - uint32_t delta = cur_time - r->ts_last_frame;
55 - GST_BUFFER_DURATION(buffer) = gst_util_uint64_scale_int(delta, GST_SECOND, 1000);
56 + GstClockTime delta = cur_time - r->ts_last_frame;
58 + GST_BUFFER_DURATION(buffer) = delta;
61 r->timestamp += GST_BUFFER_DURATION(buffer);