From 7dcc3ffe5a6448852fce9dd2525c979fc78e6ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 28 Jun 2014 12:44:31 +0100 Subject: [PATCH] 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. --- gst/autodetect/gstautoaudiosrc.c | 23 +++++++++++++++++++++++ gst/autodetect/gstautodetect.c | 16 +++++++++++++++- gst/autodetect/gstautodetect.h | 3 ++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/gst/autodetect/gstautoaudiosrc.c b/gst/autodetect/gstautoaudiosrc.c index e60b24c86a..2859386cf7 100644 --- a/gst/autodetect/gstautoaudiosrc.c +++ b/gst/autodetect/gstautoaudiosrc.c @@ -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 , " "Stefan Kost "); + + autoclass->create_fake_element = gst_auto_audio_src_create_fake_element; } static void diff --git a/gst/autodetect/gstautodetect.c b/gst/autodetect/gstautodetect.c index 6970eaa515..59aab7e1bd 100644 --- a/gst/autodetect/gstautodetect.c +++ b/gst/autodetect/gstautodetect.c @@ -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) { diff --git a/gst/autodetect/gstautodetect.h b/gst/autodetect/gstautodetect.h index 03b06aed7b..05ae89fe5f 100644 --- a/gst/autodetect/gstautodetect.h +++ b/gst/autodetect/gstautodetect.h @@ -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);