AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags) { unsigned int i, j; if (!m) return NULL; if (prev) i = prev - m->elems + 1; else i = 0; for (; i < m->count; i++) { const char *s = m->elems[i].key; if (flags & AV_DICT_MATCH_CASE) for (j = 0; s[j] == key[j] && key[j]; j++) ; else for (j = 0; av_toupper(s[j]) == av_toupper(key[j]) && key[j]; j++) ; if (key[j]) continue; if (s[j] && !(flags & AV_DICT_IGNORE_SUFFIX)) continue; return &m->elems[i]; } return NULL; }
int av_stristart(const char *str, const char *pfx, const char **ptr) { while (*pfx && av_toupper((unsigned)*pfx) == av_toupper((unsigned)*str)) { pfx++; str++; } if (!*pfx && ptr) *ptr = str; return !*pfx; }
static int get_jss_cmd(char k) { int i; k = av_toupper(k); for (i = 0; i < FF_ARRAY_ELEMS(cmds); i++) if (k == cmds[i][0]) return i; return -1; }
static void old_print_object_footer(const char *name) { char *str, *p; if (!strcmp(name, "tags")) return; str = p = av_strdup(name); if (!str) return; while (*p) { *p = av_toupper(*p); p++; } avio_printf(probe_out, "[/%s]\n", str); av_freep(&str); }
static void jacosub_to_ass(AVCodecContext *avctx, AVBPrint *dst, const char *src) { int i, valign = 0, halign = 0; char c = av_toupper(*src); char directives[128] = {0}; /* extract the optional directives */ if ((c >= 'A' && c <= 'Z') || c == '[') { char *p = directives; char *pend = directives + sizeof(directives) - 1; do *p++ = av_toupper(*src++); while (*src && !jss_whitespace(*src) && p < pend); *p = 0; src = jss_skip_whitespace(src); } /* handle directives (TODO: handle more of them, and more reliably) */ if (strstr(directives, "VB")) valign = ALIGN_VB; else if (strstr(directives, "VM")) valign = ALIGN_VM; else if (strstr(directives, "VT")) valign = ALIGN_VT; if (strstr(directives, "JC")) halign = ALIGN_JC; else if (strstr(directives, "JL")) halign = ALIGN_JL; else if (strstr(directives, "JR")) halign = ALIGN_JR; if (valign || halign) { if (!valign) valign = ALIGN_VB; if (!halign) halign = ALIGN_JC; switch (valign | halign) { case ALIGN_VB | ALIGN_JL: av_bprintf(dst, "{\\an1}"); break; // bottom left case ALIGN_VB | ALIGN_JC: av_bprintf(dst, "{\\an2}"); break; // bottom center case ALIGN_VB | ALIGN_JR: av_bprintf(dst, "{\\an3}"); break; // bottom right case ALIGN_VM | ALIGN_JL: av_bprintf(dst, "{\\an4}"); break; // middle left case ALIGN_VM | ALIGN_JC: av_bprintf(dst, "{\\an5}"); break; // middle center case ALIGN_VM | ALIGN_JR: av_bprintf(dst, "{\\an6}"); break; // middle right case ALIGN_VT | ALIGN_JL: av_bprintf(dst, "{\\an7}"); break; // top left case ALIGN_VT | ALIGN_JC: av_bprintf(dst, "{\\an8}"); break; // top center case ALIGN_VT | ALIGN_JR: av_bprintf(dst, "{\\an9}"); break; // top right } } /* process timed line */ while (*src && *src != '\n') { /* text continue on the next line */ if (src[0] == '\\' && src[1] == '\n') { src += 2; while (jss_whitespace(*src)) src++; continue; } /* special character codes */ for (i = 0; i < FF_ARRAY_ELEMS(ass_codes_map); i++) { const char *from = ass_codes_map[i].from; const char *arg = ass_codes_map[i].arg; size_t codemap_len = strlen(from); if (!strncmp(src, from, codemap_len)) { src += codemap_len; src += ass_codes_map[i].func(dst, src, arg); break; } } /* simple char copy */ if (i == FF_ARRAY_ELEMS(ass_codes_map)) av_bprintf(dst, "%c", *src++); } av_bprintf(dst, "\r\n"); }
static int ffserver_parse_config_feed(FFServerConfig *config, const char *cmd, const char **p, FFServerStream **pfeed) { FFServerStream *feed; char arg[1024]; av_assert0(pfeed); feed = *pfeed; if (!av_strcasecmp(cmd, "<Feed")) { char *q; FFServerStream *s; feed = av_mallocz(sizeof(FFServerStream)); if (!feed) return AVERROR(ENOMEM); ffserver_get_arg(feed->filename, sizeof(feed->filename), p); q = strrchr(feed->filename, '>'); if (*q) *q = '\0'; for (s = config->first_feed; s; s = s->next) { if (!strcmp(feed->filename, s->filename)) ERROR("Feed '%s' already registered\n", s->filename); } feed->fmt = av_guess_format("ffm", NULL, NULL); /* default feed file */ snprintf(feed->feed_filename, sizeof(feed->feed_filename), "/tmp/%s.ffm", feed->filename); feed->feed_max_size = 5 * 1024 * 1024; feed->is_feed = 1; feed->feed = feed; /* self feeding :-) */ *pfeed = feed; return 0; } av_assert0(feed); if (!av_strcasecmp(cmd, "Launch")) { int i; feed->child_argv = av_mallocz_array(MAX_CHILD_ARGS, sizeof(char *)); if (!feed->child_argv) return AVERROR(ENOMEM); for (i = 0; i < MAX_CHILD_ARGS - 2; i++) { ffserver_get_arg(arg, sizeof(arg), p); if (!arg[0]) break; feed->child_argv[i] = av_strdup(arg); if (!feed->child_argv[i]) return AVERROR(ENOMEM); } feed->child_argv[i] = av_asprintf("http://%s:%d/%s", (config->http_addr.sin_addr.s_addr == INADDR_ANY) ? "127.0.0.1" : inet_ntoa(config->http_addr.sin_addr), ntohs(config->http_addr.sin_port), feed->filename); if (!feed->child_argv[i]) return AVERROR(ENOMEM); } else if (!av_strcasecmp(cmd, "ACL")) { ffserver_parse_acl_row(NULL, feed, NULL, *p, config->filename, config->line_num); } else if (!av_strcasecmp(cmd, "File") || !av_strcasecmp(cmd, "ReadOnlyFile")) { ffserver_get_arg(feed->feed_filename, sizeof(feed->feed_filename), p); feed->readonly = !av_strcasecmp(cmd, "ReadOnlyFile"); } else if (!av_strcasecmp(cmd, "Truncate")) { ffserver_get_arg(arg, sizeof(arg), p); /* assume Truncate is true in case no argument is specified */ if (!arg[0]) { feed->truncate = 1; } else { WARNING("Truncate N syntax in configuration file is deprecated. " "Use Truncate alone with no arguments.\n"); feed->truncate = strtod(arg, NULL); } } else if (!av_strcasecmp(cmd, "FileMaxSize")) { char *p1; double fsize; ffserver_get_arg(arg, sizeof(arg), p); p1 = arg; fsize = strtod(p1, &p1); switch(av_toupper(*p1)) { case 'K': fsize *= 1024; break; case 'M': fsize *= 1024 * 1024; break; case 'G': fsize *= 1024 * 1024 * 1024; break; default: ERROR("Invalid file size: '%s'\n", arg); break; } feed->feed_max_size = (int64_t)fsize; if (feed->feed_max_size < FFM_PACKET_SIZE*4) { ERROR("Feed max file size is too small. Must be at least %d.\n", FFM_PACKET_SIZE*4); } } else if (!av_strcasecmp(cmd, "</Feed>")) { *pfeed = NULL; } else { ERROR("Invalid entry '%s' inside <Feed></Feed>\n", cmd); } return 0; }