matroskamux: no need to set cache twice
[platform/upstream/gst-plugins-good.git] / gst / matroska / ebml-write.h
1 /* GStreamer EBML I/O
2  * (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
3  * (c) 2005 Michal Benes <michal.benes@xeris.cz>
4  *
5  * ebml-write.c: write EBML data to file/stream
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #ifndef __GST_EBML_WRITE_H__
24 #define __GST_EBML_WRITE_H__
25
26 #include <glib.h>
27 #include <gst/gst.h>
28 #include <gst/base/gstbytewriter.h>
29
30 G_BEGIN_DECLS
31
32 #define GST_TYPE_EBML_WRITE \
33   (gst_ebml_write_get_type ())
34 #define GST_EBML_WRITE(obj) \
35   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_EBML_WRITE, GstEbmlWrite))
36 #define GST_EBML_WRITE_CLASS(klass) \
37   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_EBML_WRITE, GstEbmlWriteClass))
38 #define GST_IS_EBML_WRITE(obj) \
39   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_EBML_WRITE))
40 #define GST_IS_EBML_WRITE_CLASS(klass) \
41   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_EBML_WRITE))
42 #define GST_EBML_WRITE_GET_CLASS(obj) \
43   (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_EBML_WRITE, GstEbmlWriteClass))
44
45 typedef struct _GstEbmlWrite {
46   GstObject object;
47
48   GstPad *srcpad;
49   guint64 pos;
50   GstClockTime timestamp;
51
52   GstByteWriter *cache;
53   guint64 cache_pos;
54
55   GstFlowReturn last_write_result;
56
57   gboolean need_newsegment;
58 } GstEbmlWrite;
59
60 typedef struct _GstEbmlWriteClass {
61   GstObjectClass parent;
62 } GstEbmlWriteClass;
63
64 GType   gst_ebml_write_get_type      (void);
65
66 GstEbmlWrite *gst_ebml_write_new     (GstPad *srcpad);
67 void    gst_ebml_write_reset         (GstEbmlWrite *ebml);
68
69 GstFlowReturn gst_ebml_last_write_result (GstEbmlWrite *ebml);
70
71 /*
72  * Caching means that we do not push one buffer for
73  * each element, but fill this one until a flush.
74  */
75 void    gst_ebml_write_set_cache     (GstEbmlWrite *ebml,
76                                       guint         size);
77 void    gst_ebml_write_flush_cache   (GstEbmlWrite *ebml);
78
79 /*
80  * Seeking.
81  */
82 void    gst_ebml_write_seek          (GstEbmlWrite *ebml,
83                                       guint64       pos);
84
85 /*
86  * Data writing. 
87  */
88 void    gst_ebml_write_uint          (GstEbmlWrite *ebml,
89                                       guint32       id,
90                                       guint64       num);
91 void    gst_ebml_write_sint          (GstEbmlWrite *ebml,
92                                       guint32       id,
93                                       gint64        num);
94 void    gst_ebml_write_float         (GstEbmlWrite *ebml,
95                                       guint32       id,
96                                       gdouble       num);
97 void    gst_ebml_write_ascii         (GstEbmlWrite *ebml,
98                                       guint32       id,
99                                       const gchar  *str);
100 void    gst_ebml_write_utf8          (GstEbmlWrite *ebml,
101                                       guint32       id,
102                                       const gchar  *str);
103 void    gst_ebml_write_date          (GstEbmlWrite *ebml,
104                                       guint32       id,
105                                       gint64        date);
106 guint64 gst_ebml_write_master_start  (GstEbmlWrite *ebml,
107                                       guint32       id);
108 void    gst_ebml_write_master_finish (GstEbmlWrite *ebml,
109                                       guint64       startpos);
110 void    gst_ebml_write_master_finish_full (GstEbmlWrite * ebml,
111                                       guint64 startpos,
112                                       guint64 extra_size);
113 void    gst_ebml_write_binary        (GstEbmlWrite *ebml,
114                                       guint32       id,
115                                       guchar       *binary,
116                                       guint64       length);
117 void    gst_ebml_write_header        (GstEbmlWrite *ebml,
118                                       const gchar  *doctype,
119                                       guint         version);
120
121 /*
122  * Note: this is supposed to be used only for media data.
123  */
124 void    gst_ebml_write_buffer_header (GstEbmlWrite *ebml,
125                                       guint32       id,
126                                       guint64       length);
127 void    gst_ebml_write_buffer        (GstEbmlWrite *ebml,
128                                       GstBuffer    *data);
129
130 /*
131  * A hack, basically... See matroska-mux.c. I should actually
132  * make a nice _replace_element_with_size() or so, but this
133  * works for now.
134  */
135 void    gst_ebml_replace_uint        (GstEbmlWrite *ebml,
136                                       guint64       pos,
137                                       guint64       num);
138
139 G_END_DECLS
140
141 #endif /* __GST_EBML_WRITE_H__ */