ebml-write.h 5.13 KB
Newer Older
1 2
/* GStreamer EBML I/O
 * (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
3
 * (c) 2005 Michal Benes <michal.benes@xeris.cz>
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 * ebml-write.c: write EBML data to file/stream
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef __GST_EBML_WRITE_H__
#define __GST_EBML_WRITE_H__

#include <glib.h>
#include <gst/gst.h>
28
#include <gst/base/gstbytewriter.h>
29 30

G_BEGIN_DECLS
Johan Dahlin's avatar
Johan Dahlin committed
31

32 33 34 35 36 37 38 39
#define GST_TYPE_EBML_WRITE \
  (gst_ebml_write_get_type ())
#define GST_EBML_WRITE(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_EBML_WRITE, GstEbmlWrite))
#define GST_EBML_WRITE_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_EBML_WRITE, GstEbmlWriteClass))
#define GST_IS_EBML_WRITE(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_EBML_WRITE))
Stefan Kost's avatar
Stefan Kost committed
40
#define GST_IS_EBML_WRITE_CLASS(klass) \
41 42 43
  (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_EBML_WRITE))
#define GST_EBML_WRITE_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_EBML_WRITE, GstEbmlWriteClass))
Johan Dahlin's avatar
Johan Dahlin committed
44 45

typedef struct _GstEbmlWrite {
46
  GstObject object;
47 48 49

  GstPad *srcpad;
  guint64 pos;
50
  GstClockTime timestamp;
51

52 53
  GstByteWriter *cache;
  guint64 cache_pos;
54 55 56

  GstFlowReturn last_write_result;

57
  gboolean need_newsegment;
58 59
} GstEbmlWrite;

Johan Dahlin's avatar
Johan Dahlin committed
60
typedef struct _GstEbmlWriteClass {
61
  GstObjectClass parent;
62 63
} GstEbmlWriteClass;

Johan Dahlin's avatar
Johan Dahlin committed
64
GType   gst_ebml_write_get_type      (void);
65

66 67 68 69 70
GstEbmlWrite *gst_ebml_write_new     (GstPad *srcpad);
void    gst_ebml_write_reset         (GstEbmlWrite *ebml);

GstFlowReturn gst_ebml_last_write_result (GstEbmlWrite *ebml);

71 72 73 74
/*
 * Caching means that we do not push one buffer for
 * each element, but fill this one until a flush.
 */
Johan Dahlin's avatar
Johan Dahlin committed
75
void    gst_ebml_write_set_cache     (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
76
                                      guint         size);
Johan Dahlin's avatar
Johan Dahlin committed
77
void    gst_ebml_write_flush_cache   (GstEbmlWrite *ebml);
78 79 80 81

/*
 * Seeking.
 */
Johan Dahlin's avatar
Johan Dahlin committed
82
void    gst_ebml_write_seek          (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
83
                                      guint64       pos);
84 85 86 87

/*
 * Data writing. 
 */
Johan Dahlin's avatar
Johan Dahlin committed
88
void    gst_ebml_write_uint          (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
89 90
                                      guint32       id,
                                      guint64       num);
Johan Dahlin's avatar
Johan Dahlin committed
91
void    gst_ebml_write_sint          (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
92 93
                                      guint32       id,
                                      gint64        num);
Johan Dahlin's avatar
Johan Dahlin committed
94
void    gst_ebml_write_float         (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
95 96
                                      guint32       id,
                                      gdouble       num);
Johan Dahlin's avatar
Johan Dahlin committed
97
void    gst_ebml_write_ascii         (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
98 99
                                      guint32       id,
                                      const gchar  *str);
Johan Dahlin's avatar
Johan Dahlin committed
100
void    gst_ebml_write_utf8          (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
101 102
                                      guint32       id,
                                      const gchar  *str);
Johan Dahlin's avatar
Johan Dahlin committed
103
void    gst_ebml_write_date          (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
104 105
                                      guint32       id,
                                      gint64        date);
Johan Dahlin's avatar
Johan Dahlin committed
106
guint64 gst_ebml_write_master_start  (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
107
                                      guint32       id);
Johan Dahlin's avatar
Johan Dahlin committed
108
void    gst_ebml_write_master_finish (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
109
                                      guint64       startpos);
110 111 112
void    gst_ebml_write_master_finish_full (GstEbmlWrite * ebml,
                                      guint64 startpos,
                                      guint64 extra_size);
Johan Dahlin's avatar
Johan Dahlin committed
113
void    gst_ebml_write_binary        (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
114 115 116
                                      guint32       id,
                                      guchar       *binary,
                                      guint64       length);
Johan Dahlin's avatar
Johan Dahlin committed
117
void    gst_ebml_write_header        (GstEbmlWrite *ebml,
118
                                      const gchar  *doctype,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
119
                                      guint         version);
120 121 122 123

/*
 * Note: this is supposed to be used only for media data.
 */
Johan Dahlin's avatar
Johan Dahlin committed
124
void    gst_ebml_write_buffer_header (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
125 126
                                      guint32       id,
                                      guint64       length);
Johan Dahlin's avatar
Johan Dahlin committed
127
void    gst_ebml_write_buffer        (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
128
                                      GstBuffer    *data);
129 130 131 132 133 134

/*
 * A hack, basically... See matroska-mux.c. I should actually
 * make a nice _replace_element_with_size() or so, but this
 * works for now.
 */
Johan Dahlin's avatar
Johan Dahlin committed
135
void    gst_ebml_replace_uint        (GstEbmlWrite *ebml,
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
136 137
                                      guint64       pos,
                                      guint64       num);
138 139

G_END_DECLS
Johan Dahlin's avatar
Johan Dahlin committed
140

141
#endif /* __GST_EBML_WRITE_H__ */