1 /*****************************************************************************
2 * mp4.h : MP4 file input module for vlc
3 *****************************************************************************
4 * Copyright (C) 2001-2004, 2010, 2014 VLC authors and VideoLAN
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
32 #include <vlc_common.h>
34 #include "../asf/asfpacket.h"
36 /* Contain all information about a chunk */
39 uint64_t i_offset; /* absolute position of this chunk in the file */
40 uint32_t i_sample_description_index; /* index for SampleEntry to use */
41 uint32_t i_sample_count; /* how many samples in this chunk */
42 uint32_t i_sample_first; /* index of the first sample in this chunk */
43 uint32_t i_sample; /* index of the next sample to read in this chunk */
45 /* now provide way to calculate pts, dts, and offset without too
46 much memory and with fast access */
48 /* with this we can calculate dts/pts without waste memory */
49 uint64_t i_first_dts; /* DTS of the first sample */
50 uint64_t i_last_dts; /* DTS of the last sample */
51 uint32_t *p_sample_count_dts;
52 uint32_t *p_sample_delta_dts; /* dts delta */
54 uint32_t *p_sample_count_pts;
55 int32_t *p_sample_offset_pts; /* pts-dts */
57 uint8_t **p_sample_data; /* set when b_fragmented is true */
58 uint32_t *p_sample_size;
59 /* TODO if needed add pts
60 but quickly *add* support for edts and seeking */
64 /* Contain all needed information for read all track with vlc */
67 unsigned int i_track_ID;/* this should be unique */
69 int b_ok; /* The track is usable */
70 int b_enable; /* is the trak enable by default */
71 bool b_selected; /* is the trak being played */
72 bool b_chapter; /* True when used for chapter only */
73 uint32_t i_switch_group;
78 uint8_t rgi_chans_reordering[AOUT_CHAN_MAX];
82 /* display size only ! */
87 /* more internal data */
88 uint32_t i_timescale; /* time scale for this track only */
89 uint16_t current_qid; /* Smooth Streaming quality level ID */
92 int i_elst; /* current elst */
93 int64_t i_elst_time; /* current elst start time (in movie time scale)*/
94 MP4_Box_t *p_elst; /* elst (could be NULL) */
96 /* give the next sample to read, i_chunk is to find quickly where
97 the sample is located */
98 uint32_t i_sample; /* next sample to read */
99 uint32_t i_chunk; /* chunk where next sample is stored */
100 /* total count of chunk and sample */
101 uint32_t i_chunk_count;
102 uint32_t i_sample_count;
104 mp4_chunk_t *chunk; /* always defined for each chunk */
105 mp4_chunk_t *cchunk; /* current chunk if b_fragmented is true */
107 /* sample size, p_sample_size defined only if i_sample_size == 0
108 else i_sample_size is size for all sample */
109 uint32_t i_sample_size;
110 uint32_t *p_sample_size; /* XXX perhaps add file offset if take
111 too much time to do sumations each time*/
113 uint32_t i_sample_first; /* i_sample_first value
115 uint64_t i_first_dts; /* i_first_dts value
118 MP4_Box_t *p_stbl; /* will contain all timing information */
119 MP4_Box_t *p_stsd; /* will contain all data to initialize decoder */
120 MP4_Box_t *p_sample;/* point on actual sdsd */
123 bool b_has_non_empty_cchunk;
124 bool b_codec_need_restart;
132 /* for moof parsing */
136 uint64_t i_traf_base_offset;
139 /* ASF packets handling */
141 mtime_t i_dts_backup;
142 mtime_t i_pts_backup;
143 asf_track_info_t asfinfo;
146 typedef struct mp4_fragment_t mp4_fragment_t;
147 struct mp4_fragment_t
149 uint64_t i_chunk_range_min_offset;
150 uint64_t i_chunk_range_max_offset;
153 mp4_fragment_t *p_next;
156 int SetupVideoES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample );
157 int SetupAudioES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample );
158 int SetupSpuES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample );
159 void SetupMeta( vlc_meta_t *p_meta, MP4_Box_t *p_udta );