Commit f1f9c101 authored by Thomas Guillem's avatar Thomas Guillem

test: input: use new decoder owner/callbacks

Introduced by d49b43b6
parent c3fbff8a
......@@ -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)
......
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