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., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, 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;
65 /* did we parse cues/tracks/segmentinfo already? */
66 gboolean index_parsed;
67 gboolean segmentinfo_parsed;
68 gboolean attachments_parsed;
69 gboolean chapters_parsed;
76 /* start-of-segment */
77 guint64 ebml_segment_start;
79 /* a cue (index) table */
82 /* timescale in the file */
85 /* keeping track of playback position */
88 GstTagList *global_tags;
90 /* pull mode caching */
91 GstBuffer *cached_buffer;
93 GstMapInfo cached_map;
95 /* push and pull mode */
98 /* push based mode usual suspects */
100 } GstMatroskaReadCommon;
102 GstFlowReturn gst_matroska_decode_content_encodings (GArray * encodings);
103 gboolean gst_matroska_decode_data (GArray * encodings, gpointer * data_out,
104 gsize * size_out, GstMatroskaTrackEncodingScope scope, gboolean free);
105 gint gst_matroska_index_seek_find (GstMatroskaIndex * i1, GstClockTime * time,
107 GstMatroskaIndex * gst_matroska_read_common_do_index_seek (
108 GstMatroskaReadCommon * common, GstMatroskaTrackContext * track, gint64
109 seek_pos, GArray ** _index, gint * _entry_index);
110 void gst_matroska_read_common_found_global_tag (GstMatroskaReadCommon * common,
111 GstElement * el, GstTagList * taglist);
112 gint64 gst_matroska_read_common_get_length (GstMatroskaReadCommon * common);
113 GstMatroskaTrackContext * gst_matroska_read_common_get_seek_track (
114 GstMatroskaReadCommon * common, GstMatroskaTrackContext * track);
115 GstFlowReturn gst_matroska_read_common_parse_index (GstMatroskaReadCommon *
116 common, GstEbmlRead * ebml);
117 GstFlowReturn gst_matroska_read_common_parse_info (GstMatroskaReadCommon *
118 common, GstElement * el, GstEbmlRead * ebml);
119 GstFlowReturn gst_matroska_read_common_parse_attachments (
120 GstMatroskaReadCommon * common, GstElement * el, GstEbmlRead * ebml);
121 GstFlowReturn gst_matroska_read_common_parse_chapters (GstMatroskaReadCommon *
122 common, GstEbmlRead * ebml);
123 GstFlowReturn gst_matroska_read_common_parse_header (GstMatroskaReadCommon *
124 common, GstEbmlRead * ebml);
125 GstFlowReturn gst_matroska_read_common_parse_metadata (GstMatroskaReadCommon *
126 common, GstElement * el, GstEbmlRead * ebml);
127 GstFlowReturn gst_matroska_read_common_parse_skip (GstMatroskaReadCommon *
128 common, GstEbmlRead * ebml, const gchar * parent_name, guint id);
129 GstFlowReturn gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon *
130 common, guint64 offset, guint size, GstBuffer ** p_buf, guint8 ** bytes);
131 GstFlowReturn gst_matroska_read_common_peek_id_length_pull (GstMatroskaReadCommon *
132 common, GstElement * el, guint32 * _id, guint64 * _length, guint *
134 GstFlowReturn gst_matroska_read_common_peek_id_length_push (GstMatroskaReadCommon *
135 common, GstElement * el, guint32 * _id, guint64 * _length, guint *
137 gint gst_matroska_read_common_stream_from_num (GstMatroskaReadCommon * common,
139 GstFlowReturn gst_matroska_read_common_read_track_encodings (
140 GstMatroskaReadCommon * common, GstEbmlRead * ebml,
141 GstMatroskaTrackContext * context);
142 void gst_matroska_read_common_reset_streams (GstMatroskaReadCommon * common,
143 GstClockTime time, gboolean full);
144 gboolean gst_matroska_read_common_tracknumber_unique (GstMatroskaReadCommon *
145 common, guint64 num);
149 #endif /* __GST_MATROSKA_READ_COMMON_H__ */