From d5409fca8a500d09eb147679fc9700da1eb4fcdc Mon Sep 17 00:00:00 2001 From: "Joshua M. Doe" Date: Thu, 14 Jun 2012 13:42:20 -0400 Subject: [PATCH] niimaq: send DateTime tag event --- sys/niimaq/gstniimaq.c | 18 ++++++++++++++++++ sys/niimaq/gstniimaq.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/sys/niimaq/gstniimaq.c b/sys/niimaq/gstniimaq.c index 5a1a054..f423684 100644 --- a/sys/niimaq/gstniimaq.c +++ b/sys/niimaq/gstniimaq.c @@ -143,6 +143,9 @@ gst_niimaqsrc_frame_start_callback (SESSION_ID sid, IMG_ERR err, GstNiImaqSrcFrameTime *frametime = g_new (GstNiImaqSrcFrameTime, 1); uInt32 val; + if (G_UNLIKELY (niimaqsrc->start_time == NULL)) + niimaqsrc->start_time = gst_date_time_new_now_utc (); + /* get clock time and set to frametime struct */ clock = gst_element_get_clock (GST_ELEMENT (niimaqsrc)); if (G_LIKELY (clock)) { @@ -520,6 +523,9 @@ gst_niimaqsrc_init (GstNiImaqSrc * niimaqsrc, GstNiImaqSrcClass * g_class) niimaqsrc->timelist = NULL; niimaqsrc->frametime_mutex = g_mutex_new (); + + niimaqsrc->start_time = NULL; + niimaqsrc->start_time_sent = FALSE; } /** @@ -546,6 +552,11 @@ gst_niimaqsrc_dispose (GObject * object) niimaqsrc->frametime_mutex = NULL; /* unref objects */ + if (niimaqsrc->start_time) { + gst_date_time_unref (niimaqsrc->start_time); + niimaqsrc->start_time = NULL; + } + if (niimaqsrc->caps) { gst_caps_unref (niimaqsrc->caps); niimaqsrc->caps = NULL; @@ -837,6 +848,13 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer) src->rate_denominator, src->rate_numerator); } */ + if (G_UNLIKELY (niimaqsrc->start_time && !niimaqsrc->start_time_sent)) { + GstTagList *tl = + gst_tag_list_new_full (GST_TAG_DATE_TIME, niimaqsrc->start_time, NULL); + GstEvent *e = gst_event_new_tag (tl); + gst_pad_push_event (GST_PAD (GST_BASE_SRC_PAD (niimaqsrc)), e); + } + return res; error: diff --git a/sys/niimaq/gstniimaq.h b/sys/niimaq/gstniimaq.h index 6ce75cd..3bdcb33 100644 --- a/sys/niimaq/gstniimaq.h +++ b/sys/niimaq/gstniimaq.h @@ -75,6 +75,9 @@ struct _GstNiImaqSrc { GSList *timelist; GMutex *frametime_mutex; + + GstDateTime *start_time; + gboolean start_time_sent; }; struct _GstNiImaqSrcClass {