mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
tests: fix some tests
This commit is contained in:
parent
fae37396a4
commit
be20e84e39
5 changed files with 44 additions and 62 deletions
|
@ -197,7 +197,7 @@ noinst_HEADERS = elements/mxfdemux.h
|
|||
|
||||
TESTS = $(check_PROGRAMS)
|
||||
|
||||
AM_CFLAGS = $(GST_CHECK_CFLAGS) $(GST_OPTION_CFLAGS) \
|
||||
AM_CFLAGS = $(GST_CFLAGS) $(GST_CHECK_CFLAGS) $(GST_OPTION_CFLAGS) \
|
||||
-DGST_TEST_FILES_PATH="\"$(TEST_FILES_DIRECTORY)\"" \
|
||||
-UG_DISABLE_ASSERT -UG_DISABLE_CAST_CHECKS
|
||||
LDADD = $(GST_CHECK_LIBS)
|
||||
|
@ -207,7 +207,7 @@ noinst_LTLIBRARIES = libparser.la
|
|||
libparser_la_SOURCES = elements/parser.c elements/parser.h
|
||||
libparser_la_CFLAGS = \
|
||||
-I$(top_srcdir)/tests/check \
|
||||
$(GST_CHECK_CFLAGS) $(GST_OPTION_CFLAGS)
|
||||
$(GST_CFLAGS) $(GST_CHECK_CFLAGS) $(GST_OPTION_CFLAGS)
|
||||
|
||||
elements_mpegvideoparse_LDADD = libparser.la $(LDADD)
|
||||
|
||||
|
|
|
@ -55,16 +55,19 @@ buffer_new (const unsigned char *buffer_data, guint size)
|
|||
|
||||
buffer = gst_buffer_new_and_alloc (size);
|
||||
if (buffer_data) {
|
||||
memcpy (GST_BUFFER_DATA (buffer), buffer_data, size);
|
||||
gst_buffer_fill (buffer, 0, buffer_data, size);
|
||||
} else {
|
||||
guint i;
|
||||
guint8 *data;
|
||||
|
||||
/* Create a recognizable pattern (loop 0x00 -> 0xff) in the data block */
|
||||
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
|
||||
for (i = 0; i < size; i++) {
|
||||
GST_BUFFER_DATA (buffer)[i] = i % 0x100;
|
||||
data[i] = i % 0x100;
|
||||
}
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
}
|
||||
|
||||
gst_buffer_set_caps (buffer, GST_PAD_CAPS (srcpad));
|
||||
GST_BUFFER_OFFSET (buffer) = dataoffset;
|
||||
dataoffset += size;
|
||||
return buffer;
|
||||
|
@ -77,7 +80,7 @@ static void
|
|||
buffer_count_size (void *buffer, void *user_data)
|
||||
{
|
||||
guint *sum = (guint *) user_data;
|
||||
*sum += GST_BUFFER_SIZE (buffer);
|
||||
*sum += gst_buffer_get_size (buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -99,7 +102,7 @@ buffer_verify_data (void *buffer, void *user_data)
|
|||
if (ctx_verify_buffer)
|
||||
ctx_verify_buffer (vdata, buffer);
|
||||
vdata->buffer_counter++;
|
||||
vdata->offset_counter += GST_BUFFER_SIZE (buffer);
|
||||
vdata->offset_counter += gst_buffer_get_size (buffer);
|
||||
if (vdata->buffer_counter == vdata->discard) {
|
||||
vdata->buffer_counter = 0;
|
||||
vdata->discard = 0;
|
||||
|
@ -108,8 +111,8 @@ buffer_verify_data (void *buffer, void *user_data)
|
|||
}
|
||||
|
||||
if (!ctx_verify_buffer || !ctx_verify_buffer (vdata, buffer)) {
|
||||
fail_unless (GST_BUFFER_SIZE (buffer) == vdata->data_to_verify_size);
|
||||
fail_unless (memcmp (GST_BUFFER_DATA (buffer), vdata->data_to_verify,
|
||||
fail_unless (gst_buffer_get_size (buffer) == vdata->data_to_verify_size);
|
||||
fail_unless (gst_buffer_memcmp (buffer, 0, vdata->data_to_verify,
|
||||
vdata->data_to_verify_size) == 0);
|
||||
}
|
||||
|
||||
|
@ -125,14 +128,8 @@ buffer_verify_data (void *buffer, void *user_data)
|
|||
fail_unless (GST_BUFFER_OFFSET (buffer) == vdata->offset_counter);
|
||||
}
|
||||
|
||||
if (vdata->caps) {
|
||||
GST_LOG ("%" GST_PTR_FORMAT " = %" GST_PTR_FORMAT " ?",
|
||||
GST_BUFFER_CAPS (buffer), vdata->caps);
|
||||
fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), vdata->caps));
|
||||
}
|
||||
|
||||
vdata->ts_counter += GST_BUFFER_DURATION (buffer);
|
||||
vdata->offset_counter += GST_BUFFER_SIZE (buffer);
|
||||
vdata->offset_counter += gst_buffer_get_size (buffer);
|
||||
vdata->buffer_counter++;
|
||||
}
|
||||
|
||||
|
@ -246,14 +243,8 @@ gst_parser_test_run (GstParserTest * test, GstCaps ** out_caps)
|
|||
if (!k)
|
||||
buffer = buffer_new (test->series[j].data, test->series[j].size);
|
||||
else {
|
||||
GstCaps *caps = gst_buffer_get_caps (buffer);
|
||||
|
||||
buffer = gst_buffer_join (buffer,
|
||||
buffer_new (test->series[j].data, test->series[j].size));
|
||||
if (caps) {
|
||||
gst_buffer_set_caps (buffer, caps);
|
||||
gst_caps_unref (caps);
|
||||
}
|
||||
}
|
||||
}
|
||||
fail_unless_equals_int (gst_pad_push (srcpad, buffer), GST_FLOW_OK);
|
||||
|
@ -292,7 +283,7 @@ gst_parser_test_run (GstParserTest * test, GstCaps ** out_caps)
|
|||
fail_unless_equals_int (datasum, size);
|
||||
}
|
||||
|
||||
src_caps = gst_pad_get_negotiated_caps (sinkpad);
|
||||
src_caps = gst_pad_get_current_caps (sinkpad);
|
||||
GST_LOG ("output caps: %" GST_PTR_FORMAT, src_caps);
|
||||
|
||||
if (test->sink_caps) {
|
||||
|
|
|
@ -171,15 +171,16 @@ static const gchar *test_names[TEST_CASES] = {
|
|||
static void print_result (void);
|
||||
static gboolean run_test (gpointer user_data);
|
||||
static gboolean setup_add_pad_probe (GstElement * elem, const gchar * pad_name,
|
||||
GCallback handler, gpointer data);
|
||||
GstPadProbeCallback handler, gpointer data);
|
||||
|
||||
|
||||
/*
|
||||
* Callbacks
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
pad_has_buffer (GstPad * pad, GstBuffer * buf, gpointer user_data)
|
||||
static GstProbeReturn
|
||||
pad_has_buffer (GstPad * pad, GstProbeType type, gpointer type_data,
|
||||
gpointer user_data)
|
||||
{
|
||||
gboolean *signal_sink = (gboolean *) user_data;
|
||||
gboolean print_and_restart = FALSE;
|
||||
|
@ -209,7 +210,7 @@ pad_has_buffer (GstPad * pad, GstBuffer * buf, gpointer user_data)
|
|||
print_result ();
|
||||
g_idle_add ((GSourceFunc) run_test, NULL);
|
||||
}
|
||||
return TRUE;
|
||||
return GST_PROBE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -227,8 +228,7 @@ element_added (GstBin * bin, GstElement * element, gpointer user_data)
|
|||
if (elem) {
|
||||
need_vmux_pad_probe = FALSE;
|
||||
GST_INFO_OBJECT (elem, "got default video muxer");
|
||||
if (setup_add_pad_probe (elem, "src", (GCallback) pad_has_buffer,
|
||||
&signal_vid_sink)) {
|
||||
if (setup_add_pad_probe (elem, "src", pad_has_buffer, &signal_vid_sink)) {
|
||||
/* enable test */
|
||||
target[8] = test_09_taget;
|
||||
}
|
||||
|
@ -239,8 +239,7 @@ element_added (GstBin * bin, GstElement * element, gpointer user_data)
|
|||
if (elem) {
|
||||
need_ienc_pad_probe = FALSE;
|
||||
GST_INFO_OBJECT (elem, "got default image encoder");
|
||||
if (setup_add_pad_probe (elem, "src", (GCallback) pad_has_buffer,
|
||||
&signal_img_enc)) {
|
||||
if (setup_add_pad_probe (elem, "src", pad_has_buffer, &signal_img_enc)) {
|
||||
/* enable test */
|
||||
target[5] = test_06_taget;
|
||||
}
|
||||
|
@ -480,7 +479,7 @@ cleanup_pipeline (void)
|
|||
|
||||
static gboolean
|
||||
setup_add_pad_probe (GstElement * elem, const gchar * pad_name,
|
||||
GCallback handler, gpointer data)
|
||||
GstPadProbeCallback handler, gpointer data)
|
||||
{
|
||||
GstPad *pad = NULL;
|
||||
|
||||
|
@ -489,7 +488,8 @@ setup_add_pad_probe (GstElement * elem, const gchar * pad_name,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
gst_pad_add_buffer_probe (pad, (GCallback) handler, data);
|
||||
gst_pad_add_probe (pad, GST_PROBE_TYPE_BLOCK | GST_PROBE_TYPE_BUFFER, handler,
|
||||
data, NULL);
|
||||
gst_object_unref (pad);
|
||||
|
||||
return TRUE;
|
||||
|
@ -567,13 +567,12 @@ setup_pipeline (void)
|
|||
/* set properties */
|
||||
g_object_set (camera_bin, "filename", filename->str, NULL);
|
||||
|
||||
if (src_csp && strlen (src_csp) == 4) {
|
||||
if (src_csp) {
|
||||
GstCaps *filter_caps;
|
||||
|
||||
/* FIXME: why do we need to set this? */
|
||||
filter_caps = gst_caps_new_simple ("video/x-raw-yuv",
|
||||
"format", GST_TYPE_FOURCC,
|
||||
GST_MAKE_FOURCC (src_csp[0], src_csp[1], src_csp[2], src_csp[3]), NULL);
|
||||
filter_caps = gst_caps_new_simple ("video/x-raw",
|
||||
"format", G_TYPE_STRING, src_csp, NULL);
|
||||
if (filter_caps) {
|
||||
g_object_set (camera_bin, "filter-caps", filter_caps, NULL);
|
||||
gst_caps_unref (filter_caps);
|
||||
|
@ -589,8 +588,7 @@ setup_pipeline (void)
|
|||
|
||||
/* connect signal handlers */
|
||||
g_assert (sink);
|
||||
if (!setup_add_pad_probe (sink, "sink", (GCallback) pad_has_buffer,
|
||||
&signal_vf_sink)) {
|
||||
if (!setup_add_pad_probe (sink, "sink", pad_has_buffer, &signal_vf_sink)) {
|
||||
goto error;
|
||||
}
|
||||
if (!vmux) {
|
||||
|
@ -603,8 +601,7 @@ setup_pipeline (void)
|
|||
}
|
||||
}
|
||||
if (vmux) {
|
||||
if (!setup_add_pad_probe (vmux, "src", (GCallback) pad_has_buffer,
|
||||
&signal_vid_sink)) {
|
||||
if (!setup_add_pad_probe (vmux, "src", pad_has_buffer, &signal_vid_sink)) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -618,8 +615,7 @@ setup_pipeline (void)
|
|||
}
|
||||
}
|
||||
if (ienc) {
|
||||
if (!setup_add_pad_probe (ienc, "src", (GCallback) pad_has_buffer,
|
||||
&signal_img_enc)) {
|
||||
if (!setup_add_pad_probe (ienc, "src", pad_has_buffer, &signal_img_enc)) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "gst-camera.h"
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/interfaces/xoverlay.h>
|
||||
#include <gst/interfaces/videooverlay.h>
|
||||
#include <gst/interfaces/colorbalance.h>
|
||||
#include <gst/interfaces/photography.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
#define GST_USE_UNSTABLE_API 1
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/interfaces/xoverlay.h>
|
||||
#include <gst/interfaces/videooverlay.h>
|
||||
#include <gst/interfaces/photography.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -240,8 +240,7 @@ sync_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
|||
const GValue *image;
|
||||
GstBuffer *buf = NULL;
|
||||
guint8 *data_buf = NULL;
|
||||
gchar *caps_string;
|
||||
guint size = 0;
|
||||
gsize size = 0;
|
||||
gchar *preview_filename = NULL;
|
||||
FILE *f = NULL;
|
||||
size_t written;
|
||||
|
@ -250,10 +249,10 @@ sync_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
|||
case GST_MESSAGE_ELEMENT:{
|
||||
st = gst_message_get_structure (message);
|
||||
if (st) {
|
||||
if (gst_structure_has_name (message->structure, "prepare-xwindow-id")) {
|
||||
if (gst_structure_has_name (st, "prepare-xwindow-id")) {
|
||||
if (!no_xwindow && window) {
|
||||
gst_x_overlay_set_window_handle (GST_X_OVERLAY (GST_MESSAGE_SRC
|
||||
(message)), window);
|
||||
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY
|
||||
(GST_MESSAGE_SRC (message)), window);
|
||||
gst_message_unref (message);
|
||||
message = NULL;
|
||||
return GST_BUS_DROP;
|
||||
|
@ -266,13 +265,10 @@ sync_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
|||
image = gst_structure_get_value (st, "buffer");
|
||||
if (image) {
|
||||
buf = gst_value_get_buffer (image);
|
||||
data_buf = GST_BUFFER_DATA (buf);
|
||||
size = GST_BUFFER_SIZE (buf);
|
||||
data_buf = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
preview_filename = g_strdup_printf ("test_vga.rgb");
|
||||
caps_string = gst_caps_to_string (GST_BUFFER_CAPS (buf));
|
||||
g_print ("writing buffer to %s, elapsed: %.2fs, buffer caps: %s\n",
|
||||
preview_filename, g_timer_elapsed (timer, NULL), caps_string);
|
||||
g_free (caps_string);
|
||||
g_print ("writing buffer to %s, elapsed: %.2fs\n",
|
||||
preview_filename, g_timer_elapsed (timer, NULL));
|
||||
f = g_fopen (preview_filename, "w");
|
||||
if (f) {
|
||||
written = fwrite (data_buf, size, 1, f);
|
||||
|
@ -284,6 +280,7 @@ sync_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
|
|||
g_print ("error opening file for raw image writing\n");
|
||||
}
|
||||
g_free (preview_filename);
|
||||
gst_buffer_unmap (buf, data_buf, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -526,12 +523,11 @@ setup_pipeline (void)
|
|||
/* set properties */
|
||||
if (src_format) {
|
||||
filter_caps = gst_caps_from_string (src_format);
|
||||
} else if (src_csp && strlen (src_csp) == 4) {
|
||||
} else if (src_csp) {
|
||||
/* Set requested colorspace format, this is needed if the default
|
||||
colorspace negotiated for viewfinder doesn't match with e.g. encoders. */
|
||||
filter_caps = gst_caps_new_simple ("video/x-raw-yuv",
|
||||
"format", GST_TYPE_FOURCC,
|
||||
GST_MAKE_FOURCC (src_csp[0], src_csp[1], src_csp[2], src_csp[3]), NULL);
|
||||
filter_caps = gst_caps_new_simple ("video/x-raw",
|
||||
"format", G_TYPE_STRING, src_csp, NULL);
|
||||
}
|
||||
|
||||
if (filter_caps) {
|
||||
|
@ -646,8 +642,7 @@ run_pipeline (gpointer user_data)
|
|||
|
||||
g_object_get (camera_bin, "video-source", &video_source, NULL);
|
||||
if (video_source) {
|
||||
if (GST_IS_ELEMENT (video_source) &&
|
||||
gst_element_implements_interface (video_source, GST_TYPE_PHOTOGRAPHY)) {
|
||||
if (GST_IS_ELEMENT (video_source) && GST_IS_PHOTOGRAPHY (video_source)) {
|
||||
/* Set GstPhotography interface options. If option not given as
|
||||
command-line parameter use default of the source element. */
|
||||
if (scene_mode != SCENE_MODE_NONE)
|
||||
|
|
Loading…
Reference in a new issue