From 14b34f42063004151aed8165fda81b094c9dbadc Mon Sep 17 00:00:00 2001 From: Yalu Zhang <yalu.zhang@iopsys.eu> Date: Wed, 15 May 2024 14:27:43 +0000 Subject: [PATCH] Support DTMF payload type change --- libvoice/voice-types.h | 2 ++ ubus.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/libvoice/voice-types.h b/libvoice/voice-types.h index 07a21fd..949cb96 100644 --- a/libvoice/voice-types.h +++ b/libvoice/voice-types.h @@ -41,11 +41,13 @@ enum voice_dtmf_mode { #define UBUS_DATA_CODEC_BIT 1 #define UBUS_DATA_PTIME_BIT (1<<1) #define UBUS_DATA_DTMF_BIT (1<<2) +#define UBUS_DATA_DTMF_PT_BIT (1<<3) struct config_update_struct { uint8_t mask; // 8 bit mask enum VOICE_CODEC codec; int ptime; enum voice_dtmf_mode dtmf_mode; + int dtmf_pt; // add more if needed }; diff --git a/ubus.c b/ubus.c index b651c6e..32e57a4 100644 --- a/ubus.c +++ b/ubus.c @@ -42,6 +42,7 @@ enum { CONNECTION_DATA_CODEC, CONNECTION_DATA_PTIME, CONNECTION_DATA_DTMF_MODE, + CONNECTION_DATA_DTMF_PT, __CONNECTION_MAX, }; @@ -147,6 +148,7 @@ static const struct blobmsg_policy request_connection_policy[] = { [CONNECTION_DATA_CODEC] = { .name = "codec", .type = BLOBMSG_TYPE_INT32 }, [CONNECTION_DATA_PTIME] = { .name = "ptime", .type = BLOBMSG_TYPE_INT32 }, [CONNECTION_DATA_DTMF_MODE] = { .name = "dtmf_mode", .type = BLOBMSG_TYPE_INT32 }, + [CONNECTION_DATA_DTMF_PT] = { .name = "dtmf_pt", .type = BLOBMSG_TYPE_INT32 }, }; static const struct blobmsg_policy request_count_policy[] = { @@ -631,6 +633,7 @@ static int ubus_request_connection(struct ubus_context *uctx, struct ubus_object .codec = VOICE_CODEC_G711A, .ptime = 0, .dtmf_mode = VOICE_DTMF_RFC_4733, + .dtmf_pt = 101, }; if (keys[CONNECTION_DATA_CODEC]){ @@ -645,6 +648,10 @@ static int ubus_request_connection(struct ubus_context *uctx, struct ubus_object data.dtmf_mode = blobmsg_get_u32(keys[CONNECTION_DATA_DTMF_MODE]); data.mask = data.mask|UBUS_DATA_DTMF_BIT; } + if (keys[CONNECTION_DATA_DTMF_PT]){ + data.dtmf_pt = blobmsg_get_u32(keys[CONNECTION_DATA_DTMF_PT]); + data.mask = data.mask|UBUS_DATA_DTMF_PT_BIT; + } ENDPT_DBG("line: %d connection_id: %d action: %s\n", line, id, action_str); if (strcmp("create", action_str) == 0) { -- GitLab