1 /*****************************************************************************
2  * libmp4mux.h: mp4/mov muxer
3  *****************************************************************************
4  * Copyright (C) 2001, 2002, 2003, 2006, 20115 VLC authors and VideoLAN
5  *
6  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
7  *          Gildas Bazin <gbazin at videolan dot org>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23 #include <vlc_common.h>
24 #include <vlc_es.h>
25 #include <vlc_boxes.h>
26 
27 typedef struct
28 {
29     uint64_t i_pos;
30     int      i_size;
31 
32     mtime_t  i_pts_dts;
33     mtime_t  i_length;
34     unsigned int i_flags;
35 } mp4mux_entry_t;
36 
37 typedef struct
38 {
39     uint64_t i_duration;
40     mtime_t i_start_time;
41     mtime_t i_start_offset;
42 } mp4mux_edit_t;
43 
44 typedef struct
45 {
46     unsigned i_track_id;
47     es_format_t   fmt;
48 
49     /* index */
50     unsigned int i_entry_count;
51     unsigned int i_entry_max;
52     mp4mux_entry_t *entry;
53 
54     /* XXX: needed for other codecs too, see lavf */
55     block_t      *a52_frame;
56 
57     /* stats */
58     int64_t      i_read_duration;
59     uint32_t     i_timescale;
60     mtime_t      i_firstdts; /* the really first packet */
61     bool         b_hasbframes;
62 
63     /* temp stuff */
64     /* for later stco fix-up (fast start files) */
65     uint64_t     i_stco_pos;
66 
67     /* frags */
68     uint32_t     i_trex_default_length;
69     uint32_t     i_trex_default_size;
70 
71     /* edit list */
72     unsigned int i_edits_count;
73     mp4mux_edit_t *p_edits;
74 
75 } mp4mux_trackinfo_t;
76 
77 bool mp4mux_trackinfo_Init( mp4mux_trackinfo_t *, unsigned, uint32_t );
78 void mp4mux_trackinfo_Clear( mp4mux_trackinfo_t * );
79 
80 bo_t *box_new     (const char *fcc);
81 bo_t *box_full_new(const char *fcc, uint8_t v, uint32_t f);
82 void  box_fix     (bo_t *box, uint32_t);
83 void  box_gather  (bo_t *box, bo_t *box2);
84 
85 bool mp4mux_CanMux(vlc_object_t *, const es_format_t *);
86 bo_t *mp4mux_GetFtyp(vlc_fourcc_t, uint32_t, vlc_fourcc_t[], size_t i_fourcc);
87 bo_t *mp4mux_GetMoovBox(vlc_object_t *, mp4mux_trackinfo_t **pp_tracks, unsigned int i_tracks,
88                         int64_t i_movie_duration,
89                         bool b_fragmented, bool b_mov, bool b_64ext, bool b_stco64);
90