#define DEFAULT_SINK "filesink"
#define DEFAULT_ENC "jpegenc"
-#define DEFAULT_META_MUX "jifmux"
+#define DEFAULT_FORMATTER "jifmux"
#define DEFAULT_FLAGS GST_CAMERABIN_FLAG_IMAGE_COLOR_CONVERSION
enum
img->csp = NULL;
img->enc = NULL;
img->app_enc = NULL;
- img->meta_mux = NULL;
+ img->formatter = NULL;
+ img->app_formatter = NULL;
img->sink = NULL;
/* Create src and sink ghost pads */
img->sink = NULL;
}
- if (img->meta_mux) {
+ if (img->formatter) {
GST_LOG_OBJECT (img, "disposing %s with refcount %d",
- GST_ELEMENT_NAME (img->meta_mux),
- GST_OBJECT_REFCOUNT_VALUE (img->meta_mux));
- gst_object_unref (img->meta_mux);
- img->meta_mux = NULL;
+ GST_ELEMENT_NAME (img->formatter),
+ GST_OBJECT_REFCOUNT_VALUE (img->formatter));
+ gst_object_unref (img->formatter);
+ img->formatter = NULL;
+ }
+
+ if (img->app_formatter) {
+ gst_object_sink (img->app_formatter);
+ GST_LOG_OBJECT (img, "disposing %s with refcount %d",
+ GST_ELEMENT_NAME (img->app_formatter),
+ GST_OBJECT_REFCOUNT_VALUE (img->app_formatter));
+ gst_object_unref (img->app_formatter);
+ img->app_formatter = NULL;
}
if (img->enc) {
}
/* Create metadata muxer element */
- if (!prepare_element (&imagebin->elements, DEFAULT_META_MUX, NULL,
- &imagebin->meta_mux)) {
+ if (!prepare_element (&imagebin->elements, DEFAULT_FORMATTER,
+ imagebin->app_formatter, &imagebin->formatter)) {
goto done;
} else if (!imagebin->metadata_probe_id) {
/* Add probe for default XMP metadata writing */
- sinkpad = gst_element_get_static_pad (imagebin->meta_mux, "sink");
+ sinkpad = gst_element_get_static_pad (imagebin->formatter, "sink");
imagebin->metadata_probe_id =
gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (metadata_write_probe),
imagebin);
g_return_val_if_fail (img != NULL, TRUE);
- setter = GST_TAG_SETTER (img->meta_mux);
+ if (GST_IS_TAG_SETTER (img->formatter)) {
+ setter = GST_TAG_SETTER (img->formatter);
+ }
if (!setter) {
GST_WARNING_OBJECT (img, "setting tags failed");
}
void
+gst_camerabin_image_set_formatter (GstCameraBinImage * img,
+ GstElement * formatter)
+{
+ GstElement **app_formatter;
+ GST_DEBUG ("setting image formatter %" GST_PTR_FORMAT, formatter);
+
+ app_formatter = &img->app_formatter;
+ GST_OBJECT_LOCK (img);
+ gst_object_replace ((GstObject **) app_formatter, GST_OBJECT (formatter));
+ GST_OBJECT_UNLOCK (img);
+}
+
+void
gst_camerabin_image_set_flags (GstCameraBinImage * img, GstCameraBinFlags flags)
{
GST_DEBUG_OBJECT (img, "setting image flags: %d", flags);
}
GstElement *
+gst_camerabin_image_get_formatter (GstCameraBinImage * img)
+{
+ /* Prefer formatter that is currently in use */
+ return img->formatter ? img->formatter : img->app_formatter;
+}
+
+GstElement *
gst_camerabin_image_get_postproc (GstCameraBinImage * img)
{
return img->post;
GstElement *csp;
GstElement *enc;
GstElement *app_enc;
- GstElement *meta_mux;
+ GstElement *formatter;
+ GstElement *app_formatter;
GstElement *sink;
GstCameraBinFlags flags;
GstElement * postproc);
void
+gst_camerabin_image_set_formatter (GstCameraBinImage * img, GstElement * formatter);
+
+void
gst_camerabin_image_set_flags (GstCameraBinImage * img,
GstCameraBinFlags flags);
GstElement *gst_camerabin_image_get_postproc (GstCameraBinImage * img);
+GstElement *gst_camerabin_image_get_formatter (GstCameraBinImage * img);
+
gboolean gst_camerabin_image_prepare_elements (GstCameraBinImage * imagebin);
G_END_DECLS
ARG_ZOOM,
ARG_IMAGE_POST,
ARG_IMAGE_ENC,
+ ARG_IMAGE_FORMATTER,
ARG_VIDEO_POST,
ARG_VIDEO_ENC,
ARG_AUDIO_ENC,
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
+ * GstCameraBin:image-formatter:
+ *
+ * Set up an image formatter (for example, jifmux) element.
+ * This property can only be set while #GstCameraBin is in NULL state.
+ * The ownership of the element will be taken by #GstCameraBin.
+ */
+
+ g_object_class_install_property (gobject_class, ARG_IMAGE_FORMATTER,
+ g_param_spec_object ("image-formatter", "Image formatter",
+ "Image formatter GStreamer element (default is jifmux)",
+ GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
* GstCameraBin:video-post-processing:
*
* Set up an element to do video post processing.
gst_camerabin_image_set_encoder (GST_CAMERABIN_IMAGE (camera->imgbin),
g_value_get_object (value));
break;
+ case ARG_IMAGE_FORMATTER:
+ if (GST_STATE (camera->imgbin) != GST_STATE_NULL) {
+ GST_WARNING_OBJECT (camera,
+ "can't use set element until next image bin NULL to READY state change");
+ }
+ gst_camerabin_image_set_formatter (GST_CAMERABIN_IMAGE (camera->imgbin),
+ g_value_get_object (value));
+ break;
case ARG_VF_SINK:
if (GST_STATE (camera) != GST_STATE_NULL) {
GST_ELEMENT_ERROR (camera, CORE, FAILED,
gst_camerabin_image_get_encoder (GST_CAMERABIN_IMAGE
(camera->imgbin)));
break;
+ case ARG_IMAGE_FORMATTER:
+ g_value_set_object (value,
+ gst_camerabin_image_get_formatter (GST_CAMERABIN_IMAGE
+ (camera->imgbin)));
+ break;
case ARG_VIDEO_POST:
g_value_set_object (value,
gst_camerabin_video_get_post (GST_CAMERABIN_VIDEO (camera->vidbin)));
setup_camerabin_elements (GstElement * camera)
{
GstElement *vfsink, *audiosrc, *videosrc, *audioenc, *videoenc, *imageenc,
- *videomux, *viewfinder_filter, *imagepp, *videopp;
+ *videomux, *viewfinder_filter, *imagepp, *videopp, *formatter;
GstCaps *audiocaps, *videocaps;
/* Use fakesink for view finder */
viewfinder_filter = gst_element_factory_make ("identity", NULL);
imagepp = gst_element_factory_make ("identity", NULL);
videopp = gst_element_factory_make ("identity", NULL);
+ formatter = gst_element_factory_make ("jifmux", NULL);
if (set_and_check_camerabin_element (camera, "viewfinder-sink", vfsink)
&& set_and_check_camerabin_element (camera, "audio-source", audiosrc)
&& set_and_check_camerabin_element (camera, "image-post-processing",
imagepp)
&& set_and_check_camerabin_element (camera, "video-post-processing",
- videopp)) {
+ videopp)
+ && set_and_check_camerabin_element (camera, "image-formatter", formatter)) {
GST_INFO ("element properties set and checked");
} else {
GST_WARNING ("error setting up test plugins");