[vlc-commits] libmp4: Add function MP4_BoxGetSmooBox()

Frédéric Yhuel git at videolan.org
Wed Jul 18 17:08:08 CEST 2012


vlc | branch: master | Frédéric Yhuel <fyhuel at viotech.net> | Wed Jul 18 16:52:35 2012 +0200| [bf1ee347ed9069c4b4f752f553b9577b21b7edd5] | committer: Jean-Baptiste Kempf

libmp4: Add function MP4_BoxGetSmooBox()

also modify MP4_BoxGetNextChunk() so that a initialization
segment which has been put between two chunks is properly handled.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bf1ee347ed9069c4b4f752f553b9577b21b7edd5
---

 modules/demux/mp4/libmp4.c |   51 ++++++++++++++++++++++++++++++++++++++++++++
 modules/demux/mp4/libmp4.h |    1 +
 2 files changed, 52 insertions(+)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 03da565..81fc6b0 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -3440,6 +3440,39 @@ void MP4_BoxFree( stream_t *s, MP4_Box_t *p_box )
     free( p_box );
 }
 
+/* SmooBox is a very simple MP4 box, VLC specific, used only for the stream_filter to
+ * send information to the demux. SmooBox is actually a simplified moov box (we wanted
+ * to avoid the hassle of building a moov box at the stream_filter level) */
+MP4_Box_t *MP4_BoxGetSmooBox( stream_t *s )
+{
+    /* p_chunk is a virtual root container for the smoo box */
+    MP4_Box_t *p_chunk;
+    MP4_Box_t *p_smoo;
+
+    p_chunk = calloc( 1, sizeof( MP4_Box_t ) );
+    if( unlikely( p_chunk == NULL ) )
+        return NULL;
+
+    p_chunk->i_type = ATOM_root;
+    p_chunk->i_shortsize = 1;
+
+    p_smoo = MP4_ReadBox( s, p_chunk );
+    if( !p_smoo || p_smoo->i_type != ATOM_uuid || CmpUUID( &p_smoo->i_uuid, &SmooBoxUUID ) )
+    {
+        msg_Warn( s, "no smoo box found!");
+        goto error;
+    }
+
+    p_chunk->p_first = p_smoo;
+    p_chunk->p_last = p_smoo;
+
+    return p_chunk;
+
+error:
+    free( p_chunk );
+    return NULL;
+}
+
 MP4_Box_t *MP4_BoxGetInitFrag( stream_t *s )
 {
     /* p_chunk is a virtual root container for the ftyp and moov boxes */
@@ -3497,6 +3530,24 @@ MP4_Box_t *MP4_BoxGetNextChunk( stream_t *s )
     MP4_Box_t *p_chunk;
     MP4_Box_t *p_moof = NULL;
     MP4_Box_t *p_sidx = NULL;
+    MP4_Box_t *p_tmp_box = NULL;
+
+    p_tmp_box = calloc( 1, sizeof( MP4_Box_t ) );
+    if( unlikely( p_tmp_box == NULL ) )
+        return NULL;
+
+    /* We might get a ftyp box or a SmooBox */
+    MP4_ReadBoxCommon( s, p_tmp_box );
+
+    if( (p_tmp_box->i_type == ATOM_uuid && !CmpUUID( &p_tmp_box->i_uuid, &SmooBoxUUID )) )
+    {
+        return MP4_BoxGetSmooBox( s );
+    }
+    else if( p_tmp_box->i_type == ATOM_ftyp )
+    {
+        return MP4_BoxGetInitFrag( s );
+    }
+    free( p_tmp_box );
 
     p_chunk = calloc( 1, sizeof( MP4_Box_t ) );
     if( unlikely( p_chunk == NULL ) )
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index c1f72fd..0883e9d 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1476,6 +1476,7 @@ static const UUID_t StraBoxUUID = {
                 { 0xb0, 0x3e, 0xf7, 0x70, 0x33, 0xbd, 0x4b, 0xac,
                   0x96, 0xc7, 0xbf, 0x25, 0xf9, 0x7e, 0x24, 0x47 } };
 
+MP4_Box_t *MP4_BoxGetSmooBox( stream_t * );
 /*****************************************************************************
  * MP4_BoxGetInitFrag : Parse the initialization segment.
  *****************************************************************************



More information about the vlc-commits mailing list