mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-17 22:06:41 +00:00
camerabin: update unit test to have test on recording snapshot preview
Adds a small check to verify that the preview image message is being sent on video recording.
This commit is contained in:
parent
2c05df08b2
commit
3b6faa6404
1 changed files with 31 additions and 0 deletions
|
@ -25,6 +25,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <glib.h>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/check/gstcheck.h>
|
#include <gst/check/gstcheck.h>
|
||||||
#include <gst/interfaces/photography.h>
|
#include <gst/interfaces/photography.h>
|
||||||
|
@ -40,6 +41,7 @@
|
||||||
static GstElement *camera;
|
static GstElement *camera;
|
||||||
static GMainLoop *main_loop;
|
static GMainLoop *main_loop;
|
||||||
static guint cycle_count = 0;
|
static guint cycle_count = 0;
|
||||||
|
static gboolean received_preview_msg = FALSE;
|
||||||
|
|
||||||
/* helper function for filenames */
|
/* helper function for filenames */
|
||||||
static const gchar *
|
static const gchar *
|
||||||
|
@ -201,6 +203,23 @@ capture_bus_cb (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstBusSyncReply
|
||||||
|
bus_sync_callback (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
|
{
|
||||||
|
const GstStructure *st;
|
||||||
|
st = gst_message_get_structure (message);
|
||||||
|
if (st) {
|
||||||
|
if (gst_structure_has_name (st, "preview-image")) {
|
||||||
|
GST_DEBUG ("get preview-image message");
|
||||||
|
received_preview_msg = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return GST_BUS_PASS;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup (void)
|
setup (void)
|
||||||
{
|
{
|
||||||
|
@ -221,6 +240,7 @@ setup (void)
|
||||||
|
|
||||||
bus = gst_pipeline_get_bus (GST_PIPELINE (camera));
|
bus = gst_pipeline_get_bus (GST_PIPELINE (camera));
|
||||||
gst_bus_add_watch (bus, (GstBusFunc) capture_bus_cb, main_loop);
|
gst_bus_add_watch (bus, (GstBusFunc) capture_bus_cb, main_loop);
|
||||||
|
gst_bus_set_sync_handler (bus, bus_sync_callback, main_loop);
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
|
|
||||||
filter_caps = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)I420");
|
filter_caps = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)I420");
|
||||||
|
@ -429,6 +449,9 @@ GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_video_recording)
|
GST_START_TEST (test_video_recording)
|
||||||
{
|
{
|
||||||
|
GstCaps *preview_caps;
|
||||||
|
preview_caps = gst_caps_from_string ("video/x-raw-rgb,width=320,height=240");
|
||||||
|
|
||||||
if (!camera)
|
if (!camera)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -436,11 +459,19 @@ GST_START_TEST (test_video_recording)
|
||||||
g_object_set (camera, "mode", 1,
|
g_object_set (camera, "mode", 1,
|
||||||
"filename", make_test_file_name (VIDEO_FILENAME), NULL);
|
"filename", make_test_file_name (VIDEO_FILENAME), NULL);
|
||||||
|
|
||||||
|
/*Set preview-caps */
|
||||||
|
g_object_set (camera, "preview-caps", preview_caps, NULL);
|
||||||
|
|
||||||
GST_INFO ("starting capture");
|
GST_INFO ("starting capture");
|
||||||
g_signal_emit_by_name (camera, "capture-start", NULL);
|
g_signal_emit_by_name (camera, "capture-start", NULL);
|
||||||
/* Record for one seconds */
|
/* Record for one seconds */
|
||||||
g_usleep (G_USEC_PER_SEC);
|
g_usleep (G_USEC_PER_SEC);
|
||||||
g_signal_emit_by_name (camera, "capture-stop", NULL);
|
g_signal_emit_by_name (camera, "capture-stop", NULL);
|
||||||
|
|
||||||
|
/*check if receiving the preview-image message */
|
||||||
|
fail_if (!received_preview_msg,
|
||||||
|
"creating video recording preview image failed");
|
||||||
|
|
||||||
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
|
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue