tizen 2.0 init
[framework/multimedia/gst-plugins-good0.10.git] / gst / matroska / matroska-read-common.h
1 /* GStreamer Matroska muxer/demuxer
2  * (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
3  * (c) 2011 Debarshi Ray <rishi@gnu.org>
4  *
5  * matroska-read-common.h: shared by matroska file/stream demuxer and parser
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_READ_COMMON_H__
24 #define __GST_MATROSKA_READ_COMMON_H__
25
26 #include <glib.h>
27 #include <gst/gst.h>
28 #include <gst/base/gstadapter.h>
29
30 #include "matroska-ids.h"
31
32 G_BEGIN_DECLS
33
34 GST_DEBUG_CATEGORY_EXTERN(matroskareadcommon_debug);
35
36 typedef enum {
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;
44
45 typedef struct _GstMatroskaReadCommon {
46   GstIndex                *element_index;
47   gint                     element_index_writer_id;
48
49   /* pads */
50   GstPad                  *sinkpad;
51   GPtrArray               *src;
52   guint                    num_streams;
53
54   /* metadata */
55   gchar                   *muxing_app;
56   gchar                   *writing_app;
57   gint64                   created;
58
59   /* state */
60   GstMatroskaReadState     state;
61
62   /* did we parse cues/tracks/segmentinfo already? */
63   gboolean                 index_parsed;
64   gboolean                 segmentinfo_parsed;
65   gboolean                 attachments_parsed;
66   GList                   *tags_parsed;
67
68   /* start-of-segment */
69   guint64                  ebml_segment_start;
70
71   /* a cue (index) table */
72   GArray                  *index;
73
74   /* timescale in the file */
75   guint64                  time_scale;
76
77   /* keeping track of playback position */
78   GstSegment               segment;
79
80   GstTagList              *global_tags;
81
82   /* pull mode caching */
83   GstBuffer *cached_buffer;
84
85   /* push and pull mode */
86   guint64                  offset;
87
88   /* push based mode usual suspects */
89   GstAdapter              *adapter;
90 } GstMatroskaReadCommon;
91
92 GstFlowReturn gst_matroska_decode_content_encodings (GArray * encodings);
93 gboolean gst_matroska_decode_data (GArray * encodings, guint8 ** data_out,
94     guint * size_out, GstMatroskaTrackEncodingScope scope, gboolean free);
95 gint gst_matroska_index_seek_find (GstMatroskaIndex * i1, GstClockTime * time,
96     gpointer user_data);
97 GstMatroskaIndex * gst_matroska_read_common_do_index_seek (
98     GstMatroskaReadCommon * common, GstMatroskaTrackContext * track, gint64
99     seek_pos, GArray ** _index, gint * _entry_index);
100 void gst_matroska_read_common_found_global_tag (GstMatroskaReadCommon * common,
101     GstElement * el, GstTagList * taglist);
102 gint64 gst_matroska_read_common_get_length (GstMatroskaReadCommon * common);
103 GstMatroskaTrackContext * gst_matroska_read_common_get_seek_track (
104     GstMatroskaReadCommon * common, GstMatroskaTrackContext * track);
105 GstFlowReturn gst_matroska_read_common_parse_index (GstMatroskaReadCommon *
106     common, GstEbmlRead * ebml);
107 GstFlowReturn gst_matroska_read_common_parse_info (GstMatroskaReadCommon *
108     common, GstElement * el, GstEbmlRead * ebml);
109 GstFlowReturn gst_matroska_read_common_parse_attachments (
110     GstMatroskaReadCommon * common, GstElement * el, GstEbmlRead * ebml);
111 GstFlowReturn gst_matroska_read_common_parse_chapters (GstMatroskaReadCommon *
112     common, GstEbmlRead * ebml);
113 GstFlowReturn gst_matroska_read_common_parse_header (GstMatroskaReadCommon *
114     common, GstEbmlRead * ebml);
115 GstFlowReturn gst_matroska_read_common_parse_metadata (GstMatroskaReadCommon *
116     common, GstElement * el, GstEbmlRead * ebml);
117 GstFlowReturn gst_matroska_read_common_parse_skip (GstMatroskaReadCommon *
118     common, GstEbmlRead * ebml, const gchar * parent_name, guint id);
119 GstFlowReturn gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon *
120     common, guint64 offset, guint size, GstBuffer ** p_buf, guint8 ** bytes);
121 GstFlowReturn gst_matroska_read_common_peek_id_length_pull (GstMatroskaReadCommon *
122     common, GstElement * el, guint32 * _id, guint64 * _length, guint *
123     _needed);
124 GstFlowReturn gst_matroska_read_common_peek_id_length_push (GstMatroskaReadCommon *
125     common, GstElement * el, guint32 * _id, guint64 * _length, guint *
126     _needed);
127 gint gst_matroska_read_common_stream_from_num (GstMatroskaReadCommon * common,
128     guint track_num);
129 GstFlowReturn gst_matroska_read_common_read_track_encodings (
130     GstMatroskaReadCommon * common, GstEbmlRead * ebml,
131     GstMatroskaTrackContext * context);
132 void gst_matroska_read_common_reset_streams (GstMatroskaReadCommon * common,
133     GstClockTime time, gboolean full);
134 gboolean gst_matroska_read_common_tracknumber_unique (GstMatroskaReadCommon *
135     common, guint64 num);
136
137 G_END_DECLS
138
139 #endif /* __GST_MATROSKA_READ_COMMON_H__ */