camerabin2: Add names to some elements

Adds names to instances of some elements to make debugging easier
This commit is contained in:
Thiago Santos 2011-01-26 10:54:53 -03:00
parent 6395b45908
commit b66dde5746
4 changed files with 35 additions and 20 deletions

View file

@ -138,6 +138,7 @@ gst_camerabin_try_add_element (GstBin * bin, const gchar * srcpad,
* gst_camerabin_create_and_add_element: * gst_camerabin_create_and_add_element:
* @bin: tries adding an element to this bin * @bin: tries adding an element to this bin
* @elem_name: name of the element to be created * @elem_name: name of the element to be created
* @instance_name: name of the instance of the element to be created
* *
* Creates an element according to given name and * Creates an element according to given name and
* adds it to given @bin. Looks for an unconnected src pad * adds it to given @bin. Looks for an unconnected src pad
@ -146,14 +147,15 @@ gst_camerabin_try_add_element (GstBin * bin, const gchar * srcpad,
* Returns: pointer to the new element if successful, NULL otherwise. * Returns: pointer to the new element if successful, NULL otherwise.
*/ */
GstElement * GstElement *
gst_camerabin_create_and_add_element (GstBin * bin, const gchar * elem_name) gst_camerabin_create_and_add_element (GstBin * bin, const gchar * elem_name,
const gchar * instance_name)
{ {
GstElement *new_elem; GstElement *new_elem;
g_return_val_if_fail (bin, FALSE); g_return_val_if_fail (bin, FALSE);
g_return_val_if_fail (elem_name, FALSE); g_return_val_if_fail (elem_name, FALSE);
new_elem = gst_element_factory_make (elem_name, NULL); new_elem = gst_element_factory_make (elem_name, instance_name);
if (!new_elem) { if (!new_elem) {
GST_ELEMENT_ERROR (bin, CORE, MISSING_PLUGIN, (NULL), GST_ELEMENT_ERROR (bin, CORE, MISSING_PLUGIN, (NULL),
("could not create \"%s\" element.", elem_name)); ("could not create \"%s\" element.", elem_name));
@ -187,7 +189,8 @@ try_element (GstElement * bin, GstElement * element, gboolean unref)
GstElement * GstElement *
gst_camerabin_setup_default_element (GstBin * bin, GstElement * user_elem, gst_camerabin_setup_default_element (GstBin * bin, GstElement * user_elem,
const gchar * auto_elem_name, const gchar * default_elem_name) const gchar * auto_elem_name, const gchar * default_elem_name,
const gchar * instance_name)
{ {
GstElement *elem; GstElement *elem;
@ -197,13 +200,13 @@ gst_camerabin_setup_default_element (GstBin * bin, GstElement * user_elem,
} else { } else {
/* only try fallback if no specific sink was chosen */ /* only try fallback if no specific sink was chosen */
GST_DEBUG_OBJECT (bin, "trying %s", auto_elem_name); GST_DEBUG_OBJECT (bin, "trying %s", auto_elem_name);
elem = gst_element_factory_make (auto_elem_name, NULL); elem = gst_element_factory_make (auto_elem_name, instance_name);
elem = try_element (GST_ELEMENT_CAST (bin), elem, TRUE); elem = try_element (GST_ELEMENT_CAST (bin), elem, TRUE);
if (elem == NULL) { if (elem == NULL) {
/* if default sink from config.h is different then try it too */ /* if default sink from config.h is different then try it too */
if (strcmp (default_elem_name, auto_elem_name)) { if (strcmp (default_elem_name, auto_elem_name)) {
GST_DEBUG_OBJECT (bin, "trying %s", default_elem_name); GST_DEBUG_OBJECT (bin, "trying %s", default_elem_name);
elem = gst_element_factory_make (default_elem_name, NULL); elem = gst_element_factory_make (default_elem_name, instance_name);
elem = try_element (GST_ELEMENT_CAST (bin), elem, TRUE); elem = try_element (GST_ELEMENT_CAST (bin), elem, TRUE);
} }
} }

View file

@ -43,9 +43,10 @@ gboolean gst_camerabin_try_add_element (GstBin * bin, const gchar * srcpad, GstE
gboolean gst_camerabin_add_element (GstBin * bin, GstElement * new_elem); gboolean gst_camerabin_add_element (GstBin * bin, GstElement * new_elem);
gboolean gst_camerabin_add_element_full (GstBin * bin, const gchar * srcpad, GstElement * new_elem, const gchar * dstpad); gboolean gst_camerabin_add_element_full (GstBin * bin, const gchar * srcpad, GstElement * new_elem, const gchar * dstpad);
GstElement *gst_camerabin_create_and_add_element (GstBin * bin, const gchar * elem_name); GstElement *gst_camerabin_create_and_add_element (GstBin * bin, const gchar * elem_name, const gchar * instance_name);
GstElement * gst_camerabin_setup_default_element (GstBin * bin, GstElement *user_elem, const gchar *auto_elem_name, const gchar *default_elem_name); GstElement * gst_camerabin_setup_default_element (GstBin * bin, GstElement *user_elem, const gchar *auto_elem_name, const gchar *default_elem_name,
const gchar * instance_elem_name);
void gst_camerabin_remove_elements_from_bin (GstBin * bin); void gst_camerabin_remove_elements_from_bin (GstBin * bin);

View file

@ -261,7 +261,7 @@ gst_image_capture_bin_create_elements (GstImageCaptureBin * imagebin)
/* create elements */ /* create elements */
colorspace = colorspace =
gst_camerabin_create_and_add_element (GST_BIN (imagebin), gst_camerabin_create_and_add_element (GST_BIN (imagebin),
DEFAULT_COLORSPACE); DEFAULT_COLORSPACE, "imagebin-colorspace");
if (!colorspace) if (!colorspace)
goto error; goto error;
@ -273,7 +273,7 @@ gst_image_capture_bin_create_elements (GstImageCaptureBin * imagebin)
} else { } else {
imagebin->encoder = imagebin->encoder =
gst_camerabin_create_and_add_element (GST_BIN (imagebin), gst_camerabin_create_and_add_element (GST_BIN (imagebin),
DEFAULT_ENCODER); DEFAULT_ENCODER, "imagebin-encoder");
if (!imagebin->encoder) if (!imagebin->encoder)
goto error; goto error;
} }
@ -286,13 +286,14 @@ gst_image_capture_bin_create_elements (GstImageCaptureBin * imagebin)
} else { } else {
imagebin->muxer = imagebin->muxer =
gst_camerabin_create_and_add_element (GST_BIN (imagebin), gst_camerabin_create_and_add_element (GST_BIN (imagebin),
DEFAULT_MUXER); DEFAULT_MUXER, "imagebin-muxer");
if (!imagebin->muxer) if (!imagebin->muxer)
goto error; goto error;
} }
imagebin->sink = imagebin->sink =
gst_camerabin_create_and_add_element (GST_BIN (imagebin), DEFAULT_SINK); gst_camerabin_create_and_add_element (GST_BIN (imagebin), DEFAULT_SINK,
"imagebin-sink");
if (!imagebin->sink) if (!imagebin->sink)
goto error; goto error;

View file

@ -298,7 +298,8 @@ gst_wrapper_camera_bin_src_construct_pipeline (GstBaseCameraSrc * bcamsrc)
/* Add application set or default video src element */ /* Add application set or default video src element */
if (!(self->src_vid_src = gst_camerabin_setup_default_element (cbin, if (!(self->src_vid_src = gst_camerabin_setup_default_element (cbin,
self->app_vid_src, "autovideosrc", DEFAULT_VIDEOSRC))) { self->app_vid_src, "autovideosrc", DEFAULT_VIDEOSRC,
"camerasrc-real-src"))) {
self->src_vid_src = NULL; self->src_vid_src = NULL;
goto done; goto done;
} else { } else {
@ -319,24 +320,30 @@ gst_wrapper_camera_bin_src_construct_pipeline (GstBaseCameraSrc * bcamsrc)
gst_object_unref (pad); gst_object_unref (pad);
} }
if (!gst_camerabin_create_and_add_element (cbin, "ffmpegcolorspace")) if (!gst_camerabin_create_and_add_element (cbin, "ffmpegcolorspace",
"src-colorspace"))
goto done; goto done;
if (!(self->src_filter = if (!(self->src_filter =
gst_camerabin_create_and_add_element (cbin, "capsfilter"))) gst_camerabin_create_and_add_element (cbin, "capsfilter",
"src-capsfilter")))
goto done; goto done;
if (!(self->src_zoom_crop = if (!(self->src_zoom_crop =
gst_camerabin_create_and_add_element (cbin, "videocrop"))) gst_camerabin_create_and_add_element (cbin, "videocrop",
"zoom-crop")))
goto done; goto done;
if (!(self->src_zoom_scale = if (!(self->src_zoom_scale =
gst_camerabin_create_and_add_element (cbin, "videoscale"))) gst_camerabin_create_and_add_element (cbin, "videoscale",
"zoom-scale")))
goto done; goto done;
if (!(self->src_zoom_filter = if (!(self->src_zoom_filter =
gst_camerabin_create_and_add_element (cbin, "capsfilter"))) gst_camerabin_create_and_add_element (cbin, "capsfilter",
"zoom-capsfilter")))
goto done; goto done;
if (!(tee = gst_camerabin_create_and_add_element (cbin, "tee"))) if (!(tee =
gst_camerabin_create_and_add_element (cbin, "tee", "camerasrc-tee")))
goto done; goto done;
/* viewfinder pad */ /* viewfinder pad */
@ -345,9 +352,12 @@ gst_wrapper_camera_bin_src_construct_pipeline (GstBaseCameraSrc * bcamsrc)
gst_object_unref (vf_pad); gst_object_unref (vf_pad);
/* the viewfinder should always work, so we add some converters to it */ /* the viewfinder should always work, so we add some converters to it */
if (!gst_camerabin_create_and_add_element (cbin, "ffmpegcolorspace")) if (!gst_camerabin_create_and_add_element (cbin, "ffmpegcolorspace",
"viewfinder-colorspace"))
goto done; goto done;
if (!(videoscale = gst_camerabin_create_and_add_element (cbin, "videoscale"))) if (!(videoscale =
gst_camerabin_create_and_add_element (cbin, "videoscale",
"viewfinder-scale")))
goto done; goto done;
/* image/video pad from tee */ /* image/video pad from tee */