summaryrefslogtreecommitdiff
path: root/src/audio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio.c')
-rw-r--r--src/audio.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/audio.c b/src/audio.c
index 37e746b..b1bba35 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -11,6 +11,7 @@
#define BUFFER_TIME (gst_util_uint64_scale_int(1, GST_SECOND, 100))
#define CELT_CAPS "audio/x-celt,channels=" G_STRINGIFY(CHANNELS) "," \
"rate=" G_STRINGIFY(SAMPLERATE) ",frame-size=" G_STRINGIFY(FRAMESIZE)
+#define OPUS_CAPS "audio/x-opus"
#define AUDIO_CAPS "audio/x-raw,format=S16LE,channels=" \
G_STRINGIFY(CHANNELS) ",rate=" G_STRINGIFY(SAMPLERATE)
@@ -243,7 +244,7 @@ pull_buffer(GstAppSink *sink, gpointer user_data)
GstSample *sample;
GstBuffer *buf;
GstClockTime *silence;
-
+ GstCaps *caps;
sample = gst_app_sink_pull_sample(cm->audio.sink);
if (sample == NULL)
@@ -264,6 +265,15 @@ pull_buffer(GstAppSink *sink, gpointer user_data)
return GST_FLOW_OK;
}
+ caps = gst_sample_get_caps(sample);
+ /* FIXME: Find a better method to match the caps */
+ char *caps_s = gst_caps_to_string(caps);
+ if (strcmp(caps_s, "audio/x-opus") == 0) {
+ pull_opus_buffer(sink, cm);
+ } else if (strncmp(caps_s, "audio/x-celt", strlen("audio/x-celt")) == 0) {
+ pull_celt_buffer(sink, cm);
+ }
+
if (gst_buffer_get_size(buf) > 127) {
g_printerr("error: unexpected buffer size\n");
gst_sample_unref(sample);
@@ -386,8 +396,14 @@ setup_recording_gst_pipeline(struct cmumble *cm)
GstBus *bus;
char *desc = "autoaudiosrc name=src ! cutter name=cutter ! "
"audioresample ! audioconvert ! "AUDIO_CAPS" ! "
- "celtenc name=enc " /*perfect-timestamp=true hard-resync=true" */" ! "
- "appsink name=sink caps="CELT_CAPS;
+ "output-selector name=os ! "
+ "os.src0 "
+ "celtenc name=celt-enc " /*perfect-timestamp=true hard-resync=true" */" ! "
+ CELT_CAPS" ! "
+ "os.src1 "
+ "opusenc name=opus-enc ! " OPUS_CAPS " ! "
+ "funnel ! "
+ "appsink name=sink"
pipeline = gst_parse_launch(desc, &error);
if (error) {