matroskademux: implement push mode seeking
[platform/upstream/gst-plugins-good.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_HEADER,
47   GST_MATROSKA_DEMUX_STATE_DATA,
48   GST_MATROSKA_DEMUX_STATE_SEEK
49 } GstMatroskaDemuxState;
50
51 typedef struct _GstMatroskaDemux {
52   GstEbmlRead              parent;
53
54   /* < private > */
55
56   GstIndex                *element_index;
57   gint                     element_index_writer_id;
58
59   /* pads */
60   GstPad                  *sinkpad;
61   GPtrArray               *src;
62   GstClock                *clock;
63   guint                    num_streams;
64   guint                    num_v_streams;
65   guint                    num_a_streams;
66   guint                    num_t_streams;
67
68   /* metadata */
69   gchar                   *muxing_app;
70   gchar                   *writing_app;
71   gint64                   created;
72
73   /* state */
74   gboolean                 streaming;
75   GstMatroskaDemuxState    state;
76   guint                    level_up;
77   guint64                  seek_block;
78
79   /* did we parse cues/tracks/segmentinfo already? */
80   gboolean                 index_parsed;
81   gboolean                 tracks_parsed;
82   gboolean                 segmentinfo_parsed;
83   gboolean                 attachments_parsed;
84   GList                   *tags_parsed;
85
86   /* start-of-segment */
87   guint64                  ebml_segment_start;
88
89   /* a cue (index) table */
90   GArray                  *index;
91
92   /* timescale in the file */
93   guint64                  time_scale;
94
95   /* keeping track of playback position */
96   GstSegment               segment;
97   gboolean                 segment_running;
98   GstClockTime             last_stop_end;
99
100   GstEvent                *close_segment;
101   GstEvent                *new_segment;
102   GstTagList              *global_tags;
103
104   /* push based mode usual suspects */
105   guint64                  offset;
106   GstAdapter              *adapter;
107   /* some state saving */
108   GstClockTime             cluster_time;
109   guint64                  cluster_offset;
110   /* index stuff */
111   gboolean                 seekable;
112   gboolean                 building_index;
113   guint64                  index_offset;
114   GstEvent                *seek_event;
115   gboolean                 need_newsegment;
116
117   /* reverse playback */
118   GArray                  *seek_index;
119   gint                     seek_entry;
120   gint64                   from_offset;
121   gint64                   to_offset;
122 } GstMatroskaDemux;
123
124 typedef struct _GstMatroskaDemuxClass {
125   GstEbmlReadClass parent;
126 } GstMatroskaDemuxClass;
127
128 gboolean gst_matroska_demux_plugin_init (GstPlugin *plugin);
129
130 G_END_DECLS
131
132 #endif /* __GST_MATROSKA_DEMUX_H__ */