kayasrc: report dropped frames with warning and bus message

This commit is contained in:
Joshua M. Doe 2018-07-18 08:51:13 -04:00
parent e7cdcb426d
commit 4c47870c00
2 changed files with 30 additions and 3 deletions

View File

@ -189,6 +189,8 @@ gst_kayasrc_class_init (GstKayaSrcClass * klass)
static void static void
gst_kayasrc_cleanup (GstKayaSrc * src) gst_kayasrc_cleanup (GstKayaSrc * src)
{ {
src->frame_size = 0;
src->dropped_frames = 0;
src->stop_requested = FALSE; src->stop_requested = FALSE;
src->acquisition_started = FALSE; src->acquisition_started = FALSE;
@ -241,8 +243,8 @@ gst_kayasrc_init (GstKayaSrc * src)
src->fg_handle = INVALID_FGHANDLE; src->fg_handle = INVALID_FGHANDLE;
src->cam_handle = INVALID_CAMHANDLE; src->cam_handle = INVALID_CAMHANDLE;
src->stream_handle = INVALID_STREAMHANDLE;
gst_kayasrc_cleanup (src); src->buffer_handles = NULL;
} }
static void static void
@ -386,6 +388,8 @@ gst_kayasrc_start (GstBaseSrc * bsrc)
GST_DEBUG_OBJECT (src, "start"); GST_DEBUG_OBJECT (src, "start");
gst_kayasrc_cleanup (src);
/* find and list all KAYA interfaces */ /* find and list all KAYA interfaces */
num_ifaces = KYFG_Scan (NULL, 0); num_ifaces = KYFG_Scan (NULL, 0);
if (num_ifaces == 0) { if (num_ifaces == 0) {
@ -541,6 +545,9 @@ gst_kayasrc_start (GstBaseSrc * bsrc)
return FALSE; return FALSE;
} }
src->stop_requested = FALSE;
src->dropped_frames = 0;
return TRUE; return TRUE;
error: error:
@ -700,7 +707,7 @@ static GstFlowReturn
gst_kayasrc_create (GstPushSrc * psrc, GstBuffer ** buf) gst_kayasrc_create (GstPushSrc * psrc, GstBuffer ** buf)
{ {
GstKayaSrc *src = GST_KAYA_SRC (psrc); GstKayaSrc *src = GST_KAYA_SRC (psrc);
guint32 dropped_frames = 0; gint64 dropped_frames = 0;
GST_LOG_OBJECT (src, "create"); GST_LOG_OBJECT (src, "create");
@ -724,6 +731,25 @@ gst_kayasrc_create (GstPushSrc * psrc, GstBuffer ** buf)
goto error; goto error;
} }
dropped_frames =
KYFG_GetGrabberValueInt (src->cam_handle, "DropFrameCounter");
if (dropped_frames > src->dropped_frames) {
GstStructure *info_msg;
gint64 just_dropped = dropped_frames - src->dropped_frames;
src->dropped_frames = dropped_frames;
GST_WARNING_OBJECT (src, "Just dropped %d frames (%d total)", just_dropped,
src->dropped_frames);
info_msg = gst_structure_new ("dropped-frame-info",
"num-dropped-frames", G_TYPE_INT, just_dropped,
"total-dropped-frames", G_TYPE_INT, src->dropped_frames,
"timestamp", GST_TYPE_CLOCK_TIME, GST_BUFFER_TIMESTAMP (buf), NULL);
gst_element_post_message (GST_ELEMENT (src),
gst_message_new_element (GST_OBJECT (src), info_msg));
src->dropped_frames = dropped_frames;
}
if (src->stop_requested) { if (src->stop_requested) {
if (*buf != NULL) { if (*buf != NULL) {
gst_buffer_unref (*buf); gst_buffer_unref (*buf);

View File

@ -58,6 +58,7 @@ struct _GstKayaSrc
gboolean acquisition_started; gboolean acquisition_started;
gboolean stop_requested; gboolean stop_requested;
gint64 dropped_frames;
GstCaps *caps; GstCaps *caps;
GAsyncQueue *queue; GAsyncQueue *queue;