matroska: Adds support to muxing/demuxing WMA
[platform/upstream/gst-plugins-good.git] / gst / matroska / matroska-mux.h
1 /* GStreamer Matroska muxer/demuxer
2  * (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
3  * (c) 2005 Michal Benes <michal.benes@xeris.cz>
4  *
5  * matroska-mux.h: matroska file/stream muxer object types
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_MATROSKA_MUX_H__
24 #define __GST_MATROSKA_MUX_H__
25
26 #include <gst/gst.h>
27 #include <gst/base/gstcollectpads.h>
28
29 #include "ebml-write.h"
30 #include "matroska-ids.h"
31
32 G_BEGIN_DECLS
33
34 #define GST_TYPE_MATROSKA_MUX \
35   (gst_matroska_mux_get_type ())
36 #define GST_MATROSKA_MUX(obj) \
37   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MATROSKA_MUX, GstMatroskaMux))
38 #define GST_MATROSKA_MUX_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MATROSKA_MUX, GstMatroskaMuxClass))
40 #define GST_IS_MATROSKA_MUX(obj) \
41   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MATROSKA_MUX))
42 #define GST_IS_MATROSKA_MUX_CLASS(klass) \
43   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MATROSKA_MUX))
44
45 typedef struct _BITMAPINFOHEADER {
46   guint32 bi_size;
47   guint32 bi_width;
48   guint32 bi_height;
49   guint16 bi_planes;
50   guint16 bi_bit_count;
51   guint32 bi_compression;
52   guint32 bi_size_image;
53   guint32 bi_x_pels_per_meter;
54   guint32 bi_y_pels_per_meter;
55   guint32 bi_clr_used;
56   guint32 bi_clr_important;
57 } BITMAPINFOHEADER;
58
59 #define WAVEFORMATEX_SIZE 18
60
61 typedef enum {
62   GST_MATROSKA_MUX_STATE_START,
63   GST_MATROSKA_MUX_STATE_HEADER,
64   GST_MATROSKA_MUX_STATE_DATA,
65 } GstMatroskaMuxState;
66
67 typedef struct _GstMatroskaMetaSeekIndex {
68   guint32  id;
69   guint64  pos;
70 } GstMatroskaMetaSeekIndex;
71
72 /* all information needed for one matroska stream */
73 typedef struct
74 {
75   GstCollectData collect;       /* we extend the CollectData */
76   GstMatroskaTrackContext *track;
77
78   GstBuffer *buffer;            /* the queued buffer for this pad */
79
80   guint64 duration;
81   GstClockTime start_ts;
82   GstClockTime end_ts;    /* last timestamp + (if available) duration */
83 }
84 GstMatroskaPad;
85
86
87 typedef struct _GstMatroskaMux {
88   GstElement     element;
89   
90   /* < private > */
91
92   /* pads */
93   GstPad        *srcpad;
94   GstCollectPads *collect;
95   GstPadEventFunction collect_event;
96   GstEbmlWrite *ebml_write;
97
98   guint          num_streams,
99                  num_v_streams, num_a_streams, num_t_streams;
100
101   /* Application name (for the writing application header element) */
102   gchar          *writing_app;
103
104   /* Matroska version. */
105   guint          matroska_version;
106
107   /* state */
108   GstMatroskaMuxState state;
109
110   /* a cue (index) table */
111   GstMatroskaIndex *index;
112   guint          num_indexes;
113
114   /* timescale in the file */
115   guint64        time_scale;
116
117   /* length, position (time, ns) */
118   guint64        duration;
119
120   /* byte-positions of master-elements (for replacing contents) */
121   guint64        segment_pos,
122                  seekhead_pos,
123                  cues_pos,
124                  tags_pos,
125                  info_pos,
126                  tracks_pos,
127                  duration_pos,
128                  meta_pos;
129   guint64        segment_master;
130
131   /* current cluster */
132   guint64        cluster,
133                  cluster_time,
134                  cluster_pos;
135
136 } GstMatroskaMux;
137
138 typedef struct _GstMatroskaMuxClass {
139   GstElementClass parent;
140 } GstMatroskaMuxClass;
141
142 gboolean gst_matroska_mux_plugin_init (GstPlugin *plugin);
143
144 G_END_DECLS
145
146 #endif /* __GST_MATROSKA_MUX_H__ */