diff --git a/src/channels/chan_voicemngr.c b/src/channels/chan_voicemngr.c index 7551ff1b29ec9d64c6565a7bd2d4ddb95911f824..7c43e19ac7119367ad276dd52f2c921174bdbcd3 100644 --- a/src/channels/chan_voicemngr.c +++ b/src/channels/chan_voicemngr.c @@ -426,7 +426,7 @@ static enum VOICE_CODEC codec_string_to_enum(const char *data) return VOICE_CODEC_G711A; } -static const struct endpt_event event_map[] = { +static struct endpt_event event_map[] = { { .name = "DTMF0", .event = EVENT_DTMF0 }, { .name = "DTMF1", .event = EVENT_DTMF1 }, { .name = "DTMF2", .event = EVENT_DTMF2 }, @@ -1991,7 +1991,7 @@ static struct ast_channel *chan_voicemngr_new(struct chan_voicemngr_subchannel * struct ast_format_cap *format) { struct ast_channel *chan = NULL; - struct ast_format *fmt; + struct ast_format *fmt, *fmt_722 = ast_format_cache_get("g722"); struct ast_format_cap *caps; struct ast_str *buf = ast_str_alloca(256); @@ -2006,11 +2006,17 @@ static struct ast_channel *chan_voicemngr_new(struct chan_voicemngr_subchannel * ast_channel_tech_set(chan, cur_tech); if (format) { ast_format_cap_get_names(format, &buf); - ast_debug(1, "debug_tmp: requested codecs: %s. but the default codecs will be used instead\n", ast_str_buffer(buf)); + ast_debug(1, "debug_tmp: requested codecs: %s is used\n", ast_str_buffer(buf)); + ast_format_cap_append_from_cap(caps, format, AST_MEDIA_TYPE_UNKNOWN); + } else { + ast_format_cap_get_names(default_cap, &buf); + ast_debug(1, "debug_tmp: create a channel with default codecs: %s\n", ast_str_buffer(buf)); + ast_format_cap_append_from_cap(caps, default_cap, AST_MEDIA_TYPE_UNKNOWN); + if (subchan->parent->flags & VOICEMNGR_CHAN_FLAG_NARROW_BAND_ONLY) { + ast_debug(3, "Remove g722 since the terminal supports narrow band only\n"); + ast_format_cap_remove(caps, fmt_722); + } } - ast_format_cap_get_names(default_cap, &buf); - ast_debug(1, "debug_tmp: create a channel with default codecs: %s\n", ast_str_buffer(buf)); - ast_format_cap_append_from_cap(caps, default_cap, AST_MEDIA_TYPE_UNKNOWN); ast_channel_nativeformats_set(chan, caps); ao2_ref(caps, -1); @@ -2026,7 +2032,7 @@ static struct ast_channel *chan_voicemngr_new(struct chan_voicemngr_subchannel * if (subchan->call_direction != OUTGOING_CALL){ // set default codec for incoming call to avoid transcoding ast_channel_codec_set(chan, ast_format_get_name(fmt)); - ast_log(LOG_NOTICE, "set local codec to :%s \n", ast_channel_codec_get(chan)); + ast_debug(3, "set local codec to :%s \n", ast_channel_codec_get(chan)); } /* no need to call ast_setstate: the channel_alloc already did its job */ @@ -2040,7 +2046,8 @@ static struct ast_channel *chan_voicemngr_new(struct chan_voicemngr_subchannel * ast_channel_caller(chan)->ani.number.str = ast_strdup(subchan->parent->cid_num); } - ast_channel_caller(chan)->id.number.presentation = s->anonymouscallenable ? AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED : AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; + ast_channel_caller(chan)->id.number.presentation = s->anonymouscallenable ? + AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED : AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; ast_channel_caller(chan)->id.name.presentation = s->calleridnameenable; //Setup jitter buffer @@ -3605,7 +3612,7 @@ static void chan_voicemngr_process_event(const struct endpt_event *ev, const cha /* If the wide band codec is not supported by the terminal, indicate the associated PJSIP channel * support narrow band only. This will prevent the wide band code being chosen in the SDP re- * negotiation with the remote calling party. */ - if (/*TODO: sub->nb_only*/1) { + if (p->flags & VOICEMNGR_CHAN_FLAG_NARROW_BAND_ONLY) { struct ast_channel *chan_pjsip = ast_channel_get_by_name(ast_channel_linkedid(owner)); if (chan_pjsip && strncasecmp(ast_channel_name(chan_pjsip), "PJSIP", 5) == 0) { @@ -5064,11 +5071,11 @@ static int asterisk_event(struct ubus_context *ctx, struct ubus_object *obj, tb, blob_data(msg), blob_len(msg)); if (!tb[EVENT_LINE_ID] || !tb[EVENT_TYPE]) { - ast_log(LOG_DEBUG, "Wrong param: tb[EVENT_LINE_ID]: %p, tb[EVENT_TYPE]: %p\n", (void*)tb[EVENT_LINE_ID], (void*)tb[EVENT_TYPE]); + ast_log(LOG_DEBUG, "Wrong param: tb[EVENT_LINE_ID]: %p, tb[EVENT_TYPE]: %p\n", (void*)tb[EVENT_LINE_ID], + (void*)tb[EVENT_TYPE]); return UBUS_STATUS_INVALID_ARGUMENT; } line = blobmsg_get_u32(tb[EVENT_LINE_ID]); - event_type = blobmsg_get_string(tb[EVENT_TYPE]); event_data = blobmsg_get_string(tb[EVENT_DATA]);