From 3bacd4082e2d3a2dd5b8b13635df956aa4f415cd Mon Sep 17 00:00:00 2001 From: tilghman Date: Wed, 4 Nov 2009 14:05:12 +0000 Subject: Expand codec bitfield from 32 bits to 64 bits. Reviewboard: https://reviewboard.asterisk.org/r/416/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@227580 f38db490-d61c-443f-a65b-d21fe96a405b --- main/abstract_jb.c | 6 +- main/app.c | 16 ++-- main/asterisk.exports | 2 + main/audiohook.c | 24 +++--- main/autoservice.c | 2 +- main/bridging.c | 53 +++++++------ main/channel.c | 203 +++++++++++++++++++++++++------------------------- main/dial.c | 4 +- main/dsp.c | 21 +++--- main/features.c | 34 ++++----- main/file.c | 26 +++---- main/frame.c | 153 +++++++++++++++++++------------------ main/indications.c | 2 +- main/manager.c | 8 +- main/pbx.c | 8 +- main/rtp_engine.c | 103 ++++++++++++------------- main/slinfactory.c | 10 +-- main/strcompat.c | 52 +++++++++++++ main/translate.c | 73 ++++++++++-------- main/udptl.c | 8 +- 20 files changed, 446 insertions(+), 362 deletions(-) (limited to 'main') diff --git a/main/abstract_jb.c b/main/abstract_jb.c index cda9a6dca..7ebbb628b 100644 --- a/main/abstract_jb.c +++ b/main/abstract_jb.c @@ -409,14 +409,14 @@ static void jb_get_and_deliver(struct ast_channel *chan) 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 @@ static int create_jb(struct ast_channel *chan, struct ast_frame *frr) 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)) { diff --git a/main/app.c b/main/app.c index e33fb03ab..881f99dad 100644 --- a/main/app.c +++ b/main/app.c @@ -429,7 +429,7 @@ static int linear_generator(struct ast_channel *chan, void *data, int len, int s 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 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, } 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; } diff --git a/main/asterisk.exports b/main/asterisk.exports index 2a26061b2..284bf36f2 100644 --- a/main/asterisk.exports +++ b/main/asterisk.exports @@ -38,6 +38,8 @@ asprintf; strtoq; getloadavg; + ntohll; + htonll; local: *; }; diff --git a/main/audiohook.c b/main/audiohook.c index 950b0eb2d..19de2be02 100644 --- a/main/audiohook.c +++ b/main/audiohook.c @@ -40,7 +40,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") struct ast_audiohook_translate { struct ast_trans_pvt *trans_pvt; - int format; + format_t format; }; struct ast_audiohook_list { @@ -173,7 +173,7 @@ static struct ast_frame *audiohook_read_frame_single(struct ast_audiohook *audio 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 @@ static struct ast_frame *audiohook_read_frame_both(struct ast_audiohook *audioho 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 @@ static struct ast_frame *audiohook_read_frame_both(struct ast_audiohook *audioho * \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 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st 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 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st /* 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))) { diff --git a/main/autoservice.c b/main/autoservice.c index 4e1cd5203..8e3465417 100644 --- a/main/autoservice.c +++ b/main/autoservice.c @@ -74,7 +74,7 @@ static void *autoservice_run(void *ign) { struct ast_frame hangup_frame = { .frametype = AST_FRAME_CONTROL, - .subclass = AST_CONTROL_HANGUP, + .subclass.integer = AST_CONTROL_HANGUP, }; for (;;) { diff --git a/main/bridging.c b/main/bridging.c index 2f5afa2cb..6c2a66804 100644 --- a/main/bridging.c +++ b/main/bridging.c @@ -250,7 +250,7 @@ static struct ast_frame *bridge_handle_dtmf(struct ast_bridge *bridge, struct as /* 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 @@ void ast_bridge_handle_trip(struct ast_bridge *bridge, struct ast_bridge_channel 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 @@ static void *bridge_thread(void *data) } /*! \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 @@ static void destroy_bridge(void *obj) 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 @@ struct ast_bridge *ast_bridge_new(int capabilities, int flags) /* 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 @@ struct ast_bridge *ast_bridge_new(int capabilities, int flags) 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 @@ int ast_bridge_destroy(struct ast_bridge *bridge) 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 @@ static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_c /* 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 @@ static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_c /*! \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 @@ static int smart_bridge_operation(struct ast_bridge *bridge, struct ast_bridge_c /* 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; } diff --git a/main/channel.c b/main/channel.c index 946288ebf..ce74b3f26 100644 --- a/main/channel.c +++ b/main/channel.c @@ -280,6 +280,7 @@ static char *complete_channeltypes(struct ast_cli_args *a) 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 @@ static char *handle_cli_core_show_channeltype(struct ast_cli_entry *e, int cmd, " 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 @@ static char *handle_cli_core_show_channeltype(struct ast_cli_entry *e, int cmd, (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,12 +720,12 @@ char *ast_transfercapability2str(int transfercapability) } /*! \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 */ int x; - static const int prefs[] = + static const format_t prefs[] = { /*! Okay, ulaw is used by all telephony equipment, so start with it */ AST_FORMAT_ULAW, @@ -732,6 +733,7 @@ int ast_best_codec(int fmts) AST_FORMAT_ALAW, AST_FORMAT_SIREN14, AST_FORMAT_SIREN7, + AST_FORMAT_TESTLAW, /*! G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority */ AST_FORMAT_G722, /*! Okay, well, signed linear is easy to translate into other stuff */ @@ -758,6 +760,7 @@ int ast_best_codec(int fmts) /*! 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 +771,7 @@ int ast_best_codec(int fmts) 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 +1074,7 @@ static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, in /* 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 +1159,7 @@ int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *fin) /*! \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 +1171,7 @@ int ast_queue_hangup(struct ast_channel *chan) /*! \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 +1191,7 @@ int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause) /*! \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 +1199,7 @@ int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type cont 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 +2343,7 @@ int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer) } 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 +2932,12 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd) 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 +2950,7 @@ int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd) /* 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 +3002,9 @@ static void ast_read_generator_actions(struct ast_channel *chan, struct ast_fram 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 +3040,7 @@ static inline void queue_dtmf_readq(struct ast_channel *chan, struct ast_frame * 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 +3217,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) /* 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 +3259,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) 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 +3277,8 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) } 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 +3295,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) /* 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 +3304,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) 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 +3318,23 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) } 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 +3349,18 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) } 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 +3378,12 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) 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 +3418,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) 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 +3427,17 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) 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 +3520,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) done: if (chan->music_state && chan->generator && chan->generator->digit && f && f->frametype == AST_FRAME_DTMF_END) - chan->generator->digit(chan, f->subclass); + chan->generator->digit(chan, f->subclass.integer); ast_channel_unlock(chan); return f; @@ -3767,7 +3762,7 @@ char *ast_recvtext(struct ast_channel *chan, int timeout) f = ast_read(chan); if (f == NULL) break; /* no frame */ - if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) + if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP) done = 1; /* force a break */ else if (f->frametype == AST_FRAME_TEXT) { /* what we want */ buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */ @@ -3867,7 +3862,7 @@ int ast_prod(struct ast_channel *chan) /* Send an empty audio frame to get things moving */ if (chan->_state != AST_STATE_UP) { ast_debug(1, "Prodding channel '%s'\n", chan->name); - a.subclass = chan->rawwriteformat; + a.subclass.codec = chan->rawwriteformat; a.data.ptr = nothing + AST_FRIENDLY_OFFSET; a.src = "ast_prod"; if (ast_write(chan, &a)) @@ -3929,13 +3924,13 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) * stop the generator */ ast_clear_flag(chan, AST_FLAG_BLOCKING); ast_channel_unlock(chan); - res = ast_senddigit_end(chan, fr->subclass, fr->len); + res = ast_senddigit_end(chan, fr->subclass.integer, fr->len); ast_channel_lock(chan); CHECK_BLOCKING(chan); - } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass == AST_CONTROL_UNHOLD) { + } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_UNHOLD) { /* This is a side case where Echo is basically being called and the person put themselves on hold and took themselves off hold */ res = (chan->tech->indicate == NULL) ? 0 : - chan->tech->indicate(chan, fr->subclass, fr->data.ptr, fr->datalen); + chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen); } res = 0; /* XXX explain, why 0 ? */ goto done; @@ -3948,7 +3943,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) switch (fr->frametype) { case AST_FRAME_CONTROL: res = (chan->tech->indicate == NULL) ? 0 : - chan->tech->indicate(chan, fr->subclass, fr->data.ptr, fr->datalen); + chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen); break; case AST_FRAME_DTMF_BEGIN: if (chan->audiohooks) { @@ -3957,10 +3952,10 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) if (old_frame != fr) f = fr; } - send_dtmf_event(chan, "Sent", fr->subclass, "Yes", "No"); + send_dtmf_event(chan, "Sent", fr->subclass.integer, "Yes", "No"); ast_clear_flag(chan, AST_FLAG_BLOCKING); ast_channel_unlock(chan); - res = ast_senddigit_begin(chan, fr->subclass); + res = ast_senddigit_begin(chan, fr->subclass.integer); ast_channel_lock(chan); CHECK_BLOCKING(chan); break; @@ -3973,15 +3968,15 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) ast_frfree(new_frame); } } - send_dtmf_event(chan, "Sent", fr->subclass, "No", "Yes"); + send_dtmf_event(chan, "Sent", fr->subclass.integer, "No", "Yes"); ast_clear_flag(chan, AST_FLAG_BLOCKING); ast_channel_unlock(chan); - res = ast_senddigit_end(chan, fr->subclass, fr->len); + res = ast_senddigit_end(chan, fr->subclass.integer, fr->len); ast_channel_lock(chan); CHECK_BLOCKING(chan); break; case AST_FRAME_TEXT: - if (fr->subclass == AST_FORMAT_T140) { + if (fr->subclass.integer == AST_FORMAT_T140) { res = (chan->tech->write_text == NULL) ? 0 : chan->tech->write_text(chan, fr); } else { @@ -3991,7 +3986,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) break; case AST_FRAME_HTML: res = (chan->tech->send_html == NULL) ? 0 : - chan->tech->send_html(chan, fr->subclass, (char *) fr->data.ptr, fr->datalen); + chan->tech->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen); break; case AST_FRAME_VIDEO: /* XXX Handle translation of video codecs one day XXX */ @@ -4007,7 +4002,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr) break; /*! \todo XXX should return 0 maybe ? */ /* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */ - if (fr->subclass == chan->rawwriteformat) + if (fr->subclass.codec == chan->rawwriteformat) f = fr; else f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr; @@ -4145,10 +4140,10 @@ done: return res; } -static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *format, +static int set_format(struct ast_channel *chan, format_t fmt, format_t *rawformat, format_t *format, struct ast_trans_pvt **trans, const int direction) { - int native, native_fmt = ast_best_codec(fmt); + format_t native, native_fmt = ast_best_codec(fmt); int res; char from[200], to[200]; @@ -4162,8 +4157,8 @@ static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *fo /* See if the underlying channel driver is capable of performing transcoding for us */ if (!ast_channel_setoption(chan, direction ? AST_OPTION_FORMAT_WRITE : AST_OPTION_FORMAT_READ, &native_fmt, sizeof(int*), 0)) { - ast_debug(1, "Channel driver natively set channel %s to %s format %s (%d)\n", chan->name, - direction ? "write" : "read", ast_getformatname(native_fmt), native_fmt); + ast_debug(1, "Channel driver natively set channel %s to %s format %s\n", chan->name, + direction ? "write" : "read", ast_getformatname(native_fmt)); chan->nativeformats = *rawformat = *format = native_fmt; if (*trans) { ast_translator_free_path(*trans); @@ -4215,13 +4210,13 @@ static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *fo return 0; } -int ast_set_read_format(struct ast_channel *chan, int fmt) +int ast_set_read_format(struct ast_channel *chan, format_t fmt) { return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat, &chan->readtrans, 0); } -int ast_set_write_format(struct ast_channel *chan, int fmt) +int ast_set_write_format(struct ast_channel *chan, format_t fmt) { return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat, &chan->writetrans, 1); @@ -4263,7 +4258,7 @@ static void handle_cause(int cause, int *outstate) } } -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) { char tmpchan[256]; struct ast_channel *new = NULL; @@ -4339,7 +4334,7 @@ struct ast_channel *ast_call_forward(struct ast_channel *caller, struct ast_chan return new; } -struct ast_channel *__ast_request_and_dial(const char *type, int format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh) +struct ast_channel *__ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh) { int dummy_outstate; int cause = 0; @@ -4411,15 +4406,15 @@ struct ast_channel *__ast_request_and_dial(const char *type, int format, const s break; } if (f->frametype == AST_FRAME_CONTROL) { - switch (f->subclass) { + switch (f->subclass.integer) { case AST_CONTROL_RINGING: /* record but keep going */ - *outstate = f->subclass; + *outstate = f->subclass.integer; break; case AST_CONTROL_BUSY: case AST_CONTROL_CONGESTION: case AST_CONTROL_ANSWER: - *outstate = f->subclass; + *outstate = f->subclass.integer; timeout = 0; /* trick to force exit from the while() */ break; @@ -4436,9 +4431,9 @@ struct ast_channel *__ast_request_and_dial(const char *type, int format, const s break; default: - ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass); + ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer); } - last_subclass = f->subclass; + last_subclass = f->subclass.integer; } ast_frfree(f); } @@ -4478,21 +4473,21 @@ struct ast_channel *__ast_request_and_dial(const char *type, int format, const s return chan; } -struct ast_channel *ast_request_and_dial(const char *type, int format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname) +struct ast_channel *ast_request_and_dial(const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname) { return __ast_request_and_dial(type, format, requestor, data, timeout, outstate, cidnum, cidname, NULL); } -struct ast_channel *ast_request(const char *type, int format, const struct ast_channel *requestor, void *data, int *cause) +struct ast_channel *ast_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause) { struct chanlist *chan; struct ast_channel *c; - int capabilities; - int fmt; + format_t capabilities; + format_t fmt; int res; int foo; - int videoformat = format & AST_FORMAT_VIDEO_MASK; - int textformat = format & AST_FORMAT_TEXT_MASK; + format_t videoformat = format & AST_FORMAT_VIDEO_MASK; + format_t textformat = format & AST_FORMAT_TEXT_MASK; if (!cause) cause = &foo; @@ -4515,7 +4510,10 @@ struct ast_channel *ast_request(const char *type, int format, const struct ast_c */ res = ast_translator_best_choice(&fmt, &capabilities); if (res < 0) { - ast_log(LOG_WARNING, "No translator path exists for channel type %s (native 0x%x) to 0x%x\n", type, chan->tech->capabilities, format); + char tmp1[256], tmp2[256]; + ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %s) to %s\n", type, + ast_getformatname_multiple(tmp1, sizeof(tmp1), chan->tech->capabilities), + ast_getformatname_multiple(tmp2, sizeof(tmp2), format)); *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; AST_RWLIST_UNLOCK(&backends); return NULL; @@ -4595,7 +4593,7 @@ int ast_transfer(struct ast_channel *chan, char *dest) break; } - if (fr->frametype == AST_FRAME_CONTROL && fr->subclass == AST_CONTROL_TRANSFER) { + if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_TRANSFER) { enum ast_control_transfer *message = fr->data.ptr; if (*message == AST_TRANSFER_SUCCESS) { @@ -4687,8 +4685,7 @@ int ast_channel_sendurl(struct ast_channel *chan, const char *url) /*! \brief Set up translation from one channel to another */ static int ast_channel_make_compatible_helper(struct ast_channel *from, struct ast_channel *to) { - int src; - int dst; + format_t src, dst; /* See if the channel driver can natively make these two channels compatible */ if (from->tech->bridge && from->tech->bridge == to->tech->bridge && @@ -4710,7 +4707,7 @@ static int ast_channel_make_compatible_helper(struct ast_channel *from, struct a return 0; if (ast_translator_best_choice(&dst, &src) < 0) { - ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", from->name, src, to->name, dst); + ast_log(LOG_WARNING, "No path to translate from %s to %s\n", from->name, to->name); return -1; } @@ -4722,11 +4719,11 @@ static int ast_channel_make_compatible_helper(struct ast_channel *from, struct a (ast_translate_path_steps(dst, src) != 1)) dst = AST_FORMAT_SLINEAR; if (ast_set_read_format(from, dst) < 0) { - ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", from->name, dst); + ast_log(LOG_WARNING, "Unable to set read format on channel %s to %s\n", from->name, ast_getformatname(dst)); return -1; } if (ast_set_write_format(to, dst) < 0) { - ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", to->name, dst); + ast_log(LOG_WARNING, "Unable to set write format on channel %s to %s\n", to->name, ast_getformatname(dst)); return -1; } return 0; @@ -5099,7 +5096,8 @@ static void report_new_callerid(const struct ast_channel *chan) */ int ast_do_masquerade(struct ast_channel *original) { - int x,i; + format_t x; + int i; int res=0; int origstate; struct ast_frame *current; @@ -5112,8 +5110,8 @@ int ast_do_masquerade(struct ast_channel *original) } exchange; struct ast_channel *clonechan; struct ast_cdr *cdr; - int rformat = original->readformat; - int wformat = original->writeformat; + format_t rformat = original->readformat; + format_t wformat = original->writeformat; char newn[AST_CHANNEL_NAME]; char orig[AST_CHANNEL_NAME]; char masqn[AST_CHANNEL_NAME]; @@ -5369,7 +5367,8 @@ int ast_do_masquerade(struct ast_channel *original) ast_cel_report_event(original, AST_CEL_BRIDGE_UPDATE, NULL, NULL, NULL); } - ast_debug(1, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat); + ast_debug(1, "Putting channel %s in %s/%s formats\n", original->name, + ast_getformatname(wformat), ast_getformatname(rformat)); /* Okay. Last thing is to let the channel driver know about all this mess, so he can fix up everything as best as possible */ @@ -5552,8 +5551,8 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct struct ast_channel *cs[3]; struct ast_frame *f; enum ast_bridge_result res = AST_BRIDGE_COMPLETE; - int o0nativeformats; - int o1nativeformats; + format_t o0nativeformats; + format_t o1nativeformats; int watch_c0_dtmf; int watch_c1_dtmf; void *pvt0, *pvt1; @@ -5660,20 +5659,20 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct if ((f->frametype == AST_FRAME_CONTROL) && !(config->flags & AST_BRIDGE_IGNORE_SIGS)) { int bridge_exit = 0; - switch (f->subclass) { + switch (f->subclass.integer) { case AST_CONTROL_REDIRECTING: - ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen); + ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen); break; case AST_CONTROL_CONNECTED_LINE: if (ast_channel_connected_line_macro(who, other, f, other == c0, 1)) { - ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen); + ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen); } break; case AST_CONTROL_HOLD: case AST_CONTROL_UNHOLD: case AST_CONTROL_VIDUPDATE: case AST_CONTROL_SRCUPDATE: - ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen); + ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen); if (jb_in_use) { ast_jb_empty_and_reset(c0, c1); } @@ -5682,7 +5681,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct *fo = f; *rc = who; bridge_exit = 1; - ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name); + ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass.integer, who->name); break; } if (bridge_exit) @@ -5839,8 +5838,8 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha struct ast_channel *who = NULL; enum ast_bridge_result res = AST_BRIDGE_COMPLETE; int nativefailed=0; - int o0nativeformats; - int o1nativeformats; + format_t o0nativeformats; + format_t o1nativeformats; long time_left_ms=0; char caller_warning = 0; char callee_warning = 0; @@ -6138,7 +6137,7 @@ struct tonepair_state { int v1_2; int v2_2; int v3_2; - int origwfmt; + format_t origwfmt; int pos; int duration; int modulate; @@ -6218,7 +6217,7 @@ static int tonepair_generator(struct ast_channel *chan, void *data, int len, int ts->data[x] = ts->v3_1 + ts->v3_2; } ts->f.frametype = AST_FRAME_VOICE; - ts->f.subclass = AST_FORMAT_SLINEAR; + ts->f.subclass.codec = AST_FORMAT_SLINEAR; ts->f.datalen = len; ts->f.samples = samples; ts->f.offset = AST_FRIENDLY_OFFSET; @@ -6421,7 +6420,7 @@ static int silence_generator_generate(struct ast_channel *chan, void *data, int short buf[samples]; struct ast_frame frame = { .frametype = AST_FRAME_VOICE, - .subclass = AST_FORMAT_SLINEAR, + .subclass.codec = AST_FORMAT_SLINEAR, .data.ptr = buf, .samples = samples, .datalen = sizeof(buf), diff --git a/main/dial.c b/main/dial.c index 4c57cb12d..cd8a7af7a 100644 --- a/main/dial.c +++ b/main/dial.c @@ -390,7 +390,7 @@ static void set_state(struct ast_dial *dial, enum ast_dial_result state) static void handle_frame(struct ast_dial *dial, struct ast_dial_channel *channel, struct ast_frame *fr, struct ast_channel *chan) { if (fr->frametype == AST_FRAME_CONTROL) { - switch (fr->subclass) { + switch (fr->subclass.integer) { case AST_CONTROL_ANSWER: ast_verb(3, "%s answered %s\n", channel->owner->name, chan->name); AST_LIST_LOCK(&dial->channels); @@ -474,7 +474,7 @@ static void handle_frame_ownerless(struct ast_dial *dial, struct ast_dial_channe if (fr->frametype != AST_FRAME_CONTROL) return; - switch (fr->subclass) { + switch (fr->subclass.integer) { case AST_CONTROL_ANSWER: ast_verb(3, "%s answered\n", channel->owner->name); AST_LIST_LOCK(&dial->channels); diff --git a/main/dsp.c b/main/dsp.c index 585403786..b3c87ddec 100644 --- a/main/dsp.c +++ b/main/dsp.c @@ -1092,7 +1092,7 @@ int ast_dsp_call_progress(struct ast_dsp *dsp, struct ast_frame *inf) ast_log(LOG_WARNING, "Can't check call progress of non-voice frames\n"); return 0; } - if (inf->subclass != AST_FORMAT_SLINEAR) { + if (inf->subclass.codec != AST_FORMAT_SLINEAR) { ast_log(LOG_WARNING, "Can only check call progress in signed-linear frames\n"); return 0; } @@ -1266,7 +1266,7 @@ int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence) ast_log(LOG_WARNING, "Can't calculate silence on a non-voice frame\n"); return 0; } - if (f->subclass != AST_FORMAT_SLINEAR) { + if (f->subclass.codec != AST_FORMAT_SLINEAR) { ast_log(LOG_WARNING, "Can only calculate silence on signed-linear frames :(\n"); return 0; } @@ -1284,7 +1284,7 @@ int ast_dsp_noise(struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise) ast_log(LOG_WARNING, "Can't calculate noise on a non-voice frame\n"); return 0; } - if (f->subclass != AST_FORMAT_SLINEAR) { + if (f->subclass.codec != AST_FORMAT_SLINEAR) { ast_log(LOG_WARNING, "Can only calculate noise on signed-linear frames :(\n"); return 0; } @@ -1315,12 +1315,13 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, odata = af->data.ptr; len = af->datalen; /* Make sure we have short data */ - switch (af->subclass) { + switch (af->subclass.codec) { case AST_FORMAT_SLINEAR: shortdata = af->data.ptr; 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]); @@ -1333,7 +1334,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, } break; default: - ast_log(LOG_WARNING, "Inband DTMF is not supported on codec %s. Use RFC2833\n", ast_getformatname(af->subclass)); + ast_log(LOG_WARNING, "Inband DTMF is not supported on codec %s. Use RFC2833\n", ast_getformatname(af->subclass.codec)); return af; } @@ -1355,7 +1356,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, chan->_softhangup |= AST_SOFTHANGUP_DEV; memset(&dsp->f, 0, sizeof(dsp->f)); dsp->f.frametype = AST_FRAME_CONTROL; - dsp->f.subclass = AST_CONTROL_BUSY; + dsp->f.subclass.integer = AST_CONTROL_BUSY; ast_frfree(af); ast_debug(1, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name); return ast_frisolate(&dsp->f); @@ -1401,7 +1402,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, if (event) { memset(&dsp->f, 0, sizeof(dsp->f)); dsp->f.frametype = event; - dsp->f.subclass = event_digit; + dsp->f.subclass.integer = event_digit; outf = &dsp->f; goto done; } @@ -1413,7 +1414,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, memset(&dsp->f, 0, sizeof(dsp->f)); dsp->f.frametype = AST_FRAME_DTMF; - dsp->f.subclass = fax_digit; + dsp->f.subclass.integer = fax_digit; outf = &dsp->f; goto done; } @@ -1429,7 +1430,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, case AST_CONTROL_HANGUP: memset(&dsp->f, 0, sizeof(dsp->f)); dsp->f.frametype = AST_FRAME_CONTROL; - dsp->f.subclass = res; + dsp->f.subclass.integer = res; dsp->f.src = "dsp_progress"; if (chan) ast_queue_frame(chan, &dsp->f); @@ -1448,7 +1449,7 @@ done: memset(shortdata + dsp->mute_data[x].start, 0, sizeof(int16_t) * (dsp->mute_data[x].end - dsp->mute_data[x].start)); } - switch (af->subclass) { + switch (af->subclass.codec) { case AST_FORMAT_SLINEAR: break; case AST_FORMAT_ULAW: diff --git a/main/features.c b/main/features.c index cfce3f1d7..fe79d4977 100644 --- a/main/features.c +++ b/main/features.c @@ -2483,30 +2483,30 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller, } if (f->frametype == AST_FRAME_CONTROL || f->frametype == AST_FRAME_DTMF || f->frametype == AST_FRAME_TEXT) { - if (f->subclass == AST_CONTROL_RINGING) { - state = f->subclass; + if (f->subclass.integer == AST_CONTROL_RINGING) { + state = f->subclass.integer; ast_verb(3, "%s is ringing\n", chan->name); ast_indicate(caller, AST_CONTROL_RINGING); - } else if ((f->subclass == AST_CONTROL_BUSY) || (f->subclass == AST_CONTROL_CONGESTION)) { - state = f->subclass; + } else if ((f->subclass.integer == AST_CONTROL_BUSY) || (f->subclass.integer == AST_CONTROL_CONGESTION)) { + state = f->subclass.integer; ast_verb(3, "%s is busy\n", chan->name); ast_indicate(caller, AST_CONTROL_BUSY); ast_frfree(f); f = NULL; break; - } else if (f->subclass == AST_CONTROL_ANSWER) { + } else if (f->subclass.integer == AST_CONTROL_ANSWER) { /* This is what we are hoping for */ - state = f->subclass; + state = f->subclass.integer; ast_frfree(f); f = NULL; ready=1; break; - } else if (f->subclass == AST_CONTROL_CONNECTED_LINE) { + } else if (f->subclass.integer == AST_CONTROL_CONNECTED_LINE) { if (ast_channel_connected_line_macro(chan, caller, f, 1, 1)) { ast_indicate_data(caller, AST_CONTROL_CONNECTED_LINE, f->data.ptr, f->datalen); } - } else if (f->subclass != -1 && f->subclass != AST_CONTROL_PROGRESS) { - ast_log(LOG_NOTICE, "Don't know what to do about control frame: %d\n", f->subclass); + } else if (f->subclass.integer != -1 && f->subclass.integer != AST_CONTROL_PROGRESS) { + ast_log(LOG_NOTICE, "Don't know what to do about control frame: %d\n", f->subclass.integer); } /* else who cares */ } else if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO) { @@ -2529,7 +2529,7 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller, } else { if (f->frametype == AST_FRAME_DTMF) { - dialed_code[x++] = f->subclass; + dialed_code[x++] = f->subclass.integer; dialed_code[x] = '\0'; if (strlen(dialed_code) == len) { x = 0; @@ -2941,19 +2941,19 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast } if (!f || (f->frametype == AST_FRAME_CONTROL && - (f->subclass == AST_CONTROL_HANGUP || f->subclass == AST_CONTROL_BUSY || - f->subclass == AST_CONTROL_CONGESTION))) { + (f->subclass.integer == AST_CONTROL_HANGUP || f->subclass.integer == AST_CONTROL_BUSY || + f->subclass.integer == AST_CONTROL_CONGESTION))) { res = -1; break; } /* many things should be sent to the 'other' channel */ other = (who == chan) ? peer : chan; if (f->frametype == AST_FRAME_CONTROL) { - switch (f->subclass) { + switch (f->subclass.integer) { case AST_CONTROL_RINGING: case AST_CONTROL_FLASH: case -1: - ast_indicate(other, f->subclass); + ast_indicate(other, f->subclass.integer); break; case AST_CONTROL_CONNECTED_LINE: if (!ast_channel_connected_line_macro(who, other, f, who != chan, 1)) { @@ -2962,7 +2962,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast /* The implied "else" falls through purposely */ case AST_CONTROL_HOLD: case AST_CONTROL_UNHOLD: - ast_indicate_data(other, f->subclass, f->data.ptr, f->datalen); + ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen); break; case AST_CONTROL_OPTION: aoh = f->data.ptr; @@ -2992,7 +2992,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast * not overflowing it. * \todo XXX how do we guarantee the latter ? */ - featurecode[strlen(featurecode)] = f->subclass; + featurecode[strlen(featurecode)] = f->subclass.integer; /* Get rid of the frame before we start doing "stuff" with the channels */ ast_frfree(f); f = NULL; @@ -3391,7 +3391,7 @@ int manage_parkinglot(struct ast_parkinglot *curlot, fd_set *rfds, fd_set *efds, /* See if they need servicing */ f = ast_read(pu->chan); /* Hangup? */ - if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP))) { + if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_HANGUP))) { if (f) ast_frfree(f); post_manager_event("ParkedCallGiveUp", pu); diff --git a/main/file.c b/main/file.c index 10764c67f..fce474ba5 100644 --- a/main/file.c +++ b/main/file.c @@ -128,7 +128,7 @@ int ast_stopstream(struct ast_channel *tmp) ast_closestream(tmp->stream); tmp->stream = NULL; if (tmp->oldwriteformat && ast_set_write_format(tmp, tmp->oldwriteformat)) - ast_log(LOG_WARNING, "Unable to restore format back to %d\n", tmp->oldwriteformat); + ast_log(LOG_WARNING, "Unable to restore format back to %s\n", ast_getformatname(tmp->oldwriteformat)); } /* Stop the video stream too */ if (tmp->vstream != NULL) { @@ -149,7 +149,7 @@ int ast_writestream(struct ast_filestream *fs, struct ast_frame *f) if (fs->fmt->format & AST_FORMAT_AUDIO_MASK) { /* This is the audio portion. Call the video one... */ if (!fs->vfs && fs->filename) { - const char *type = ast_getformatname(f->subclass & ~0x1); + const char *type = ast_getformatname(f->subclass.codec & ~0x1); fs->vfs = ast_writefile(fs->filename, type, NULL, fs->flags, 0, fs->mode); ast_debug(1, "Opened video output file\n"); } @@ -165,7 +165,7 @@ int ast_writestream(struct ast_filestream *fs, struct ast_frame *f) ast_log(LOG_WARNING, "Tried to write non-voice frame\n"); return -1; } - if (((fs->fmt->format | alt) & f->subclass) == f->subclass) { + if (((fs->fmt->format | alt) & f->subclass.codec) == f->subclass.codec) { res = fs->fmt->write(fs, f); if (res < 0) ast_log(LOG_WARNING, "Natural write failed\n"); @@ -174,18 +174,18 @@ int ast_writestream(struct ast_filestream *fs, struct ast_frame *f) } else { /* XXX If they try to send us a type of frame that isn't the normal frame, and isn't the one we've setup a translator for, we do the "wrong thing" XXX */ - if (fs->trans && f->subclass != fs->lastwriteformat) { + if (fs->trans && f->subclass.codec != fs->lastwriteformat) { ast_translator_free_path(fs->trans); fs->trans = NULL; } if (!fs->trans) - fs->trans = ast_translator_build_path(fs->fmt->format, f->subclass); + fs->trans = ast_translator_build_path(fs->fmt->format, f->subclass.codec); if (!fs->trans) ast_log(LOG_WARNING, "Unable to translate to format %s, source format %s\n", - fs->fmt->name, ast_getformatname(f->subclass)); + fs->fmt->name, ast_getformatname(f->subclass.codec)); else { struct ast_frame *trf; - fs->lastwriteformat = f->subclass; + fs->lastwriteformat = f->subclass.codec; /* Get the translated frame but don't consume the original in case they're using it on another stream */ if ((trf = ast_translate(fs->trans, f, 0))) { struct ast_frame *cur; @@ -660,7 +660,7 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil /* As above, but for video. But here we don't have translators * so we must enforce a format. */ - unsigned int format; + format_t format; char *buf; int buflen; @@ -1233,15 +1233,15 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, switch (fr->frametype) { case AST_FRAME_DTMF_END: if (context) { - const char exten[2] = { fr->subclass, '\0' }; + const char exten[2] = { fr->subclass.integer, '\0' }; if (ast_exists_extension(c, context, exten, 1, c->cid.cid_num)) { - res = fr->subclass; + res = fr->subclass.integer; ast_frfree(fr); ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); return res; } } else { - res = fr->subclass; + res = fr->subclass.integer; if (strchr(forward, res)) { int eoftest; ast_stream_fastforward(c->stream, skip_ms); @@ -1261,7 +1261,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, } break; case AST_FRAME_CONTROL: - switch (fr->subclass) { + switch (fr->subclass.integer) { case AST_CONTROL_HANGUP: case AST_CONTROL_BUSY: case AST_CONTROL_CONGESTION: @@ -1278,7 +1278,7 @@ static int waitstream_core(struct ast_channel *c, const char *breakon, /* Unimportant */ break; default: - ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", fr->subclass); + ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", fr->subclass.integer); } break; case AST_FRAME_VOICE: diff --git a/main/frame.c b/main/frame.c index f24c7a4dc..a11644577 100644 --- a/main/frame.c +++ b/main/frame.c @@ -80,7 +80,7 @@ enum frame_type { struct ast_smoother { int size; - int format; + format_t format; int flags; float samplesperbyte; unsigned int opt_needs_swap:1; @@ -119,6 +119,7 @@ static const struct ast_format_list AST_FORMAT_LIST[] = { { AST_FORMAT_T140, "t140", 0, "Passthrough T.140 Realtime Text" }, /*!< Passthrough support for T.140 Realtime Text */ { AST_FORMAT_SIREN7, "siren7", 16000, "ITU G.722.1 (Siren7, licensed from Polycom)", 80, 20, 80, 20, 20 }, /*!< Binary commercial distribution */ { AST_FORMAT_SIREN14, "siren14", 32000, "ITU G.722.1 Annex C, (Siren14, licensed from Polycom)", 120, 20, 80, 20, 20 }, /*!< Binary commercial distribution */ + { AST_FORMAT_TESTLAW, "testlaw", 8000, "G.711 test-law", 80, 10, 150, 10, 20 }, /*!< codec_ulaw.c */ }; struct ast_frame ast_null_frame = { AST_FRAME_NULL, }; @@ -205,10 +206,11 @@ int __ast_smoother_feed(struct ast_smoother *s, struct ast_frame *f, int swap) return -1; } if (!s->format) { - s->format = f->subclass; + s->format = f->subclass.codec; s->samplesperbyte = (float)f->samples / (float)f->datalen; - } else if (s->format != f->subclass) { - ast_log(LOG_WARNING, "Smoother was working on %d format frames, now trying to feed %d?\n", s->format, f->subclass); + } else if (s->format != f->subclass.codec) { + ast_log(LOG_WARNING, "Smoother was working on %s format frames, now trying to feed %s?\n", + ast_getformatname(s->format), ast_getformatname(f->subclass.codec)); return -1; } if (s->len + f->datalen > SMOOTHER_SIZE) { @@ -259,7 +261,7 @@ struct ast_frame *ast_smoother_read(struct ast_smoother *s) len = s->len; /* Make frame */ s->f.frametype = AST_FRAME_VOICE; - s->f.subclass = s->format; + s->f.subclass.codec = s->format; s->f.data.ptr = s->framedata + AST_FRIENDLY_OFFSET; s->f.offset = AST_FRIENDLY_OFFSET; s->f.datalen = len; @@ -404,7 +406,7 @@ struct ast_frame *ast_frisolate(struct ast_frame *fr) return NULL; } out->frametype = fr->frametype; - out->subclass = fr->subclass; + out->subclass.codec = fr->subclass.codec; out->datalen = fr->datalen; out->samples = fr->samples; out->offset = fr->offset; @@ -506,7 +508,7 @@ struct ast_frame *ast_frdup(const struct ast_frame *f) } out->frametype = f->frametype; - out->subclass = f->subclass; + out->subclass.codec = f->subclass.codec; out->datalen = f->datalen; out->samples = f->samples; out->delivery = f->delivery; @@ -557,7 +559,7 @@ const struct ast_format_list *ast_get_format_list(size_t *size) return AST_FORMAT_LIST; } -char* ast_getformatname(int format) +char* ast_getformatname(format_t format) { int x; char *ret = "unknown"; @@ -570,7 +572,7 @@ char* ast_getformatname(int format) return ret; } -char *ast_getformatname_multiple(char *buf, size_t size, int format) +char *ast_getformatname_multiple(char *buf, size_t size, format_t format) { int x; unsigned len; @@ -578,14 +580,14 @@ char *ast_getformatname_multiple(char *buf, size_t size, int format) if (!size) return buf; - snprintf(end, size, "0x%x (", format); + snprintf(end, size, "0x%llx (", (unsigned long long) format); len = strlen(end); end += len; size -= len; start = end; for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) { if (AST_FORMAT_LIST[x].bits & format) { - snprintf(end, size,"%s|",AST_FORMAT_LIST[x].name); + snprintf(end, size, "%s|", AST_FORMAT_LIST[x].name); len = strlen(end); end += len; size -= len; @@ -594,7 +596,7 @@ char *ast_getformatname_multiple(char *buf, size_t size, int format) if (start == end) ast_copy_string(start, "nothing)", size); else if (size > 1) - *(end -1) = ')'; + *(end - 1) = ')'; return buf; } @@ -620,9 +622,10 @@ static const char *ast_expand_codec_alias(const char *in) return in; } -int ast_getformatbyname(const char *name) +format_t ast_getformatbyname(const char *name) { - int x, all, format = 0; + int x, all; + format_t format = 0; all = strcasecmp(name, "all") ? 0 : 1; for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) { @@ -638,7 +641,7 @@ int ast_getformatbyname(const char *name) return format; } -char *ast_codec2str(int codec) +char *ast_codec2str(format_t codec) { int x; char *ret = "unknown"; @@ -676,27 +679,30 @@ static char *show_codecs(struct ast_cli_entry *e, int cmd, struct ast_cli_args * ast_cli(a->fd, "%11s %9s %10s TYPE %8s %s\n","INT","BINARY","HEX","NAME","DESC"); ast_cli(a->fd, "--------------------------------------------------------------------------------\n"); - if ((a->argc == 3) || (!strcasecmp(a->argv[3],"audio"))) { + if ((a->argc == 3) || (!strcasecmp(a->argv[3], "audio"))) { found = 1; - for (i=0;i<13;i++) { - snprintf(hex,25,"(0x%x)",1<fd, "%11u (1 << %2d) %10s audio %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<fd, "%11Lu (1 << %2d) %10s audio %8s (%s)\n", 1LL << i, i, hex, ast_getformatname(1LL << i), ast_codec2str(1LL << i)); } } - if ((a->argc == 3) || (!strcasecmp(a->argv[3],"image"))) { + if ((a->argc == 3) || (!strcasecmp(a->argv[3], "image"))) { found = 1; - for (i=16;i<18;i++) { - snprintf(hex,25,"(0x%x)",1<fd, "%11u (1 << %2d) %10s image %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<fd, "%11Lu (1 << %2d) %10s image %8s (%s)\n", 1LL << i, i, hex, ast_getformatname(1LL << i), ast_codec2str(1LL << i)); } } - if ((a->argc == 3) || (!strcasecmp(a->argv[3],"video"))) { + if ((a->argc == 3) || (!strcasecmp(a->argv[3], "video"))) { found = 1; - for (i=18;i<22;i++) { - snprintf(hex,25,"(0x%x)",1<fd, "%11u (1 << %2d) %10s video %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<fd, "%11Lu (1 << %2d) %10s video %8s (%s)\n", 1LL << i, i, hex, ast_getformatname(1LL << i), ast_codec2str(1LL << i)); } } @@ -708,12 +714,13 @@ static char *show_codecs(struct ast_cli_entry *e, int cmd, struct ast_cli_args * static char *show_codec_n(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { - int codec, i, found=0; + format_t codec; + int i, found = 0; switch (cmd) { case CLI_INIT: e->command = "core show codec"; - e->usage = + e->usage = "Usage: core show codec \n" " Displays codec mapping\n"; return NULL; @@ -724,17 +731,17 @@ static char *show_codec_n(struct ast_cli_entry *e, int cmd, struct ast_cli_args if (a->argc != 4) return CLI_SHOWUSAGE; - if (sscanf(a->argv[3], "%30d", &codec) != 1) + if (sscanf(a->argv[3], "%30Ld", &codec) != 1) return CLI_SHOWUSAGE; - for (i = 0; i < 32; i++) - if (codec & (1 << i)) { + for (i = 0; i < 63; i++) + if (codec & (1LL << i)) { found = 1; - ast_cli(a->fd, "%11u (1 << %2d) %s\n",1 << i,i,ast_codec2str(1<fd, "%11Lu (1 << %2d) %s\n", 1LL << i, i, ast_codec2str(1LL << i)); } if (!found) - ast_cli(a->fd, "Codec %d not found\n", codec); + ast_cli(a->fd, "Codec %Ld not found\n", codec); return CLI_SUCCESS; } @@ -772,17 +779,17 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) switch(f->frametype) { case AST_FRAME_DTMF_BEGIN: strcpy(ftype, "DTMF Begin"); - subclass[0] = f->subclass; + subclass[0] = f->subclass.integer; subclass[1] = '\0'; break; case AST_FRAME_DTMF_END: strcpy(ftype, "DTMF End"); - subclass[0] = f->subclass; + subclass[0] = f->subclass.integer; subclass[1] = '\0'; break; case AST_FRAME_CONTROL: strcpy(ftype, "Control"); - switch(f->subclass) { + switch (f->subclass.integer) { case AST_CONTROL_HANGUP: strcpy(subclass, "Hangup"); break; @@ -851,7 +858,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) strcpy(subclass, "Stop generators"); break; default: - snprintf(subclass, sizeof(subclass), "Unknown control '%d'", f->subclass); + snprintf(subclass, sizeof(subclass), "Unknown control '%d'", f->subclass.integer); } break; case AST_FRAME_NULL: @@ -861,7 +868,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) case AST_FRAME_IAX: /* Should never happen */ strcpy(ftype, "IAX Specific"); - snprintf(subclass, sizeof(subclass), "IAX Frametype %d", f->subclass); + snprintf(subclass, sizeof(subclass), "IAX Frametype %d", f->subclass.integer); break; case AST_FRAME_TEXT: strcpy(ftype, "Text"); @@ -870,11 +877,11 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) break; case AST_FRAME_IMAGE: strcpy(ftype, "Image"); - snprintf(subclass, sizeof(subclass), "Image format %s\n", ast_getformatname(f->subclass)); + snprintf(subclass, sizeof(subclass), "Image format %s\n", ast_getformatname(f->subclass.codec)); break; case AST_FRAME_HTML: strcpy(ftype, "HTML"); - switch(f->subclass) { + switch (f->subclass.integer) { case AST_HTML_URL: strcpy(subclass, "URL"); ast_copy_string(moreinfo, f->data.ptr, sizeof(moreinfo)); @@ -905,13 +912,13 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) strcpy(subclass, "Link Reject"); break; default: - snprintf(subclass, sizeof(subclass), "Unknown HTML frame '%d'\n", f->subclass); + snprintf(subclass, sizeof(subclass), "Unknown HTML frame '%d'\n", f->subclass.integer); break; } break; case AST_FRAME_MODEM: strcpy(ftype, "Modem"); - switch (f->subclass) { + switch (f->subclass.integer) { case AST_MODEM_T38: strcpy(subclass, "T.38"); break; @@ -919,7 +926,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) strcpy(subclass, "V.150"); break; default: - snprintf(subclass, sizeof(subclass), "Unknown MODEM frame '%d'\n", f->subclass); + snprintf(subclass, sizeof(subclass), "Unknown MODEM frame '%d'\n", f->subclass.integer); break; } break; @@ -932,7 +939,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)), f->frametype, term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)), - f->subclass, + f->subclass.integer, term_color(cmn, moreinfo, COLOR_BRGREEN, COLOR_BLACK, sizeof(cmn)), term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn))); else @@ -941,7 +948,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix) term_color(cft, ftype, COLOR_BRRED, COLOR_BLACK, sizeof(cft)), f->frametype, term_color(csub, subclass, COLOR_BRCYAN, COLOR_BLACK, sizeof(csub)), - f->subclass, + f->subclass.integer, term_color(cn, name, COLOR_YELLOW, COLOR_BLACK, sizeof(cn))); } @@ -970,11 +977,11 @@ void ast_codec_pref_convert(struct ast_codec_pref *pref, char *buf, size_t size, } else { to = pref->order; from = buf; - mem = 32; + mem = sizeof(format_t) * 8; } memset(to, 0, mem); - for (x = 0; x < 32 ; x++) { + for (x = 0; x < sizeof(format_t) * 8; x++) { if (!from[x]) break; to[x] = right ? (from[x] + differential) : (from[x] - differential); @@ -983,15 +990,16 @@ void ast_codec_pref_convert(struct ast_codec_pref *pref, char *buf, size_t size, int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size) { - int x, codec; + int x; + format_t codec; size_t total_len, slen; char *formatname; - memset(buf,0,size); + memset(buf, 0, size); total_len = size; buf[0] = '('; total_len--; - for(x = 0; x < 32 ; x++) { + for (x = 0; x < sizeof(format_t) * 8; x++) { if (total_len <= 0) break; if (!(codec = ast_codec_pref_index(pref,x))) @@ -1003,7 +1011,7 @@ int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size) strncat(buf, formatname, total_len - 1); /* safe */ total_len -= slen; } - if (total_len && x < 31 && ast_codec_pref_index(pref , x + 1)) { + if (total_len && x < sizeof(format_t) * 8 - 1 && ast_codec_pref_index(pref, x + 1)) { strncat(buf, "|", total_len - 1); /* safe */ total_len--; } @@ -1016,7 +1024,7 @@ int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size) return size - total_len; } -int ast_codec_pref_index(struct ast_codec_pref *pref, int idx) +format_t ast_codec_pref_index(struct ast_codec_pref *pref, int idx) { int slot = 0; @@ -1028,7 +1036,7 @@ int ast_codec_pref_index(struct ast_codec_pref *pref, int idx) } /*! \brief Remove codec from pref list */ -void ast_codec_pref_remove(struct ast_codec_pref *pref, int format) +void ast_codec_pref_remove(struct ast_codec_pref *pref, format_t format) { struct ast_codec_pref oldorder; int x, y = 0; @@ -1051,11 +1059,10 @@ void ast_codec_pref_remove(struct ast_codec_pref *pref, int format) pref->framing[y++] = size; } } - } /*! \brief Append codec to list */ -int ast_codec_pref_append(struct ast_codec_pref *pref, int format) +int ast_codec_pref_append(struct ast_codec_pref *pref, format_t format) { int x, newindex = 0; @@ -1081,7 +1088,7 @@ int ast_codec_pref_append(struct ast_codec_pref *pref, int format) } /*! \brief Prepend codec to list */ -void ast_codec_pref_prepend(struct ast_codec_pref *pref, int format, int only_if_existing) +void ast_codec_pref_prepend(struct ast_codec_pref *pref, format_t format, int only_if_existing) { int x, newindex = 0; @@ -1097,7 +1104,7 @@ void ast_codec_pref_prepend(struct ast_codec_pref *pref, int format, int only_if return; /* Now find any existing occurrence, or the end */ - for (x = 0; x < 32; x++) { + for (x = 0; x < sizeof(format_t) * 8; x++) { if (!pref->order[x] || pref->order[x] == newindex) break; } @@ -1118,7 +1125,7 @@ void ast_codec_pref_prepend(struct ast_codec_pref *pref, int format, int only_if } /*! \brief Set packet size for codec */ -int ast_codec_pref_setsize(struct ast_codec_pref *pref, int format, int framems) +int ast_codec_pref_setsize(struct ast_codec_pref *pref, format_t format, int framems) { int x, idx = -1; @@ -1156,7 +1163,7 @@ int ast_codec_pref_setsize(struct ast_codec_pref *pref, int format, int framems) } /*! \brief Get packet size for codec */ -struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, int format) +struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, format_t format) { int x, idx = -1, framems = 0; struct ast_format_list fmt = { 0, }; @@ -1195,9 +1202,10 @@ struct ast_format_list ast_codec_pref_getsize(struct ast_codec_pref *pref, int f } /*! \brief Pick a codec */ -int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best) +format_t ast_codec_choose(struct ast_codec_pref *pref, format_t formats, int find_best) { - int x, ret = 0, slot; + int x, slot; + format_t ret = 0; for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) { slot = pref->order[x]; @@ -1217,11 +1225,11 @@ int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best) return find_best ? ast_best_codec(formats) : 0; } -int ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char *list, int allowing) +int ast_parse_allow_disallow(struct ast_codec_pref *pref, format_t *mask, const char *list, int allowing) { - int errors = 0; + int errors = 0, framems = 0; char *parse = NULL, *this = NULL, *psize = NULL; - int format = 0, framems = 0; + format_t format = 0; parse = ast_strdupa(list); while ((this = strsep(&parse, ","))) { @@ -1418,8 +1426,9 @@ static int speex_samples(unsigned char *data, int len) int ast_codec_get_samples(struct ast_frame *f) { int samples = 0; + char tmp[64]; - switch(f->subclass) { + switch (f->subclass.codec) { case AST_FORMAT_SPEEX: samples = speex_samples(f->data.ptr, f->datalen); break; @@ -1446,6 +1455,7 @@ int ast_codec_get_samples(struct ast_frame *f) break; case AST_FORMAT_ULAW: case AST_FORMAT_ALAW: + case AST_FORMAT_TESTLAW: samples = f->datalen; break; case AST_FORMAT_G722: @@ -1463,12 +1473,12 @@ int ast_codec_get_samples(struct ast_frame *f) samples = (int) f->datalen * ((float) 32000 / 6000); break; default: - ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname(f->subclass)); + ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), f->subclass.codec)); } return samples; } -int ast_codec_get_len(int format, int samples) +int ast_codec_get_len(format_t format, int samples) { int len = 0; @@ -1492,6 +1502,7 @@ int ast_codec_get_len(int format, int samples) break; case AST_FORMAT_ULAW: case AST_FORMAT_ALAW: + case AST_FORMAT_TESTLAW: len = samples; break; case AST_FORMAT_G722: @@ -1521,7 +1532,7 @@ int ast_frame_adjust_volume(struct ast_frame *f, int adjustment) short *fdata = f->data.ptr; short adjust_value = abs(adjustment); - if ((f->frametype != AST_FRAME_VOICE) || (f->subclass != AST_FORMAT_SLINEAR)) + if ((f->frametype != AST_FRAME_VOICE) || (f->subclass.codec != AST_FORMAT_SLINEAR)) return -1; if (!adjustment) @@ -1543,10 +1554,10 @@ int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2) int count; short *data1, *data2; - if ((f1->frametype != AST_FRAME_VOICE) || (f1->subclass != AST_FORMAT_SLINEAR)) + if ((f1->frametype != AST_FRAME_VOICE) || (f1->subclass.codec != AST_FORMAT_SLINEAR)) return -1; - if ((f2->frametype != AST_FRAME_VOICE) || (f2->subclass != AST_FORMAT_SLINEAR)) + if ((f2->frametype != AST_FRAME_VOICE) || (f2->subclass.codec != AST_FORMAT_SLINEAR)) return -1; if (f1->samples != f2->samples) diff --git a/main/indications.c b/main/indications.c index b658e3f51..78010e0e7 100644 --- a/main/indications.c +++ b/main/indications.c @@ -209,7 +209,7 @@ static int playtones_generator(struct ast_channel *chan, void *data, int len, in } ps->f.frametype = AST_FRAME_VOICE; - ps->f.subclass = AST_FORMAT_SLINEAR; + ps->f.subclass.codec = AST_FORMAT_SLINEAR; ps->f.datalen = len; ps->f.samples = samples; ps->f.offset = AST_FRIENDLY_OFFSET; diff --git a/main/manager.c b/main/manager.c index e618a2fef..b2a21bd87 100644 --- a/main/manager.c +++ b/main/manager.c @@ -3162,12 +3162,12 @@ static int action_atxfer(struct mansession *s, const struct message *m) } for (feature_code = atxfer_feature->exten; feature_code && *feature_code; ++feature_code) { - struct ast_frame f = { AST_FRAME_DTMF, *feature_code }; + struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = *feature_code }; ast_queue_frame(chan, &f); } for (feature_code = (char *)exten; feature_code && *feature_code; ++feature_code) { - struct ast_frame f = { AST_FRAME_DTMF, *feature_code }; + struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = *feature_code }; ast_queue_frame(chan, &f); } @@ -3274,7 +3274,7 @@ struct fast_originate_helper { /*! data can contain a channel name, extension number, username, password, etc. */ char data[512]; int timeout; - int format; /*!< Codecs used for a call */ + format_t format; /*!< Codecs used for a call */ char app[AST_MAX_APP]; char appdata[AST_MAX_EXTENSION]; char cid_name[AST_MAX_EXTENSION]; @@ -3359,7 +3359,7 @@ static int action_originate(struct mansession *s, const struct message *m) int reason = 0; char tmp[256]; char tmp2[256]; - int format = AST_FORMAT_SLINEAR; + format_t format = AST_FORMAT_SLINEAR; pthread_t th; if (ast_strlen_zero(name)) { diff --git a/main/pbx.c b/main/pbx.c index 6125b1758..ed852956a 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -8155,8 +8155,8 @@ static void *async_wait(void *data) if (!f) break; if (f->frametype == AST_FRAME_CONTROL) { - if ((f->subclass == AST_CONTROL_BUSY) || - (f->subclass == AST_CONTROL_CONGESTION) ) { + if ((f->subclass.integer == AST_CONTROL_BUSY) || + (f->subclass.integer == AST_CONTROL_CONGESTION) ) { ast_frfree(f); break; } @@ -8224,7 +8224,7 @@ static int ast_pbx_outgoing_cdr_failed(void) return 0; /* success */ } -int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel) +int ast_pbx_outgoing_exten(const char *type, format_t format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel) { struct ast_channel *chan; struct async_stat *as; @@ -8390,7 +8390,7 @@ static void *ast_pbx_run_app(void *data) return NULL; } -int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel) +int ast_pbx_outgoing_app(const char *type, format_t format, void *data, int timeout, const char *app, const char *appdata, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel) { struct ast_channel *chan; struct app_tmp *tmp; diff --git a/main/rtp_engine.c b/main/rtp_engine.c index 9818ea584..5a8e5090b 100644 --- a/main/rtp_engine.c +++ b/main/rtp_engine.c @@ -601,7 +601,7 @@ struct ast_rtp_payload_type ast_rtp_codecs_payload_lookup(struct ast_rtp_codecs return result; } -void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, int *astformats, int *nonastformats) +void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, format_t *astformats, int *nonastformats) { int i; @@ -619,7 +619,7 @@ void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, int *astforma } } -int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const int code) +int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const format_t code) { int i; @@ -638,7 +638,7 @@ int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asteris return -1; } -const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const int code, enum ast_rtp_options options) +const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const format_t code, enum ast_rtp_options options) { int i; @@ -655,7 +655,7 @@ const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const int co 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; @@ -668,15 +668,16 @@ unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, int code) return 0; } -char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const int capability, const int asterisk_format, enum ast_rtp_options options) +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; } - ast_str_append(&buf, 0, "0x%x (", capability); + ast_str_append(&buf, 0, "0x%llx (", (unsigned long long) capability); for (format = 1; format < AST_RTP_MAX; format <<= 1) { if (capability & format) { @@ -851,13 +852,13 @@ static enum ast_bridge_result local_bridge_loop(struct ast_channel *c0, struct a res = AST_BRIDGE_COMPLETE; break; } else if ((fr->frametype == AST_FRAME_CONTROL) && !(flags & AST_BRIDGE_IGNORE_SIGS)) { - if ((fr->subclass == AST_CONTROL_HOLD) || - (fr->subclass == AST_CONTROL_UNHOLD) || - (fr->subclass == AST_CONTROL_VIDUPDATE) || - (fr->subclass == AST_CONTROL_SRCUPDATE) || - (fr->subclass == AST_CONTROL_T38_PARAMETERS)) { + if ((fr->subclass.integer == AST_CONTROL_HOLD) || + (fr->subclass.integer == AST_CONTROL_UNHOLD) || + (fr->subclass.integer == AST_CONTROL_VIDUPDATE) || + (fr->subclass.integer == AST_CONTROL_SRCUPDATE) || + (fr->subclass.integer == AST_CONTROL_T38_PARAMETERS)) { /* If we are going on hold, then break callback mode and P2P bridging */ - if (fr->subclass == AST_CONTROL_HOLD) { + if (fr->subclass.integer == AST_CONTROL_HOLD) { if (instance0->engine->local_bridge) { instance0->engine->local_bridge(instance0, NULL); } @@ -866,7 +867,7 @@ static enum ast_bridge_result local_bridge_loop(struct ast_channel *c0, struct a } instance0->bridged = NULL; instance1->bridged = NULL; - } else if (fr->subclass == AST_CONTROL_UNHOLD) { + } else if (fr->subclass.integer == AST_CONTROL_UNHOLD) { if (instance0->engine->local_bridge) { instance0->engine->local_bridge(instance0, instance1); } @@ -876,12 +877,12 @@ static enum ast_bridge_result local_bridge_loop(struct ast_channel *c0, struct a instance0->bridged = instance1; instance1->bridged = instance0; } - ast_indicate_data(other, fr->subclass, fr->data.ptr, fr->datalen); + ast_indicate_data(other, fr->subclass.integer, fr->data.ptr, fr->datalen); ast_frfree(fr); } else { *fo = fr; *rc = who; - ast_debug(1, "rtp-engine-local-bridge: Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name); + ast_debug(1, "rtp-engine-local-bridge: Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass.integer, who->name); res = AST_BRIDGE_COMPLETE; break; } @@ -923,12 +924,12 @@ static enum ast_bridge_result local_bridge_loop(struct ast_channel *c0, struct a static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, struct ast_channel *c1, struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1, struct ast_rtp_instance *vinstance0, struct ast_rtp_instance *vinstance1, struct ast_rtp_instance *tinstance0, - struct ast_rtp_instance *tinstance1, struct ast_rtp_glue *glue0, struct ast_rtp_glue *glue1, int codec0, int codec1, int timeoutms, + struct ast_rtp_instance *tinstance1, struct ast_rtp_glue *glue0, struct ast_rtp_glue *glue1, format_t codec0, format_t codec1, int timeoutms, int flags, struct ast_frame **fo, struct ast_channel **rc, void *pvt0, void *pvt1) { enum ast_bridge_result res = AST_BRIDGE_FAILED; struct ast_channel *who = NULL, *other = NULL, *cs[3] = { NULL, }; - int oldcodec0 = codec0, oldcodec1 = codec1; + format_t oldcodec0 = codec0, oldcodec1 = codec1; struct sockaddr_in ac1 = {0,}, vac1 = {0,}, tac1 = {0,}, ac0 = {0,}, vac0 = {0,}, tac0 = {0,}; struct sockaddr_in t1 = {0,}, vt1 = {0,}, tt1 = {0,}, t0 = {0,}, vt0 = {0,}, tt0 = {0,}; struct ast_frame *fr = NULL; @@ -1009,18 +1010,18 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, struct (vinstance1 && inaddrcmp(&vt1, &vac1)) || (tinstance1 && inaddrcmp(&tt1, &tac1)) || (codec1 != oldcodec1)) { - ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %d)\n", - c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port), codec1); - ast_debug(1, "Oooh, '%s' changed end vaddress to %s:%d (format %d)\n", - c1->name, ast_inet_ntoa(vt1.sin_addr), ntohs(vt1.sin_port), codec1); - ast_debug(1, "Oooh, '%s' changed end taddress to %s:%d (format %d)\n", - c1->name, ast_inet_ntoa(tt1.sin_addr), ntohs(tt1.sin_port), codec1); - ast_debug(1, "Oooh, '%s' was %s:%d/(format %d)\n", - c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port), oldcodec1); - ast_debug(1, "Oooh, '%s' was %s:%d/(format %d)\n", - c1->name, ast_inet_ntoa(vac1.sin_addr), ntohs(vac1.sin_port), oldcodec1); - ast_debug(1, "Oooh, '%s' was %s:%d/(format %d)\n", - c1->name, ast_inet_ntoa(tac1.sin_addr), ntohs(tac1.sin_port), oldcodec1); + ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %s)\n", + c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port), ast_getformatname(codec1)); + ast_debug(1, "Oooh, '%s' changed end vaddress to %s:%d (format %s)\n", + c1->name, ast_inet_ntoa(vt1.sin_addr), ntohs(vt1.sin_port), ast_getformatname(codec1)); + ast_debug(1, "Oooh, '%s' changed end taddress to %s:%d (format %s)\n", + c1->name, ast_inet_ntoa(tt1.sin_addr), ntohs(tt1.sin_port), ast_getformatname(codec1)); + ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n", + c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port), ast_getformatname(oldcodec1)); + ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n", + c1->name, ast_inet_ntoa(vac1.sin_addr), ntohs(vac1.sin_port), ast_getformatname(oldcodec1)); + ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n", + c1->name, ast_inet_ntoa(tac1.sin_addr), ntohs(tac1.sin_port), ast_getformatname(oldcodec1)); if (glue0->update_peer(c0, t1.sin_addr.s_addr ? instance1 : NULL, vt1.sin_addr.s_addr ? vinstance1 : NULL, tt1.sin_addr.s_addr ? tinstance1 : NULL, codec1, 0)) { ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c0->name, c1->name); } @@ -1033,10 +1034,10 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, struct (vinstance0 && inaddrcmp(&vt0, &vac0)) || (tinstance0 && inaddrcmp(&tt0, &tac0)) || (codec0 != oldcodec0)) { - ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %d)\n", - c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port), codec0); - ast_debug(1, "Oooh, '%s' was %s:%d/(format %d)\n", - c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port), oldcodec0); + ast_debug(1, "Oooh, '%s' changed end address to %s:%d (format %s)\n", + c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port), ast_getformatname(codec0)); + ast_debug(1, "Oooh, '%s' was %s:%d/(format %s)\n", + c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port), ast_getformatname(oldcodec0)); if (glue1->update_peer(c1, t0.sin_addr.s_addr ? instance0 : NULL, vt0.sin_addr.s_addr ? vinstance0 : NULL, tt0.sin_addr.s_addr ? tinstance0 : NULL, codec0, 0)) { ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c1->name, c0->name); } @@ -1070,19 +1071,19 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, struct res = AST_BRIDGE_COMPLETE; break; } else if ((fr->frametype == AST_FRAME_CONTROL) && !(flags & AST_BRIDGE_IGNORE_SIGS)) { - if ((fr->subclass == AST_CONTROL_HOLD) || - (fr->subclass == AST_CONTROL_UNHOLD) || - (fr->subclass == AST_CONTROL_VIDUPDATE) || - (fr->subclass == AST_CONTROL_SRCUPDATE) || - (fr->subclass == AST_CONTROL_T38_PARAMETERS)) { - if (fr->subclass == AST_CONTROL_HOLD) { + if ((fr->subclass.integer == AST_CONTROL_HOLD) || + (fr->subclass.integer == AST_CONTROL_UNHOLD) || + (fr->subclass.integer == AST_CONTROL_VIDUPDATE) || + (fr->subclass.integer == AST_CONTROL_SRCUPDATE) || + (fr->subclass.integer == AST_CONTROL_T38_PARAMETERS)) { + if (fr->subclass.integer == AST_CONTROL_HOLD) { /* If we someone went on hold we want the other side to reinvite back to us */ if (who == c0) { glue1->update_peer(c1, NULL, NULL, NULL, 0, 0); } else { glue0->update_peer(c0, NULL, NULL, NULL, 0, 0); } - } else if (fr->subclass == AST_CONTROL_UNHOLD) { + } else if (fr->subclass.integer == AST_CONTROL_UNHOLD) { /* If they went off hold they should go back to being direct */ if (who == c0) { glue1->update_peer(c1, instance0, vinstance0, tinstance0, codec0, 0); @@ -1102,12 +1103,12 @@ static enum ast_bridge_result remote_bridge_loop(struct ast_channel *c0, struct if (glue1->get_codec && c1->tech_pvt) { oldcodec1 = codec1 = glue1->get_codec(c1); } - ast_indicate_data(other, fr->subclass, fr->data.ptr, fr->datalen); + ast_indicate_data(other, fr->subclass.integer, fr->data.ptr, fr->datalen); ast_frfree(fr); } else { *fo = fr; *rc = who; - ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name); + ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass.integer, who->name); return AST_BRIDGE_COMPLETE; } } else { @@ -1164,7 +1165,7 @@ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct as 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 @@ enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct as 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; } @@ -1286,7 +1287,7 @@ void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c0, struc struct ast_rtp_glue *glue0, *glue1; 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; - int codec0 = 0, codec1 = 0; + format_t codec0 = 0, codec1 = 0; int res = 0; /* Lock both channels so we can look for the glue that binds them together */ @@ -1370,7 +1371,7 @@ int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1 struct ast_rtp_glue *glue0, *glue1; 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; - int codec0 = 0, codec1 = 0; + format_t codec0 = 0, codec1 = 0; int res = 0; /* If there is no second channel just immediately bail out, we are of no use in that scenario */ @@ -1538,12 +1539,12 @@ void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_in } } -int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, int format) +int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, format_t format) { return instance->engine->set_read_format ? instance->engine->set_read_format(instance, format) : -1; } -int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, int format) +int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, format_t format) { return instance->engine->set_write_format ? instance->engine->set_write_format(instance, format) : -1; } @@ -1584,9 +1585,9 @@ int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_in return res; } -int 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, int to_endpoint, int to_asterisk) { - int formats; + format_t formats; if (instance->engine->available_formats && (formats = instance->engine->available_formats(instance, to_endpoint, to_asterisk))) { return formats; diff --git a/main/slinfactory.c b/main/slinfactory.c index 8f004da8d..4da443af5 100644 --- a/main/slinfactory.c +++ b/main/slinfactory.c @@ -85,19 +85,19 @@ int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f) return 0; } - if (f->subclass != sf->output_format) { - if (sf->trans && f->subclass != sf->format) { + if (f->subclass.codec != sf->output_format) { + if (sf->trans && f->subclass.codec != sf->format) { ast_translator_free_path(sf->trans); sf->trans = NULL; } if (!sf->trans) { - if (!(sf->trans = ast_translator_build_path(sf->output_format, f->subclass))) { - ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n", ast_getformatname(f->subclass), + if (!(sf->trans = ast_translator_build_path(sf->output_format, f->subclass.codec))) { + ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n", ast_getformatname(f->subclass.codec), ast_getformatname(sf->output_format)); return 0; } - sf->format = f->subclass; + sf->format = f->subclass.codec; } if (!(begin_frame = ast_translate(sf->trans, f, 0))) { diff --git a/main/strcompat.c b/main/strcompat.c index 7f9d2813b..156809003 100644 --- a/main/strcompat.c +++ b/main/strcompat.c @@ -334,3 +334,55 @@ int getloadavg(double *list, int nelem) #endif /* linux */ #endif /* !HAVE_GETLOADAVG */ +#ifndef HAVE_NTOHLL +uint64_t ntohll(uint64_t net64) +{ +#if BYTE_ORDER == BIG_ENDIAN + return net64; +#elif BYTE_ORDER == LITTLE_ENDIAN + union { + unsigned char c[8]; + uint64_t u; + } number; + number.u = net64; + return + (((uint64_t) number.c[0]) << 0) | + (((uint64_t) number.c[1]) << 8) | + (((uint64_t) number.c[2]) << 16) | + (((uint64_t) number.c[3]) << 24) | + (((uint64_t) number.c[4]) << 32) | + (((uint64_t) number.c[5]) << 40) | + (((uint64_t) number.c[6]) << 48) | + (((uint64_t) number.c[7]) << 56); +#else + #error "Unknown byte order" +#endif +} +#endif + +#ifndef HAVE_HTONLL +uint64_t htonll(uint64_t host64) +{ +#if BYTE_ORDER == BIG_ENDIAN + return host64; +#elif BYTE_ORDER == LITTLE_ENDIAN + union { + unsigned char c[8]; + uint64_t u; + } number; + number.u = host64; + return + (((uint64_t) number.c[0]) << 0) | + (((uint64_t) number.c[1]) << 8) | + (((uint64_t) number.c[2]) << 16) | + (((uint64_t) number.c[3]) << 24) | + (((uint64_t) number.c[4]) << 32) | + (((uint64_t) number.c[5]) << 40) | + (((uint64_t) number.c[6]) << 48) | + (((uint64_t) number.c[7]) << 56); +#else + #error "Unknown byte order" +#endif +} +#endif + diff --git a/main/translate.c b/main/translate.c index a4a915291..fbe6e5852 100644 --- a/main/translate.c +++ b/main/translate.c @@ -70,14 +70,14 @@ static struct translator_path tr_matrix[MAX_FORMAT][MAX_FORMAT]; */ /*! \brief returns the index of the lowest bit set */ -static force_inline int powerof(unsigned int d) +static force_inline int powerof(format_t d) { - int x = ffs(d); + int x = ffsll(d); if (x) return x - 1; - ast_log(LOG_WARNING, "No bits set? %d\n", d); + ast_log(LOG_WARNING, "No bits set? %llu\n", (unsigned long long) d); return -1; } @@ -221,7 +221,7 @@ struct ast_frame *ast_trans_frameout(struct ast_trans_pvt *pvt, } f->frametype = AST_FRAME_VOICE; - f->subclass = 1 << (pvt->t->dstfmt); + f->subclass.codec = 1LL << (pvt->t->dstfmt); f->mallocd = 0; f->offset = AST_FRIENDLY_OFFSET; f->src = pvt->t->name; @@ -247,7 +247,7 @@ void ast_translator_free_path(struct ast_trans_pvt *p) } /*! \brief Build a chain of translators based upon the given source and dest formats */ -struct ast_trans_pvt *ast_translator_build_path(int dest, int source) +struct ast_trans_pvt *ast_translator_build_path(format_t dest, format_t source) { struct ast_trans_pvt *head = NULL, *tail = NULL; @@ -271,7 +271,8 @@ struct ast_trans_pvt *ast_translator_build_path(int dest, int source) return NULL; } if (!(cur = newpvt(t))) { - ast_log(LOG_WARNING, "Failed to build translator step from %d to %d\n", source, dest); + ast_log(LOG_WARNING, "Failed to build translator step from %s to %s\n", + ast_getformatname(source), ast_getformatname(dest)); if (head) ast_translator_free_path(head); AST_RWLIST_UNLOCK(&translators); @@ -327,7 +328,7 @@ struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f, path->nextout = f->delivery; } /* Predict next incoming sample */ - path->nextin = ast_tvadd(path->nextin, ast_samp2tv(f->samples, ast_format_rate(f->subclass))); + path->nextin = ast_tvadd(path->nextin, ast_samp2tv(f->samples, ast_format_rate(f->subclass.codec))); } delivery = f->delivery; for ( ; out && p ; p = p->next) { @@ -351,7 +352,7 @@ struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f, /* Predict next outgoing timestamp from samples in this frame. */ - path->nextout = ast_tvadd(path->nextout, ast_samp2tv(out->samples, ast_format_rate(out->subclass))); + path->nextout = ast_tvadd(path->nextout, ast_samp2tv(out->samples, ast_format_rate(out->subclass.codec))); } else { out->delivery = ast_tv(0, 0); ast_set2_flag(out, has_timing_info, AST_FRFLAG_HAS_TIMING_INFO); @@ -492,7 +493,7 @@ static void rebuild_matrix(int samples) tr_matrix[x][z].cost = newcost; tr_matrix[x][z].multistep = 1; ast_debug(3, "Discovered %d cost path from %s to %s, via %s\n", tr_matrix[x][z].cost, - ast_getformatname(1 << x), ast_getformatname(1 << z), ast_getformatname(1 << y)); + ast_getformatname(1LL << x), ast_getformatname(1LL << z), ast_getformatname(1LL << y)); changed++; } } @@ -550,7 +551,7 @@ static char *handle_cli_core_show_translation(struct ast_cli_entry *e, int cmd, ast_cli(a->fd, " Source Format (Rows) Destination Format (Columns)\n\n"); /* Get the length of the longest (usable?) codec name, so we know how wide the left side should be */ for (x = 0; x < SHOW_TRANS; x++) { - curlen = strlen(ast_getformatname(1 << (x))); + curlen = strlen(ast_getformatname(1LL << (x))); if (curlen > longest) longest = curlen; for (y = 0; y < SHOW_TRANS; y++) { @@ -562,15 +563,15 @@ static char *handle_cli_core_show_translation(struct ast_cli_entry *e, int cmd, for (x = -1; x < SHOW_TRANS; x++) { struct ast_str *out = ast_str_alloca(125); /*Go ahead and move to next iteration if dealing with an unknown codec*/ - if(x >= 0 && !strcmp(ast_getformatname(1 << (x)), "unknown")) + if(x >= 0 && !strcmp(ast_getformatname(1LL << (x)), "unknown")) continue; ast_str_set(&out, -1, " "); for (y = -1; y < SHOW_TRANS; y++) { /*Go ahead and move to next iteration if dealing with an unknown codec*/ - if (y >= 0 && !strcmp(ast_getformatname(1 << (y)), "unknown")) + if (y >= 0 && !strcmp(ast_getformatname(1LL << (y)), "unknown")) continue; if (y >= 0) - curlen = strlen(ast_getformatname(1 << (y))); + curlen = strlen(ast_getformatname(1LL << (y))); if (y >= 0 && magnitude[y] + 1 > curlen) { curlen = magnitude[y] + 1; } @@ -581,10 +582,10 @@ static char *handle_cli_core_show_translation(struct ast_cli_entry *e, int cmd, ast_str_append(&out, -1, "%*d", curlen + 1, tr_matrix[x][y].cost); } else if (x == -1 && y >= 0) { /* Top row - use a dynamic size */ - ast_str_append(&out, -1, "%*s", curlen + 1, ast_getformatname(1 << (y)) ); + ast_str_append(&out, -1, "%*s", curlen + 1, ast_getformatname(1LL << (y)) ); } else if (y == -1 && x >= 0) { /* Left column - use a static size. */ - ast_str_append(&out, -1, "%*s", longest, ast_getformatname(1 << (x)) ); + ast_str_append(&out, -1, "%*s", longest, ast_getformatname(1LL << (x)) ); } else if (x >= 0 && y >= 0) { /* Codec not supported */ ast_str_append(&out, -1, "%*s", curlen + 1, "-"); @@ -638,8 +639,8 @@ int __ast_register_translator(struct ast_translator *t, struct ast_module *mod) return -1; } if (t->dstfmt != powerof(AST_FORMAT_SLINEAR)) - ast_log(LOG_WARNING, "plc_samples %d format %x\n", - t->plc_samples, t->dstfmt); + ast_log(LOG_WARNING, "plc_samples %d format %llx\n", + t->plc_samples, (unsigned long long) t->dstfmt); } if (t->srcfmt >= MAX_FORMAT) { ast_log(LOG_WARNING, "Source format %s is larger than MAX_FORMAT\n", ast_getformatname(t->srcfmt)); @@ -669,7 +670,7 @@ int __ast_register_translator(struct ast_translator *t, struct ast_module *mod) ast_verb(2, "Registered translator '%s' from format %s to %s, cost %d\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), - ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt), t->cost); + ast_getformatname(1LL << t->srcfmt), ast_getformatname(1LL << t->dstfmt), t->cost); if (!added_cli) { ast_cli_register_multiple(cli_translate, ARRAY_LEN(cli_translate)); @@ -713,7 +714,7 @@ int ast_unregister_translator(struct ast_translator *t) AST_RWLIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) { if (u == t) { AST_RWLIST_REMOVE_CURRENT(list); - ast_verb(2, "Unregistered translator '%s' from format %s to %s\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt)); + ast_verb(2, "Unregistered translator '%s' from format %s to %s\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), ast_getformatname(1LL << t->srcfmt), ast_getformatname(1LL << t->dstfmt)); found = 1; break; } @@ -745,15 +746,15 @@ void ast_translator_deactivate(struct ast_translator *t) } /*! \brief Calculate our best translator source format, given costs, and a desired destination */ -int ast_translator_best_choice(int *dst, int *srcs) +format_t ast_translator_best_choice(format_t *dst, format_t *srcs) { int x,y; - int best = -1; - int bestdst = 0; - int cur, cursrc; + format_t best = -1; + format_t bestdst = 0; + format_t cur, cursrc; int besttime = INT_MAX; int beststeps = INT_MAX; - int common = ((*dst) & (*srcs)) & AST_FORMAT_AUDIO_MASK; /* are there common formats ? */ + format_t common = ((*dst) & (*srcs)) & AST_FORMAT_AUDIO_MASK; /* are there common formats ? */ if (common) { /* yes, pick one and return */ for (cur = 1, y = 0; y <= MAX_AUDIO_FORMAT; cur <<= 1, y++) { @@ -792,7 +793,7 @@ int ast_translator_best_choice(int *dst, int *srcs) } } -unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src) +unsigned int ast_translate_path_steps(format_t dest, format_t src) { unsigned int res = -1; @@ -814,12 +815,12 @@ unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src) return res; } -unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src) +format_t ast_translate_available_formats(format_t dest, format_t src) { - unsigned int res = dest; - unsigned int x; - unsigned int src_audio = src & AST_FORMAT_AUDIO_MASK; - unsigned int src_video = src & AST_FORMAT_VIDEO_MASK; + format_t res = dest; + format_t x; + format_t src_audio = src & AST_FORMAT_AUDIO_MASK; + format_t src_video = src & AST_FORMAT_VIDEO_MASK; /* if we don't have a source format, we just have to try all possible destination formats */ @@ -840,7 +841,11 @@ unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src known audio formats to determine whether there exists a translation path from the source format to the destination format. */ - for (x = 1; src_audio && (x & AST_FORMAT_AUDIO_MASK); x <<= 1) { + for (x = 1LL; src_audio && x > 0; x <<= 1) { + if (!(x & AST_FORMAT_AUDIO_MASK)) { + continue; + } + /* if this is not a desired format, nothing to do */ if (!(dest & x)) continue; @@ -866,7 +871,11 @@ unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src known video formats to determine whether there exists a translation path from the source format to the destination format. */ - for (; src_video && (x & AST_FORMAT_VIDEO_MASK); x <<= 1) { + for (x = 1LL; src_video && x > 0; x <<= 1) { + if (!(x & AST_FORMAT_VIDEO_MASK)) { + continue; + } + /* if this is not a desired format, nothing to do */ if (!(dest & x)) continue; diff --git a/main/udptl.c b/main/udptl.c index db2ae8f01..77fe8b157 100644 --- a/main/udptl.c +++ b/main/udptl.c @@ -368,7 +368,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, unsigned int len) /* Decode the secondary IFP packet */ //fprintf(stderr, "Secondary %d, len %d\n", seq_no - i, lengths[i - 1]); s->f[ifp_no].frametype = AST_FRAME_MODEM; - s->f[ifp_no].subclass = AST_MODEM_T38; + s->f[ifp_no].subclass.codec = AST_MODEM_T38; s->f[ifp_no].mallocd = 0; s->f[ifp_no].seqno = seq_no - i; @@ -470,7 +470,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, unsigned int len) if (repaired[l]) { //fprintf(stderr, "Fixed packet %d, len %d\n", j, l); s->f[ifp_no].frametype = AST_FRAME_MODEM; - s->f[ifp_no].subclass = AST_MODEM_T38; + s->f[ifp_no].subclass.codec = AST_MODEM_T38; s->f[ifp_no].mallocd = 0; s->f[ifp_no].seqno = j; @@ -491,7 +491,7 @@ static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, unsigned int len) if (seq_no >= s->rx_seq_no) { /* Decode the primary IFP packet */ s->f[ifp_no].frametype = AST_FRAME_MODEM; - s->f[ifp_no].subclass = AST_MODEM_T38; + s->f[ifp_no].subclass.codec = AST_MODEM_T38; s->f[ifp_no].mallocd = 0; s->f[ifp_no].seqno = seq_no; @@ -988,7 +988,7 @@ int ast_udptl_write(struct ast_udptl *s, struct ast_frame *f) return 0; if ((f->frametype != AST_FRAME_MODEM) || - (f->subclass != AST_MODEM_T38)) { + (f->subclass.codec != AST_MODEM_T38)) { ast_log(LOG_WARNING, "UDPTL can only send T.38 data.\n"); return -1; } -- cgit v1.2.3