kayasrc: sync clock every second and use better clock
g_get_real_time() on Windows sometimes gives millisecond resolution. Also grabbing framegrabber timestamp takes a non-insignificant amount of time, so do it every second.
This commit is contained in:
parent
ac4a7b29e3
commit
fec3ce5308
@ -41,6 +41,7 @@
|
|||||||
#include <gst/base/gstpushsrc.h>
|
#include <gst/base/gstpushsrc.h>
|
||||||
#include <gst/video/video.h>
|
#include <gst/video/video.h>
|
||||||
|
|
||||||
|
#include "get_unix_ns.h"
|
||||||
#include "gstkayasrc.h"
|
#include "gstkayasrc.h"
|
||||||
#include "genicampixelformat.h"
|
#include "genicampixelformat.h"
|
||||||
|
|
||||||
@ -223,6 +224,7 @@ gst_kayasrc_cleanup (GstKayaSrc * src)
|
|||||||
src->stop_requested = FALSE;
|
src->stop_requested = FALSE;
|
||||||
src->acquisition_started = FALSE;
|
src->acquisition_started = FALSE;
|
||||||
src->kaya_base = GST_CLOCK_TIME_NONE;
|
src->kaya_base = GST_CLOCK_TIME_NONE;
|
||||||
|
src->unix_base = 0;
|
||||||
|
|
||||||
if (src->caps) {
|
if (src->caps) {
|
||||||
gst_caps_unref (src->caps);
|
gst_caps_unref (src->caps);
|
||||||
@ -799,11 +801,13 @@ gst_kayasrc_stream_buffer_callback (STREAM_BUFFER_HANDLE buffer_handle,
|
|||||||
GST_BUFFER_OFFSET (buf) = src->frame_count;
|
GST_BUFFER_OFFSET (buf) = src->frame_count;
|
||||||
src->frame_count++;
|
src->frame_count++;
|
||||||
|
|
||||||
//if (src->kaya_base == GST_CLOCK_TIME_NONE) {
|
guint64 cur_time = get_unix_ns();
|
||||||
// assume delay between these two calls is negligible
|
if (cur_time - src->unix_base > GST_SECOND) {
|
||||||
|
// assume delay between these two calls is negligible (one measurement showed <100ns)
|
||||||
src->kaya_base = KYFG_GetGrabberValueInt (src->cam_handle, "Timestamp");
|
src->kaya_base = KYFG_GetGrabberValueInt (src->cam_handle, "Timestamp");
|
||||||
src->unix_base = g_get_real_time () * 1000;
|
src->unix_base = get_unix_ns ();
|
||||||
//}
|
}
|
||||||
|
|
||||||
#if GST_CHECK_VERSION(1,14,0)
|
#if GST_CHECK_VERSION(1,14,0)
|
||||||
{
|
{
|
||||||
GstClockTime unix_ts = src->unix_base + (timestamp - src->kaya_base);
|
GstClockTime unix_ts = src->unix_base + (timestamp - src->kaya_base);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user