{
GstCameraBin *camerabin = GST_CAMERA_BIN_CAST (object);
+ gst_object_unref (camerabin->vf_bin);
+
g_free (camerabin->img_location);
g_free (camerabin->vid_location);
camerabin->mode = DEFAULT_MODE;
camerabin->vid_location = g_strdup (DEFAULT_VID_LOCATION);
camerabin->img_location = g_strdup (DEFAULT_IMG_LOCATION);
+ camerabin->vf_bin = gst_element_factory_make ("viewfinderbin", "vf-bin");
+
+ gst_bin_add (GST_BIN (camerabin), gst_object_ref (camerabin->vf_bin));
}
/**
GstElement *src;
GstElement *vid;
GstElement *img;
- GstElement *vf;
GstElement *vid_queue;
GstElement *img_queue;
GstElement *vf_queue;
src = gst_element_factory_make ("v4l2camerasrc", "camerasrc");
vid = gst_element_factory_make ("videorecordingbin", "video-rec-bin");
img = gst_element_factory_make ("imagecapturebin", "image-cap-bin");
- vf = gst_element_factory_make ("viewfinderbin", "vf-bin");
camera->src = gst_object_ref (src);
camera->vidbin = gst_object_ref (vid);
img_capsfilter = gst_element_factory_make ("capsfilter", "image-capsfilter");
vf_capsfilter = gst_element_factory_make ("capsfilter", "vf-capsfilter");
- gst_bin_add_many (GST_BIN_CAST (camera), src, vid, img, vf, vid_queue,
- img_queue, vf_queue, vid_capsfilter, img_capsfilter, vf_capsfilter, NULL);
+ gst_bin_add_many (GST_BIN_CAST (camera), src, vid, img,
+ vid_queue, img_queue, vf_queue, vid_capsfilter, img_capsfilter,
+ vf_capsfilter, NULL);
/* Linking can be optimized TODO */
gst_element_link_many (vid_queue, vid_capsfilter, vid, NULL);
gst_element_link_many (img_queue, img_capsfilter, img, NULL);
- gst_element_link_many (vf_queue, vf_capsfilter, vf, NULL);
+ gst_element_link_many (vf_queue, vf_capsfilter, camera->vf_bin, NULL);
gst_element_link_pads (src, "vfsrc", vf_queue, "sink");
gst_element_link_pads (src, "imgsrc", img_queue, "sink");
gst_element_link_pads (src, "vidsrc", vid_queue, "sink");
enum
{
- PROP_0
+ PROP_0,
+ PROP_VIDEO_SINK,
};
/* pad templates */
GST_BOILERPLATE (GstViewfinderBin, gst_viewfinder_bin, GstBin, GST_TYPE_BIN);
+static void gst_viewfinder_bin_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * spec);
+static void gst_viewfinder_bin_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * spec);
+
+static void
+gst_viewfinder_bin_set_video_sink (GstViewfinderBin * vfbin, GstElement * sink);
+
+
/* Element class functions */
static GstStateChangeReturn
gst_viewfinder_bin_change_state (GstElement * element, GstStateChange trans);
static void
gst_viewfinder_bin_class_init (GstViewfinderBinClass * klass)
{
+ GObjectClass *gobject_klass;
GstElementClass *element_class;
+ gobject_klass = (GObjectClass *) klass;
element_class = GST_ELEMENT_CLASS (klass);
element_class->change_state =
GST_DEBUG_FUNCPTR (gst_viewfinder_bin_change_state);
+
+ gobject_klass->set_property = gst_viewfinder_bin_set_property;
+ gobject_klass->get_property = gst_viewfinder_bin_get_property;
+
+ g_object_class_install_property (gobject_klass, PROP_VIDEO_SINK,
+ g_param_spec_object ("video-sink", "Video Sink",
+ "the video output element to use (NULL = default)",
+ GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
gst_static_pad_template_get (&sink_template));
gst_element_add_pad (GST_ELEMENT_CAST (viewfinderbin),
viewfinderbin->ghostpad);
+
+ viewfinderbin->video_sink = NULL;
}
static gboolean
if (!videoscale)
goto error;
- sink = gst_element_factory_make ("autovideosink", "vfbin-sink");
- if (!sink)
- goto error;
+ if (vfbin->video_sink) {
+ sink = vfbin->video_sink;
+ } else {
+ sink = gst_element_factory_make ("autovideosink", "vfbin-sink");
+ if (!sink)
+ goto error;
+ }
GST_DEBUG_OBJECT (vfbin, "Internal elements created, proceding to linking");
return ret;
}
+static void
+gst_viewfinder_bin_set_video_sink (GstViewfinderBin * vfbin, GstElement * sink)
+{
+ GST_INFO_OBJECT (vfbin, "Setting video sink to %" GST_PTR_FORMAT, sink);
+
+ if (vfbin->video_sink != sink) {
+ if (sink)
+ gst_object_ref_sink (sink);
+
+ if (vfbin->video_sink)
+ gst_object_unref (vfbin->video_sink);
+
+ vfbin->video_sink = sink;
+ }
+
+ GST_LOG_OBJECT (vfbin, "Video sink is now %" GST_PTR_FORMAT, sink);
+}
+
+static void
+gst_viewfinder_bin_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstViewfinderBin *vfbin = GST_VIEWFINDER_BIN_CAST (object);
+
+ switch (prop_id) {
+ case PROP_VIDEO_SINK:
+ gst_viewfinder_bin_set_video_sink (vfbin, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_viewfinder_bin_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
+{
+ GstViewfinderBin *vfbin = GST_VIEWFINDER_BIN_CAST (object);
+
+ switch (prop_id) {
+ case PROP_VIDEO_SINK:
+ g_value_take_object (value, vfbin->video_sink);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
gboolean
gst_viewfinder_bin_plugin_init (GstPlugin * plugin)
{