2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) <2006> Nokia Corporation (contact <stefan.kost@nokia.com>)
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #ifndef __GST_AVI_DEMUX_H__
22 #define __GST_AVI_DEMUX_H__
27 #include "gst/riff/riff-ids.h"
28 #include "gst/riff/riff-read.h"
29 #include <gst/base/gstadapter.h>
33 #define GST_TYPE_AVI_DEMUX \
34 (gst_avi_demux_get_type ())
35 #define GST_AVI_DEMUX(obj) \
36 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_AVI_DEMUX, GstAviDemux))
37 #define GST_AVI_DEMUX_CLASS(klass) \
38 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_AVI_DEMUX, GstAviDemuxClass))
39 #define GST_IS_AVI_DEMUX(obj) \
40 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_AVI_DEMUX))
41 #define GST_IS_AVI_DEMUX_CLASS(klass) \
42 (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_AVI_DEMUX))
44 #define GST_AVI_DEMUX_MAX_STREAMS 16
46 #define CHUNKID_TO_STREAMNR(chunkid) \
47 ((((chunkid) & 0xff) - '0') * 10 + \
48 (((chunkid) >> 8) & 0xff) - '0')
51 /* new index entries 24 bytes */
54 guint32 size; /* bytes of the data */
55 guint64 offset; /* data offset in file */
56 guint64 total; /* total bytes before */
59 #define GST_AVI_KEYFRAME 1
60 #define ENTRY_IS_KEYFRAME(e) ((e)->flags == GST_AVI_KEYFRAME)
61 #define ENTRY_SET_KEYFRAME(e) ((e)->flags = GST_AVI_KEYFRAME)
62 #define ENTRY_UNSET_KEYFRAME(e) ((e)->flags = 0)
65 /* index of this streamcontext */
71 /* stream info and headers */
74 gst_riff_strf_vids *vids;
75 gst_riff_strf_auds *auds;
76 gst_riff_strf_iavs *iavs;
79 GstBuffer *extradata, *initdata;
82 /* the start/step/stop entries */
87 /* current index entry */
89 /* position (byte, frame, time) for current_entry */
91 GstClockTime current_timestamp;
92 GstClockTime current_ts_end;
93 guint64 current_offset;
94 guint64 current_offset_end;
96 GstFlowReturn last_flow;
101 guint32 total_blocks;
103 /* stream length according to index */
104 GstClockTime idx_duration;
105 /* stream length according to header */
106 GstClockTime hdr_duration;
107 /* stream length based on header/index */
108 GstClockTime duration;
113 /* openDML support (for files >4GB) */
118 GstAviIndexEntry *index; /* array with index entries */
119 guint idx_n; /* number of entries */
120 guint idx_max; /* max allocated size of entries */
129 GST_AVI_DEMUX_HEADER,
134 GST_AVI_DEMUX_HEADER_TAG_LIST,
135 GST_AVI_DEMUX_HEADER_AVIH,
136 GST_AVI_DEMUX_HEADER_ELEMENTS,
137 GST_AVI_DEMUX_HEADER_INFO,
138 GST_AVI_DEMUX_HEADER_JUNK,
139 GST_AVI_DEMUX_HEADER_DATA
140 } GstAviDemuxHeaderState;
142 typedef struct _GstAviDemux {
148 /* AVI decoding state */
149 GstAviDemuxState state;
150 GstAviDemuxHeaderState header_state;
152 gboolean abort_buffering;
154 /* when we loaded the indexes */
156 /* index offset in the file */
157 guint64 index_offset;
160 GstAviStream stream[GST_AVI_DEMUX_MAX_STREAMS];
164 guint num_t_streams; /* subtitle text streams */
166 /* for streaming mode */
172 /* some stream info for length */
175 /* segment in TIME */
177 gboolean segment_running;
179 /* pending tags/events */
180 GstEvent *seek_event;
181 GstTagList *globaltags;
184 /* gst index support */
185 GstIndex *element_index;
190 typedef struct _GstAviDemuxClass {
191 GstElementClass parent_class;
194 GType gst_avi_demux_get_type (void);
198 #endif /* __GST_AVI_DEMUX_H__ */