mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
camerabin: add viewfinder-filter property
Adds a new property called viewfinder-filter to camerabin. This property is used to add a filter to process the video flow right before the viewfinder sink. Also updates test to check property exists.
This commit is contained in:
parent
3b788bac25
commit
16cff06a70
4 changed files with 51 additions and 4 deletions
|
@ -57,7 +57,8 @@ enum
|
|||
ARG_APERTURE,
|
||||
ARG_EXPOSURE,
|
||||
ARG_VIDEO_SOURCE_FILTER,
|
||||
ARG_IMAGE_CAPTURE_SUPPORTED_CAPS
|
||||
ARG_IMAGE_CAPTURE_SUPPORTED_CAPS,
|
||||
ARG_VIEWFINDER_FILTER
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -690,6 +690,14 @@ camerabin_create_view_elements (GstCameraBin * camera)
|
|||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (camera->app_viewfinder_filter) {
|
||||
if (!gst_camerabin_add_element (GST_BIN (camera),
|
||||
camera->app_viewfinder_filter)) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add application set or default video sink element */
|
||||
if (!(camera->view_sink = gst_camerabin_setup_default_element (cbin,
|
||||
camera->app_vf_sink, "autovideosink", DEFAULT_VIDEOSINK))) {
|
||||
|
@ -900,6 +908,11 @@ camerabin_dispose_elements (GstCameraBin * camera)
|
|||
camera->app_video_filter = NULL;
|
||||
}
|
||||
|
||||
if (camera->app_viewfinder_filter) {
|
||||
gst_object_unref (camera->app_viewfinder_filter);
|
||||
camera->app_viewfinder_filter = NULL;
|
||||
}
|
||||
|
||||
/* Free caps */
|
||||
gst_caps_replace (&camera->image_capture_caps, NULL);
|
||||
gst_caps_replace (&camera->view_finder_caps, NULL);
|
||||
|
@ -2711,6 +2724,21 @@ gst_camerabin_class_init (GstCameraBinClass * klass)
|
|||
"Caps defining the preview image format",
|
||||
GST_TYPE_CAPS, G_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GstCameraBin:viewfinder-filter:
|
||||
* Set up viewfinder filter element, all frames going to viewfinder sink
|
||||
* element will be processed by this element.
|
||||
* Applications can use this to overlay text/images in the screen, or
|
||||
* plug facetracking algorithms, for example.
|
||||
* 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_VIEWFINDER_FILTER,
|
||||
g_param_spec_object ("viewfinder-filter", "viewfinder filter element",
|
||||
"viewfinder filter GStreamer element",
|
||||
GST_TYPE_ELEMENT, G_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GstCameraBin::capture-start:
|
||||
* @camera: the camera bin element
|
||||
|
@ -2905,6 +2933,7 @@ gst_camerabin_init (GstCameraBin * camera, GstCameraBinClass * gclass)
|
|||
camera->view_sink = NULL;
|
||||
|
||||
camera->app_vf_sink = NULL;
|
||||
camera->app_viewfinder_filter = NULL;
|
||||
|
||||
/* source elements */
|
||||
camera->src_vid_src = NULL;
|
||||
|
@ -3152,6 +3181,17 @@ gst_camerabin_set_property (GObject * object, guint prop_id,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case ARG_VIEWFINDER_FILTER:
|
||||
if (GST_STATE (camera) != GST_STATE_NULL) {
|
||||
GST_ELEMENT_ERROR (camera, CORE, FAILED,
|
||||
("camerabin must be in NULL state when setting the viewfinder filter element"),
|
||||
(NULL));
|
||||
} else {
|
||||
if (camera->app_viewfinder_filter)
|
||||
gst_object_unref (camera->app_viewfinder_filter);
|
||||
camera->app_viewfinder_filter = g_value_dup_object (value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -3244,6 +3284,9 @@ gst_camerabin_get_property (GObject * object, guint prop_id,
|
|||
else if (camera->mode == MODE_VIDEO)
|
||||
gst_value_set_caps (value, camera->video_preview_caps);
|
||||
break;
|
||||
case ARG_VIEWFINDER_FILTER:
|
||||
g_value_set_object (value, camera->app_viewfinder_filter);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
|
@ -138,6 +138,7 @@ struct _GstCameraBin
|
|||
GstElement *app_vid_src;
|
||||
GstElement *app_vf_sink;
|
||||
GstElement *app_video_filter;
|
||||
GstElement *app_viewfinder_filter;
|
||||
|
||||
/* Night mode handling */
|
||||
gboolean night_mode;
|
||||
|
|
|
@ -122,7 +122,7 @@ static void
|
|||
setup_camerabin_elements (GstElement * camera)
|
||||
{
|
||||
GstElement *vfsink, *audiosrc, *videosrc, *audioenc, *videoenc, *imageenc,
|
||||
*videomux;
|
||||
*videomux, *viewfinder_filter;
|
||||
GstCaps *audiocaps, *videocaps;
|
||||
|
||||
/* Use fakesink for view finder */
|
||||
|
@ -143,12 +143,14 @@ setup_camerabin_elements (GstElement * camera)
|
|||
gst_caps_unref (videocaps);
|
||||
videomux = gst_element_factory_make ("avimux", NULL);
|
||||
imageenc = gst_element_factory_make ("jpegenc", NULL);
|
||||
viewfinder_filter = gst_element_factory_make ("identity", NULL);
|
||||
|
||||
if (vfsink && audiosrc && videosrc && audioenc && videoenc && videomux
|
||||
&& imageenc) {
|
||||
&& imageenc && viewfinder_filter) {
|
||||
g_object_set (camera, "viewfinder-sink", vfsink, "audio-source", audiosrc,
|
||||
"video-source", videosrc, "audio-encoder", audioenc, "video-encoder",
|
||||
videoenc, "image-encoder", imageenc, "video-muxer", videomux, NULL);
|
||||
videoenc, "image-encoder", imageenc, "video-muxer", videomux,
|
||||
"viewfinder-filter", viewfinder_filter, NULL);
|
||||
} else {
|
||||
GST_WARNING ("error setting up test plugins");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue