dect
/
asterisk
Archived
13
0
Fork 0

More 32->64 bit codec conversions.

In the process of swapping ULAW to a place in the extended codec space, we
found several unhandled cases, where a 32-bit integer was still being used to
handle a codec field.  Most of these have been fixed with this commit, although
there is at least one case (codec_dahdi) which depends upon outside headers to
be altered before a conversion can be made.
(Fixes AST-278, SWP-459)


git-svn-id: http://svn.digium.com/svn/asterisk/trunk@231850 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
tilghman 2009-12-01 20:27:37 +00:00
parent f925470a1b
commit f4d89e410a
16 changed files with 57 additions and 52 deletions

View File

@ -169,9 +169,9 @@ static struct ooh323_pvt {
char callee_url[AST_MAX_EXTENSION];
int port;
int readformat; /* negotiated read format */
int writeformat; /* negotiated write format */
int capability;
format_t readformat; /* negotiated read format */
format_t writeformat; /* negotiated write format */
format_t capability;
struct ast_codec_pref prefs;
int dtmfmode;
int dtmfcodec;
@ -3673,7 +3673,7 @@ int ooh323_update_capPrefsOrderForCall
}
int ooh323_convertAsteriskCapToH323Cap(int cap)
int ooh323_convertAsteriskCapToH323Cap(format_t cap)
{
char formats[FORMAT_STRING_SIZE];
switch (cap) {
@ -3744,7 +3744,8 @@ int configure_local_rtp(struct ooh323_pvt *p, ooCallData *call)
{
struct sockaddr_in us;
ooMediaInfo mediaInfo;
int x, format = 0;
int x;
format_t format = 0;
if (gH323Debug)
ast_verbose("--- configure_local_rtp\n");

View File

@ -60,7 +60,7 @@
#include <asterisk/manager.h>
#include <asterisk/dsp.h>
#include <asterisk/stringfields.h>
#include <asterisk/frame_defs.h>
#include <asterisk/udptl.h>
#include "ootypes.h"
@ -104,7 +104,7 @@ void ooh323_set_read_format(ooCallData *call, int fmt);
int ooh323_update_capPrefsOrderForCall
(ooCallData *call, struct ast_codec_pref *prefs);
int ooh323_convertAsteriskCapToH323Cap(int cap);
int ooh323_convertAsteriskCapToH323Cap(format_t cap);
int ooh323_convert_hangupcause_asteriskToH323(int cause);
int ooh323_convert_hangupcause_h323ToAsterisk(int cause);

View File

@ -594,7 +594,7 @@ int ooh323c_set_aliases(ooAliases * aliases)
int ooh323c_start_receive_channel(ooCallData *call, ooLogicalChannel *pChannel)
{
int fmt=-1;
format_t fmt=-1;
fmt = convertH323CapToAsteriskCap(pChannel->chanCap->cap);
if(fmt>0) {
/* ooh323_set_read_format(call, fmt); */
@ -608,7 +608,7 @@ int ooh323c_start_receive_channel(ooCallData *call, ooLogicalChannel *pChannel)
int ooh323c_start_transmit_channel(ooCallData *call, ooLogicalChannel *pChannel)
{
int fmt=-1;
format_t fmt;
fmt = convertH323CapToAsteriskCap(pChannel->chanCap->cap);
if(fmt>0) {
switch (fmt) {
@ -665,7 +665,7 @@ int ooh323c_stop_transmit_datachannel(ooCallData *call, ooLogicalChannel *pChann
return 1;
}
int convertH323CapToAsteriskCap(int cap)
format_t convertH323CapToAsteriskCap(int cap)
{
switch(cap)

View File

@ -22,6 +22,7 @@
#include "ooCalls.h"
#include "ooCapability.h"
#include "ooStackCmds.h"
#include <asterisk/frame_defs.h>
#define H323_DTMF_RFC2833 (1 << 0)
#define H323_DTMF_Q931 (1 << 1)
#define H323_DTMF_H245ALPHANUMERIC (1 << 2)
@ -37,7 +38,7 @@ int ooh323c_start_call_thread(ooCallData *call);
int ooh323c_stop_call_thread(ooCallData *call);
int ooh323c_set_capability
(struct ast_codec_pref *prefs, int capability, int dtmf, int dtmfcodec);
int convertH323CapToAsteriskCap(int cap);
format_t convertH323CapToAsteriskCap(int cap);
int ooh323c_set_capability_for_call
(ooCallData *call, struct ast_codec_pref *prefs, int capability, int dtmf, int dtmfcodec,
int t38support);

View File

@ -8527,7 +8527,7 @@ static int dahdi_indicate(struct ast_channel *chan, int condition, const void *d
static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, int transfercapability, const char *linkedid)
{
struct ast_channel *tmp;
int deflaw;
format_t deflaw;
int res;
int x,y;
int features;
@ -9909,7 +9909,7 @@ struct mwi_thread_data {
size_t len;
};
static int calc_energy(const unsigned char *buf, int len, int law)
static int calc_energy(const unsigned char *buf, int len, format_t law)
{
int x;
int sum = 0;

View File

@ -3154,7 +3154,7 @@ static enum ast_rtp_glue_result oh323_get_rtp_peer(struct ast_channel *chan, str
return res;
}
static char *convertcap(int cap)
static char *convertcap(format_t cap)
{
switch (cap) {
case AST_FORMAT_G723_1:
@ -3176,7 +3176,7 @@ static char *convertcap(int cap)
case AST_FORMAT_ILBC:
return "ILBC";
default:
ast_log(LOG_NOTICE, "Don't know how to deal with mode %d\n", cap);
ast_log(LOG_NOTICE, "Don't know how to deal with mode %" PRId64 "\n", cap);
return NULL;
}
}

View File

@ -94,7 +94,7 @@ static int echocancel = AEC_OFF;
static int silencesupression = 0;
static int prefformat = AST_FORMAT_G729A | AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW;
static format_t prefformat = AST_FORMAT_G729A | AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW;
/* Protect the interface list (of phone_pvt's) */
AST_MUTEX_DEFINE_STATIC(iflock);

View File

@ -212,6 +212,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <signal.h>
#include <sys/signal.h>
#include <regex.h>
#include <inttypes.h>
#include "asterisk/network.h"
#include "asterisk/paths.h" /* need ast_config_AST_SYSTEM_NAME */
@ -10353,7 +10354,7 @@ static void add_codec_to_sdp(const struct sip_pvt *p, format_t codec,
if (debug)
ast_verbose("Adding codec 0x%Lx (%s) to SDP\n", (long long) codec, ast_getformatname(codec));
ast_verbose("Adding codec 0x%" PRIx64 " (%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;
@ -10401,7 +10402,7 @@ static void add_codec_to_sdp(const struct sip_pvt *p, format_t codec,
/*! \brief Add video codec offer to SDP offer/answer body in INVITE or 200 OK */
/* This is different to the audio one now so we can add more caps later */
static void add_vcodec_to_sdp(const struct sip_pvt *p, int codec,
static void add_vcodec_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)
{
@ -10411,7 +10412,7 @@ static void add_vcodec_to_sdp(const struct sip_pvt *p, int codec,
return;
if (debug)
ast_verbose("Adding video codec 0x%x (%s) to SDP\n", codec, ast_getformatname(codec));
ast_verbose("Adding video codec 0x%" PRIx64 " (%s) to SDP\n", codec, ast_getformatname(codec));
if ((rtp_code = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(p->vrtp), 1, codec)) == -1)
return;
@ -10726,7 +10727,7 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p, int
}
/* Now send any other common audio and video codecs, and non-codec formats: */
for (x = 1LL; x <= (needtext ? AST_FORMAT_TEXT_MASK : (needvideo ? AST_FORMAT_VIDEO_MASK : AST_FORMAT_AUDIO_MASK)); x <<= 1) {
for (x = 1ULL; x <= (needtext ? AST_FORMAT_TEXT_MASK : (needvideo ? AST_FORMAT_VIDEO_MASK : AST_FORMAT_AUDIO_MASK)); x <<= 1) {
if (!(capability & x)) /* Codec not requested */
continue;

View File

@ -1715,7 +1715,7 @@ static struct skinny_speeddial *find_speeddial_by_instance(struct skinny_device
return sd;
}
static int codec_skinny2ast(enum skinny_codecs skinnycodec)
static format_t codec_skinny2ast(enum skinny_codecs skinnycodec)
{
switch (skinnycodec) {
case SKINNY_CODEC_ALAW:
@ -1737,7 +1737,7 @@ static int codec_skinny2ast(enum skinny_codecs skinnycodec)
}
}
static int codec_ast2skinny(int astcodec)
static int codec_ast2skinny(format_t astcodec)
{
switch (astcodec) {
case AST_FORMAT_ALAW:
@ -5307,7 +5307,7 @@ static int handle_capabilities_res_message(struct skinny_req *req, struct skinny
struct skinny_device *d = s->device;
struct skinny_line *l;
uint32_t count = 0;
int codecs = 0;
format_t codecs = 0;
int i;
char buf[256];
@ -5318,12 +5318,12 @@ static int handle_capabilities_res_message(struct skinny_req *req, struct skinny
}
for (i = 0; i < count; i++) {
int acodec = 0;
format_t acodec = 0;
int scodec = 0;
scodec = letohl(req->data.caps.caps[i].codec);
acodec = codec_skinny2ast(scodec);
if (skinnydebug)
ast_verb(1, "Adding codec capability '%d (%d)'\n", acodec, scodec);
ast_verb(1, "Adding codec capability '%" PRId64 " (%d)'\n", acodec, scodec);
codecs |= acodec;
}

View File

@ -407,7 +407,7 @@ struct unistim_line {
/*! AMA flags (for billing) */
int amaflags;
/*! Codec supported */
int capability;
format_t capability;
/*! Parkinglot */
char parkinglot[AST_MAX_CONTEXT];
struct unistim_line *next;
@ -4710,7 +4710,7 @@ static char *unistim_info(struct ast_cli_entry *e, int cmd, struct ast_cli_args
line = device->lines;
while (line) {
ast_cli(a->fd,
"->name=%s fullname=%s exten=%s callid=%s cap=%d device=%p line=%p\n",
"->name=%s fullname=%s exten=%s callid=%s cap=%" PRId64 " device=%p line=%p\n",
line->name, line->fullname, line->exten, line->cid_num,
line->capability, line->parent, line);
for (i = 0; i < MAX_SUBS; i++) {

View File

@ -45,6 +45,8 @@
#ifndef _ASTERISK_CALLERID_H
#define _ASTERISK_CALLERID_H
#include "asterisk/frame_defs.h"
#define MAX_CALLERID_SIZE 32000
#define CID_PRIVATE_NAME (1 << 0)
@ -99,7 +101,7 @@ void callerid_init(void);
* \return It returns the size
* (in bytes) of the data (if it returns a size of 0, there is probably an error)
*/
int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, int codec);
int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, format_t codec);
/*! \brief Create a callerID state machine
* \param cid_signalling Type of signalling in use
@ -122,7 +124,7 @@ struct callerid_state *callerid_new(int cid_signalling);
* \retval 0 for "needs more samples"
* \retval 1 if the CallerID spill reception is complete.
*/
int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int samples, int codec);
int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int samples, format_t codec);
/*! \brief Read samples into the state machine.
* \param cid Which state machine to act upon
@ -136,7 +138,7 @@ int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int samples,
* \retval 0 for "needs more samples"
* \retval 1 if the CallerID spill reception is complete.
*/
int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int samples, int codec);
int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int samples, format_t codec);
/*! \brief Extract info out of callerID state machine. Flags are listed above
* \param cid Callerid state machine to act upon
@ -175,7 +177,7 @@ void callerid_free(struct callerid_state *cid);
* \details
* Acts like callerid_generate except uses an asterisk format callerid string.
*/
int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, int codec);
int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, format_t codec);
/*!
* \brief Generate message waiting indicator
@ -185,13 +187,13 @@ int ast_callerid_generate(unsigned char *buf, const char *name, const char *numb
* \see callerid_generate() for more info as it uses the same encoding
* \version 1.6.1 changed mdmf parameter to type, added name, number and flags for caller id message generation
*/
int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, int codec, const char *name,
int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, format_t codec, const char *name,
const char *number, int flags);
/*! \brief Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm)
* \see ast_callerid_generate() for other details
*/
int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, int codec);
int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, format_t codec);
/*! \brief Destructively parse inbuf into name and location (or number)
* \details
@ -216,7 +218,7 @@ int ast_callerid_parse(char *instr, char **name, char **location);
* \param codec Which codec (AST_FORMAT_ALAW or AST_FORMAT_ULAW)
* \return Returns -1 on error (if len is less than 2400), 0 on success.
*/
int ast_gen_cas(unsigned char *outbuf, int sas, int len, int codec);
int ast_gen_cas(unsigned char *outbuf, int sas, int len, format_t codec);
/*!
* \brief Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...

View File

@ -364,7 +364,7 @@ struct ast_rtp_engine {
/*! Callback to request that the RTP engine send a STUN BIND request */
void (*stun_request)(struct ast_rtp_instance *instance, struct sockaddr_in *suggestion, const char *username);
/*! Callback to get the transcodeable formats supported */
int (*available_formats)(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk);
int (*available_formats)(struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk);
/*! Linked list information */
AST_RWLIST_ENTRY(ast_rtp_engine) entry;
};
@ -1527,7 +1527,7 @@ int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_in
*
* \since 1.6.3
*/
format_t ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk);
format_t ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk);
/*!
* \brief Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance

View File

@ -71,7 +71,7 @@ float casdr1, casdi1, casdr2, casdi2;
#define AST_CALLERID_UNKNOWN "<unknown>"
static inline void gen_tones(unsigned char *buf, int len, int codec, float ddr1, float ddi1, float ddr2, float ddi2, float *cr1, float *ci1, float *cr2, float *ci2)
static inline void gen_tones(unsigned char *buf, int len, format_t codec, float ddr1, float ddi1, float ddr2, float ddi2, float *cr1, float *ci1, float *cr2, float *ci2)
{
int x;
float t;
@ -93,7 +93,7 @@ static inline void gen_tones(unsigned char *buf, int len, int codec, float ddr1,
}
}
static inline void gen_tone(unsigned char *buf, int len, int codec, float ddr1, float ddi1, float *cr1, float *ci1)
static inline void gen_tone(unsigned char *buf, int len, format_t codec, float ddr1, float ddi1, float *cr1, float *ci1)
{
int x;
float t;
@ -255,7 +255,7 @@ void callerid_get_dtmf(char *cidstring, char *number, int *flags)
}
}
int ast_gen_cas(unsigned char *outbuf, int sendsas, int len, int codec)
int ast_gen_cas(unsigned char *outbuf, int sendsas, int len, format_t codec)
{
int pos = 0;
int saslen = 2400;
@ -300,7 +300,7 @@ static unsigned short calc_crc(unsigned short crc, unsigned char data)
return crc;
}
int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, int codec)
int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, format_t codec)
{
int mylen = len;
int olen;
@ -539,7 +539,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i
}
int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int len, int codec)
int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int len, format_t codec)
{
int mylen = len;
int olen;
@ -791,7 +791,7 @@ static int callerid_genmsg(char *msg, int size, const char *number, const char *
}
int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, int codec,
int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, format_t codec,
const char* name, const char* number, int flags)
{
char msg[256];
@ -879,7 +879,7 @@ int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, int cod
return bytes;
}
int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, int codec)
int callerid_generate(unsigned char *buf, const char *number, const char *name, int flags, int callwaiting, format_t codec)
{
int bytes = 0;
int x, sum;
@ -1036,7 +1036,7 @@ int ast_callerid_parse(char *instr, char **name, char **location)
return 0;
}
static int __ast_callerid_generate(unsigned char *buf, const char *name, const char *number, int callwaiting, int codec)
static int __ast_callerid_generate(unsigned char *buf, const char *name, const char *number, int callwaiting, format_t codec)
{
if (ast_strlen_zero(name))
name = NULL;
@ -1045,12 +1045,12 @@ static int __ast_callerid_generate(unsigned char *buf, const char *name, const c
return callerid_generate(buf, number, name, 0, callwaiting, codec);
}
int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, int codec)
int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, format_t codec)
{
return __ast_callerid_generate(buf, name, number, 0, codec);
}
int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, int codec)
int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, format_t codec)
{
return __ast_callerid_generate(buf, name, number, 1, codec);
}

View File

@ -1585,7 +1585,7 @@ int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_in
return res;
}
format_t ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, int to_endpoint, int to_asterisk)
format_t ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk)
{
format_t formats;

View File

@ -67,7 +67,7 @@ static char speeddial[ADSI_MAX_SPEED_DIAL][3][SPEEDDIAL_MAX_LEN];
static int alignment = 0;
static int adsi_generate(unsigned char *buf, int msgtype, unsigned char *msg, int msglen, int msgnum, int last, int codec)
static int adsi_generate(unsigned char *buf, int msgtype, unsigned char *msg, int msglen, int msgnum, int last, format_t codec)
{
int sum, x, bytes = 0;
/* Initial carrier (imaginary) */

View File

@ -131,8 +131,8 @@ struct ast_rtp {
unsigned int cycles; /*!< Shifted count of sequence number cycles */
double rxjitter; /*!< Interarrival jitter at the moment */
double rxtransit; /*!< Relative transit time for previous packet */
int lasttxformat;
int lastrxformat;
format_t lasttxformat;
format_t lastrxformat;
int rtptimeout; /*!< RTP timeout time (negative or zero means disabled, negative value means temporarily disabled) */
int rtpholdtimeout; /*!< RTP timeout when on hold (negative or zero means disabled, negative value means temporarily disabled). */
@ -1137,7 +1137,7 @@ static int ast_rtp_write(struct ast_rtp_instance *instance, struct ast_frame *fr
/* Grab the subclass and look up the payload we are going to use */
subclass = frame->subclass.codec;
if (frame->frametype == AST_FRAME_VIDEO) {
subclass &= ~0x1;
subclass &= ~0x1LL;
}
if ((codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 1, subclass)) < 0) {
ast_log(LOG_WARNING, "Don't know how to send format %s packets with RTP\n", ast_getformatname(frame->subclass.codec));
@ -1503,7 +1503,7 @@ static struct ast_frame *process_cn_rfc3389(struct ast_rtp_instance *instance, u
totally help us out becuase we don't have an engine to keep it going and we are not
guaranteed to have it every 20ms or anything */
if (rtpdebug)
ast_debug(0, "- RTP 3389 Comfort noise event: Level %d (len = %d)\n", rtp->lastrxformat, len);
ast_debug(0, "- RTP 3389 Comfort noise event: Level %" PRId64 " (len = %d)\n", rtp->lastrxformat, len);
if (ast_test_flag(rtp, FLAG_3389_WARNING)) {
struct sockaddr_in remote_address = { 0, };