Merge branch 'master' into 0.11

This commit is contained in:
Wim Taymans 2011-10-03 11:24:04 +02:00
commit d26f7319e9
8 changed files with 204 additions and 129 deletions

View File

@ -571,6 +571,12 @@ gst_kate_tiger_kate_chain (GstPad * pad, GstBuffer * buf)
GST_LOG_OBJECT (tiger, "Got kate buffer, caps %" GST_PTR_FORMAT, GST_LOG_OBJECT (tiger, "Got kate buffer, caps %" GST_PTR_FORMAT,
GST_BUFFER_CAPS (buf)); GST_BUFFER_CAPS (buf));
/* Now that we have the lock, check if we're flushing */
if (tiger->decoder.kate_flushing) {
GST_DEBUG_OBJECT (tiger, "Flushing, disregarding buffer");
goto done;
}
/* Unfortunately, it can happen that the start of the stream is not sent, /* Unfortunately, it can happen that the start of the stream is not sent,
for instance if there's a stream selector upstream, which is switched for instance if there's a stream selector upstream, which is switched
from another Kate stream. If this happens, then we can fallback on the from another Kate stream. If this happens, then we can fallback on the
@ -663,6 +669,7 @@ gst_kate_tiger_kate_chain (GstPad * pad, GstBuffer * buf)
} }
} }
done:
GST_KATE_TIGER_MUTEX_UNLOCK (tiger); GST_KATE_TIGER_MUTEX_UNLOCK (tiger);
gst_object_unref (tiger); gst_object_unref (tiger);
@ -718,6 +725,7 @@ gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf)
GstFlowReturn rflow = GST_FLOW_OK; GstFlowReturn rflow = GST_FLOW_OK;
unsigned char *ptr; unsigned char *ptr;
int ret; int ret;
kate_float t;
GST_KATE_TIGER_MUTEX_LOCK (tiger); GST_KATE_TIGER_MUTEX_LOCK (tiger);
@ -736,45 +744,58 @@ gst_kate_tiger_video_chain (GstPad * pad, GstBuffer * buf)
g_cond_broadcast (tiger->cond); g_cond_broadcast (tiger->cond);
} }
/* draw on it */ /* Update first with a dummy buffer pointer we cannot write to. If there is nothing
to draw, we will not have to make it writeable */
ptr = GST_BUFFER_DATA (buf);
ret =
tiger_renderer_set_buffer (tiger->tr, ptr, tiger->video_width,
tiger->video_height, tiger->video_width * 4, tiger->swap_rgb);
if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (tiger,
"Tiger renderer failed to set buffer to video frame: %d", ret);
goto pass;
}
/* update the renderer at the time of the video frame */
t = gst_kate_tiger_get_time (tiger);
GST_LOG_OBJECT (tiger, "Video segment calc: last stop %ld, time %.3f",
(long) tiger->video_segment.last_stop, t);
ret = tiger_renderer_update (tiger->tr, t, 1);
if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (tiger, "Tiger renderer failed to update: %d", ret);
goto pass;
}
/* if there nothing to draw, we can just push the video buffer as is */
if (ret > 0)
goto pass;
/* there is something to draw, so first make the buffer writable */
buf = gst_buffer_make_writable (buf); buf = gst_buffer_make_writable (buf);
if (G_UNLIKELY (!buf)) { if (G_UNLIKELY (!buf)) {
GST_WARNING_OBJECT (tiger, "Failed to make video buffer writable"); GST_WARNING_OBJECT (tiger, "Failed to make video buffer writable");
} else { goto pass;
ptr = GST_BUFFER_DATA (buf);
if (!ptr) {
GST_WARNING_OBJECT (tiger,
"Failed to get a pointer to video buffer data");
} else {
ret =
tiger_renderer_set_buffer (tiger->tr, ptr, tiger->video_width,
tiger->video_height, tiger->video_width * 4, tiger->swap_rgb);
if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (tiger,
"Tiger renderer failed to set buffer to video frame: %d", ret);
} else {
kate_float t = gst_kate_tiger_get_time (tiger);
GST_LOG_OBJECT (tiger, "Video segment calc: last stop %ld, time %.3f",
(long) tiger->video_segment.last_stop, t);
ret = tiger_renderer_update (tiger->tr, t, 1);
if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (tiger, "Tiger renderer failed to update: %d",
ret);
} else {
ret = tiger_renderer_render (tiger->tr);
if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (tiger,
"Tiger renderer failed to render to video frame: %d", ret);
} else {
GST_LOG_OBJECT (tiger,
"Tiger renderer rendered on video frame at %f", t);
}
}
}
}
} }
/* and setup that buffer before rendering */
ptr = GST_BUFFER_DATA (buf);
ret =
tiger_renderer_set_buffer (tiger->tr, ptr, tiger->video_width,
tiger->video_height, tiger->video_width * 4, tiger->swap_rgb);
if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (tiger,
"Tiger renderer failed to set buffer to video frame: %d", ret);
goto pass;
}
ret = tiger_renderer_render (tiger->tr);
if (G_UNLIKELY (ret < 0)) {
GST_WARNING_OBJECT (tiger,
"Tiger renderer failed to render to video frame: %d", ret);
} else {
GST_LOG_OBJECT (tiger, "Tiger renderer rendered on video frame at %f", t);
}
pass:
GST_KATE_TIGER_MUTEX_UNLOCK (tiger); GST_KATE_TIGER_MUTEX_UNLOCK (tiger);
rflow = gst_pad_push (tiger->srcpad, buf); rflow = gst_pad_push (tiger->srcpad, buf);

View File

@ -135,13 +135,11 @@ gst_camerabin_create_preview_pipeline (GstElement * element,
data->pipeline = gst_pipeline_new ("preview-pipeline"); data->pipeline = gst_pipeline_new ("preview-pipeline");
data->appsrc = gst_element_factory_make ("appsrc", "preview-appsrc"); data->appsrc = gst_element_factory_make ("appsrc", "preview-appsrc");
data->capsfilter = gst_element_factory_make ("capsfilter",
"preview-capsfilter");
data->appsink = gst_element_factory_make ("appsink", "preview-appsink"); data->appsink = gst_element_factory_make ("appsink", "preview-appsink");
csp = gst_element_factory_make ("ffmpegcolorspace", "preview-csp"); csp = gst_element_factory_make ("ffmpegcolorspace", "preview-csp");
vscale = gst_element_factory_make ("videoscale", "preview-vscale"); vscale = gst_element_factory_make ("videoscale", "preview-vscale");
if (!data->appsrc || !data->capsfilter || !data->appsink || !csp || !vscale) { if (!data->appsrc || !data->appsink || !csp || !vscale) {
goto error; goto error;
} }
@ -149,7 +147,7 @@ gst_camerabin_create_preview_pipeline (GstElement * element,
g_object_set (data->appsink, "sync", FALSE, "enable-last-buffer", g_object_set (data->appsink, "sync", FALSE, "enable-last-buffer",
FALSE, NULL); FALSE, NULL);
gst_bin_add_many (GST_BIN (data->pipeline), data->appsrc, data->capsfilter, gst_bin_add_many (GST_BIN (data->pipeline), data->appsrc,
data->appsink, csp, vscale, NULL); data->appsink, csp, vscale, NULL);
if (filter) if (filter)
gst_bin_add (GST_BIN (data->pipeline), gst_object_ref (filter)); gst_bin_add (GST_BIN (data->pipeline), gst_object_ref (filter));
@ -173,9 +171,6 @@ gst_camerabin_create_preview_pipeline (GstElement * element,
"sink", GST_PAD_LINK_CHECK_NOTHING)); "sink", GST_PAD_LINK_CHECK_NOTHING));
linkfail |= linkfail |=
GST_PAD_LINK_FAILED (gst_element_link_pads_full (csp, "src", GST_PAD_LINK_FAILED (gst_element_link_pads_full (csp, "src",
data->capsfilter, "sink", GST_PAD_LINK_CHECK_NOTHING));
linkfail |=
GST_PAD_LINK_FAILED (gst_element_link_pads_full (data->capsfilter, "src",
data->appsink, "sink", GST_PAD_LINK_CHECK_NOTHING)); data->appsink, "sink", GST_PAD_LINK_CHECK_NOTHING));
if (linkfail) { if (linkfail) {
@ -212,8 +207,6 @@ error:
gst_object_unref (vscale); gst_object_unref (vscale);
if (data->appsrc) if (data->appsrc)
gst_object_unref (data->appsrc); gst_object_unref (data->appsrc);
if (data->capsfilter)
gst_object_unref (data->capsfilter);
if (data->appsink) if (data->appsink)
gst_object_unref (data->appsink); gst_object_unref (data->appsink);
} }
@ -304,7 +297,7 @@ _gst_camerabin_preview_set_caps (GstCameraBinPreviewPipelineData * preview,
pending = GST_STATE_VOID_PENDING; pending = GST_STATE_VOID_PENDING;
} }
gst_element_set_state (preview->pipeline, GST_STATE_NULL); gst_element_set_state (preview->pipeline, GST_STATE_NULL);
g_object_set (preview->capsfilter, "caps", caps, NULL); g_object_set (preview->appsink, "caps", caps, NULL);
if (pending != GST_STATE_VOID_PENDING) if (pending != GST_STATE_VOID_PENDING)
state = pending; state = pending;
gst_element_set_state (preview->pipeline, state); gst_element_set_state (preview->pipeline, state);

View File

@ -35,7 +35,6 @@ typedef struct
GstElement *appsrc; GstElement *appsrc;
GstElement *filter; GstElement *filter;
GstElement *capsfilter;
GstElement *appsink; GstElement *appsink;
GstElement *element; GstElement *element;

View File

@ -363,7 +363,8 @@ static void
gst_camera_bin_start_capture (GstCameraBin2 * camerabin) gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
{ {
const GstTagList *taglist; const GstTagList *taglist;
gint capture_index = camerabin->capture_index;
gchar *location = NULL;
GST_DEBUG_OBJECT (camerabin, "Received start-capture"); GST_DEBUG_OBJECT (camerabin, "Received start-capture");
/* check that we have a valid location */ /* check that we have a valid location */
@ -376,6 +377,9 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
GST_CAMERA_BIN2_PROCESSING_INC (camerabin); GST_CAMERA_BIN2_PROCESSING_INC (camerabin);
if (camerabin->location)
location = g_strdup_printf (camerabin->location, capture_index);
if (camerabin->mode == MODE_VIDEO) { if (camerabin->mode == MODE_VIDEO) {
if (camerabin->audio_src) { if (camerabin->audio_src) {
GstClock *clock = gst_pipeline_get_clock (GST_PIPELINE_CAST (camerabin)); GstClock *clock = gst_pipeline_get_clock (GST_PIPELINE_CAST (camerabin));
@ -396,16 +400,15 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
} }
} }
} else { } else {
gchar *location = NULL;
/* store the next capture buffer filename */ /* store the next capture buffer filename */
if (camerabin->location)
location =
g_strdup_printf (camerabin->location, camerabin->capture_index++);
camerabin->image_location_list = camerabin->image_location_list =
g_slist_append (camerabin->image_location_list, location); g_slist_append (camerabin->image_location_list, g_strdup (location));
} }
/* store the next preview filename */
camerabin->preview_location_list =
g_slist_append (camerabin->preview_location_list, location);
g_signal_emit_by_name (camerabin->src, "start-capture", NULL); g_signal_emit_by_name (camerabin->src, "start-capture", NULL);
if (camerabin->mode == MODE_VIDEO && camerabin->audio_src) if (camerabin->mode == MODE_VIDEO && camerabin->audio_src)
gst_element_set_state (camerabin->audio_src, GST_STATE_PLAYING); gst_element_set_state (camerabin->audio_src, GST_STATE_PLAYING);
@ -434,7 +437,6 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin)
gst_event_new_tag (gst_tag_list_copy (taglist))); gst_event_new_tag (gst_tag_list_copy (taglist)));
gst_object_unref (active_pad); gst_object_unref (active_pad);
} }
} }
static void static void
@ -447,14 +449,6 @@ gst_camera_bin_stop_capture (GstCameraBin2 * camerabin)
if (camerabin->mode == MODE_VIDEO && camerabin->audio_src) { if (camerabin->mode == MODE_VIDEO && camerabin->audio_src) {
camerabin->audio_drop_eos = FALSE; camerabin->audio_drop_eos = FALSE;
gst_element_send_event (camerabin->audio_src, gst_event_new_eos ()); gst_element_send_event (camerabin->audio_src, gst_event_new_eos ());
/* FIXME We need to set audiosrc to null to make it resync the ringbuffer
* while bug https://bugzilla.gnome.org/show_bug.cgi?id=648359 isn't
* fixed.
*
* Also, we set to NULL here to stop capturing audio through to the next
* video mode start capture. */
gst_element_set_state (camerabin->audio_src, GST_STATE_NULL);
} }
} }
@ -490,7 +484,7 @@ gst_camera_bin_src_notify_readyforcapture (GObject * obj, GParamSpec * pspec,
gst_element_set_state (camera->videosink, GST_STATE_NULL); gst_element_set_state (camera->videosink, GST_STATE_NULL);
gst_element_set_state (camera->video_encodebin, GST_STATE_NULL); gst_element_set_state (camera->video_encodebin, GST_STATE_NULL);
gst_element_set_state (camera->videobin_capsfilter, GST_STATE_NULL); gst_element_set_state (camera->videobin_capsfilter, GST_STATE_NULL);
location = g_strdup_printf (camera->location, camera->capture_index++); location = g_strdup_printf (camera->location, camera->capture_index);
GST_DEBUG_OBJECT (camera, "Switching videobin location to %s", location); GST_DEBUG_OBJECT (camera, "Switching videobin location to %s", location);
g_object_set (camera->videosink, "location", location, NULL); g_object_set (camera->videosink, "location", location, NULL);
g_free (location); g_free (location);
@ -504,6 +498,17 @@ gst_camera_bin_src_notify_readyforcapture (GObject * obj, GParamSpec * pspec,
gst_element_set_state (camera->videobin_capsfilter, GST_STATE_PLAYING); gst_element_set_state (camera->videobin_capsfilter, GST_STATE_PLAYING);
} }
camera->capture_index++;
} else {
if (camera->mode == MODE_VIDEO && camera->audio_src) {
/* FIXME We need to set audiosrc to null to make it resync the ringbuffer
* while bug https://bugzilla.gnome.org/show_bug.cgi?id=648359 isn't
* fixed.
*
* Also, we set to NULL here to stop capturing audio through to the next
* video mode start capture and to clear EOS. */
gst_element_set_state (camera->audio_src, GST_STATE_NULL);
}
} }
} }
@ -922,6 +927,8 @@ gst_video_capture_bin_post_video_done (GstCameraBin2 * camera)
static void static void
gst_camera_bin_handle_message (GstBin * bin, GstMessage * message) gst_camera_bin_handle_message (GstBin * bin, GstMessage * message)
{ {
GstCameraBin2 *camerabin = GST_CAMERA_BIN2_CAST (bin);
switch (GST_MESSAGE_TYPE (message)) { switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_ELEMENT:{ case GST_MESSAGE_ELEMENT:{
const GstStructure *structure = gst_message_get_structure (message); const GstStructure *structure = gst_message_get_structure (message);
@ -936,6 +943,22 @@ gst_camera_bin_handle_message (GstBin * bin, GstMessage * message)
gst_image_capture_bin_post_image_done (GST_CAMERA_BIN2_CAST (bin), gst_image_capture_bin_post_image_done (GST_CAMERA_BIN2_CAST (bin),
filename); filename);
} }
} else if (gst_structure_has_name (structure, "preview-image")) {
GValue *value;
gchar *location;
location = camerabin->preview_location_list->data;
camerabin->preview_location_list =
g_slist_delete_link (camerabin->preview_location_list,
camerabin->preview_location_list);
GST_DEBUG_OBJECT (camerabin, "Adding preview location to preview "
"message '%s'", location);
value = g_new0 (GValue, 1);
g_value_init (value, G_TYPE_STRING);
g_value_take_string (value, location);
gst_structure_take_value ((GstStructure *) structure, "location",
value);
} }
} }
break; break;
@ -1702,6 +1725,10 @@ gst_camera_bin_change_state (GstElement * element, GstStateChange trans)
g_slist_free (camera->image_location_list); g_slist_free (camera->image_location_list);
camera->image_location_list = NULL; camera->image_location_list = NULL;
g_slist_foreach (camera->preview_location_list, (GFunc) g_free, NULL);
g_slist_free (camera->preview_location_list);
camera->preview_location_list = NULL;
/* explicitly set to READY as they might be outside of the bin */ /* explicitly set to READY as they might be outside of the bin */
gst_element_set_state (camera->audio_volume, GST_STATE_READY); gst_element_set_state (camera->audio_volume, GST_STATE_READY);
gst_element_set_state (camera->audio_capsfilter, GST_STATE_READY); gst_element_set_state (camera->audio_capsfilter, GST_STATE_READY);

View File

@ -94,6 +94,9 @@ struct _GstCameraBin2
* each buffer capture */ * each buffer capture */
GSList *image_location_list; GSList *image_location_list;
/* similar to above, but used for giving names to previews */
GSList *preview_location_list;
gboolean video_profile_switch; gboolean video_profile_switch;
gboolean image_profile_switch; gboolean image_profile_switch;

View File

@ -1042,8 +1042,9 @@ gst_flups_demux_do_seek (GstFluPSDemux * demux, GstSegment * seeksegment)
GST_INFO_OBJECT (demux, "sink segment configured %" GST_SEGMENT_FORMAT GST_INFO_OBJECT (demux, "sink segment configured %" GST_SEGMENT_FORMAT
", trying to go at SCR: %" G_GUINT64_FORMAT, &demux->sink_segment, scr); ", trying to go at SCR: %" G_GUINT64_FORMAT, &demux->sink_segment, scr);
offset = MIN (gst_util_uint64_scale (scr, scr_rate_n, scr_rate_d), offset =
demux->sink_segment.stop); MIN (gst_util_uint64_scale (scr - demux->first_scr, scr_rate_n,
scr_rate_d), demux->sink_segment.stop);
found = gst_flups_demux_scan_forward_ts (demux, &offset, SCAN_SCR, &fscr); found = gst_flups_demux_scan_forward_ts (demux, &offset, SCAN_SCR, &fscr);
if (!found) { if (!found) {
@ -1247,6 +1248,7 @@ gst_flups_demux_src_query (GstPad * pad, GstQuery * query)
switch (GST_QUERY_TYPE (query)) { switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION: case GST_QUERY_POSITION:
{ {
GstClockTime pos;
GstFormat format; GstFormat format;
gst_query_parse_position (query, &format, NULL); gst_query_parse_position (query, &format, NULL);
@ -1257,10 +1259,9 @@ gst_flups_demux_src_query (GstPad * pad, GstQuery * query)
goto not_supported; goto not_supported;
} }
GST_LOG_OBJECT (demux, "Position at GStreamer Time:%" GST_TIME_FORMAT, pos = demux->src_segment.last_stop - demux->src_segment.start;
GST_TIME_ARGS (demux->src_segment.last_stop)); GST_LOG_OBJECT (demux, "Position %" GST_TIME_FORMAT, GST_TIME_ARGS (pos));
gst_query_set_position (query, format, pos);
gst_query_set_position (query, format, demux->src_segment.last_stop);
res = TRUE; res = TRUE;
break; break;
} }

View File

@ -84,7 +84,6 @@ struct _GstFluPSStream
gint id; gint id;
gint type; gint type;
gint size_bound;
GstClockTime segment_thresh; GstClockTime segment_thresh;
GstClockTime last_seg_start; GstClockTime last_seg_start;

View File

@ -166,8 +166,11 @@ static guint bus_source;
static GMainLoop *main_loop; static GMainLoop *main_loop;
static gint capture_count = 0; static gint capture_count = 0;
guint32 test_id = 0; guint32 test_id = 0;
static gchar *image_filename;
static gchar *video_filename;
static GstBuffer *preview_buffer; static GstBuffer *preview_buffer;
static gchar *preview_filename;
static GstCaps *preview_caps; static GstCaps *preview_caps;
static GstTagList *tags_found; static GstTagList *tags_found;
@ -196,24 +199,31 @@ validate_taglist_foreach (const GstTagList * list, const gchar * tag,
/* helper function for filenames */ /* helper function for filenames */
static const gchar * static gchar *
make_test_file_name (const gchar * base_name, gint num) make_test_file_name (const gchar * base_name, gint num)
{
/* num == -1 means to keep the %d in the resulting string to be used on
* multifilesink like location */
if (num == -1) {
return g_strdup_printf ("%s" G_DIR_SEPARATOR_S
"gstcamerabin2test_%s_%u_%%03d.cap", g_get_tmp_dir (), base_name,
test_id);
} else {
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]; static gchar file_name[1000];
/* num == -1 means to keep the %d in the resulting string to be used on /* num == -1 means to keep the %d in the resulting string to be used on
* multifilesink like location */ * multifilesink like location */
if (num == -1) { g_snprintf (file_name, 999, filename, num);
g_snprintf (file_name, 999, "%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
"gstcamerabin2test_%s_%u_%03d.cap", g_get_tmp_dir (), base_name,
test_id, num);
}
GST_INFO ("capturing to: %s", file_name);
return file_name; return file_name;
} }
@ -275,6 +285,8 @@ capture_bus_cb (GstBus * bus, GstMessage * message, gpointer data)
if (preview_buffer) if (preview_buffer)
gst_buffer_unref (preview_buffer); gst_buffer_unref (preview_buffer);
preview_buffer = gst_buffer_ref (buf); preview_buffer = gst_buffer_ref (buf);
g_free (preview_filename);
preview_filename = g_strdup (gst_structure_get_string (st, "location"));
} }
break; break;
} }
@ -282,8 +294,10 @@ capture_bus_cb (GstBus * bus, GstMessage * message, gpointer data)
} }
static void static void
check_preview_image (GstElement * camera) check_preview_image (GstElement * camera, const gchar * filename, gint index)
{ {
gchar *prev_filename = NULL;
if (!preview_buffer && camera) { if (!preview_buffer && camera) {
GstMessage *msg = wait_for_element_message (camera, GstMessage *msg = wait_for_element_message (camera,
GST_BASE_CAMERA_SRC_PREVIEW_MESSAGE_NAME, GST_CLOCK_TIME_NONE); GST_BASE_CAMERA_SRC_PREVIEW_MESSAGE_NAME, GST_CLOCK_TIME_NONE);
@ -291,11 +305,21 @@ check_preview_image (GstElement * camera)
gst_message_unref (msg); gst_message_unref (msg);
} }
fail_unless (preview_buffer != NULL); fail_unless (preview_buffer != NULL);
if (filename) {
if (index >= 0) {
prev_filename = g_strdup_printf (filename, index);
} else {
prev_filename = g_strdup (filename);
}
fail_unless (preview_filename != NULL);
fail_unless (strcmp (preview_filename, prev_filename) == 0);
}
if (preview_caps) { if (preview_caps) {
fail_unless (GST_BUFFER_CAPS (preview_buffer) != NULL); fail_unless (GST_BUFFER_CAPS (preview_buffer) != NULL);
fail_unless (gst_caps_can_intersect (GST_BUFFER_CAPS (preview_buffer), fail_unless (gst_caps_can_intersect (GST_BUFFER_CAPS (preview_buffer),
preview_caps)); preview_caps));
} }
g_free (prev_filename);
} }
static void static void
@ -303,7 +327,7 @@ extract_jpeg_tags (const gchar * filename, gint num)
{ {
GstBus *bus; GstBus *bus;
GMainLoop *loop = g_main_loop_new (NULL, FALSE); 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 ! " gchar *pipeline_str = g_strdup_printf ("filesrc location=%s ! "
"jpegparse ! fakesink", filepath); "jpegparse ! fakesink", filepath);
GstElement *pipeline; GstElement *pipeline;
@ -371,6 +395,8 @@ setup_wrappercamerabinsrc_videotestsrc (void)
tags_found = NULL; tags_found = NULL;
capture_count = 0; capture_count = 0;
image_filename = make_test_file_name (IMAGE_FILENAME, -1);
video_filename = make_test_file_name (VIDEO_FILENAME, -1);
GST_INFO ("init finished"); GST_INFO ("init finished");
} }
@ -399,10 +425,18 @@ teardown (void)
gst_buffer_unref (preview_buffer); gst_buffer_unref (preview_buffer);
preview_buffer = NULL; preview_buffer = NULL;
g_free (preview_filename);
preview_filename = NULL;
if (tags_found) if (tags_found)
gst_tag_list_free (tags_found); gst_tag_list_free (tags_found);
tags_found = NULL; tags_found = NULL;
g_free (video_filename);
g_free (image_filename);
video_filename = NULL;
image_filename = NULL;
GST_INFO ("done"); GST_INFO ("done");
} }
@ -475,7 +509,7 @@ check_file_validity (const gchar * filename, gint num, GstTagList * taglist,
GstElement *playbin = gst_element_factory_make ("playbin2", NULL); GstElement *playbin = gst_element_factory_make ("playbin2", NULL);
GstElement *fakevideo = gst_element_factory_make ("fakesink", NULL); GstElement *fakevideo = gst_element_factory_make ("fakesink", NULL);
GstElement *fakeaudio = 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); NULL);
GST_DEBUG ("checking uri: %s", uri); GST_DEBUG ("checking uri: %s", uri);
@ -569,6 +603,9 @@ wait_for_element_message (GstElement * camera, const gchar * name,
if (preview_buffer) if (preview_buffer)
gst_buffer_unref (preview_buffer); gst_buffer_unref (preview_buffer);
preview_buffer = gst_buffer_ref (buf); preview_buffer = gst_buffer_ref (buf);
g_free (preview_filename);
preview_filename =
g_strdup (gst_structure_get_string (st, "location"));
} }
if (gst_structure_has_name (st, name)) if (gst_structure_has_name (st, name))
@ -593,8 +630,7 @@ GST_START_TEST (test_single_image_capture)
return; return;
/* set still image mode */ /* set still image mode */
g_object_set (camera, "mode", 1, g_object_set (camera, "mode", 1, "location", image_filename, NULL);
"location", make_test_file_name (IMAGE_FILENAME, -1), NULL);
if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE) { GST_STATE_CHANGE_FAILURE) {
@ -614,12 +650,12 @@ GST_START_TEST (test_single_image_capture)
gst_message_unref (msg); gst_message_unref (msg);
/* check that we got a preview image */ /* check that we got a preview image */
check_preview_image (camera); check_preview_image (camera, image_filename, 0);
g_object_get (camera, "idle", &idle, NULL); g_object_get (camera, "idle", &idle, NULL);
fail_unless (idle); fail_unless (idle);
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); 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; GST_END_TEST;
@ -636,8 +672,7 @@ GST_START_TEST (test_multiple_image_captures)
return; return;
/* set still image mode */ /* set still image mode */
g_object_set (camera, "mode", 1, g_object_set (camera, "mode", 1, "location", image_filename, NULL);
"location", make_test_file_name (IMAGE_FILENAME, -1), NULL);
if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE) { GST_STATE_CHANGE_FAILURE) {
@ -667,14 +702,14 @@ GST_START_TEST (test_multiple_image_captures)
fail_unless (msg != NULL); fail_unless (msg != NULL);
gst_message_unref (msg); gst_message_unref (msg);
check_preview_image (camera); check_preview_image (camera, image_filename, i);
} }
g_object_get (camera, "idle", &idle, NULL); g_object_get (camera, "idle", &idle, NULL);
fail_unless (idle); fail_unless (idle);
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
for (i = 0; i < 3; i++) { 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); NO_AUDIO);
} }
} }
@ -689,8 +724,7 @@ GST_START_TEST (test_single_video_recording)
return; return;
/* Set video recording mode */ /* Set video recording mode */
g_object_set (camera, "mode", 2, g_object_set (camera, "mode", 2, "location", video_filename, NULL);
"location", make_test_file_name (VIDEO_FILENAME, -1), NULL);
if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE) { GST_STATE_CHANGE_FAILURE) {
@ -716,7 +750,7 @@ GST_START_TEST (test_single_video_recording)
g_signal_emit_by_name (camera, "stop-capture", NULL); g_signal_emit_by_name (camera, "stop-capture", NULL);
check_preview_image (camera); check_preview_image (camera, video_filename, 0);
msg = wait_for_element_message (camera, "video-done", GST_CLOCK_TIME_NONE); msg = wait_for_element_message (camera, "video-done", GST_CLOCK_TIME_NONE);
fail_unless (msg != NULL); fail_unless (msg != NULL);
@ -726,7 +760,7 @@ GST_START_TEST (test_single_video_recording)
fail_unless (idle); fail_unless (idle);
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); 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_END_TEST;
@ -743,7 +777,7 @@ GST_START_TEST (test_multiple_video_recordings)
return; return;
/* Set video recording mode */ /* Set video recording mode */
g_object_set (camera, "mode", 2, NULL); g_object_set (camera, "mode", 2, "location", video_filename, NULL);
if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE) { GST_STATE_CHANGE_FAILURE) {
@ -765,8 +799,7 @@ GST_START_TEST (test_multiple_video_recordings)
widths[i], "height", G_TYPE_INT, heights[i], "framerate", widths[i], "height", G_TYPE_INT, heights[i], "framerate",
GST_TYPE_FRACTION, fr[i], 1, NULL); GST_TYPE_FRACTION, fr[i], 1, NULL);
g_object_set (camera, "video-capture-caps", caps, g_object_set (camera, "video-capture-caps", caps, NULL);
"location", make_test_file_name (VIDEO_FILENAME, i), NULL);
gst_caps_unref (caps); gst_caps_unref (caps);
@ -784,7 +817,7 @@ GST_START_TEST (test_multiple_video_recordings)
fail_unless (msg != NULL); fail_unless (msg != NULL);
gst_message_unref (msg); gst_message_unref (msg);
check_preview_image (camera); check_preview_image (camera, video_filename, i);
g_object_get (camera, "idle", &idle, NULL); g_object_get (camera, "idle", &idle, NULL);
fail_unless (idle); fail_unless (idle);
@ -792,7 +825,7 @@ GST_START_TEST (test_multiple_video_recordings)
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
for (i = 0; i < 3; i++) { 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); WITH_AUDIO);
} }
} }
@ -818,25 +851,29 @@ GST_START_TEST (test_image_video_cycle)
GST_INFO ("starting capture"); GST_INFO ("starting capture");
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
GstMessage *msg; GstMessage *msg;
const gchar *img_filename;
const gchar *vid_filename;
g_object_get (camera, "idle", &idle, NULL); g_object_get (camera, "idle", &idle, NULL);
fail_unless (idle); fail_unless (idle);
/* take a picture */ /* take a picture */
img_filename = make_const_file_name (image_filename, i);
g_object_set (camera, "mode", 1, NULL); g_object_set (camera, "mode", 1, NULL);
g_object_set (camera, "location", make_test_file_name (IMAGE_FILENAME, i), g_object_set (camera, "location", img_filename, NULL);
NULL);
g_signal_emit_by_name (camera, "start-capture", NULL); g_signal_emit_by_name (camera, "start-capture", NULL);
msg = wait_for_element_message (camera, "image-done", GST_CLOCK_TIME_NONE); msg = wait_for_element_message (camera, "image-done", GST_CLOCK_TIME_NONE);
fail_unless (msg != NULL); fail_unless (msg != NULL);
gst_message_unref (msg); gst_message_unref (msg);
check_preview_image (camera); check_preview_image (camera, img_filename, i);
/* now go to video */ /* now go to video */
vid_filename = make_const_file_name (video_filename, i);
g_object_set (camera, "mode", 2, NULL); g_object_set (camera, "mode", 2, NULL);
g_object_set (camera, "location", make_test_file_name (VIDEO_FILENAME, i), g_object_set (camera, "location", vid_filename, NULL);
NULL);
g_signal_emit_by_name (camera, "start-capture", NULL); g_signal_emit_by_name (camera, "start-capture", NULL);
g_timeout_add_seconds (VIDEO_DURATION, (GSourceFunc) g_main_loop_quit, g_timeout_add_seconds (VIDEO_DURATION, (GSourceFunc) g_main_loop_quit,
main_loop); main_loop);
@ -847,7 +884,7 @@ GST_START_TEST (test_image_video_cycle)
fail_unless (msg != NULL); fail_unless (msg != NULL);
gst_message_unref (msg); gst_message_unref (msg);
check_preview_image (camera); check_preview_image (camera, vid_filename, i);
/* wait for capture to finish */ /* wait for capture to finish */
g_usleep (G_USEC_PER_SEC); g_usleep (G_USEC_PER_SEC);
@ -856,8 +893,8 @@ GST_START_TEST (test_image_video_cycle)
/* validate all the files */ /* validate all the files */
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
check_file_validity (IMAGE_FILENAME, i, NULL, 0, 0, NO_AUDIO); 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 (video_filename, i, NULL, 0, 0, WITH_AUDIO);
} }
} }
@ -874,8 +911,7 @@ GST_START_TEST (test_image_capture_previews)
return; return;
/* set still image mode */ /* set still image mode */
g_object_set (camera, "mode", 1, g_object_set (camera, "mode", 1, "location", image_filename, NULL);
"location", make_test_file_name (IMAGE_FILENAME, -1), NULL);
if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE) { GST_STATE_CHANGE_FAILURE) {
@ -904,7 +940,7 @@ GST_START_TEST (test_image_capture_previews)
fail_unless (msg != NULL); fail_unless (msg != NULL);
gst_message_unref (msg); gst_message_unref (msg);
check_preview_image (camera); check_preview_image (camera, image_filename, i);
if (preview_buffer) if (preview_buffer)
gst_buffer_unref (preview_buffer); gst_buffer_unref (preview_buffer);
@ -955,8 +991,7 @@ GST_START_TEST (test_image_capture_with_tags)
GST_TAG_GEO_LOCATION_ELEVATION, 0.0, NULL); GST_TAG_GEO_LOCATION_ELEVATION, 0.0, NULL);
/* set still image mode */ /* set still image mode */
g_object_set (camera, "mode", 1, g_object_set (camera, "mode", 1, "location", image_filename, NULL);
"location", make_test_file_name (IMAGE_FILENAME, -1), NULL);
if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE) { GST_STATE_CHANGE_FAILURE) {
@ -983,7 +1018,7 @@ GST_START_TEST (test_image_capture_with_tags)
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
for (i = 0; i < 3; i++) { 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]); gst_tag_list_free (taglists[i]);
} }
} }
@ -1004,8 +1039,7 @@ GST_START_TEST (test_video_capture_with_tags)
taglists[2] = gst_tag_list_new_full (GST_TAG_COMMENT, "test3", NULL); taglists[2] = gst_tag_list_new_full (GST_TAG_COMMENT, "test3", NULL);
/* set video mode */ /* set video mode */
g_object_set (camera, "mode", 2, g_object_set (camera, "mode", 2, "location", video_filename, NULL);
"location", make_test_file_name (VIDEO_FILENAME, -1), NULL);
/* set a profile that has xmp support for more tags being saved */ /* set a profile that has xmp support for more tags being saved */
{ {
@ -1061,7 +1095,7 @@ GST_START_TEST (test_video_capture_with_tags)
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
for (i = 0; i < 3; i++) { 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_tag_list_free (taglists[i]);
} }
} }
@ -1123,8 +1157,7 @@ GST_START_TEST (test_idle_property)
return; return;
/* Set video recording mode */ /* Set video recording mode */
g_object_set (camera, "mode", 2, g_object_set (camera, "mode", 2, "location", video_filename, NULL);
"location", make_test_file_name (VIDEO_FILENAME, -1), NULL);
if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE) { GST_STATE_CHANGE_FAILURE) {
@ -1158,14 +1191,14 @@ GST_START_TEST (test_idle_property)
fail_unless (msg != NULL); fail_unless (msg != NULL);
gst_message_unref (msg); gst_message_unref (msg);
check_preview_image (camera); check_preview_image (camera, video_filename, 0);
g_object_get (camera, "idle", &idle, NULL); g_object_get (camera, "idle", &idle, NULL);
fail_unless (idle); fail_unless (idle);
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); 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_END_TEST;
@ -1205,7 +1238,7 @@ GST_START_TEST (test_image_custom_filter)
/* set still image mode and filters */ /* set still image mode and filters */
g_object_set (camera, "mode", 1, g_object_set (camera, "mode", 1,
"location", make_test_file_name (IMAGE_FILENAME, -1), "location", image_filename,
"viewfinder-filter", vf_filter, "image-filter", image_filter, "viewfinder-filter", vf_filter, "image-filter", image_filter,
"preview-filter", preview_filter, NULL); "preview-filter", preview_filter, NULL);
@ -1228,10 +1261,10 @@ GST_START_TEST (test_image_custom_filter)
g_main_loop_run (main_loop); g_main_loop_run (main_loop);
/* check that we got a preview image */ /* check that we got a preview image */
check_preview_image (camera); check_preview_image (camera, image_filename, 0);
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); 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 (vf_probe_counter > 0);
fail_unless (image_probe_counter == 1); fail_unless (image_probe_counter == 1);
@ -1283,7 +1316,7 @@ GST_START_TEST (test_video_custom_filter)
/* set still image mode and filters */ /* set still image mode and filters */
g_object_set (camera, "mode", 2, g_object_set (camera, "mode", 2,
"location", make_test_file_name (VIDEO_FILENAME, -1), "location", video_filename,
"viewfinder-filter", vf_filter, "video-filter", video_filter, "viewfinder-filter", vf_filter, "video-filter", video_filter,
"preview-filter", preview_filter, "audio-filter", audio_filter, NULL); "preview-filter", preview_filter, "audio-filter", audio_filter, NULL);
@ -1309,10 +1342,10 @@ GST_START_TEST (test_video_custom_filter)
g_signal_emit_by_name (camera, "stop-capture", NULL); g_signal_emit_by_name (camera, "stop-capture", NULL);
/* check that we got a preview image */ /* check that we got a preview image */
check_preview_image (camera); check_preview_image (camera, video_filename, 0);
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); 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 (vf_probe_counter > 0);
fail_unless (video_probe_counter > 0); fail_unless (video_probe_counter > 0);
@ -1375,8 +1408,7 @@ GST_START_TEST (test_image_location_switching)
g_object_get (camera, "camera-source", &src, NULL); g_object_get (camera, "camera-source", &src, NULL);
for (i = 0; i < LOCATION_SWITCHING_FILENAMES_COUNT; i++) { for (i = 0; i < LOCATION_SWITCHING_FILENAMES_COUNT; i++) {
filenames[i] = filenames[i] = make_test_file_name ("image-switching-filename-test", i);
g_strdup (make_test_file_name ("image-switching-filename-test", i));
} }
filenames[LOCATION_SWITCHING_FILENAMES_COUNT] = NULL; filenames[LOCATION_SWITCHING_FILENAMES_COUNT] = NULL;