[asterisk-commits] seanbright: branch group/asterisk-cpp r168461 - in /team/group/asterisk-cpp: ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jan 11 20:10:02 CST 2009


Author: seanbright
Date: Sun Jan 11 20:10:02 2009
New Revision: 168461

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168461
Log:
rtp.c compiles now.  replaced the array initializers by building the table at load time based on a suggestion by russellb.

Modified:
    team/group/asterisk-cpp/README-cpp
    team/group/asterisk-cpp/include/asterisk/rtp.h
    team/group/asterisk-cpp/main/rtp.c

Modified: team/group/asterisk-cpp/README-cpp
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/README-cpp?view=diff&rev=168461&r1=168460&r2=168461
==============================================================================
--- team/group/asterisk-cpp/README-cpp (original)
+++ team/group/asterisk-cpp/README-cpp Sun Jan 11 20:10:02 2009
@@ -2,7 +2,7 @@
 --- Assigned conversions
 ----------------------------------
 
-Objects left in main: channel.o pbx.o rtp.o
+Objects left in main: channel.o pbx.o
 
 mmichelson: done! (for now, maybe.)
 russell: pbx.c

Modified: team/group/asterisk-cpp/include/asterisk/rtp.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/rtp.h?view=diff&rev=168461&r1=168460&r2=168461
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/rtp.h (original)
+++ team/group/asterisk-cpp/include/asterisk/rtp.h Sun Jan 11 20:10:02 2009
@@ -259,7 +259,7 @@
 /*! \brief The RTP bridge.
 	\arg \ref AstRTPbridge
 */
-int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
+enum ast_bridge_result ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
 
 /*! \brief Register an RTP channel client */
 int ast_rtp_proto_register(struct ast_rtp_protocol *proto);

Modified: team/group/asterisk-cpp/main/rtp.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/rtp.c?view=diff&rev=168461&r1=168460&r2=168461
==============================================================================
--- team/group/asterisk-cpp/main/rtp.c (original)
+++ team/group/asterisk-cpp/main/rtp.c Sun Jan 11 20:10:02 2009
@@ -1895,40 +1895,48 @@
  * See http://www.iana.org/assignments/rtp-parameters for a list of
  * assigned values
  */
-static struct rtpPayloadType static_RTP_PT[MAX_RTP_PT] = {
-	[0] = {1, AST_FORMAT_ULAW},
+
+struct rtpPayloadTypeMap {
+    unsigned int index;
+    struct rtpPayloadType payloadType;
+};
+
+static struct rtpPayloadType static_RTP_PT[MAX_RTP_PT] = { { 0, 0 } };
+
+static struct rtpPayloadTypeMap static_RTP_PT_map[] = {
+	{ 0,   {1, AST_FORMAT_ULAW}      },
 #ifdef USE_DEPRECATED_G726
-	[2] = {1, AST_FORMAT_G726}, /* Technically this is G.721, but if Cisco can do it, so can we... */
+	{ 2,   {1, AST_FORMAT_G726}      }, /* Technically this is G.721, but if Cisco can do it, so can we... */
 #endif
-	[3] = {1, AST_FORMAT_GSM},
-	[4] = {1, AST_FORMAT_G723_1},
-	[5] = {1, AST_FORMAT_ADPCM}, /* 8 kHz */
-	[6] = {1, AST_FORMAT_ADPCM}, /* 16 kHz */
-	[7] = {1, AST_FORMAT_LPC10},
-	[8] = {1, AST_FORMAT_ALAW},
-	[9] = {1, AST_FORMAT_G722},
-	[10] = {1, AST_FORMAT_SLINEAR}, /* 2 channels */
-	[11] = {1, AST_FORMAT_SLINEAR}, /* 1 channel */
-	[13] = {0, AST_RTP_CN},
-	[16] = {1, AST_FORMAT_ADPCM}, /* 11.025 kHz */
-	[17] = {1, AST_FORMAT_ADPCM}, /* 22.050 kHz */
-	[18] = {1, AST_FORMAT_G729A},
-	[19] = {0, AST_RTP_CN},		/* Also used for CN */
-	[26] = {1, AST_FORMAT_JPEG},
-	[31] = {1, AST_FORMAT_H261},
-	[34] = {1, AST_FORMAT_H263},
-	[97] = {1, AST_FORMAT_ILBC},
-	[98] = {1, AST_FORMAT_H263_PLUS},
-	[99] = {1, AST_FORMAT_H264},
-	[101] = {0, AST_RTP_DTMF},
-	[103] = {1, AST_FORMAT_H263_PLUS},
-	[104] = {1, AST_FORMAT_MP4_VIDEO},
-	[105] = {1, AST_FORMAT_T140RED},	/* Real time text chat (with redundancy encoding) */
-	[106] = {1, AST_FORMAT_T140},	/* Real time text chat */
-	[110] = {1, AST_FORMAT_SPEEX},
-	[111] = {1, AST_FORMAT_G726},
-	[112] = {1, AST_FORMAT_G726_AAL2},
-	[121] = {0, AST_RTP_CISCO_DTMF}, /* Must be type 121 */
+	{ 3,   {1, AST_FORMAT_GSM}       },
+	{ 4,   {1, AST_FORMAT_G723_1}    },
+	{ 5,   {1, AST_FORMAT_ADPCM}     }, /* 8 kHz */
+	{ 6,   {1, AST_FORMAT_ADPCM}     }, /* 16 kHz */
+	{ 7,   {1, AST_FORMAT_LPC10}     },
+	{ 8,   {1, AST_FORMAT_ALAW}      },
+	{ 9,   {1, AST_FORMAT_G722}      },
+	{ 10,  {1, AST_FORMAT_SLINEAR}   }, /* 2 channels */
+	{ 11,  {1, AST_FORMAT_SLINEAR}   }, /* 1 channel */
+	{ 13,  {0, AST_RTP_CN}           },
+	{ 16,  {1, AST_FORMAT_ADPCM}     }, /* 11.025 kHz */
+	{ 17,  {1, AST_FORMAT_ADPCM}     }, /* 22.050 kHz */
+	{ 18,  {1, AST_FORMAT_G729A}     },
+	{ 19,  {0, AST_RTP_CN}           },		/* Also used for CN */
+	{ 26,  {1, AST_FORMAT_JPEG}      },
+	{ 31,  {1, AST_FORMAT_H261}      },
+	{ 34,  {1, AST_FORMAT_H263}      },
+	{ 97,  {1, AST_FORMAT_ILBC}      },
+	{ 98,  {1, AST_FORMAT_H263_PLUS} },
+	{ 99,  {1, AST_FORMAT_H264}      },
+	{ 101, {0, AST_RTP_DTMF}         },
+	{ 103, {1, AST_FORMAT_H263_PLUS} },
+	{ 104, {1, AST_FORMAT_MP4_VIDEO} },
+	{ 105, {1, AST_FORMAT_T140RED}   },	/* Real time text chat (with redundancy encoding) */
+	{ 106, {1, AST_FORMAT_T140}      },	/* Real time text chat */
+	{ 110, {1, AST_FORMAT_SPEEX}     },
+	{ 111, {1, AST_FORMAT_G726}      },
+	{ 112, {1, AST_FORMAT_G726_AAL2} },
+	{ 121, {0, AST_RTP_CISCO_DTMF}   }, /* Must be type 121 */
 };
 
 void ast_rtp_pt_clear(struct ast_rtp* rtp) 
@@ -2397,7 +2405,7 @@
 {
 	struct ast_rtcp *rtcp;
 
-	if (!(rtcp = ast_calloc(1, sizeof(*rtcp))))
+	if (!(rtcp = (struct ast_rtcp *) ast_calloc(1, sizeof(*rtcp))))
 		return NULL;
 	rtcp->s = rtp_socket("RTCP");
 	rtcp->us.sin_family = AF_INET;
@@ -2436,7 +2444,7 @@
 	int x;
 	int startplace;
 	
-	if (!(rtp = ast_calloc(1, sizeof(*rtp))))
+	if (!(rtp = (struct ast_rtp *) ast_calloc(1, sizeof(*rtp))))
 		return NULL;
 
 	ast_rtp_new_init(rtp);
@@ -3181,7 +3189,7 @@
 /*! \brief Public function: Send an H.261 fast update request, some devices need this rather than SIP XML */
 int ast_rtcp_send_h261fur(void *data)
 {
-	struct ast_rtp *rtp = data;
+	struct ast_rtp *rtp = (struct ast_rtp *) data;
 	int res;
 
 	rtp->rtcp->sendfur = 1;
@@ -3566,7 +3574,7 @@
 		rtp->lastts = f->ts * 8;
 
 	/* Get a pointer to the header */
-	rtpheader = (unsigned char *)(f->data.ptr - hdrlen);
+	rtpheader = (unsigned char *)(((unsigned char *) f->data.ptr) - hdrlen);
 
 	put_unaligned_uint32(rtpheader, htonl((2 << 30) | (codec << 16) | (rtp->seqno) | (mark << 23)));
 	put_unaligned_uint32(rtpheader + 4, htonl(rtp->lastts));
@@ -4653,6 +4661,11 @@
 /*! \brief Initialize the RTP system in Asterisk */
 void ast_rtp_init(void)
 {
+    /* Initialize format lookup table */
+    for (size_t x = 0; x < ARRAY_LEN(static_RTP_PT_map); x++) {
+        static_RTP_PT[static_RTP_PT_map[x].index] = static_RTP_PT_map[x].payloadType;
+    }
+
 	ast_cli_register_multiple(cli_rtp, sizeof(cli_rtp) / sizeof(struct ast_cli_entry));
 	__ast_rtp_reload(0);
 }
@@ -4673,7 +4686,7 @@
  * \param red redundant data structure
  */
 static struct ast_frame *red_t140_to_red(struct rtp_red *red) {
-	unsigned char *data = red->t140red.data.ptr;
+	unsigned char *data = (unsigned char *) red->t140red.data.ptr;
 	int len = 0;
 	int i;
 
@@ -4721,7 +4734,7 @@
 	struct rtp_red *r;
 	int x;
 	
-	if (!(r = ast_calloc(1, sizeof(struct rtp_red))))
+	if (!(r = (struct rtp_red *) ast_calloc(1, sizeof(struct rtp_red))))
 		return -1;
 
 	r->t140.frametype = AST_FRAME_TEXT;




More information about the asterisk-commits mailing list