camerabin2: viewfinderbin: Post missing plugin messages

Makes viewfinderbin post missing plugin messages when it
can't create an internal elements
This commit is contained in:
Thiago Santos 2011-03-23 18:41:02 -03:00
parent 54a35ab879
commit 7fd638bd0d

View file

@ -35,6 +35,9 @@
#endif
#include "gstviewfinderbin.h"
#include "camerabingeneral.h"
#include <gst/gst-i18n-plugin.h>
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;
}