FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/tee_common.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 0 23 0.0%
Functions: 0 1 0.0%
Branches: 0 10 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/log.h"
25 #include "libavutil/opt.h"
26
27 #include "tee_common.h"
28
29 static const char *const slave_opt_open = "[";
30 static const char *const slave_opt_close = "]";
31 static const char *const slave_opt_delim = ":]"; /* must have the close too */
32
33 int ff_tee_parse_slave_options(void *log, char *slave,
34 AVDictionary **options, char **filename)
35 {
36 const char *p;
37 char *key, *val;
38 int ret;
39
40 if (!strspn(slave, slave_opt_open)) {
41 *filename = slave;
42 return 0;
43 }
44 p = slave + 1;
45 if (strspn(p, slave_opt_close)) {
46 *filename = (char *)p + 1;
47 return 0;
48 }
49 while (1) {
50 ret = av_opt_get_key_value(&p, "=", slave_opt_delim, 0, &key, &val);
51 if (ret < 0) {
52 av_log(log, AV_LOG_ERROR, "No option found near \"%s\"\n", p);
53 goto fail;
54 }
55 ret = av_dict_set(options, key, val,
56 AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
57 if (ret < 0)
58 goto fail;
59 if (strspn(p, slave_opt_close))
60 break;
61 p++;
62 }
63 *filename = (char *)p + 1;
64 return 0;
65
66 fail:
67 av_dict_free(options);
68 return ret;
69 }
70