gstavidemux.h 5.73 KB
Newer Older
Andy Wingo's avatar
Andy Wingo committed
1
/* GStreamer
Andy Wingo's avatar
Andy Wingo committed
2
 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3
 * Copyright (C) <2006> Nokia Corporation (contact <stefan.kost@nokia.com>)
Andy Wingo's avatar
Andy Wingo committed
4 5 6 7 8 9 10 11 12 13 14 15 16
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
17 18
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
Andy Wingo's avatar
Andy Wingo committed
19 20 21 22 23 24 25
 */

#ifndef __GST_AVI_DEMUX_H__
#define __GST_AVI_DEMUX_H__

#include <gst/gst.h>

26
#include "avi-ids.h"
27 28
#include "gst/riff/riff-ids.h"
#include "gst/riff/riff-read.h"
29
#include <gst/base/gstadapter.h>
Thiago Santos's avatar
Thiago Santos committed
30
#include <gst/base/gstflowcombiner.h>
31 32

G_BEGIN_DECLS
Johan Dahlin's avatar
Johan Dahlin committed
33

Andy Wingo's avatar
Andy Wingo committed
34
#define GST_TYPE_AVI_DEMUX \
35
  (gst_avi_demux_get_type ())
Andy Wingo's avatar
Andy Wingo committed
36
#define GST_AVI_DEMUX(obj) \
37
  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_AVI_DEMUX, GstAviDemux))
Andy Wingo's avatar
Andy Wingo committed
38
#define GST_AVI_DEMUX_CLASS(klass) \
39
  (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_AVI_DEMUX, GstAviDemuxClass))
Andy Wingo's avatar
Andy Wingo committed
40
#define GST_IS_AVI_DEMUX(obj) \
41
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_AVI_DEMUX))
42
#define GST_IS_AVI_DEMUX_CLASS(klass) \
43
  (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_AVI_DEMUX))
Johan Dahlin's avatar
Johan Dahlin committed
44

45
#define GST_AVI_DEMUX_MAX_STREAMS       16
Johan Dahlin's avatar
Johan Dahlin committed
46

Wim Taymans's avatar
Wim Taymans committed
47
#define CHUNKID_TO_STREAMNR(chunkid) \
48 49
  ((((chunkid) & 0xff) - '0') * 10 + \
   (((chunkid) >> 8) & 0xff) - '0')
Johan Dahlin's avatar
Johan Dahlin committed
50

51

52 53 54 55 56 57 58 59
/* new index entries 24 bytes */
typedef struct {
  guint32        flags;
  guint32        size;    /* bytes of the data */
  guint64        offset;  /* data offset in file */
  guint64        total;   /* total bytes before */
} GstAviIndexEntry;

Johan Dahlin's avatar
Johan Dahlin committed
60
typedef struct {
61
  /* index of this streamcontext */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
62
  guint          num;
63

64
  /* pad*/
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
65
  GstPad        *pad;
66
  gboolean       exposed;
67 68

  /* stream info and headers */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
69
  gst_riff_strh *strh;
70 71 72 73
  union {
    gst_riff_strf_vids *vids;
    gst_riff_strf_auds *auds;
    gst_riff_strf_iavs *iavs;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
74
    gpointer     data;
75
  } strf;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
76
  GstBuffer     *extradata, *initdata;
77
  GstBuffer     *rgb8_palette;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
78
  gchar         *name;
Wim Taymans's avatar
Wim Taymans committed
79

Wim Taymans's avatar
Wim Taymans committed
80 81 82 83
  /* the start/step/stop entries */
  guint          start_entry;
  guint          step_entry;
  guint          stop_entry;
Wim Taymans's avatar
Wim Taymans committed
84 85

  /* current index entry */
Wim Taymans's avatar
Wim Taymans committed
86
  guint          current_entry;
Wim Taymans's avatar
Wim Taymans committed
87 88 89 90 91 92
  /* position (byte, frame, time) for current_entry */
  guint          current_total;
  GstClockTime   current_timestamp;
  GstClockTime   current_ts_end;
  guint64        current_offset;
  guint64        current_offset_end;
Wim Taymans's avatar
Wim Taymans committed
93

94
  gboolean       discont;
Wim Taymans's avatar
Wim Taymans committed
95

96
  /* stream length */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
97
  guint64        total_bytes;
98
  guint32        total_blocks;
99
  guint          n_keyframes;
100 101
  /* stream length according to index */
  GstClockTime   idx_duration;
102 103 104 105
  /* stream length according to header */
  GstClockTime   hdr_duration;
  /* stream length based on header/index */
  GstClockTime   duration;
106

107 108 109
  /* VBR indicator */
  gboolean       is_vbr;

110
  /* openDML support (for files >4GB) */
111
  gboolean       superindex;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
112
  guint64       *indexes;
113

114 115 116 117 118
  /* new indexes */
  GstAviIndexEntry *index;     /* array with index entries */
  guint             idx_n;     /* number of entries */
  guint             idx_max;   /* max allocated size of entries */

119
  GstTagList	*taglist;
120 121

  gint           index_id;
122
  gboolean is_raw;
Wim Taymans's avatar
Wim Taymans committed
123
} GstAviStream;
Wim Taymans's avatar
Wim Taymans committed
124

Johan Dahlin's avatar
Johan Dahlin committed
125
typedef enum {
126 127 128
  GST_AVI_DEMUX_START,
  GST_AVI_DEMUX_HEADER,
  GST_AVI_DEMUX_MOVI,
129
  GST_AVI_DEMUX_SEEK,
130 131
} GstAviDemuxState;

132 133 134 135 136 137 138 139 140
typedef enum {
  GST_AVI_DEMUX_HEADER_TAG_LIST,
  GST_AVI_DEMUX_HEADER_AVIH,
  GST_AVI_DEMUX_HEADER_ELEMENTS,
  GST_AVI_DEMUX_HEADER_INFO,
  GST_AVI_DEMUX_HEADER_JUNK,
  GST_AVI_DEMUX_HEADER_DATA
} GstAviDemuxHeaderState;

Johan Dahlin's avatar
Johan Dahlin committed
141
typedef struct _GstAviDemux {
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
142
  GstElement     parent;
Andy Wingo's avatar
Andy Wingo committed
143 144

  /* pads */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
145
  GstPad        *sinkpad;
Andy Wingo's avatar
Andy Wingo committed
146 147

  /* AVI decoding state */
148
  GstAviDemuxState state;
149
  GstAviDemuxHeaderState header_state;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
150
  guint64        offset;
151
  gboolean       abort_buffering;
Andy Wingo's avatar
Andy Wingo committed
152

Wim Taymans's avatar
Wim Taymans committed
153 154
  /* when we loaded the indexes */
  gboolean       have_index;
Wim Taymans's avatar
Wim Taymans committed
155
  /* index offset in the file */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
156
  guint64        index_offset;
Andy Wingo's avatar
Andy Wingo committed
157

158
  /* streams */
Wim Taymans's avatar
Wim Taymans committed
159
  GstAviStream   stream[GST_AVI_DEMUX_MAX_STREAMS];
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
160 161 162
  guint          num_streams;
  guint          num_v_streams;
  guint          num_a_streams;
163 164
  guint          num_t_streams;   /* subtitle text streams */
  guint          num_sp_streams;  /* subpicture streams */
165

166 167
  guint          main_stream; /* used for seeking */

Thiago Santos's avatar
Thiago Santos committed
168 169
  GstFlowCombiner *flowcombiner;

170 171 172
  gboolean       have_group_id;
  guint          group_id;

173
  /* for streaming mode */
Wim Taymans's avatar
Wim Taymans committed
174 175
  gboolean       streaming;
  gboolean       have_eos;
176
  GstAdapter    *adapter;
177
  guint          todrop;
178

179
  /* some stream info for length */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
180
  gst_riff_avih *avih;
181
  GstClockTime   duration;
182

183 184
  /* segment in TIME */
  GstSegment     segment;
185

186
  /* pending tags/events */
Wim Taymans's avatar
Wim Taymans committed
187
  GstEvent      *seg_event;
188
  GstTagList	*globaltags;
Wim Taymans's avatar
Wim Taymans committed
189
  gboolean	 got_tags;
190

191
#if 0
192 193 194
  /* gst index support */
  GstIndex      *element_index;
  gint           index_id;
195 196
#endif

197
  gboolean       seekable;
198 199 200

  guint64        first_movi_offset;
  guint64        idx1_offset; /* offset in file of list/chunk after movi */
Wim Taymans's avatar
Wim Taymans committed
201
  GstEvent      *seek_event;
202 203 204 205 206

  gboolean       building_index;
  guint          odml_stream;
  guint          odml_subidx;
  guint64       *odml_subidxs;
207 208

  guint64        seek_kf_offset; /* offset of the keyframe to which we want to seek */
209
} GstAviDemux;
Andy Wingo's avatar
Andy Wingo committed
210

Johan Dahlin's avatar
Johan Dahlin committed
211
typedef struct _GstAviDemuxClass {
212
  GstElementClass parent_class;
213
} GstAviDemuxClass;
Andy Wingo's avatar
Andy Wingo committed
214

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
215
GType           gst_avi_demux_get_type          (void);
Andy Wingo's avatar
Andy Wingo committed
216

217
G_END_DECLS
Johan Dahlin's avatar
Johan Dahlin committed
218

Andy Wingo's avatar
Andy Wingo committed
219
#endif /* __GST_AVI_DEMUX_H__ */