mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 19:20:35 +00:00
test: port schroenc unit test
This commit is contained in:
parent
db64b868ff
commit
5e132060c2
1 changed files with 18 additions and 13 deletions
|
@ -31,8 +31,8 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|||
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("video/x-raw-yuv, "
|
||||
"format = (fourcc) I420, "
|
||||
GST_STATIC_CAPS ("video/x-raw, "
|
||||
"format = (string) I420, "
|
||||
"width = (int) [1, MAX], "
|
||||
"height = (int) [1, MAX], " "framerate = (fraction) [0, MAX]"));
|
||||
|
||||
|
@ -52,11 +52,13 @@ setup_schroenc (const gchar * src_caps_str)
|
|||
|
||||
schroenc = gst_check_setup_element ("schroenc");
|
||||
fail_unless (schroenc != NULL);
|
||||
srcpad = gst_check_setup_src_pad (schroenc, &srctemplate, srccaps);
|
||||
sinkpad = gst_check_setup_sink_pad (schroenc, &sinktemplate, NULL);
|
||||
srcpad = gst_check_setup_src_pad (schroenc, &srctemplate);
|
||||
sinkpad = gst_check_setup_sink_pad (schroenc, &sinktemplate);
|
||||
gst_pad_set_active (srcpad, TRUE);
|
||||
gst_pad_set_active (sinkpad, TRUE);
|
||||
|
||||
gst_pad_set_caps (srcpad, srccaps);
|
||||
|
||||
bus = gst_bus_new ();
|
||||
gst_element_set_bus (schroenc, bus);
|
||||
|
||||
|
@ -96,21 +98,22 @@ GST_START_TEST (test_encode_simple)
|
|||
GstBuffer *buffer;
|
||||
gint i;
|
||||
GList *l;
|
||||
GstCaps *outcaps;
|
||||
GstCaps *outcaps, *sinkcaps;
|
||||
GstSegment seg;
|
||||
|
||||
schroenc =
|
||||
setup_schroenc
|
||||
("video/x-raw-yuv,format=(fourcc)I420,width=(int)320,height=(int)240,framerate=(fraction)25/1");
|
||||
("video/x-raw,format=(string)I420,width=(int)320,height=(int)240,framerate=(fraction)25/1");
|
||||
|
||||
g_object_set (schroenc, "queue-depth", 10, NULL);
|
||||
|
||||
fail_unless (gst_pad_push_event (srcpad, gst_event_new_new_segment (FALSE,
|
||||
1.0, GST_FORMAT_TIME, 0, gst_util_uint64_scale (20, GST_SECOND,
|
||||
25), 0)));
|
||||
gst_segment_init (&seg, GST_FORMAT_TIME);
|
||||
seg.stop = gst_util_uint64_scale (20, GST_SECOND, 25);
|
||||
|
||||
buffer = gst_buffer_new_and_alloc (320 * 240 + 2 * 160 * 120);
|
||||
memset (GST_BUFFER_DATA (buffer), 0, GST_BUFFER_SIZE (buffer));
|
||||
gst_buffer_set_caps (buffer, GST_PAD_CAPS (srcpad));
|
||||
fail_unless (gst_pad_push_event (srcpad, gst_event_new_segment (&seg)));
|
||||
|
||||
buffer = gst_buffer_new_allocate (NULL, 320 * 240 + 2 * 160 * 120, 0);
|
||||
gst_buffer_memset (buffer, 0, 0, -1);
|
||||
|
||||
for (i = 0; i < 20; i++) {
|
||||
GST_BUFFER_TIMESTAMP (buffer) = gst_util_uint64_scale (i, GST_SECOND, 25);
|
||||
|
@ -146,7 +149,9 @@ GST_START_TEST (test_encode_simple)
|
|||
fail_unless_equals_uint64 (GST_BUFFER_DURATION (buffer),
|
||||
gst_util_uint64_scale (1, GST_SECOND, 25));
|
||||
|
||||
fail_unless (gst_caps_can_intersect (GST_BUFFER_CAPS (buffer), outcaps));
|
||||
sinkcaps = gst_pad_get_current_caps (sinkpad);
|
||||
fail_unless (gst_caps_can_intersect (sinkcaps, outcaps));
|
||||
gst_caps_unref (sinkcaps);
|
||||
}
|
||||
|
||||
gst_caps_unref (outcaps);
|
||||
|
|
Loading…
Reference in a new issue