1 /* GStreamer Matroska muxer/demuxer
2 * (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
3 * (c) 2011 Debarshi Ray <rishi@gnu.org>
5 * matroska-read-common.h: shared by matroska file/stream demuxer and parser
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.
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.
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.
23 #ifndef __GST_MATROSKA_READ_COMMON_H__
24 #define __GST_MATROSKA_READ_COMMON_H__
28 #include <gst/base/gstadapter.h>
30 #include "matroska-ids.h"
34 GST_DEBUG_CATEGORY_EXTERN(matroskareadcommon_debug);
37 GST_MATROSKA_READ_STATE_START,
38 GST_MATROSKA_READ_STATE_SEGMENT,
39 GST_MATROSKA_READ_STATE_HEADER,
40 GST_MATROSKA_READ_STATE_DATA,
41 GST_MATROSKA_READ_STATE_SEEK,
42 GST_MATROSKA_READ_STATE_SCANNING
43 } GstMatroskaReadState;
45 typedef struct _GstMatroskaReadCommon {
47 GstIndex *element_index;
48 gint element_index_writer_id;
62 GstMatroskaReadState state;
68 /* did we parse cues/tracks/segmentinfo already? */
69 gboolean index_parsed;
70 gboolean segmentinfo_parsed;
71 gboolean attachments_parsed;
72 gboolean chapters_parsed;
79 /* start-of-segment and length */
80 guint64 ebml_segment_start;
81 guint64 ebml_segment_length;
83 /* a cue (index) table */
86 /* timescale in the file */
89 /* keeping track of playback position */
92 GstTagList *global_tags;
93 gboolean global_tags_changed;
95 /* pull mode caching */
96 GstBuffer *cached_buffer;
98 GstMapInfo cached_map;
100 /* push and pull mode */
103 guint64 start_resync_offset;
105 /* state to restore after scanning for invalid data */
106 gint state_to_restore;
108 /* push based mode usual suspects */
111 /* cache for track tags that forward-reference their tracks */
112 GHashTable *cached_track_taglists ;
114 } GstMatroskaReadCommon;
116 GstFlowReturn gst_matroska_decode_content_encodings (GArray * encodings);
117 gboolean gst_matroska_decode_data (GArray * encodings, gpointer * data_out,
118 gsize * size_out, GstMatroskaTrackEncodingScope scope, gboolean free);
119 gint gst_matroska_index_seek_find (GstMatroskaIndex * i1, GstClockTime * time,
121 GstMatroskaIndex * gst_matroska_read_common_do_index_seek (
122 GstMatroskaReadCommon * common, GstMatroskaTrackContext * track, gint64
123 seek_pos, GArray ** _index, gint * _entry_index, GstSearchMode snap_dir);
124 void gst_matroska_read_common_found_global_tag (GstMatroskaReadCommon * common,
125 GstElement * el, GstTagList * taglist);
126 gint64 gst_matroska_read_common_get_length (GstMatroskaReadCommon * common);
127 GstMatroskaTrackContext * gst_matroska_read_common_get_seek_track (
128 GstMatroskaReadCommon * common, GstMatroskaTrackContext * track);
129 GstFlowReturn gst_matroska_read_common_parse_index (GstMatroskaReadCommon *
130 common, GstEbmlRead * ebml);
131 GstFlowReturn gst_matroska_read_common_parse_info (GstMatroskaReadCommon *
132 common, GstElement * el, GstEbmlRead * ebml);
133 GstFlowReturn gst_matroska_read_common_parse_attachments (
134 GstMatroskaReadCommon * common, GstElement * el, GstEbmlRead * ebml);
135 GstFlowReturn gst_matroska_read_common_parse_chapters (GstMatroskaReadCommon *
136 common, GstEbmlRead * ebml);
137 GstFlowReturn gst_matroska_read_common_parse_header (GstMatroskaReadCommon *
138 common, GstEbmlRead * ebml);
139 GstFlowReturn gst_matroska_read_common_parse_metadata (GstMatroskaReadCommon *
140 common, GstElement * el, GstEbmlRead * ebml);
141 GstFlowReturn gst_matroska_read_common_parse_skip (GstMatroskaReadCommon *
142 common, GstEbmlRead * ebml, const gchar * parent_name, guint id);
143 GstFlowReturn gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon *
144 common, guint64 offset, guint size, GstBuffer ** p_buf, guint8 ** bytes);
145 GstFlowReturn gst_matroska_read_common_peek_id_length_pull (GstMatroskaReadCommon *
146 common, GstElement * el, guint32 * _id, guint64 * _length, guint *
148 GstFlowReturn gst_matroska_read_common_peek_id_length_push (GstMatroskaReadCommon *
149 common, GstElement * el, guint32 * _id, guint64 * _length, guint *
151 gint gst_matroska_read_common_stream_from_num (GstMatroskaReadCommon * common,
153 GstFlowReturn gst_matroska_read_common_read_track_encodings (
154 GstMatroskaReadCommon * common, GstEbmlRead * ebml,
155 GstMatroskaTrackContext * context);
156 void gst_matroska_read_common_reset_streams (GstMatroskaReadCommon * common,
157 GstClockTime time, gboolean full);
158 void gst_matroska_read_common_free_parsed_el (gpointer mem, gpointer user_data);
159 void gst_matroska_read_common_init (GstMatroskaReadCommon * ctx);
160 void gst_matroska_read_common_finalize (GstMatroskaReadCommon * ctx);
161 void gst_matroska_read_common_reset (GstElement * element,
162 GstMatroskaReadCommon * ctx);
163 gboolean gst_matroska_read_common_tracknumber_unique (GstMatroskaReadCommon *
164 common, guint64 num);
168 #endif /* __GST_MATROSKA_READ_COMMON_H__ */