mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 17:18:15 +00:00
tests: various fixes
... such as setting input caps, ensuring to unmap and bearing in mind that gst_buffer_make_writable usually does not provide a separate memory copy/area.
This commit is contained in:
parent
68300bde0b
commit
0acef1dbe9
6 changed files with 28 additions and 31 deletions
|
@ -141,8 +141,8 @@ check_PROGRAMS = \
|
|||
elements/videorate \
|
||||
elements/videoscale \
|
||||
elements/videotestsrc \
|
||||
elements/volume
|
||||
elements/adder \
|
||||
elements/volume \
|
||||
elements/adder \
|
||||
$(check_theora)
|
||||
|
||||
# TORTURE_TO_FIX = \
|
||||
|
|
|
@ -111,9 +111,6 @@ GST_START_TEST (test_event)
|
|||
bus = gst_element_get_bus (bin);
|
||||
gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
|
||||
|
||||
/* FIXME, fakesrc with default setting will produce 0 sized
|
||||
* buffers and incompatible caps for adder that will make
|
||||
* adder EOS and error out */
|
||||
src1 = gst_element_factory_make ("audiotestsrc", "src1");
|
||||
g_object_set (src1, "wave", 4, NULL); /* silence */
|
||||
src2 = gst_element_factory_make ("audiotestsrc", "src2");
|
||||
|
@ -765,7 +762,7 @@ GST_START_TEST (test_clip)
|
|||
GstFlowReturn ret;
|
||||
GstEvent *event;
|
||||
GstBuffer *buffer;
|
||||
//FIXME: GstCaps *caps;
|
||||
GstCaps *caps;
|
||||
|
||||
GST_INFO ("preparing test");
|
||||
|
||||
|
@ -805,17 +802,22 @@ GST_START_TEST (test_clip)
|
|||
event = gst_event_new_segment (&segment);
|
||||
gst_pad_send_event (sinkpad, event);
|
||||
|
||||
/*FIXME: caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, GST_AUDIO_NE (S16),
|
||||
"rate", G_TYPE_INT, 44100,
|
||||
"channels", G_TYPE_INT, 2, NULL);
|
||||
*/
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
"format", G_TYPE_STRING, "S16BE",
|
||||
#else
|
||||
"format", G_TYPE_STRING, "S16LE",
|
||||
#endif
|
||||
"layout", G_TYPE_STRING, "interleaved",
|
||||
"rate", G_TYPE_INT, 44100, "channels", G_TYPE_INT, 2, NULL);
|
||||
|
||||
gst_pad_set_caps (sinkpad, caps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
/* should be clipped and ok */
|
||||
buffer = gst_buffer_new_and_alloc (44100);
|
||||
GST_BUFFER_TIMESTAMP (buffer) = 0;
|
||||
GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND;
|
||||
//FIXME: gst_buffer_set_caps (buffer, caps);
|
||||
GST_DEBUG ("pushing buffer %p", buffer);
|
||||
ret = gst_pad_chain (sinkpad, buffer);
|
||||
fail_unless (ret == GST_FLOW_OK);
|
||||
|
@ -825,7 +827,6 @@ GST_START_TEST (test_clip)
|
|||
buffer = gst_buffer_new_and_alloc (44100);
|
||||
GST_BUFFER_TIMESTAMP (buffer) = 900 * GST_MSECOND;
|
||||
GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND;
|
||||
//FIXME: gst_buffer_set_caps (buffer, caps);
|
||||
GST_DEBUG ("pushing buffer %p", buffer);
|
||||
ret = gst_pad_chain (sinkpad, buffer);
|
||||
fail_unless (ret == GST_FLOW_OK);
|
||||
|
@ -836,7 +837,6 @@ GST_START_TEST (test_clip)
|
|||
buffer = gst_buffer_new_and_alloc (44100);
|
||||
GST_BUFFER_TIMESTAMP (buffer) = 1 * GST_SECOND;
|
||||
GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND;
|
||||
//FIXME: gst_buffer_set_caps (buffer, caps);
|
||||
GST_DEBUG ("pushing buffer %p", buffer);
|
||||
ret = gst_pad_chain (sinkpad, buffer);
|
||||
fail_unless (ret == GST_FLOW_OK);
|
||||
|
@ -847,7 +847,6 @@ GST_START_TEST (test_clip)
|
|||
buffer = gst_buffer_new_and_alloc (44100);
|
||||
GST_BUFFER_TIMESTAMP (buffer) = 2 * GST_SECOND;
|
||||
GST_BUFFER_DURATION (buffer) = 250 * GST_MSECOND;
|
||||
//FIXME: gst_buffer_set_caps (buffer, caps);
|
||||
GST_DEBUG ("pushing buffer %p", buffer);
|
||||
ret = gst_pad_chain (sinkpad, buffer);
|
||||
fail_unless (ret == GST_FLOW_OK);
|
||||
|
|
|
@ -510,6 +510,7 @@ gst_codec_demuxer_setup_pad (GstCodecDemuxer * demux, GstPad ** pad,
|
|||
} else if (g_str_equal (streaminfo, "raw-audio")) {
|
||||
caps = gst_caps_new_simple ("audio/x-raw",
|
||||
"format", G_TYPE_STRING, "S16LE",
|
||||
"layout", G_TYPE_STRING, "interleaved",
|
||||
"rate", G_TYPE_INT, 48000, "channels", G_TYPE_INT, 2, NULL);
|
||||
} else {
|
||||
caps = gst_caps_new_empty_simple ("audio/x-compressed");
|
||||
|
@ -969,7 +970,8 @@ GST_START_TEST (test_raw_single_audio_stream_manual_sink)
|
|||
playbin =
|
||||
create_playbin
|
||||
("caps:audio/x-raw,"
|
||||
" format=(string)S16LE, " " rate=(int)48000, " " channels=(int)2", TRUE);
|
||||
" format=(string)S16LE, " "layout=(string)interleaved, "
|
||||
" rate=(int)48000, " " channels=(int)2", TRUE);
|
||||
|
||||
fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
|
||||
GST_STATE_CHANGE_SUCCESS);
|
||||
|
|
|
@ -139,7 +139,7 @@ static SubParseInputChunk srt_input1[] = {
|
|||
static SubParseInputChunk srt_input2[] = {
|
||||
{
|
||||
"\xef\xbb\xbf" "1\n00:00:00,000 --> 00:00:03,50\nJust testing.\n\n",
|
||||
0, 3 * GST_SECOND + 50 * GST_MSECOND, "Just testing."}
|
||||
0, 3 * GST_SECOND + 500 * GST_MSECOND, "Just testing."}
|
||||
};
|
||||
|
||||
/* starts with chunk number 0 and has less than three digits after the comma
|
||||
|
|
|
@ -177,6 +177,7 @@ buffer_is_all_black (GstBuffer * buf, GstCaps * caps)
|
|||
for (x = 0; x < w; ++x) {
|
||||
if (ptr[x] != 0x00) {
|
||||
GST_LOG ("non-black pixel (%d) at (x,y) %d,%d", ptr[x], x, y);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -533,10 +534,6 @@ GST_START_TEST (test_video_waits_for_text)
|
|||
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
||||
GST_BUFFER_DURATION (inbuffer) = GST_SECOND / 2;
|
||||
|
||||
/* take additional ref to keep it alive */
|
||||
gst_buffer_ref (inbuffer);
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 2);
|
||||
|
||||
/* pushing gives away one of the two references we have ... */
|
||||
GST_LOG ("pushing video buffer 1");
|
||||
fail_unless (gst_pad_push (myvideosrcpad, inbuffer) == GST_FLOW_OK);
|
||||
|
@ -549,18 +546,19 @@ GST_START_TEST (test_video_waits_for_text)
|
|||
|
||||
/* there should be no text rendered */
|
||||
outbuffer = GST_BUFFER_CAST (buffers->data);
|
||||
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
|
||||
outcaps = gst_pad_get_current_caps (mysinkpad);
|
||||
fail_unless (buffer_is_all_black (outbuffer, outcaps));
|
||||
gst_caps_unref (outcaps);
|
||||
|
||||
/* now, another video buffer */
|
||||
inbuffer = gst_buffer_make_writable (inbuffer);
|
||||
inbuffer = create_black_buffer (incaps);
|
||||
GST_BUFFER_TIMESTAMP (inbuffer) = GST_SECOND;
|
||||
GST_BUFFER_DURATION (inbuffer) = GST_SECOND / 2;
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
||||
/* pushing gives away one of the two references we have ... */
|
||||
GST_LOG ("pushing video buffer 2");
|
||||
gst_buffer_ref (inbuffer);
|
||||
fail_unless (gst_pad_push (myvideosrcpad, inbuffer) == GST_FLOW_OK);
|
||||
|
||||
/* video buffer should have gone right away, with text rendered on it */
|
||||
|
@ -571,12 +569,13 @@ GST_START_TEST (test_video_waits_for_text)
|
|||
|
||||
/* there should be text rendered */
|
||||
outbuffer = GST_BUFFER_CAST (buffers->next->data);
|
||||
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
|
||||
outcaps = gst_pad_get_current_caps (mysinkpad);
|
||||
fail_unless (buffer_is_all_black (outbuffer, outcaps) == FALSE);
|
||||
gst_caps_unref (outcaps);
|
||||
|
||||
/* a third video buffer */
|
||||
inbuffer = gst_buffer_make_writable (inbuffer);
|
||||
inbuffer = create_black_buffer (incaps);
|
||||
GST_BUFFER_TIMESTAMP (inbuffer) = 30 * GST_SECOND;
|
||||
GST_BUFFER_DURATION (inbuffer) = GST_SECOND / 2;
|
||||
|
||||
|
@ -590,7 +589,6 @@ GST_START_TEST (test_video_waits_for_text)
|
|||
fail_unless (thread != NULL);
|
||||
|
||||
GST_LOG ("pushing video buffer 3");
|
||||
gst_buffer_ref (inbuffer);
|
||||
fail_unless (gst_pad_push (myvideosrcpad, inbuffer) == GST_FLOW_OK);
|
||||
|
||||
/* but the text should no longer be stuck in textoverlay */
|
||||
|
@ -601,12 +599,13 @@ GST_START_TEST (test_video_waits_for_text)
|
|||
|
||||
/* ... and there should not be any text rendered on it */
|
||||
outbuffer = GST_BUFFER_CAST (buffers->next->next->data);
|
||||
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
|
||||
outcaps = gst_pad_get_current_caps (mysinkpad);
|
||||
fail_unless (buffer_is_all_black (outbuffer, outcaps));
|
||||
gst_caps_unref (outcaps);
|
||||
|
||||
/* a fourth video buffer */
|
||||
inbuffer = gst_buffer_make_writable (inbuffer);
|
||||
inbuffer = create_black_buffer (incaps);
|
||||
GST_BUFFER_TIMESTAMP (inbuffer) = 35 * GST_SECOND;
|
||||
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
|
||||
|
||||
|
@ -619,18 +618,15 @@ GST_START_TEST (test_video_waits_for_text)
|
|||
fail_unless (thread != NULL);
|
||||
|
||||
GST_LOG ("pushing video buffer 4");
|
||||
gst_buffer_ref (inbuffer);
|
||||
fail_unless (gst_pad_push (myvideosrcpad, inbuffer) == GST_FLOW_FLUSHING);
|
||||
|
||||
/* and clean up */
|
||||
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
|
||||
g_list_free (buffers);
|
||||
buffers = NULL;
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
||||
/* cleanup */
|
||||
cleanup_textoverlay (textoverlay);
|
||||
gst_buffer_unref (inbuffer);
|
||||
|
||||
/* give up our ref, textoverlay should've cleared its queued buffer by now */
|
||||
ASSERT_BUFFER_REFCOUNT (tbuf, "tbuf", 1);
|
||||
|
|
|
@ -36,9 +36,9 @@
|
|||
|
||||
#define check_buffer_is_header(buffer,is_header) \
|
||||
fail_unless (GST_BUFFER_FLAG_IS_SET (buffer, \
|
||||
GST_BUFFER_FLAG_IN_CAPS) == is_header, \
|
||||
GST_BUFFER_FLAG_HEADER) == is_header, \
|
||||
"GST_BUFFER_IN_CAPS is set to %d but expected %d", \
|
||||
GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS), is_header)
|
||||
GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_HEADER), is_header)
|
||||
|
||||
#define check_buffer_timestamp(buffer,timestamp) \
|
||||
fail_unless (GST_BUFFER_TIMESTAMP (buffer) == timestamp, \
|
||||
|
|
Loading…
Reference in a new issue