qtdemux.h 4.75 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* GStreamer
 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
16 17
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
18 19 20 21 22 23 24
 */


#ifndef __GST_QTDEMUX_H__
#define __GST_QTDEMUX_H__

#include <gst/gst.h>
25
#include <gst/base/gstadapter.h>
Thiago Santos's avatar
Thiago Santos committed
26
#include <gst/base/gstflowcombiner.h>
27
#include "gstisoff.h"
28

29
G_BEGIN_DECLS
30

31 32 33
GST_DEBUG_CATEGORY_EXTERN (qtdemux_debug);
#define GST_CAT_DEFAULT qtdemux_debug

34 35 36 37 38
#define GST_TYPE_QTDEMUX \
  (gst_qtdemux_get_type())
#define GST_QTDEMUX(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_QTDEMUX,GstQTDemux))
#define GST_QTDEMUX_CLASS(klass) \
39
  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_QTDEMUX,GstQTDemuxClass))
40 41
#define GST_IS_QTDEMUX(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_QTDEMUX))
42
#define GST_IS_QTDEMUX_CLASS(klass) \
43 44
  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_QTDEMUX))

45
#define GST_QTDEMUX_CAST(obj) ((GstQTDemux *)(obj))
46

47 48
/* qtdemux produces these for atoms it cannot parse */
#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

Johan Dahlin's avatar
Johan Dahlin committed
53 54 55
typedef struct _GstQTDemux GstQTDemux;
typedef struct _GstQTDemuxClass GstQTDemuxClass;
typedef struct _QtDemuxStream QtDemuxStream;
56

Johan Dahlin's avatar
Johan Dahlin committed
57 58
struct _GstQTDemux {
  GstElement element;
59

Johan Dahlin's avatar
Johan Dahlin committed
60 61
  /* pads */
  GstPad *sinkpad;
62

Johan Dahlin's avatar
Johan Dahlin committed
63
  QtDemuxStream *streams[GST_QTDEMUX_MAX_STREAMS];
64 65 66
  gint     n_streams;
  gint     n_video_streams;
  gint     n_audio_streams;
67
  gint     n_sub_streams;
68

Thiago Santos's avatar
Thiago Santos committed
69 70
  GstFlowCombiner *flowcombiner;

71 72 73
  gboolean have_group_id;
  guint group_id;

74
  guint  major_brand;
75
  GstBuffer *comp_brands;
Johan Dahlin's avatar
Johan Dahlin committed
76 77
  GNode *moov_node;
  GNode *moov_node_compressed;
78

Johan Dahlin's avatar
Johan Dahlin committed
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 92 93 94

  /* push based variables */
  guint neededbytes;
  guint todrop;
  GstAdapter *adapter;
95
  GstBuffer *mdatbuffer;
96
  guint64 mdatleft;
97 98 99 100 101 102 103 104 105
  /* When restoring the mdat to the adatpter, this buffer
   * stores any trailing data that was after the last atom parsed as it
   * has to be restored later along with the correct offset. Used in
   * fragmented scenario where mdat/moof are one after the other
   * in any order.
   *
   * Check https://bugzilla.gnome.org/show_bug.cgi?id=710623 */
  GstBuffer *restoredata_buffer;
  guint64 restoredata_offset;
106

107
  guint64 offset;
108 109
  /* offset of the mdat atom */
  guint64 mdatoffset;
110
  guint64 first_mdat;
111
  gboolean got_moov;
112
  guint64 last_moov_offset;
113
  guint header_size;
114

115 116
  GstTagList *tag_list;

117
  /* configured playback region */
118
  GstSegment segment;
119
  GstEvent *pending_newsegment;
120 121 122 123
  gboolean upstream_format_is_time; /* qtdemux received upstream
                                     * newsegment in TIME format which likely
                                     * means that upstream is driving the pipeline
                                     * (adaptive demuxers / dlna) */
124
  guint32 offset_seek_seqnum;
125 126 127
  gint64 seek_offset;
  gint64 push_seek_start;
  gint64 push_seek_stop;
128

129
#if 0
130 131 132
  /* gst index support */
  GstIndex *element_index;
  gint index_id;
133
#endif
134

135
  gboolean upstream_seekable;
136
  gint64 upstream_size;
Thiago Santos's avatar
Thiago Santos committed
137 138 139 140 141

  /* MSS streams have a single media that is unspecified at the atoms, so
   * upstream provides it at the caps */
  GstCaps *media_caps;
  gboolean exposed;
142 143 144
  gboolean mss_mode; /* flag to indicate that we're working with a smoothstreaming fragment
                      * Mss doesn't have 'moov' or any information about the streams format,
                      * requiring qtdemux to expose and create the streams */
145
  guint64 fragment_start;
146
  guint64 fragment_start_offset;
147 148
    
  gint64 chapters_track_id;
149 150 151 152

  /* protection support */
  GPtrArray *protection_system_ids; /* Holds identifiers of all content protection systems for all tracks */
  GQueue protection_event_queue; /* holds copy of upstream protection events */
153 154 155 156
  guint64 cenc_aux_info_offset;
  guint8 *cenc_aux_info_sizes;
  guint32 cenc_aux_sample_count;

Johan Dahlin's avatar
Johan Dahlin committed
157
};
158

Johan Dahlin's avatar
Johan Dahlin committed
159 160 161
struct _GstQTDemuxClass {
  GstElementClass parent_class;
};
162

163 164
GType gst_qtdemux_get_type (void);

165
G_END_DECLS
166

Johan Dahlin's avatar
Johan Dahlin committed
167
#endif /* __GST_QTDEMUX_H__ */