}
return r;
}
+
+/*
+ *
+ */
+int
+htsmsg_is_string_in_list(htsmsg_t *list, const char *str)
+{
+ const char *s;
+ htsmsg_field_t *f;
+
+ if (list == NULL || !list->hm_islist)
+ return 0;
+ HTSMSG_FOREACH(f, list) {
+ s = htsmsg_field_get_str(f);
+ if (s == NULL)
+ continue;
+ if (!strcasecmp(s, str))
+ return 1;
+ }
+ return 0;
+}
htsmsg_t *htsmsg_create_key_val(const char *key, const char *val);
+int htsmsg_is_string_in_list(htsmsg_t *list, const char *str);
+
/**
*
*/
const char *src_codecs)
{
const char *txtname;
- char *codecs, *str, *token, *saveptr;
+ htsmsg_t *list;
+ int r;
/* if the source codec is in the list, do the stream copy only */
if (src_codecs && *src_codecs != '\0' && *src_codecs != '-') {
- txtname = streaming_component_type2txt(ssc->ssc_type);
- if (txtname == NULL)
- goto cont;
- codecs = tvh_strdupa(src_codecs);
- if (codecs == NULL)
- goto cont;
- for (str = codecs; ; str = NULL) {
- token = strtok_r(str, " ,|;" , &saveptr);
- if (token == NULL)
- break;
- if (!strcasecmp(token, txtname))
+ list = htsmsg_csv_2_list(src_codecs, ',');
+ if (list) {
+ txtname = streaming_component_type2txt(ssc->ssc_type);
+ r = htsmsg_is_string_in_list(list, txtname);
+ htsmsg_destroy(list);
+ if (r)
goto cont;
}
return 1;