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 #include "gstqtmuxmap.h"
25 /* static info related to various format */
27 #define COMMON_VIDEO_CAPS \
28 "width = (int) [ 16, 4096 ], " \
29 "height = (int) [ 16, 4096 ], " \
30 "framerate = (fraction) [ 0, MAX ]"
32 #define COMMON_VIDEO_CAPS_NO_FRAMERATE \
33 "width = (int) [ 16, 4096 ], " \
34 "height = (int) [ 16, 4096 ] "
42 "mpegversion = (int) 4, "\
43 "systemstream = (boolean) false, " \
44 COMMON_VIDEO_CAPS "; " \
46 "divxversion = (int) 5, "\
49 #define COMMON_AUDIO_CAPS(c, r) \
50 "channels = (int) [ 1, " G_STRINGIFY (c) " ], " \
51 "rate = (int) [ 1, " G_STRINGIFY (r) " ]"
57 COMMON_AUDIO_CAPS (2, MAX) ", " \
58 "signed = (boolean) { true, false }; " \
60 "width = (int) 16, " \
61 "depth = (int) 16, " \
62 "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, " \
63 COMMON_AUDIO_CAPS (2, MAX) ", " \
64 "signed = (boolean) true " \
66 #define PCM_CAPS_FULL \
69 "width = (int) 24, " \
70 "depth = (int) 24, " \
71 "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, " \
72 COMMON_AUDIO_CAPS (2, MAX) ", " \
73 "signed = (boolean) true; " \
75 "width = (int) 32, " \
76 "depth = (int) 32, " \
77 "endianness = (int) { BIG_ENDIAN, LITTLE_ENDIAN }, " \
78 COMMON_AUDIO_CAPS (2, MAX) ", " \
79 "signed = (boolean) true "
83 "mpegversion = (int) 1, " \
85 COMMON_AUDIO_CAPS (2, MAX)
89 "mpegversion = (int) 4, " \
90 COMMON_AUDIO_CAPS (8, MAX)
93 GstQTMuxFormatProp gst_qt_mux_format_list[] = {
94 /* original QuickTime format; see Apple site (e.g. qtff.pdf) */
100 GST_STATIC_CAPS ("video/quicktime"),
101 GST_STATIC_CAPS ("video/x-raw-rgb, "
102 COMMON_VIDEO_CAPS "; "
104 "format = (fourcc) UYVY, "
105 COMMON_VIDEO_CAPS "; "
107 "h263version = (string) h263, "
108 COMMON_VIDEO_CAPS "; "
112 "systemstream = (boolean) false, "
113 COMMON_VIDEO_CAPS "; "
115 COMMON_VIDEO_CAPS_NO_FRAMERATE "; " "video/x-qt-part"),
116 GST_STATIC_CAPS (PCM_CAPS_FULL "; "
120 COMMON_AUDIO_CAPS (2, MAX) "; "
121 "audio/x-mulaw, " COMMON_AUDIO_CAPS (2, MAX))
124 /* ISO 14496-14: mp42 as ISO base media extension
125 * (supersedes original ISO 144996-1 mp41) */
127 GST_QT_MUX_FORMAT_MP4,
131 /* FIXME does not feel right, due to qt caps mess */
132 GST_STATIC_CAPS ("video/quicktime"),
133 GST_STATIC_CAPS (MPEG4V_CAPS "; " H264_CAPS),
134 GST_STATIC_CAPS (MP3_CAPS "; " AAC_CAPS)
137 /* 3GPP Technical Specification 26.244 V7.3.0
138 * (extended in 3GPP2 File Formats for Multimedia Services) */
140 GST_QT_MUX_FORMAT_3GP,
144 GST_STATIC_CAPS ("application/x-3gp"),
145 GST_STATIC_CAPS (H264_CAPS),
146 GST_STATIC_CAPS ("audio/AMR, "
147 COMMON_AUDIO_CAPS (8, MAX) "; " MP3_CAPS "; " AAC_CAPS)
150 /* ISO 15444-3: Motion-JPEG-2000 (also ISO base media extension) */
152 GST_QT_MUX_FORMAT_MJ2,
156 GST_STATIC_CAPS ("video/mj2"),
157 GST_STATIC_CAPS ("image/x-j2c, " COMMON_VIDEO_CAPS),
158 GST_STATIC_CAPS (PCM_CAPS)
162 GST_QT_MUX_FORMAT_NONE,
167 /* pretty static, but may turn out needed a few times */
169 gst_qt_mux_map_format_to_flavor (GstQTMuxFormat format)
171 if (format == GST_QT_MUX_FORMAT_QT)
172 return ATOMS_TREE_FLAVOR_MOV;
174 return ATOMS_TREE_FLAVOR_ISOM;
177 /* pretty static, but possibly dynamic format info */
180 * - avc1 brand is not used, since the specific extensions indicated by it
181 * are not used (e.g. sample groupings, etc)
182 * - 3GPP2 specific formats not (yet) used, only 3GPP, so no need yet either
183 * for 3g2a (but later on, moov might be used to conditionally switch to
186 gst_qt_mux_map_format_to_header (GstQTMuxFormat format, GstBuffer ** _prefix,
187 guint32 * _major, guint32 * _version, GList ** _compatible, AtomMOOV * moov)
189 static guint32 qt_brands[] = { 0 };
190 static guint32 mp4_brands[] = { FOURCC_mp41, FOURCC_isom, FOURCC_iso2, 0 };
191 static guint32 gpp_brands[] = { FOURCC_isom, FOURCC_iso2, 0 };
192 static guint32 mjp2_brands[] = { FOURCC_isom, FOURCC_iso2, 0 };
193 static guint8 mjp2_prefix[] =
194 { 0, 0, 0, 12, 'j', 'P', ' ', ' ', 0x0D, 0x0A, 0x87, 0x0A };
195 guint32 *comp = NULL;
196 guint32 major = 0, version = 0;
197 GstBuffer *prefix = NULL;
198 GList *result = NULL;
200 g_return_if_fail (_prefix != NULL);
201 g_return_if_fail (_major != NULL);
202 g_return_if_fail (_version != NULL);
203 g_return_if_fail (_compatible != NULL);
206 case GST_QT_MUX_FORMAT_QT:
209 version = 0x20050300;
211 case GST_QT_MUX_FORMAT_MP4:
215 case GST_QT_MUX_FORMAT_3GP:
219 case GST_QT_MUX_FORMAT_MJ2:
223 prefix = gst_buffer_new_and_alloc (sizeof (mjp2_prefix));
224 memcpy (GST_BUFFER_DATA (prefix), mjp2_prefix, GST_BUFFER_SIZE (prefix));
227 g_assert_not_reached ();
231 /* convert list to list, hm */
232 while (comp && *comp != 0) {
233 /* order matters over efficiency */
234 result = g_list_append (result, GUINT_TO_POINTER (*comp));
241 *_compatible = result;
243 /* TODO 3GPP may include mp42 as compatible if applicable */
244 /* TODO 3GPP major brand 3gp7 if at most 1 video and audio track */