Commit ab6dfaa9 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

es_out: use constant callback structures

parent 43b42acc
......@@ -108,37 +108,41 @@ enum es_out_policy_e
ES_OUT_ES_POLICY_SIMULTANEOUS, /* Allows multiple ES per cat */
};
struct es_out_t
struct es_out_callbacks
{
es_out_id_t *(*pf_add) ( es_out_t *, const es_format_t * );
int (*pf_send) ( es_out_t *, es_out_id_t *, block_t * );
void (*pf_del) ( es_out_t *, es_out_id_t * );
int (*pf_control)( es_out_t *, int i_query, va_list );
void (*pf_destroy)( es_out_t * );
es_out_id_t *(*add)(es_out_t *, const es_format_t *);
int (*send)(es_out_t *, es_out_id_t *, block_t *);
void (*del)(es_out_t *, es_out_id_t *);
int (*control)(es_out_t *, int query, va_list);
void (*destroy)(es_out_t *);
};
struct es_out_t
{
const struct es_out_callbacks *cbs;
void *p_sys;
};
VLC_USED
static inline es_out_id_t * es_out_Add( es_out_t *out, const es_format_t *fmt )
{
return out->pf_add( out, fmt );
return out->cbs->add( out, fmt );
}
static inline void es_out_Del( es_out_t *out, es_out_id_t *id )
{
out->pf_del( out, id );
out->cbs->del( out, id );
}
static inline int es_out_Send( es_out_t *out, es_out_id_t *id,
block_t *p_block )
{
return out->pf_send( out, id, p_block );
return out->cbs->send( out, id, p_block );
}
static inline int es_out_vaControl( es_out_t *out, int i_query, va_list args )
{
return out->pf_control( out, i_query, args );
return out->cbs->control( out, i_query, args );
}
static inline int es_out_Control( es_out_t *out, int i_query, ... )
......@@ -154,7 +158,7 @@ static inline int es_out_Control( es_out_t *out, int i_query, ... )
static inline void es_out_Delete( es_out_t *p_out )
{
p_out->pf_destroy( p_out );
p_out->cbs->destroy( p_out );
}
static inline int es_out_SetPCR( es_out_t *out, mtime_t pcr )
......
......@@ -1106,17 +1106,21 @@ static void esOutDestroy(es_out_t *p_out)
free(p_out);
}
static const struct es_out_callbacks esOutCallbacks = {
.add = esOutAdd,
.send = esOutSend,
.del = esOutDel,
.control = esOutControl,
.destroy = esOutDestroy,
};
static es_out_t *esOutNew(vlc_object_t *p_obj, es_out_t *p_dst_out, void *priv)
{
es_out_t *p_out = malloc(sizeof(*p_out));
if (unlikely(p_out == NULL))
return NULL;
p_out->pf_add = esOutAdd;
p_out->pf_control = esOutControl;
p_out->pf_del = esOutDel;
p_out->pf_destroy = esOutDestroy;
p_out->pf_send = esOutSend;
p_out->cbs = &esOutCallbacks;
es_out_sys_t *es_out_sys = malloc(sizeof(*es_out_sys));
if (unlikely(es_out_sys == NULL)) {
......
......@@ -31,6 +31,15 @@
using namespace adaptive;
static const struct es_out_callbacks esOutCallbacks =
{
FakeESOut::esOutAdd_Callback,
FakeESOut::esOutSend_Callback,
FakeESOut::esOutDel_Callback,
FakeESOut::esOutControl_Callback,
FakeESOut::esOutDestroy_Callback,
};
FakeESOut::FakeESOut( es_out_t *es, CommandsQueue *queue )
: real_es_out( es )
, extrainfo( NULL )
......@@ -40,11 +49,7 @@ FakeESOut::FakeESOut( es_out_t *es, CommandsQueue *queue )
, timestamps_expected( 0 )
, timestamps_check_done( false )
{
fakeesout->pf_add = esOutAdd_Callback;
fakeesout->pf_control = esOutControl_Callback;
fakeesout->pf_del = esOutDel_Callback;
fakeesout->pf_destroy = esOutDestroy_Callback;
fakeesout->pf_send = esOutSend_Callback;
fakeesout->cbs = &esOutCallbacks;
fakeesout->p_sys = this;
vlc_mutex_init(&lock);
......
......@@ -177,11 +177,7 @@ typedef struct
int i_prev_stream_level;
} es_out_sys_t;
static es_out_id_t *EsOutAdd ( es_out_t *, const es_format_t * );
static int EsOutSend ( es_out_t *, es_out_id_t *, block_t * );
static void EsOutDel ( es_out_t *, es_out_id_t * );
static int EsOutControl( es_out_t *, int i_query, va_list );
static void EsOutDelete ( es_out_t * );
static void EsOutTerminate( es_out_t * );
static void EsOutSelect( es_out_t *, es_out_id_t *es, bool b_force );
......@@ -282,6 +278,8 @@ static void EsOutPropsInit( es_out_es_props_t *p_props,
}
}
static const struct es_out_callbacks es_out_cbs;
/*****************************************************************************
* input_EsOutNew:
*****************************************************************************/
......@@ -298,11 +296,7 @@ es_out_t *input_EsOutNew( input_thread_t *p_input, int i_rate )
return NULL;
}
out->pf_add = EsOutAdd;
out->pf_send = EsOutSend;
out->pf_del = EsOutDel;
out->pf_control = EsOutControl;
out->pf_destroy = EsOutDelete;
out->cbs = &es_out_cbs;
out->p_sys = p_sys;
vlc_mutex_init_recursive( &p_sys->lock );
......@@ -2907,6 +2901,15 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
return i_ret;
}
static const struct es_out_callbacks es_out_cbs =
{
.add = EsOutAdd,
.send = EsOutSend,
.del = EsOutDel,
.control = EsOutControl,
.destroy = EsOutDelete,
};
/****************************************************************************
* LanguageGetName: try to expend iso639 into plain name
****************************************************************************/
......
......@@ -247,11 +247,7 @@ typedef struct
es_out_id_t **pp_es;
} es_out_sys_t;
static es_out_id_t *Add ( es_out_t *, const es_format_t * );
static int Send ( es_out_t *, es_out_id_t *, block_t * );
static void Del ( es_out_t *, es_out_id_t * );
static int Control( es_out_t *, int i_query, va_list );
static void Destroy( es_out_t * );
static int TsStart( es_out_t * );
static void TsAutoStop( es_out_t * );
......@@ -296,6 +292,8 @@ static int CmdExecuteControl( es_out_t *, ts_cmd_t * );
/* File helpers */
static int GetTmpFile( char **ppsz_file, const char *psz_path );
static const struct es_out_callbacks es_out_timeshift_cbs;
/*****************************************************************************
* input_EsOutTimeshiftNew:
*****************************************************************************/
......@@ -312,12 +310,7 @@ es_out_t *input_EsOutTimeshiftNew( input_thread_t *p_input, es_out_t *p_next_out
return NULL;
}
/* */
p_out->pf_add = Add;
p_out->pf_send = Send;
p_out->pf_del = Del;
p_out->pf_control = Control;
p_out->pf_destroy = Destroy;
p_out->cbs = &es_out_timeshift_cbs;
p_out->p_sys = p_sys;
/* */
......@@ -751,6 +744,15 @@ static int Control( es_out_t *p_out, int i_query, va_list args )
return i_ret;
}
static const struct es_out_callbacks es_out_timeshift_cbs =
{
.add = Add,
.send = Send,
.del = Del,
.control = Control,
.destroy = Destroy,
};
/*****************************************************************************
*
*****************************************************************************/
......
......@@ -206,6 +206,15 @@ static void EsOutDestroy(es_out_t *out)
free(ctx);
}
static const struct es_out_callbacks es_out_cbs =
{
.add = EsOutAdd,
.send = EsOutSend,
.del = EsOutDelete,
.control = EsOutControl,
.destroy = EsOutDestroy,
};
static es_out_t *test_es_out_create(vlc_object_t *parent)
{
struct test_es_out_t *ctx = malloc(sizeof (*ctx));
......@@ -218,11 +227,7 @@ static es_out_t *test_es_out_create(vlc_object_t *parent)
ctx->ids = NULL;
es_out_t *out = &ctx->out;
out->pf_add = EsOutAdd;
out->pf_send = EsOutSend;
out->pf_del = EsOutDelete;
out->pf_control = EsOutControl;
out->pf_destroy = EsOutDestroy;
out->cbs = &es_out_cbs;
out->p_sys = (void *)parent;
return out;
......
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