qtdemux: Initial 'sidx' atom parsing support
[platform/upstream/gst-plugins-good.git] / gst / isomp4 / qtdemux.h
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20
21 #ifndef __GST_QTDEMUX_H__
22 #define __GST_QTDEMUX_H__
23
24 #include <gst/gst.h>
25 #include <gst/base/gstadapter.h>
26 #include <gst/base/gstflowcombiner.h>
27 #include "gstisoff.h"
28
29 G_BEGIN_DECLS
30
31 GST_DEBUG_CATEGORY_EXTERN (qtdemux_debug);
32 #define GST_CAT_DEFAULT qtdemux_debug
33
34 #define GST_TYPE_QTDEMUX \
35   (gst_qtdemux_get_type())
36 #define GST_QTDEMUX(obj) \
37   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_QTDEMUX,GstQTDemux))
38 #define GST_QTDEMUX_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_QTDEMUX,GstQTDemuxClass))
40 #define GST_IS_QTDEMUX(obj) \
41   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_QTDEMUX))
42 #define GST_IS_QTDEMUX_CLASS(klass) \
43   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_QTDEMUX))
44
45 #define GST_QTDEMUX_CAST(obj) ((GstQTDemux *)(obj))
46
47 /* qtdemux produces these for atoms it cannot parse */
48 #define GST_QT_DEMUX_PRIVATE_TAG "private-qt-tag"
49 #define GST_QT_DEMUX_CLASSIFICATION_TAG "classification"
50
51 #define GST_QTDEMUX_MAX_STREAMS         32
52
53 typedef struct _GstQTDemux GstQTDemux;
54 typedef struct _GstQTDemuxClass GstQTDemuxClass;
55 typedef struct _QtDemuxStream QtDemuxStream;
56
57 struct _GstQTDemux {
58   GstElement element;
59
60   /* pads */
61   GstPad *sinkpad;
62
63   QtDemuxStream *streams[GST_QTDEMUX_MAX_STREAMS];
64   gint     n_streams;
65   gint     n_video_streams;
66   gint     n_audio_streams;
67   gint     n_sub_streams;
68
69   GstFlowCombiner *flowcombiner;
70
71   gboolean have_group_id;
72   guint group_id;
73
74   guint  major_brand;
75   GstBuffer *comp_brands;
76   GNode *moov_node;
77   GNode *moov_node_compressed;
78
79   guint32 timescale;
80   GstClockTime duration;
81
82   gboolean fragmented;
83   gboolean fragmented_seek_pending;
84   guint64 moof_offset;
85
86   gint state;
87
88   gboolean pullbased;
89   gboolean posted_redirect;
90
91   /* push based variables */
92   guint neededbytes;
93   guint todrop;
94   GstAdapter *adapter;
95   GstBuffer *mdatbuffer;
96   guint64 mdatleft;
97   /* When restoring the mdat to the adatpter, this buffer
98    * stores any trailing data that was after the last atom parsed as it
99    * has to be restored later along with the correct offset. Used in
100    * fragmented scenario where mdat/moof are one after the other
101    * in any order.
102    *
103    * Check https://bugzilla.gnome.org/show_bug.cgi?id=710623 */
104   GstBuffer *restoredata_buffer;
105   guint64 restoredata_offset;
106
107   guint64 offset;
108   /* offset of the mdat atom */
109   guint64 mdatoffset;
110   guint64 first_mdat;
111   gboolean got_moov;
112   guint64 last_moov_offset;
113   guint header_size;
114
115   GstTagList *tag_list;
116
117   /* configured playback region */
118   GstSegment segment;
119   GstEvent *pending_newsegment;
120   gboolean upstream_newsegment; /* qtdemux received upstream
121                                  * newsegment in TIME format which likely
122                                  * means that upstream is driving the pipeline
123                                  * (adaptive demuxers) */
124   gint64 seek_offset;
125   gint64 push_seek_start;
126   gint64 push_seek_stop;
127
128 #if 0
129   /* gst index support */
130   GstIndex *element_index;
131   gint index_id;
132 #endif
133
134   gboolean upstream_seekable;
135   gint64 upstream_size;
136
137   /* MSS streams have a single media that is unspecified at the atoms, so
138    * upstream provides it at the caps */
139   GstCaps *media_caps;
140   gboolean exposed;
141   gboolean mss_mode; /* flag to indicate that we're working with a smoothstreaming fragment
142                       * Mss doesn't have 'moov' or any information about the streams format,
143                       * requiring qtdemux to expose and create the streams */
144   guint64 fragment_start;
145   guint64 fragment_start_offset;
146     
147   gint64 chapters_track_id;
148 };
149
150 struct _GstQTDemuxClass {
151   GstElementClass parent_class;
152 };
153
154 GType gst_qtdemux_get_type (void);
155
156 G_END_DECLS
157
158 #endif /* __GST_QTDEMUX_H__ */