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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Oct 25 17:14:13 CDT 2009


Author: tilghman
Date: Sun Oct 25 17:14:07 2009
New Revision: 225764

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=225764
Log:
Commit an afternoon of changes

Added:
    team/tilghman/codec_bits3/include/asterisk/frame_defs.h   (with props)
Modified:
    team/tilghman/codec_bits3/channels/chan_agent.c
    team/tilghman/codec_bits3/include/asterisk/abstract_jb.h
    team/tilghman/codec_bits3/include/asterisk/audiohook.h
    team/tilghman/codec_bits3/include/asterisk/bridging.h
    team/tilghman/codec_bits3/include/asterisk/channel.h
    team/tilghman/codec_bits3/include/asterisk/frame.h
    team/tilghman/codec_bits3/main/abstract_jb.c
    team/tilghman/codec_bits3/main/app.c
    team/tilghman/codec_bits3/main/audiohook.c
    team/tilghman/codec_bits3/main/autoservice.c
    team/tilghman/codec_bits3/main/bridging.c
    team/tilghman/codec_bits3/main/channel.c
    team/tilghman/codec_bits3/main/dial.c
    team/tilghman/codec_bits3/main/dsp.c
    team/tilghman/codec_bits3/main/features.c
    team/tilghman/codec_bits3/main/file.c
    team/tilghman/codec_bits3/main/frame.c
    team/tilghman/codec_bits3/res/res_agi.c
    team/tilghman/codec_bits3/res/res_musiconhold.c
    team/tilghman/codec_bits3/res/res_rtp_asterisk.c
    team/tilghman/codec_bits3/res/res_rtp_multicast.c

Modified: team/tilghman/codec_bits3/channels/chan_agent.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/channels/chan_agent.c?view=diff&rev=225764&r1=225763&r2=225764
==============================================================================
--- team/tilghman/codec_bits3/channels/chan_agent.c (original)
+++ team/tilghman/codec_bits3/channels/chan_agent.c Sun Oct 25 17:14:07 2009
@@ -1959,12 +1959,12 @@
 					if (!res) {
 						res = ast_set_read_format(chan, ast_best_codec(chan->nativeformats));
 						if (res)
-							ast_log(LOG_WARNING, "Unable to set read format to %d\n", ast_best_codec(chan->nativeformats));
+							ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_best_codec(chan->nativeformats)));
 					}
 					if (!res) {
 						res = ast_set_write_format(chan, ast_best_codec(chan->nativeformats));
 						if (res)
-							ast_log(LOG_WARNING, "Unable to set write format to %d\n", ast_best_codec(chan->nativeformats));
+							ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_best_codec(chan->nativeformats)));
 					}
 					/* Check once more just in case */
 					if (p->chan)

Modified: team/tilghman/codec_bits3/include/asterisk/abstract_jb.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/include/asterisk/abstract_jb.h?view=diff&rev=225764&r1=225763&r2=225764
==============================================================================
--- team/tilghman/codec_bits3/include/asterisk/abstract_jb.h (original)
+++ team/tilghman/codec_bits3/include/asterisk/abstract_jb.h Sun Oct 25 17:14:07 2009
@@ -31,6 +31,8 @@
 #define _ABSTRACT_JB_H_
 
 #include <sys/time.h>
+
+#include "asterisk/frame_defs.h"
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
@@ -92,7 +94,7 @@
 	/*! \brief The time the next frame should be played. */
 	long next;
 	/*! \brief Voice format of the last frame in. */
-	int last_format;
+	format_t last_format;
 	/*! \brief File for frame timestamp tracing. */
 	FILE *logfile;
 	/*! \brief Jitterbuffer internal state flags. */

Modified: team/tilghman/codec_bits3/include/asterisk/audiohook.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/include/asterisk/audiohook.h?view=diff&rev=225764&r1=225763&r2=225764
==============================================================================
--- team/tilghman/codec_bits3/include/asterisk/audiohook.h (original)
+++ team/tilghman/codec_bits3/include/asterisk/audiohook.h Sun Oct 25 17:14:07 2009
@@ -30,7 +30,7 @@
 /* these two are used in struct ast_audiohook */
 #include "asterisk/lock.h"
 #include "asterisk/linkedlists.h"
-
+#include "asterisk/frame_defs.h"
 #include "asterisk/slinfactory.h"
 
 enum ast_audiohook_type {
@@ -133,7 +133,7 @@
  * \param format Format of frame remote side wants back
  * \return Returns frame on success, NULL on failure
  */
-struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, int format);
+struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, format_t format);
 
 /*! \brief Attach audiohook to channel
  * \param chan Channel

Modified: team/tilghman/codec_bits3/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/include/asterisk/bridging.h?view=diff&rev=225764&r1=225763&r2=225764
==============================================================================
--- team/tilghman/codec_bits3/include/asterisk/bridging.h (original)
+++ team/tilghman/codec_bits3/include/asterisk/bridging.h Sun Oct 25 17:14:07 2009
@@ -193,7 +193,7 @@
  * This creates a simple two party bridge that will be destroyed once one of
  * the channels hangs up.
  */
-struct ast_bridge *ast_bridge_new(int capabilities, int flags);
+struct ast_bridge *ast_bridge_new(format_t capabilities, int flags);
 
 /*! \brief See if it is possible to create a bridge
  *
@@ -211,7 +211,7 @@
  * This sees if it is possible to create a bridge capable of bridging two channels
  * together.
  */
-int ast_bridge_check(int capabilities);
+int ast_bridge_check(format_t capabilities);
 
 /*! \brief Destroy a bridge
  *

Modified: team/tilghman/codec_bits3/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/include/asterisk/channel.h?view=diff&rev=225764&r1=225763&r2=225764
==============================================================================
--- team/tilghman/codec_bits3/include/asterisk/channel.h (original)
+++ team/tilghman/codec_bits3/include/asterisk/channel.h Sun Oct 25 17:14:07 2009
@@ -731,7 +731,7 @@
 	int fdno;					/*!< Which fd had an event detected on */
 	int streamid;					/*!< For streaming playback, the schedule ID */
 	int vstreamid;					/*!< For streaming video playback, the schedule ID */
-	int oldwriteformat;				/*!< Original writer format */
+	format_t oldwriteformat;		/*!< Original writer format */
 	int timingfd;					/*!< Timing fd */
 	enum ast_channel_state _state;			/*!< State of line -- Don't write directly, use ast_setstate() */
 	int rings;					/*!< Number of rings so far */
@@ -1139,7 +1139,7 @@
  * \retval NULL failure
  * \retval non-NULL channel on success
  */
-struct ast_channel *ast_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *status);
+struct ast_channel *ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *status);
 
 /*!
  * \brief Request a channel of a given type, with data as optional information used
@@ -1186,7 +1186,7 @@
  * \param outstate reason why unsuccessful (if uncuccessful)
  * \return Returns the forwarded call's ast_channel on success or NULL on failure
  */
-struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, int format, struct outgoing_helper *oh, int *outstate);
+struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, format_t format, struct outgoing_helper *oh, int *outstate);
 
 /*!
  * \brief Register a channel technology (a new channel driver)
@@ -1821,7 +1821,7 @@
 
 /*! Pick the best codec
  * Choose the best codec...  Uhhh...   Yah. */
-int ast_best_codec(format_t fmts);
+format_t ast_best_codec(format_t fmts);
 
 
 /*!

Modified: team/tilghman/codec_bits3/include/asterisk/frame.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/include/asterisk/frame.h?view=diff&rev=225764&r1=225763&r2=225764
==============================================================================
--- team/tilghman/codec_bits3/include/asterisk/frame.h (original)
+++ team/tilghman/codec_bits3/include/asterisk/frame.h Sun Oct 25 17:14:07 2009
@@ -31,10 +31,9 @@
 
 #include <sys/time.h>
 
+#include "asterisk/frame_defs.h"
 #include "asterisk/endian.h"
 #include "asterisk/linkedlists.h"
-
-typedef uint64_t format_t;
 
 struct ast_codec_pref {
 	char order[sizeof(format_t) * 8];
@@ -622,7 +621,7 @@
  * \brief Codec located at a particular place in the preference index.
  * \arg \ref AudioCodecPref 
 */
-int ast_codec_pref_index(struct ast_codec_pref *pref, int index);
+format_t ast_codec_pref_index(struct ast_codec_pref *pref, int index);
 
 /*! \brief Remove audio a codec from a preference list */
 void ast_codec_pref_remove(struct ast_codec_pref *pref, format_t format);

Added: team/tilghman/codec_bits3/include/asterisk/frame_defs.h
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/include/asterisk/frame_defs.h?view=auto&rev=225764
==============================================================================
--- team/tilghman/codec_bits3/include/asterisk/frame_defs.h (added)
+++ team/tilghman/codec_bits3/include/asterisk/frame_defs.h Sun Oct 25 17:14:07 2009
@@ -1,0 +1,38 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2009, Digium, Inc.
+ *
+ * Mark Spencer <markster at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ * \brief Asterisk internal frame definitions.
+ * \arg For an explanation of frames, see \ref Def_Frame
+ * \arg Frames are send of Asterisk channels, see \ref Def_Channel
+ */
+
+#ifndef _ASTERISK_FRAME_DEFS_H
+#define _ASTERISK_FRAME_DEFS_H
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+typedef uint64_t format_t;
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif /* _ASTERISK_FRAME_DEFS_H */

Propchange: team/tilghman/codec_bits3/include/asterisk/frame_defs.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/tilghman/codec_bits3/include/asterisk/frame_defs.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/tilghman/codec_bits3/include/asterisk/frame_defs.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/tilghman/codec_bits3/main/abstract_jb.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/main/abstract_jb.c?view=diff&rev=225764&r1=225763&r2=225764
==============================================================================
--- team/tilghman/codec_bits3/main/abstract_jb.c (original)
+++ team/tilghman/codec_bits3/main/abstract_jb.c Sun Oct 25 17:14:07 2009
@@ -409,14 +409,14 @@
 		case JB_IMPL_DROP:
 			jb_framelog("\tJB_GET {now=%ld}: %s frame with ts=%ld and len=%ld\n",
 				now, jb_get_actions[res], f->ts, f->len);
-			jb->last_format = f->subclass;
+			jb->last_format = f->subclass.codec;
 			ast_frfree(f);
 			break;
 		case JB_IMPL_INTERP:
 			/* interpolate a frame */
 			f = &finterp;
 			f->frametype = AST_FRAME_VOICE;
-			f->subclass = jb->last_format;
+			f->subclass.codec = jb->last_format;
 			f->datalen  = 0;
 			f->samples  = interpolation_len * 8;
 			f->mallocd  = 0;
@@ -480,7 +480,7 @@
 	jb->next = jbimpl->next(jbobj);
 
 	/* Init last format for a first time. */
-	jb->last_format = frr->subclass;
+	jb->last_format = frr->subclass.codec;
 
 	/* Create a frame log file */
 	if (ast_test_flag(jbconf, AST_JB_LOG)) {

Modified: team/tilghman/codec_bits3/main/app.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/main/app.c?view=diff&rev=225764&r1=225763&r2=225764
==============================================================================
--- team/tilghman/codec_bits3/main/app.c (original)
+++ team/tilghman/codec_bits3/main/app.c Sun Oct 25 17:14:07 2009
@@ -429,7 +429,7 @@
 	struct linear_state *ls = data;
 	struct ast_frame f = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_SLINEAR,
+		.subclass.codec = AST_FORMAT_SLINEAR,
 		.data.ptr = buf + AST_FRIENDLY_OFFSET / 2,
 		.offset = AST_FRIENDLY_OFFSET,
 	};
@@ -851,20 +851,20 @@
 			} else if (f->frametype == AST_FRAME_DTMF) {
 				if (prepend) {
 				/* stop recording with any digit */
-					ast_verb(3, "User ended message by pressing %c\n", f->subclass);
+					ast_verb(3, "User ended message by pressing %c\n", f->subclass.integer);
 					res = 't';
 					outmsg = 2;
 					break;
 				}
-				if (strchr(acceptdtmf, f->subclass)) {
-					ast_verb(3, "User ended message by pressing %c\n", f->subclass);
-					res = f->subclass;
+				if (strchr(acceptdtmf, f->subclass.integer)) {
+					ast_verb(3, "User ended message by pressing %c\n", f->subclass.integer);
+					res = f->subclass.integer;
 					outmsg = 2;
 					break;
 				}
-				if (strchr(canceldtmf, f->subclass)) {
-					ast_verb(3, "User cancelled message by pressing %c\n", f->subclass);
-					res = f->subclass;
+				if (strchr(canceldtmf, f->subclass.integer)) {
+					ast_verb(3, "User cancelled message by pressing %c\n", f->subclass.integer);
+					res = f->subclass.integer;
 					outmsg = 0;
 					break;
 				}

Modified: team/tilghman/codec_bits3/main/audiohook.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/main/audiohook.c?view=diff&rev=225764&r1=225763&r2=225764
==============================================================================
--- team/tilghman/codec_bits3/main/audiohook.c (original)
+++ team/tilghman/codec_bits3/main/audiohook.c Sun Oct 25 17:14:07 2009
@@ -40,7 +40,7 @@
 
 struct ast_audiohook_translate {
 	struct ast_trans_pvt *trans_pvt;
-	int format;
+	format_t format;
 };
 
 struct ast_audiohook_list {
@@ -173,7 +173,7 @@
 	short buf[samples];
 	struct ast_frame frame = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_SLINEAR,
+		.subclass.codec = AST_FORMAT_SLINEAR,
 		.data.ptr = buf,
 		.datalen = sizeof(buf),
 		.samples = samples,
@@ -200,7 +200,7 @@
 	short buf1[samples], buf2[samples], *read_buf = NULL, *write_buf = NULL, *final_buf = NULL, *data1 = NULL, *data2 = NULL;
 	struct ast_frame frame = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass = AST_FORMAT_SLINEAR,
+		.subclass.codec = AST_FORMAT_SLINEAR,
 		.data.ptr = NULL,
 		.datalen = sizeof(buf1),
 		.samples = samples,
@@ -292,7 +292,7 @@
  * \param format Format of frame remote side wants back
  * \return Returns frame on success, NULL on failure
  */
-struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, int format)
+struct ast_frame *ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, format_t format)
 {
 	struct ast_frame *read_frame = NULL, *final_frame = NULL;
 
@@ -576,13 +576,13 @@
 	int samples = frame->samples;
 
 	/* If the frame coming in is not signed linear we have to send it through the in_translate path */
-	if (frame->subclass != AST_FORMAT_SLINEAR) {
-		if (in_translate->format != frame->subclass) {
+	if (frame->subclass.codec != AST_FORMAT_SLINEAR) {
+		if (in_translate->format != frame->subclass.codec) {
 			if (in_translate->trans_pvt)
 				ast_translator_free_path(in_translate->trans_pvt);
-			if (!(in_translate->trans_pvt = ast_translator_build_path(AST_FORMAT_SLINEAR, frame->subclass)))
+			if (!(in_translate->trans_pvt = ast_translator_build_path(AST_FORMAT_SLINEAR, frame->subclass.codec)))
 				return frame;
-			in_translate->format = frame->subclass;
+			in_translate->format = frame->subclass.codec;
 		}
 		if (!(middle_frame = ast_translate(in_translate->trans_pvt, frame, 0)))
 			return frame;
@@ -660,16 +660,16 @@
 	/* Now we figure out what to do with our end frame (whether to transcode or not) */
 	if (middle_frame == end_frame) {
 		/* Middle frame was modified and became the end frame... let's see if we need to transcode */
-		if (end_frame->subclass != start_frame->subclass) {
-			if (out_translate->format != start_frame->subclass) {
+		if (end_frame->subclass.codec != start_frame->subclass.codec) {
+			if (out_translate->format != start_frame->subclass.codec) {
 				if (out_translate->trans_pvt)
 					ast_translator_free_path(out_translate->trans_pvt);
-				if (!(out_translate->trans_pvt = ast_translator_build_path(start_frame->subclass, AST_FORMAT_SLINEAR))) {
+				if (!(out_translate->trans_pvt = ast_translator_build_path(start_frame->subclass.codec, AST_FORMAT_SLINEAR))) {
 					/* We can't transcode this... drop our middle frame and return the original */
 					ast_frfree(middle_frame);
 					return start_frame;
 				}
-				out_translate->format = start_frame->subclass;
+				out_translate->format = start_frame->subclass.codec;
 			}
 			/* Transcode from our middle (signed linear) frame to new format of the frame that came in */
 			if (!(end_frame = ast_translate(out_translate->trans_pvt, middle_frame, 0))) {

Modified: team/tilghman/codec_bits3/main/autoservice.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/main/autoservice.c?view=diff&rev=225764&r1=225763&r2=225764
==============================================================================
--- team/tilghman/codec_bits3/main/autoservice.c (original)
+++ team/tilghman/codec_bits3/main/autoservice.c Sun Oct 25 17:14:07 2009
@@ -74,7 +74,7 @@
 {
 	struct ast_frame hangup_frame = {
 		.frametype = AST_FRAME_CONTROL,
-		.subclass = AST_CONTROL_HANGUP,
+		.subclass.integer = AST_CONTROL_HANGUP,
 	};
 
 	for (;;) {

Modified: team/tilghman/codec_bits3/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/main/bridging.c?view=diff&rev=225764&r1=225763&r2=225764
==============================================================================
--- team/tilghman/codec_bits3/main/bridging.c (original)
+++ team/tilghman/codec_bits3/main/bridging.c Sun Oct 25 17:14:07 2009
@@ -250,7 +250,7 @@
 
 	/* See if this DTMF matches the beginnings of any feature hooks, if so we switch to the feature state to either execute the feature or collect more DTMF */
 	AST_LIST_TRAVERSE(&features->hooks, hook, entry) {
-		if (hook->dtmf[0] == frame->subclass) {
+		if (hook->dtmf[0] == frame->subclass.integer) {
 			ast_frfree(frame);
 			frame = NULL;
 			ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_FEATURE);
@@ -285,10 +285,10 @@
 		struct ast_frame *frame = (((bridge->features.mute) || (bridge_channel->features && bridge_channel->features->mute)) ? ast_read_noaudio(chan) : ast_read(chan));
 
 		/* This is pretty simple... see if they hung up */
-		if (!frame || (frame->frametype == AST_FRAME_CONTROL && frame->subclass == AST_CONTROL_HANGUP)) {
+		if (!frame || (frame->frametype == AST_FRAME_CONTROL && frame->subclass.integer == AST_CONTROL_HANGUP)) {
 			/* Signal the thread that is handling the bridged channel that it should be ended */
 			ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
-		} else if (frame->frametype == AST_FRAME_CONTROL && bridge_drop_control_frame(frame->subclass)) {
+		} else if (frame->frametype == AST_FRAME_CONTROL && bridge_drop_control_frame(frame->subclass.integer)) {
 			ast_debug(1, "Dropping control frame from bridge channel %p\n", bridge_channel);
 		} else {
 			if (frame->frametype == AST_FRAME_DTMF_BEGIN) {
@@ -382,13 +382,16 @@
 }
 
 /*! \brief Helper function used to find the "best" bridge technology given a specified capabilities */
-static struct ast_bridge_technology *find_best_technology(int capabilities)
+static struct ast_bridge_technology *find_best_technology(format_t capabilities)
 {
 	struct ast_bridge_technology *current = NULL, *best = NULL;
 
 	AST_RWLIST_RDLOCK(&bridge_technologies);
 	AST_RWLIST_TRAVERSE(&bridge_technologies, current, entry) {
-		ast_debug(1, "Bridge technology %s has capabilities %d and we want %d\n", current->name, current->capabilities, capabilities);
+		char tmp1[256], tmp2[256];
+		ast_debug(1, "Bridge technology %s has capabilities %s and we want %s\n", current->name,
+			ast_getformatname_multiple(tmp1, sizeof(tmp1), current->capabilities),
+			ast_getformatname_multiple(tmp2, sizeof(tmp2), capabilities));
 		if (current->suspended) {
 			ast_debug(1, "Bridge technology %s is suspended. Skipping.\n", current->name);
 			continue;
@@ -445,7 +448,7 @@
 	return;
 }
 
-struct ast_bridge *ast_bridge_new(int capabilities, int flags)
+struct ast_bridge *ast_bridge_new(format_t capabilities, int flags)
 {
 	struct ast_bridge *bridge = NULL;
 	struct ast_bridge_technology *bridge_technology = NULL;
@@ -467,7 +470,9 @@
 
 	/* If no bridge technology was found we can't possibly do bridging so fail creation of the bridge */
 	if (!bridge_technology) {
-		ast_debug(1, "Failed to find a bridge technology to satisfy capabilities %d\n", capabilities);
+		char codec_buf[256];
+		ast_debug(1, "Failed to find a bridge technology to satisfy capabilities %s\n",
+			ast_getformatname_multiple(codec_buf, sizeof(codec_buf), capabilities));
 		return NULL;
 	}
 
@@ -498,7 +503,7 @@
 	return bridge;
 }
 
-int ast_bridge_check(int capabilities)
+int ast_bridge_check(format_t capabilities)
 {
 	struct ast_bridge_technology *bridge_technology = NULL;
 
@@ -537,26 +542,27 @@
 
 static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
 {
-	int formats[2] = {bridge_channel->chan->readformat, bridge_channel->chan->writeformat};
+	format_t formats[2] = {bridge_channel->chan->readformat, bridge_channel->chan->writeformat};
 
 	/* Are the formats currently in use something ths bridge can handle? */
 	if (!(bridge->technology->formats & bridge_channel->chan->readformat)) {
-		int best_format = ast_best_codec(bridge->technology->formats);
+		format_t best_format = ast_best_codec(bridge->technology->formats);
 
 		/* Read format is a no go... */
 		if (option_debug) {
 			char codec_buf[512];
-			ast_getformatname_multiple(codec_buf, sizeof(codec_buf), bridge->technology->formats);
-			ast_debug(1, "Bridge technology %s wants to read any of formats %s(%d) but channel has %s(%d)\n", bridge->technology->name, codec_buf, bridge->technology->formats, ast_getformatname(formats[0]), formats[0]);
+			ast_debug(1, "Bridge technology %s wants to read any of formats %s but channel has %s\n", bridge->technology->name,
+				ast_getformatname_multiple(codec_buf, sizeof(codec_buf), bridge->technology->formats),
+				ast_getformatname(formats[0]));
 		}
 		/* Switch read format to the best one chosen */
 		if (ast_set_read_format(bridge_channel->chan, best_format)) {
-			ast_log(LOG_WARNING, "Failed to set channel %s to read format %s(%d)\n", bridge_channel->chan->name, ast_getformatname(best_format), best_format);
+			ast_log(LOG_WARNING, "Failed to set channel %s to read format %s\n", bridge_channel->chan->name, ast_getformatname(best_format));
 			return -1;
 		}
-		ast_debug(1, "Bridge %p put channel %s into read format %s(%d)\n", bridge, bridge_channel->chan->name, ast_getformatname(best_format), best_format);
+		ast_debug(1, "Bridge %p put channel %s into read format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(best_format));
 	} else {
-		ast_debug(1, "Bridge %p is happy that channel %s already has read format %s(%d)\n", bridge, bridge_channel->chan->name, ast_getformatname(formats[0]), formats[0]);
+		ast_debug(1, "Bridge %p is happy that channel %s already has read format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(formats[0]));
 	}
 
 	if (!(bridge->technology->formats & formats[1])) {
@@ -565,17 +571,18 @@
 		/* Write format is a no go... */
 		if (option_debug) {
 			char codec_buf[512];
-			ast_getformatname_multiple(codec_buf, sizeof(codec_buf), bridge->technology->formats);
-			ast_debug(1, "Bridge technology %s wants to write any of formats %s(%d) but channel has %s(%d)\n", bridge->technology->name, codec_buf, bridge->technology->formats, ast_getformatname(formats[1]), formats[1]);
+			ast_debug(1, "Bridge technology %s wants to write any of formats %s but channel has %s\n", bridge->technology->name,
+				ast_getformatname_multiple(codec_buf, sizeof(codec_buf), bridge->technology->formats),
+				ast_getformatname(formats[1]));
 		}
 		/* Switch write format to the best one chosen */
 		if (ast_set_write_format(bridge_channel->chan, best_format)) {
-			ast_log(LOG_WARNING, "Failed to set channel %s to write format %s(%d)\n", bridge_channel->chan->name, ast_getformatname(best_format), best_format);
+			ast_log(LOG_WARNING, "Failed to set channel %s to write format %s\n", bridge_channel->chan->name, ast_getformatname(best_format));
 			return -1;
 		}
-		ast_debug(1, "Bridge %p put channel %s into write format %s(%d)\n", bridge, bridge_channel->chan->name, ast_getformatname(best_format), best_format);
+		ast_debug(1, "Bridge %p put channel %s into write format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(best_format));
 	} else {
-		ast_debug(1, "Bridge %p is happy that channel %s already has write format %s(%d)\n", bridge, bridge_channel->chan->name, ast_getformatname(formats[1]), formats[1]);
+		ast_debug(1, "Bridge %p is happy that channel %s already has write format %s\n", bridge, bridge_channel->chan->name, ast_getformatname(formats[1]));
 	}
 
 	return 0;
@@ -584,7 +591,7 @@
 /*! \brief Perform the smart bridge operation. Basically sees if a new bridge technology should be used instead of the current one. */
 static int smart_bridge_operation(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int count)
 {
-	int new_capabilities = 0;
+	format_t new_capabilities = 0;
 	struct ast_bridge_technology *new_technology = NULL, *old_technology = bridge->technology;
 	struct ast_bridge temp_bridge = {
 		.technology = bridge->technology,
@@ -614,7 +621,9 @@
 
 	/* Attempt to find a new bridge technology to satisfy the capabilities */
 	if (!(new_technology = find_best_technology(new_capabilities))) {
-		ast_debug(1, "Smart bridge operation was unable to find new bridge technology with capabilities %d to satisfy bridge %p\n", new_capabilities, bridge);
+		char codec_buf[256];
+		ast_debug(1, "Smart bridge operation was unable to find new bridge technology with capabilities %s to satisfy bridge %p\n",
+			ast_getformatname_multiple(codec_buf, sizeof(codec_buf), new_capabilities), bridge);
 		return -1;
 	}
 

Modified: team/tilghman/codec_bits3/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/main/channel.c?view=diff&rev=225764&r1=225763&r2=225764
==============================================================================
--- team/tilghman/codec_bits3/main/channel.c (original)
+++ team/tilghman/codec_bits3/main/channel.c Sun Oct 25 17:14:07 2009
@@ -280,6 +280,7 @@
 static char *handle_cli_core_show_channeltype(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct chanlist *cl = NULL;
+	char buf[512];
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -314,7 +315,7 @@
 		"  Device State: %s\n"
 		"    Indication: %s\n"
 		"     Transfer : %s\n"
-		"  Capabilities: %d\n"
+		"  Capabilities: %s\n"
 		"   Digit Begin: %s\n"
 		"     Digit End: %s\n"
 		"    Send HTML : %s\n"
@@ -324,7 +325,7 @@
 		(cl->tech->devicestate) ? "yes" : "no",
 		(cl->tech->indicate) ? "yes" : "no",
 		(cl->tech->transfer) ? "yes" : "no",
-		(cl->tech->capabilities) ? cl->tech->capabilities : -1,
+		ast_getformatname_multiple(buf, sizeof(buf), (cl->tech->capabilities) ? cl->tech->capabilities : -1),
 		(cl->tech->send_digit_begin) ? "yes" : "no",
 		(cl->tech->send_digit_end) ? "yes" : "no",
 		(cl->tech->send_html) ? "yes" : "no",
@@ -719,7 +720,7 @@
 }
 
 /*! \brief Pick the best audio codec */
-int ast_best_codec(int fmts)
+format_t ast_best_codec(format_t fmts)
 {
 	/* This just our opinion, expressed in code.  We are asked to choose
 	   the best codec to use, given no information */
@@ -758,6 +759,7 @@
 		/*! Down to G.723.1 which is proprietary but at least designed for voice */
 		AST_FORMAT_G723_1,
 	};
+	char buf[512];
 
 	/* Strip out video */
 	fmts &= AST_FORMAT_AUDIO_MASK;
@@ -768,7 +770,7 @@
 			return prefs[x];
 	}
 
-	ast_log(LOG_WARNING, "Don't know any of 0x%x formats\n", fmts);
+	ast_log(LOG_WARNING, "Don't know any of %s formats\n", ast_getformatname_multiple(buf, sizeof(buf), fmts));
 
 	return 0;
 }
@@ -1071,7 +1073,7 @@
 	/* See if the last frame on the queue is a hangup, if so don't queue anything */
 	if ((cur = AST_LIST_LAST(&chan->readq)) &&
 	    (cur->frametype == AST_FRAME_CONTROL) &&
-	    (cur->subclass == AST_CONTROL_HANGUP)) {
+	    (cur->subclass.integer == AST_CONTROL_HANGUP)) {
 		ast_channel_unlock(chan);
 		return 0;
 	}
@@ -1156,7 +1158,7 @@
 /*! \brief Queue a hangup frame for channel */
 int ast_queue_hangup(struct ast_channel *chan)
 {
-	struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
+	struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
 	/* Yeah, let's not change a lock-critical value without locking */
 	if (!ast_channel_trylock(chan)) {
 		chan->_softhangup |= AST_SOFTHANGUP_DEV;
@@ -1168,7 +1170,7 @@
 /*! \brief Queue a hangup frame for channel */
 int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
 {
-	struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
+	struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP };
 
 	if (cause >= 0)
 		f.data.uint32 = cause;
@@ -1188,10 +1190,7 @@
 /*! \brief Queue a control frame */
 int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
 {
-	struct ast_frame f = { AST_FRAME_CONTROL, };
-
-	f.subclass = control;
-
+	struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control };
 	return ast_queue_frame(chan, &f);
 }
 
@@ -1199,12 +1198,7 @@
 int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control,
 			   const void *data, size_t datalen)
 {
-	struct ast_frame f = { AST_FRAME_CONTROL, };
-
-	f.subclass = control;
-	f.data.ptr = (void *) data;
-	f.datalen = datalen;
-
+	struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control, .data.ptr = (void *) data, .datalen = datalen };
 	return ast_queue_frame(chan, &f);
 }
 
@@ -2348,7 +2342,7 @@
 				}
 				cur = ast_read(chan);
 				if (!cur || ((cur->frametype == AST_FRAME_CONTROL) &&
-					     (cur->subclass == AST_CONTROL_HANGUP))) {
+					     (cur->subclass.integer == AST_CONTROL_HANGUP))) {
 					if (cur) {
 						ast_frfree(cur);
 					}
@@ -2937,12 +2931,12 @@
 			case AST_FRAME_DTMF_BEGIN:
 				break;
 			case AST_FRAME_DTMF_END:
-				res = f->subclass;
+				res = f->subclass.integer;
 				ast_frfree(f);
 				ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
 				return res;
 			case AST_FRAME_CONTROL:
-				switch (f->subclass) {
+				switch (f->subclass.integer) {
 				case AST_CONTROL_HANGUP:
 					ast_frfree(f);
 					ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY);
@@ -2955,7 +2949,7 @@
 					/* Unimportant */
 					break;
 				default:
-					ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass);
+					ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass.integer);
 					break;
 				}
 				break;
@@ -3007,9 +3001,9 @@
 
 		chan->generatordata = NULL;     /* reset, to let writes go through */
 
-		if (f->subclass != chan->writeformat) {
+		if (f->subclass.codec != chan->writeformat) {
 			float factor;
-			factor = ((float) ast_format_rate(chan->writeformat)) / ((float) ast_format_rate(f->subclass));
+			factor = ((float) ast_format_rate(chan->writeformat)) / ((float) ast_format_rate(f->subclass.codec));
 			samples = (int) ( ((float) f->samples) * factor );
 		} else {
 			samples = f->samples;
@@ -3045,7 +3039,7 @@
 	struct ast_frame *fr = &chan->dtmff;
 
 	fr->frametype = AST_FRAME_DTMF_END;
-	fr->subclass = f->subclass;
+	fr->subclass.integer = f->subclass.integer;
 	fr->len = f->len;
 
 	/* The only time this function will be called is for a frame that just came
@@ -3222,7 +3216,7 @@
 
 		/* Interpret hangup and return NULL */
 		/* XXX why not the same for frames from the channel ? */
-		if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) {
+		if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP) {
 			cause = f->data.uint32;
 			ast_frfree(f);
 			f = NULL;
@@ -3264,7 +3258,7 @@
 
 		switch (f->frametype) {
 		case AST_FRAME_CONTROL:
-			if (f->subclass == AST_CONTROL_ANSWER) {
+			if (f->subclass.integer == AST_CONTROL_ANSWER) {
 				if (!ast_test_flag(chan, AST_FLAG_OUTGOING)) {
 					ast_debug(1, "Ignoring answer on an inbound call!\n");
 					ast_frfree(f);
@@ -3282,8 +3276,8 @@
 			}
 			break;
 		case AST_FRAME_DTMF_END:
-			send_dtmf_event(chan, "Received", f->subclass, "No", "Yes");
-			ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass, chan->name, f->len);
+			send_dtmf_event(chan, "Received", f->subclass.integer, "No", "Yes");
+			ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass.integer, chan->name, f->len);
 			/* Queue it up if DTMF is deferred, or if DTMF emulation is forced. */
 			if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF) || ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) {
 				queue_dtmf_readq(chan, f);
@@ -3300,7 +3294,7 @@
 					/* There was no begin, turn this into a begin and send the end later */
 					f->frametype = AST_FRAME_DTMF_BEGIN;
 					ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
-					chan->emulate_dtmf_digit = f->subclass;
+					chan->emulate_dtmf_digit = f->subclass.integer;
 					chan->dtmf_tv = ast_tvnow();
 					if (f->len) {
 						if (f->len > AST_MIN_DTMF_DURATION)
@@ -3309,7 +3303,7 @@
 							chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION;
 					} else
 						chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
-					ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass, chan->emulate_dtmf_duration, chan->name);
+					ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, chan->emulate_dtmf_duration, chan->name);
 				}
 				if (chan->audiohooks) {
 					struct ast_frame *old_frame = f;
@@ -3323,23 +3317,23 @@
 			} else {
 				struct timeval now = ast_tvnow();
 				if (ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
-					ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass, chan->name);
+					ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass.integer, chan->name);
 					ast_clear_flag(chan, AST_FLAG_IN_DTMF);
 					if (!f->len)
 						f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
 				} else if (!f->len) {
-					ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass, chan->name);
+					ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass.integer, chan->name);
 					f->len = AST_MIN_DTMF_DURATION;
 				}
 				if (f->len < AST_MIN_DTMF_DURATION && !ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)) {
-					ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass, f->len, AST_MIN_DTMF_DURATION, chan->name);
+					ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass.integer, f->len, AST_MIN_DTMF_DURATION, chan->name);
 					ast_set_flag(chan, AST_FLAG_EMULATE_DTMF);
-					chan->emulate_dtmf_digit = f->subclass;
+					chan->emulate_dtmf_digit = f->subclass.integer;
 					chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION - f->len;
 					ast_frfree(f);
 					f = &ast_null_frame;
 				} else {
-					ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass, chan->name);
+					ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass.integer, chan->name);
 					if (f->len < AST_MIN_DTMF_DURATION) {
 						f->len = AST_MIN_DTMF_DURATION;
 					}
@@ -3354,18 +3348,18 @@
 			}
 			break;
 		case AST_FRAME_DTMF_BEGIN:
-			send_dtmf_event(chan, "Received", f->subclass, "Yes", "No");
-			ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass, chan->name);
+			send_dtmf_event(chan, "Received", f->subclass.integer, "Yes", "No");
+			ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass.integer, chan->name);
 			if ( ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_END_DTMF_ONLY | AST_FLAG_EMULATE_DTMF) || 
 			    (!ast_tvzero(chan->dtmf_tv) && 
 			      ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) ) {
-				ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass, chan->name);
+				ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass.integer, chan->name);
 				ast_frfree(f);
 				f = &ast_null_frame;
 			} else {
 				ast_set_flag(chan, AST_FLAG_IN_DTMF);
 				chan->dtmf_tv = ast_tvnow();
-				ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass, chan->name);
+				ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass.integer, chan->name);
 			}
 			break;
 		case AST_FRAME_NULL:
@@ -3383,12 +3377,12 @@
 					ast_frfree(f);
 					f = &chan->dtmff;
 					f->frametype = AST_FRAME_DTMF_END;
-					f->subclass = chan->emulate_dtmf_digit;
+					f->subclass.integer = chan->emulate_dtmf_digit;
 					f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
 					chan->dtmf_tv = now;
 					ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF);
 					chan->emulate_dtmf_digit = 0;
-					ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass, chan->name);
+					ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name);
 					if (chan->audiohooks) {
 						struct ast_frame *old_frame = f;
 						f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
@@ -3423,7 +3417,7 @@
 					ast_frfree(f);
 					f = &chan->dtmff;
 					f->frametype = AST_FRAME_DTMF_END;
-					f->subclass = chan->emulate_dtmf_digit;
+					f->subclass.integer = chan->emulate_dtmf_digit;
 					f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
 					chan->dtmf_tv = now;
 					if (chan->audiohooks) {
@@ -3432,17 +3426,17 @@
 						if (old_frame != f)
 							ast_frfree(old_frame);
 					}
-					ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass, chan->name);
+					ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name);
 				} else {
 					/* Drop voice frames while we're still in the middle of the digit */
 					ast_frfree(f);
 					f = &ast_null_frame;
 				}
-			} else if ((f->frametype == AST_FRAME_VOICE) && !(f->subclass & chan->nativeformats)) {
+			} else if ((f->frametype == AST_FRAME_VOICE) && !(f->subclass.codec & chan->nativeformats)) {
 				/* This frame is not one of the current native formats -- drop it on the floor */
 				char to[200];
 				ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n",
-					chan->name, ast_getformatname(f->subclass), ast_getformatname_multiple(to, sizeof(to), chan->nativeformats));
+					chan->name, ast_getformatname(f->subclass.codec), ast_getformatname_multiple(to, sizeof(to), chan->nativeformats));
 				ast_frfree(f);
 				f = &ast_null_frame;
 			} else if ((f->frametype == AST_FRAME_VOICE)) {
@@ -3525,7 +3519,7 @@
 
 done:
 	if (chan->music_state && chan->generator && chan->generator->digit && f && f->frametype == AST_FRAME_DTMF_END)
-		chan->generator->digit(chan, f->subclass);

[... 1370 lines stripped ...]



More information about the asterisk-commits mailing list