mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
autodetect: extract common helper code
The function to generate the pretty names is basically the same. Use one and add a parameter.
This commit is contained in:
parent
ce683b0031
commit
c0fd8e0c39
6 changed files with 38 additions and 88 deletions
|
@ -210,27 +210,6 @@ gst_auto_audio_sink_factory_filter (GstPluginFeature * feature, gpointer data)
|
||||||
return TRUE;
|
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 *
|
static GstElement *
|
||||||
gst_auto_audio_sink_find_best (GstAutoAudioSink * sink)
|
gst_auto_audio_sink_find_best (GstAutoAudioSink * sink)
|
||||||
{
|
{
|
||||||
|
@ -257,7 +236,8 @@ gst_auto_audio_sink_find_best (GstAutoAudioSink * sink)
|
||||||
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
|
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
|
||||||
GstElement *el;
|
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;
|
GstStateChangeReturn ret;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (sink, "Testing %s", GST_OBJECT_NAME (f));
|
GST_DEBUG_OBJECT (sink, "Testing %s", GST_OBJECT_NAME (f));
|
||||||
|
|
|
@ -196,27 +196,6 @@ gst_auto_audio_src_factory_filter (GstPluginFeature * feature, gpointer data)
|
||||||
return TRUE;
|
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 *
|
static GstElement *
|
||||||
gst_auto_audio_src_find_best (GstAutoAudioSrc * src)
|
gst_auto_audio_src_find_best (GstAutoAudioSrc * src)
|
||||||
{
|
{
|
||||||
|
@ -243,7 +222,8 @@ gst_auto_audio_src_find_best (GstAutoAudioSrc * src)
|
||||||
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
|
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
|
||||||
GstElement *el;
|
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;
|
GstStateChangeReturn ret;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (src, "Testing %s", GST_OBJECT_NAME (f));
|
GST_DEBUG_OBJECT (src, "Testing %s", GST_OBJECT_NAME (f));
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
#include "gstautodetect.h"
|
#include "gstautodetect.h"
|
||||||
|
@ -31,6 +33,30 @@
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY (autodetect_debug);
|
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
|
static gboolean
|
||||||
plugin_init (GstPlugin * plugin)
|
plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,4 +23,8 @@
|
||||||
GST_DEBUG_CATEGORY_EXTERN (autodetect_debug);
|
GST_DEBUG_CATEGORY_EXTERN (autodetect_debug);
|
||||||
#define GST_CAT_DEFAULT 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__ */
|
#endif /* __GST_AUTO_DETECT_H__ */
|
||||||
|
|
|
@ -209,27 +209,6 @@ gst_auto_video_sink_factory_filter (GstPluginFeature * feature, gpointer data)
|
||||||
return TRUE;
|
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 *
|
static GstElement *
|
||||||
gst_auto_video_sink_find_best (GstAutoVideoSink * sink)
|
gst_auto_video_sink_find_best (GstAutoVideoSink * sink)
|
||||||
{
|
{
|
||||||
|
@ -253,7 +232,8 @@ gst_auto_video_sink_find_best (GstAutoVideoSink * sink)
|
||||||
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
|
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
|
||||||
GstElement *el;
|
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;
|
GstStateChangeReturn ret;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (sink, "Testing %s", GST_OBJECT_NAME (f));
|
GST_DEBUG_OBJECT (sink, "Testing %s", GST_OBJECT_NAME (f));
|
||||||
|
|
|
@ -195,27 +195,6 @@ gst_auto_video_src_factory_filter (GstPluginFeature * feature, gpointer data)
|
||||||
return TRUE;
|
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 *
|
static GstElement *
|
||||||
gst_auto_video_src_find_best (GstAutoVideoSrc * src)
|
gst_auto_video_src_find_best (GstAutoVideoSrc * src)
|
||||||
{
|
{
|
||||||
|
@ -239,7 +218,8 @@ gst_auto_video_src_find_best (GstAutoVideoSrc * src)
|
||||||
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
|
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
|
||||||
GstElement *el;
|
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;
|
GstStateChangeReturn ret;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (src, "Testing %s", GST_OBJECT_NAME (f));
|
GST_DEBUG_OBJECT (src, "Testing %s", GST_OBJECT_NAME (f));
|
||||||
|
|
Loading…
Reference in a new issue