Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / ext / ogg / gstoggdemux.h
1 /* GStreamer
2  * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
3  *
4  * gstoggdemux.c: ogg stream demuxer
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_OGG_DEMUX_H__
23 #define __GST_OGG_DEMUX_H__
24
25 #include <ogg/ogg.h>
26
27 #include <gst/gst.h>
28
29 #include "gstoggstream.h"
30
31 G_BEGIN_DECLS
32
33 #define GST_TYPE_OGG_PAD (gst_ogg_pad_get_type())
34 #define GST_OGG_PAD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OGG_PAD, GstOggPad))
35 #define GST_OGG_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OGG_PAD, GstOggPad))
36 #define GST_IS_OGG_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OGG_PAD))
37 #define GST_IS_OGG_PAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OGG_PAD))
38
39 typedef struct _GstOggPad GstOggPad;
40 typedef struct _GstOggPadClass GstOggPadClass;
41
42 #define GST_TYPE_OGG_DEMUX (gst_ogg_demux_get_type())
43 #define GST_OGG_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OGG_DEMUX, GstOggDemux))
44 #define GST_OGG_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OGG_DEMUX, GstOggDemux))
45 #define GST_IS_OGG_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OGG_DEMUX))
46 #define GST_IS_OGG_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OGG_DEMUX))
47
48 GType gst_ogg_demux_get_type (void);
49
50 typedef struct _GstOggDemux GstOggDemux;
51 typedef struct _GstOggDemuxClass GstOggDemuxClass;
52 typedef struct _GstOggChain GstOggChain;
53
54 /* all information needed for one ogg chain (relevant for chained bitstreams) */
55 struct _GstOggChain
56 {
57   GstOggDemux *ogg;
58
59   gint64 offset;                /* starting offset of chain */
60   gint64 end_offset;            /* end offset of chain */
61   gint64 bytes;                 /* number of bytes */
62
63   gboolean have_bos;
64
65   GArray *streams;
66
67   GstClockTime total_time;      /* the total time of this chain, this is the MAX of
68                                    the totals of all streams */
69   GstClockTime begin_time;      /* when this chain starts in the stream */
70
71   GstClockTime segment_start;   /* the timestamp of the first sample, this is the MIN of
72                                    the start times of all streams. */
73   GstClockTime segment_stop;    /* the timestamp of the last page, this is the MAX of the
74                                    streams. */
75 };
76
77 /* different modes for the pad */
78 typedef enum
79 {
80   GST_OGG_PAD_MODE_INIT,        /* we are feeding our internal decoder to get info */
81   GST_OGG_PAD_MODE_STREAMING,   /* we are streaming buffers to the outside */
82 } GstOggPadMode;
83
84 /* all information needed for one ogg stream */
85 struct _GstOggPad
86 {
87   GstPad pad;                   /* subclass GstPad */
88
89   gboolean have_type;
90   GstOggPadMode mode;
91
92   GstOggChain *chain;           /* the chain we are part of */
93   GstOggDemux *ogg;             /* the ogg demuxer we are part of */
94
95   GstOggStream map;
96
97   gint64 packetno;
98   gint64 current_granule;
99   gint64 keyframe_granule;
100
101   GstClockTime start_time;      /* the timestamp of the first sample */
102
103   gint64 first_granule;         /* the granulepos of first page == first sample in next page */
104   GstClockTime first_time;      /* the timestamp of the second page or granuletime of first page */
105
106   GstClockTime last_stop;       /* last_stop when last push occured; used to detect when we
107                                  * need to send a newsegment update event for sparse streams */
108
109   GList *continued;
110
111   gboolean discont;
112   GstFlowReturn last_ret;       /* last return of _pad_push() */
113   gboolean is_eos;
114
115   gboolean added;
116 };
117
118 struct _GstOggPadClass
119 {
120   GstPadClass parent_class;
121 };
122
123 /**
124  * GstOggDemux:
125  *
126  * The ogg demuxer object structure.
127  */
128 struct _GstOggDemux
129 {
130   GstElement element;
131
132   GstPad *sinkpad;
133
134   gint64 length;
135   gint64 read_offset;
136   gint64 offset;
137
138   gboolean pullmode;
139   gboolean running;
140
141   gboolean need_chains;
142   gboolean resync;
143
144   /* state */
145   GMutex *chain_lock;           /* we need the lock to protect the chains */
146   GArray *chains;               /* list of chains we know */
147   GstClockTime total_time;
148   gint bitrate;                 /* bitrate of the current chain */
149
150   GstOggChain *current_chain;
151   GstOggChain *building_chain;
152
153   /* playback start/stop positions */
154   GstSegment segment;
155   gboolean segment_running;
156   guint32  seqnum;
157
158   GstEvent *event;
159   GstEvent *newsegment;         /* pending newsegment to be sent from _loop */
160
161   /* annodex stuff */
162   gint64 basetime;
163   gint64 prestime;
164
165   /* ogg stuff */
166   ogg_sync_state sync;
167 };
168
169 struct _GstOggDemuxClass
170 {
171   GstElementClass parent_class;
172 };
173
174 gboolean gst_ogg_demux_plugin_init (GstPlugin * plugin);
175
176 G_END_DECLS
177
178 #endif /* __GST_OGG_DEMUX_H__ */