[vlc-commits] test: input: use new decoder owner/callbacks
Thomas Guillem
git at videolan.org
Thu Jun 7 12:08:27 CEST 2018
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jun 7 12:06:58 2018 +0200| [f1f9c10113205f8b0ce098ea79c972511c1d462f] | committer: Thomas Guillem
test: input: use new decoder owner/callbacks
Introduced by d49b43b6064da7b4c811cf8afd2aad708b704375
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f1f9c10113205f8b0ce098ea79c972511c1d462f
---
test/src/input/decoder.c | 104 +++++++++++++++++++++++++++++++++--------------
1 file changed, 73 insertions(+), 31 deletions(-)
diff --git a/test/src/input/decoder.c b/test/src/input/decoder.c
index 44cb6098ca..3514d5684f 100644
--- a/test/src/input/decoder.c
+++ b/test/src/input/decoder.c
@@ -39,6 +39,17 @@
#include "common.h"
#include "decoder.h"
+struct decoder_owner
+{
+ decoder_t dec;
+ decoder_t *packetizer;
+};
+
+static inline struct decoder_owner *dec_get_owner(decoder_t *dec)
+{
+ return container_of(dec, struct decoder_owner, dec);
+}
+
static picture_t *video_new_buffer_decoder(decoder_t *dec)
{
return picture_NewFromFormat(&dec->fmt_out.video);
@@ -51,35 +62,26 @@ static subpicture_t *spu_new_buffer_decoder(decoder_t *dec,
return subpicture_New (p_subpic);
}
-static int video_update_format_decoder(decoder_t *dec)
-{
- (void) dec;
- return 0;
-}
-static int queue_video(decoder_t *dec, picture_t *pic)
+static void queue_video(decoder_t *dec, picture_t *pic)
{
(void) dec;
picture_Release(pic);
- return 0;
}
-static int queue_audio(decoder_t *dec, block_t *p_block)
+static void queue_audio(decoder_t *dec, block_t *p_block)
{
(void) dec;
block_Release(p_block);
- return 0;
}
-static int queue_cc(decoder_t *dec, block_t *p_block, const decoder_cc_desc_t *desc)
+static void queue_cc(decoder_t *dec, block_t *p_block, const decoder_cc_desc_t *desc)
{
(void) dec; (void) desc;
block_Release(p_block);
- return 0;
}
-static int queue_sub(decoder_t *dec, subpicture_t *p_subpic)
+static void queue_sub(decoder_t *dec, subpicture_t *p_subpic)
{
(void) dec;
subpicture_Delete(p_subpic);
- return 0;
}
static int decoder_load(decoder_t *decoder, bool is_packetizer,
@@ -135,7 +137,8 @@ static void decoder_unload(decoder_t *decoder)
void test_decoder_destroy(decoder_t *decoder)
{
- decoder_t *packetizer = (void *) decoder->p_owner;
+ struct decoder_owner *owner = dec_get_owner(decoder);
+ decoder_t *packetizer = owner->packetizer;
decoder_unload(packetizer);
decoder_unload(decoder);
@@ -150,40 +153,79 @@ decoder_t *test_decoder_create(vlc_object_t *parent, const es_format_t *fmt)
decoder_t *decoder = NULL;
packetizer = vlc_object_create(parent, sizeof(*packetizer));
- decoder = vlc_object_create(parent, sizeof(*decoder));
+ struct decoder_owner *owner = vlc_object_create(parent, sizeof(*owner));
- if (packetizer == NULL || decoder == NULL)
+ if (packetizer == NULL || owner == NULL)
{
if (packetizer)
vlc_object_release(packetizer);
return NULL;
}
+ decoder = &owner->dec;
+
+ static const struct decoder_owner_callbacks dec_video_cbs =
+ {
+ .video = {
+ NULL,
+ video_new_buffer_decoder,
+ queue_video,
+ queue_cc,
+ },
+ };
+ static const struct decoder_owner_callbacks dec_audio_cbs =
+ {
+ .audio = {
+ NULL,
+ queue_audio,
+ },
+ };
+ static const struct decoder_owner_callbacks dec_spu_cbs =
+ {
+ .spu = {
+ spu_new_buffer_decoder,
+ queue_sub,
+ },
+ };
- decoder->pf_vout_format_update = video_update_format_decoder;
- decoder->pf_vout_buffer_new = video_new_buffer_decoder;
- decoder->pf_spu_buffer_new = spu_new_buffer_decoder;
- decoder->pf_queue_video = queue_video;
- decoder->pf_queue_audio = queue_audio;
- decoder->pf_queue_cc = queue_cc;
- decoder->pf_queue_sub = queue_sub;
- decoder->p_owner = (void *)packetizer;
+ switch (fmt->i_cat)
+ {
+ case VIDEO_ES:
+ decoder->cbs = &dec_video_cbs;
+ break;
+ case AUDIO_ES:
+ decoder->cbs = &dec_audio_cbs;
+ break;
+ case SPU_ES:
+ decoder->cbs = &dec_spu_cbs;
+ break;
+ default:
+ vlc_object_release(packetizer);
+ vlc_object_release(decoder);
+ return NULL;
+ }
if (decoder_load(packetizer, true, fmt) != VLC_SUCCESS)
- goto end;
+ {
+ vlc_object_release(packetizer);
+ vlc_object_release(decoder);
+ return NULL;
+ }
if (decoder_load(decoder, false, &packetizer->fmt_out) != VLC_SUCCESS)
- goto end;
+ {
+ decoder_unload(packetizer);
+ vlc_object_release(packetizer);
+ vlc_object_release(decoder);
+ return NULL;
+ }
return decoder;
-
-end:
- test_decoder_destroy(decoder);
- return NULL;
}
int test_decoder_process(decoder_t *decoder, block_t *p_block)
{
- decoder_t *packetizer = (void *) decoder->p_owner;
+ struct decoder_owner *owner = dec_get_owner(decoder);
+ decoder_t *packetizer = owner->packetizer;
/* This case can happen if a decoder reload failed */
if (decoder->p_module == NULL)
More information about the vlc-commits
mailing list