MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / amf_parse_object

Function amf_parse_object

libavformat/flvdec.c:121–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, int64_t max_pos, int depth) {
122 AVCodecContext *acodec, *vcodec;
123 ByteIOContext *ioc;
124 AMFDataType amf_type;
125 char str_val[256];
126 double num_val;
127
128 num_val = 0;
129 ioc = s->pb;
130
131 amf_type = get_byte(ioc);
132
133 switch(amf_type) {
134 case AMF_DATA_TYPE_NUMBER:
135 num_val = av_int2dbl(get_be64(ioc)); break;
136 case AMF_DATA_TYPE_BOOL:
137 num_val = get_byte(ioc); break;
138 case AMF_DATA_TYPE_STRING:
139 if(amf_get_string(ioc, str_val, sizeof(str_val)) < 0)
140 return -1;
141 break;
142 case AMF_DATA_TYPE_OBJECT: {
143 unsigned int keylen;
144
145 while(url_ftell(ioc) < max_pos - 2 && (keylen = get_be16(ioc))) {
146 url_fskip(ioc, keylen); //skip key string
147 if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
148 return -1; //if we couldn't skip, bomb out.
149 }
150 if(get_byte(ioc) != AMF_END_OF_OBJECT)
151 return -1;
152 }
153 break;
154 case AMF_DATA_TYPE_NULL:
155 case AMF_DATA_TYPE_UNDEFINED:
156 case AMF_DATA_TYPE_UNSUPPORTED:
157 break; //these take up no additional space
158 case AMF_DATA_TYPE_MIXEDARRAY:
159 url_fskip(ioc, 4); //skip 32-bit max array index
160 while(url_ftell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) {
161 //this is the only case in which we would want a nested parse to not skip over the object
162 if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0)
163 return -1;
164 }
165 if(get_byte(ioc) != AMF_END_OF_OBJECT)
166 return -1;
167 break;
168 case AMF_DATA_TYPE_ARRAY: {
169 unsigned int arraylen, i;
170
171 arraylen = get_be32(ioc);
172 for(i = 0; i < arraylen && url_ftell(ioc) < max_pos - 1; i++) {
173 if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
174 return -1; //if we couldn't skip, bomb out.
175 }
176 }
177 break;
178 case AMF_DATA_TYPE_DATE:

Callers 1

flv_read_metabodyFunction · 0.85

Calls 10

av_int2dblFunction · 0.85
get_be64Function · 0.85
amf_get_stringFunction · 0.85
url_ftellFunction · 0.85
get_be16Function · 0.85
url_fskipFunction · 0.85
get_be32Function · 0.85
av_strlcpyFunction · 0.85
av_metadata_set2Function · 0.85
get_byteFunction · 0.70

Tested by

no test coverage detected