1 /* Quicktime muxer plugin for GStreamer
2 * Copyright (C) 2008 Thiago Sousa Santos <thiagoss@embedded.ufcg.edu.br>
3 * Copyright (C) 2008 Mark Nauwelaerts <mnauw@users.sf.net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 * Unless otherwise indicated, Source Code is licensed under MIT license.
22 * See further explanation attached in License Statement (distributed in the file
25 * Permission is hereby granted, free of charge, to any person obtaining a copy of
26 * this software and associated documentation files (the "Software"), to deal in
27 * the Software without restriction, including without limitation the rights to
28 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
29 * of the Software, and to permit persons to whom the Software is furnished to do
30 * so, subject to the following conditions:
32 * The above copyright notice and this permission notice shall be included in all
33 * copies or substantial portions of the Software.
35 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
44 #include "gstqtmuxmap.h"
48 /* static info related to various format */
50 #define COMMON_VIDEO_CAPS \
51 "width = (int) [ 16, 4096 ], " \
52 "height = (int) [ 16, 4096 ], " \
53 "framerate = (fraction) [ 0, MAX ]"
55 #define COMMON_VIDEO_CAPS_NO_FRAMERATE \
56 "width = (int) [ 16, 4096 ], " \
57 "height = (int) [ 16, 4096 ] "
65 "mpegversion = (int) 4, "\
66 "systemstream = (boolean) false, " \
67 COMMON_VIDEO_CAPS "; " \
69 "divxversion = (int) 5, "\
72 #define COMMON_AUDIO_CAPS(c, r) \
73 "channels = (int) [ 1, " G_STRINGIFY (c) " ], " \
74 "rate = (int) [ 1, " G_STRINGIFY (r) " ]"
80 COMMON_AUDIO_CAPS (2, MAX) ", " \
81 "signed = (boolean) { true, false }; " \
83 "width = (int) 16, " \
84 "depth = (int) 16, " \
85 "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, " \
86 COMMON_AUDIO_CAPS (2, MAX) ", " \
87 "signed = (boolean) true " \
89 #define PCM_CAPS_FULL \
92 "width = (int) 24, " \
93 "depth = (int) 24, " \
94 "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, " \
95 COMMON_AUDIO_CAPS (2, MAX) ", " \
96 "signed = (boolean) true; " \
98 "width = (int) 32, " \
99 "depth = (int) 32, " \
100 "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, " \
101 COMMON_AUDIO_CAPS (2, MAX) ", " \
102 "signed = (boolean) true "
106 "mpegversion = (int) 1, " \
107 "layer = (int) 3, " \
108 COMMON_AUDIO_CAPS (2, MAX)
112 "mpegversion = (int) 4, " \
113 COMMON_AUDIO_CAPS (8, MAX)
116 GstQTMuxFormatProp gst_qt_mux_format_list[] = {
117 /* original QuickTime format; see Apple site (e.g. qtff.pdf) */
119 GST_QT_MUX_FORMAT_QT,
123 GST_STATIC_CAPS ("video/quicktime"),
124 GST_STATIC_CAPS ("video/x-raw-rgb, "
125 COMMON_VIDEO_CAPS "; "
127 "format = (fourcc) UYVY, "
128 COMMON_VIDEO_CAPS "; "
130 "h263version = (string) h263, "
131 COMMON_VIDEO_CAPS "; "
135 "systemstream = (boolean) false, "
136 COMMON_VIDEO_CAPS "; "
138 COMMON_VIDEO_CAPS_NO_FRAMERATE "; "
139 "video/x-qt-part, " COMMON_VIDEO_CAPS),
140 GST_STATIC_CAPS (PCM_CAPS_FULL "; "
144 COMMON_AUDIO_CAPS (2, MAX) "; "
145 "audio/x-mulaw, " COMMON_AUDIO_CAPS (2, MAX))
148 /* ISO 14496-14: mp42 as ISO base media extension
149 * (supersedes original ISO 144996-1 mp41) */
151 GST_QT_MUX_FORMAT_MP4,
155 /* FIXME does not feel right, due to qt caps mess */
156 GST_STATIC_CAPS ("video/quicktime"),
157 GST_STATIC_CAPS (MPEG4V_CAPS "; " H264_CAPS ";"
158 "video/x-mp4-part," COMMON_VIDEO_CAPS),
159 GST_STATIC_CAPS (MP3_CAPS "; " AAC_CAPS)
162 /* 3GPP Technical Specification 26.244 V7.3.0
163 * (extended in 3GPP2 File Formats for Multimedia Services) */
165 GST_QT_MUX_FORMAT_3GP,
169 GST_STATIC_CAPS ("application/x-3gp"),
170 GST_STATIC_CAPS (H264_CAPS),
171 GST_STATIC_CAPS ("audio/AMR, "
172 COMMON_AUDIO_CAPS (8, MAX) "; " MP3_CAPS "; " AAC_CAPS)
175 /* ISO 15444-3: Motion-JPEG-2000 (also ISO base media extension) */
177 GST_QT_MUX_FORMAT_MJ2,
181 GST_STATIC_CAPS ("video/mj2"),
182 GST_STATIC_CAPS ("image/x-j2c, " COMMON_VIDEO_CAPS),
183 GST_STATIC_CAPS (PCM_CAPS)
187 GST_QT_MUX_FORMAT_NONE,
192 /* pretty static, but may turn out needed a few times */
194 gst_qt_mux_map_format_to_flavor (GstQTMuxFormat format)
196 if (format == GST_QT_MUX_FORMAT_QT)
197 return ATOMS_TREE_FLAVOR_MOV;
199 return ATOMS_TREE_FLAVOR_ISOM;
202 /* pretty static, but possibly dynamic format info */
205 * - avc1 brand is not used, since the specific extensions indicated by it
206 * are not used (e.g. sample groupings, etc)
207 * - 3GPP2 specific formats not (yet) used, only 3GPP, so no need yet either
208 * for 3g2a (but later on, moov might be used to conditionally switch to
211 gst_qt_mux_map_format_to_header (GstQTMuxFormat format, GstBuffer ** _prefix,
212 guint32 * _major, guint32 * _version, GList ** _compatible, AtomMOOV * moov)
214 static guint32 qt_brands[] = { 0 };
215 static guint32 mp4_brands[] = { FOURCC_mp41, FOURCC_isom, FOURCC_iso2, 0 };
216 static guint32 gpp_brands[] = { FOURCC_isom, FOURCC_iso2, 0 };
217 static guint32 mjp2_brands[] = { FOURCC_isom, FOURCC_iso2, 0 };
218 static guint8 mjp2_prefix[] =
219 { 0, 0, 0, 12, 'j', 'P', ' ', ' ', 0x0D, 0x0A, 0x87, 0x0A };
220 guint32 *comp = NULL;
221 guint32 major = 0, version = 0;
222 GstBuffer *prefix = NULL;
223 GList *result = NULL;
225 g_return_if_fail (_prefix != NULL);
226 g_return_if_fail (_major != NULL);
227 g_return_if_fail (_version != NULL);
228 g_return_if_fail (_compatible != NULL);
231 case GST_QT_MUX_FORMAT_QT:
234 version = 0x20050300;
236 case GST_QT_MUX_FORMAT_MP4:
240 case GST_QT_MUX_FORMAT_3GP:
244 case GST_QT_MUX_FORMAT_MJ2:
248 prefix = gst_buffer_new_and_alloc (sizeof (mjp2_prefix));
249 memcpy (GST_BUFFER_DATA (prefix), mjp2_prefix, GST_BUFFER_SIZE (prefix));
252 g_assert_not_reached ();
256 /* convert list to list, hm */
257 while (comp && *comp != 0) {
258 /* order matters over efficiency */
259 result = g_list_append (result, GUINT_TO_POINTER (*comp));
266 *_compatible = result;
268 /* TODO 3GPP may include mp42 as compatible if applicable */
269 /* TODO 3GPP major brand 3gp7 if at most 1 video and audio track */