Skip to content

Commit

Permalink
Merge pull request #104 from AdminXVII/fix-latency
Browse files Browse the repository at this point in the history
Fix latency calculation
  • Loading branch information
thiesmoeller authored Jun 6, 2024
2 parents 1ebcb0c + 6236141 commit 49bb36c
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions ext/pylon/gstpylonsrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ static gboolean gst_pylon_src_set_caps(GstBaseSrc *src, GstCaps *caps) {
self->duration = GST_CLOCK_TIME_NONE;
}
GST_OBJECT_UNLOCK(self);
gst_element_post_message (GST_ELEMENT_CAST (self), gst_message_new_latency (GST_OBJECT_CAST (self)));

ret = gst_pylon_stop(self->pylon, &error);
if (FALSE == ret && error) {
Expand Down Expand Up @@ -865,21 +866,18 @@ static gboolean gst_pylon_src_query(GstBaseSrc *src, GstQuery *query) {

switch (GST_QUERY_TYPE(query)) {
case GST_QUERY_LATENCY: {
GstClockTime min_latency = GST_CLOCK_TIME_NONE;
GstClockTime max_latency = GST_CLOCK_TIME_NONE;
GstClockTime min_latency;
GstClockTime max_latency;

if (GST_CLOCK_TIME_NONE == self->duration) {
GST_WARNING_OBJECT(
src, "Can't report latency since framerate is not fixated yet");
goto done;
min_latency = 0;
max_latency = GST_CLOCK_TIME_NONE;
} else {
max_latency = min_latency = self->duration;
}

/* FIXME: we are assuming we cannot hold more than one
buffer. Eventually we want to have Pylon::StartGrabbing's
MaxNumImages extend the max_latency.
*/
max_latency = min_latency = self->duration;

GST_DEBUG_OBJECT(
self, "report latency min %" GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
GST_TIME_ARGS(min_latency), GST_TIME_ARGS(max_latency));
Expand All @@ -894,7 +892,6 @@ static gboolean gst_pylon_src_query(GstBaseSrc *src, GstQuery *query) {
break;
}

done:
return res;
}

Expand Down

0 comments on commit 49bb36c

Please sign in to comment.