fix for big endian machines. Chunk ID conversion was being swabbed twice.
[platform/upstream/gst-plugins-good.git] / gst / avi / gstavidemux.h
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
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_DEMUX_H__
22 #define __GST_AVI_DEMUX_H__
23
24
25 #include <config.h>
26 #include <gst/gst.h>
27 #include <gst/riff/riff.h>
28 #include <gst/bytestream/bytestream.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33
34 #define GST_TYPE_AVI_DEMUX \
35   (gst_avi_demux_get_type())
36 #define GST_AVI_DEMUX(obj) \
37   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AVI_DEMUX,GstAviDemux))
38 #define GST_AVI_DEMUX_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AVI_DEMUX,GstAviDemux))
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(obj) \
43   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AVI_DEMUX))
44
45
46 #define GST_AVI_DEMUX_MAX_STREAMS       16      
47
48 #define CHUNKID_TO_STREAMNR(chunkid) \
49   ((((chunkid) & 0xff) - '0') * 10 + \
50    (((chunkid) >> 8) & 0xff) - '0')
51
52 typedef struct _GstAviDemux GstAviDemux;
53 typedef struct _GstAviDemuxClass GstAviDemuxClass;
54
55 typedef struct
56 {
57   gint          index_nr;
58   gint          stream_nr;
59   guint64       ts;
60   guint32       flags;
61   guint32       offset;
62   gint          size;
63   guint64       bytes_before;
64   guint32       frames_before;
65 } gst_avi_index_entry;
66
67 typedef struct
68 {
69   GstPad       *pad;
70   gint          num;
71   gst_riff_strh strh;
72   guint32       current_frame;
73   guint32       current_byte;
74   guint64       delay;
75   gboolean      need_flush;
76   guint32       av_bps;
77
78   guint64       total_bytes;
79   guint32       total_frames;
80
81   guint32       skip;
82
83 } avi_stream_context;
84
85 struct _GstAviDemux {
86   GstElement     element;
87
88   /* pads */
89   GstPad        *sinkpad, *srcpad;
90
91   /* AVI decoding state */
92   guint32        fcc_type;
93
94   GstByteStream *bs;
95
96   gst_avi_index_entry *index_entries;
97   gulong         index_size;
98   gulong         index_offset;
99
100   gst_riff_avih  avih;
101
102   guint          num_streams;
103   guint          num_v_streams;
104   guint          num_a_streams;
105
106   avi_stream_context stream[GST_AVI_DEMUX_MAX_STREAMS];
107
108   gboolean       seek_pending;
109   gint64         seek_offset;
110   guint64        last_seek;
111   gboolean       restart;
112 };
113
114 struct _GstAviDemuxClass {
115   GstElementClass parent_class;
116 };
117
118 GType           gst_avi_demux_get_type          (void);
119
120 #ifdef __cplusplus
121 }
122 #endif /* __cplusplus */
123
124
125 #endif /* __GST_AVI_DEMUX_H__ */