[asterisk-commits] mmichelson: branch group/asterisk-cpp r168420 - in /team/group/asterisk-cpp: ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jan 10 20:29:55 CST 2009


Author: mmichelson
Date: Sat Jan 10 20:29:54 2009
New Revision: 168420

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168420
Log:
frame.c compiles


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

Modified: team/group/asterisk-cpp/include/asterisk/frame.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/include/asterisk/frame.h?view=diff&rev=168420&r1=168419&r2=168420
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/frame.h (original)
+++ team/group/asterisk-cpp/include/asterisk/frame.h Sat Jan 10 20:29:54 2009
@@ -390,9 +390,9 @@
 /*! \brief Definition of supported media formats (codecs) */
 struct ast_format_list {
 	int bits;	/*!< bitmask value */
-	char *name;	/*!< short name */
+	const char *name;	/*!< short name */
 	int samplespersecond; /*!< Number of samples per second (8000/16000) */
-	char *desc;	/*!< Description */
+	const char *desc;	/*!< Description */
 	int fr_len;	/*!< Single frame length in bytes */
 	int min_ms;	/*!< Min value */
 	int max_ms;	/*!< Max value */
@@ -457,7 +457,7 @@
  * \param format id of format
  * \return A static string containing the name of the format or "unknown" if unknown.
  */
-char* ast_getformatname(int format);
+const char* ast_getformatname(int format);
 
 /*! \brief Get the names of a set of formats
  * \param buf a buffer for the output string
@@ -481,7 +481,7 @@
  * \param codec codec number (1,2,4,8,16,etc.)
  * \return This returns a static string identifying the format on success, 0 on error.
  */
-char *ast_codec2str(int codec);
+const char *ast_codec2str(int codec);
 
 /*! \name AST_Smoother 
 */

Modified: team/group/asterisk-cpp/main/frame.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/frame.c?view=diff&rev=168420&r1=168419&r2=168420
==============================================================================
--- team/group/asterisk-cpp/main/frame.c (original)
+++ team/group/asterisk-cpp/main/frame.c Sat Jan 10 20:29:54 2009
@@ -137,7 +137,7 @@
 	struct ast_smoother *s;
 	if (size < 1)
 		return NULL;
-	if ((s = ast_malloc(sizeof(*s))))
+	if ((s = (struct ast_smoother *) ast_malloc(sizeof(*s))))
 		ast_smoother_reset(s, size);
 	return s;
 }
@@ -265,7 +265,7 @@
 #if !defined(LOW_MEMORY)
 	struct ast_frame_cache *frames;
 
-	if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
+	if ((frames = (struct ast_frame_cache *) ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
 		if ((f = AST_LIST_REMOVE_HEAD(&frames->list, frame_list))) {
 			size_t mallocd_len = f->mallocd_hdr_len;
 			memset(f, 0, sizeof(*f));
@@ -275,10 +275,10 @@
 			return f;
 		}
 	}
-	if (!(f = ast_calloc_cache(1, sizeof(*f))))
+	if (!(f = (struct ast_frame *) ast_calloc_cache(1, sizeof(*f))))
 		return NULL;
 #else
-	if (!(f = ast_calloc(1, sizeof(*f))))
+	if (!(f = (struct ast_frame *) ast_calloc(1, sizeof(*f))))
 		return NULL;
 #endif
 
@@ -296,7 +296,7 @@
 #if !defined(LOW_MEMORY)
 static void frame_cache_cleanup(void *data)
 {
-	struct ast_frame_cache *frames = data;
+	struct ast_frame_cache *frames = (struct ast_frame_cache *) data;
 	struct ast_frame *f;
 
 	while ((f = AST_LIST_REMOVE_HEAD(&frames->list, frame_list)))
@@ -325,7 +325,7 @@
 		 * to keep things simple... */
 		struct ast_frame_cache *frames;
 
-		if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames))) 
+		if ((frames = (struct ast_frame_cache *) ast_threadstorage_get(&frame_cache, sizeof(*frames))) 
 		    && frames->size < FRAME_CACHE_MAX_SIZE) {
 			AST_LIST_INSERT_HEAD(&frames->list, fr, frame_list);
 			frames->size++;
@@ -336,7 +336,7 @@
 	
 	if (fr->mallocd & AST_MALLOCD_DATA) {
 		if (fr->data.ptr) 
-			ast_free(fr->data.ptr - fr->offset);
+			ast_free((char *) fr->data.ptr - fr->offset);
 	}
 	if (fr->mallocd & AST_MALLOCD_SRC) {
 		if (fr->src)
@@ -405,7 +405,7 @@
 				ast_free(out);
 			return NULL;
 		}
-		newdata += AST_FRIENDLY_OFFSET;
+		newdata = (char *) newdata + AST_FRIENDLY_OFFSET;
 		out->offset = AST_FRIENDLY_OFFSET;
 		out->datalen = fr->datalen;
 		memcpy(newdata, fr->data.ptr, fr->datalen);
@@ -440,9 +440,9 @@
 		len += srclen + 1;
 	
 #if !defined(LOW_MEMORY)
-	if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
+	if ((frames = (struct ast_frame_cache *) ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
 		AST_LIST_TRAVERSE_SAFE_BEGIN(&frames->list, out, frame_list) {
-			if (out->mallocd_hdr_len >= len) {
+			if ((int) out->mallocd_hdr_len >= len) {
 				size_t mallocd_len = out->mallocd_hdr_len;
 
 				AST_LIST_REMOVE_CURRENT(frame_list);
@@ -460,7 +460,7 @@
 	if (!buf) {
 		if (!(buf = ast_calloc_cache(1, len)))
 			return NULL;
-		out = buf;
+		out = (struct ast_frame *) buf;
 		out->mallocd_hdr_len = len;
 	}
 
@@ -474,7 +474,7 @@
 	out->mallocd = AST_MALLOCD_HDR;
 	out->offset = AST_FRIENDLY_OFFSET;
 	if (out->datalen) {
-		out->data.ptr = buf + sizeof(*out) + AST_FRIENDLY_OFFSET;
+		out->data.ptr = (char *) buf + sizeof(*out) + AST_FRIENDLY_OFFSET;
 		memcpy(out->data.ptr, f->data.ptr, out->datalen);	
 	} else {
 		out->data.uint32 = f->data.uint32;
@@ -482,7 +482,7 @@
 	if (srclen > 0) {
 		/* This may seem a little strange, but it's to avoid a gcc (4.2.4) compiler warning */
 		char *src;
-		out->src = buf + sizeof(*out) + AST_FRIENDLY_OFFSET + f->datalen;
+		out->src = (char *) buf + sizeof(*out) + AST_FRIENDLY_OFFSET + f->datalen;
 		src = (char *) out->src;
 		/* Must have space since we allocated for it */
 		strcpy(src, f->src);
@@ -497,8 +497,8 @@
 void ast_swapcopy_samples(void *dst, const void *src, int samples)
 {
 	int i;
-	unsigned short *dst_s = dst;
-	const unsigned short *src_s = src;
+	unsigned short *dst_s = (unsigned short *) dst;
+	const unsigned short *src_s = (const unsigned short *) src;
 
 	for (i = 0; i < samples; i++)
 		dst_s[i] = (src_s[i]<<8) | (src_s[i]>>8);
@@ -516,10 +516,10 @@
 	return AST_FORMAT_LIST;
 }
 
-char* ast_getformatname(int format)
-{
-	int x;
-	char *ret = "unknown";
+const char* ast_getformatname(int format)
+{
+	size_t x;
+	const char *ret = "unknown";
 	for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
 		if (AST_FORMAT_LIST[x].bits == format) {
 			ret = AST_FORMAT_LIST[x].name;
@@ -531,7 +531,7 @@
 
 char *ast_getformatname_multiple(char *buf, size_t size, int format)
 {
-	int x;
+	size_t x;
 	unsigned len;
 	char *start, *end = buf;
 
@@ -558,8 +558,8 @@
 }
 
 static struct ast_codec_alias_table {
-	char *alias;
-	char *realname;
+	const char *alias;
+	const char *realname;
 } ast_codec_alias_table[] = {
 	{ "slinear", "slin"},
 	{ "slinear16", "slin16"},
@@ -568,7 +568,7 @@
 
 static const char *ast_expand_codec_alias(const char *in)
 {
-	int x;
+	size_t x;
 
 	for (x = 0; x < ARRAY_LEN(ast_codec_alias_table); x++) {
 		if (!strcmp(in,ast_codec_alias_table[x].alias))
@@ -579,7 +579,8 @@
 
 int ast_getformatbyname(const char *name)
 {
-	int x, all, format = 0;
+	size_t x;
+	int all, format = 0;
 
 	all = strcasecmp(name, "all") ? 0 : 1;
 	for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
@@ -595,10 +596,10 @@
 	return format;
 }
 
-char *ast_codec2str(int codec)
-{
-	int x;
-	char *ret = "unknown";
+const char *ast_codec2str(int codec)
+{
+	size_t x;
+	const char *ret = "unknown";
 	for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
 		if (AST_FORMAT_LIST[x].bits == codec) {
 			ret = AST_FORMAT_LIST[x].desc;
@@ -822,7 +823,7 @@
 	case AST_FRAME_TEXT:
 		strcpy(ftype, "Text");
 		strcpy(subclass, "N/A");
-		ast_copy_string(moreinfo, f->data.ptr, sizeof(moreinfo));
+		ast_copy_string(moreinfo, (const char *) f->data.ptr, sizeof(moreinfo));
 		break;
 	case AST_FRAME_IMAGE:
 		strcpy(ftype, "Image");
@@ -833,7 +834,7 @@
 		switch(f->subclass) {
 		case AST_HTML_URL:
 			strcpy(subclass, "URL");
-			ast_copy_string(moreinfo, f->data.ptr, sizeof(moreinfo));
+			ast_copy_string(moreinfo, (const char *) f->data.ptr, sizeof(moreinfo));
 			break;
 		case AST_HTML_DATA:
 			strcpy(subclass, "Data");
@@ -852,7 +853,7 @@
 			break;
 		case AST_HTML_LINKURL:
 			strcpy(subclass, "Link URL");
-			ast_copy_string(moreinfo, f->data.ptr, sizeof(moreinfo));
+			ast_copy_string(moreinfo, (const char *) f->data.ptr, sizeof(moreinfo));
 			break;
 		case AST_HTML_UNLINK:
 			strcpy(subclass, "Unlink");
@@ -975,7 +976,7 @@
 {
 	int x, codec; 
 	size_t total_len, slen;
-	char *formatname;
+	const char *formatname;
 	
 	memset(buf,0,size);
 	total_len = size;
@@ -1010,7 +1011,7 @@
 {
 	int slot = 0;
 
-	if ((idx >= 0) && (idx < sizeof(pref->order))) {
+	if ((idx >= 0) && (idx < (int) sizeof(pref->order))) {
 		slot = pref->order[idx];
 	}
 
@@ -1021,7 +1022,7 @@
 void ast_codec_pref_remove(struct ast_codec_pref *pref, int format)
 {
 	struct ast_codec_pref oldorder;
-	int x, y = 0;
+	size_t x, y = 0;
 	int slot;
 	int size;
 
@@ -1047,7 +1048,8 @@
 /*! \brief Append codec to list */
 int ast_codec_pref_append(struct ast_codec_pref *pref, int format)
 {
-	int x, newindex = 0;
+	size_t x;
+	int newindex = 0;
 
 	ast_codec_pref_remove(pref, format);
 
@@ -1073,7 +1075,8 @@
 /*! \brief Prepend codec to list */
 void ast_codec_pref_prepend(struct ast_codec_pref *pref, int format, int only_if_existing)
 {
-	int x, newindex = 0;
+	size_t x;
+	int newindex = 0;
 
 	/* First step is to get the codecs "index number" */
 	for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
@@ -1110,7 +1113,8 @@
 /*! \brief Set packet size for codec */
 int ast_codec_pref_setsize(struct ast_codec_pref *pref, int format, int framems)
 {
-	int x, idx = -1;
+	size_t x;
+	int idx = -1;
 
 	for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
 		if (AST_FORMAT_LIST[x].bits == format) {
@@ -1148,7 +1152,8 @@
 /*! \brief Get packet size for codec */
 struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, int format)
 {
-	int x, idx = -1, framems = 0;
+	size_t x;
+	int idx = -1, framems = 0;
 	struct ast_format_list fmt = { 0, };
 
 	for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
@@ -1187,7 +1192,7 @@
 /*! \brief Pick a codec */
 int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best)
 {
-	int x, ret = 0, slot;
+	size_t x, ret = 0, slot;
 
 	for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
 		slot = pref->order[x];
@@ -1210,24 +1215,24 @@
 int ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char *list, int allowing) 
 {
 	int errors = 0;
-	char *parse = NULL, *this = NULL, *psize = NULL;
+	char *parse = NULL, *this_format = NULL, *psize = NULL;
 	int format = 0, framems = 0;
 
 	parse = ast_strdupa(list);
-	while ((this = strsep(&parse, ","))) {
+	while ((this_format = strsep(&parse, ","))) {
 		framems = 0;
-		if ((psize = strrchr(this, ':'))) {
+		if ((psize = strrchr(this_format, ':'))) {
 			*psize++ = '\0';
-			ast_debug(1, "Packetization for codec: %s is %s\n", this, psize);
+			ast_debug(1, "Packetization for codec: %s is %s\n", this_format, psize);
 			framems = atoi(psize);
 			if (framems < 0) {
 				framems = 0;
 				errors++;
-				ast_log(LOG_WARNING, "Bad packetization value for codec %s\n", this);
+				ast_log(LOG_WARNING, "Bad packetization value for codec %s\n", this_format);
 			}
 		}
-		if (!(format = ast_getformatbyname(this))) {
-			ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", allowing ? "allow" : "disallow", this);
+		if (!(format = ast_getformatbyname(this_format))) {
+			ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", allowing ? "allow" : "disallow", this_format);
 			errors++;
 			continue;
 		}
@@ -1243,7 +1248,7 @@
 		   since we can not transcode video and have to use whatever is offered
 		 */
 		if (pref && (format & AST_FORMAT_AUDIO_MASK)) {
-			if (strcasecmp(this, "all")) {
+			if (strcasecmp(this_format, "all")) {
 				if (allowing) {
 					ast_codec_pref_append(pref, format);
 					ast_codec_pref_setsize(pref, format, framems);
@@ -1260,7 +1265,7 @@
 
 static int g723_len(unsigned char buf)
 {
-	enum frame_type type = buf & TYPE_MASK;
+	enum frame_type type = (enum frame_type) (buf & TYPE_MASK);
 
 	switch(type) {
 	case TYPE_DONTSEND:
@@ -1410,10 +1415,10 @@
 	int samples=0;
 	switch(f->subclass) {
 	case AST_FORMAT_SPEEX:
-		samples = speex_samples(f->data.ptr, f->datalen);
+		samples = speex_samples((unsigned char *)f->data.ptr, f->datalen);
 		break;
 	case AST_FORMAT_G723_1:
-		samples = g723_samples(f->data.ptr, f->datalen);
+		samples = g723_samples((unsigned char *)f->data.ptr, f->datalen);
 		break;
 	case AST_FORMAT_ILBC:
 		samples = 240 * (f->datalen / 50);
@@ -1491,7 +1496,7 @@
 int ast_frame_adjust_volume(struct ast_frame *f, int adjustment)
 {
 	int count;
-	short *fdata = f->data.ptr;
+	short *fdata = (short *) f->data.ptr;
 	short adjust_value = abs(adjustment);
 
 	if ((f->frametype != AST_FRAME_VOICE) || (f->subclass != AST_FORMAT_SLINEAR))
@@ -1525,7 +1530,7 @@
 	if (f1->samples != f2->samples)
 		return -1;
 
-	for (count = 0, data1 = f1->data.ptr, data2 = f2->data.ptr;
+	for (count = 0, data1 = (short *) f1->data.ptr, data2 = (short *) f2->data.ptr;
 	     count < f1->samples;
 	     count++, data1++, data2++)
 		ast_slinear_saturated_add(data1, data2);




More information about the asterisk-commits mailing list