| 119 | } |
| 120 | |
| 121 | static 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: |
no test coverage detected