]> git.sesse.net Git - vlc/blob - modules/demux/ogg.h
Qt: move Q_WS => Q_OS in widgets and playlist code
[vlc] / modules / demux / ogg.h
1 /*****************************************************************************
2  * ogg.h : ogg stream demux module for vlc
3  *****************************************************************************
4  * Copyright (C) 2001-2010 VLC authors and VideoLAN
5  *
6  * Authors: Gildas Bazin <gbazin@netcourrier.com>
7  *          Andre Pang <Andre.Pang@csiro.au> (Annodex support)
8  *          Gabriel Finch <salsaman@gmail.com> (moved from ogg.c to ogg.h)
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Definitions of structures and functions used by this plugin
27  *****************************************************************************/
28
29 typedef struct oggseek_index_entry demux_index_entry_t;
30
31 typedef struct logical_stream_s
32 {
33     ogg_stream_state os;                        /* logical stream of packets */
34
35     es_format_t      fmt;
36     es_format_t      fmt_old;                  /* format of old ES is reused */
37     es_out_id_t      *p_es;
38     double           f_rate;
39
40     int              i_serial_no;
41
42     /* the header of some logical streams (eg vorbis) contain essential
43      * data for the decoder. We back them up here in case we need to re-feed
44      * them to the decoder. */
45     bool             b_force_backup;
46     int              i_packets_backup;
47     void             *p_headers;
48     int              i_headers;
49     ogg_int64_t      i_previous_granulepos;
50
51     /* program clock reference (in units of 90kHz) derived from the previous
52      * granulepos */
53     mtime_t          i_pcr;
54     mtime_t          i_interpolated_pcr;
55     mtime_t          i_previous_pcr;
56
57     /* Misc */
58     bool b_reinit;
59     int i_granule_shift;
60
61     /* Opus has a starting offset in the headers. */
62     int i_pre_skip;
63     /* Vorbis and Opus can trim the end of a stream using granule positions. */
64     int i_end_trim;
65
66     /* offset of first keyframe for theora; can be 0 or 1 depending on version number */
67     int64_t i_keyframe_offset;
68
69     /* keyframe index for seeking, created as we discover keyframes */
70     demux_index_entry_t *idx;
71
72     /* skip some frames after a seek */
73     int i_skip_frames;
74
75     /* data start offset (absolute) in bytes */
76     int64_t i_data_start;
77
78     /* kate streams have the number of headers in the ID header */
79     int i_kate_num_headers;
80
81     /* for Annodex logical bitstreams */
82     int i_secondary_header_packets;
83
84 } logical_stream_t;
85
86 struct demux_sys_t
87 {
88     ogg_sync_state oy;        /* sync and verify incoming physical bitstream */
89
90     int i_streams;                           /* number of logical bitstreams */
91     logical_stream_t **pp_stream;  /* pointer to an array of logical streams */
92
93     logical_stream_t *p_old_stream; /* pointer to a old logical stream to avoid recreating it */
94
95     /* program clock reference (in units of 90kHz) derived from the pcr of
96      * the sub-streams */
97     mtime_t i_pcr;
98
99     /* stream state */
100     int     i_bos; /* Begnning of stream, tell the demux to look for elementary streams. */
101     int     i_eos;
102
103     /* bitrate */
104     int     i_bitrate;
105
106     /* after reading all headers, the first data page is stuffed into the relevant stream, ready to use */
107     bool    b_page_waiting;
108
109     /* count of total frames in video stream */
110     int64_t i_total_frames;
111
112     /* length of file in bytes */
113     int64_t i_total_length;
114
115     /* offset position in file (for reading) */
116     int64_t i_input_position;
117
118     /* current page being parsed */
119     ogg_page current_page;
120
121     /* */
122     vlc_meta_t          *p_meta;
123     int                 i_seekpoints;
124     seekpoint_t         **pp_seekpoints;
125
126     /* */
127     int                 i_attachments;
128     input_attachment_t  **attachments;
129
130     /* Length, if available. */
131     int64_t i_length;
132 };