|
16
|
1 |
/* Quicktime muxer plugin for GStreamer
|
|
|
2 |
* Copyright (C) 2008 Thiago Sousa Santos <thiagoss@embedded.ufcg.edu.br>
|
|
|
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., 59 Temple Place - Suite 330,
|
|
|
17 |
* Boston, MA 02111-1307, USA.
|
|
|
18 |
*/
|
|
|
19 |
/*
|
|
|
20 |
* Unless otherwise indicated, Source Code is licensed under MIT license.
|
|
|
21 |
* See further explanation attached in License Statement (distributed in the file
|
|
|
22 |
* LICENSE).
|
|
|
23 |
*
|
|
|
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:
|
|
|
30 |
*
|
|
|
31 |
* The above copyright notice and this permission notice shall be included in all
|
|
|
32 |
* copies or substantial portions of the Software.
|
|
|
33 |
*
|
|
|
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
|
|
|
40 |
* SOFTWARE.
|
|
|
41 |
*/
|
|
|
42 |
|
|
|
43 |
#ifndef __GST_QT_MUX_H__
|
|
|
44 |
#define __GST_QT_MUX_H__
|
|
|
45 |
|
|
|
46 |
#include <gst/gst.h>
|
|
|
47 |
#include <gst/base/gstcollectpads.h>
|
|
|
48 |
|
|
|
49 |
#include "fourcc.h"
|
|
|
50 |
#include "atoms.h"
|
|
|
51 |
#include "gstqtmuxmap.h"
|
|
|
52 |
|
|
|
53 |
G_BEGIN_DECLS
|
|
|
54 |
|
|
|
55 |
#define GST_TYPE_QT_MUX (gst_qt_mux_get_type())
|
|
|
56 |
#define GST_QT_MUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_QT_MUX, GstQTMux))
|
|
|
57 |
#define GST_QT_MUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_QT_MUX, GstQTMux))
|
|
|
58 |
#define GST_IS_QT_MUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_QT_MUX))
|
|
|
59 |
#define GST_IS_QT_MUX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_QT_MUX))
|
|
|
60 |
#define GST_QT_MUX_CAST(obj) ((GstQTMux*)(obj))
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
typedef struct _GstQTMux GstQTMux;
|
|
|
64 |
typedef struct _GstQTMuxClass GstQTMuxClass;
|
|
|
65 |
|
|
|
66 |
typedef struct _GstQTPad
|
|
|
67 |
{
|
|
|
68 |
GstCollectData collect; /* we extend the CollectData */
|
|
|
69 |
|
|
|
70 |
/* fourcc id of stream */
|
|
|
71 |
guint32 fourcc;
|
|
|
72 |
/* whether using format that have out of order buffers */
|
|
|
73 |
gboolean is_out_of_order;
|
|
|
74 |
/* whether upstream provides valid PTS data */
|
|
|
75 |
gboolean have_dts;
|
|
|
76 |
/* if not 0, track with constant sized samples, e.g. raw audio */
|
|
|
77 |
guint sample_size;
|
|
|
78 |
/* make sync table entry */
|
|
|
79 |
gboolean sync;
|
|
|
80 |
|
|
|
81 |
GstBuffer *last_buf;
|
|
|
82 |
/* dts of last_buf */
|
|
|
83 |
GstClockTime last_dts;
|
|
|
84 |
|
|
|
85 |
/* all the atom and chunk book-keeping is delegated here
|
|
|
86 |
* unowned/uncounted reference, parent MOOV owns */
|
|
|
87 |
AtomTRAK *trak;
|
|
|
88 |
} GstQTPad;
|
|
|
89 |
|
|
|
90 |
typedef enum _GstQTMuxState
|
|
|
91 |
{
|
|
|
92 |
GST_QT_MUX_STATE_NONE,
|
|
|
93 |
GST_QT_MUX_STATE_STARTED,
|
|
|
94 |
GST_QT_MUX_STATE_DATA,
|
|
|
95 |
GST_QT_MUX_STATE_EOS
|
|
|
96 |
} GstQTMuxState;
|
|
|
97 |
|
|
|
98 |
struct _GstQTMux
|
|
|
99 |
{
|
|
|
100 |
GstElement element;
|
|
|
101 |
|
|
|
102 |
GstPad *srcpad;
|
|
|
103 |
GstCollectPads *collect;
|
|
|
104 |
|
|
|
105 |
/* state */
|
|
|
106 |
GstQTMuxState state;
|
|
|
107 |
|
|
|
108 |
/* size of header (prefix, atoms (ftyp, mdat)) */
|
|
|
109 |
guint64 header_size;
|
|
|
110 |
/* accumulated size of raw media data (a priori not including mdat header) */
|
|
|
111 |
guint64 mdat_size;
|
|
|
112 |
/* position of mdat atom (for later updating) */
|
|
|
113 |
guint64 mdat_pos;
|
|
|
114 |
|
|
|
115 |
/* keep track of the largest chunk to fine-tune brands */
|
|
|
116 |
GstClockTime longest_chunk;
|
|
|
117 |
|
|
|
118 |
/* atom helper objects */
|
|
|
119 |
AtomsContext *context;
|
|
|
120 |
AtomFTYP *ftyp;
|
|
|
121 |
AtomMOOV *moov;
|
|
|
122 |
|
|
|
123 |
/* fast start */
|
|
|
124 |
FILE *fast_start_file;
|
|
|
125 |
|
|
|
126 |
/* properties */
|
|
|
127 |
guint32 timescale;
|
|
|
128 |
AtomsTreeFlavor flavor;
|
|
|
129 |
gboolean fast_start;
|
|
|
130 |
gboolean large_file;
|
|
|
131 |
gboolean guess_pts;
|
|
|
132 |
gchar *fast_start_file_path;
|
|
|
133 |
|
|
|
134 |
/* for collect pads event handling function */
|
|
|
135 |
GstPadEventFunction collect_event;
|
|
|
136 |
|
|
|
137 |
/* for request pad naming */
|
|
|
138 |
guint video_pads, audio_pads;
|
|
|
139 |
};
|
|
|
140 |
|
|
|
141 |
struct _GstQTMuxClass
|
|
|
142 |
{
|
|
|
143 |
GstElementClass parent_class;
|
|
|
144 |
|
|
|
145 |
GstQTMuxFormat format;
|
|
|
146 |
};
|
|
|
147 |
|
|
|
148 |
/* type register helper struct */
|
|
|
149 |
typedef struct _GstQTMuxClassParams
|
|
|
150 |
{
|
|
|
151 |
GstQTMuxFormatProp *prop;
|
|
|
152 |
GstCaps *src_caps;
|
|
|
153 |
GstCaps *video_sink_caps;
|
|
|
154 |
GstCaps *audio_sink_caps;
|
|
|
155 |
} GstQTMuxClassParams;
|
|
|
156 |
|
|
|
157 |
#define GST_QT_MUX_PARAMS_QDATA g_quark_from_static_string("qt-mux-params")
|
|
|
158 |
|
|
|
159 |
GType gst_qt_mux_get_type (void);
|
|
|
160 |
|
|
|
161 |
G_END_DECLS
|
|
|
162 |
|
|
|
163 |
#endif /* __GST_QT_MUX_H__ */
|