[vlc-commits] MP4: RTP Reception Hint Track related box recognition

Joni Räsänen git at videolan.org
Sat Apr 16 10:46:20 CEST 2016


vlc | branch: master | Joni Räsänen <joni.rasanen at tut.fi> | Tue Apr  5 06:18:42 2016 -0700| [2a04df0dd7aff128fd2c7986bf2b0b171d73a3cd] | committer: Jean-Baptiste Kempf

MP4: RTP Reception Hint Track related box recognition

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

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

 modules/demux/mp4/libmp4.c |   98 +++++++++++++++++++++++++++++++++++++++++++-
 modules/demux/mp4/libmp4.h |   84 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 180 insertions(+), 2 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 382b7a7..84f97a1 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -2313,6 +2313,35 @@ static int MP4_ReadBox_sample_mp4s( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
+int MP4_ReadBox_sample_hint8( stream_t *p_stream, MP4_Box_t *p_box )
+{
+    MP4_READBOX_ENTER_PARTIAL( MP4_Box_data_sample_hint_t, 24, MP4_FreeBox_sample_hint );
+
+    for( unsigned i = 0; i < 6 ; i++ )
+    {
+        MP4_GET1BYTE( p_box->data.p_sample_hint->i_reserved1[i] );
+    }
+
+    MP4_GET2BYTES( p_box->data.p_sample_hint->i_data_reference_index );
+
+    if( !(p_box->data.p_sample_hint->p_data = malloc(8)) )
+        MP4_READBOX_EXIT( 0 );
+
+    MP4_GET8BYTES( *(p_box->data.p_sample_hint->p_data) );
+
+    MP4_ReadBoxContainerChildren(p_stream, p_box, NULL);
+
+    if ( MP4_Seek( p_stream, p_box->i_pos + p_box->i_size ) )
+        MP4_READBOX_EXIT( 0 );
+
+    MP4_READBOX_EXIT( 1 );
+}
+
+void MP4_FreeBox_sample_hint( MP4_Box_t *p_box )
+{
+    FREENULL( p_box->data.p_sample_hint->p_data );
+}
+
 static int MP4_ReadBox_sample_text( stream_t *p_stream, MP4_Box_t *p_box )
 {
     int32_t t;
@@ -2512,6 +2541,63 @@ static int MP4_ReadBox_stsc( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
+static void MP4_FreeBox_sdp( MP4_Box_t *p_box )
+{
+    FREENULL( p_box->data.p_sdp->psz_text );
+}
+
+static int MP4_ReadBox_sdp( stream_t *p_stream, MP4_Box_t *p_box )
+{
+   MP4_READBOX_ENTER( MP4_Box_data_sdp_t, MP4_FreeBox_sdp );
+
+   MP4_GETSTRINGZ( p_box->data.p_sdp->psz_text );
+
+   MP4_READBOX_EXIT( 1 );
+}
+
+static void MP4_FreeBox_rtp( MP4_Box_t *p_box )
+{
+    FREENULL( p_box->data.p_moviehintinformation_rtp->psz_text );
+}
+
+static int MP4_ReadBox_rtp( stream_t *p_stream, MP4_Box_t *p_box )
+{
+    MP4_READBOX_ENTER( MP4_Box_data_moviehintinformation_rtp_t, MP4_FreeBox_rtp );
+
+    MP4_GET4BYTES( p_box->data.p_moviehintinformation_rtp->i_description_format );
+
+    MP4_GETSTRINGZ( p_box->data.p_moviehintinformation_rtp->psz_text );
+
+    MP4_READBOX_EXIT( 1 );
+}
+
+static int MP4_ReadBox_tims( stream_t *p_stream, MP4_Box_t *p_box )
+{
+    MP4_READBOX_ENTER( MP4_Box_data_tims_t, NULL );
+
+    MP4_GET4BYTES( p_box->data.p_tims->i_timescale );
+
+    MP4_READBOX_EXIT( 1 );
+}
+
+static int MP4_ReadBox_tsro( stream_t *p_stream, MP4_Box_t *p_box )
+{
+    MP4_READBOX_ENTER( MP4_Box_data_tsro_t, NULL );
+
+    MP4_GET4BYTES( p_box->data.p_tsro->i_offset );
+
+    MP4_READBOX_EXIT( 1 );
+}
+
+static int MP4_ReadBox_tssy( stream_t *p_stream, MP4_Box_t *p_box )
+{
+    MP4_READBOX_ENTER( MP4_Box_data_tssy_t,  NULL );
+
+    MP4_GET1BYTE( p_box->data.p_tssy->i_reserved_timestamp_sync );
+
+    MP4_READBOX_EXIT( 1 );
+}
+
 static void MP4_FreeBox_stco_co64( MP4_Box_t *p_box )
 {
     FREENULL( p_box->data.p_co64->i_chunk_offset );
@@ -3744,6 +3830,8 @@ static int MP4_ReadBox_default( stream_t *p_stream, MP4_Box_t *p_box )
                 return MP4_ReadBox_sample_soun( p_stream, p_box );
             case ATOM_vide:
                 return MP4_ReadBox_sample_vide( p_stream, p_box );
+            case ATOM_hint:
+                return MP4_ReadBox_sample_hint8( p_stream, p_box );
             case ATOM_text:
                 return MP4_ReadBox_sample_text( p_stream, p_box );
             case ATOM_tx3g:
@@ -3970,6 +4058,8 @@ static const struct
     { ATOM_avc1,    MP4_ReadBox_sample_vide,  ATOM_stsd },
     { ATOM_avc3,    MP4_ReadBox_sample_vide,  ATOM_stsd },
 
+    { ATOM_rrtp,    MP4_ReadBox_sample_hint8,  ATOM_stsd },
+
     { ATOM_yv12,    MP4_ReadBox_sample_vide,  0 },
     { ATOM_yuv2,    MP4_ReadBox_sample_vide,  0 },
 
@@ -3989,7 +4079,13 @@ static const struct
     { ATOM_chap,    MP4_ReadBox_tref_generic, 0 },
 
     /* found in hnti */
-    { ATOM_rtp,     MP4_ReadBox_default,      0 },
+    { ATOM_rtp,     MP4_ReadBox_rtp,          ATOM_hnti },
+    { ATOM_sdp,     MP4_ReadBox_sdp,          ATOM_hnti },
+
+    /* found in rrtp sample description */
+    { ATOM_tims,     MP4_ReadBox_tims,        0 },
+    { ATOM_tsro,     MP4_ReadBox_tsro,        0 },
+    { ATOM_tssy,     MP4_ReadBox_tssy,        0 },
 
     /* found in rmra/rmda */
     { ATOM_rdrf,    MP4_ReadBox_rdrf,         ATOM_rmda },
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 7c30159..a170456 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -127,14 +127,23 @@ typedef int64_t stime_t;
 #define ATOM_soun VLC_FOURCC( 's', 'o', 'u', 'n' )
 #define ATOM_hint VLC_FOURCC( 'h', 'i', 'n', 't' )
 #define ATOM_hdv2 VLC_FOURCC( 'h', 'd', 'v', '2' )
+#define ATOM_rrtp VLC_FOURCC( 'r', 'r', 't', 'p' )
 
 #define ATOM_dpnd VLC_FOURCC( 'd', 'p', 'n', 'd' )
+#define ATOM_cdsc VLC_FOURCC( 'c', 'd', 's', 'c' )
 #define ATOM_ipir VLC_FOURCC( 'i', 'p', 'i', 'r' )
 #define ATOM_mpod VLC_FOURCC( 'm', 'p', 'o', 'd' )
 #define ATOM_hnti VLC_FOURCC( 'h', 'n', 't', 'i' )
 #define ATOM_rtp  VLC_FOURCC( 'r', 't', 'p', ' ' )
 #define ATOM_btrt VLC_FOURCC( 'b', 't', 'r', 't' )
+#define ATOM_sdp  VLC_FOURCC( 's', 'd', 'p', ' ' )
 
+#define ATOM_tims VLC_FOURCC( 't', 'i', 'm', 's' )
+#define ATOM_tsro VLC_FOURCC( 't', 's', 'r', 'o' )
+#define ATOM_tssy VLC_FOURCC( 't', 's', 's', 'y' )
+
+#define ATOM_isom VLC_FOURCC( 'i', 's', 'o', 'm' )
+#define ATOM_3gp4 VLC_FOURCC( '3', 'g', 'p', '4' )
 #define ATOM_esds VLC_FOURCC( 'e', 's', 'd', 's' )
 
 #define ATOM_lpcm VLC_FOURCC( 'l', 'p', 'c', 'm' )
@@ -704,6 +713,34 @@ typedef struct MP4_Box_data_sample_hint_s
 
 } MP4_Box_data_sample_hint_t;
 
+typedef struct MP4_Box_data_rrtp_sample_s
+{
+    uint16_t i_hinttrackversion;
+    uint16_t i_highestcompatibleversion;
+    uint32_t i_maxpacketsize;
+
+    uint8_t *p_additionaldata;
+
+} MP4_Box_data_rrtp_sample_t;
+
+typedef struct MP4_Box_data_timescale_entry_s
+{
+    uint32_t i_timescale;
+
+} MP4_Box_data_timescale_entry_t;
+
+typedef struct MP4_Box_data_time_offset_s
+{
+    uint32_t i_offset;
+
+} MP4_Box_data_time_offset_t;
+
+typedef struct MP4_Box_data_timestampsynchrony_s
+{
+    uint8_t i_reserved_timestamp_sync;
+
+} MP4_Box_data_timestampsynchrony_t;
+
 typedef struct MP4_Box_data_moviehintinformation_rtp_s
 {
     uint32_t i_description_format;
@@ -711,6 +748,42 @@ typedef struct MP4_Box_data_moviehintinformation_rtp_s
 
 } MP4_Box_data_moviehintinformation_rtp_t;
 
+typedef struct MP4_Box_data_sdp_s
+{
+    char *psz_text;
+
+} MP4_Box_data_sdp_t;
+
+typedef struct MP4_Box_data_tims_s
+{
+    uint32_t i_timescale;
+
+} MP4_Box_data_tims_t;
+
+typedef struct MP4_Box_data_tsro_s
+{
+    int32_t i_offset;
+
+} MP4_Box_data_tsro_t;
+
+typedef struct MP4_Box_data_tssy_s
+{
+    uint8_t i_reserved_timestamp_sync;
+
+} MP4_Box_data_tssy_t;
+
+typedef struct MP4_Box_data_stsd_s
+{
+    uint8_t  i_version;
+    uint32_t i_flags;
+
+    uint32_t i_entry_count;
+
+    /* it contains SampleEntry handled as if it was Box */
+
+} MP4_Box_data_stsd_t;
+
+
 typedef struct MP4_Box_data_stsz_s
 {
     uint8_t  i_version;
@@ -1479,6 +1552,12 @@ typedef union MP4_Box_data_s
     MP4_Box_data_tfra_t *p_tfra;
     MP4_Box_data_mfro_t *p_mfro;
 
+    MP4_Box_data_sdp_t *p_sdp;
+
+    MP4_Box_data_tims_t *p_tims;
+    MP4_Box_data_tsro_t *p_tsro;
+    MP4_Box_data_tssy_t *p_tssy;
+
     MP4_Box_data_stsz_t *p_stsz;
     MP4_Box_data_stz2_t *p_stz2;
     MP4_Box_data_stsc_t *p_stsc;
@@ -1494,7 +1573,7 @@ typedef union MP4_Box_data_s
     MP4_Box_data_cmvd_t *p_cmvd;
     MP4_Box_data_cmov_t *p_cmov;
 
-    MP4_Box_data_moviehintinformation_rtp_t p_moviehintinformation_rtp;
+    MP4_Box_data_moviehintinformation_rtp_t *p_moviehintinformation_rtp;
 
     MP4_Box_data_frma_t *p_frma;
     MP4_Box_data_skcr_t *p_skcr;
@@ -1734,4 +1813,7 @@ int MP4_ReadBoxContainerChildren( stream_t *p_stream, MP4_Box_t *p_container,
 int MP4_ReadBox_sample_vide( stream_t *p_stream, MP4_Box_t *p_box );
 void MP4_FreeBox_sample_vide( MP4_Box_t *p_box );
 
+int MP4_ReadBox_sample_hint8( stream_t *p_stream, MP4_Box_t *p_box );
+void MP4_FreeBox_sample_hint( MP4_Box_t *p_box );
+
 #endif



More information about the vlc-commits mailing list