matroskademux: Clean up position/duration handling
[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
27 #include "ebml-read.h"
28 #include "matroska-ids.h"
29
30 G_BEGIN_DECLS
31
32 #define GST_TYPE_MATROSKA_DEMUX \
33   (gst_matroska_demux_get_type ())
34 #define GST_MATROSKA_DEMUX(obj) \
35   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MATROSKA_DEMUX, GstMatroskaDemux))
36 #define GST_MATROSKA_DEMUX_CLASS(klass) \
37   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MATROSKA_DEMUX, GstMatroskaDemuxClass))
38 #define GST_IS_MATROSKA_DEMUX(obj) \
39   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MATROSKA_DEMUX))
40 #define GST_IS_MATROSKA_DEMUX_CLASS(klass) \
41   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MATROSKA_DEMUX))
42
43 typedef enum {
44   GST_MATROSKA_DEMUX_STATE_START,
45   GST_MATROSKA_DEMUX_STATE_HEADER,
46   GST_MATROSKA_DEMUX_STATE_DATA
47 } GstMatroskaDemuxState;
48
49 typedef struct _GstMatroskaDemux {
50   GstEbmlRead              parent;
51
52   /* < private > */
53
54   GstIndex                *element_index;
55   gint                     element_index_writer_id;
56
57   /* pads */
58   GstPad                  *sinkpad;
59   GPtrArray               *src;
60   GstClock                *clock;
61   guint                    num_streams;
62   guint                    num_v_streams;
63   guint                    num_a_streams;
64   guint                    num_t_streams;
65
66   /* metadata */
67   gchar                   *muxing_app;
68   gchar                   *writing_app;
69   gint64                   created;
70
71   /* state */
72   GstMatroskaDemuxState    state;
73   guint                    level_up;
74
75   /* did we parse cues/tracks/segmentinfo already? */
76   gboolean                 index_parsed;
77   gboolean                 tracks_parsed;
78   gboolean                 segmentinfo_parsed;
79   gboolean                 attachments_parsed;
80   GList                   *tags_parsed;
81
82   /* start-of-segment */
83   guint64                  ebml_segment_start;
84
85   /* a cue (index) table */
86   GArray                  *index;
87
88   /* timescale in the file */
89   guint64                  time_scale;
90
91   /* keeping track of playback position */
92   GstSegment               segment;
93   gboolean                 segment_running;
94   GstClockTime             last_stop_end;
95   gint64                   duration;
96
97   GstEvent                *close_segment;
98   GstEvent                *new_segment;
99   GstTagList              *global_tags;
100 } GstMatroskaDemux;
101
102 typedef struct _GstMatroskaDemuxClass {
103   GstEbmlReadClass parent;
104 } GstMatroskaDemuxClass;
105
106 gboolean gst_matroska_demux_plugin_init (GstPlugin *plugin);
107
108 G_END_DECLS
109
110 #endif /* __GST_MATROSKA_DEMUX_H__ */