mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
autoaudiosrc: use audiotestsrc as fallback element instead of fakesrc
fakesrc doesn't announce audio caps, so most audio pipelines will just error out with not-negotiated if a fallback element is created.
This commit is contained in:
parent
07a3a98391
commit
7dcc3ffe5a
3 changed files with 40 additions and 2 deletions
|
@ -49,9 +49,30 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS_ANY);
|
GST_STATIC_CAPS_ANY);
|
||||||
|
|
||||||
|
static GstElement *
|
||||||
|
gst_auto_audio_src_create_fake_element (GstAutoDetect * autodetect)
|
||||||
|
{
|
||||||
|
GstElement *fake;
|
||||||
|
|
||||||
|
fake = gst_element_factory_make ("audiotestsrc", "fake-auto-audio-src");
|
||||||
|
if (fake != NULL) {
|
||||||
|
g_object_set (fake, "is-live", TRUE, NULL);
|
||||||
|
gst_util_set_object_arg (G_OBJECT (fake), "wave", "silence");
|
||||||
|
} else {
|
||||||
|
GST_ELEMENT_ERROR (autodetect, RESOURCE, NOT_FOUND,
|
||||||
|
("Failed to find usable audio source element."),
|
||||||
|
("Failed to find a usable audio source and couldn't create an audio"
|
||||||
|
"testsrc as fallback either, check your GStreamer installation."));
|
||||||
|
/* This will error out with not-negotiated.. */
|
||||||
|
fake = gst_element_factory_make ("fakesrc", "fake-auto-audio-src");
|
||||||
|
}
|
||||||
|
return fake;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_auto_audio_src_class_init (GstAutoAudioSrcClass * klass)
|
gst_auto_audio_src_class_init (GstAutoAudioSrcClass * klass)
|
||||||
{
|
{
|
||||||
|
GstAutoDetectClass *autoclass = GST_AUTO_DETECT_CLASS (klass);
|
||||||
GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
|
GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
|
||||||
|
|
||||||
gst_element_class_add_pad_template (eklass,
|
gst_element_class_add_pad_template (eklass,
|
||||||
|
@ -61,6 +82,8 @@ gst_auto_audio_src_class_init (GstAutoAudioSrcClass * klass)
|
||||||
"Wrapper audio source for automatically detected audio source",
|
"Wrapper audio source for automatically detected audio source",
|
||||||
"Jan Schmidt <thaytan@noraisin.net>, "
|
"Jan Schmidt <thaytan@noraisin.net>, "
|
||||||
"Stefan Kost <ensonic@users.sf.net>");
|
"Stefan Kost <ensonic@users.sf.net>");
|
||||||
|
|
||||||
|
autoclass->create_fake_element = gst_auto_audio_src_create_fake_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -119,7 +119,7 @@ gst_auto_detect_clear_kid (GstAutoDetect * self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstElement *
|
static GstElement *
|
||||||
gst_auto_detect_create_fake_element (GstAutoDetect * self)
|
gst_auto_detect_create_fake_element_default (GstAutoDetect * self)
|
||||||
{
|
{
|
||||||
GstElement *fake;
|
GstElement *fake;
|
||||||
gchar dummy_factory[10], dummy_name[20];
|
gchar dummy_factory[10], dummy_name[20];
|
||||||
|
@ -132,6 +132,20 @@ gst_auto_detect_create_fake_element (GstAutoDetect * self)
|
||||||
return fake;
|
return fake;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstElement *
|
||||||
|
gst_auto_detect_create_fake_element (GstAutoDetect * self)
|
||||||
|
{
|
||||||
|
GstAutoDetectClass *klass = GST_AUTO_DETECT_GET_CLASS (self);
|
||||||
|
GstElement *fake;
|
||||||
|
|
||||||
|
if (klass->create_fake_element)
|
||||||
|
fake = klass->create_fake_element (self);
|
||||||
|
else
|
||||||
|
fake = gst_auto_detect_create_fake_element_default (self);
|
||||||
|
|
||||||
|
return fake;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_auto_detect_attach_ghost_pad (GstAutoDetect * self)
|
gst_auto_detect_attach_ghost_pad (GstAutoDetect * self)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,9 +60,10 @@ typedef struct _GstAutoDetect {
|
||||||
typedef struct _GstAutoDetectClass {
|
typedef struct _GstAutoDetectClass {
|
||||||
GstBinClass parent_class;
|
GstBinClass parent_class;
|
||||||
|
|
||||||
/*< public >*/
|
/*< private >*/
|
||||||
/* virtual methods for subclasses */
|
/* virtual methods for subclasses */
|
||||||
void (*configure)(GstAutoDetect *self, GstElement *kid);
|
void (*configure)(GstAutoDetect *self, GstElement *kid);
|
||||||
|
GstElement * (*create_fake_element) (GstAutoDetect * autodetect);
|
||||||
} GstAutoDetectClass;
|
} GstAutoDetectClass;
|
||||||
|
|
||||||
GType gst_auto_detect_get_type (void);
|
GType gst_auto_detect_get_type (void);
|
||||||
|
|
Loading…
Reference in a new issue