upload tizen1.0 source
[framework/multimedia/gst-plugins-good0.10.git] / gst / matroska / matroska-demux.h
1 /* GStreamer Matroska muxer/demuxer
2  * (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
3  *
4  * matroska-demux.h: matroska file/stream demuxer definition
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 #ifndef __GST_MATROSKA_DEMUX_H__
23 #define __GST_MATROSKA_DEMUX_H__
24
25 #include <gst/gst.h>
26 #include <gst/base/gstadapter.h>
27
28 #include "ebml-read.h"
29 #include "matroska-ids.h"
30
31 G_BEGIN_DECLS
32
33 #define GST_TYPE_MATROSKA_DEMUX \
34   (gst_matroska_demux_get_type ())
35 #define GST_MATROSKA_DEMUX(obj) \
36   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MATROSKA_DEMUX, GstMatroskaDemux))
37 #define GST_MATROSKA_DEMUX_CLASS(klass) \
38   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MATROSKA_DEMUX, GstMatroskaDemuxClass))
39 #define GST_IS_MATROSKA_DEMUX(obj) \
40   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MATROSKA_DEMUX))
41 #define GST_IS_MATROSKA_DEMUX_CLASS(klass) \
42   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MATROSKA_DEMUX))
43
44 typedef enum {
45   GST_MATROSKA_DEMUX_STATE_START,
46   GST_MATROSKA_DEMUX_STATE_SEGMENT,
47   GST_MATROSKA_DEMUX_STATE_HEADER,
48   GST_MATROSKA_DEMUX_STATE_DATA,
49   GST_MATROSKA_DEMUX_STATE_SEEK,
50   GST_MATROSKA_DEMUX_STATE_SCANNING
51 } GstMatroskaDemuxState;
52
53 #define MKVDEMUX_MODIFICATION
54
55 typedef struct _GstMatroskaDemux {
56   GstElement              parent;
57
58   /* < private > */
59
60   GstIndex                *element_index;
61   gint                     element_index_writer_id;
62
63   /* pads */
64   GstPad                  *sinkpad;
65   GPtrArray               *src;
66   GstClock                *clock;
67   guint                    num_streams;
68   guint                    num_v_streams;
69   guint                    num_a_streams;
70   guint                    num_t_streams;
71
72   /* metadata */
73   gchar                   *muxing_app;
74   gchar                   *writing_app;
75   gint64                   created;
76
77   /* state */
78   gboolean                 streaming;
79   GstMatroskaDemuxState    state;
80   guint                    level_up;
81   guint64                  seek_block;
82   gboolean                 seek_first;
83
84   /* did we parse cues/tracks/segmentinfo already? */
85   gboolean                 index_parsed;
86   gboolean                 tracks_parsed;
87   gboolean                 segmentinfo_parsed;
88   gboolean                 attachments_parsed;
89   GList                   *tags_parsed;
90   GList                   *seek_parsed;
91
92   /* start-of-segment */
93   guint64                  ebml_segment_start;
94
95   /* a cue (index) table */
96   GArray                  *index;
97   /* cluster positions (optional) */
98   GArray                  *clusters;
99
100   /* timescale in the file */
101   guint64                  time_scale;
102
103   /* keeping track of playback position */
104   GstSegment               segment;
105   gboolean                 segment_running;
106   GstClockTime             last_stop_end;
107   gint64                   duration;
108
109   GstEvent                *close_segment;
110   GstEvent                *new_segment;
111   GstTagList              *global_tags;
112
113   /* pull mode caching */
114   GstBuffer *cached_buffer;
115
116   /* push and pull mode */
117   guint64                  offset;
118   /* some state saving */
119   GstClockTime             cluster_time;
120   guint64                  cluster_offset;
121   guint64                  first_cluster_offset;
122   guint64                  next_cluster_offset;
123
124 #ifdef MKVDEMUX_MODIFICATION
125   GstClockTime         time_position;
126   GstMatroskaTrackContext* audio_stream;
127   gboolean      video;
128   gboolean found_videokeyframe;
129   gboolean found_audioframe;
130 #endif
131
132   /* push based mode usual suspects */
133   GstAdapter              *adapter;
134   /* index stuff */
135   gboolean                 seekable;
136   gboolean                 building_index;
137   guint64                  index_offset;
138   GstEvent                *seek_event;
139   gboolean                 need_newsegment;
140
141   /* reverse playback */
142   GArray                  *seek_index;
143   gint                     seek_entry;
144
145 #ifdef MKVDEMUX_MODIFICATION
146
147   GstClockTime      next_key_cluster_time;
148   guint64               next_key_frame_offset;
149
150 #endif
151 } GstMatroskaDemux;
152
153 typedef struct _GstMatroskaDemuxClass {
154   GstElementClass parent;
155 } GstMatroskaDemuxClass;
156
157 gboolean gst_matroska_demux_plugin_init (GstPlugin *plugin);
158
159 G_END_DECLS
160
161 #endif /* __GST_MATROSKA_DEMUX_H__ */