]> git.sesse.net Git - vlc/blob - modules/demux/mp4/mp4.h
1fcf9c6a592a9035c323a386a11f92be4c778c0b
[vlc] / modules / demux / mp4 / mp4.h
1 /*****************************************************************************
2  * mp4.h : MP4 file input module for vlc
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: mp4.h,v 1.13 2004/01/18 22:00:00 fenrir Exp $
6  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22
23
24 /*****************************************************************************
25  * Contain all information about a chunk
26  *****************************************************************************/
27 typedef struct
28 {
29     uint64_t     i_offset; /* absolute position of this chunk in the file */
30     uint32_t     i_sample_description_index; /* index for SampleEntry to use */
31     uint32_t     i_sample_count; /* how many samples in this chunk */
32     uint32_t     i_sample_first; /* index of the first sample in this chunk */
33
34     /* now provide way to calculate pts, dts, and offset without to
35         much memory and with fast acces */
36
37     /* with this we can calculate dts/pts without waste memory */
38     uint64_t     i_first_dts;
39     uint32_t     *p_sample_count_dts;
40     uint32_t     *p_sample_delta_dts; /* dts delta */
41
42     /* TODO if needed add pts
43         but quickly *add* support for edts and seeking */
44
45 } mp4_chunk_t;
46
47
48 /*****************************************************************************
49  * Contain all needed information for read all track with vlc
50  *****************************************************************************/
51 typedef struct
52 {
53     int i_track_ID;     /* this should be unique */
54
55     int b_ok;           /* The track is usable */
56     int b_enable;       /* is the trak enable by default */
57     vlc_bool_t b_selected;     /* is the trak being played */
58
59     es_format_t fmt;
60     es_out_id_t *p_es;
61
62     /* display size only ! */
63     int i_width;
64     int i_height;
65
66     /* more internal data */
67     uint64_t        i_timescale;    /* time scale for this track only */
68
69     /* elst */
70     int             i_elst;         /* current elst */
71     int64_t         i_elst_time;    /* current elst start time (in movie time scale)*/
72     MP4_Box_t       *p_elst;        /* elst (could be NULL) */
73
74     /* give the next sample to read, i_chunk is to find quickly where
75       the sample is located */
76     uint32_t         i_sample;       /* next sample to read */
77     uint32_t         i_chunk;        /* chunk where next sample is stored */
78     /* total count of chunk and sample */
79     uint32_t         i_chunk_count;
80     uint32_t         i_sample_count;
81
82     mp4_chunk_t    *chunk; /* always defined  for each chunk */
83
84     /* sample size, p_sample_size defined only if i_sample_size == 0
85         else i_sample_size is size for all sample */
86     uint32_t         i_sample_size;
87     uint32_t         *p_sample_size; /* XXX perhaps add file offset if take
88                                     too much time to do sumations each time*/
89
90     MP4_Box_t *p_stbl;  /* will contain all timing information */
91     MP4_Box_t *p_stsd;  /* will contain all data to initialize decoder */
92     MP4_Box_t *p_sample;/* point on actual sdsd */
93
94     vlc_bool_t b_drms;
95     void      *p_drms;
96
97 } mp4_track_t;
98
99
100 /*****************************************************************************
101  *
102  *****************************************************************************/
103 struct demux_sys_t
104 {
105     MP4_Box_t    *p_root;      /* container for the whole file */
106
107     mtime_t      i_pcr;
108
109     uint64_t     i_time;        /* time position of the presentation
110                                  * in movie timescale */
111     uint64_t     i_timescale;   /* movie time scale */
112     uint64_t     i_duration;    /* movie duration */
113     unsigned int i_tracks;      /* number of tracks */
114     mp4_track_t *track;    /* array of track */
115 };
116
117