[vlc-devel] [PATCH 2/3] libmp4: Add function MP4_BoxGetSmooBox()

Frédéric Yhuel fyhuel at viotech.net
Tue Apr 24 10:22:29 CEST 2012


Also, some changes in MP4_BoxGetNextChunk() so that a 'smoo' box which
has been sent between two chunks is properly handled.
---
 modules/demux/mp4/libmp4.c |   41 ++++++++++++++++++++++++++++++++++++++++-
 modules/demux/mp4/libmp4.h |    1 +
 2 files changed, 41 insertions(+), 1 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index e0cffb4..040d8de 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -3415,6 +3415,36 @@ void MP4_BoxFree( stream_t *s, MP4_Box_t *p_box )
     free( p_box );
 }
 
+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_smoo )
+    {
+        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 */
@@ -3472,11 +3502,20 @@ 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_trash = NULL;
+
+    p_trash = calloc( 1, sizeof( MP4_Box_t ) );
+    if( unlikely( p_trash == NULL ) )
+        return NULL;
+    MP4_ReadBoxCommon( s, p_trash );
+    if( p_trash->i_type == ATOM_smoo )
+        return p_trash;
+    else
+        free( p_trash );
 
     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;
 
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 6e8a1d4..50359a1 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1453,6 +1453,7 @@ static const UUID_t TfxdBoxUUID = {
                   0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2 } };
 
 
+MP4_Box_t *MP4_BoxGetSmooBox( stream_t * );
 /*****************************************************************************
  * MP4_BoxGetInitFrag : Parse the initialization segment.
  *****************************************************************************
-- 
1.7.5.4




More information about the vlc-devel mailing list