[asterisk-commits] tilghman: branch tilghman/codec_bits3 r227544 - in /team/tilghman/codec_bits3...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Nov 3 22:01:44 CST 2009


Author: tilghman
Date: Tue Nov  3 22:01:40 2009
New Revision: 227544

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=227544
Log:
Make SIP also work against extended codec bits

Modified:
    team/tilghman/codec_bits3/channels/chan_sip.c
    team/tilghman/codec_bits3/include/asterisk/rtp_engine.h
    team/tilghman/codec_bits3/main/dsp.c
    team/tilghman/codec_bits3/main/rtp_engine.c

Modified: team/tilghman/codec_bits3/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/channels/chan_sip.c?view=diff&rev=227544&r1=227543&r2=227544
==============================================================================
--- team/tilghman/codec_bits3/channels/chan_sip.c (original)
+++ team/tilghman/codec_bits3/channels/chan_sip.c Tue Nov  3 22:01:40 2009
@@ -1146,7 +1146,7 @@
 #define DEFAULT_SDPSESSION "Asterisk PBX"	/*!< Default SDP session name, (s=) header unless re-defined in sip.conf */
 #define DEFAULT_SDPOWNER "root"			/*!< Default SDP username field in (o=) header unless re-defined in sip.conf */
 #define DEFAULT_ENGINE "asterisk"               /*!< Default RTP engine to use for sessions */
-#define DEFAULT_CAPABILITY (AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263);
+#define DEFAULT_CAPABILITY (AST_FORMAT_ULAW | AST_FORMAT_TESTLAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263);
 #endif
 /*@}*/
 
@@ -2501,7 +2501,7 @@
 static const char *get_sdp(struct sip_request *req, const char *name);
 static int find_sdp(struct sip_request *req);
 static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action);
-static void add_codec_to_sdp(const struct sip_pvt *p, int codec,
+static void add_codec_to_sdp(const struct sip_pvt *p, format_t codec,
 			     struct ast_str **m_buf, struct ast_str **a_buf,
 			     int debug, int *min_packet_size);
 static void add_noncodec_to_sdp(const struct sip_pvt *p, int format,
@@ -6459,7 +6459,7 @@
 /*! \brief Try setting codec suggested by the SIP_CODEC channel variable */
 static void try_suggested_sip_codec(struct sip_pvt *p)
 {
-	int fmt;
+	format_t fmt;
 	const char *codec;
 	struct ast_channel* chan;
 
@@ -6914,10 +6914,10 @@
 {
 	struct ast_channel *tmp;
 	struct ast_variable *v = NULL;
-	int fmt;
-	int what;
-	int video;
-	int text;
+	format_t fmt;
+	format_t what;
+	format_t video;
+	format_t text;
 	format_t needvideo = 0;
 	int needtext = 0;
 	char buf[SIPBUFSIZE];
@@ -10185,7 +10185,7 @@
 }
 
 /*! \brief Add codec offer to SDP offer/answer body in INVITE or 200 OK */
-static void add_codec_to_sdp(const struct sip_pvt *p, int codec,
+static void add_codec_to_sdp(const struct sip_pvt *p, format_t codec,
 			     struct ast_str **m_buf, struct ast_str **a_buf,
 			     int debug, int *min_packet_size)
 {
@@ -10194,7 +10194,7 @@
 
 
 	if (debug)
-		ast_verbose("Adding codec 0x%x (%s) to SDP\n", codec, ast_getformatname(codec));
+		ast_verbose("Adding codec 0x%Lx (%s) to SDP\n", codec, ast_getformatname(codec));
 	if ((rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(p->rtp), 1, codec)) == -1)
 		return;
 
@@ -10392,7 +10392,7 @@
 static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int oldsdp, int add_audio, int add_t38)
 {
 	int len = 0;
-	int alreadysent = 0;
+	format_t alreadysent = 0;
 
 	struct sockaddr_in sin = { 0, };
 	struct sockaddr_in vsin = { 0, };
@@ -10420,8 +10420,8 @@
 	struct ast_str *a_text = ast_str_alloca(1024);  /* Attributes for text */
 	struct ast_str *a_modem = ast_str_alloca(1024); /* Attributes for modem */
 
-	int x;
-	int capability = 0;
+	format_t x;
+	format_t capability = 0;
 	int needaudio = FALSE;
 	int needvideo = FALSE;
 	int needtext = FALSE;
@@ -10543,15 +10543,15 @@
 		   Note that p->prefcodec can include video codecs, so mask them out
 		*/
 		if (capability & p->prefcodec) {
-			int codec = p->prefcodec & AST_FORMAT_AUDIO_MASK;
+			format_t codec = p->prefcodec & AST_FORMAT_AUDIO_MASK;
 
 			add_codec_to_sdp(p, codec, &m_audio, &a_audio, debug, &min_audio_packet_size);
 			alreadysent |= codec;
 		}
 
 		/* Start by sending our preferred audio/video codecs */
-		for (x = 0; x < 32; x++) {
-			int codec;
+		for (x = 0; x < 64; x++) {
+			format_t codec;
 
 			if (!(codec = ast_codec_pref_index(&p->prefs, x)))
 				break;
@@ -10567,7 +10567,7 @@
 		}
 
 		/* Now send any other common audio and video codecs, and non-codec formats: */
-		for (x = 1; x <= (needtext ? AST_FORMAT_TEXT_MASK : (needvideo ? AST_FORMAT_VIDEO_MASK : AST_FORMAT_AUDIO_MASK)); x <<= 1) {
+		for (x = 1LL; x <= (needtext ? AST_FORMAT_TEXT_MASK : (needvideo ? AST_FORMAT_VIDEO_MASK : AST_FORMAT_AUDIO_MASK)); x <<= 1) {
 			if (!(capability & x))	/* Codec not requested */
 				continue;
 
@@ -10583,7 +10583,7 @@
 		}
 
 		/* Now add DTMF RFC2833 telephony-event as a codec */
-		for (x = 1; x <= AST_RTP_MAX; x <<= 1) {
+		for (x = 1LL; x <= AST_RTP_MAX; x <<= 1) {
 			if (!(p->jointnoncodeccapability & x))
 				continue;
 
@@ -15665,9 +15665,10 @@
 /*! \brief Print codec list from preference to CLI/manager */
 static void print_codec_to_cli(int fd, struct ast_codec_pref *pref)
 {
-	int x, codec;
-
-	for(x = 0; x < 32 ; x++) {
+	int x;
+	format_t codec;
+
+	for(x = 0; x < 64 ; x++) {
 		codec = ast_codec_pref_index(pref, x);
 		if (!codec)
 			break;
@@ -15860,7 +15861,8 @@
 	struct ast_codec_pref *pref;
 	struct ast_variable *v;
 	struct sip_auth *auth;
-	int x = 0, codec = 0, load_realtime;
+	int x = 0, load_realtime;
+	format_t codec = 0;
 	int realtimepeers;
 
 	realtimepeers = ast_check_realtime("sippeers");
@@ -16067,12 +16069,12 @@
 		astman_append(s, "%s\r\n", codec_buf);
 		astman_append(s, "CodecOrder: ");
 		pref = &peer->prefs;
-		for(x = 0; x < 32 ; x++) {
+		for(x = 0; x < 64 ; x++) {
 			codec = ast_codec_pref_index(pref, x);
 			if (!codec)
 				break;
 			astman_append(s, "%s", ast_getformatname(codec));
-			if (x < 31 && ast_codec_pref_index(pref, x+1))
+			if (x < 63 && ast_codec_pref_index(pref, x+1))
 				astman_append(s, ",");
 		}
 
@@ -17862,7 +17864,7 @@
 		}
 	} else  if (!strncasecmp(colname, "codec[", 6)) {
 		char *codecnum;
-		int codec = 0;
+		format_t codec = 0;
 		
 		codecnum = colname + 6;	/* move past the '[' */
 		codecnum = strsep(&codecnum, "]"); /* trim trailing ']' if any */

Modified: team/tilghman/codec_bits3/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/include/asterisk/rtp_engine.h?view=diff&rev=227544&r1=227543&r2=227544
==============================================================================
--- team/tilghman/codec_bits3/include/asterisk/rtp_engine.h (original)
+++ team/tilghman/codec_bits3/include/asterisk/rtp_engine.h Tue Nov  3 22:01:40 2009
@@ -994,7 +994,7 @@
  *
  * \since 1.6.3
  */
-unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, int code);
+unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, format_t code);
 
 /*!
  * \brief Retrieve all formats that were found

Modified: team/tilghman/codec_bits3/main/dsp.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/main/dsp.c?view=diff&rev=227544&r1=227543&r2=227544
==============================================================================
--- team/tilghman/codec_bits3/main/dsp.c (original)
+++ team/tilghman/codec_bits3/main/dsp.c Tue Nov  3 22:01:40 2009
@@ -1321,6 +1321,7 @@
 		len = af->datalen / 2;
 		break;
 	case AST_FORMAT_ULAW:
+	case AST_FORMAT_TESTLAW:
 		shortdata = alloca(af->datalen * 2);
 		for (x = 0;x < len; x++) {
 			shortdata[x] = AST_MULAW(odata[x]);

Modified: team/tilghman/codec_bits3/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/main/rtp_engine.c?view=diff&rev=227544&r1=227543&r2=227544
==============================================================================
--- team/tilghman/codec_bits3/main/rtp_engine.c (original)
+++ team/tilghman/codec_bits3/main/rtp_engine.c Tue Nov  3 22:01:40 2009
@@ -655,7 +655,7 @@
 	return "";
 }
 
-unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, int code)
+unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, format_t code)
 {
 	unsigned int i;
 
@@ -670,7 +670,8 @@
 
 char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const format_t capability, const int asterisk_format, enum ast_rtp_options options)
 {
-	int format, found = 0;
+	format_t format;
+	int found = 0;
 
 	if (!buf) {
 		return NULL;
@@ -1164,7 +1165,7 @@
 	enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID, text_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
 	enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID, text_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
 	enum ast_bridge_result res = AST_BRIDGE_FAILED;
-	int codec0 = 0, codec1 = 0;
+	format_t codec0 = 0, codec1 = 0;
 	int unlock_chans = 1;
 
 	/* Lock both channels so we can look for the glue that binds them together */
@@ -1229,7 +1230,7 @@
 	codec0 = glue0->get_codec ? glue0->get_codec(c0) : 0;
 	codec1 = glue1->get_codec ? glue1->get_codec(c1) : 0;
 	if (codec0 && codec1 && !(codec0 & codec1)) {
-		ast_debug(1, "Channel codec0 = %d is not codec1 = %d, cannot native bridge in RTP.\n", codec0, codec1);
+		ast_debug(1, "Channel codec0 = %s is not codec1 = %s, cannot native bridge in RTP.\n", ast_getformatname(codec0), ast_getformatname(codec1));
 		res = AST_BRIDGE_FAILED_NOWARN;
 		goto done;
 	}




More information about the asterisk-commits mailing list