]> git.kaiwu.me - nginx.git/commitdiff
Mp4: fixed streaming if moov atom is at buffer edge.
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 18 Jun 2012 14:02:20 +0000 (14:02 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 18 Jun 2012 14:02:20 +0000 (14:02 +0000)
src/http/modules/ngx_http_mp4_module.c

index 80c7ed8534b968855bbda6885b923f82e1b2ce46..eb51ab2dcf2af6b40b60f14bd68b5dd2ddd7321a 100644 (file)
@@ -1024,6 +1024,10 @@ ngx_http_mp4_read_moov_atom(ngx_http_mp4_file_t *mp4, uint64_t atom_data_size)
                          + NGX_HTTP_MP4_MOOV_BUFFER_EXCESS * no_mdat;
     }
 
+    if (ngx_http_mp4_read(mp4, atom_data_size) != NGX_OK) {
+        return NGX_ERROR;
+    }
+
     mp4->trak.elts = &mp4->traks;
     mp4->trak.size = sizeof(ngx_http_mp4_trak_t);
     mp4->trak.nalloc = 2;
@@ -1044,6 +1048,12 @@ ngx_http_mp4_read_moov_atom(ngx_http_mp4_file_t *mp4, uint64_t atom_data_size)
         mp4->buffer_start = mp4->buffer_pos;
         mp4->buffer_size = NGX_HTTP_MP4_MOOV_BUFFER_EXCESS;
 
+        if (mp4->buffer_start + mp4->buffer_size > mp4->buffer_end) {
+            mp4->buffer = NULL;
+            mp4->buffer_pos = NULL;
+            mp4->buffer_end = NULL;
+        }
+
     } else {
         /* skip atoms after moov atom */
         mp4->offset = mp4->end;