The function to generate the pretty names is basically the same. Use one and add
a parameter.
return TRUE;
}
-static GstElement *
-gst_auto_audio_sink_create_element_with_pretty_name (GstAutoAudioSink * sink,
- GstElementFactory * factory)
-{
- GstElement *element;
- gchar *name, *marker;
-
- marker = g_strdup (GST_OBJECT_NAME (factory));
- if (g_str_has_suffix (marker, "sink"))
- marker[strlen (marker) - 4] = '\0';
- if (g_str_has_prefix (marker, "gst"))
- memmove (marker, marker + 3, strlen (marker + 3) + 1);
- name = g_strdup_printf ("%s-actual-sink-%s", GST_OBJECT_NAME (sink), marker);
- g_free (marker);
-
- element = gst_element_factory_create (factory, name);
- g_free (name);
-
- return element;
-}
-
static GstElement *
gst_auto_audio_sink_find_best (GstAutoAudioSink * sink)
{
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
GstElement *el;
- if ((el = gst_auto_audio_sink_create_element_with_pretty_name (sink, f))) {
+ if ((el = gst_auto_create_element_with_pretty_name (GST_ELEMENT_CAST (sink),
+ f, "sink"))) {
GstStateChangeReturn ret;
GST_DEBUG_OBJECT (sink, "Testing %s", GST_OBJECT_NAME (f));
return TRUE;
}
-static GstElement *
-gst_auto_audio_src_create_element_with_pretty_name (GstAutoAudioSrc * src,
- GstElementFactory * factory)
-{
- GstElement *element;
- gchar *name, *marker;
-
- marker = g_strdup (GST_OBJECT_NAME (factory));
- if (g_str_has_suffix (marker, "src"))
- marker[strlen (marker) - 4] = '\0';
- if (g_str_has_prefix (marker, "gst"))
- memmove (marker, marker + 3, strlen (marker + 3) + 1);
- name = g_strdup_printf ("%s-actual-src-%s", GST_OBJECT_NAME (src), marker);
- g_free (marker);
-
- element = gst_element_factory_create (factory, name);
- g_free (name);
-
- return element;
-}
-
static GstElement *
gst_auto_audio_src_find_best (GstAutoAudioSrc * src)
{
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
GstElement *el;
- if ((el = gst_auto_audio_src_create_element_with_pretty_name (src, f))) {
+ if ((el = gst_auto_create_element_with_pretty_name (GST_ELEMENT_CAST (src),
+ f, "src"))) {
GstStateChangeReturn ret;
GST_DEBUG_OBJECT (src, "Testing %s", GST_OBJECT_NAME (f));
#include "config.h"
#endif
+#include <string.h>
+
#include <gst/gst.h>
#include "gstautodetect.h"
GST_DEBUG_CATEGORY (autodetect_debug);
+GstElement *
+gst_auto_create_element_with_pretty_name (GstElement * autodetect,
+ GstElementFactory * factory, const gchar * suffix)
+{
+ GstElement *element;
+ gchar *name, *marker;
+
+ marker = g_strdup (GST_OBJECT_NAME (factory));
+ if (g_str_has_suffix (marker, suffix))
+ marker[strlen (marker) - 4] = '\0';
+ if (g_str_has_prefix (marker, "gst"))
+ memmove (marker, marker + 3, strlen (marker + 3) + 1);
+ name = g_strdup_printf ("%s-actual-%s-%s", GST_OBJECT_NAME (autodetect),
+ suffix, marker);
+ g_free (marker);
+
+ element = gst_element_factory_create (factory, name);
+ g_free (name);
+
+ return element;
+}
+
+
+
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_EXTERN (autodetect_debug);
#define GST_CAT_DEFAULT autodetect_debug
+GstElement * gst_auto_create_element_with_pretty_name (
+ GstElement * autodetect, GstElementFactory * factory, const gchar *suffix);
+
+
#endif /* __GST_AUTO_DETECT_H__ */
return TRUE;
}
-static GstElement *
-gst_auto_video_sink_create_element_with_pretty_name (GstAutoVideoSink * sink,
- GstElementFactory * factory)
-{
- GstElement *element;
- gchar *name, *marker;
-
- marker = g_strdup (GST_OBJECT_NAME (factory));
- if (g_str_has_suffix (marker, "sink"))
- marker[strlen (marker) - 4] = '\0';
- if (g_str_has_prefix (marker, "gst"))
- memmove (marker, marker + 3, strlen (marker + 3) + 1);
- name = g_strdup_printf ("%s-actual-sink-%s", GST_OBJECT_NAME (sink), marker);
- g_free (marker);
-
- element = gst_element_factory_create (factory, name);
- g_free (name);
-
- return element;
-}
-
static GstElement *
gst_auto_video_sink_find_best (GstAutoVideoSink * sink)
{
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
GstElement *el;
- if ((el = gst_auto_video_sink_create_element_with_pretty_name (sink, f))) {
+ if ((el = gst_auto_create_element_with_pretty_name (GST_ELEMENT_CAST (sink),
+ f, "sink"))) {
GstStateChangeReturn ret;
GST_DEBUG_OBJECT (sink, "Testing %s", GST_OBJECT_NAME (f));
return TRUE;
}
-static GstElement *
-gst_auto_video_src_create_element_with_pretty_name (GstAutoVideoSrc * src,
- GstElementFactory * factory)
-{
- GstElement *element;
- gchar *name, *marker;
-
- marker = g_strdup (GST_OBJECT_NAME (factory));
- if (g_str_has_suffix (marker, "src"))
- marker[strlen (marker) - 4] = '\0';
- if (g_str_has_prefix (marker, "gst"))
- memmove (marker, marker + 3, strlen (marker + 3) + 1);
- name = g_strdup_printf ("%s-actual-src-%s", GST_OBJECT_NAME (src), marker);
- g_free (marker);
-
- element = gst_element_factory_create (factory, name);
- g_free (name);
-
- return element;
-}
-
static GstElement *
gst_auto_video_src_find_best (GstAutoVideoSrc * src)
{
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
GstElement *el;
- if ((el = gst_auto_video_src_create_element_with_pretty_name (src, f))) {
+ if ((el = gst_auto_create_element_with_pretty_name (GST_ELEMENT_CAST (src),
+ f, "src"))) {
GstStateChangeReturn ret;
GST_DEBUG_OBJECT (src, "Testing %s", GST_OBJECT_NAME (f));