2008-11-08 02:00:58 +00:00
|
|
|
/* Quicktime muxer plugin for GStreamer
|
|
|
|
* Copyright (C) 2008 Thiago Sousa Santos <thiagoss@embedded.ufcg.edu.br>
|
|
|
|
* Copyright (C) 2008 Mark Nauwelaerts <mnauw@users.sf.net>
|
|
|
|
*
|
|
|
|
* 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
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2008-11-08 02:00:58 +00:00
|
|
|
*/
|
2008-12-19 18:33:47 +00:00
|
|
|
/*
|
|
|
|
* Unless otherwise indicated, Source Code is licensed under MIT license.
|
|
|
|
* See further explanation attached in License Statement (distributed in the file
|
|
|
|
* LICENSE).
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
* this software and associated documentation files (the "Software"), to deal in
|
|
|
|
* the Software without restriction, including without limitation the rights to
|
|
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is furnished to do
|
|
|
|
* so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
2008-11-08 02:00:58 +00:00
|
|
|
|
|
|
|
#include "gstqtmuxmap.h"
|
|
|
|
#include "fourcc.h"
|
|
|
|
|
|
|
|
/* static info related to various format */
|
|
|
|
|
|
|
|
#define COMMON_VIDEO_CAPS \
|
2014-11-20 10:45:07 +00:00
|
|
|
"width = (int) [ 16, MAX ], " \
|
|
|
|
"height = (int) [ 16, MAX ]"
|
2008-11-08 02:00:58 +00:00
|
|
|
|
|
|
|
#define COMMON_VIDEO_CAPS_NO_FRAMERATE \
|
2014-11-20 10:45:07 +00:00
|
|
|
"width = (int) [ 16, MAX ], " \
|
|
|
|
"height = (int) [ 16, MAX ] "
|
2008-11-08 02:00:58 +00:00
|
|
|
|
2009-01-28 12:25:14 +00:00
|
|
|
#define H263_CAPS \
|
|
|
|
"video/x-h263, " \
|
|
|
|
COMMON_VIDEO_CAPS
|
|
|
|
|
2008-11-08 02:00:58 +00:00
|
|
|
#define H264_CAPS \
|
|
|
|
"video/x-h264, " \
|
2021-08-06 21:36:48 +00:00
|
|
|
"stream-format = (string) { avc, avc3 }, " \
|
2011-04-13 15:37:07 +00:00
|
|
|
"alignment = (string) au, " \
|
2008-11-08 02:00:58 +00:00
|
|
|
COMMON_VIDEO_CAPS
|
|
|
|
|
2016-12-08 16:02:22 +00:00
|
|
|
#define H265_CAPS \
|
|
|
|
"video/x-h265, " \
|
|
|
|
"stream-format = (string) { hvc1, hev1 }, " \
|
|
|
|
"alignment = (string) au, " \
|
|
|
|
COMMON_VIDEO_CAPS
|
|
|
|
|
2008-11-08 02:00:58 +00:00
|
|
|
#define MPEG4V_CAPS \
|
|
|
|
"video/mpeg, " \
|
|
|
|
"mpegversion = (int) 4, "\
|
|
|
|
"systemstream = (boolean) false, " \
|
|
|
|
COMMON_VIDEO_CAPS "; " \
|
|
|
|
"video/x-divx, " \
|
|
|
|
"divxversion = (int) 5, "\
|
|
|
|
COMMON_VIDEO_CAPS
|
|
|
|
|
2015-10-11 08:18:40 +00:00
|
|
|
#define PRORES_CAPS \
|
2017-01-17 09:53:39 +00:00
|
|
|
"video/x-prores, " \
|
|
|
|
"variant = (string) {standard, lt, hq, proxy, 4444, 4444xq}, " \
|
2015-10-11 08:18:40 +00:00
|
|
|
COMMON_VIDEO_CAPS
|
|
|
|
|
2017-03-14 09:10:19 +00:00
|
|
|
#define CINEFORM_CAPS \
|
|
|
|
"video/x-cineform, " \
|
|
|
|
COMMON_VIDEO_CAPS
|
|
|
|
|
2009-10-29 11:36:02 +00:00
|
|
|
#define SVQ_CAPS \
|
|
|
|
"video/x-svq, " \
|
|
|
|
"svqversion = (int) 3, " \
|
|
|
|
COMMON_VIDEO_CAPS
|
|
|
|
|
2008-11-08 02:00:58 +00:00
|
|
|
#define COMMON_AUDIO_CAPS(c, r) \
|
|
|
|
"channels = (int) [ 1, " G_STRINGIFY (c) " ], " \
|
|
|
|
"rate = (int) [ 1, " G_STRINGIFY (r) " ]"
|
|
|
|
|
|
|
|
#define PCM_CAPS \
|
2012-01-04 10:29:26 +00:00
|
|
|
"audio/x-raw, " \
|
2015-10-19 08:14:19 +00:00
|
|
|
"format = (string) { S16LE, S16BE, S8, U8 }, " \
|
2012-01-04 10:29:26 +00:00
|
|
|
"layout = (string) interleaved, " \
|
|
|
|
COMMON_AUDIO_CAPS (2, MAX)
|
2008-11-08 02:00:58 +00:00
|
|
|
|
|
|
|
#define PCM_CAPS_FULL \
|
2012-01-04 10:29:26 +00:00
|
|
|
"audio/x-raw, " \
|
2015-10-19 08:14:19 +00:00
|
|
|
"format = (string) { S32LE, S32BE, S24LE, S24BE, S16LE, S16BE, S8, U8 }, " \
|
2012-01-04 10:29:26 +00:00
|
|
|
"layout = (string) interleaved, " \
|
2015-10-19 08:14:19 +00:00
|
|
|
COMMON_AUDIO_CAPS (2, MAX)
|
2008-11-08 02:00:58 +00:00
|
|
|
|
2016-11-21 14:17:31 +00:00
|
|
|
#define PCM_CAPS_UNPOSITIONED \
|
|
|
|
"audio/x-raw, " \
|
|
|
|
"format = (string) { S32LE, S32BE, S24LE, S24BE, S16LE, S16BE, S8, U8 }, " \
|
|
|
|
"layout = (string) interleaved, " \
|
|
|
|
"channel-mask = (bitmask) 0, " \
|
|
|
|
COMMON_AUDIO_CAPS (16, MAX)
|
|
|
|
|
2008-11-08 02:00:58 +00:00
|
|
|
#define MP3_CAPS \
|
|
|
|
"audio/mpeg, " \
|
|
|
|
"mpegversion = (int) 1, " \
|
|
|
|
"layer = (int) 3, " \
|
|
|
|
COMMON_AUDIO_CAPS (2, MAX)
|
|
|
|
|
2016-04-28 13:24:52 +00:00
|
|
|
#define MP123_CAPS \
|
|
|
|
"audio/mpeg, " \
|
|
|
|
"mpegversion = (int) 1, " \
|
|
|
|
"layer = (int) [1, 3], " \
|
|
|
|
COMMON_AUDIO_CAPS (2, MAX)
|
|
|
|
|
2008-11-08 02:00:58 +00:00
|
|
|
#define AAC_CAPS \
|
|
|
|
"audio/mpeg, " \
|
|
|
|
"mpegversion = (int) 4, " \
|
2010-01-11 16:13:41 +00:00
|
|
|
"stream-format = (string) raw, " \
|
2008-11-08 02:00:58 +00:00
|
|
|
COMMON_AUDIO_CAPS (8, MAX)
|
|
|
|
|
2015-06-11 01:27:27 +00:00
|
|
|
#define AC3_CAPS \
|
|
|
|
"audio/x-ac3, " \
|
|
|
|
COMMON_AUDIO_CAPS (6, MAX)
|
|
|
|
|
2009-01-28 12:25:14 +00:00
|
|
|
#define AMR_CAPS \
|
|
|
|
"audio/AMR, " \
|
|
|
|
"rate = (int) 8000, " \
|
|
|
|
"channels = [ 1, 2 ]; " \
|
|
|
|
"audio/AMR-WB, " \
|
|
|
|
"rate = (int) 16000, " \
|
|
|
|
"channels = [ 1, 2 ] "
|
2008-11-08 02:00:58 +00:00
|
|
|
|
2009-12-09 01:55:56 +00:00
|
|
|
#define ADPCM_CAPS \
|
|
|
|
"audio/x-adpcm, " \
|
|
|
|
"layout = (string)dvi, " \
|
|
|
|
"block_align = (int)[64, 8096], " \
|
|
|
|
COMMON_AUDIO_CAPS(2, MAX)
|
|
|
|
|
2010-02-16 15:24:12 +00:00
|
|
|
#define ALAC_CAPS \
|
|
|
|
"audio/x-alac, " \
|
|
|
|
COMMON_AUDIO_CAPS(2, MAX)
|
2009-12-09 01:55:56 +00:00
|
|
|
|
2015-11-16 13:26:50 +00:00
|
|
|
#define OPUS_CAPS \
|
|
|
|
"audio/x-opus, " \
|
|
|
|
"channel-mapping-family = (int) [0, 255], " \
|
|
|
|
COMMON_AUDIO_CAPS(8, MAX)
|
|
|
|
|
|
|
|
|
2014-02-06 15:15:22 +00:00
|
|
|
#define TEXT_UTF8 \
|
|
|
|
"text/x-raw, " \
|
|
|
|
"format=(string)utf8"
|
|
|
|
|
2018-02-07 10:00:18 +00:00
|
|
|
#define CEA608_CAPS \
|
2018-12-10 15:34:03 +00:00
|
|
|
"closedcaption/x-cea-608, format=(string)s334-1a"
|
2018-02-07 10:00:18 +00:00
|
|
|
#define CEA708_CAPS \
|
|
|
|
"closedcaption/x-cea-708, format=(string)cdp"
|
|
|
|
|
2009-04-30 17:43:36 +00:00
|
|
|
/* FIXME 0.11 - take a look at bugs #580005 and #340375 */
|
2008-11-08 02:00:58 +00:00
|
|
|
GstQTMuxFormatProp gst_qt_mux_format_list[] = {
|
|
|
|
/* original QuickTime format; see Apple site (e.g. qtff.pdf) */
|
|
|
|
{
|
|
|
|
GST_QT_MUX_FORMAT_QT,
|
2011-04-21 21:51:52 +00:00
|
|
|
GST_RANK_PRIMARY,
|
2008-11-08 02:00:58 +00:00
|
|
|
"qtmux",
|
|
|
|
"QuickTime",
|
2020-09-29 12:44:54 +00:00
|
|
|
"GstQTMux",
|
2011-04-13 14:18:11 +00:00
|
|
|
GST_STATIC_CAPS ("video/quicktime, variant = (string) apple; "
|
|
|
|
"video/quicktime"),
|
2011-06-29 10:46:20 +00:00
|
|
|
GST_STATIC_CAPS ("video/x-raw, "
|
2015-01-13 18:05:20 +00:00
|
|
|
"format = (string) { RGB, UYVY, v210 }, "
|
2008-11-08 02:00:58 +00:00
|
|
|
COMMON_VIDEO_CAPS "; "
|
|
|
|
MPEG4V_CAPS "; "
|
2015-10-11 08:18:40 +00:00
|
|
|
PRORES_CAPS "; "
|
2017-03-14 09:10:19 +00:00
|
|
|
CINEFORM_CAPS "; "
|
2009-01-28 12:25:14 +00:00
|
|
|
H263_CAPS "; "
|
2008-11-08 02:00:58 +00:00
|
|
|
H264_CAPS "; "
|
2016-12-08 16:02:22 +00:00
|
|
|
H265_CAPS "; "
|
2009-10-29 11:36:02 +00:00
|
|
|
SVQ_CAPS "; "
|
2008-11-08 02:00:58 +00:00
|
|
|
"video/x-dv, "
|
|
|
|
"systemstream = (boolean) false, "
|
|
|
|
COMMON_VIDEO_CAPS "; "
|
|
|
|
"image/jpeg, "
|
2009-01-09 21:59:48 +00:00
|
|
|
COMMON_VIDEO_CAPS_NO_FRAMERATE "; "
|
2017-06-15 22:31:24 +00:00
|
|
|
"image/png, "
|
|
|
|
COMMON_VIDEO_CAPS_NO_FRAMERATE "; "
|
2010-05-13 01:50:34 +00:00
|
|
|
"video/x-vp8, "
|
2011-07-07 00:18:05 +00:00
|
|
|
COMMON_VIDEO_CAPS "; "
|
2017-11-13 01:38:06 +00:00
|
|
|
"video/x-vp9, "
|
|
|
|
COMMON_VIDEO_CAPS "; "
|
2011-07-07 00:18:05 +00:00
|
|
|
"video/x-dirac, "
|
2018-07-25 22:37:48 +00:00
|
|
|
COMMON_VIDEO_CAPS "; " "video/x-qt-part, " COMMON_VIDEO_CAPS "; "
|
|
|
|
"video/x-av1, " COMMON_VIDEO_CAPS),
|
2008-11-08 02:00:58 +00:00
|
|
|
GST_STATIC_CAPS (PCM_CAPS_FULL "; "
|
2016-11-21 14:17:31 +00:00
|
|
|
PCM_CAPS_UNPOSITIONED " ; "
|
2017-09-06 13:55:38 +00:00
|
|
|
MP123_CAPS " ; "
|
2008-11-08 02:00:58 +00:00
|
|
|
AAC_CAPS " ; "
|
2017-09-06 13:55:38 +00:00
|
|
|
AC3_CAPS " ; "
|
2009-12-09 01:55:56 +00:00
|
|
|
ADPCM_CAPS " ; "
|
2010-02-16 15:24:12 +00:00
|
|
|
"audio/x-alaw, " COMMON_AUDIO_CAPS (2, MAX) "; "
|
2013-03-18 11:30:50 +00:00
|
|
|
"audio/x-mulaw, " COMMON_AUDIO_CAPS (2, MAX) "; "
|
2017-09-06 13:55:38 +00:00
|
|
|
AMR_CAPS " ; " ALAC_CAPS " ; " OPUS_CAPS),
|
2018-02-07 10:00:18 +00:00
|
|
|
GST_STATIC_CAPS (TEXT_UTF8),
|
|
|
|
GST_STATIC_CAPS (CEA608_CAPS "; " CEA708_CAPS)}
|
2008-11-08 02:00:58 +00:00
|
|
|
,
|
|
|
|
/* ISO 14496-14: mp42 as ISO base media extension
|
|
|
|
* (supersedes original ISO 144996-1 mp41) */
|
|
|
|
{
|
|
|
|
GST_QT_MUX_FORMAT_MP4,
|
2011-04-21 21:51:52 +00:00
|
|
|
GST_RANK_PRIMARY,
|
2008-11-08 02:00:58 +00:00
|
|
|
"mp4mux",
|
|
|
|
"MP4",
|
|
|
|
"GstMP4Mux",
|
2009-04-30 17:43:36 +00:00
|
|
|
GST_STATIC_CAPS ("video/quicktime, variant = (string) iso"),
|
2016-12-08 16:02:22 +00:00
|
|
|
GST_STATIC_CAPS (MPEG4V_CAPS "; " H264_CAPS ";" H265_CAPS ";"
|
2018-07-25 22:37:48 +00:00
|
|
|
"video/x-mp4-part," COMMON_VIDEO_CAPS "; "
|
|
|
|
"video/x-av1, " COMMON_VIDEO_CAPS),
|
2016-04-28 13:24:52 +00:00
|
|
|
GST_STATIC_CAPS (MP123_CAPS "; "
|
2015-11-16 13:26:50 +00:00
|
|
|
AAC_CAPS " ; " AC3_CAPS " ; " ALAC_CAPS " ; " OPUS_CAPS),
|
2018-02-07 10:00:18 +00:00
|
|
|
GST_STATIC_CAPS (TEXT_UTF8),
|
|
|
|
GST_STATIC_CAPS_NONE}
|
2008-11-08 02:00:58 +00:00
|
|
|
,
|
2010-09-02 11:58:05 +00:00
|
|
|
/* Microsoft Smooth Streaming fmp4/isml */
|
|
|
|
/* TODO add WMV/WMA support */
|
|
|
|
{
|
|
|
|
GST_QT_MUX_FORMAT_ISML,
|
2011-04-21 21:51:52 +00:00
|
|
|
GST_RANK_PRIMARY,
|
2010-09-02 11:58:05 +00:00
|
|
|
"ismlmux",
|
|
|
|
"ISML",
|
|
|
|
"GstISMLMux",
|
2011-11-25 22:28:55 +00:00
|
|
|
GST_STATIC_CAPS ("video/quicktime, variant = (string) iso-fragmented"),
|
2010-09-02 11:58:05 +00:00
|
|
|
GST_STATIC_CAPS (MPEG4V_CAPS "; " H264_CAPS),
|
2014-02-05 13:27:54 +00:00
|
|
|
GST_STATIC_CAPS (MP3_CAPS "; " AAC_CAPS),
|
2018-02-07 10:00:18 +00:00
|
|
|
GST_STATIC_CAPS_NONE,
|
2014-02-05 13:27:54 +00:00
|
|
|
GST_STATIC_CAPS_NONE}
|
2010-09-02 11:58:05 +00:00
|
|
|
,
|
2008-11-08 02:00:58 +00:00
|
|
|
/* 3GPP Technical Specification 26.244 V7.3.0
|
|
|
|
* (extended in 3GPP2 File Formats for Multimedia Services) */
|
|
|
|
{
|
|
|
|
GST_QT_MUX_FORMAT_3GP,
|
2011-04-21 21:51:52 +00:00
|
|
|
GST_RANK_PRIMARY,
|
|
|
|
"3gppmux",
|
|
|
|
"3GPP",
|
|
|
|
"Gst3GPPMux",
|
|
|
|
GST_STATIC_CAPS ("video/quicktime, variant = (string) 3gpp"),
|
|
|
|
GST_STATIC_CAPS (H263_CAPS "; " MPEG4V_CAPS "; " H264_CAPS),
|
2015-06-11 01:27:27 +00:00
|
|
|
GST_STATIC_CAPS (AMR_CAPS "; " MP3_CAPS "; " AAC_CAPS "; " AC3_CAPS),
|
2018-02-07 10:00:18 +00:00
|
|
|
GST_STATIC_CAPS (TEXT_UTF8),
|
|
|
|
GST_STATIC_CAPS_NONE}
|
2011-04-21 21:51:52 +00:00
|
|
|
,
|
2008-11-08 02:00:58 +00:00
|
|
|
/* ISO 15444-3: Motion-JPEG-2000 (also ISO base media extension) */
|
|
|
|
{
|
|
|
|
GST_QT_MUX_FORMAT_MJ2,
|
2011-04-21 21:51:52 +00:00
|
|
|
GST_RANK_PRIMARY,
|
2008-11-08 02:00:58 +00:00
|
|
|
"mj2mux",
|
|
|
|
"MJ2",
|
|
|
|
"GstMJ2Mux",
|
|
|
|
GST_STATIC_CAPS ("video/mj2"),
|
2009-12-11 01:20:45 +00:00
|
|
|
GST_STATIC_CAPS ("image/x-j2c, " COMMON_VIDEO_CAPS "; "
|
|
|
|
"image/x-jpc, " COMMON_VIDEO_CAPS),
|
2014-02-05 13:27:54 +00:00
|
|
|
GST_STATIC_CAPS (PCM_CAPS),
|
2018-02-07 10:00:18 +00:00
|
|
|
GST_STATIC_CAPS_NONE,
|
2014-02-05 13:27:54 +00:00
|
|
|
GST_STATIC_CAPS_NONE}
|
2008-11-08 02:00:58 +00:00
|
|
|
,
|
|
|
|
{
|
|
|
|
GST_QT_MUX_FORMAT_NONE,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* pretty static, but may turn out needed a few times */
|
|
|
|
AtomsTreeFlavor
|
|
|
|
gst_qt_mux_map_format_to_flavor (GstQTMuxFormat format)
|
|
|
|
{
|
|
|
|
if (format == GST_QT_MUX_FORMAT_QT)
|
|
|
|
return ATOMS_TREE_FLAVOR_MOV;
|
2009-06-10 10:42:44 +00:00
|
|
|
else if (format == GST_QT_MUX_FORMAT_3GP)
|
|
|
|
return ATOMS_TREE_FLAVOR_3GP;
|
2010-09-02 11:58:05 +00:00
|
|
|
else if (format == GST_QT_MUX_FORMAT_ISML)
|
|
|
|
return ATOMS_TREE_FLAVOR_ISML;
|
2008-11-08 02:00:58 +00:00
|
|
|
else
|
|
|
|
return ATOMS_TREE_FLAVOR_ISOM;
|
|
|
|
}
|
|
|
|
|
2009-06-01 20:42:08 +00:00
|
|
|
static void
|
|
|
|
gst_qt_mux_map_check_tracks (AtomMOOV * moov, gint * _video, gint * _audio,
|
|
|
|
gboolean * _has_h264)
|
|
|
|
{
|
|
|
|
GList *it;
|
|
|
|
gint video = 0, audio = 0;
|
|
|
|
gboolean has_h264 = FALSE;
|
|
|
|
|
|
|
|
for (it = moov->traks; it != NULL; it = g_list_next (it)) {
|
|
|
|
AtomTRAK *track = it->data;
|
|
|
|
|
|
|
|
if (track->is_video) {
|
|
|
|
video++;
|
|
|
|
if (track->is_h264)
|
|
|
|
has_h264 = TRUE;
|
|
|
|
} else
|
|
|
|
audio++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_video)
|
|
|
|
*_video = video;
|
|
|
|
if (_audio)
|
|
|
|
*_audio = audio;
|
|
|
|
if (_has_h264)
|
|
|
|
*_has_h264 = has_h264;
|
|
|
|
}
|
|
|
|
|
2008-11-08 02:00:58 +00:00
|
|
|
/* pretty static, but possibly dynamic format info */
|
|
|
|
|
|
|
|
/* notes:
|
|
|
|
* - avc1 brand is not used, since the specific extensions indicated by it
|
|
|
|
* are not used (e.g. sample groupings, etc)
|
2009-06-01 20:42:08 +00:00
|
|
|
* - TODO: maybe even more 3GPP brand fine-tuning ??
|
|
|
|
* (but that might need ftyp rewriting at the end) */
|
2008-11-08 02:00:58 +00:00
|
|
|
void
|
|
|
|
gst_qt_mux_map_format_to_header (GstQTMuxFormat format, GstBuffer ** _prefix,
|
2009-10-16 13:47:32 +00:00
|
|
|
guint32 * _major, guint32 * _version, GList ** _compatible, AtomMOOV * moov,
|
|
|
|
GstClockTime longest_chunk, gboolean faststart)
|
2008-11-08 02:00:58 +00:00
|
|
|
{
|
2015-01-21 08:55:30 +00:00
|
|
|
static const guint32 qt_brands[] = { 0 };
|
|
|
|
static const guint32 mp4_brands[] =
|
|
|
|
{ FOURCC_mp41, FOURCC_isom, FOURCC_iso2, 0 };
|
|
|
|
static const guint32 isml_brands[] = { FOURCC_iso2, 0 };
|
|
|
|
static const guint32 gpp_brands[] = { FOURCC_isom, FOURCC_iso2, 0 };
|
|
|
|
static const guint32 mjp2_brands[] = { FOURCC_isom, FOURCC_iso2, 0 };
|
|
|
|
static const guint8 mjp2_prefix[] =
|
2008-11-08 02:00:58 +00:00
|
|
|
{ 0, 0, 0, 12, 'j', 'P', ' ', ' ', 0x0D, 0x0A, 0x87, 0x0A };
|
2015-01-21 08:55:30 +00:00
|
|
|
const guint32 *comp = NULL;
|
2008-11-14 20:17:10 +00:00
|
|
|
guint32 major = 0, version = 0;
|
2008-11-08 02:00:58 +00:00
|
|
|
GstBuffer *prefix = NULL;
|
|
|
|
GList *result = NULL;
|
|
|
|
|
|
|
|
g_return_if_fail (_prefix != NULL);
|
|
|
|
g_return_if_fail (_major != NULL);
|
|
|
|
g_return_if_fail (_version != NULL);
|
|
|
|
g_return_if_fail (_compatible != NULL);
|
|
|
|
|
|
|
|
switch (format) {
|
|
|
|
case GST_QT_MUX_FORMAT_QT:
|
|
|
|
major = FOURCC_qt__;
|
|
|
|
comp = qt_brands;
|
|
|
|
version = 0x20050300;
|
|
|
|
break;
|
|
|
|
case GST_QT_MUX_FORMAT_MP4:
|
|
|
|
major = FOURCC_mp42;
|
|
|
|
comp = mp4_brands;
|
|
|
|
break;
|
2010-09-02 11:58:05 +00:00
|
|
|
case GST_QT_MUX_FORMAT_ISML:
|
|
|
|
major = FOURCC_isml;
|
|
|
|
comp = isml_brands;
|
|
|
|
break;
|
2008-11-08 02:00:58 +00:00
|
|
|
case GST_QT_MUX_FORMAT_3GP:
|
2009-06-01 20:42:08 +00:00
|
|
|
{
|
|
|
|
gint video, audio;
|
|
|
|
gboolean has_h264;
|
|
|
|
|
|
|
|
gst_qt_mux_map_check_tracks (moov, &video, &audio, &has_h264);
|
|
|
|
/* only track restriction really matters for Basic Profile */
|
|
|
|
if (video <= 1 && audio <= 1) {
|
|
|
|
/* it seems only newer spec knows about H264 */
|
|
|
|
major = has_h264 ? FOURCC_3gp6 : FOURCC_3gp4;
|
|
|
|
version = has_h264 ? 0x100 : 0x200;
|
|
|
|
} else {
|
|
|
|
major = FOURCC_3gg6;
|
|
|
|
version = 0x100;
|
|
|
|
}
|
2008-11-08 02:00:58 +00:00
|
|
|
comp = gpp_brands;
|
2009-10-16 13:47:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We assume that we have chunks in dts order
|
|
|
|
*/
|
|
|
|
if (faststart && longest_chunk <= GST_SECOND) {
|
|
|
|
/* add progressive download profile */
|
|
|
|
result = g_list_append (result, GUINT_TO_POINTER (FOURCC_3gr6));
|
|
|
|
}
|
2008-11-08 02:00:58 +00:00
|
|
|
break;
|
2009-06-01 20:42:08 +00:00
|
|
|
}
|
2008-11-08 02:00:58 +00:00
|
|
|
case GST_QT_MUX_FORMAT_MJ2:
|
2011-06-29 10:46:20 +00:00
|
|
|
{
|
2008-11-08 02:00:58 +00:00
|
|
|
major = FOURCC_mjp2;
|
|
|
|
comp = mjp2_brands;
|
2008-11-14 20:17:10 +00:00
|
|
|
version = 0;
|
2008-11-08 02:00:58 +00:00
|
|
|
prefix = gst_buffer_new_and_alloc (sizeof (mjp2_prefix));
|
2012-01-23 16:25:37 +00:00
|
|
|
gst_buffer_fill (prefix, 0, mjp2_prefix, sizeof (mjp2_prefix));
|
2008-11-08 02:00:58 +00:00
|
|
|
break;
|
2011-06-29 10:46:20 +00:00
|
|
|
}
|
2008-11-08 02:00:58 +00:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert list to list, hm */
|
|
|
|
while (comp && *comp != 0) {
|
|
|
|
/* order matters over efficiency */
|
|
|
|
result = g_list_append (result, GUINT_TO_POINTER (*comp));
|
|
|
|
comp++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*_major = major;
|
|
|
|
*_version = version;
|
|
|
|
*_prefix = prefix;
|
|
|
|
*_compatible = result;
|
|
|
|
|
|
|
|
/* TODO 3GPP may include mp42 as compatible if applicable */
|
|
|
|
/* TODO 3GPP major brand 3gp7 if at most 1 video and audio track */
|
|
|
|
}
|