[vlc-devel] [RFC/WIP PATCH 3/3] decoder: add "packetized decoder" type
Thomas Guillem
thomas at gllm.fr
Fri Jul 1 12:18:32 CEST 2016
These type of decoders must call decoder_RequestPacketizer() at Open() to query
a specific packetizer. They shoud also release the requested packetizer in
Close() or if Open() fails.
Calling decoder_RequestPacketizer() from Open() will cause the p_dec->fmt_in to
change (updated by the packetizer).
Usecase:
- mediacodec module can force h264 or hevc packetizer. This will allow to
remove a lot of duplicated code.
TODO: handle decoder restart when packetizer fmt changes.
---
include/vlc_codec.h | 6 ++++++
src/input/decoder.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++-------
src/libvlccore.sym | 1 +
3 files changed, 53 insertions(+), 7 deletions(-)
diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index 2d01d26..2f98c7c 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -368,6 +368,12 @@ VLC_API block_t * decoder_NewAudioBuffer( decoder_t *, int i_size ) VLC_USED;
VLC_API subpicture_t * decoder_NewSubpicture( decoder_t *, const subpicture_updater_t * ) VLC_USED;
/**
+ * @param psz_packetizer_name if not NULL, request the specific packetizer. If
+ * null, release a previously requested packetizer.
+ */
+VLC_API int decoder_RequestPacketizer( decoder_t *, const char *psz_packetizer_name );
+
+/**
* This function gives all input attachments at once.
*
* You MUST release the returned values
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 6987fed..90c2b61 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -588,6 +588,32 @@ subpicture_t *decoder_NewSubpicture( decoder_t *p_decoder,
return p_subpicture;
}
+int decoder_RequestPacketizer( decoder_t *p_dec, const char *psz_packetizer_name )
+{
+ decoder_owner_sys_t *p_owner = p_dec->p_owner;
+
+ if( psz_packetizer_name != NULL )
+ {
+ assert( p_owner->p_packetizer == NULL );
+
+ int i_ret = CreateExtraPacketizer( p_dec, &p_dec->fmt_in,
+ psz_packetizer_name );
+ if( i_ret != VLC_SUCCESS )
+ return i_ret;
+ es_format_Copy( &p_dec->fmt_in, &p_owner->p_packetizer->fmt_out );
+ return VLC_SUCCESS;
+ }
+ else
+ {
+ assert( p_owner->p_packetizer != NULL );
+
+ UnloadDecoder( p_owner->p_packetizer );
+ vlc_object_release( p_owner->p_packetizer );
+ p_owner->p_packetizer = NULL;
+ return VLC_SUCCESS;
+ }
+}
+
/* decoder_GetInputAttachments:
*/
int decoder_GetInputAttachments( decoder_t *p_dec,
@@ -1620,15 +1646,28 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
p_dec->pf_queue_audio = DecoderQueueAudio;
p_dec->pf_queue_sub = DecoderQueueSpu;
- /* Load a packetizer module if the input is not already packetized */
- if( p_sout == NULL && !fmt->b_packetized )
+ if( p_sout == NULL )
{
- if( CreateExtraPacketizer( p_dec, fmt, NULL ) == VLC_SUCCESS )
- fmt = &p_owner->p_packetizer->fmt_out;
- }
+ /* Try first to load a decoder that need a specific packetizer */
+ if( LoadDecoder( p_dec, "packetized decoder", NULL, fmt ) == 0 )
+ {
+ assert( p_owner->p_packetizer != NULL );
+ }
+ else
+ {
+ assert( p_owner->p_packetizer == NULL );
- /* Find a suitable decoder/packetizer module */
- if( LoadDecoder( p_dec, p_sout == NULL ? "decoder" : "packetizer", NULL, fmt ) )
+ /* Load a packetizer module if the input is not already packetized */
+ if( !fmt->b_packetized
+ && CreateExtraPacketizer( p_dec, fmt, NULL ) == VLC_SUCCESS )
+ fmt = &p_owner->p_packetizer->fmt_out;
+
+ /* Load a decoder */
+ if( LoadDecoder( p_dec, "decoder", NULL, fmt ) )
+ return p_dec;
+ }
+ }
+ else if( LoadDecoder( p_dec, "packetizer", NULL, fmt ) )
return p_dec;
/* Copy ourself the input replay gain */
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 89e74f8..310ecd4 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -82,6 +82,7 @@ decoder_GetDisplayRate
decoder_GetInputAttachments
decoder_NewAudioBuffer
decoder_NewSubpicture
+decoder_RequestPacketizer
decoder_SynchroChoose
decoder_SynchroDate
decoder_SynchroDecode
--
2.8.1
More information about the vlc-devel
mailing list