From e810950547b4c55abdec977a002db522ccab0ad1 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Fri, 24 Jan 2014 13:37:22 +0100 Subject: WIP opus --- src/audio.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/audio.c') 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) { -- cgit