| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
#ifdef HAVE_CONFIG_H |
| 40 |
#include "config.h" |
| 41 |
#endif |
| 42 |
|
| 43 |
#include "gstautodetectelements.h" |
| 44 |
#include "gstautodetect.h" |
| 45 |
#include "gstautoaudiosrc.h" |
| 46 |
|
| 47 |
G_DEFINE_TYPE (GstAutoAudioSrc, gst_auto_audio_src, GST_TYPE_AUTO_DETECT); |
| 48 |
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (autoaudiosrc, "autoaudiosrc", |
| 49 |
GST_RANK_NONE, GST_TYPE_AUTO_AUDIO_SRC, autodetect_element_init (plugin)); |
| 50 |
|
| 51 |
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", |
| 52 |
GST_PAD_SRC, |
| 53 |
GST_PAD_ALWAYS, |
| 54 |
GST_STATIC_CAPS_ANY); |
| 55 |
|
| 56 |
static GstElement * |
| 57 |
gst_auto_audio_src_create_fake_element (GstAutoDetect * autodetect) |
| 58 |
{ |
| 59 |
GstElement *fake; |
| 60 |
|
| 61 |
fake = gst_element_factory_make ("audiotestsrc", "fake-auto-audio-src"); |
| 62 |
if (fake != NULL) { |
| 63 |
g_object_set (fake, "is-live", TRUE, NULL); |
| 64 |
gst_util_set_object_arg (G_OBJECT (fake), "wave", "silence"); |
| 65 |
} else { |
| 66 |
GST_ELEMENT_ERROR (autodetect, RESOURCE, NOT_FOUND, |
| 67 |
("Failed to find usable audio source element."), |
| 68 |
("Failed to find a usable audio source and couldn't create an audio" |
| 69 |
"testsrc as fallback either, check your GStreamer installation.")); |
| 70 |
|
| 71 |
fake = gst_element_factory_make ("fakesrc", "fake-auto-audio-src"); |
| 72 |
} |
| 73 |
return fake; |
| 74 |
} |
| 75 |
|
| 76 |
static void |
| 77 |
gst_auto_audio_src_class_init (GstAutoAudioSrcClass * klass) |
| 78 |
{ |
| 79 |
GstAutoDetectClass *autoclass = GST_AUTO_DETECT_CLASS (klass); |
| 80 |
GstElementClass *eklass = GST_ELEMENT_CLASS (klass); |
| 81 |
|
| 82 |
gst_element_class_add_static_pad_template (eklass, &src_template); |
| 83 |
gst_element_class_set_static_metadata (eklass, "Auto audio source", |
| 84 |
"Source/Audio", |
| 85 |
"Wrapper audio source for automatically detected audio source", |
| 86 |
"Jan Schmidt <[email protected]>, " |
| 87 |
"Stefan Kost <[email protected]>"); |
| 88 |
|
| 89 |
autoclass->create_fake_element = gst_auto_audio_src_create_fake_element; |
| 90 |
} |
| 91 |
|
| 92 |
static void |
| 93 |
gst_auto_audio_src_init (GstAutoAudioSrc * src) |
| 94 |
{ |
| 95 |
GstAutoDetect *autodetect = GST_AUTO_DETECT (src); |
| 96 |
|
| 97 |
autodetect->media_klass = "Audio"; |
| 98 |
autodetect->flag = GST_ELEMENT_FLAG_SOURCE; |
| 99 |
} |