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

Frédéric Yhuel fyhuel at viotech.net
Tue May 22 17:11:09 CEST 2012


---
 modules/demux/mp4/libmp4.c |   30 ++++++++++++++++++++++++++++++
 modules/demux/mp4/libmp4.h |    1 +
 2 files changed, 31 insertions(+)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 1058e8f..4c65b93 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -3422,6 +3422,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_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 */
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index cf7f779..0775b2a 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1458,6 +1458,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.
  *****************************************************************************
-- 
1.7.9.5




More information about the vlc-devel mailing list