Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.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   GstPadEventFunction  collect_event;
148
149   /* the AVI header */
150   /* still some single stream video data in mux struct */
151   gst_riff_avih avi_hdr;
152   /* total number of (video) frames */
153   guint32 total_frames;
154   /* amount of total data (bytes) */
155   guint64 total_data;
156   /* amount of data (bytes) in the AVI/AVIX block;
157    * actually the movi list, so counted from and including the movi tag */
158   guint32 data_size, datax_size;
159   /* num (video) frames in the AVI/AVIX block */
160   guint32 num_frames, numx_frames;
161   /* size of hdrl list, including tag as usual */
162
163   /* total size of extra codec data */
164   guint32 codec_data_size;
165   /* state info */
166   gboolean write_header;
167   gboolean restart;
168
169   /* tags */
170   GstTagList *tags_snap;
171
172   /* information about the AVI index ('idx') */
173   gst_riff_index_entry *idx;
174   gint idx_index, idx_count;
175   /* offset of *chunk* (relative to a base offset); entered in the index */
176   guint32 idx_offset;
177   /* size of idx1 chunk (including! chunk header and size bytes) */
178   guint32 idx_size;
179
180   /* are we a big file already? */
181   gboolean is_bigfile;
182   guint64 avix_start;
183
184   /* whether to use "large AVI files" or just stick to small indexed files */
185   gboolean enable_large_avi;
186 };
187
188 struct _GstAviMuxClass {
189   GstElementClass parent_class;
190 };
191
192 GType gst_avi_mux_get_type(void);
193
194 G_END_DECLS
195
196
197 #endif /* __GST_AVI_MUX_H__ */