gstavidemux.h 3.59 KB
Newer Older
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
1
/* GStreamer
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef __GST_AVI_DEMUX_H__
#define __GST_AVI_DEMUX_H__

#include <gst/gst.h>

25
#include "avi-ids.h"
26
27
28
29
#include "gst/riff/riff-ids.h"
#include "gst/riff/riff-read.h"

G_BEGIN_DECLS
Johan Dahlin's avatar
Johan Dahlin committed
30

Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
31
#define GST_TYPE_AVI_DEMUX \
32
  (gst_avi_demux_get_type ())
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
33
#define GST_AVI_DEMUX(obj) \
34
  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_AVI_DEMUX, GstAviDemux))
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
35
#define GST_AVI_DEMUX_CLASS(klass) \
36
  (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_AVI_DEMUX, GstAviDemuxClass))
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
37
#define GST_IS_AVI_DEMUX(obj) \
38
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_AVI_DEMUX))
39
#define GST_IS_AVI_DEMUX_CLASS(klass) \
40
  (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_AVI_DEMUX))
Johan Dahlin's avatar
Johan Dahlin committed
41

42
#define GST_AVI_DEMUX_MAX_STREAMS       16
Johan Dahlin's avatar
Johan Dahlin committed
43

Wim Taymans's avatar
Wim Taymans committed
44
#define CHUNKID_TO_STREAMNR(chunkid) \
45
46
  ((((chunkid) & 0xff) - '0') * 10 + \
   (((chunkid) >> 8) & 0xff) - '0')
Johan Dahlin's avatar
Johan Dahlin committed
47
48

typedef struct {
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
49
50
51
52
53
54
55
56
  gint           index_nr;
  gint           stream_nr;
  guint64        ts, dur;
  guint32        flags;
  guint64        offset;
  gint           size;
  guint64        bytes_before;
  guint32        frames_before;
Wim Taymans's avatar
Wim Taymans committed
57
58
} gst_avi_index_entry;

Johan Dahlin's avatar
Johan Dahlin committed
59
typedef struct {
60
  /* index of this streamcontext */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
61
  guint          num;
62
63

  /* pad, strh */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
64
  GstPad        *pad;
65
  GstFlowReturn  last_flow;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
66
  gst_riff_strh *strh;
67
68
69
70
  union {
    gst_riff_strf_vids *vids;
    gst_riff_strf_auds *auds;
    gst_riff_strf_iavs *iavs;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
71
    gpointer     data;
72
  } strf;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
73
74
  GstBuffer     *extradata, *initdata;
  gchar         *name;
Wim Taymans's avatar
Wim Taymans committed
75

76
  /* current position (byte, frame, time) */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
77
78
79
  guint          current_frame;
  guint64        current_byte;
  gint           current_entry;
Wim Taymans's avatar
Wim Taymans committed
80

81
  /* stream length */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
82
83
  guint64        total_bytes;
  guint32        total_frames;
84
85
86
87
  guint64        total_time;

  /* VBR indicator */
  gboolean       is_vbr;
88

89
90
91
  /* stream length according to index */
  GstClockTime   idx_duration;

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
92
  guint64       *indexes;
93
94

  GstTagList	*taglist;
Wim Taymans's avatar
Wim Taymans committed
95
96
} avi_stream_context;

Johan Dahlin's avatar
Johan Dahlin committed
97
typedef enum {
98
99
100
101
102
  GST_AVI_DEMUX_START,
  GST_AVI_DEMUX_HEADER,
  GST_AVI_DEMUX_MOVI,
} GstAviDemuxState;

Johan Dahlin's avatar
Johan Dahlin committed
103
typedef struct _GstAviDemux {
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
104
  GstElement     parent;
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
105
106

  /* pads */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
107
  GstPad        *sinkpad;
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
108
109

  /* AVI decoding state */
110
  GstAviDemuxState state;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
111
  guint64        offset;
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
112

113
  /* index */
Wim Taymans's avatar
Wim Taymans committed
114
  gst_avi_index_entry *index_entries;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
115
116
117
  guint          index_size;
  guint64        index_offset;
  guint          current_entry;
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
118

119
  /* streams */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
120
121
122
  guint          num_streams;
  guint          num_v_streams;
  guint          num_a_streams;
Wim Taymans's avatar
Wim Taymans committed
123
  avi_stream_context stream[GST_AVI_DEMUX_MAX_STREAMS];
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
124

125
  /* some stream info for length */
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
126
  gst_riff_avih *avih;
127

128
129
  /* seeking in TIME */
  GstSegment    segment;
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
130
  GstEvent      *seek_event;
131

132
133
  GstTagList	*globaltags;
  
134
135
  gboolean	got_tags;

136
} GstAviDemux;
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
137

Johan Dahlin's avatar
Johan Dahlin committed
138
typedef struct _GstAviDemuxClass {
139
  GstElementClass parent_class;
140
} GstAviDemuxClass;
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
141

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
142
GType           gst_avi_demux_get_type          (void);
Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
143

144
G_END_DECLS
Johan Dahlin's avatar
Johan Dahlin committed
145

Andy Wingo Wingo's avatar
Andy Wingo Wingo committed
146
#endif /* __GST_AVI_DEMUX_H__ */