{
PROP_0,
PROP_LOCATION,
- PROP_ENCODER
+ PROP_ENCODER,
+ PROP_MUXER
};
#define DEFAULT_LOCATION "img_%d"
}
static void
+gst_image_capture_bin_set_muxer (GstImageCaptureBin * imagebin,
+ GstElement * muxer)
+{
+ GST_DEBUG_OBJECT (GST_OBJECT (imagebin),
+ "Setting image muxer %" GST_PTR_FORMAT, muxer);
+
+ if (imagebin->user_muxer)
+ g_object_unref (imagebin->user_muxer);
+
+ if (muxer)
+ g_object_ref (muxer);
+
+ imagebin->user_muxer = muxer;
+}
+
+static void
gst_image_capture_bin_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
case PROP_ENCODER:
gst_image_capture_bin_set_encoder (imagebin, g_value_get_object (value));
break;
+ case PROP_MUXER:
+ gst_image_capture_bin_set_muxer (imagebin, g_value_get_object (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case PROP_ENCODER:
g_value_set_object (value, imagebin->encoder);
break;
+ case PROP_MUXER:
+ g_value_set_object (value, imagebin->muxer);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
g_param_spec_object ("image-encoder", "Image encoder",
"Image encoder GStreamer element (default is jpegenc)",
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_MUXER,
+ g_param_spec_object ("image-muxer", "Image muxer",
+ "Image muxer GStreamer element (default is jifmux)",
+ GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
goto error;
}
- imagebin->muxer =
- gst_camerabin_create_and_add_element (GST_BIN (imagebin), DEFAULT_MUXER);
- if (!imagebin->muxer)
- goto error;
+ if (imagebin->user_muxer) {
+ imagebin->muxer = imagebin->user_muxer;
+ if (!gst_camerabin_add_element (GST_BIN (imagebin), imagebin->muxer)) {
+ goto error;
+ }
+ } else {
+ imagebin->muxer =
+ gst_camerabin_create_and_add_element (GST_BIN (imagebin),
+ DEFAULT_MUXER);
+ if (!imagebin->muxer)
+ goto error;
+ }
imagebin->sink =
gst_camerabin_create_and_add_element (GST_BIN (imagebin), DEFAULT_SINK);
GST_END_TEST;
+GST_START_TEST (test_setting_muxer)
+{
+ GstImageCaptureBinTestContext ctx;
+ GstBus *bus;
+ GstMessage *msg;
+ GstElement *encoder;
+ gchar *test_file_name;
+ gint i;
+
+ gstimagecapturebin_init_test_context (&ctx, N_BUFFERS);
+ bus = gst_element_get_bus (ctx.pipe);
+
+ test_file_name = make_test_file_name ();
+ g_object_set (ctx.icbin, "location", test_file_name, NULL);
+
+ encoder = gst_element_factory_make ("pngenc", NULL);
+ g_object_set (ctx.icbin, "image-encoder", encoder, NULL);
+
+ encoder = gst_element_factory_make ("identity", NULL);
+ g_object_set (ctx.icbin, "image-muxer", encoder, NULL);
+
+ fail_if (gst_element_set_state (ctx.pipe, GST_STATE_PLAYING) ==
+ GST_STATE_CHANGE_FAILURE);
+
+ msg = gst_bus_timed_pop_filtered (bus, GST_SECOND * 10,
+ GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
+ fail_unless (msg != NULL);
+ fail_unless (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS);
+
+ /* check there are N_BUFFERS files */
+ for (i = 0; i < N_BUFFERS; i++) {
+ gchar *filename;
+ FILE *f;
+
+ filename = g_strdup_printf (test_file_name, i);
+
+ fail_unless (g_file_test (filename, G_FILE_TEST_EXISTS));
+ fail_unless (g_file_test (filename, G_FILE_TEST_IS_REGULAR));
+ fail_if (g_file_test (filename, G_FILE_TEST_IS_SYMLINK));
+
+ /* check the file isn't empty */
+ f = fopen (filename, "r");
+ fseek (f, 0, SEEK_END);
+ fail_unless (ftell (f) > 0);
+ fclose (f);
+
+ g_free (filename);
+ }
+
+ gstimagecapturebin_unset_test_context (&ctx);
+ gst_object_unref (bus);
+ g_free (test_file_name);
+}
+
+GST_END_TEST;
+
static Suite *
imagecapturebin_suite (void)
{
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_simple_capture);
tcase_add_test (tc_chain, test_setting_encoder);
+ tcase_add_test (tc_chain, test_setting_muxer);
return s;
}