changeset 3170:3c56f53f437b libavformat

support fragments when non streamable
author bcoudurier
date Fri, 21 Mar 2008 13:43:19 +0000
parents 8ae50c221ae6
children b6d9c48d0dfb
files mov.c
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mov.c	Fri Mar 21 13:40:23 2008 +0000
+++ b/mov.c	Fri Mar 21 13:43:19 2008 +0000
@@ -1727,7 +1727,7 @@
     AVIndexEntry *sample = 0;
     int64_t best_dts = INT64_MAX;
     int i;
-
+ retry:
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st = s->streams[i];
         MOVStreamContext *msc = st->priv_data;
@@ -1747,8 +1747,15 @@
             }
         }
     }
-    if (!sample)
-        return -1;
+    if (!sample) {
+        mov->found_mdat = 0;
+        if (!url_is_streamed(s->pb) ||
+            mov_read_default(mov, s->pb, (MOV_atom_t){ 0, 0, INT64_MAX }) < 0 ||
+            url_feof(s->pb))
+            return -1;
+        dprintf(s, "read fragments, offset 0x%llx\n", url_ftell(s->pb));
+        goto retry;
+    }
     /* must be done just before reading, to avoid infinite loop on sample */
     sc->current_sample++;
     if (url_fseek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {