summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2020-07-16 16:25:15 -0400
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>2020-07-20 22:05:57 +0000
commitcb6edaf6f81a55642be43c36c284b1b663b51c00 (patch)
treeaaaa9da2d17bb51e31c2ae50c146670fc07fd22a
parent90ff086a4372ab5ad6374544dfbefcb23ff66a24 (diff)
downloadgstreamer-plugins-base-cb6edaf6f81a55642be43c36c284b1b663b51c00.tar.gz
videorate: Error out on streams with no way to guess framerate
This is better than going into an infinite loop. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/761>
-rw-r--r--gst/videorate/gstvideorate.c8
-rw-r--r--tests/check/elements/videorate.c29
2 files changed, 11 insertions, 26 deletions
diff --git a/gst/videorate/gstvideorate.c b/gst/videorate/gstvideorate.c
index a80453fc2..ea99e00ee 100644
--- a/gst/videorate/gstvideorate.c
+++ b/gst/videorate/gstvideorate.c
@@ -1469,6 +1469,14 @@ gst_video_rate_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
if (videorate->to_rate_numerator == 0 && videorate->prevbuf &&
!videorate->force_variable_rate) {
+ if (!GST_BUFFER_PTS_IS_VALID (buffer) ||
+ !GST_BUFFER_PTS_IS_VALID (videorate->prevbuf)) {
+ GST_ELEMENT_ERROR (videorate, STREAM, FAILED, (NULL),
+ ("videorate requires a non-variable framerate on the output caps or the"
+ " two first consecutive buffers to have valid timestamps to guess the"
+ " framerate."));
+ return GST_FLOW_ERROR;
+ }
gst_video_rate_check_variable_rate (videorate, buffer);
}
diff --git a/tests/check/elements/videorate.c b/tests/check/elements/videorate.c
index 3d2ef460c..19c15f960 100644
--- a/tests/check/elements/videorate.c
+++ b/tests/check/elements/videorate.c
@@ -1540,7 +1540,7 @@ GST_END_TEST;
GST_START_TEST (test_nopts_in_middle)
{
GstElement *videorate;
- GstBuffer *first, *second, *third;
+ GstBuffer *first, *second;
GstCaps *caps;
videorate =
@@ -1576,33 +1576,10 @@ GST_START_TEST (test_nopts_in_middle)
gst_buffer_ref (second);
/* pushing gives away my reference ... */
- fail_unless (gst_pad_push (mysrcpad, second) == GST_FLOW_OK);
- /* ... and the first one should have been pushed out */
+ fail_unless (gst_pad_push (mysrcpad, second) == GST_FLOW_ERROR);
ASSERT_BUFFER_REFCOUNT (second, "second", 1);
- fail_unless_equals_int (g_list_length (buffers), 1);
-
- /* ... and the first one was replaced */
- assert_videorate_stats (videorate, "second", 2, 1, 0, 0);
- ASSERT_BUFFER_REFCOUNT (first, "first", 1);
-
- /* third buffer */
- third = gst_buffer_new_and_alloc (4);
- GST_BUFFER_TIMESTAMP (third) = 2 * GST_SECOND;
- gst_buffer_memset (third, 0, 0, 4);
- ASSERT_BUFFER_REFCOUNT (third, "third", 1);
- gst_buffer_ref (third);
-
- /* pushing gives away my reference ... */
- fail_unless (gst_pad_push (mysrcpad, third) == GST_FLOW_OK);
- /* ... and a copy is now stuck inside videorate */
- ASSERT_BUFFER_REFCOUNT (third, "third", 1);
+ fail_unless_equals_int (g_list_length (buffers), 0);
- /* and now it should have pushed out the second one */
- fail_unless_equals_int (g_list_length (buffers), 1);
- ASSERT_BUFFER_REFCOUNT (first, "first", 1);
- ASSERT_BUFFER_REFCOUNT (second, "second", 1);
- ASSERT_BUFFER_REFCOUNT (third, "third", 1);
- assert_videorate_stats (videorate, "third", 3, 2, 0, 0);
/* cleanup */
gst_buffer_unref (first);