mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
fix videorate decision, add latency offset to v4l
Original commit message from CVS: fix videorate decision, add latency offset to v4l
This commit is contained in:
parent
e7ec8bcb7a
commit
a45f29c44a
4 changed files with 53 additions and 6 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,4 +1,23 @@
|
|||
2004-06-26 set REAL_NAME environment variable <set EMAIL_ADDRESS environment variable>
|
||||
2004-06-26 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/videorate/gstvideorate.c: (gst_videorate_chain):
|
||||
fix decision for when getting frames with same timestamp
|
||||
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_class_init), (gst_v4lsrc_init),
|
||||
(gst_v4lsrc_get), (gst_v4lsrc_set_property),
|
||||
(gst_v4lsrc_get_property):
|
||||
* sys/v4l/gstv4lsrc.h:
|
||||
add latency offset property
|
||||
|
||||
2004-06-26 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/tcp/gsttcpserversink.c: (gst_tcpserversink_queue_buffer):
|
||||
* gst/videorate/gstvideorate.c: (gst_videorate_chain):
|
||||
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_class_init), (gst_v4lsrc_init),
|
||||
(gst_v4lsrc_get), (gst_v4lsrc_set_property),
|
||||
(gst_v4lsrc_get_property):
|
||||
* sys/v4l/gstv4lsrc.h:
|
||||
|
||||
2004-06-26 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* gst/videorate/gstvideorate.c: (gst_videorate_chain),
|
||||
(plugin_init):
|
||||
|
|
|
@ -369,7 +369,7 @@ gst_videorate_chain (GstPad * pad, GstData * data)
|
|||
GST_TIME_ARGS (videorate->next_ts));
|
||||
|
||||
/* output first one when its the best */
|
||||
if (diff1 <= diff2) {
|
||||
if (diff1 < diff2) {
|
||||
GstBuffer *outbuf;
|
||||
|
||||
count++;
|
||||
|
@ -389,7 +389,7 @@ gst_videorate_chain (GstPad * pad, GstData * data)
|
|||
}
|
||||
/* continue while the first one was the best */
|
||||
}
|
||||
while (diff1 <= diff2);
|
||||
while (diff1 < diff2);
|
||||
|
||||
/* if we outputed the first buffer more then once, we have dups */
|
||||
if (count > 1) {
|
||||
|
|
|
@ -63,7 +63,8 @@ enum
|
|||
ARG_BUFSIZE,
|
||||
ARG_SYNC_MODE,
|
||||
ARG_COPY_MODE,
|
||||
ARG_AUTOPROBE
|
||||
ARG_AUTOPROBE,
|
||||
ARG_LATENCY_OFFSET
|
||||
};
|
||||
|
||||
GST_FORMATS_FUNCTION (GstPad *, gst_v4lsrc_get_formats,
|
||||
|
@ -212,6 +213,10 @@ gst_v4lsrc_class_init (GstV4lSrcClass * klass)
|
|||
g_param_spec_boolean ("autoprobe", "Autoprobe",
|
||||
"Whether the device should be probed for all possible features",
|
||||
TRUE, G_PARAM_READWRITE));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LATENCY_OFFSET,
|
||||
g_param_spec_int ("latency-offset", "Latency offset",
|
||||
"A latency offset subtracted from timestamps set on buffers (in ns)",
|
||||
G_MININT, G_MAXINT, 0, G_PARAM_READWRITE));
|
||||
|
||||
/* signals */
|
||||
gst_v4lsrc_signals[SIGNAL_FRAME_CAPTURE] =
|
||||
|
@ -273,6 +278,8 @@ gst_v4lsrc_init (GstV4lSrc * v4lsrc)
|
|||
|
||||
v4lsrc->is_capturing = FALSE;
|
||||
v4lsrc->autoprobe = TRUE;
|
||||
|
||||
v4lsrc->latency_offset = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -956,9 +963,20 @@ gst_v4lsrc_get (GstPad * pad)
|
|||
case GST_V4LSRC_SYNC_MODE_CLOCK:
|
||||
if (v4lsrc->clock) {
|
||||
GstClockTime time = gst_element_get_time (GST_ELEMENT (v4lsrc));
|
||||
GstClockTimeDiff target_ts = 0;
|
||||
|
||||
/* FIXME: figure out a way to add the capture latency here */
|
||||
GST_BUFFER_TIMESTAMP (buf) = time /* + 0.5 * GST_SECOND / fps */ ;
|
||||
/* we can't go negative for timestamps. FIXME: latency querying
|
||||
* in the core generally should solve this */
|
||||
target_ts = GST_CLOCK_DIFF (time, v4lsrc->latency_offset);
|
||||
if (target_ts < 0)
|
||||
target_ts = 0;
|
||||
/* FIXME: create GST_TIME_DIFF_ARGS for target_ts */
|
||||
GST_LOG_OBJECT (v4lsrc, "time: %" GST_TIME_FORMAT
|
||||
", latency-offset: %" GST_TIME_FORMAT
|
||||
", timestamp: %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (time), GST_TIME_ARGS (v4lsrc->latency_offset),
|
||||
GST_TIME_ARGS (target_ts));
|
||||
GST_BUFFER_TIMESTAMP (buf) = target_ts;
|
||||
} else {
|
||||
GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
|
||||
}
|
||||
|
@ -1047,6 +1065,11 @@ gst_v4lsrc_set_property (GObject * object,
|
|||
}
|
||||
break;
|
||||
|
||||
case ARG_LATENCY_OFFSET:
|
||||
v4lsrc->latency_offset = g_value_get_int (value);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -1088,6 +1111,10 @@ gst_v4lsrc_get_property (GObject * object,
|
|||
g_value_set_boolean (value, v4lsrc->autoprobe);
|
||||
break;
|
||||
|
||||
case ARG_LATENCY_OFFSET:
|
||||
g_value_set_int (value, v4lsrc->latency_offset);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
|
@ -76,6 +76,7 @@ struct _GstV4lSrc
|
|||
gint num_queued;
|
||||
gint sync_frame, queue_frame;
|
||||
gboolean is_capturing;
|
||||
GstClockTimeDiff latency_offset;
|
||||
|
||||
/* True if we want to stop */
|
||||
gboolean quit;
|
||||
|
|
Loading…
Reference in a new issue