diff --git a/dmtree/tr104/common.c b/dmtree/tr104/common.c index 963704ee..cf75574f 100644 --- a/dmtree/tr104/common.c +++ b/dmtree/tr104/common.c @@ -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; diff --git a/dmtree/tr104/servicesvoiceservicesip.c b/dmtree/tr104/servicesvoiceservicesip.c index 2b5d9e8e..d91469c0 100644 --- a/dmtree/tr104/servicesvoiceservicesip.c +++ b/dmtree/tr104/servicesvoiceservicesip.c @@ -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);