libmp4mux.h 2.87 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*****************************************************************************
 * libmp4mux.h: mp4/mov muxer
 *****************************************************************************
 * Copyright (C) 2001, 2002, 2003, 2006, 20115 VLC authors and VideoLAN
 *
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
 *          Gildas Bazin <gbazin at videolan dot org>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/
#include <vlc_common.h>
#include <vlc_es.h>
25
#include <vlc_boxes.h>
26 27 28 29 30 31 32 33 34 35 36

typedef struct
{
    uint64_t i_pos;
    int      i_size;

    mtime_t  i_pts_dts;
    mtime_t  i_length;
    unsigned int i_flags;
} mp4mux_entry_t;

37 38
typedef struct
{
39
    mtime_t i_duration;
40 41 42 43
    mtime_t i_start_time;
    mtime_t i_start_offset;
} mp4mux_edit_t;

44 45 46 47 48 49 50 51 52 53 54 55 56 57
typedef struct
{
    unsigned i_track_id;
    es_format_t   fmt;

    /* index */
    unsigned int i_entry_count;
    unsigned int i_entry_max;
    mp4mux_entry_t *entry;

    /* XXX: needed for other codecs too, see lavf */
    block_t      *a52_frame;

    /* stats */
58
    mtime_t      i_read_duration;
59
    uint32_t     i_timescale;
60
    mtime_t      i_firstdts; /* the really first packet */
61 62 63 64 65 66 67
    bool         b_hasbframes;

    /* temp stuff */
    /* for later stco fix-up (fast start files) */
    uint64_t     i_stco_pos;

    /* frags */
68
    mtime_t      i_trex_default_length;
69 70
    uint32_t     i_trex_default_size;

71 72 73 74
    /* edit list */
    unsigned int i_edits_count;
    mp4mux_edit_t *p_edits;

75 76
} mp4mux_trackinfo_t;

77
bool mp4mux_trackinfo_Init( mp4mux_trackinfo_t *, unsigned, uint32_t );
78 79 80 81 82 83 84
void mp4mux_trackinfo_Clear( mp4mux_trackinfo_t * );

bo_t *box_new     (const char *fcc);
bo_t *box_full_new(const char *fcc, uint8_t v, uint32_t f);
void  box_fix     (bo_t *box, uint32_t);
void  box_gather  (bo_t *box, bo_t *box2);

85
bool mp4mux_CanMux(vlc_object_t *, const es_format_t *, vlc_fourcc_t, bool);
86 87
bo_t *mp4mux_GetFtyp(vlc_fourcc_t, uint32_t, vlc_fourcc_t[], size_t i_fourcc);
bo_t *mp4mux_GetMoovBox(vlc_object_t *, mp4mux_trackinfo_t **pp_tracks, unsigned int i_tracks,
88
                        mtime_t i_movie_duration,
89
                        bool b_fragmented, bool b_mov, bool b_64ext, bool b_stco64);