Skip to content

Commit

Permalink
codec/packetizer: expose a read-only version of the input format
Browse files Browse the repository at this point in the history
All code creating a decoder uses decoder_Init().
Packetizer creation needs to be taken care of as well.
  • Loading branch information
robUx4 committed Nov 16, 2022
1 parent 1fac7f1 commit e652fc2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/vlc_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ struct decoder_t
module_t * p_module;
void *p_sys;

/* Input format ie from demuxer (XXX: a lot of field could be invalid) */
/* Input format ie from demuxer (XXX: a lot of fields could be invalid) */
es_format_t fmt_in;
/* Input format ie from demuxer (XXX: a lot of fields could be invalid),
cannot be NULL */
const es_format_t *p_fmt_in;

/* Output format of decoder/packetizer */
es_format_t fmt_out;
Expand Down
1 change: 1 addition & 0 deletions src/input/decoder_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void decoder_Init( decoder_t *p_dec, const es_format_t *restrict p_fmt )
p_dec->p_module = NULL;

es_format_Copy( &p_dec->fmt_in, p_fmt );
p_dec->p_fmt_in = &p_dec->fmt_in;
es_format_Init( &p_dec->fmt_out, p_fmt->i_cat, 0 );
}

Expand Down
1 change: 1 addition & 0 deletions src/input/demux.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ decoder_t *demux_PacketizerNew( vlc_object_t *p_demux, es_format_t *p_fmt, const
p_packetizer->pf_packetize = NULL;

p_packetizer->fmt_in = *p_fmt;
p_packetizer->p_fmt_in = &p_packetizer->fmt_in;
es_format_Init( &p_packetizer->fmt_out, p_fmt->i_cat, 0 );

p_packetizer->p_module = module_need( p_packetizer, "packetizer", NULL, false );
Expand Down
1 change: 1 addition & 0 deletions test/modules/packetizer/packetizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ static decoder_t *create_packetizer(libvlc_instance_t *vlc,
p_pack->fmt_in.video.i_frame_rate = num;
p_pack->fmt_in.video.i_frame_rate_base = den;
p_pack->fmt_in.b_packetized = false;
p_pack->p_fmt_in = &p_pack->fmt_in;

p_pack->p_module = module_need( p_pack, "packetizer", NULL, false );
if(!p_pack->p_module)
Expand Down

0 comments on commit e652fc2

Please sign in to comment.