Originally committed as revision 24390 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -178,60 +178,61 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, |
| 178 | 178 |
init_put_byte(pb, buf, len, 0, NULL, NULL, NULL, NULL); |
| 179 | 179 |
|
| 180 | 180 |
while (url_ftell(pb) + 4 < len) {
|
| 181 |
- int start_off = url_ftell(pb); |
|
| 182 |
- |
|
| 183 |
- mflags = get_byte(pb); |
|
| 184 |
- if (mflags & 0x80) |
|
| 185 |
- flags |= RTP_FLAG_KEY; |
|
| 186 |
- len_off = get_be24(pb); |
|
| 187 |
- if (mflags & 0x20) /**< relative timestamp */ |
|
| 188 |
- url_fskip(pb, 4); |
|
| 189 |
- if (mflags & 0x10) /**< has duration */ |
|
| 190 |
- url_fskip(pb, 4); |
|
| 191 |
- if (mflags & 0x8) /**< has location ID */ |
|
| 192 |
- url_fskip(pb, 4); |
|
| 193 |
- off = url_ftell(pb); |
|
| 194 |
- |
|
| 195 |
- if (!(mflags & 0x40)) {
|
|
| 196 |
- /** |
|
| 197 |
- * If 0x40 is not set, the len_off field specifies an offset of this |
|
| 198 |
- * packet's payload data in the complete (reassembled) ASF packet. |
|
| 199 |
- * This is used to spread one ASF packet over multiple RTP packets. |
|
| 200 |
- */ |
|
| 201 |
- if (asf->pktbuf && len_off != url_ftell(asf->pktbuf)) {
|
|
| 202 |
- uint8_t *p; |
|
| 203 |
- url_close_dyn_buf(asf->pktbuf, &p); |
|
| 181 |
+ int start_off = url_ftell(pb); |
|
| 182 |
+ |
|
| 183 |
+ mflags = get_byte(pb); |
|
| 184 |
+ if (mflags & 0x80) |
|
| 185 |
+ flags |= RTP_FLAG_KEY; |
|
| 186 |
+ len_off = get_be24(pb); |
|
| 187 |
+ if (mflags & 0x20) /**< relative timestamp */ |
|
| 188 |
+ url_fskip(pb, 4); |
|
| 189 |
+ if (mflags & 0x10) /**< has duration */ |
|
| 190 |
+ url_fskip(pb, 4); |
|
| 191 |
+ if (mflags & 0x8) /**< has location ID */ |
|
| 192 |
+ url_fskip(pb, 4); |
|
| 193 |
+ off = url_ftell(pb); |
|
| 194 |
+ |
|
| 195 |
+ if (!(mflags & 0x40)) {
|
|
| 196 |
+ /** |
|
| 197 |
+ * If 0x40 is not set, the len_off field specifies an offset |
|
| 198 |
+ * of this packet's payload data in the complete (reassembled) |
|
| 199 |
+ * ASF packet. This is used to spread one ASF packet over |
|
| 200 |
+ * multiple RTP packets. |
|
| 201 |
+ */ |
|
| 202 |
+ if (asf->pktbuf && len_off != url_ftell(asf->pktbuf)) {
|
|
| 203 |
+ uint8_t *p; |
|
| 204 |
+ url_close_dyn_buf(asf->pktbuf, &p); |
|
| 205 |
+ asf->pktbuf = NULL; |
|
| 206 |
+ av_free(p); |
|
| 207 |
+ } |
|
| 208 |
+ if (!len_off && !asf->pktbuf && |
|
| 209 |
+ (res = url_open_dyn_buf(&asf->pktbuf)) < 0) |
|
| 210 |
+ return res; |
|
| 211 |
+ if (!asf->pktbuf) |
|
| 212 |
+ return AVERROR(EIO); |
|
| 213 |
+ |
|
| 214 |
+ put_buffer(asf->pktbuf, buf + off, len - off); |
|
| 215 |
+ url_fskip(pb, len - off); |
|
| 216 |
+ if (!(flags & RTP_FLAG_MARKER)) |
|
| 217 |
+ return -1; |
|
| 218 |
+ out_len = url_close_dyn_buf(asf->pktbuf, &asf->buf); |
|
| 204 | 219 |
asf->pktbuf = NULL; |
| 205 |
- av_free(p); |
|
| 220 |
+ } else {
|
|
| 221 |
+ /** |
|
| 222 |
+ * If 0x40 is set, the len_off field specifies the length of |
|
| 223 |
+ * the next ASF packet that can be read from this payload |
|
| 224 |
+ * data alone. This is commonly the same as the payload size, |
|
| 225 |
+ * but could be less in case of packet splitting (i.e. |
|
| 226 |
+ * multiple ASF packets in one RTP packet). |
|
| 227 |
+ */ |
|
| 228 |
+ |
|
| 229 |
+ int cur_len = start_off + len_off - off; |
|
| 230 |
+ int prev_len = out_len; |
|
| 231 |
+ out_len += cur_len; |
|
| 232 |
+ asf->buf = av_realloc(asf->buf, out_len); |
|
| 233 |
+ memcpy(asf->buf + prev_len, buf + off, cur_len); |
|
| 234 |
+ url_fskip(pb, cur_len); |
|
| 206 | 235 |
} |
| 207 |
- if (!len_off && !asf->pktbuf && |
|
| 208 |
- (res = url_open_dyn_buf(&asf->pktbuf)) < 0) |
|
| 209 |
- return res; |
|
| 210 |
- if (!asf->pktbuf) |
|
| 211 |
- return AVERROR(EIO); |
|
| 212 |
- |
|
| 213 |
- put_buffer(asf->pktbuf, buf + off, len - off); |
|
| 214 |
- url_fskip(pb, len - off); |
|
| 215 |
- if (!(flags & RTP_FLAG_MARKER)) |
|
| 216 |
- return -1; |
|
| 217 |
- out_len = url_close_dyn_buf(asf->pktbuf, &asf->buf); |
|
| 218 |
- asf->pktbuf = NULL; |
|
| 219 |
- } else {
|
|
| 220 |
- /** |
|
| 221 |
- * If 0x40 is set, the len_off field specifies the length of the |
|
| 222 |
- * next ASF packet that can be read from this payload data alone. |
|
| 223 |
- * This is commonly the same as the payload size, but could be |
|
| 224 |
- * less in case of packet splitting (i.e. multiple ASF packets in |
|
| 225 |
- * one RTP packet). |
|
| 226 |
- */ |
|
| 227 |
- |
|
| 228 |
- int cur_len = start_off + len_off - off; |
|
| 229 |
- int prev_len = out_len; |
|
| 230 |
- out_len += cur_len; |
|
| 231 |
- asf->buf = av_realloc(asf->buf, out_len); |
|
| 232 |
- memcpy(asf->buf + prev_len, buf + off, cur_len); |
|
| 233 |
- url_fskip(pb, cur_len); |
|
| 234 |
- } |
|
| 235 | 236 |
} |
| 236 | 237 |
|
| 237 | 238 |
init_packetizer(pb, asf->buf, out_len); |