summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-02-11 13:53:02 +0100
committerSebastian Dröge <sebastian@centricular.com>2015-02-11 13:53:02 +0100
commitf4b510779611a1495c06be0d7ec8b987d20a78d1 (patch)
treea3f454449689729d1a9ea3d2aa99fb3818c1122f
parentb79eff7f9bfcf1b3b0360d346cc3b3483da1361e (diff)
Improve and fix LATENCY query handling
This now follows the design docs everywhere, especially the maximum latency handling. https://bugzilla.gnome.org/show_bug.cgi?id=744106
-rw-r--r--ext/raw1394/gstdv1394src.c2
-rw-r--r--ext/vpx/gstvp8enc.c14
-rw-r--r--ext/vpx/gstvp9enc.c14
-rw-r--r--gst/interleave/interleave.c16
-rw-r--r--gst/rtsp/gstrtpdec.c1
-rw-r--r--gst/videomixer/videomixer2.c16
6 files changed, 38 insertions, 25 deletions
diff --git a/ext/raw1394/gstdv1394src.c b/ext/raw1394/gstdv1394src.c
index 41a57e7f6..09755ba53 100644
--- a/ext/raw1394/gstdv1394src.c
+++ b/ext/raw1394/gstdv1394src.c
@@ -980,7 +980,7 @@ gst_dv1394src_query (GstBaseSrc * basesrc, GstQuery * query)
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_LATENCY:
{
- gst_query_set_latency (query, TRUE, GST_SECOND / 25, GST_CLOCK_TIME_NONE);
+ gst_query_set_latency (query, TRUE, GST_SECOND / 25, GST_SECOND / 25);
}
break;
default:
diff --git a/ext/vpx/gstvp8enc.c b/ext/vpx/gstvp8enc.c
index 5fca8f6b1..083c5902f 100644
--- a/ext/vpx/gstvp8enc.c
+++ b/ext/vpx/gstvp8enc.c
@@ -1500,6 +1500,7 @@ gst_vp8_enc_set_format (GstVideoEncoder * video_encoder,
GstVideoInfo *info = &state->info;
GstVideoCodecState *output_state;
gchar *profile_str;
+ GstClockTime latency;
encoder = GST_VP8_ENC (video_encoder);
GST_DEBUG_OBJECT (video_encoder, "set_format");
@@ -1681,13 +1682,16 @@ gst_vp8_enc_set_format (GstVideoEncoder * video_encoder,
}
if (GST_VIDEO_INFO_FPS_D (info) == 0 || GST_VIDEO_INFO_FPS_N (info) == 0) {
- gst_video_encoder_set_latency (video_encoder, 0, GST_CLOCK_TIME_NONE);
+ /* FIXME: Assume 25fps for unknown framerates. Better than reporting
+ * that we introduce no latency while we actually do
+ */
+ latency = gst_util_uint64_scale (encoder->cfg.g_lag_in_frames,
+ 1 * GST_SECOND, 25);
} else {
- gst_video_encoder_set_latency (video_encoder, 0,
- gst_util_uint64_scale (encoder->cfg.g_lag_in_frames,
- GST_VIDEO_INFO_FPS_D (info) * GST_SECOND,
- GST_VIDEO_INFO_FPS_N (info)));
+ latency = gst_util_uint64_scale (encoder->cfg.g_lag_in_frames,
+ GST_VIDEO_INFO_FPS_D (info) * GST_SECOND, GST_VIDEO_INFO_FPS_N (info));
}
+ gst_video_encoder_set_latency (video_encoder, latency, latency);
encoder->inited = TRUE;
/* Store input state */
diff --git a/ext/vpx/gstvp9enc.c b/ext/vpx/gstvp9enc.c
index 84b4b2228..7a18e6102 100644
--- a/ext/vpx/gstvp9enc.c
+++ b/ext/vpx/gstvp9enc.c
@@ -1476,6 +1476,7 @@ gst_vp9_enc_set_format (GstVideoEncoder * video_encoder,
GstVideoInfo *info = &state->info;
GstVideoCodecState *output_state;
gchar *profile_str;
+ GstClockTime latency;
encoder = GST_VP9_ENC (video_encoder);
GST_DEBUG_OBJECT (video_encoder, "set_format");
@@ -1660,13 +1661,16 @@ gst_vp9_enc_set_format (GstVideoEncoder * video_encoder,
}
if (GST_VIDEO_INFO_FPS_D (info) == 0 || GST_VIDEO_INFO_FPS_N (info) == 0) {
- gst_video_encoder_set_latency (video_encoder, 0, GST_CLOCK_TIME_NONE);
+ /* FIXME: Assume 25fps for unknown framerates. Better than reporting
+ * that we introduce no latency while we actually do
+ */
+ latency = gst_util_uint64_scale (encoder->cfg.g_lag_in_frames,
+ 1 * GST_SECOND, 25);
} else {
- gst_video_encoder_set_latency (video_encoder, 0,
- gst_util_uint64_scale (encoder->cfg.g_lag_in_frames,
- GST_VIDEO_INFO_FPS_D (info) * GST_SECOND,
- GST_VIDEO_INFO_FPS_N (info)));
+ latency = gst_util_uint64_scale (encoder->cfg.g_lag_in_frames,
+ GST_VIDEO_INFO_FPS_D (info) * GST_SECOND, GST_VIDEO_INFO_FPS_N (info));
}
+ gst_video_encoder_set_latency (video_encoder, latency, latency);
encoder->inited = TRUE;
/* Store input state */
diff --git a/gst/interleave/interleave.c b/gst/interleave/interleave.c
index 2a2fd6e4b..1d36654e9 100644
--- a/gst/interleave/interleave.c
+++ b/gst/interleave/interleave.c
@@ -1079,15 +1079,17 @@ gst_interleave_src_query_latency (GstInterleave * self, GstQuery * query)
if (res) {
gst_query_parse_latency (peerquery, &live_cur, &min_cur, &max_cur);
- if (min_cur > min)
- min = min_cur;
+ if (live_cur) {
+ if (min_cur > min)
+ min = min_cur;
- if (max_cur != GST_CLOCK_TIME_NONE &&
- ((max != GST_CLOCK_TIME_NONE && max_cur > max) ||
- (max == GST_CLOCK_TIME_NONE)))
- max = max_cur;
+ if (max == GST_CLOCK_TIME_NONE)
+ max = max_cur;
+ else if (max_cur < max)
+ max = max_cur;
- live = live || live_cur;
+ live = TRUE;
+ }
}
gst_query_unref (peerquery);
diff --git a/gst/rtsp/gstrtpdec.c b/gst/rtsp/gstrtpdec.c
index b59aa5dfd..e24927bf4 100644
--- a/gst/rtsp/gstrtpdec.c
+++ b/gst/rtsp/gstrtpdec.c
@@ -372,6 +372,7 @@ gst_rtp_dec_query_src (GstPad * pad, GstObject * parent, GstQuery * query)
case GST_QUERY_LATENCY:
{
/* we pretend to be live with a 3 second latency */
+ /* FIXME: Do we really have infinite maximum latency? */
gst_query_set_latency (query, TRUE, 3 * GST_SECOND, -1);
res = TRUE;
break;
diff --git a/gst/videomixer/videomixer2.c b/gst/videomixer/videomixer2.c
index abb18f8ab..e3956458a 100644
--- a/gst/videomixer/videomixer2.c
+++ b/gst/videomixer/videomixer2.c
@@ -1472,15 +1472,17 @@ gst_videomixer2_query_latency (GstVideoMixer2 * mix, GstQuery * query)
if (res) {
gst_query_parse_latency (peerquery, &live_cur, &min_cur, &max_cur);
- if (min_cur > min)
- min = min_cur;
+ if (live_cur) {
+ if (min_cur > min)
+ min = min_cur;
- if (max_cur != GST_CLOCK_TIME_NONE &&
- ((max != GST_CLOCK_TIME_NONE && max_cur > max) ||
- (max == GST_CLOCK_TIME_NONE)))
- max = max_cur;
+ if (max == GST_CLOCK_TIME_NONE)
+ max = max_cur;
+ else if (max_cur < max)
+ max = max_cur;
- live = live || live_cur;
+ live = TRUE;
+ }
}
gst_query_unref (peerquery);