From 7fd638bd0dcacde3c26d06b9c3b2ec1d2c2e4a8b Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Wed, 23 Mar 2011 18:41:02 -0300 Subject: [PATCH] camerabin2: viewfinderbin: Post missing plugin messages Makes viewfinderbin post missing plugin messages when it can't create an internal elements --- gst/camerabin2/gstviewfinderbin.c | 42 +++++++++++++++---------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/gst/camerabin2/gstviewfinderbin.c b/gst/camerabin2/gstviewfinderbin.c index e03631e328..61a113c71a 100644 --- a/gst/camerabin2/gstviewfinderbin.c +++ b/gst/camerabin2/gstviewfinderbin.c @@ -35,6 +35,9 @@ #endif #include "gstviewfinderbin.h" +#include "camerabingeneral.h" + +#include GST_DEBUG_CATEGORY_STATIC (gst_viewfinder_bin_debug); #define GST_CAT_DEFAULT gst_viewfinder_bin_debug @@ -144,33 +147,29 @@ gst_viewfinder_bin_create_elements (GstViewfinderBin * vfbin) GstElement *csp = NULL; GstElement *videoscale = NULL; GstPad *pad = NULL; - gboolean added = FALSE; GST_DEBUG_OBJECT (vfbin, "Creating internal elements"); if (!vfbin->elements_created) { /* create elements */ - csp = gst_element_factory_make ("ffmpegcolorspace", "vfbin-csp"); + csp = + gst_camerabin_create_and_add_element (GST_BIN (vfbin), + "ffmpegcolorspace", "vfbin-csp"); if (!csp) goto error; - videoscale = gst_element_factory_make ("videoscale", "vfbin-videoscale"); + videoscale = + gst_camerabin_create_and_add_element (GST_BIN (vfbin), "videoscale", + "vfbin-videoscale"); if (!videoscale) goto error; - GST_DEBUG_OBJECT (vfbin, "Internal elements created, proceding to linking"); - - /* add and link */ - gst_bin_add_many (GST_BIN_CAST (vfbin), csp, videoscale, NULL); - added = TRUE; - if (!gst_element_link (csp, videoscale)) - goto error; - /* add ghostpad */ pad = gst_element_get_static_pad (csp, "sink"); if (!gst_ghost_pad_set_target (GST_GHOST_PAD (vfbin->ghostpad), pad)) goto error; gst_object_unref (pad); + pad = NULL; vfbin->elements_created = TRUE; GST_DEBUG_OBJECT (vfbin, "Elements succesfully created and linked"); @@ -188,9 +187,14 @@ gst_viewfinder_bin_create_elements (GstViewfinderBin * vfbin) if (!vfbin->video_sink) { if (vfbin->user_video_sink) vfbin->video_sink = gst_object_ref (vfbin->user_video_sink); - else + else { vfbin->video_sink = gst_element_factory_make ("autovideosink", "vfbin-sink"); + GST_ELEMENT_ERROR (vfbin, CORE, MISSING_PLUGIN, + (_("Missing element '%s' - check your GStreamer installation."), + "autovideosink"), (NULL)); + goto error; + } gst_bin_add (GST_BIN_CAST (vfbin), gst_object_ref (vfbin->video_sink)); @@ -199,8 +203,12 @@ gst_viewfinder_bin_create_elements (GstViewfinderBin * vfbin) "vfbin-videoscale"); if (!gst_element_link_pads (videoscale, "src", vfbin->video_sink, "sink")) { - GST_WARNING_OBJECT (vfbin, "Failed to link the new sink"); + GST_ELEMENT_ERROR (vfbin, CORE, NEGOTIATION, (NULL), + ("linking videoscale and viewfindersink failed")); } + + /* prevent it from being removed from the bin at this point */ + videoscale = NULL; } return TRUE; @@ -209,14 +217,6 @@ error: GST_WARNING_OBJECT (vfbin, "Creating internal elements failed"); if (pad) gst_object_unref (pad); - if (!added) { - if (csp) - gst_object_unref (csp); - if (videoscale) - gst_object_unref (videoscale); - } else { - gst_bin_remove_many (GST_BIN_CAST (vfbin), csp, videoscale, NULL); - } return FALSE; }