|
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 typedef struct _gst_avi_superindex_entry { |
|
50 guint64 offset; |
|
51 guint32 size; |
|
52 guint32 duration; |
|
53 } gst_avi_superindex_entry; |
|
54 |
|
55 typedef struct _gst_riff_strh_full { |
|
56 gst_riff_strh parent; |
|
57 /* rcFrame, RECT structure (struct of 4 shorts) */ |
|
58 gint16 left; |
|
59 gint16 top; |
|
60 gint16 right; |
|
61 gint16 bottom; |
|
62 } gst_riff_strh_full; |
|
63 |
|
64 typedef struct _GstAviPad { |
|
65 /* do not extend, link to it */ |
|
66 /* is NULL if original sink request pad has been removed */ |
|
67 GstCollectData *collect; |
|
68 |
|
69 /* type */ |
|
70 gboolean is_video; |
|
71 gboolean connected; |
|
72 |
|
73 /* chunk tag */ |
|
74 gchar *tag; |
|
75 |
|
76 /* stream header */ |
|
77 gst_riff_strh hdr; |
|
78 |
|
79 /* odml super indexes */ |
|
80 gst_avi_superindex_entry idx[GST_AVI_SUPERINDEX_COUNT]; |
|
81 gint idx_index; |
|
82 gchar *idx_tag; |
|
83 } GstAviPad; |
|
84 |
|
85 typedef struct _GstAviVideoPad { |
|
86 GstAviPad parent; |
|
87 |
|
88 /* stream format */ |
|
89 gst_riff_strf_vids vids; |
|
90 /* extra data */ |
|
91 GstBuffer *vids_codec_data; |
|
92 /* ODML video properties */ |
|
93 gst_riff_vprp vprp; |
|
94 |
|
95 } GstAviVideoPad; |
|
96 |
|
97 typedef struct _GstAviAudioPad { |
|
98 GstAviPad parent; |
|
99 |
|
100 /* stream format */ |
|
101 gst_riff_strf_auds auds; |
|
102 /* audio info for bps calculation */ |
|
103 guint32 audio_size; |
|
104 guint64 audio_time; |
|
105 /* extra data */ |
|
106 GstBuffer *auds_codec_data; |
|
107 } GstAviAudioPad; |
|
108 |
|
109 typedef struct _GstAviCollectData { |
|
110 /* extend the CollectData */ |
|
111 GstCollectData collect; |
|
112 |
|
113 GstAviPad *avipad; |
|
114 } GstAviCollectData; |
|
115 |
|
116 typedef struct _GstAviMux GstAviMux; |
|
117 typedef struct _GstAviMuxClass GstAviMuxClass; |
|
118 |
|
119 struct _GstAviMux { |
|
120 GstElement element; |
|
121 |
|
122 /* pads */ |
|
123 GstPad *srcpad; |
|
124 /* sinkpads, video first */ |
|
125 GSList *sinkpads; |
|
126 /* video restricted to 1 pad */ |
|
127 guint video_pads, audio_pads; |
|
128 GstCollectPads *collect; |
|
129 GstPadEventFunction collect_event; |
|
130 |
|
131 /* the AVI header */ |
|
132 /* still some single stream video data in mux struct */ |
|
133 gst_riff_avih avi_hdr; |
|
134 /* total number of (video) frames */ |
|
135 guint32 total_frames; |
|
136 /* amount of total data (bytes) */ |
|
137 guint64 total_data; |
|
138 /* amount of data (bytes) in the AVI/AVIX block; |
|
139 * actually the movi list, so counted from and including the movi tag */ |
|
140 guint32 data_size, datax_size; |
|
141 /* num (video) frames in the AVI/AVIX block */ |
|
142 guint32 num_frames, numx_frames; |
|
143 /* size of hdrl list, including tag as usual */ |
|
144 |
|
145 /* total size of extra codec data */ |
|
146 guint32 codec_data_size; |
|
147 /* state info */ |
|
148 gboolean write_header; |
|
149 gboolean restart; |
|
150 |
|
151 /* tags */ |
|
152 GstTagList *tags_snap; |
|
153 |
|
154 /* information about the AVI index ('idx') */ |
|
155 gst_riff_index_entry *idx; |
|
156 gint idx_index, idx_count; |
|
157 /* offset of *chunk* (relative to a base offset); entered in the index */ |
|
158 guint32 idx_offset; |
|
159 /* size of idx1 chunk (including! chunk header and size bytes) */ |
|
160 guint32 idx_size; |
|
161 |
|
162 /* are we a big file already? */ |
|
163 gboolean is_bigfile; |
|
164 guint64 avix_start; |
|
165 |
|
166 /* whether to use "large AVI files" or just stick to small indexed files */ |
|
167 gboolean enable_large_avi; |
|
168 }; |
|
169 |
|
170 struct _GstAviMuxClass { |
|
171 GstElementClass parent_class; |
|
172 }; |
|
173 |
|
174 GType gst_avi_mux_get_type(void); |
|
175 |
|
176 G_END_DECLS |
|
177 |
|
178 |
|
179 #endif /* __GST_AVI_MUX_H__ */ |