diff options
author | Alfred E. Heggestad <aeh@db.org> | 2016-05-07 16:36:01 +0200 |
---|---|---|
committer | Alfred E. Heggestad <aeh@db.org> | 2016-05-07 16:36:01 +0200 |
commit | cbe0cbf72deab28f8559cc1de61553f797df3fe7 (patch) | |
tree | 13af9cc1cce78796756b5f8e99f7d0c4dbf9ba70 | |
parent | 0c7c2bfb50465641a4bfec39b6848ab58a7e2692 (diff) |
opus: add more config options
opus_bitrate 128000 # Average bitrate in [bps]
opus_cbr {yes,no} # Constant Bitrate (inverse of VBR)
opus_inbandfec {yes,no} # Enable inband Forward Error Correction (FEC)
opus_dtx {yes,no} # Enable Discontinuous Transmission (DTX)
-rw-r--r-- | modules/opus/opus.c | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/modules/opus/opus.c b/modules/opus/opus.c index bf92604..10d9f46 100644 --- a/modules/opus/opus.c +++ b/modules/opus/opus.c @@ -17,6 +17,15 @@ * * Supported version: libopus 1.0.0 or later * + * Configuration options: + * + \verbatim + opus_bitrate 128000 # Average bitrate in [bps] + opus_cbr {yes,no} # Constant Bitrate (inverse of VBR) + opus_inbandfec {yes,no} # Enable inband Forward Error Correction (FEC) + opus_dtx {yes,no} # Enable Discontinuous Transmission (DTX) + \endverbatim + * * References: * * RFC 6716 Definition of the Opus Audio Codec @@ -44,15 +53,55 @@ static int module_init(void) { struct conf *conf = conf_cur(); uint32_t value; - static char fmtp[128]; + static char fmtp[256] = "stereo=1;sprop-stereo=1"; + char *p = fmtp + str_len(fmtp); + bool b; + int n = 0; if (0 == conf_get_u32(conf, "opus_bitrate", &value)) { - (void)re_snprintf(fmtp, sizeof(fmtp), - "stereo=1;sprop-stereo=1;maxaveragebitrate=%d", - value); - opus.fmtp = fmtp; + + n = re_snprintf(p, sizeof(fmtp) - str_len(p), + ";maxaveragebitrate=%d", value); + if (n <= 0) + return ENOMEM; + + p += n; + } + + if (0 == conf_get_bool(conf, "opus_cbr", &b)) { + + n = re_snprintf(p, sizeof(fmtp) - str_len(p), + ";cbr=%d", b); + if (n <= 0) + return ENOMEM; + + p += n; + } + + if (0 == conf_get_bool(conf, "opus_inbandfec", &b)) { + + n = re_snprintf(p, sizeof(fmtp) - str_len(p), + ";useinbandfec=%d", b); + if (n <= 0) + return ENOMEM; + + p += n; } + if (0 == conf_get_bool(conf, "opus_dtx", &b)) { + + n = re_snprintf(p, sizeof(fmtp) - str_len(p), + ";usedtx=%d", b); + if (n <= 0) + return ENOMEM; + + p += n; + } + + opus.fmtp = fmtp; + + debug("opus: fmtp=\"%s\"\n", fmtp); + aucodec_register(&opus); return 0; |