Commit 7dcc3ffe authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠

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.
parent 07a3a983
......@@ -49,9 +49,30 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_ALWAYS,
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
gst_auto_audio_src_class_init (GstAutoAudioSrcClass * klass)
{
GstAutoDetectClass *autoclass = GST_AUTO_DETECT_CLASS (klass);
GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
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",
"Jan Schmidt <thaytan@noraisin.net>, "
"Stefan Kost <ensonic@users.sf.net>");
autoclass->create_fake_element = gst_auto_audio_src_create_fake_element;
}
static void
......
......@@ -119,7 +119,7 @@ gst_auto_detect_clear_kid (GstAutoDetect * self)
}
static GstElement *
gst_auto_detect_create_fake_element (GstAutoDetect * self)
gst_auto_detect_create_fake_element_default (GstAutoDetect * self)
{
GstElement *fake;
gchar dummy_factory[10], dummy_name[20];
......@@ -132,6 +132,20 @@ gst_auto_detect_create_fake_element (GstAutoDetect * self)
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
gst_auto_detect_attach_ghost_pad (GstAutoDetect * self)
{
......
......@@ -60,9 +60,10 @@ typedef struct _GstAutoDetect {
typedef struct _GstAutoDetectClass {
GstBinClass parent_class;
/*< public >*/
/*< private >*/
/* virtual methods for subclasses */
void (*configure)(GstAutoDetect *self, GstElement *kid);
GstElement * (*create_fake_element) (GstAutoDetect * autodetect);
} GstAutoDetectClass;
GType gst_auto_detect_get_type (void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment