Debian Codegraph @

gst/asfdemux/gstasfdemux.h

raw
1 /* GStreamer
2 * Copyright (C) <1999> Erik Walthinsen <[email protected]>
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., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20
21 #ifndef __ASF_DEMUX_H__
22 #define __ASF_DEMUX_H__
23
24 #include <gst/gst.h>
25 #include <gst/base/gstadapter.h>
26 #include <gst/base/gstflowcombiner.h>
27
28 #include "asfheaders.h"
29
30 G_BEGIN_DECLS
31
32 #define GST_TYPE_ASF_DEMUX \
33 (gst_asf_demux_get_type())
34 #define GST_ASF_DEMUX(obj) \
35 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ASF_DEMUX,GstASFDemux))
36 #define GST_ASF_DEMUX_CLASS(klass) \
37 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ASF_DEMUX,GstASFDemuxClass))
38 #define GST_IS_ASF_DEMUX(obj) \
39 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ASF_DEMUX))
40 #define GST_IS_ASF_DEMUX_CLASS(klass) \
41 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ASF_DEMUX))
42
43 typedef struct _GstASFDemux GstASFDemux;
44 typedef struct _GstASFDemuxClass GstASFDemuxClass;
45 typedef enum _GstASF3DMode GstASF3DMode;
46
47 typedef struct {
48 guint32 packet;
49 guint16 count;
50 } AsfSimpleIndexEntry;
51
52 typedef struct {
53 AsfPayloadExtensionID id : 16; /* extension ID; the :16 makes sure the
54 * struct gets packed into 4 bytes */
55 guint16 len; /* save this so we can skip unknown IDs */
56 } AsfPayloadExtension;
57
58 /*
59 * 3D Types for Media play
60 */
61 enum _GstASF3DMode
62 {
63 GST_ASF_3D_NONE = 0x00,
64
65 //added, interim format - half
66 GST_ASF_3D_SIDE_BY_SIDE_HALF_LR = 0x01,
67 GST_ASF_3D_SIDE_BY_SIDE_HALF_RL = 0x02,
68 GST_ASF_3D_TOP_AND_BOTTOM_HALF_LR = 0x03,
69 GST_ASF_3D_TOP_AND_BOTTOM_HALF_RL = 0x04,
70 GST_ASF_3D_DUAL_STREAM = 0x0D, /*< Full format*/
71 };
72
73 typedef struct
74 {
75 gboolean valid; /* TRUE if structure is valid/filled */
76
77 GstClockTime start_time;
78 GstClockTime end_time;
79 GstClockTime avg_time_per_frame;
80 guint32 data_bitrate;
81 guint32 buffer_size;
82 guint32 intial_buf_fullness;
83 guint32 data_bitrate2;
84 guint32 buffer_size2;
85 guint32 intial_buf_fullness2;
86 guint32 max_obj_size;
87 guint32 flags;
88 guint16 lang_idx;
89
90 /* may be NULL if there are no extensions; otherwise, terminated by
91 * an AsfPayloadExtension record with len 0 */
92 AsfPayloadExtension *payload_extensions;
93
94 /* missing: stream names */
95 } AsfStreamExtProps;
96
97 typedef struct
98 {
99 AsfStreamType type;
100
101 gboolean active; /* if the stream has been activated (pad added) */
102
103 GstPad *pad;
104 guint16 id;
105
106 /* video-only */
107 gboolean is_video;
108 gboolean fps_known;
109
110 GstCaps *caps;
111
112 GstBuffer *streamheader;
113
114 GstTagList *pending_tags;
115
116 gboolean discont;
117 gboolean first_buffer;
118
119 /* Descrambler settings */
120 guint8 span;
121 guint16 ds_packet_size;
122 guint16 ds_chunk_size;
123 guint16 ds_data_size;
124
125 /* for new parsing code */
126 GArray *payloads; /* pending payloads */
127
128 /* Video stream PAR & interlacing */
129 guint8 par_x;
130 guint8 par_y;
131 gboolean interlaced;
132
133 /* For reverse playback */
134 gboolean reverse_kf_ready; /* Found complete KF payload*/
135 GArray *payloads_rev; /* Temp queue for storing multiple payloads of packet*/
136 gint kf_pos; /* KF position in payload queue. Payloads from this pos will be pushed */
137
138 /* extended stream properties (optional) */
139 AsfStreamExtProps ext_props;
140
141 gboolean inspect_payload;
142 } AsfStream;
143
144 typedef enum {
145 GST_ASF_DEMUX_STATE_HEADER,
146 GST_ASF_DEMUX_STATE_DATA,
147 GST_ASF_DEMUX_STATE_INDEX
148 } GstASFDemuxState;
149
150 #define GST_ASF_DEMUX_IS_REVERSE_PLAYBACK(seg) (seg.rate < 0.0? TRUE:FALSE)
151
152 #define GST_ASF_DEMUX_NUM_VIDEO_PADS 16
153 #define GST_ASF_DEMUX_NUM_AUDIO_PADS 32
154 #define GST_ASF_DEMUX_NUM_STREAMS 32
155 #define GST_ASF_DEMUX_NUM_STREAM_IDS 127
156
157 struct _GstASFDemux {
158 GstElement element;
159
160 GstPad *sinkpad;
161
162 gboolean have_group_id;
163 guint group_id;
164
165 GstAdapter *adapter;
166 GstTagList *taglist;
167 GstASFDemuxState state;
168
169 /* byte offset where the asf starts, which might not be zero on chained
170 * asfs, index_offset and data_offset already are 'offseted' by base_offset */
171 guint64 base_offset;
172
173 guint64 index_offset; /* byte offset where index might be, or 0 */
174 guint64 data_offset; /* byte offset where packets start */
175 guint64 data_size; /* total size of packet data in bytes, or 0 */
176 guint64 num_packets; /* total number of data packets, or 0 */
177 gint64 packet; /* current packet */
178 guint speed_packets; /* Known number of packets to get in one go*/
179
180 gchar **languages;
181 guint num_languages;
182
183 GstCaps *metadata; /* metadata, for delayed parsing; one
184 * structure ('stream-N') per stream */
185 GstStructure *global_metadata; /* metadata which isn't specific to one stream */
186 GSList *ext_stream_props; /* for delayed processing (buffers) */
187 GSList *mut_ex_streams; /* mutually exclusive streams */
188
189 guint32 num_audio_streams;
190 guint32 num_video_streams;
191 guint32 num_streams;
192 AsfStream stream[GST_ASF_DEMUX_NUM_STREAMS];
193 gboolean activated_streams;
194 GstFlowCombiner *flowcombiner;
195
196 /* for chained asf handling, we need to hold the old asf streams until
197 * we detect the new ones */
198 AsfStream old_stream[GST_ASF_DEMUX_NUM_STREAMS];
199 gboolean old_num_streams;
200
201 GstClockTime first_ts; /* smallest timestamp found */
202
203 guint32 packet_size;
204 guint64 play_time;
205
206 guint64 preroll;
207
208 gboolean seekable;
209 gboolean broadcast;
210
211 GstSegment segment; /* configured play segment */
212 gboolean keyunit_sync;
213 gboolean accurate;
214
215 gboolean need_newsegment; /* do we need to send a new-segment event? */
216 guint32 segment_seqnum; /* if the new segment must have this seqnum */
217 GstClockTime segment_ts; /* streaming; timestamp for segment start */
218 GstSegment in_segment; /* streaming; upstream segment info */
219 GstClockTime in_gap; /* streaming; upstream initial segment gap for interpolation */
220 gboolean segment_running; /* if we've started the current segment */
221 gboolean streaming; /* TRUE if we are operating chain-based */
222 GstClockTime latency;
223
224 /* for debugging only */
225 gchar *objpath;
226
227 /* simple index, if available */
228 GstClockTime sidx_interval; /* interval between entries in ns */
229 guint sidx_num_entries; /* number of index entries */
230 AsfSimpleIndexEntry *sidx_entries; /* packet number for each entry */
231
232 GSList *other_streams; /* remember streams that are in header but have unknown type */
233
234 /* For reverse playback */
235 gboolean seek_to_cur_pos; /* Search packets till we reach 'seek' time */
236 gboolean multiple_payloads; /* Whether packet has multiple payloads */
237
238 /* parsing 3D */
239 GstASF3DMode asf_3D_mode;
240
241 gboolean saw_file_header;
242 };
243
244 struct _GstASFDemuxClass {
245 GstElementClass parent_class;
246 };
247
248 GType gst_asf_demux_get_type (void);
249
250 AsfStream * gst_asf_demux_get_stream (GstASFDemux * demux, guint16 id);
251
252 gboolean gst_asf_demux_is_unknown_stream(GstASFDemux *demux, guint stream_num);
253
254 G_END_DECLS
255
256 #endif /* __ASF_DEMUX_H__ */