[asterisk-commits] dvossel: branch dvossel/celt_codec_ftw r312997 - in /team/dvossel/celt_codec_...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 6 16:07:50 CDT 2011
Author: dvossel
Date: Wed Apr 6 16:07:46 2011
New Revision: 312997
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=312997
Log:
CELT codecs.conf config parsing and rtp payload type
Modified:
team/dvossel/celt_codec_ftw/include/asterisk/celt.h
team/dvossel/celt_codec_ftw/main/channel.c
team/dvossel/celt_codec_ftw/main/format.c
team/dvossel/celt_codec_ftw/main/frame.c
team/dvossel/celt_codec_ftw/main/rtp_engine.c
team/dvossel/celt_codec_ftw/res/res_rtp_asterisk.c
Modified: team/dvossel/celt_codec_ftw/include/asterisk/celt.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/celt_codec_ftw/include/asterisk/celt.h?view=diff&rev=312997&r1=312996&r2=312997
==============================================================================
--- team/dvossel/celt_codec_ftw/include/asterisk/celt.h (original)
+++ team/dvossel/celt_codec_ftw/include/asterisk/celt.h Wed Apr 6 16:07:46 2011
@@ -25,6 +25,8 @@
#ifndef _AST_FORMAT_CELT_H_
#define _AST_FORMAT_CELT_H_
+#define AST_CELT_DEFAULT_FRAME_SIZE = 512
+
/*! CELT format attribute key value pairs, all are accessible through ast_format_get_value()*/
enum celt_attr_keys {
CELT_ATTR_KEY_SAMP_RATE, /*!< value is an unsigned integer representing sample rate */
Modified: team/dvossel/celt_codec_ftw/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/celt_codec_ftw/main/channel.c?view=diff&rev=312997&r1=312996&r2=312997
==============================================================================
--- team/dvossel/celt_codec_ftw/main/channel.c (original)
+++ team/dvossel/celt_codec_ftw/main/channel.c Wed Apr 6 16:07:46 2011
@@ -1032,6 +1032,8 @@
AST_FORMAT_SPEEX,
/*! SILK is pretty awesome. */
AST_FORMAT_SILK,
+ /*! CELT supports crazy high sample rates */
+ AST_FORMAT_CELT,
/*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough
to use it */
AST_FORMAT_LPC10,
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=312997&r1=312996&r2=312997
==============================================================================
--- team/dvossel/celt_codec_ftw/main/format.c (original)
+++ team/dvossel/celt_codec_ftw/main/format.c Wed Apr 6 16:07:46 2011
@@ -748,6 +748,15 @@
} else {
return 8000;
}
+ case AST_FORMAT_CELT:
+ {
+ int samplerate;
+ if (!(ast_format_get_value(format,
+ SILK_ATTR_KEY_SAMP_RATE,
+ &samplerate))) {
+ return samplerate;
+ }
+ }
default:
return 8000;
}
@@ -1085,6 +1094,30 @@
return -1;
}
+static int custom_celt_format(struct ast_format_list *entry, unsigned int maxbitrate, unsigned int framesize)
+{
+ if (!entry->samplespersecond) {
+ ast_log(LOG_WARNING, "Custom CELT format definition '%s' requires sample rate to be defined.\n", entry->name);
+ }
+ ast_format_set(&entry->format, AST_FORMAT_CELT, 0);
+ if (!has_interface(&entry->format)) {
+ return -1;
+ }
+
+ ast_format_append(&entry->format,
+ CELT_ATTR_KEY_SAMP_RATE, entry->samplespersecond,
+ CELT_ATTR_KEY_MAX_BITRATE, maxbitrate,
+ CELT_ATTR_KEY_FRAME_SIZE, framesize,
+ AST_FORMAT_ATTR_END);
+
+ entry->fr_len = 80;
+ entry->min_ms = 20;
+ entry->max_ms = 20;
+ entry->inc_ms = 20;
+ entry->def_ms = 20;
+ return 0;
+}
+
static int custom_silk_format(struct ast_format_list *entry, unsigned int maxbitrate, int usedtx, int usefec, int packetloss_percentage)
{
if (!entry->samplespersecond) {
@@ -1184,6 +1217,7 @@
struct {
enum ast_format_id id;
unsigned int maxbitrate;
+ unsigned int framesize;
unsigned int packetloss_percentage;
int usefec;
int usedtx;
@@ -1221,6 +1255,11 @@
ast_log(LOG_WARNING, "maxbitrate '%s' at line %d of %s is not supported.\n",
var->value, var->lineno, FORMAT_CONFIG);
}
+ } else if (!strcasecmp(var->name, "framesize")) {
+ if (sscanf(var->value, "%30u", &settings.framesize) != 1) {
+ ast_log(LOG_WARNING, "framesize '%s' at line %d of %s is not supported.\n",
+ var->value, var->lineno, FORMAT_CONFIG);
+ }
} else if (!strcasecmp(var->name, "dtx")) {
settings.usedtx = ast_true(var->value) ? 1 : 0;
} else if (!strcasecmp(var->name, "fec")) {
@@ -1239,6 +1278,12 @@
add_it = 1;
}
break;
+ case AST_FORMAT_CELT:
+ if (!(custom_celt_format(&entry, settings.maxbitrate, settings.framesize))) {
+ add_it = 1;
+ }
+ break;
+
default:
ast_log(LOG_WARNING, "Can not create custom format %s\n", entry.name);
}
Modified: team/dvossel/celt_codec_ftw/main/frame.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/celt_codec_ftw/main/frame.c?view=diff&rev=312997&r1=312996&r2=312997
==============================================================================
--- team/dvossel/celt_codec_ftw/main/frame.c (original)
+++ team/dvossel/celt_codec_ftw/main/frame.c Wed Apr 6 16:07:46 2011
@@ -1011,6 +1011,10 @@
} else {
return 160;
}
+ case AST_FORMAT_CELT:
+ /* TODO The assumes 20ms delivery right now, which is incorrect */
+ samples = ast_format_rate(&f->subclass.format) / 50;
+ break;
default:
ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname(&f->subclass.format));
}
Modified: team/dvossel/celt_codec_ftw/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/celt_codec_ftw/main/rtp_engine.c?view=diff&rev=312997&r1=312996&r2=312997
==============================================================================
--- team/dvossel/celt_codec_ftw/main/rtp_engine.c (original)
+++ team/dvossel/celt_codec_ftw/main/rtp_engine.c Wed Apr 6 16:07:46 2011
@@ -1913,6 +1913,10 @@
set_next_mime_type(format, 0, "audio", "SILK", ast_format_rate(format));
add_static_payload(-1, format, 0);
break;
+ case AST_FORMAT_CELT:
+ set_next_mime_type(format, 0, "audio", "CELT", ast_format_rate(format));
+ add_static_payload(-1, format, 0);
+ break;
default:
break;
}
Modified: team/dvossel/celt_codec_ftw/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/celt_codec_ftw/res/res_rtp_asterisk.c?view=diff&rev=312997&r1=312996&r2=312997
==============================================================================
--- team/dvossel/celt_codec_ftw/res/res_rtp_asterisk.c (original)
+++ team/dvossel/celt_codec_ftw/res/res_rtp_asterisk.c Wed Apr 6 16:07:46 2011
@@ -1252,6 +1252,7 @@
case AST_FORMAT_SPEEX16:
case AST_FORMAT_SPEEX32:
case AST_FORMAT_SILK:
+ case AST_FORMAT_CELT:
case AST_FORMAT_G723_1:
case AST_FORMAT_SIREN7:
case AST_FORMAT_SIREN14:
More information about the asterisk-commits
mailing list