static GMainLoop *main_loop;
static gint capture_count = 0;
guint32 test_id = 0;
-static const gchar *image_filename;
-static const gchar *video_filename;
+static gchar *image_filename;
+static gchar *video_filename;
static GstBuffer *preview_buffer;
static gchar *preview_filename;
/* helper function for filenames */
-static const gchar *
+static gchar *
make_test_file_name (const gchar * base_name, gint num)
{
- static gchar file_name[1000];
-
/* num == -1 means to keep the %d in the resulting string to be used on
* multifilesink like location */
if (num == -1) {
- g_snprintf (file_name, 999, "%s" G_DIR_SEPARATOR_S
+ return g_strdup_printf ("%s" G_DIR_SEPARATOR_S
"gstcamerabin2test_%s_%u_%%03d.cap", g_get_tmp_dir (), base_name,
test_id);
} else {
- g_snprintf (file_name, 999, "%s" G_DIR_SEPARATOR_S
+ return g_strdup_printf ("%s" G_DIR_SEPARATOR_S
"gstcamerabin2test_%s_%u_%03d.cap", g_get_tmp_dir (), base_name,
test_id, num);
}
+}
+
+static const gchar *
+make_const_file_name (const gchar * filename, gint num)
+{
+ static gchar file_name[1000];
+
+ /* num == -1 means to keep the %d in the resulting string to be used on
+ * multifilesink like location */
+ g_snprintf (file_name, 999, filename, num);
- GST_INFO ("capturing to: %s", file_name);
return file_name;
}
{
GstBus *bus;
GMainLoop *loop = g_main_loop_new (NULL, FALSE);
- const gchar *filepath = make_test_file_name (filename, num);
+ const gchar *filepath = make_const_file_name (filename, num);
gchar *pipeline_str = g_strdup_printf ("filesrc location=%s ! "
"jpegparse ! fakesink", filepath);
GstElement *pipeline;
gst_tag_list_free (tags_found);
tags_found = NULL;
+ g_free (video_filename);
+ g_free (image_filename);
+ video_filename = NULL;
+ image_filename = NULL;
+
GST_INFO ("done");
}
GstElement *playbin = gst_element_factory_make ("playbin2", NULL);
GstElement *fakevideo = gst_element_factory_make ("fakesink", NULL);
GstElement *fakeaudio = gst_element_factory_make ("fakesink", NULL);
- gchar *uri = g_strconcat ("file://", make_test_file_name (filename, num),
+ gchar *uri = g_strconcat ("file://", make_const_file_name (filename, num),
NULL);
GST_DEBUG ("checking uri: %s", uri);
g_object_get (camera, "idle", &idle, NULL);
fail_unless (idle);
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
- check_file_validity (IMAGE_FILENAME, 0, NULL, 0, 0, NO_AUDIO);
+ check_file_validity (image_filename, 0, NULL, 0, 0, NO_AUDIO);
}
GST_END_TEST;
fail_unless (idle);
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
for (i = 0; i < 3; i++) {
- check_file_validity (IMAGE_FILENAME, i, NULL, widths[i], heights[i],
+ check_file_validity (image_filename, i, NULL, widths[i], heights[i],
NO_AUDIO);
}
}
fail_unless (idle);
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
- check_file_validity (VIDEO_FILENAME, 0, NULL, 0, 0, WITH_AUDIO);
+ check_file_validity (video_filename, 0, NULL, 0, 0, WITH_AUDIO);
}
GST_END_TEST;
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
for (i = 0; i < 3; i++) {
- check_file_validity (VIDEO_FILENAME, i, NULL, widths[i], heights[i],
+ check_file_validity (video_filename, i, NULL, widths[i], heights[i],
WITH_AUDIO);
}
}
g_object_get (camera, "idle", &idle, NULL);
fail_unless (idle);
- img_filename = make_test_file_name (IMAGE_FILENAME, i);
- vid_filename = make_test_file_name (VIDEO_FILENAME, i);
-
/* take a picture */
+ img_filename = make_const_file_name (image_filename, i);
g_object_set (camera, "mode", 1, NULL);
g_object_set (camera, "location", img_filename, NULL);
g_signal_emit_by_name (camera, "start-capture", NULL);
check_preview_image (camera, img_filename, i);
/* now go to video */
+ vid_filename = make_const_file_name (video_filename, i);
g_object_set (camera, "mode", 2, NULL);
g_object_set (camera, "location", vid_filename, NULL);
/* validate all the files */
for (i = 0; i < 2; i++) {
- check_file_validity (IMAGE_FILENAME, i, NULL, 0, 0, NO_AUDIO);
- check_file_validity (VIDEO_FILENAME, i, NULL, 0, 0, WITH_AUDIO);
+ check_file_validity (image_filename, i, NULL, 0, 0, NO_AUDIO);
+ check_file_validity (video_filename, i, NULL, 0, 0, WITH_AUDIO);
}
}
GST_TAG_GEO_LOCATION_ELEVATION, 0.0, NULL);
/* set still image mode */
- g_object_set (camera, "mode", 1,
- "location", make_test_file_name (IMAGE_FILENAME, -1), NULL);
+ g_object_set (camera, "mode", 1, "location", image_filename, NULL);
if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE) {
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
for (i = 0; i < 3; i++) {
- check_file_validity (IMAGE_FILENAME, i, taglists[i], 0, 0, NO_AUDIO);
+ check_file_validity (image_filename, i, taglists[i], 0, 0, NO_AUDIO);
gst_tag_list_free (taglists[i]);
}
}
taglists[2] = gst_tag_list_new_full (GST_TAG_COMMENT, "test3", NULL);
/* set video mode */
- g_object_set (camera, "mode", 2,
- "location", make_test_file_name (VIDEO_FILENAME, -1), NULL);
+ g_object_set (camera, "mode", 2, "location", video_filename, NULL);
/* set a profile that has xmp support for more tags being saved */
{
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
for (i = 0; i < 3; i++) {
- check_file_validity (VIDEO_FILENAME, i, taglists[i], 0, 0, NO_AUDIO);
+ check_file_validity (video_filename, i, taglists[i], 0, 0, NO_AUDIO);
gst_tag_list_free (taglists[i]);
}
}
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
- check_file_validity (VIDEO_FILENAME, 0, NULL, 0, 0, WITH_AUDIO);
+ check_file_validity (video_filename, 0, NULL, 0, 0, WITH_AUDIO);
}
GST_END_TEST;
check_preview_image (camera, image_filename, 0);
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
- check_file_validity (IMAGE_FILENAME, 0, NULL, 0, 0, NO_AUDIO);
+ check_file_validity (image_filename, 0, NULL, 0, 0, NO_AUDIO);
fail_unless (vf_probe_counter > 0);
fail_unless (image_probe_counter == 1);
check_preview_image (camera, video_filename, 0);
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
- check_file_validity (VIDEO_FILENAME, 0, NULL, 0, 0, WITH_AUDIO);
+ check_file_validity (video_filename, 0, NULL, 0, 0, WITH_AUDIO);
fail_unless (vf_probe_counter > 0);
fail_unless (video_probe_counter > 0);
g_object_get (camera, "camera-source", &src, NULL);
for (i = 0; i < LOCATION_SWITCHING_FILENAMES_COUNT; i++) {
- filenames[i] =
- g_strdup (make_test_file_name ("image-switching-filename-test", i));
+ filenames[i] = make_test_file_name ("image-switching-filename-test", i);
}
filenames[LOCATION_SWITCHING_FILENAMES_COUNT] = NULL;