Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to...
[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  *
4  * ebml-write.c: write EBML data to file/stream
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_EBML_WRITE_H__
23 #define __GST_EBML_WRITE_H__
24
25 #include <glib.h>
26 #include <gst/gst.h>
27
28 G_BEGIN_DECLS
29
30 #define GST_TYPE_EBML_WRITE \
31   (gst_ebml_write_get_type ())
32 #define GST_EBML_WRITE(obj) \
33   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_EBML_WRITE, GstEbmlWrite))
34 #define GST_EBML_WRITE_CLASS(klass) \
35   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_EBML_WRITE, GstEbmlWriteClass))
36 #define GST_IS_EBML_WRITE(obj) \
37   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_EBML_WRITE))
38 #define GST_IS_EBML_WRITE_CLASS(obj) \
39   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_EBML_WRITE))
40 #define GST_EBML_WRITE_GET_CLASS(obj) \
41   (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_EBML_WRITE, GstEbmlWriteClass))
42
43 typedef struct _GstEbmlWrite {
44   GstElement parent;
45
46   GstPad *srcpad;
47   guint64 pos;
48
49   GstBuffer *cache;
50   guint handled;
51 } GstEbmlWrite;
52
53 typedef struct _GstEbmlWriteClass {
54   GstElementClass parent;
55 } GstEbmlWriteClass;
56
57 GType   gst_ebml_write_get_type      (void);
58
59 /*
60  * Caching means that we do not push one buffer for
61  * each element, but fill this one until a flush.
62  */
63 void    gst_ebml_write_set_cache     (GstEbmlWrite *ebml,
64                                       guint         size);
65 void    gst_ebml_write_flush_cache   (GstEbmlWrite *ebml);
66
67 /*
68  * Seeking.
69  */
70 void    gst_ebml_write_seek          (GstEbmlWrite *ebml,
71                                       guint64       pos);
72
73 /*
74  * Data writing. 
75  */
76 void    gst_ebml_write_uint          (GstEbmlWrite *ebml,
77                                       guint32       id,
78                                       guint64       num);
79 void    gst_ebml_write_sint          (GstEbmlWrite *ebml,
80                                       guint32       id,
81                                       gint64        num);
82 void    gst_ebml_write_float         (GstEbmlWrite *ebml,
83                                       guint32       id,
84                                       gdouble       num);
85 void    gst_ebml_write_ascii         (GstEbmlWrite *ebml,
86                                       guint32       id,
87                                       const gchar  *str);
88 void    gst_ebml_write_utf8          (GstEbmlWrite *ebml,
89                                       guint32       id,
90                                       const gchar  *str);
91 void    gst_ebml_write_date          (GstEbmlWrite *ebml,
92                                       guint32       id,
93                                       gint64        date);
94 guint64 gst_ebml_write_master_start  (GstEbmlWrite *ebml,
95                                       guint32       id);
96 void    gst_ebml_write_master_finish (GstEbmlWrite *ebml,
97                                       guint64       startpos);
98 void    gst_ebml_write_binary        (GstEbmlWrite *ebml,
99                                       guint32       id,
100                                       guchar       *binary,
101                                       guint64       length);
102 void    gst_ebml_write_header        (GstEbmlWrite *ebml,
103                                       gchar        *doctype,
104                                       guint         version);
105
106 /*
107  * Note: this is supposed to be used only for media data.
108  */
109 void    gst_ebml_write_buffer_header (GstEbmlWrite *ebml,
110                                       guint32       id,
111                                       guint64       length);
112 void    gst_ebml_write_buffer        (GstEbmlWrite *ebml,
113                                       GstBuffer    *data);
114
115 /*
116  * A hack, basically... See matroska-mux.c. I should actually
117  * make a nice _replace_element_with_size() or so, but this
118  * works for now.
119  */
120 void    gst_ebml_replace_uint        (GstEbmlWrite *ebml,
121                                       guint64       pos,
122                                       guint64       num);
123
124 G_END_DECLS
125
126 #endif /* __GST_EBML_WRITE_H__ */