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