Commit 42e4c9cb authored by François Cartegnie's avatar François Cartegnie 🤞

mux: mp4: simplify trackinit

parent b8afd4d6
......@@ -206,12 +206,11 @@ void ForgedInitSegment::setLanguage(const std::string &lang)
block_t * ForgedInitSegment::buildMoovBox()
{
mp4mux_trackinfo_t trackinfo;
mp4mux_trackinfo_Init(&trackinfo);
const Timescale &trackTimescale = inheritTimescale();
trackinfo.i_track_id = 0x01; /* Will always be 1st and unique track; tfhd patched on block read */
trackinfo.i_timescale = (uint64_t) trackTimescale;
mp4mux_trackinfo_t trackinfo;
mp4mux_trackinfo_Init(&trackinfo,
0x01, /* Will always be 1st and unique track; tfhd patched on block read */
(uint32_t) trackTimescale);
trackinfo.i_read_duration = duration.Get();
trackinfo.i_trex_default_length = 1;
trackinfo.i_trex_default_size = 1;
......
......@@ -36,35 +36,22 @@
#include <assert.h>
#include <time.h>
bool mp4mux_trackinfo_Init(mp4mux_trackinfo_t *p_stream)
bool mp4mux_trackinfo_Init(mp4mux_trackinfo_t *p_stream, unsigned i_id,
uint32_t i_timescale)
{
p_stream->i_track_id = 1;
es_format_Init(&p_stream->fmt, 0, 0);
memset(p_stream, 0, sizeof(*p_stream));
p_stream->i_track_id = i_id;
p_stream->i_timescale = i_timescale;
p_stream->i_entry_count = 0;
p_stream->i_entry_max = 1000;
p_stream->entry = calloc(p_stream->i_entry_max, sizeof(mp4mux_entry_t));
if(!p_stream->entry)
{
es_format_Clean(&p_stream->fmt);
return false;
}
p_stream->a52_frame = NULL;
p_stream->i_read_duration = 0;
p_stream->i_timescale = CLOCK_FREQ;
p_stream->i_firstdts = 0;
p_stream->b_hasbframes = false;
p_stream->i_stco_pos = 0;
p_stream->i_trex_default_length = 0;
p_stream->i_trex_default_size = 0;
es_format_Init(&p_stream->fmt, 0, 0);
p_stream->i_edits_count = 0;
p_stream->p_edits = NULL;
return true;
}
......
......@@ -74,7 +74,7 @@ typedef struct
} mp4mux_trackinfo_t;
bool mp4mux_trackinfo_Init( mp4mux_trackinfo_t * );
bool mp4mux_trackinfo_Init( mp4mux_trackinfo_t *, unsigned, uint32_t );
void mp4mux_trackinfo_Clear( mp4mux_trackinfo_t * );
bo_t *box_new (const char *fcc);
......
......@@ -403,14 +403,14 @@ static int AddStream(sout_mux_t *p_mux, sout_input_t *p_input)
}
p_stream = malloc(sizeof(mp4_stream_t));
if (!p_stream || !mp4mux_trackinfo_Init(&p_stream->mux))
if (!p_stream ||
!mp4mux_trackinfo_Init(&p_stream->mux, p_sys->i_nb_streams + 1, CLOCK_FREQ))
{
free(p_stream);
return VLC_ENOMEM;
}
es_format_Copy(&p_stream->mux.fmt, p_input->p_fmt);
p_stream->mux.i_track_id = p_sys->i_nb_streams + 1;
p_stream->i_length_neg = 0;
p_stream->i_first_dts = VLC_TS_INVALID;
switch( p_stream->mux.fmt.i_cat )
......
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