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., 51 Franklin St, Fifth Floor, 20 * Boston, MA 02110-1301, 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 typedef gboolean (*GstMatroskaCapsFunc) (GstPad *pad, GstCaps *caps); 57 58 typedef struct _GstMatroskaMux GstMatroskaMux; 59 60 /* all information needed for one matroska stream */ 61 typedef struct 62 { 63 GstCollectData collect; /* we extend the CollectData */ 64 GstMatroskaCapsFunc capsfunc; 65 GstMatroskaTrackContext *track; 66 67 GstMatroskaMux *mux; 68 69 GstTagList *tags; 70 71 GstClockTime start_ts; 72 GstClockTime end_ts; /* last timestamp + (if available) duration */ 73 guint64 default_duration_scaled; 74 } 75 GstMatroskaPad; 76 77 78 struct _GstMatroskaMux { 79 GstElement element; 80 81 /* < private > */ 82 83 /* pads */ 84 GstPad *srcpad; 85 GstCollectPads *collect; 86 GstEbmlWrite *ebml_write; 87 88 guint num_streams, 89 num_v_streams, num_a_streams, num_t_streams; 90 91 /* Application name (for the writing application header element) */ 92 gchar *writing_app; 93 94 /* Date (for the DateUTC header element) */ 95 GDateTime *creation_time; 96 97 /* EBML DocType. */ 98 const gchar *doctype; 99 100 /* DocType version. */ 101 guint doctype_version; 102 103 /* state */ 104 GstMatroskaMuxState state; 105 106 /* a cue (index) table */ 107 GstMatroskaIndex *index; 108 guint num_indexes; 109 GstClockTimeDiff min_index_interval; 110 111 /* timescale in the file */ 112 guint64 time_scale; 113 /* minimum and maximum limit of nanoseconds you can have in a cluster */ 114 guint64 max_cluster_duration; 115 guint64 min_cluster_duration; 116 117 /* earliest timestamp (time, ns) if offsetting to zero */ 118 gboolean offset_to_zero; 119 guint64 cluster_timestamp_offset; 120 guint64 earliest_time; 121 /* length, position (time, ns) */ 122 guint64 duration; 123 124 /* byte-positions of master-elements (for replacing contents) */ 125 guint64 segment_pos, 126 seekhead_pos, 127 cues_pos, 128 chapters_pos, 129 tags_pos, 130 info_pos, 131 tracks_pos, 132 duration_pos, 133 meta_pos; 134 guint64 segment_master; 135 136 /* current cluster */ 137 guint64 cluster, 138 cluster_time, 139 cluster_pos, 140 prev_cluster_size; 141 142 /* GstForceKeyUnit event */ 143 GstEvent *force_key_unit_event; 144 145 /* Internal Toc (adjusted UIDs and title tags removed when processed) */ 146 GstToc *internal_toc; 147 148 /* Flag to ease handling of WebM specifics */ 149 gboolean is_webm; 150 }; 151 152 typedef struct _GstMatroskaMuxClass { 153 GstElementClass parent; 154 } GstMatroskaMuxClass; 155 156 GType gst_matroska_mux_get_type (void); 157 158 G_END_DECLS 159 160 #endif /* __GST_MATROSKA_MUX_H__ */ 161