[vlc-devel] [PATCH 1/2] RTP Reception Hint Track related box recognition for MP4 module.

Denis Charmet typx at dinauz.org
Mon Feb 15 14:31:28 CET 2016


Hi,

While I can't really comment on the mp4 part, here are some code 
remarks:

On 2016-02-12 15:16, Joni Räsänen wrote:
> ---
>  modules/demux/mp4/libmp4.c | 86 
> ++++++++++++++++++++++++++++++++++++++++++++-
>  modules/demux/mp4/libmp4.h | 87 
> ++++++++++++++++++++++++++++++++++++++++++++--
>  2 files changed, 170 insertions(+), 3 deletions(-)
> 
> diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
> index 3b9bb1b..32c0bcd 100644
> --- a/modules/demux/mp4/libmp4.c
> +++ b/modules/demux/mp4/libmp4.c
> @@ -2136,6 +2136,33 @@ 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] );
> +    }
I'd rather have an extension of the libmp4 to read (or skip) a buffer.
> +
> +    MP4_GET2BYTES( p_box->data.p_sample_hint->i_data_reference_index 
> );
> +
> +    p_box->data.p_sample_hint->p_data = malloc(8);
Please check the result of malloc.

> +    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;
> @@ -2335,6 +2362,53 @@ static int MP4_ReadBox_stsc( stream_t
> *p_stream, MP4_Box_t *p_box )
>      MP4_READBOX_EXIT( 1 );
>  }
> 
> +static int MP4_ReadBox_sdp( stream_t *p_stream, MP4_Box_t *p_box )
> +{
> +   MP4_READBOX_ENTER( MP4_Box_data_sdp_t, NULL );
> +
> +   MP4_GETSTRINGZ( p_box->data.p_sdp->psz_text );
No release?

> +
> +   MP4_READBOX_EXIT( 1 );
> +}
> +
> +static int MP4_ReadBox_rtp( stream_t *p_stream, MP4_Box_t *p_box )
> +{
> +    MP4_READBOX_ENTER( MP4_Box_data_moviehintinformation_rtp_t, NULL 
> );
> +
> +    MP4_GET4BYTES(
> p_box->data.p_moviehintinformation_rtp->i_description_format );
> +
> +    MP4_GETSTRINGZ( p_box->data.p_moviehintinformation_rtp->psz_text 
> );
> +
Same.
> +    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 );
> @@ -3567,6 +3641,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:
> @@ -3787,6 +3863,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 },
> 
> @@ -3806,7 +3884,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 20a9c27..0539b3e 100644
> --- a/modules/demux/mp4/libmp4.h
> +++ b/modules/demux/mp4/libmp4.h
> @@ -126,14 +126,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' )
> @@ -698,9 +707,36 @@ typedef struct MP4_Box_data_sample_hint_s
>      uint16_t i_data_reference_index;
> 
>      uint8_t *p_data;
> -
>  } 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;
> @@ -708,6 +744,44 @@ typedef struct 
> MP4_Box_data_moviehintinformation_rtp_s
> 
>  } MP4_Box_data_moviehintinformation_rtp_t;
> 
> +typedef struct MP4_Box_data_sdp_s
> +{
> +    unsigned char *psz_text;
why unsigned?
> +
> +} 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;
> @@ -1443,6 +1517,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;
> @@ -1458,7 +1538,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;
Why making it a pointer?
> 
>      MP4_Box_data_frma_t *p_frma;
>      MP4_Box_data_skcr_t *p_skcr;
> @@ -1696,4 +1776,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

Regards,
-- 
Denis Charmet - TypX
Le mauvais esprit est un art de vivre


More information about the vlc-devel mailing list