]> git.sesse.net Git - vlc/blobdiff - modules/demux/mp4/mp4.h
* Added "Id" svn:keywords property to all files containing "$Id:".
[vlc] / modules / demux / mp4 / mp4.h
index 6f8d621e4b72120e6ffed598544d3bd6e6d8e9c3..de747749ff858ef13ad34b7f55b9878d19ed36c9 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * mp4.h : MP4 file input module for vlc
  *****************************************************************************
- * Copyright (C) 2001 VideoLAN
- * $Id: mp4.h,v 1.5 2002/12/06 16:34:06 sam Exp $
+ * Copyright (C) 2001-2004 VideoLAN
+ * $Id: mp4.h,v 1.14 2004/01/25 20:05:28 hartman Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  *****************************************************************************/
 
 
-
-/*****************************************************************************
- * Structure needed for decoder
- *****************************************************************************/
-typedef struct bitmapinfoheader_s
-{
-    uint32_t i_size; /* size of header 40 + size of data follwoing this header */
-    uint32_t i_width;
-    uint32_t i_height;
-    uint16_t i_planes;
-    uint16_t i_bitcount;
-    uint32_t i_compression;
-    uint32_t i_sizeimage;
-    uint32_t i_xpelspermeter;
-    uint32_t i_ypelspermeter;
-    uint32_t i_clrused;
-    uint32_t i_clrimportant;
-} bitmapinfoheader_t;
-
-typedef struct waveformatex_s
-{
-    uint16_t i_format;
-    uint16_t i_channels;
-    uint32_t i_samplepersec;
-    uint32_t i_avgbytespersec;
-    uint16_t i_blockalign;
-    uint16_t i_bitspersample;
-    uint16_t i_size;          /* This give size of data
-                            imediatly following this header. */
-} waveformatex_t;
-
 /*****************************************************************************
  * Contain all information about a chunk
  *****************************************************************************/
-typedef struct chunk_data_mp4_s
+typedef struct
 {
     uint64_t     i_offset; /* absolute position of this chunk in the file */
     uint32_t     i_sample_description_index; /* index for SampleEntry to use */
@@ -73,27 +42,34 @@ typedef struct chunk_data_mp4_s
     /* TODO if needed add pts
         but quickly *add* support for edts and seeking */
 
-} chunk_data_mp4_t;
+} mp4_chunk_t;
 
 
 /*****************************************************************************
  * Contain all needed information for read all track with vlc
  *****************************************************************************/
-typedef struct track_data_mp4_s
+typedef struct
 {
-    int b_ok;           /* The track is usable */
     int i_track_ID;     /* this should be unique */
+
+    int b_ok;           /* The track is usable */
     int b_enable;       /* is the trak enable by default */
-    int b_selected;     /* is the trak being played */
-    int i_cat;          /* Type of the track, VIDEO_ES, AUDIO_ES, UNKNOWN_ES  ... */
-    char        i_language[3];
+    vlc_bool_t b_selected;     /* is the trak being played */
+
+    es_format_t fmt;
+    es_out_id_t *p_es;
 
     /* display size only ! */
-    int         i_width;
-    int         i_height;
+    int i_width;
+    int i_height;
 
     /* more internal data */
-    uint64_t         i_timescale;  /* time scale for this track only */
+    uint64_t        i_timescale;    /* time scale for this track only */
+
+    /* elst */
+    int             i_elst;         /* current elst */
+    int64_t         i_elst_time;    /* current elst start time (in movie time scale)*/
+    MP4_Box_t       *p_elst;        /* elst (could be NULL) */
 
     /* give the next sample to read, i_chunk is to find quickly where
       the sample is located */
@@ -103,7 +79,7 @@ typedef struct track_data_mp4_s
     uint32_t         i_chunk_count;
     uint32_t         i_sample_count;
 
-    chunk_data_mp4_t    *chunk; /* always defined  for each chunk */
+    mp4_chunk_t    *chunk; /* always defined  for each chunk */
 
     /* sample size, p_sample_size defined only if i_sample_size == 0
         else i_sample_size is size for all sample */
@@ -111,13 +87,14 @@ typedef struct track_data_mp4_s
     uint32_t         *p_sample_size; /* XXX perhaps add file offset if take
                                     too much time to do sumations each time*/
 
-    es_descriptor_t *p_es; /* vlc es for this track */
-
     MP4_Box_t *p_stbl;  /* will contain all timing information */
     MP4_Box_t *p_stsd;  /* will contain all data to initialize decoder */
+    MP4_Box_t *p_sample;/* point on actual sdsd */
+
+    vlc_bool_t b_drms;
+    void      *p_drms;
 
-    MP4_Box_t *p_sample; /* actual SampleEntry to make life simpler */
-} track_data_mp4_t;
+} mp4_track_t;
 
 
 /*****************************************************************************
@@ -125,7 +102,7 @@ typedef struct track_data_mp4_s
  *****************************************************************************/
 struct demux_sys_t
 {
-    MP4_Box_t   box_root;      /* container for the whole file */
+    MP4_Box_t    *p_root;      /* container for the whole file */
 
     mtime_t      i_pcr;
 
@@ -134,73 +111,7 @@ struct demux_sys_t
     uint64_t     i_timescale;   /* movie time scale */
     uint64_t     i_duration;    /* movie duration */
     unsigned int i_tracks;      /* number of tracks */
-    track_data_mp4_t *track;    /* array of track */
+    mp4_track_t *track;    /* array of track */
 };
 
-static inline uint64_t MP4_GetTrackPos( track_data_mp4_t *p_track )
-{
-    unsigned int i_sample;
-    uint64_t i_pos;
-
-
-    i_pos = p_track->chunk[p_track->i_chunk].i_offset;
-
-    if( p_track->i_sample_size )
-    {
-        i_pos += ( p_track->i_sample -
-                        p_track->chunk[p_track->i_chunk].i_sample_first ) *
-                                p_track->i_sample_size;
-    }
-    else
-    {
-        for( i_sample = p_track->chunk[p_track->i_chunk].i_sample_first;
-                i_sample < p_track->i_sample; i_sample++ )
-        {
-            i_pos += p_track->p_sample_size[i_sample];
-        }
-
-    }
-    return( i_pos );
-}
-
-/* Return time in µs of a track */
-static inline mtime_t MP4_GetTrackPTS( track_data_mp4_t *p_track )
-{
-    unsigned int i_sample;
-    unsigned int i_index;
-    uint64_t i_dts;
-
-    i_sample = p_track->i_sample - p_track->chunk[p_track->i_chunk].i_sample_first;
-    i_dts = p_track->chunk[p_track->i_chunk].i_first_dts;
-    i_index = 0;
-    while( i_sample > 0 )
-    {
-        if( i_sample > p_track->chunk[p_track->i_chunk].p_sample_count_dts[i_index] )
-        {
-            i_dts += p_track->chunk[p_track->i_chunk].p_sample_count_dts[i_index] *
-                        p_track->chunk[p_track->i_chunk].p_sample_delta_dts[i_index];
-            i_sample -= p_track->chunk[p_track->i_chunk].p_sample_count_dts[i_index];
-            i_index++;
-        }
-        else
-        {
-            i_dts += i_sample *
-                        p_track->chunk[p_track->i_chunk].p_sample_delta_dts[i_index];
-            i_sample = 0;
-            break;
-        }
-    }
-    return( (mtime_t)(
-                (mtime_t)1000000 *
-                (mtime_t)i_dts /
-                (mtime_t)p_track->i_timescale ) );
-}
-
-static inline mtime_t MP4_GetMoviePTS(demux_sys_t *p_demux )
-{
-    return( (mtime_t)(
-                (mtime_t)1000000 *
-                (mtime_t)p_demux->i_time /
-                (mtime_t)p_demux->i_timescale )
-          );
-}
+