FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/tee_common.c
Date: 2026-09-28 11:37:26
Exec Total Coverage
Lines: 0 27 0.0%
Functions: 0 1 0.0%
Branches: 0 12 0.0%

Line Branch Exec Source
1 /*
2 * Tee common code
3 * Copyright (c) 2012 Nicolas George
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with FFmpeg; if not, write to the Free Software * Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <string.h>
23
24 #include "libavutil/error.h"
25 #include "libavutil/log.h"
26 #include "libavutil/opt.h"
27
28 #include "tee_common.h"
29
30 static const char *const slave_opt_open = "[";
31 static const char *const slave_opt_close = "]";
32 static const char *const slave_opt_delim = ":]"; /* must have the close too */
33
34 ✗ int ff_tee_parse_slave_options(void *log, char *slave,
35 AVDictionary **options, char **filename)
36 {
37 const char *p;
38 char *key, *val;
39 int ret;
40
41 ✗ if (!strspn(slave, slave_opt_open)) {
42 ✗ *filename = slave;
43 ✗ return 0;
44 }
45 ✗ p = slave + 1;
46 ✗ if (strspn(p, slave_opt_close)) {
47 ✗ *filename = (char *)p + 1;
48 ✗ return 0;
49 }
50 while (1) {
51 ✗ ret = av_opt_get_key_value(&p, "=", slave_opt_delim, 0, &key, &val);
52 ✗ if (ret < 0) {
53 ✗ av_log(log, AV_LOG_ERROR, "No option found near \"%s\"\n", p);
54 ✗ goto fail;
55 }
56 ✗ ret = av_dict_set(options, key, val,
57 AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
58 ✗ if (ret < 0)
59 ✗ goto fail;
60 ✗ if (strspn(p, slave_opt_close))
61 ✗ break;
62 ✗ if (!*p) {
63 ✗ av_log(log, AV_LOG_ERROR, "Unterminated slave options in \"%s\"\n", slave);
64 ✗ ret = AVERROR(EINVAL);
65 ✗ goto fail;
66 }
67 ✗ p++;
68 }
69 ✗ *filename = (char *)p + 1;
70 ✗ return 0;
71
72 ✗ fail:
73 ✗ av_dict_free(options);
74 ✗ return ret;
75 }
76