Skip to content

Commit

Permalink
when TriggerMode = On do not exit if buffer is empty on gst pipeline …
Browse files Browse the repository at this point in the history
…create
  • Loading branch information
lc-spxl committed Aug 12, 2022
1 parent 43b3ea4 commit 948b287
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions gst/gstaravis.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,15 +550,51 @@ gst_aravis_create (GstPushSrc * push_src, GstBuffer ** buffer)
gst_aravis = GST_ARAVIS (push_src);
base_src_does_timestamp = gst_base_src_get_do_timestamp(GST_BASE_SRC(push_src));

// get trigger mode
GError *error = NULL;

gboolean triggerModeEnabled = FALSE;
gboolean triggerModeAvail = arv_device_is_feature_available (arv_camera_get_device (gst_aravis->camera), "TriggerMode", &error);

if (error != NULL) {
GST_ERROR_OBJECT (gst_aravis, "Check TriggerMode avail failed: %d %s", error->code, error->message);
return GST_FLOW_ERROR;
}

if (triggerModeAvail) {

ArvGcNode *feature = arv_device_get_feature (arv_camera_get_device (gst_aravis->camera), "TriggerMode");
const char *value = arv_gc_string_get_value (ARV_GC_STRING (feature), &error);

if (error != NULL) {
GST_ERROR_OBJECT (gst_aravis, "Read TriggerMode failed: %d %s", error->code, error->message);
return GST_FLOW_ERROR;
}

triggerModeEnabled = strcmp(value, "On") == 0;
if (triggerModeEnabled) {
GST_LOG_OBJECT (gst_aravis, "TriggeMode is set to On, pipeline will wait for a stream.");
}
}

GST_OBJECT_LOCK (gst_aravis);

do {
if (arv_buffer) arv_stream_push_buffer (gst_aravis->stream, arv_buffer);
arv_buffer = arv_stream_timeout_pop_buffer (gst_aravis->stream, gst_aravis->buffer_timeout_us);
} while (arv_buffer != NULL && arv_buffer_get_status (arv_buffer) != ARV_BUFFER_STATUS_SUCCESS);

if (arv_buffer == NULL)
if (arv_buffer == NULL && triggerModeEnabled) {
GST_DEBUG_OBJECT (gst_aravis, "Waiting for buffer");
}

} while (
(arv_buffer == NULL && triggerModeEnabled) ||
(arv_buffer != NULL && arv_buffer_get_status (arv_buffer) != ARV_BUFFER_STATUS_SUCCESS)
);

if (arv_buffer == NULL) {
goto error;
}

buffer_data = (char *) arv_buffer_get_data (arv_buffer, &buffer_size);
arv_buffer_get_image_region (arv_buffer, NULL, NULL, &width, &height);
Expand Down

0 comments on commit 948b287

Please sign in to comment.