- if (!(mflags & 0x40)) {
- /**
- * If 0x40 is not set, the len_off field specifies an offset of this
- * packet's payload data in the complete (reassembled) ASF packet.
- * This is used to spread one ASF packet over multiple RTP packets.
- */
- if (asf->pktbuf && len_off != url_ftell(asf->pktbuf)) {
- uint8_t *p;
- url_close_dyn_buf(asf->pktbuf, &p);
+
+ ffio_init_context(pb, buf, len, 0, NULL, NULL, NULL, NULL);
+
+ while (avio_tell(pb) + 4 < len) {
+ int start_off = avio_tell(pb);
+
+ mflags = avio_r8(pb);
+ len_off = avio_rb24(pb);
+ if (mflags & 0x20) /**< relative timestamp */
+ avio_skip(pb, 4);
+ if (mflags & 0x10) /**< has duration */
+ avio_skip(pb, 4);
+ if (mflags & 0x8) /**< has location ID */
+ avio_skip(pb, 4);
+ off = avio_tell(pb);
+
+ if (!(mflags & 0x40)) {
+ /**
+ * If 0x40 is not set, the len_off field specifies an offset
+ * of this packet's payload data in the complete (reassembled)
+ * ASF packet. This is used to spread one ASF packet over
+ * multiple RTP packets.
+ */
+ if (asf->pktbuf && len_off != avio_tell(asf->pktbuf)) {
+ ffio_free_dyn_buf(&asf->pktbuf);
+ }
+ if (!len_off && !asf->pktbuf &&
+ (res = avio_open_dyn_buf(&asf->pktbuf)) < 0)
+ return res;
+ if (!asf->pktbuf)
+ return AVERROR(EIO);
+
+ avio_write(asf->pktbuf, buf + off, len - off);
+ avio_skip(pb, len - off);
+ if (!(flags & RTP_FLAG_MARKER))
+ return -1;
+ out_len = avio_close_dyn_buf(asf->pktbuf, &asf->buf);