1 /*
2 * Copyright (c) 2012 Nicolas George
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <string.h>
25
32
34 {
36 const char *
data, *opt, *next;
37 char *ddata;
38 int ret, base64 = 0;
39 size_t in_size;
40
41 /* data:content/type[;base64],payload */
42
44 data = strchr(uri, ',');
45 if (!data) {
48 }
49 opt = uri;
50 while (opt < data) {
52 if (opt == uri) {
53 if (!memchr(opt, '/', next - opt)) { /* basic validity check */
55 (int)(next - opt), opt);
57 }
59 (int)(next - opt), opt);
60 } else {
62 base64 = 1;
63 } else {
65 (int)(next - opt), opt);
66 }
67 }
68 opt = next + 1;
69 }
70
71 data++;
72 in_size = strlen(data);
73 if (base64) {
74 size_t out_size = 3 * (in_size / 4) + 1;
75
76 if (out_size > INT_MAX || !(ddata =
av_malloc(out_size)))
81 return ret;
82 }
85 } else {
88 }
89 return 0;
90 }
91
93 {
95
97 return 0;
98 }
99
101 {
103
107 memcpy(buf, dc->
data + dc->
pos, size);
110 }
111
118 };