[vlc-devel] [PATCH 1/5] libmp4: Parse StraBox and SmooBox
Frédéric Yhuel
fyhuel at viotech.net
Tue May 22 17:11:08 CEST 2012
These are VLC specific boxes designed for communication between the MP4
demux and the stream_filter Smooth Streaming module. I chose a very
simple design, which may change in the future.
---
modules/demux/mp4/libmp4.c | 55 ++++++++++++++++++++++++++++++++++++++++++++
modules/demux/mp4/libmp4.h | 26 +++++++++++++++++++++
2 files changed, 81 insertions(+)
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 912533f..1058e8f 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -475,12 +475,63 @@ static void MP4_FreeBox_tfrf( MP4_Box_t *p_box )
FREENULL( p_box->data.p_tfrf->p_tfrf_data_fields );
}
+static int MP4_ReadBox_stra( stream_t *p_stream, MP4_Box_t *p_box )
+{
+ MP4_READBOX_ENTER( MP4_Box_data_stra_t );
+ MP4_Box_data_stra_t *p_stra = p_box->data.p_stra;
+
+ uint8_t i_reserved;
+ MP4_GET1BYTE( p_stra->i_es_cat );
+ MP4_GET1BYTE( i_reserved );
+ MP4_GET2BYTES( p_stra->i_track_ID );
+
+ MP4_GET4BYTES( p_stra->i_timescale );
+ MP4_GET4BYTES( p_stra->FourCC );
+ MP4_GET4BYTES( p_stra->Bitrate );
+ MP4_GET4BYTES( p_stra->MaxWidth );
+ MP4_GET4BYTES( p_stra->MaxHeight );
+ MP4_GET4BYTES( p_stra->SamplingRate );
+ MP4_GET4BYTES( p_stra->Channels );
+ MP4_GET4BYTES( p_stra->BitsPerSample );
+ MP4_GET4BYTES( p_stra->PacketSize );
+ MP4_GET4BYTES( p_stra->AudioTag );
+
+ MP4_GET1BYTE( i_reserved );
+ MP4_GET1BYTE( i_reserved );
+ MP4_GET1BYTE( i_reserved );
+ uint8_t codec_data_length;
+ MP4_GET1BYTE( codec_data_length );
+ p_stra->CodecPrivateData = malloc( codec_data_length + 1);
+ if( unlikely( p_stra->CodecPrivateData == NULL ) )
+ goto error;
+ MP4_GETSTRINGZ( p_stra->CodecPrivateData );
+
+#ifdef MP4_VERBOSE
+ msg_Dbg( p_stream, "es_cat is %"PRIu8", birate is %"PRIu32", "\
+ "CodecPrivateData is %s", p_stra->i_es_cat,
+ p_stra->Bitrate, p_stra->CodecPrivateData );
+#endif
+
+ MP4_READBOX_EXIT( 1 );
+error:
+ MP4_READBOX_EXIT( 0 );
+}
+
+static void MP4_FreeBox_stra( MP4_Box_t *p_box )
+{
+ FREENULL( p_box->data.p_stra->CodecPrivateData );
+}
+
static int MP4_ReadBox_uuid( stream_t *p_stream, MP4_Box_t *p_box )
{
if( !CmpUUID( &p_box->i_uuid, &TfrfBoxUUID ) )
return MP4_ReadBox_tfrf( p_stream, p_box );
if( !CmpUUID( &p_box->i_uuid, &TfxdBoxUUID ) )
return MP4_ReadBox_tfxd( p_stream, p_box );
+ if( !CmpUUID( &p_box->i_uuid, &SmooBoxUUID ) )
+ return MP4_ReadBoxContainer( p_stream, p_box );
+ if( !CmpUUID( &p_box->i_uuid, &StraBoxUUID ) )
+ return MP4_ReadBox_stra( p_stream, p_box );
msg_Warn( p_stream, "Unknown uuid type box" );
return 1;
@@ -492,6 +543,10 @@ static void MP4_FreeBox_uuid( MP4_Box_t *p_box )
return MP4_FreeBox_tfrf( p_box );
if( !CmpUUID( &p_box->i_uuid, &TfxdBoxUUID ) )
return MP4_FreeBox_Common( p_box );
+ if( !CmpUUID( &p_box->i_uuid, &SmooBoxUUID ) )
+ return MP4_FreeBox_Common( p_box );
+ if( !CmpUUID( &p_box->i_uuid, &StraBoxUUID ) )
+ return MP4_FreeBox_stra( p_box );
}
static int MP4_ReadBox_sidx( stream_t *p_stream, MP4_Box_t *p_box )
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index c25bcff..cf7f779 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -1112,6 +1112,24 @@ typedef struct
uint8_t *p_sample_number;
} MP4_Box_data_tfra_t;
+typedef struct
+{
+ uint32_t i_timescale;
+ uint8_t i_es_cat;
+ uint16_t i_track_ID;
+
+ uint32_t FourCC;
+ uint32_t Bitrate;
+ uint32_t MaxWidth;
+ uint32_t MaxHeight;
+ uint32_t SamplingRate;
+ uint32_t Channels;
+ uint32_t BitsPerSample;
+ uint32_t PacketSize;
+ uint32_t AudioTag;
+ char *CodecPrivateData;
+} MP4_Box_data_stra_t;
+
/*
typedef struct MP4_Box_data__s
{
@@ -1162,6 +1180,7 @@ typedef union MP4_Box_data_s
MP4_Box_data_tfra_t *p_tfra;
MP4_Box_data_mfro_t *p_mfro;
+ MP4_Box_data_stra_t *p_stra;
MP4_Box_data_stsz_t *p_stsz;
MP4_Box_data_stz2_t *p_stz2;
@@ -1431,6 +1450,13 @@ static const UUID_t TfxdBoxUUID = {
{ 0x6d, 0x1d, 0x9b, 0x05, 0x42, 0xd5, 0x44, 0xe6,
0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2 } };
+static const UUID_t SmooBoxUUID = {
+ { 0xe1, 0xda, 0x72, 0xba, 0x24, 0xd7, 0x43, 0xc3,
+ 0xa6, 0xa5, 0x1b, 0x57, 0x59, 0xa1, 0xa9, 0x2c } };
+
+static const UUID_t StraBoxUUID = {
+ { 0xb0, 0x3e, 0xf7, 0x70, 0x33, 0xbd, 0x4b, 0xac,
+ 0x96, 0xc7, 0xbf, 0x25, 0xf9, 0x7e, 0x24, 0x47 } };
/*****************************************************************************
* MP4_BoxGetInitFrag : Parse the initialization segment.
--
1.7.9.5
More information about the vlc-devel
mailing list