1 /* Quicktime muxer plugin for GStreamer
2 * Copyright (C) 2008-2010 Thiago Santos <thiagoss@embedded.ufcg.edu.br>
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.
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.
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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 * Unless otherwise indicated, Source Code is licensed under MIT license.
21 * See further explanation attached in License Statement (distributed in the file
24 * Permission is hereby granted, free of charge, to any person obtaining a copy of
25 * this software and associated documentation files (the "Software"), to deal in
26 * the Software without restriction, including without limitation the rights to
27 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
28 * of the Software, and to permit persons to whom the Software is furnished to do
29 * so, subject to the following conditions:
31 * The above copyright notice and this permission notice shall be included in all
32 * copies or substantial portions of the Software.
34 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
43 #ifndef __GST_QT_MUX_H__
44 #define __GST_QT_MUX_H__
47 #include <gst/base/gstcollectpads.h>
51 #include "atomsrecovery.h"
52 #include "gstqtmuxmap.h"
56 #define GST_TYPE_QT_MUX (gst_qt_mux_get_type())
57 #define GST_QT_MUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_QT_MUX, GstQTMux))
58 #define GST_QT_MUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_QT_MUX, GstQTMux))
59 #define GST_IS_QT_MUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_QT_MUX))
60 #define GST_IS_QT_MUX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_QT_MUX))
61 #define GST_QT_MUX_CAST(obj) ((GstQTMux*)(obj))
64 typedef struct _GstQTMux GstQTMux;
65 typedef struct _GstQTMuxClass GstQTMuxClass;
66 typedef struct _GstQTPad GstQTPad;
69 * GstQTPadPrepareBufferFunc
71 * Receives a buffer (takes ref) and returns a new buffer that should
72 * replace the passed one.
74 * Useful for when the pad/datatype needs some manipulation before
75 * being muxed. (Originally added for image/x-jpc support, for which buffers
76 * need to be wrapped into a isom box)
78 typedef GstBuffer * (*GstQTPadPrepareBufferFunc) (GstQTPad * pad,
79 GstBuffer * buf, GstQTMux * qtmux);
81 #define QTMUX_NO_OF_TS 10
85 GstCollectData collect; /* we extend the CollectData */
87 /* fourcc id of stream */
89 /* whether using format that have out of order buffers */
90 gboolean is_out_of_order;
91 /* whether upstream provides valid PTS data */
93 /* if not 0, track with constant sized samples, e.g. raw audio */
95 /* make sync table entry */
98 guint32 avg_bitrate, max_bitrate;
100 /* for avg bitrate calculation */
102 guint64 total_duration;
105 /* dts of last_buf */
106 GstClockTime last_dts;
108 /* store the first timestamp for comparing with other streams and
109 * know if there are late streams */
110 GstClockTime first_ts;
111 GstClockTime ts_entries[QTMUX_NO_OF_TS + 2];
113 GstBuffer *buf_entries[QTMUX_NO_OF_TS + 2];
117 /* all the atom and chunk book-keeping is delegated here
118 * unowned/uncounted reference, parent MOOV owns */
120 /* fragmented support */
121 /* meta data book-keeping delegated here */
123 /* fragment buffers */
124 ATOM_ARRAY (GstBuffer *) fragment_buffers;
125 /* running fragment duration */
126 gint64 fragment_duration;
127 /* optional fragment index book-keeping */
130 /* if nothing is set, it won't be called */
131 GstQTPadPrepareBufferFunc prepare_buf_func;
134 typedef enum _GstQTMuxState
136 GST_QT_MUX_STATE_NONE,
137 GST_QT_MUX_STATE_STARTED,
138 GST_QT_MUX_STATE_DATA,
147 GstCollectPads *collect;
153 /* size of header (prefix, atoms (ftyp, mdat)) */
155 /* accumulated size of raw media data (a priori not including mdat header) */
157 /* position of mdat atom (for later updating) */
160 /* keep track of the largest chunk to fine-tune brands */
161 GstClockTime longest_chunk;
163 /* atom helper objects */
164 AtomsContext *context;
167 GSList *extra_atoms; /* list of extra top-level atoms (e.g. UUID for xmp)
168 * Stored as AtomInfo structs */
170 /* fragmented file index */
174 FILE *fast_start_file;
177 FILE *moov_recov_file;
179 /* fragment sequence */
180 guint32 fragment_sequence;
184 guint32 trak_timescale;
185 AtomsTreeFlavor flavor;
189 gchar *fast_start_file_path;
190 gchar *moov_recov_file_path;
191 guint32 fragment_duration;
194 /* for collect pads event handling function */
195 GstPadEventFunction collect_event;
197 /* for request pad naming */
198 guint video_pads, audio_pads;
201 struct _GstQTMuxClass
203 GstElementClass parent_class;
205 GstQTMuxFormat format;
208 /* type register helper struct */
209 typedef struct _GstQTMuxClassParams
211 GstQTMuxFormatProp *prop;
213 GstCaps *video_sink_caps;
214 GstCaps *audio_sink_caps;
215 } GstQTMuxClassParams;
217 #define GST_QT_MUX_PARAMS_QDATA g_quark_from_static_string("qt-mux-params")
219 GType gst_qt_mux_get_type (void);
220 gboolean gst_qt_mux_register (GstPlugin * plugin);
222 /* FIXME: ideally classification tag should be added and
223 * registered in gstreamer core gsttaglist
225 * this tag is a string in the format: entityfourcc://table_num/content
226 * FIXME Shouldn't we add a field for 'language'?
228 #define GST_TAG_3GP_CLASSIFICATION "classification"
232 #endif /* __GST_QT_MUX_H__ */