upload tizen1.0 source
[framework/multimedia/gst-plugins-good0.10.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 enum {
46   GST_MATROSKA_MUX_STATE_START,
47   GST_MATROSKA_MUX_STATE_HEADER,
48   GST_MATROSKA_MUX_STATE_DATA,
49 } GstMatroskaMuxState;
50
51 typedef struct _GstMatroskaMetaSeekIndex {
52   guint32  id;
53   guint64  pos;
54 } GstMatroskaMetaSeekIndex;
55
56 /* all information needed for one matroska stream */
57 typedef struct
58 {
59   GstCollectData collect;       /* we extend the CollectData */
60   GstMatroskaTrackContext *track;
61
62   GstBuffer *buffer;            /* the queued buffer for this pad */
63
64   guint64 duration;
65   GstClockTime start_ts;
66   GstClockTime end_ts;    /* last timestamp + (if available) duration */
67 }
68 GstMatroskaPad;
69
70
71 typedef struct _GstMatroskaMux {
72   GstElement     element;
73   
74   /* < private > */
75
76   /* pads */
77   GstPad        *srcpad;
78   GstCollectPads *collect;
79   GstPadEventFunction collect_event;
80   GstEbmlWrite *ebml_write;
81
82   guint          num_streams,
83                  num_v_streams, num_a_streams, num_t_streams;
84
85   /* Application name (for the writing application header element) */
86   gchar          *writing_app;
87
88   /* EBML DocType. */
89   const gchar    *doctype;
90
91   /* DocType version. */
92   guint          doctype_version;
93
94   /* state */
95   GstMatroskaMuxState state;
96
97   /* a cue (index) table */
98   GstMatroskaIndex *index;
99   guint          num_indexes;
100   GstClockTimeDiff min_index_interval;
101   gboolean       streamable;
102  
103   /* timescale in the file */
104   guint64        time_scale;
105   /* based on timescale, limit of nanoseconds you can have in a cluster */ 
106   guint64        max_cluster_duration;
107
108   /* length, position (time, ns) */
109   guint64        duration;
110
111   /* byte-positions of master-elements (for replacing contents) */
112   guint64        segment_pos,
113                  seekhead_pos,
114                  cues_pos,
115                  tags_pos,
116                  info_pos,
117                  tracks_pos,
118                  duration_pos,
119                  meta_pos;
120   guint64        segment_master;
121
122   /* current cluster */
123   guint64        cluster,
124                  cluster_time,
125                  cluster_pos,
126                  prev_cluster_size;
127
128 } GstMatroskaMux;
129
130 typedef struct _GstMatroskaMuxClass {
131   GstElementClass parent;
132 } GstMatroskaMuxClass;
133
134 GType   gst_matroska_mux_get_type (void);
135
136 G_END_DECLS
137
138 #endif /* __GST_MATROSKA_MUX_H__ */