gst/matroska/: Set timestamps on outgoing ebml headers as well, so that the element...
[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
29 G_BEGIN_DECLS
30
31 #define GST_TYPE_EBML_WRITE \
32   (gst_ebml_write_get_type ())
33 #define GST_EBML_WRITE(obj) \
34   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_EBML_WRITE, GstEbmlWrite))
35 #define GST_EBML_WRITE_CLASS(klass) \
36   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_EBML_WRITE, GstEbmlWriteClass))
37 #define GST_IS_EBML_WRITE(obj) \
38   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_EBML_WRITE))
39 #define GST_IS_EBML_WRITE_CLASS(obj) \
40   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_EBML_WRITE))
41 #define GST_EBML_WRITE_GET_CLASS(obj) \
42   (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_EBML_WRITE, GstEbmlWriteClass))
43
44 typedef struct _GstEbmlWrite {
45   GstObject object;
46
47   GstPad *srcpad;
48   guint64 pos;
49   GstClockTime timestamp;
50
51   GstBuffer *cache;
52   guint cache_size;
53   guint handled;
54
55   GstFlowReturn last_write_result;
56
57   /*< private >*/
58   gpointer _gst_reserved[GST_PADDING];
59 } GstEbmlWrite;
60
61 typedef struct _GstEbmlWriteClass {
62   GstObjectClass parent;
63
64   /*< private >*/
65   gpointer _gst_reserved[GST_PADDING];
66 } GstEbmlWriteClass;
67
68 GType   gst_ebml_write_get_type      (void);
69
70 GstEbmlWrite *gst_ebml_write_new     (GstPad *srcpad);
71 void    gst_ebml_write_reset         (GstEbmlWrite *ebml);
72
73 GstFlowReturn gst_ebml_last_write_result (GstEbmlWrite *ebml);
74
75 /*
76  * Caching means that we do not push one buffer for
77  * each element, but fill this one until a flush.
78  */
79 void    gst_ebml_write_set_cache     (GstEbmlWrite *ebml,
80                                       guint         size);
81 void    gst_ebml_write_flush_cache   (GstEbmlWrite *ebml);
82
83 /*
84  * Seeking.
85  */
86 void    gst_ebml_write_seek          (GstEbmlWrite *ebml,
87                                       guint64       pos);
88
89 /*
90  * Data writing. 
91  */
92 void    gst_ebml_write_uint          (GstEbmlWrite *ebml,
93                                       guint32       id,
94                                       guint64       num);
95 void    gst_ebml_write_sint          (GstEbmlWrite *ebml,
96                                       guint32       id,
97                                       gint64        num);
98 void    gst_ebml_write_float         (GstEbmlWrite *ebml,
99                                       guint32       id,
100                                       gdouble       num);
101 void    gst_ebml_write_ascii         (GstEbmlWrite *ebml,
102                                       guint32       id,
103                                       const gchar  *str);
104 void    gst_ebml_write_utf8          (GstEbmlWrite *ebml,
105                                       guint32       id,
106                                       const gchar  *str);
107 void    gst_ebml_write_date          (GstEbmlWrite *ebml,
108                                       guint32       id,
109                                       gint64        date);
110 guint64 gst_ebml_write_master_start  (GstEbmlWrite *ebml,
111                                       guint32       id);
112 void    gst_ebml_write_master_finish (GstEbmlWrite *ebml,
113                                       guint64       startpos);
114 void    gst_ebml_write_binary        (GstEbmlWrite *ebml,
115                                       guint32       id,
116                                       guchar       *binary,
117                                       guint64       length);
118 void    gst_ebml_write_header        (GstEbmlWrite *ebml,
119                                       gchar        *doctype,
120                                       guint         version);
121
122 /*
123  * Note: this is supposed to be used only for media data.
124  */
125 void    gst_ebml_write_buffer_header (GstEbmlWrite *ebml,
126                                       guint32       id,
127                                       guint64       length);
128 void    gst_ebml_write_buffer        (GstEbmlWrite *ebml,
129                                       GstBuffer    *data);
130
131 /*
132  * A hack, basically... See matroska-mux.c. I should actually
133  * make a nice _replace_element_with_size() or so, but this
134  * works for now.
135  */
136 void    gst_ebml_replace_uint        (GstEbmlWrite *ebml,
137                                       guint64       pos,
138                                       guint64       num);
139
140 G_END_DECLS
141
142 #endif /* __GST_EBML_WRITE_H__ */