Commit 54c3a5ec authored by François Cartegnie's avatar François Cartegnie 🤞

mux: mp4: fix early data output

was sending data in open(), but record code
does probe muxers, so possibly breaks stream
parent 5e3a0498
......@@ -158,6 +158,9 @@ struct sout_mux_sys_t
bool b_64_ext;
bool b_fast_start;
/* global */
bool b_header_sent;
uint64_t i_mdat_pos;
uint64_t i_pos;
mtime_t i_read_duration;
......@@ -166,9 +169,9 @@ struct sout_mux_sys_t
unsigned int i_nb_streams;
mp4_stream_t **pp_streams;
/* mp4frag */
bool b_fragmented;
bool b_header_sent;
mtime_t i_written_duration;
uint32_t i_mfhd_sequence;
};
......@@ -181,34 +184,10 @@ static bool CreateCurrentEdit(mp4_stream_t *, mtime_t, bool);
static void DebugEdits(sout_mux_t *, const mp4_stream_t *);
static int MuxStream(sout_mux_t *p_mux, sout_input_t *p_input, mp4_stream_t *p_stream);
/*****************************************************************************
* Open:
*****************************************************************************/
static int Open(vlc_object_t *p_this)
static int WriteSlowStartHeader(sout_mux_t *p_mux)
{
sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys;
bo_t *box;
msg_Dbg(p_mux, "Mp4 muxer opened");
config_ChainParse(p_mux, SOUT_CFG_PREFIX, ppsz_sout_options, p_mux->p_cfg);
p_mux->pf_control = Control;
p_mux->pf_addstream = AddStream;
p_mux->pf_delstream = DelStream;
p_mux->pf_mux = Mux;
p_mux->p_sys = p_sys = malloc(sizeof(sout_mux_sys_t));
if (!p_sys)
return VLC_ENOMEM;
p_sys->i_pos = 0;
p_sys->i_nb_streams = 0;
p_sys->pp_streams = NULL;
p_sys->i_mdat_pos = 0;
p_sys->b_mov = p_mux->psz_mux && !strcmp(p_mux->psz_mux, "mov");
p_sys->b_3gp = p_mux->psz_mux && !strcmp(p_mux->psz_mux, "3gp");
p_sys->i_read_duration = 0;
p_sys->i_start_dts = VLC_TS_INVALID;
p_sys->b_fragmented = false;
sout_mux_sys_t *p_sys = p_mux->p_sys;
bo_t *box;
if (!p_sys->b_mov) {
/* Now add ftyp header */
......@@ -224,28 +203,19 @@ static int Open(vlc_object_t *p_this)
}
if(!box)
{
free(p_sys);
return VLC_ENOMEM;
}
p_sys->i_pos += bo_size(box);
p_sys->i_mdat_pos = p_sys->i_pos;
box_send(p_mux, box);
}
/* FIXME FIXME
* Quicktime actually doesn't like the 64 bits extensions !!! */
p_sys->b_64_ext = false;
/* Now add mdat header */
box = box_new("mdat");
if(!box)
{
free(p_sys);
return VLC_ENOMEM;
}
bo_add_64be (box, 0); // enough to store an extended size
bo_add_64be(box, 0); // enough to store an extended size
if(box->b)
p_sys->i_pos += bo_size(box);
......@@ -255,6 +225,42 @@ static int Open(vlc_object_t *p_this)
return VLC_SUCCESS;
}
/*****************************************************************************
* Open:
*****************************************************************************/
static int Open(vlc_object_t *p_this)
{
sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys;
msg_Dbg(p_mux, "Mp4 muxer opened");
config_ChainParse(p_mux, SOUT_CFG_PREFIX, ppsz_sout_options, p_mux->p_cfg);
p_mux->pf_control = Control;
p_mux->pf_addstream = AddStream;
p_mux->pf_delstream = DelStream;
p_mux->pf_mux = Mux;
p_mux->p_sys = p_sys = malloc(sizeof(sout_mux_sys_t));
if (!p_sys)
return VLC_ENOMEM;
p_sys->i_pos = 0;
p_sys->i_nb_streams = 0;
p_sys->pp_streams = NULL;
p_sys->i_mdat_pos = 0;
p_sys->b_mov = p_mux->psz_mux && !strcmp(p_mux->psz_mux, "mov");
p_sys->b_3gp = p_mux->psz_mux && !strcmp(p_mux->psz_mux, "3gp");
p_sys->i_read_duration = 0;
p_sys->i_start_dts = VLC_TS_INVALID;
p_sys->b_fragmented = false;
p_sys->b_header_sent = false;
/* FIXME FIXME
* Quicktime actually doesn't like the 64 bits extensions !!! */
p_sys->b_64_ext = false;
return VLC_SUCCESS;
}
/*****************************************************************************
* Close:
*****************************************************************************/
......@@ -776,8 +782,17 @@ static int MuxStream(sout_mux_t *p_mux, sout_input_t *p_input, mp4_stream_t *p_s
static int Mux(sout_mux_t *p_mux)
{
sout_mux_sys_t *p_sys = p_mux->p_sys;
int i_ret = VLC_SUCCESS;
if(!p_sys->b_header_sent)
{
i_ret = WriteSlowStartHeader(p_mux);
if(i_ret != VLC_SUCCESS)
return i_ret;
p_sys->b_header_sent = true;
}
do
{
int i_stream = sout_MuxGetStream(p_mux, 2, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment