avidemux: push mode: find the correct chunk for segment following seek
[platform/upstream/gstreamer.git] / gst / avi / gstavimux.h
1 /* AVI muxer plugin for GStreamer
2  * Copyright (C) 2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20
21 #ifndef __GST_AVI_MUX_H__
22 #define __GST_AVI_MUX_H__
23
24
25 #include <gst/gst.h>
26 #include <gst/base/gstcollectpads.h>
27 #include <gst/riff/riff-ids.h>
28 #include "avi-ids.h"
29
30 G_BEGIN_DECLS
31
32 #define GST_TYPE_AVI_MUX \
33   (gst_avi_mux_get_type())
34 #define GST_AVI_MUX(obj) \
35   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AVI_MUX,GstAviMux))
36 #define GST_AVI_MUX_CLASS(klass) \
37   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AVI_MUX,GstAviMuxClass))
38 #define GST_IS_AVI_MUX(obj) \
39   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AVI_MUX))
40 #define GST_IS_AVI_MUX_CLASS(klass) \
41   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AVI_MUX))
42
43 #define GST_AVI_INDEX_OF_INDEXES     0
44 #define GST_AVI_INDEX_OF_CHUNKS      1
45
46 /* this allows indexing up to 64GB avi file */
47 #define GST_AVI_SUPERINDEX_COUNT    32
48
49 /* max size */
50 #define GST_AVI_MAX_SIZE    0x40000000
51
52 typedef struct _gst_avi_superindex_entry {
53   guint64 offset;
54   guint32 size;
55   guint32 duration;
56 } gst_avi_superindex_entry;
57
58 typedef struct _gst_riff_strh_full {
59   gst_riff_strh  parent;
60   /* rcFrame, RECT structure (struct of 4 shorts) */
61   gint16  left;
62   gint16  top;
63   gint16  right;
64   gint16  bottom;
65 } gst_riff_strh_full;
66
67 typedef struct _GstAviPad GstAviPad;
68 typedef struct _GstAviMux GstAviMux;
69 typedef struct _GstAviMuxClass GstAviMuxClass;
70
71 typedef GstFlowReturn (*GstAviPadHook) (GstAviMux * avi, GstAviPad * avipad,
72                                         GstBuffer * buffer);
73
74 struct _GstAviPad {
75   /* do not extend, link to it */
76   /* is NULL if original sink request pad has been removed */
77   GstCollectData *collect;
78
79   /* type */
80   gboolean is_video;
81   gboolean connected;
82
83   /* chunk tag */
84   gchar *tag;
85
86   /* stream header */
87   gst_riff_strh hdr;
88
89   /* odml super indexes */
90   gst_avi_superindex_entry idx[GST_AVI_SUPERINDEX_COUNT];
91   gint idx_index;
92   gchar *idx_tag;
93
94   /* stream specific hook */
95   GstAviPadHook hook;
96 };
97
98 typedef struct _GstAviVideoPad {
99   GstAviPad parent;
100
101   /* stream format */
102   gst_riff_strf_vids vids;
103   /* extra data */
104   GstBuffer *vids_codec_data;
105   /* ODML video properties */
106   gst_riff_vprp vprp;
107
108   GstBuffer *prepend_buffer;
109
110 } GstAviVideoPad;
111
112 typedef struct _GstAviAudioPad {
113   GstAviPad parent;
114
115   /* stream format */
116   gst_riff_strf_auds auds;
117   /* audio info for bps calculation */
118   guint32 audio_size;
119   guint64 audio_time;
120
121   /* counts the number of samples to put in indx chunk
122    * useful for raw audio where usually there are more than
123    * 1 sample in each GstBuffer */
124   gint samples;
125
126   /* extra data */
127   GstBuffer *auds_codec_data;
128 } GstAviAudioPad;
129
130 typedef struct _GstAviCollectData {
131   /* extend the CollectData */
132   GstCollectData collect;
133
134   GstAviPad      *avipad;
135 } GstAviCollectData;
136
137 struct _GstAviMux {
138   GstElement element;
139
140   /* pads */
141   GstPad              *srcpad;
142   /* sinkpads, video first */
143   GSList              *sinkpads;
144   /* video restricted to 1 pad */
145   guint               video_pads, audio_pads;
146   GstCollectPads     *collect;
147
148   /* the AVI header */
149   /* still some single stream video data in mux struct */
150   gst_riff_avih avi_hdr;
151   /* total number of (video) frames */
152   guint32 total_frames;
153   /* amount of total data (bytes) */
154   guint64 total_data;
155   /* amount of data (bytes) in the AVI/AVIX block;
156    * actually the movi list, so counted from and including the movi tag */
157   guint32 data_size, datax_size;
158   /* num (video) frames in the AVI/AVIX block */
159   guint32 num_frames, numx_frames;
160   /* size of hdrl list, including tag as usual */
161
162   /* total size of extra codec data */
163   guint32 codec_data_size;
164   /* state info */
165   gboolean write_header;
166   gboolean restart;
167
168   /* tags */
169   GstTagList *tags_snap;
170
171   /* information about the AVI index ('idx') */
172   gst_riff_index_entry *idx;
173   gint idx_index, idx_count;
174   /* offset of *chunk* (relative to a base offset); entered in the index */
175   guint32 idx_offset;
176   /* size of idx1 chunk (including! chunk header and size bytes) */
177   guint32 idx_size;
178
179   /* are we a big file already? */
180   gboolean is_bigfile;
181   guint64 avix_start;
182
183   /* whether to use "large AVI files" or just stick to small indexed files */
184   gboolean enable_large_avi;
185 };
186
187 struct _GstAviMuxClass {
188   GstElementClass parent_class;
189 };
190
191 GType gst_avi_mux_get_type(void);
192
193 G_END_DECLS
194
195
196 #endif /* __GST_AVI_MUX_H__ */