[vlc-commits] mux: mp4: only mp4mux can tell if it supports specific atoms
Francois Cartegnie
git at videolan.org
Tue Aug 9 20:21:26 CEST 2016
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Aug 8 14:15:28 2016 +0200| [427d1915042479f14af34fa0b1dae8f335ca8cd3] | committer: Francois Cartegnie
mux: mp4: only mp4mux can tell if it supports specific atoms
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=427d1915042479f14af34fa0b1dae8f335ca8cd3
---
.../demux/smooth/playlist/ForgedInitSegment.cpp | 6 ++-
modules/mux/mp4/libmp4mux.c | 44 ++++++++++++++++++++++
modules/mux/mp4/libmp4mux.h | 1 +
modules/mux/mp4/mp4.c | 34 +----------------
4 files changed, 51 insertions(+), 34 deletions(-)
diff --git a/modules/demux/smooth/playlist/ForgedInitSegment.cpp b/modules/demux/smooth/playlist/ForgedInitSegment.cpp
index 2c3df21..3a9b3e0 100644
--- a/modules/demux/smooth/playlist/ForgedInitSegment.cpp
+++ b/modules/demux/smooth/playlist/ForgedInitSegment.cpp
@@ -273,7 +273,11 @@ block_t * ForgedInitSegment::buildMoovBox()
trackinfo.fmt.psz_language = strdup(language.c_str());
mp4mux_trackinfo_t *p_tracks = &trackinfo;
- bo_t *box = mp4mux_GetMoovBox(NULL, &p_tracks, 1, true, false, false, false);
+ bo_t *box = NULL;
+
+ if(mp4mux_CanMux( NULL, &trackinfo.fmt ))
+ box = mp4mux_GetMoovBox(NULL, &p_tracks, 1, true, false, false, false);
+
mp4mux_trackinfo_Clear(&trackinfo);
block_t *moov = NULL;
diff --git a/modules/mux/mp4/libmp4mux.c b/modules/mux/mp4/libmp4mux.c
index fabde93..65d7be7 100644
--- a/modules/mux/mp4/libmp4mux.c
+++ b/modules/mux/mp4/libmp4mux.c
@@ -1835,3 +1835,47 @@ bo_t *mp4mux_GetFtyp(vlc_fourcc_t major, uint32_t minor, vlc_fourcc_t extra[], s
}
return box;
}
+
+bool mp4mux_CanMux(vlc_object_t *p_obj, const es_format_t *p_fmt)
+{
+ switch(p_fmt->i_codec)
+ {
+ case VLC_CODEC_A52:
+ case VLC_CODEC_DTS:
+ case VLC_CODEC_EAC3:
+ case VLC_CODEC_MP4A:
+ case VLC_CODEC_MP4V:
+ case VLC_CODEC_MPGA:
+ case VLC_CODEC_MP3:
+ case VLC_CODEC_MPGV:
+ case VLC_CODEC_MP2V:
+ case VLC_CODEC_MP1V:
+ case VLC_CODEC_MJPG:
+ case VLC_CODEC_MJPGB:
+ case VLC_CODEC_SVQ1:
+ case VLC_CODEC_SVQ3:
+ case VLC_CODEC_H263:
+ case VLC_CODEC_AMR_NB:
+ case VLC_CODEC_AMR_WB:
+ case VLC_CODEC_YV12:
+ case VLC_CODEC_YUYV:
+ case VLC_CODEC_VC1:
+ case VLC_CODEC_WMAP:
+ break;
+ case VLC_CODEC_H264:
+ if(!p_fmt->i_extra && p_obj)
+ msg_Warn(p_obj, "H264 muxing from AnnexB source will set an incorrect default profile");
+ break;
+ case VLC_CODEC_HEVC:
+ if(!p_fmt->i_extra && p_obj)
+ msg_Err(p_obj, "HEVC muxing from AnnexB source is unsupported");
+ return false;
+ case VLC_CODEC_SUBT:
+ if(p_obj)
+ msg_Warn(p_obj, "subtitle track added like in .mov (even when creating .mp4)");
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
diff --git a/modules/mux/mp4/libmp4mux.h b/modules/mux/mp4/libmp4mux.h
index 0eb2ae1..2012987 100644
--- a/modules/mux/mp4/libmp4mux.h
+++ b/modules/mux/mp4/libmp4mux.h
@@ -71,6 +71,7 @@ bo_t *box_full_new(const char *fcc, uint8_t v, uint32_t f);
void box_fix (bo_t *box, uint32_t);
void box_gather (bo_t *box, bo_t *box2);
+bool mp4mux_CanMux(vlc_object_t *, const es_format_t *);
bo_t *mp4mux_GetFtyp(vlc_fourcc_t, uint32_t, vlc_fourcc_t[], size_t i_fourcc);
bo_t *mp4mux_GetMoovBox(vlc_object_t *, mp4mux_trackinfo_t **pp_tracks, unsigned int i_tracks,
bool b_fragmented, bool b_mov, bool b_64ext, bool b_stco64);
diff --git a/modules/mux/mp4/mp4.c b/modules/mux/mp4/mp4.c
index 83c77eb..3473e6a 100644
--- a/modules/mux/mp4/mp4.c
+++ b/modules/mux/mp4/mp4.c
@@ -396,40 +396,8 @@ static int AddStream(sout_mux_t *p_mux, sout_input_t *p_input)
sout_mux_sys_t *p_sys = p_mux->p_sys;
mp4_stream_t *p_stream;
- switch(p_input->p_fmt->i_codec)
+ if(!mp4mux_CanMux(VLC_OBJECT(p_mux), p_input->p_fmt))
{
- case VLC_CODEC_A52:
- case VLC_CODEC_DTS:
- case VLC_CODEC_EAC3:
- case VLC_CODEC_MP4A:
- case VLC_CODEC_MP4V:
- case VLC_CODEC_MPGA:
- case VLC_CODEC_MP3:
- case VLC_CODEC_MPGV:
- case VLC_CODEC_MP2V:
- case VLC_CODEC_MP1V:
- case VLC_CODEC_MJPG:
- case VLC_CODEC_MJPGB:
- case VLC_CODEC_SVQ1:
- case VLC_CODEC_SVQ3:
- case VLC_CODEC_H263:
- case VLC_CODEC_AMR_NB:
- case VLC_CODEC_AMR_WB:
- case VLC_CODEC_YV12:
- case VLC_CODEC_YUYV:
- break;
- case VLC_CODEC_H264:
- if(!p_input->p_fmt->i_extra)
- msg_Warn(p_mux, "H264 muxing from AnnexB source will set an incorrect default profile");
- break;
- case VLC_CODEC_HEVC:
- if(!p_input->p_fmt->i_extra)
- msg_Err(p_mux, "HEVC muxing from AnnexB source is unsupported");
- return VLC_EGENERIC;
- case VLC_CODEC_SUBT:
- msg_Warn(p_mux, "subtitle track added like in .mov (even when creating .mp4)");
- break;
- default:
msg_Err(p_mux, "unsupported codec %4.4s in mp4",
(char*)&p_input->p_fmt->i_codec);
return VLC_EGENERIC;
More information about the vlc-commits
mailing list