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 *****************************************************************************/
21 #ifndef VLC_MP4_MP4_H_
22 #define VLC_MP4_MP4_H_
24 /*****************************************************************************
26 *****************************************************************************/
28 #include <vlc_common.h>
30 #include "fragments.h"
31 #include "../asf/asfpacket.h"
33 /* Contain all information about a chunk */
36 uint64_t i_offset
; /* absolute position of this chunk in the file */
37 uint32_t i_sample_description_index
; /* index for SampleEntry to use */
38 uint32_t i_sample_count
; /* how many samples in this chunk */
39 uint32_t i_sample_first
; /* index of the first sample in this chunk */
40 uint32_t i_sample
; /* index of the next sample to read in this chunk */
41 uint32_t i_virtual_run_number
; /* chunks interleaving sequence */
43 /* now provide way to calculate pts, dts, and offset without too
44 much memory and with fast access */
46 /* with this we can calculate dts/pts without waste memory */
47 uint64_t i_first_dts
; /* DTS of the first sample */
48 uint64_t i_duration
; /* total duration of all samples */
50 uint32_t i_entries_dts
;
51 uint32_t *p_sample_count_dts
;
52 uint32_t *p_sample_delta_dts
; /* dts delta */
54 uint32_t i_entries_pts
;
55 uint32_t *p_sample_count_pts
;
56 int32_t *p_sample_offset_pts
; /* pts-dts */
58 uint32_t *p_sample_size
;
59 /* TODO if needed add pts
60 but quickly *add* support for edts and seeking */
68 const MP4_Box_t
*p_trun
;
71 typedef enum RTP_timstamp_synchronization_s
73 UNKNOWN_SYNC
= 0, UNSYNCHRONIZED
= 1, SYNCHRONIZED
= 2, RESERVED
= 3
74 } RTP_timstamp_synchronization_t
;
76 /* Contain all needed information for read all track with vlc */
79 unsigned int i_track_ID
;/* this should be unique */
81 int b_ok
; /* The track is usable */
82 int b_enable
; /* is the trak enable by default */
83 bool b_selected
; /* is the trak being played */
84 bool b_chapters_source
; /* True when used for chapter only */
85 bool b_forced_spu
; /* forced track selection (never done by default/priority) */
86 uint32_t i_switch_group
;
91 uint32_t i_block_flags
;
92 uint32_t i_next_block_flags
;
93 uint8_t rgi_chans_reordering
[AOUT_CHAN_MAX
];
97 /* display size only ! */
102 /* more internal data */
103 uint32_t i_timescale
; /* time scale for this track only */
106 int i_elst
; /* current elst */
107 int64_t i_elst_time
; /* current elst start time (in movie time scale)*/
108 const MP4_Box_t
*p_elst
; /* elst (could be NULL) */
110 /* give the next sample to read, i_chunk is to find quickly where
111 the sample is located */
112 uint32_t i_sample
; /* next sample to read */
113 uint32_t i_chunk
; /* chunk where next sample is stored */
114 /* total count of chunk and sample */
115 uint32_t i_chunk_count
;
116 uint32_t i_sample_count
;
118 mp4_chunk_t
*chunk
; /* always defined for each chunk */
120 /* sample size, p_sample_size defined only if i_sample_size == 0
121 else i_sample_size is size for all sample */
122 uint32_t i_sample_size
;
123 uint32_t *p_sample_size
; /* XXX perhaps add file offset if take
124 // too much time to do sumations each time*/
126 uint32_t i_sample_first
; /* i_sample_first value
128 uint64_t i_first_dts
; /* i_first_dts value
131 const MP4_Box_t
*p_track
;
132 const MP4_Box_t
*p_stbl
; /* will contain all timing information */
133 const MP4_Box_t
*p_stsd
; /* will contain all data to initialize decoder */
134 const MP4_Box_t
*p_sample
;/* point on actual sdsd */
137 bool b_codec_need_restart
;
140 mtime_t i_time
; // track scaled
142 /* rrtp reception hint track */
143 MP4_Box_t
*p_sdp
; /* parsed for codec and other info */
144 RTP_timstamp_synchronization_t sync_mode
; /* whether track is already in sync */
146 /* First recorded RTP timestamp offset.
147 * Needed for rrtp synchronization */
148 int32_t i_tsro_offset
;
152 /* for moof parsing */
154 uint32_t i_default_sample_size
;
155 uint32_t i_default_sample_duration
;
163 uint64_t i_trun_sample
;
164 uint64_t i_trun_sample_pos
;
168 /* ASF packets handling */
169 const MP4_Box_t
*p_asf
;
170 mtime_t i_dts_backup
;
171 mtime_t i_pts_backup
;
172 asf_track_info_t asfinfo
;
175 int SetupVideoES( demux_t
*p_demux
, mp4_track_t
*p_track
, MP4_Box_t
*p_sample
);
176 int SetupAudioES( demux_t
*p_demux
, mp4_track_t
*p_track
, MP4_Box_t
*p_sample
);
177 int SetupSpuES( demux_t
*p_demux
, mp4_track_t
*p_track
, MP4_Box_t
*p_sample
);
178 int SetupCCES( demux_t
*p_demux
, mp4_track_t
*p_track
, MP4_Box_t
*p_sample
);
179 void SetupMeta( vlc_meta_t
*p_meta
, MP4_Box_t
*p_udta
);
181 /* format of RTP reception hint track sample constructor */
185 int8_t trackrefindex
;
187 uint32_t samplenumber
;
188 uint32_t sampleoffset
; /* indicates where the payload is located within sample */
189 uint16_t bytesperblock
;
190 uint16_t samplesperblock
;
192 } mp4_rtpsampleconstructor_t
;