ext/ogg/gstoggmux.*: If we're muxing a dirac stream, flush the page after every picture.
[platform/upstream/gstreamer.git] / ext / ogg / gstoggmux.h
1 /* OGG muxer plugin for GStreamer
2  * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
3  * Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef __GST_OGG_MUX_H__
22 #define __GST_OGGEMUX_H__
23
24 #include <ogg/ogg.h>
25
26 #include <gst/gst.h>
27
28 G_BEGIN_DECLS
29
30 #define GST_TYPE_OGG_MUX (gst_ogg_mux_get_type())
31 #define GST_OGG_MUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OGG_MUX, GstOggMux))
32 #define GST_OGG_MUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OGG_MUX, GstOggMux))
33 #define GST_IS_OGG_MUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OGG_MUX))
34 #define GST_IS_OGG_MUX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OGG_MUX))
35
36 typedef struct _GstOggMux GstOggMux;
37 typedef struct _GstOggMuxClass GstOggMuxClass;
38
39 typedef enum
40 {
41   GST_OGG_PAD_STATE_CONTROL = 0,
42   GST_OGG_PAD_STATE_DATA = 1
43 }
44 GstOggPadState;
45
46 /* all information needed for one ogg stream */
47 typedef struct
48 {
49   GstCollectData collect;       /* we extend the CollectData */
50
51   /* These two buffers make a very simple queue - they enter as 'next_buffer'
52    * and (usually) leave as 'buffer', except at EOS, when buffer will be NULL */
53   GstBuffer *buffer;            /* the first waiting buffer for the pad */
54   GstBuffer *next_buffer;       /* the second waiting buffer for the pad */
55
56   gint serial;
57   ogg_stream_state stream;
58   gint64 packetno;              /* number of next packet */
59   gint64 pageno;                /* number of next page */
60   guint64 duration;             /* duration of current page */
61   gboolean eos;
62   gint64 offset;
63   GstClockTime timestamp;       /* timestamp of the first packet on the next
64                                  * page to be dequeued */
65   GstClockTime timestamp_end;   /* end timestamp of last complete packet on
66                                    the next page to be dequeued */
67   GstClockTime gp_time;         /* time corresponding to the gp value of the
68                                    last complete packet on the next page to be
69                                    dequeued */
70
71   GstOggPadState state;         /* state of the pad */
72
73   GList *headers;
74
75   GQueue *pagebuffers;          /* List of pages in buffers ready for pushing */
76
77   gboolean new_page;            /* starting a new page */
78   gboolean first_delta;         /* was the first packet in the page a delta */
79   gboolean prev_delta;          /* was the previous buffer a delta frame */
80
81   GstPadEventFunction collect_event;
82
83   gboolean always_flush_page;
84 }
85 GstOggPad;
86
87 /**
88  * GstOggMux:
89  *
90  * The ogg muxer object structure.
91  */
92 struct _GstOggMux
93 {
94   GstElement element;
95
96   /* source pad */
97   GstPad *srcpad;
98
99   /* sinkpads */
100   GstCollectPads *collect;
101
102   /* number of pads which have not received EOS */
103   gint active_pads;
104
105   /* the pad we are currently using to fill a page */
106   GstOggPad *pulling;
107
108   /* next timestamp for the page */
109   GstClockTime next_ts;
110
111   /* Last timestamp actually output on src pad */
112   GstClockTime last_ts;
113
114   /* offset in stream */
115   guint64 offset;
116
117   /* need_headers */
118   gboolean need_headers;
119
120   guint64 max_delay;
121   guint64 max_page_delay;
122
123   GstOggPad *delta_pad;         /* when a delta frame is detected on a stream, we mark
124                                    pages as delta frames up to the page that has the
125                                    keyframe */
126
127 };
128
129 struct _GstOggMuxClass
130 {
131   GstElementClass parent_class;
132 };
133
134 GType gst_ogg_mux_get_type (void);
135
136 G_END_DECLS
137
138 #endif /* __GST_OGG_MUX_H__ */