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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Feb 3 16:18:38 CST 2011


Author: dvossel
Date: Thu Feb  3 16:18:34 2011
New Revision: 306213

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=306213
Log:
SILK rtp mime type

Modified:
    team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c
    team/dvossel/fixtheworld_phase2/include/asterisk/format.h
    team/dvossel/fixtheworld_phase2/main/format.c
    team/dvossel/fixtheworld_phase2/main/rtp_engine.c

Modified: team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c?view=diff&rev=306213&r1=306212&r2=306213
==============================================================================
--- team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c (original)
+++ team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c Thu Feb  3 16:18:34 2011
@@ -29,17 +29,6 @@
 
 #include "asterisk/module.h"
 #include "asterisk/format.h"
-
-enum silk_attr_keys {
-	SILK_ATTR_KEY_SAMP_RATE,
-};
-
-enum silk_attr_vals {
-	SILK_ATTR_VAL_SAMP_8KHZ = (1 << 0),
-	SILK_ATTR_VAL_SAMP_12KHZ = (2 << 0),
-	SILK_ATTR_VAL_SAMP_16KHZ = (3 << 0),
-	SILK_ATTR_VAL_SAMP_24KHZ = (4 << 0),
-};
 
 struct silk_attr {
 	int samplerate;

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=306213&r1=306212&r2=306213
==============================================================================
--- team/dvossel/fixtheworld_phase2/include/asterisk/format.h (original)
+++ team/dvossel/fixtheworld_phase2/include/asterisk/format.h Thu Feb  3 16:18:34 2011
@@ -109,6 +109,18 @@
 /*! Determine what type of media a ast_format_id is. */
 #define AST_FORMAT_GET_TYPE(id) (((int) (id / AST_FORMAT_INC)) * AST_FORMAT_INC)
 
+/*! SILK format attribute key value pairs */
+enum silk_attr_keys {
+	SILK_ATTR_KEY_SAMP_RATE,
+};
+
+enum silk_attr_vals {
+	SILK_ATTR_VAL_SAMP_8KHZ = (1 << 0),
+	SILK_ATTR_VAL_SAMP_12KHZ = (2 << 0),
+	SILK_ATTR_VAL_SAMP_16KHZ = (3 << 0),
+	SILK_ATTR_VAL_SAMP_24KHZ = (4 << 0),
+};
+
 /*! \brief This structure contains the buffer used for format attributes */
 struct ast_format_attr {
 	/*! The buffer formats can use to represent attributes */

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=306213&r1=306212&r2=306213
==============================================================================
--- team/dvossel/fixtheworld_phase2/main/format.c (original)
+++ team/dvossel/fixtheworld_phase2/main/format.c Thu Feb  3 16:18:34 2011
@@ -37,6 +37,7 @@
 #include "asterisk/frame.h"
 #include "asterisk/utils.h"
 #include "asterisk/cli.h"
+#include "asterisk/rtp_engine.h"
 
 /*! This is the container for all the format attribute interfaces.
  *  An ao2 container was chosen for fast lookup. */
@@ -948,6 +949,7 @@
 
 	ao2_ref(wrapper, -1);
 
+	ast_rtp_engine_load_format(interface->id);
 	return 0;
 }
 
@@ -972,5 +974,6 @@
 
 	ao2_ref(wrapper, -1);
 
-	return 0;
-}
+	ast_rtp_engine_unload_format(interface->id);
+	return 0;
+}

Modified: team/dvossel/fixtheworld_phase2/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/main/rtp_engine.c?view=diff&rev=306213&r1=306212&r2=306213
==============================================================================
--- team/dvossel/fixtheworld_phase2/main/rtp_engine.c (original)
+++ team/dvossel/fixtheworld_phase2/main/rtp_engine.c Thu Feb  3 16:18:34 2011
@@ -1855,7 +1855,23 @@
 
 static void add_static_payload(int map, struct ast_format *format, int rtp_code)
 {
+	int x;
 	ast_rwlock_wrlock(&static_RTP_PT_lock);
+	if (map < 0) {
+		for (x = 97; x < 127; x++) {
+			if (!static_RTP_PT[x].asterisk_format && !static_RTP_PT[x].rtp_code) {
+				map = x;
+				break;
+			}
+		}
+	}
+
+	if (map < 0) {
+		ast_log(LOG_WARNING, "No Dynamic RTP mapping avaliable for format %s\n" ,ast_getformatname(format));
+		ast_rwlock_unlock(&static_RTP_PT_lock);
+		return;
+	}
+
 	if (format) {
 		static_RTP_PT[map].asterisk_format = 1;
 		ast_format_copy(&static_RTP_PT[map].format, format);
@@ -1867,14 +1883,37 @@
 
 int ast_rtp_engine_load_format(enum ast_format_id id)
 {
-/*
+	struct ast_format tmpfmt;
 	switch (id) {
 	case AST_FORMAT_SILK:
+		ast_format_set(&tmpfmt, AST_FORMAT_SILK, 1,
+			SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_8KHZ,
+			AST_FORMAT_ATTR_END);
+		set_next_mime_type(&tmpfmt, 0, "audio", "SILK", 8000);
+		add_static_payload(-1, &tmpfmt, 0);
+
+		ast_format_set(&tmpfmt, AST_FORMAT_SILK, 1,
+			SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_12KHZ,
+			AST_FORMAT_ATTR_END);
+		set_next_mime_type(&tmpfmt, 0, "audio", "SILK", 12000);
+		add_static_payload(-1, &tmpfmt, 0);
+
+		ast_format_set(&tmpfmt, AST_FORMAT_SILK, 1,
+			SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_16KHZ,
+			AST_FORMAT_ATTR_END);
+		set_next_mime_type(&tmpfmt, 0, "audio", "SILK", 16000);
+		add_static_payload(-1, &tmpfmt, 0);
+
+		ast_format_set(&tmpfmt, AST_FORMAT_SILK, 1,
+			SILK_ATTR_KEY_SAMP_RATE, SILK_ATTR_VAL_SAMP_24KHZ,
+			AST_FORMAT_ATTR_END);
+		set_next_mime_type(&tmpfmt, 0, "audio", "SILK", 24000);
+		add_static_payload(-1, &tmpfmt, 0);
 		break;
 	default:
 		break;
 	}
-*/
+
 	return 0;
 }
 




More information about the asterisk-commits mailing list