summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gst/qtmux/atoms.c6
-rw-r--r--gst/qtmux/atoms.h4
-rw-r--r--gst/qtmux/ftypcc.h3
-rw-r--r--gst/qtmux/gstqtmuxmap.c48
4 files changed, 57 insertions, 4 deletions
diff --git a/gst/qtmux/atoms.c b/gst/qtmux/atoms.c
index a5d8fe38..47db40ce 100644
--- a/gst/qtmux/atoms.c
+++ b/gst/qtmux/atoms.c
@@ -2783,6 +2783,9 @@ atom_trak_set_audio_type (AtomTRAK * trak, AtomsContext * context,
atom_trak_set_audio_commons (trak, context, scale);
ste = atom_trak_add_audio_entry (trak, context, entry->fourcc);
+ trak->is_video = FALSE;
+ trak->is_h264 = FALSE;
+
ste->version = entry->version;
ste->compression_id = entry->compression_id;
ste->sample_size = entry->sample_size;
@@ -2811,6 +2814,9 @@ atom_trak_set_video_type (AtomTRAK * trak, AtomsContext * context,
entry->height);
ste = atom_trak_add_video_entry (trak, context, entry->fourcc);
+ trak->is_video = TRUE;
+ trak->is_h264 = (entry->fourcc == FOURCC_avc1);
+
ste->width = entry->width;
ste->height = entry->height;
ste->depth = entry->depth;
diff --git a/gst/qtmux/atoms.h b/gst/qtmux/atoms.h
index 4d8dce19..23bc19bb 100644
--- a/gst/qtmux/atoms.h
+++ b/gst/qtmux/atoms.h
@@ -518,6 +518,10 @@ typedef struct _AtomTRAK
AtomTKHD tkhd;
AtomMDIA mdia;
+
+ /* some helper info for structural conformity checks */
+ gboolean is_video;
+ gboolean is_h264;
} AtomTRAK;
typedef struct _AtomMOOV
diff --git a/gst/qtmux/ftypcc.h b/gst/qtmux/ftypcc.h
index d8320c79..4855adf7 100644
--- a/gst/qtmux/ftypcc.h
+++ b/gst/qtmux/ftypcc.h
@@ -53,6 +53,9 @@ G_BEGIN_DECLS
#define FOURCC_mp41 GST_MAKE_FOURCC('m','p','4','1')
#define FOURCC_mp42 GST_MAKE_FOURCC('m','p','4','2')
#define FOURCC_mjp2 GST_MAKE_FOURCC('m','j','p','2')
+#define FOURCC_3gp4 GST_MAKE_FOURCC('3','g','p','4')
+#define FOURCC_3gp6 GST_MAKE_FOURCC('3','g','p','6')
+#define FOURCC_3gg6 GST_MAKE_FOURCC('3','g','g','6')
#define FOURCC_3gg7 GST_MAKE_FOURCC('3','g','g','7')
#define FOURCC_avc1 GST_MAKE_FOURCC('a','v','c','1')
#define FOURCC_qt__ GST_MAKE_FOURCC('q','t',' ',' ')
diff --git a/gst/qtmux/gstqtmuxmap.c b/gst/qtmux/gstqtmuxmap.c
index 11913670..e0e4faed 100644
--- a/gst/qtmux/gstqtmuxmap.c
+++ b/gst/qtmux/gstqtmuxmap.c
@@ -205,14 +205,40 @@ gst_qt_mux_map_format_to_flavor (GstQTMuxFormat format)
return ATOMS_TREE_FLAVOR_ISOM;
}
+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;
+}
+
/* 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)
- * - 3GPP2 specific formats not (yet) used, only 3GPP, so no need yet either
- * for 3g2a (but later on, moov might be used to conditionally switch to
- * 3g2a if needed) */
+ * - TODO: maybe even more 3GPP brand fine-tuning ??
+ * (but that might need ftyp rewriting at the end) */
void
gst_qt_mux_map_format_to_header (GstQTMuxFormat format, GstBuffer ** _prefix,
guint32 * _major, guint32 * _version, GList ** _compatible, AtomMOOV * moov)
@@ -244,9 +270,23 @@ gst_qt_mux_map_format_to_header (GstQTMuxFormat format, GstBuffer ** _prefix,
comp = mp4_brands;
break;
case GST_QT_MUX_FORMAT_3GP:
- major = FOURCC_3gg7;
+ {
+ 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;
+ }
comp = gpp_brands;
break;
+ }
case GST_QT_MUX_FORMAT_MJ2:
major = FOURCC_mjp2;
comp = mjp2_brands;