mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
viewfinderbin: Improve elements creation
Be more careful with cleanup of elements. Also add some logs and improve docs a little.
This commit is contained in:
parent
19e52f35ee
commit
0685b8921e
1 changed files with 28 additions and 5 deletions
|
@ -19,14 +19,14 @@
|
||||||
/**
|
/**
|
||||||
* SECTION:element-gstviewfinderbin
|
* SECTION:element-gstviewfinderbin
|
||||||
*
|
*
|
||||||
* The gstviewfinderbin element does FIXME stuff.
|
* The gstviewfinderbin element is a displaying element for camerabin2.
|
||||||
*
|
*
|
||||||
* <refsect2>
|
* <refsect2>
|
||||||
* <title>Example launch line</title>
|
* <title>Example launch line</title>
|
||||||
* |[
|
* |[
|
||||||
* gst-launch -v videotestsrc ! viewfinderbin
|
* gst-launch -v videotestsrc ! viewfinderbin
|
||||||
* ]|
|
* ]|
|
||||||
* FIXME Describe what the pipeline does.
|
* Feeds the viewfinderbin with video test data.
|
||||||
* </refsect2>
|
* </refsect2>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -36,6 +36,9 @@
|
||||||
|
|
||||||
#include "gstviewfinderbin.h"
|
#include "gstviewfinderbin.h"
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_STATIC (gst_viewfinder_bin_debug);
|
||||||
|
#define GST_CAT_DEFAULT gst_viewfinder_bin_debug
|
||||||
|
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,10 +100,13 @@ gst_viewfinder_bin_init (GstViewfinderBin * viewfinderbin,
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_viewfinder_bin_create_elements (GstViewfinderBin * vfbin)
|
gst_viewfinder_bin_create_elements (GstViewfinderBin * vfbin)
|
||||||
{
|
{
|
||||||
GstElement *csp;
|
GstElement *csp = NULL;
|
||||||
GstElement *videoscale;
|
GstElement *videoscale = NULL;
|
||||||
GstElement *sink;
|
GstElement *sink = NULL;
|
||||||
GstPad *pad = NULL;
|
GstPad *pad = NULL;
|
||||||
|
gboolean added = FALSE;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (vfbin, "Creating internal elements");
|
||||||
|
|
||||||
if (vfbin->elements_created)
|
if (vfbin->elements_created)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -118,8 +124,11 @@ gst_viewfinder_bin_create_elements (GstViewfinderBin * vfbin)
|
||||||
if (!sink)
|
if (!sink)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (vfbin, "Internal elements created, proceding to linking");
|
||||||
|
|
||||||
/* add and link */
|
/* add and link */
|
||||||
gst_bin_add_many (GST_BIN_CAST (vfbin), csp, videoscale, sink, NULL);
|
gst_bin_add_many (GST_BIN_CAST (vfbin), csp, videoscale, sink, NULL);
|
||||||
|
added = TRUE;
|
||||||
if (!gst_element_link_many (csp, videoscale, sink, NULL))
|
if (!gst_element_link_many (csp, videoscale, sink, NULL))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -129,11 +138,23 @@ gst_viewfinder_bin_create_elements (GstViewfinderBin * vfbin)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
vfbin->elements_created = TRUE;
|
vfbin->elements_created = TRUE;
|
||||||
|
GST_DEBUG_OBJECT (vfbin, "Elements succesfully created and linked");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
GST_WARNING_OBJECT (vfbin, "Creating internal elements failed");
|
||||||
if (pad)
|
if (pad)
|
||||||
gst_object_unref (pad);
|
gst_object_unref (pad);
|
||||||
|
if (!added) {
|
||||||
|
if (csp)
|
||||||
|
gst_object_unref (csp);
|
||||||
|
if (videoscale)
|
||||||
|
gst_object_unref (videoscale);
|
||||||
|
if (sink)
|
||||||
|
gst_object_unref (sink);
|
||||||
|
} else {
|
||||||
|
gst_bin_remove_many (GST_BIN_CAST (vfbin), csp, videoscale, sink, NULL);
|
||||||
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +189,8 @@ gst_viewfinder_bin_change_state (GstElement * element, GstStateChange trans)
|
||||||
gboolean
|
gboolean
|
||||||
gst_viewfinder_bin_plugin_init (GstPlugin * plugin)
|
gst_viewfinder_bin_plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
|
GST_DEBUG_CATEGORY_INIT (gst_viewfinder_bin_debug, "viewfinderbin", 0,
|
||||||
|
"ViewFinderBin");
|
||||||
return gst_element_register (plugin, "viewfinderbin", GST_RANK_NONE,
|
return gst_element_register (plugin, "viewfinderbin", GST_RANK_NONE,
|
||||||
gst_viewfinder_bin_get_type ());
|
gst_viewfinder_bin_get_type ());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue