diff --git a/gst/camerabin/gstcamerabin-enum.h b/gst/camerabin/gstcamerabin-enum.h index 3794201623..776a774e9d 100644 --- a/gst/camerabin/gstcamerabin-enum.h +++ b/gst/camerabin/gstcamerabin-enum.h @@ -55,7 +55,8 @@ enum ARG_EV_COMP, ARG_ISO_SPEED, ARG_APERTURE, - ARG_EXPOSURE + ARG_EXPOSURE, + ARG_VIDEO_SOURCE_FILTER }; /** diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c index 66ea55f5bb..fdadfb489a 100644 --- a/gst/camerabin/gstcamerabin.c +++ b/gst/camerabin/gstcamerabin.c @@ -125,7 +125,7 @@ * The pipeline in the camerabin is * * videosrc [ ! ffmpegcsp ] ! capsfilter ! crop ! scale ! capsfilter ! \ - * out-sel name=osel ! queue name=img_q + * [ video_filter ! ] out-sel name=osel ! queue name=img_q * * View finder: * osel. ! in-sel name=isel ! scale ! capsfilter [ ! ffmpegcsp ] ! vfsink @@ -583,6 +583,11 @@ camerabin_create_src_elements (GstCameraBin * camera) gst_camerabin_create_and_add_element (cbin, "capsfilter"))) goto done; } + if (camera->app_video_filter) { + if (!gst_camerabin_add_element (cbin, camera->app_video_filter)) { + goto done; + } + } if (!(camera->src_out_sel = gst_camerabin_create_and_add_element (cbin, "output-selector"))) goto done; @@ -883,6 +888,11 @@ camerabin_dispose_elements (GstCameraBin * camera) camera->user_vid_src = NULL; } + if (camera->app_video_filter) { + gst_object_unref (camera->app_video_filter); + camera->app_video_filter = NULL; + } + /* Free caps */ gst_caps_replace (&camera->image_capture_caps, NULL); gst_caps_replace (&camera->view_finder_caps, NULL); @@ -2580,6 +2590,23 @@ gst_camerabin_class_init (GstCameraBinClass * klass) "Audio source GStreamer element (NULL = default audio src)", GST_TYPE_ELEMENT, G_PARAM_READWRITE)); + /** + * GstCameraBin:video-source-filter: + * + * Set up optional video filter element, all frames from video source + * will be processed by this element. e.g. An application might add + * image enhancers/parameter adjustment filters here to improve captured + * image/video results, or add analyzers to give feedback on capture + * the application. + * 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_VIDEO_SOURCE_FILTER, + g_param_spec_object ("video-source-filter", "video source filter element", + "Optional video filter GStreamer element, filters all frames from" + "the video source", GST_TYPE_ELEMENT, G_PARAM_READWRITE)); + /** * GstCameraBin:video-source-caps: * @@ -2825,6 +2852,7 @@ gst_camerabin_init (GstCameraBin * camera, GstCameraBinClass * gclass) camera->src_zoom_filter = NULL; camera->src_out_sel = NULL; + camera->app_video_filter = NULL; camera->user_vid_src = NULL; camera->active_bin = NULL; @@ -3007,6 +3035,17 @@ gst_camerabin_set_property (GObject * object, guint prop_id, gst_camerabin_video_set_audio_src (GST_CAMERABIN_VIDEO (camera->vidbin), g_value_get_object (value)); break; + case ARG_VIDEO_SOURCE_FILTER: + if (GST_STATE (camera) != GST_STATE_NULL) { + GST_ELEMENT_ERROR (camera, CORE, FAILED, + ("camerabin must be in NULL state when setting the video filter element"), + (NULL)); + } else { + if (camera->app_video_filter) + gst_object_unref (camera->app_video_filter); + camera->app_video_filter = g_value_dup_object (value); + } + break; case ARG_FILTER_CAPS: GST_OBJECT_LOCK (camera); gst_caps_replace (&camera->view_finder_caps, @@ -3125,6 +3164,9 @@ gst_camerabin_get_property (GObject * object, guint prop_id, gst_camerabin_video_get_audio_src (GST_CAMERABIN_VIDEO (camera->vidbin))); break; + case ARG_VIDEO_SOURCE_FILTER: + g_value_set_object (value, camera->app_video_filter); + break; case ARG_INPUT_CAPS: gst_value_set_caps (value, gst_camerabin_get_allowed_input_caps (camera)); break; diff --git a/gst/camerabin/gstcamerabin.h b/gst/camerabin/gstcamerabin.h index 58350c3aae..a7dd674a1f 100644 --- a/gst/camerabin/gstcamerabin.h +++ b/gst/camerabin/gstcamerabin.h @@ -137,6 +137,7 @@ struct _GstCameraBin /* User configurable elements */ GstElement *user_vid_src; GstElement *user_vf_sink; + GstElement *app_video_filter; /* Night mode handling */ gboolean night_mode;