Voice: fix the Get/Set value of CodecList parameter

This commit is contained in:
Amin Ben Ramdhane 2020-09-29 18:51:36 +01:00
parent bbce1a47af
commit 240b7b7488
2 changed files with 11 additions and 17 deletions

View file

@ -336,6 +336,11 @@ __ret:
const char *get_codec_uci_name(const char *codec)
{
if (codec && *codec) {
// Initialize supported codecs if it has not been done
if (codecs_num <= 0)
init_supported_codecs();
for (int i = 0; i < codecs_num; i++) {
if (!strcasecmp(supported_codecs[i].codec, codec))
return supported_codecs[i].uci_name;
@ -349,6 +354,11 @@ const char *get_codec_uci_name(const char *codec)
const char *get_codec_name(const char *codec_profile)
{
if (codec_profile && *codec_profile) {
// Initialize supported codecs if it has not been done
if (codecs_num <= 0)
init_supported_codecs();
for (int i = 0; i < codecs_num; i++) {
if (!strcasecmp(supported_codecs[i].uci_name, codec_profile))
return supported_codecs[i].codec;

View file

@ -910,22 +910,6 @@ static int get_ServicesVoiceServiceSIPNetwork_CodecList(char *refparam, struct d
return 0;
}
static int del_codec_list(struct uci_section * section)
{
char *codec_list = NULL, *token, *saveptr;
dmuci_get_value_by_section_string(section, "codecs", &codec_list);
if (codec_list && *codec_list) {
for (token = strtok_r(codec_list, ", ", &saveptr); token; token = strtok_r(NULL, ", ", &saveptr)) {
dmuci_del_list_value_by_section(section, "codecs", token);
}
dmfree(codec_list);
}
return 0;
}
static int set_ServicesVoiceServiceSIPNetwork_CodecList(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int res = 0;
@ -948,7 +932,7 @@ static int set_ServicesVoiceServiceSIPNetwork_CodecList(char *refparam, struct d
case VALUESET:
if (value) {
// Empty the existing code list first
del_codec_list((struct uci_section *)data);
dmuci_set_value_by_section((struct uci_section *)data, "codecs", "");
if (*value) {
codec_list = dmstrdup(value);