[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase2 r306291 - in /team/dvossel/fixthew...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 4 12:03:52 CST 2011


Author: dvossel
Date: Fri Feb  4 12:03:48 2011
New Revision: 306291

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=306291
Log:
Added ability to define custom formats in codecs.conf

Modified:
    team/dvossel/fixtheworld_phase2/configs/codecs.conf.sample
    team/dvossel/fixtheworld_phase2/include/asterisk/format.h
    team/dvossel/fixtheworld_phase2/main/format.c

Modified: team/dvossel/fixtheworld_phase2/configs/codecs.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/configs/codecs.conf.sample?view=diff&rev=306291&r1=306290&r2=306291
==============================================================================
--- team/dvossel/fixtheworld_phase2/configs/codecs.conf.sample (original)
+++ team/dvossel/fixtheworld_phase2/configs/codecs.conf.sample Fri Feb  4 12:03:48 2011
@@ -63,3 +63,36 @@
 ; this determines whether to perform generic PLC
 ; there is a minor performance penalty for this
 genericplc => true
+
+; Generate custom formats for formats requiring attributes.
+; After defining the custom format, the name used in defining
+; the format can be used throughout Asterisk in the format 'allow'
+; and 'disallow' options.
+;
+; Example: silk8 is a predefined custom format in this config file.
+; Once this config file is loaded, silk8 can be used anywhere a
+; peer's codec capabilities are defined.
+;
+; In sip.conf 'silk8' can be defined as a capability for a peer.
+; [peer1]
+; type=peer
+; host=dynamic
+; disallow=all
+; allow=silk8 ;custom codec defined in codecs.conf
+
+; Custom SILK format definitions
+[silk8]
+type=silk
+samprate=8000
+
+[silk12]
+type=silk
+samprate=12000
+
+[silk16]
+type=silk
+samprate=16000
+
+[silk24]
+type=silk
+samprate=24000

Modified: team/dvossel/fixtheworld_phase2/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/include/asterisk/format.h?view=diff&rev=306291&r1=306290&r2=306291
==============================================================================
--- team/dvossel/fixtheworld_phase2/include/asterisk/format.h (original)
+++ team/dvossel/fixtheworld_phase2/include/asterisk/format.h Fri Feb  4 12:03:48 2011
@@ -150,7 +150,7 @@
 /*! \brief Definition of supported media formats (codecs) */
 struct ast_format_list {
 	struct ast_format format; /*!< The unique format. */
-	char name[16];	/*!< short name */
+	char name[64];	/*!< short name */
 	int samplespersecond; /*!< Number of samples per second (8000/16000) */
 	char desc[128];	/*!< Description */
 	int fr_len;	/*!< Single frame length in bytes */

Modified: team/dvossel/fixtheworld_phase2/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/main/format.c?view=diff&rev=306291&r1=306290&r2=306291
==============================================================================
--- team/dvossel/fixtheworld_phase2/main/format.c (original)
+++ team/dvossel/fixtheworld_phase2/main/format.c Fri Feb  4 12:03:48 2011
@@ -38,6 +38,9 @@
 #include "asterisk/utils.h"
 #include "asterisk/cli.h"
 #include "asterisk/rtp_engine.h"
+#include "asterisk/config.h"
+
+#define FORMAT_CONFIG "codecs.conf"
 
 /*! This is the container for all the format attribute interfaces.
  *  An ao2 container was chosen for fast lookup. */
@@ -101,6 +104,23 @@
 int ast_format_get_video_mark(const struct ast_format *format)
 {
 	return format->fattr.rtp_marker_bit;
+}
+
+static int has_interface(const struct ast_format *format)
+{
+	struct interface_ao2_wrapper *wrapper;
+	struct interface_ao2_wrapper tmp_wrapper = {
+		.id = format->id,
+	};
+
+	ast_rwlock_rdlock(&ilock);
+	if (!(wrapper = ao2_find(interfaces, &tmp_wrapper, (OBJ_POINTER | OBJ_NOLOCK)))) {
+		ast_rwlock_unlock(&ilock);
+		return 0;
+	}
+	ast_rwlock_unlock(&ilock);
+	ao2_ref(wrapper, -1);
+	return 1;
 }
 
 static struct interface_ao2_wrapper *find_interface(const struct ast_format *format)
@@ -742,7 +762,18 @@
 	return 0;
 }
 
-static int format_list_add(
+static int format_list_add_custom(struct ast_format_list *new)
+{
+	struct ast_format_list *entry;
+	if (!(entry = ao2_alloc(sizeof(*entry), NULL))) {
+		return -1;
+	}
+	memcpy(entry, new, sizeof(struct ast_format_list));
+	entry->custom_entry = 1;
+	ao2_link(format_list, entry);
+	return 0;
+}
+static int format_list_add_static(
 	const struct ast_format *format,
 	const char *name,
 	int samplespersecond,
@@ -753,8 +784,7 @@
 	int inc_ms,
 	int def_ms,
 	unsigned int flags,
-	int cur_ms,
-	int custom_entry)
+	int cur_ms)
 {
 	struct ast_format_list *entry;
 	if (!(entry = ao2_alloc(sizeof(*entry), NULL))) {
@@ -771,10 +801,16 @@
 	entry->def_ms = def_ms;
 	entry->flags = flags;
 	entry->cur_ms = cur_ms;
-	entry->custom_entry = custom_entry;
+	entry->custom_entry = 0;
 
 	ao2_link(format_list, entry);
 	return 0;
+}
+
+static int list_all_custom(void *obj, void *arg, int flag)
+{
+	struct ast_format_list *entry = obj;
+	return entry->custom_entry ? CMP_MATCH : 0;
 }
 
 static int list_cmp_cb(void *obj, void *arg, int flags)
@@ -841,34 +877,34 @@
 		return -1;
 	}
 	/* initiate static entries XXX DO NOT CHANGE THIS ORDER! */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_G723_1, 0), "g723", 8000, "G.723.1", 20, 30, 300, 30, 30, 0, 0, 0);       /*!< G723.1 */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_GSM, 0), "gsm",  8000, "GSM", 33, 20, 300, 20, 20, 0, 0, 0);              /*!< codec_gsm.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0), "ulaw", 8000, "G.711 u-law", 80, 10, 150, 10, 20, 0, 0, 0);     /*!< codec_ulaw.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_ALAW, 0), "alaw", 8000, "G.711 A-law", 80, 10, 150, 10, 20, 0, 0, 0);     /*!< codec_alaw.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_G726, 0), "g726", 8000, "G.726 RFC3551", 40, 10, 300, 10, 20, 0, 0, 0);   /*!< codec_g726.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_ADPCM, 0), "adpcm" , 8000, "ADPCM", 40, 10, 300, 10, 20, 0, 0, 0);        /*!< codec_adpcm.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0), "slin", 8000, "16 bit Signed Linear PCM", 160, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0, 0); /*!< Signed linear */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_LPC10, 0), "lpc10", 8000, "LPC10", 7, 20, 20, 20, 20, 0, 0, 0);           /*!< codec_lpc10.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_G729A, 0), "g729", 8000, "G.729A", 10, 10, 230, 10, 20, AST_SMOOTHER_FLAG_G729, 0, 0);   /*!< Binary commercial distribution */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_SPEEX, 0), "speex", 8000, "SpeeX", 10, 10, 60, 10, 20, 0, 0, 0);          /*!< codec_speex.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_SPEEX16, 0), "speex16", 16000, "SpeeX 16khz", 10, 10, 60, 10, 20, 0, 0, 0);   /*!< codec_speex.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_ILBC, 0), "ilbc", 8000, "iLBC", 50, 30, 30, 30, 30, 0, 0, 0);                 /*!< codec_ilbc.c */ /* inc=30ms - workaround */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_G726_AAL2, 0), "g726aal2", 8000, "G.726 AAL2", 40, 10, 300, 10, 20, 0, 0, 0); /*!< codec_g726.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_G722, 0), "g722", 16000, "G722", 80, 10, 150, 10, 20, 0, 0, 0);               /*!< codec_g722.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0), "slin16", 16000, "16 bit Signed Linear PCM (16kHz)", 320, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0 ,0);/*!< Signed linear (16kHz) */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_JPEG, 0), "jpeg", 0, "JPEG image", 0, 0, 0, 0 ,0 ,0 ,0, 0);          /*!< See format_jpeg.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_PNG, 0), "png", 0, "PNG image", 0, 0, 0, 0 ,0 ,0 ,0, 0);             /*!< PNG Image format */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_H261, 0), "h261", 0, "H.261 Video", 0, 0, 0, 0 ,0 ,0 ,0, 0);         /*!< H.261 Video Passthrough */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_H263, 0), "h263", 0, "H.263 Video", 0, 0, 0, 0 ,0 ,0 ,0, 0);         /*!< H.263 Passthrough support, see format_h263.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_H263_PLUS, 0), "h263p", 0, "H.263+ Video", 0, 0, 0,0 ,0 ,0, 0, 0);  /*!< H.263plus passthrough support See format_h263.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_H264, 0), "h264", 0, "H.264 Video", 0, 0, 0, 0 ,0 ,0, 0, 0);         /*!< Passthrough support, see format_h263.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_MP4_VIDEO, 0), "mpeg4", 0, "MPEG4 Video", 0, 0, 0, 0, 0 ,0, 0, 0);   /*!< Passthrough support for MPEG4 */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_T140RED, 0), "red", 1, "T.140 Realtime Text with redundancy", 0, 0, 0,0 ,0 ,0, 0, 0);     /*!< Redundant T.140 Realtime Text */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_T140, 0), "t140", 0, "Passthrough T.140 Realtime Text", 0, 0, 0, 0 ,0 ,0, 0, 0);      /*!< Passthrough support for T.140 Realtime Text */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_SIREN7, 0), "siren7", 16000, "ITU G.722.1 (Siren7, licensed from Polycom)", 80, 20, 80, 20, 20, 0, 0, 0); /*!< Binary commercial distribution */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_SIREN14, 0), "siren14", 32000, "ITU G.722.1 Annex C, (Siren14, licensed from Polycom)", 120, 20, 80, 20, 20, 0, 0, 0);	/*!< Binary commercial distribution */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_TESTLAW, 0), "testlaw", 8000, "G.711 test-law", 80, 10, 150, 10, 20, 0, 0, 0);    /*!< codec_ulaw.c */
-	format_list_add(ast_format_set(&tmpfmt, AST_FORMAT_G719, 0), "g719", 48000, "ITU G.719", 160, 20, 80, 20, 20, 0, 0, 0);
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G723_1, 0), "g723", 8000, "G.723.1", 20, 30, 300, 30, 30, 0, 0);       /*!< G723.1 */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_GSM, 0), "gsm",  8000, "GSM", 33, 20, 300, 20, 20, 0, 0);              /*!< codec_gsm.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0), "ulaw", 8000, "G.711 u-law", 80, 10, 150, 10, 20, 0, 0);     /*!< codec_ulaw.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_ALAW, 0), "alaw", 8000, "G.711 A-law", 80, 10, 150, 10, 20, 0, 0);     /*!< codec_alaw.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G726, 0), "g726", 8000, "G.726 RFC3551", 40, 10, 300, 10, 20, 0, 0);   /*!< codec_g726.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_ADPCM, 0), "adpcm" , 8000, "ADPCM", 40, 10, 300, 10, 20, 0, 0);        /*!< codec_adpcm.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0), "slin", 8000, "16 bit Signed Linear PCM", 160, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0); /*!< Signed linear */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_LPC10, 0), "lpc10", 8000, "LPC10", 7, 20, 20, 20, 20, 0, 0);           /*!< codec_lpc10.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G729A, 0), "g729", 8000, "G.729A", 10, 10, 230, 10, 20, AST_SMOOTHER_FLAG_G729, 0);   /*!< Binary commercial distribution */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SPEEX, 0), "speex", 8000, "SpeeX", 10, 10, 60, 10, 20, 0, 0);          /*!< codec_speex.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SPEEX16, 0), "speex16", 16000, "SpeeX 16khz", 10, 10, 60, 10, 20, 0, 0);   /*!< codec_speex.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_ILBC, 0), "ilbc", 8000, "iLBC", 50, 30, 30, 30, 30, 0, 0);                 /*!< codec_ilbc.c */ /* inc=30ms - workaround */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G726_AAL2, 0), "g726aal2", 8000, "G.726 AAL2", 40, 10, 300, 10, 20, 0, 0); /*!< codec_g726.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G722, 0), "g722", 16000, "G722", 80, 10, 150, 10, 20, 0, 0);               /*!< codec_g722.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0), "slin16", 16000, "16 bit Signed Linear PCM (16kHz)", 320, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (16kHz) */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_JPEG, 0), "jpeg", 0, "JPEG image", 0, 0, 0, 0 ,0 ,0 ,0);          /*!< See format_jpeg.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_PNG, 0), "png", 0, "PNG image", 0, 0, 0, 0 ,0 ,0 ,0);             /*!< PNG Image format */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_H261, 0), "h261", 0, "H.261 Video", 0, 0, 0, 0 ,0 ,0 ,0);         /*!< H.261 Video Passthrough */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_H263, 0), "h263", 0, "H.263 Video", 0, 0, 0, 0 ,0 ,0 ,0);         /*!< H.263 Passthrough support, see format_h263.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_H263_PLUS, 0), "h263p", 0, "H.263+ Video", 0, 0, 0,0 ,0 ,0, 0);  /*!< H.263plus passthrough support See format_h263.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_H264, 0), "h264", 0, "H.264 Video", 0, 0, 0, 0 ,0 ,0, 0);         /*!< Passthrough support, see format_h263.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_MP4_VIDEO, 0), "mpeg4", 0, "MPEG4 Video", 0, 0, 0, 0, 0 ,0, 0);   /*!< Passthrough support for MPEG4 */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_T140RED, 0), "red", 1, "T.140 Realtime Text with redundancy", 0, 0, 0,0 ,0 ,0, 0);     /*!< Redundant T.140 Realtime Text */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_T140, 0), "t140", 0, "Passthrough T.140 Realtime Text", 0, 0, 0, 0 ,0 ,0, 0);      /*!< Passthrough support for T.140 Realtime Text */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SIREN7, 0), "siren7", 16000, "ITU G.722.1 (Siren7, licensed from Polycom)", 80, 20, 80, 20, 20, 0, 0); /*!< Binary commercial distribution */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SIREN14, 0), "siren14", 32000, "ITU G.722.1 Annex C, (Siren14, licensed from Polycom)", 120, 20, 80, 20, 20, 0, 0);	/*!< Binary commercial distribution */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_TESTLAW, 0), "testlaw", 8000, "G.711 test-law", 80, 10, 150, 10, 20, 0, 0);    /*!< codec_ulaw.c */
+	format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_G719, 0), "g719", 48000, "ITU G.719", 160, 20, 80, 20, 20, 0, 0);
 
 	return 0;
 }
@@ -916,41 +952,127 @@
 	}
 	return -1;
 }
-/*
-static int load_format_config(int reload)
-{
-	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
-	struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
+
+static int custom_silk_format(struct ast_format_list *entry)
+{
+	if (!entry->samplespersecond) {
+		ast_log(LOG_WARNING, "Custom SILK format definition '%s' requires sample rate to be defined.\n", entry->name);
+	}
+	ast_format_set(&entry->format, AST_FORMAT_SILK, 0);
+
+	if (!has_interface(&entry->format)) {
+		return -1;
+	}
+
+	switch (entry->samplespersecond) {
+	case 8000:
+		ast_format_append(&entry->format,
+			SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_8KHZ,
+			AST_FORMAT_ATTR_END);
+		break;
+	case 12000:
+		ast_format_append(&entry->format,
+			SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_12KHZ,
+			AST_FORMAT_ATTR_END);
+		break;
+	case 16000:
+		ast_format_append(&entry->format,
+			SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_16KHZ,
+			AST_FORMAT_ATTR_END);
+		break;
+	case 24000:
+		ast_format_append(&entry->format,
+			SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_24KHZ,
+			AST_FORMAT_ATTR_END);
+		break;
+	default:
+		ast_log(LOG_WARNING, "Custom SILK format definition '%s' can not support sample rate %d\n", entry->name, entry->samplespersecond);
+		return -1;
+	}
+	ast_copy_string(entry->desc, "SILK Custom Format", sizeof(entry->desc));
+	entry->fr_len = 80;
+	entry->min_ms = 20;
+	entry->max_ms = 20;
+	entry->inc_ms = 20;
+	entry->def_ms = 20;
+	return 0;
+}
+
+static int load_format_config(void)
+{
+	struct ast_flags config_flags;
+	struct ast_config *cfg = ast_config_load(FORMAT_CONFIG, config_flags);
+	struct ast_format_list entry;
 	struct ast_variable *var;
 	char *cat = NULL;
-	int res;
-
-	if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID)
+	enum ast_format_id id;
+	int add_it = 0;
+
+	if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID)
 		return 0;
 
+	/* remove all custom formats from the AO2 Container. Note, this has no affect on the
+	 * global format list until the list is rebuild.  That is why this is okay to do while
+	 * reloading the config. */
+	ao2_callback(format_list, OBJ_NODATA | OBJ_UNLINK | OBJ_MULTIPLE, list_all_custom, NULL);
+
 	while ((cat = ast_category_browse(cfg, cat))) {
-		const char *type;
-		struct ast_variable *var;
-		type = ast_variable_retrieve(cfg, cat, "type");
-		if (!type) {
+		memset(&entry, 0, sizeof(entry));
+		id = 0;
+		add_it = 0;
+		if (!(ast_variable_retrieve(cfg, cat, "type"))) {
 			continue;
 		}
 
+		ast_copy_string(entry.name, cat, sizeof(entry.name));
 
 		var = ast_variable_browse(cfg, cat);
-
 		for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
 			if (!strcasecmp(var->name, "type")) {
-				if (!strcasecmp(v->value, "silk")) {
-
+				if (!strcasecmp(var->value, "silk")) {
+					id = AST_FORMAT_SILK;
+				} else {
+					ast_log(LOG_WARNING, "Can not make custom format type for '%s' at line %d of %s\n", var->value, var->lineno, FORMAT_CONFIG);
+					continue;
+				}
+			} else if (!strcasecmp(var->name, "samprate")) {
+				if (!strcasecmp(var->value, "8000")) {
+					entry.samplespersecond = 8000;
+				} else if (!strcasecmp(var->value, "12000")) {
+					entry.samplespersecond = 12000;
+				} else if (!strcasecmp(var->value, "16000")) {
+					entry.samplespersecond = 16000;
+				} else if (!strcasecmp(var->value, "24000")) {
+					entry.samplespersecond = 24000;
+				} else if (!strcasecmp(var->value, "32000")) {
+					entry.samplespersecond = 32000;
+				} else if (!strcasecmp(var->value, "48000")) {
+					entry.samplespersecond = 48000;
+				} else {
+					ast_log(LOG_WARNING, "Sample rate '%s' at line %d of %s is not supported.\n", var->value, var->lineno, FORMAT_CONFIG);
 				}
 			}
 		}
+
+		switch (id) {
+		case AST_FORMAT_SILK:
+			if (!(custom_silk_format(&entry))) {
+				add_it = 1;
+			}
+			break;
+		default:
+			ast_log(LOG_WARNING, "Can not create custom format %s\n", entry.name);
+		}
+
+		if (add_it) {
+			format_list_add_custom(&entry);
+		}
 	}
 	ast_config_destroy(cfg);
-	return 0;
-}
-*/
+	build_format_list_array();
+	return 0;
+}
+
 int ast_format_attr_reg_interface(const struct ast_format_attr_interface *interface)
 {
 	struct interface_ao2_wrapper *wrapper;
@@ -984,6 +1106,8 @@
 	ao2_ref(wrapper, -1);
 
 	ast_rtp_engine_load_format(interface->id);
+	load_format_config();
+
 	return 0;
 }
 
@@ -1009,5 +1133,6 @@
 	ao2_ref(wrapper, -1);
 
 	ast_rtp_engine_unload_format(interface->id);
-	return 0;
-}
+	load_format_config();
+	return 0;
+}




More information about the asterisk-commits mailing list