Merge commit 'a2337b8af45cb5e8c091ff0e1c3ef4b6cc7b20a3' into 0.11
[platform/upstream/gstreamer.git] / gst / flv / gstflvdemux.h
1 /* GStreamer
2  * Copyright (C) <2007> Julien Moutte <julien@moutte.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 #ifndef __FLV_DEMUX_H__
21 #define __FLV_DEMUX_H__
22
23 #include <gst/gst.h>
24 #include <gst/base/gstadapter.h>
25
26 G_BEGIN_DECLS
27 #define GST_TYPE_FLV_DEMUX \
28   (gst_flv_demux_get_type())
29 #define GST_FLV_DEMUX(obj) \
30   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FLV_DEMUX,GstFlvDemux))
31 #define GST_FLV_DEMUX_CLASS(klass) \
32   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FLV_DEMUX,GstFlvDemuxClass))
33 #define GST_IS_FLV_DEMUX(obj) \
34   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FLV_DEMUX))
35 #define GST_IS_FLV_DEMUX_CLASS(klass) \
36   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FLV_DEMUX))
37 typedef struct _GstFlvDemux GstFlvDemux;
38 typedef struct _GstFlvDemuxClass GstFlvDemuxClass;
39
40 typedef enum
41 {
42   FLV_STATE_HEADER,
43   FLV_STATE_TAG_TYPE,
44   FLV_STATE_TAG_VIDEO,
45   FLV_STATE_TAG_AUDIO,
46   FLV_STATE_TAG_SCRIPT,
47   FLV_STATE_SEEK,
48   FLV_STATE_DONE,
49   FLV_STATE_NONE
50 } GstFlvDemuxState;
51
52 struct _GstFlvDemux
53 {
54   GstElement element;
55
56   GstPad *sinkpad;
57
58   GstPad *audio_pad;
59   GstPad *video_pad;
60
61   /* <private> */
62   
63   GstIndex *index;
64   gint index_id;
65   gboolean own_index;
66   
67   GArray * times;
68   GArray * filepositions;
69
70   GstAdapter *adapter;
71
72   GstSegment segment;
73
74   GstEvent *new_seg_event;
75
76   GstTagList *taglist;
77
78   GstFlvDemuxState state;
79
80   guint64 offset;
81   guint64 cur_tag_offset;
82   GstClockTime duration;
83   guint64 tag_size;
84   guint64 tag_data_size;
85
86   /* Audio infos */
87   guint16 rate;
88   guint16 channels;
89   guint16 width;
90   guint16 audio_codec_tag;
91   guint64 audio_offset;
92   gboolean audio_need_discont;
93   gboolean audio_need_segment;
94   gboolean audio_linked;
95   GstBuffer * audio_codec_data;
96   GstClockTime audio_start;
97   guint32 last_audio_pts;
98   GstClockTime audio_time_offset;
99
100   /* Video infos */
101   guint32 w;
102   guint32 h;
103   guint32 par_x;
104   guint32 par_y;
105   guint16 video_codec_tag;
106   guint64 video_offset;
107   gboolean video_need_discont;
108   gboolean video_need_segment;
109   gboolean video_linked;
110   gboolean got_par;
111   GstBuffer * video_codec_data;
112   GstClockTime video_start;
113   guint32 last_video_pts;
114   GstClockTime video_time_offset;
115   gdouble framerate;
116
117   gboolean random_access;
118   gboolean need_header;
119   gboolean has_audio;
120   gboolean has_video;
121   gboolean push_tags;
122   gboolean strict;
123   gboolean flushing;
124
125   gboolean no_more_pads;
126
127   gboolean seeking;
128   gboolean building_index;
129   gboolean indexed; /* TRUE if index is completely built */
130   gboolean upstream_seekable; /* TRUE if upstream is seekable */
131   gint64 file_size;
132   GstEvent *seek_event;
133   gint64 seek_time;
134
135   GstClockTime index_max_time;
136   gint64 index_max_pos;
137
138   /* reverse playback */
139   GstClockTime video_first_ts;
140   GstClockTime audio_first_ts;
141   gboolean video_done;
142   gboolean audio_done;
143   gint64 from_offset;
144   gint64 to_offset;
145 };
146
147 struct _GstFlvDemuxClass
148 {
149   GstElementClass parent_class;
150 };
151
152 GType gst_flv_demux_get_type (void);
153
154 G_END_DECLS
155 #endif /* __FLV_DEMUX_H__ */