[asterisk-commits] dvossel: branch dvossel/celt_codec_ftw r313094 - in /team/dvossel/celt_codec_...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Apr 7 12:55:41 CDT 2011
Author: dvossel
Date: Thu Apr 7 12:55:36 2011
New Revision: 313094
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=313094
Log:
Addition of CELT SDP parameters to properly advertise custom CELT codecs
Modified:
team/dvossel/celt_codec_ftw/channels/chan_sip.c
team/dvossel/celt_codec_ftw/configs/codecs.conf.sample
team/dvossel/celt_codec_ftw/main/format.c
Modified: team/dvossel/celt_codec_ftw/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/celt_codec_ftw/channels/chan_sip.c?view=diff&rev=313094&r1=313093&r2=313094
==============================================================================
--- team/dvossel/celt_codec_ftw/channels/chan_sip.c (original)
+++ team/dvossel/celt_codec_ftw/channels/chan_sip.c Thu Apr 7 12:55:36 2011
@@ -9113,6 +9113,7 @@
if ((format = ast_rtp_codecs_get_payload_format(newaudiortp, codec))) {
unsigned int bit_rate;
+ int val = 0;
switch ((int) format->id) {
case AST_FORMAT_SIREN7:
@@ -9145,20 +9146,21 @@
}
}
break;
+ case AST_FORMAT_CELT:
+ if (sscanf(fmtp_string, "framesize=%30u", &val) == 1) {
+ ast_format_append(format, CELT_ATTR_KEY_FRAME_SIZE, val, AST_FORMAT_ATTR_END);
+ }
case AST_FORMAT_SILK:
- {
- int val = 0;
- if (sscanf(fmtp_string, "maxaveragebitrate=%30u", &val) == 1) {
- ast_format_append(format, SILK_ATTR_KEY_MAX_BITRATE, val, AST_FORMAT_ATTR_END);
- }
- if (sscanf(fmtp_string, "usedtx=%30u", &val) == 1) {
- ast_format_append(format, SILK_ATTR_KEY_DTX, val ? 1 : 0, AST_FORMAT_ATTR_END);
- }
- if (sscanf(fmtp_string, "useinbandfec=%30u", &val) == 1) {
- ast_format_append(format, SILK_ATTR_KEY_FEC, val ? 1 : 0, AST_FORMAT_ATTR_END);
- }
- break;
+ if (sscanf(fmtp_string, "maxaveragebitrate=%30u", &val) == 1) {
+ ast_format_append(format, SILK_ATTR_KEY_MAX_BITRATE, val, AST_FORMAT_ATTR_END);
}
+ if (sscanf(fmtp_string, "usedtx=%30u", &val) == 1) {
+ ast_format_append(format, SILK_ATTR_KEY_DTX, val ? 1 : 0, AST_FORMAT_ATTR_END);
+ }
+ if (sscanf(fmtp_string, "useinbandfec=%30u", &val) == 1) {
+ ast_format_append(format, SILK_ATTR_KEY_FEC, val ? 1 : 0, AST_FORMAT_ATTR_END);
+ }
+ break;
}
}
}
@@ -10476,7 +10478,7 @@
{
int rtp_code;
struct ast_format_list fmt;
-
+ int val = 0;
if (debug)
ast_verbose("Adding codec %d (%s) to SDP\n", format->id, ast_getformatname(format));
@@ -10519,20 +10521,22 @@
/* Indicate that we only expect 64Kbps */
ast_str_append(a_buf, 0, "a=fmtp:%d bitrate=64000\r\n", rtp_code);
break;
+ case AST_FORMAT_CELT:
+ if (!ast_format_get_value(format, CELT_ATTR_KEY_FRAME_SIZE, &val) && val > 0) {
+ ast_str_append(a_buf, 0, "a=fmtp:%d framesize=%u\r\n", rtp_code, val);
+ }
+ break;
case AST_FORMAT_SILK:
- {
- int val = 0;
- if (!ast_format_get_value(format, SILK_ATTR_KEY_MAX_BITRATE, &val) && val > 5000 && val < 40000) {
- ast_str_append(a_buf, 0, "a=fmtp:%d maxaveragebitrate=%u\r\n", rtp_code, val);
- }
- if (!ast_format_get_value(format, SILK_ATTR_KEY_DTX, &val)) {
- ast_str_append(a_buf, 0, "a=fmtp:%d usedtx=%u\r\n", rtp_code, val ? 1 : 0);
- }
- if (!ast_format_get_value(format, SILK_ATTR_KEY_FEC, &val)) {
- ast_str_append(a_buf, 0, "a=fmtp:%d useinbandfec=%u\r\n", rtp_code, val ? 1 : 0);
- }
- break;
- }
+ if (!ast_format_get_value(format, SILK_ATTR_KEY_MAX_BITRATE, &val) && val > 5000 && val < 40000) {
+ ast_str_append(a_buf, 0, "a=fmtp:%d maxaveragebitrate=%u\r\n", rtp_code, val);
+ }
+ if (!ast_format_get_value(format, SILK_ATTR_KEY_DTX, &val)) {
+ ast_str_append(a_buf, 0, "a=fmtp:%d usedtx=%u\r\n", rtp_code, val ? 1 : 0);
+ }
+ if (!ast_format_get_value(format, SILK_ATTR_KEY_FEC, &val)) {
+ ast_str_append(a_buf, 0, "a=fmtp:%d useinbandfec=%u\r\n", rtp_code, val ? 1 : 0);
+ }
+ break;
}
if (fmt.cur_ms && (fmt.cur_ms < *min_packet_size))
Modified: team/dvossel/celt_codec_ftw/configs/codecs.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/celt_codec_ftw/configs/codecs.conf.sample?view=diff&rev=313094&r1=313093&r2=313094
==============================================================================
--- team/dvossel/celt_codec_ftw/configs/codecs.conf.sample (original)
+++ team/dvossel/celt_codec_ftw/configs/codecs.conf.sample Thu Apr 7 12:55:36 2011
@@ -126,7 +126,6 @@
fec=true
packetloss_percentage=10;
-
[silk24]
type=silk
samprate=24000
@@ -134,3 +133,16 @@
fec=true
packetloss_percentage=10;
+
+; Default custom CELT codec definitions. Only one custom CELT definition is allowed
+; per a sample rate.
+
+[celt44]
+type=celt
+samprate=44100
+framesize=512
+
+[celt48]
+type=celt
+samprate=48000
+framesize=512
Modified: team/dvossel/celt_codec_ftw/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/celt_codec_ftw/main/format.c?view=diff&rev=313094&r1=313093&r2=313094
==============================================================================
--- team/dvossel/celt_codec_ftw/main/format.c (original)
+++ team/dvossel/celt_codec_ftw/main/format.c Thu Apr 7 12:55:36 2011
@@ -1104,6 +1104,8 @@
return -1;
}
+ snprintf(entry->desc, sizeof(entry->desc), "CELT Custom Format %dkhz", entry->samplespersecond/1000);
+
ast_format_append(&entry->format,
CELT_ATTR_KEY_SAMP_RATE, entry->samplespersecond,
CELT_ATTR_KEY_MAX_BITRATE, maxbitrate,
@@ -1177,6 +1179,8 @@
{
if (!strcasecmp(name, "silk")) {
*id = AST_FORMAT_SILK;
+ } else if (!strcasecmp(name, "celt")) {
+ *id = AST_FORMAT_CELT;
} else {
*id = 0;
return -1;
@@ -1196,8 +1200,14 @@
*result = 24000;
} else if (!strcasecmp(rate, "32000")) {
*result = 32000;
+ } else if (!strcasecmp(rate, "44100")) {
+ *result = 44100;
} else if (!strcasecmp(rate, "48000")) {
*result = 48000;
+ } else if (!strcasecmp(rate, "96000")) {
+ *result = 96000;
+ } else if (!strcasecmp(rate, "192000")) {
+ *result = 192000;
} else {
*result = 0;
return -1;
@@ -1283,7 +1293,6 @@
add_it = 1;
}
break;
-
default:
ast_log(LOG_WARNING, "Can not create custom format %s\n", entry.name);
}
More information about the asterisk-commits
mailing list