<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1126" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=942131310-10122002><FONT face=Arial color=#0000ff size=2>part
2: my suggestion:</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff size=2>in
modules.h:</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT face=Arial color=#0000ff
size=2>typedef struct function_list_s<FONT
face="MS Sans Serif"> </FONT></FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2>{</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2> union</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2> {</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2> ...</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT face=Arial><FONT color=#0000ff
size=2> </FONT><FONT face="MS Sans Serif" color=#0000ff
size=2> /* Demux plugin
*/<BR>
struct<BR>
{<BR></FONT></FONT></SPAN><SPAN class=942131310-10122002><FONT face=Arial
color=#0000ff
size=2>
int ( * pf_init ) ( struct input_thread_s *
);<BR> void (
* pf_end ) ( struct input_thread_s *
);<BR>
int ( * pf_demux )( struct input_thread_s *
);<BR>
int ( * pf_rewind ) ( struct input_thread_s *
);<BR> /*
default overloadable functions
*/<BR> void (
* pf_parse_pes ) ( struct input_thread_s * , struct es_descriptor_s * p_es
);<BR> void (
* pf_gather_pes) ( struct input_thread_s * p_input, struct data_packet_s *
p_data,<BR>
struct es_descriptor_s * p_es, boolean_t b_unit_start, boolean_t b_packet_lost
);<BR> ssize_t
( * pf_read_ps ) ( struct input_thread_s * p_input,
<BR>
struct data_packet_s ** pp_data
);<BR> struct
es_descriptor_s * ( * pf_parse_ps ) ( struct input_thread_s *
p_input,<BR>
struct data_packet_s * p_data
);<BR> void (
* pf_demux_ps ) ( struct input_thread_s * p_input, struct data_packet_s * p_data
);<BR> ssize_t
( * pf_read_ts ) ( struct input_thread_s * p_input,
<BR>
struct data_packet_s ** pp_data
);<BR>
void ( * pf_demux_ts ) ( struct input_thread_s * p_input,
<BR>
struct data_packet_s *
p_data,<BR>
void * );<BR>
void ( * pf_delete_pes ) ( struct input_buffers_s * p_buffers,
<BR>
struct pes_packet_s * p_pes
);<BR> void (
* pf_decode_pes ) ( struct decoder_fifo_s * p_decoder_fifo,
<BR>
struct pes_packet_s * p_pes ); </FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT face=Arial color=#0000ff
size=2> } demux;</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2> ...</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2> }</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2>};</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff size=2>in
configuration.h:</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT face=Arial color=#0000ff
size=2>/*****************************************************************************<BR> *
Macros used to build the 'overloadable' function
table<BR> ****************************************************************************/<BR>#define
SETUPDEMUXDEFAULTS(demux) \<BR>
demux.pf_parse_pes = input_ParsePES;
\<BR> demux.pf_gather_pes =
input_GatherPES; \<BR>
demux.pf_read_ps = input_ReadPS; \<BR>
demux.pf_parse_ps = input_ParsePS;
\<BR> demux.pf_demux_ps =
input_DemuxPS; \<BR> demux.pf_read_ts =
input_ReadTS; \<BR> demux.pf_demux_ts =
input_DemuxTS; \<BR>
demux.pf_delete_pes = input_DeletePES;
\<BR> demux.pf_decode_pes =
input_DecodePES;</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff size=2>in
custom_demux.c:</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT face=Arial color=#0000ff
size=2>/*****************************************************************************<BR> *
Functions exported as capabilities. They are declared as static so
that<BR> * we don't pollute the namespace too
much.<BR> *****************************************************************************/<BR>static
void input_getfunctions( function_list_t * p_function_list )<BR>{<BR>#define
input p_function_list->functions.demux<BR>
input.pf_init
= MyInit;<BR>
input.pf_end
= MyEnd;<BR>
input.pf_demux
= MyDemux;<BR>
input.pf_rewind =
NULL;<BR> SETUPDEMUXDEFAULTS(input);<BR>
input.pf_decode_pes = MyDecodePES;<BR>#undef
input<BR>}</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff size=2>and e.g. in
mpeg_system.c, in input_ParsePES:</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2>...</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2> /* Now we can eventually put the PES
packet in the decoder's<BR> *
PES fifo */<BR> if(
p_es->p_decoder_fifo != NULL )<BR>
{<BR>#define ft
p_input->p_demux_module->p_functions->demux.functions.demux<BR>
ft.pf_decode_pes( p_es->p_decoder_fifo, p_pes
);<BR> }</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2>...</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff size=2>i. s.
o.</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff size=2>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2> /* Now we can eventually put the PES
packet in the decoder's<BR> *
PES fifo */<BR> if(
p_es->p_decoder_fifo != NULL )<BR>
{</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT color=#0000ff
size=2> input_DecodePES(
p_es->p_decoder_fifo, p_pes );<BR>
}</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=942131310-10122002><FONT face=Arial>In this way, one can easily
overload some of the system functions, withaout the necessity to rewrite all
stuff. Most functions</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002>are useful anyway, one only needs to add
some functionality on a few places, without breaking the code for
other applications/plugins.</SPAN></DIV>
<DIV><SPAN class=942131310-10122002><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=942131310-10122002><FONT face=Arial>Problem with this solution
is, all plugins will have to add the appropriate macro to the
<MODULE_TYPE>_getfunctions function.</FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002>Does anyone have a solution for this?
Maybe some smart macro in MODULE_ACTIVATE_START?</SPAN></DIV>
<DIV><SPAN class=942131310-10122002></SPAN> </DIV>
<DIV><SPAN class=942131310-10122002><FONT face=Arial>And it have to be decided
which functions will become 'virtual' and the call to these functions will
all have to be replaced with a </FONT></SPAN></DIV>
<DIV><SPAN class=942131310-10122002>call with a function pointer, as above
example in input_ParsePES. Quite some work:)</SPAN></DIV>
<DIV><SPAN class=942131310-10122002></SPAN> </DIV>
<DIV><SPAN class=942131310-10122002><FONT
face=Arial>Stephane</FONT></SPAN></DIV>
<DIV><SPAN
class=942131310-10122002>VirtuosoMedia</SPAN></DIV></FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Oorspronkelijk bericht-----<BR><B>Van:</B>
vlc-devel-bounce@videolan.org [mailto:vlc-devel-bounce@videolan.org]<B>Namens
</B>Stephane van Hardeveld<BR><B>Verzonden:</B> maandag 9 december 2002
16:45<BR><B>Aan:</B> vlc-devel@videolan.org<BR><B>Onderwerp:</B> [vlc-devel]
Overloading<BR><BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Hi all,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I am trying to create some demux plugin for our
MPEG PS streams. I succeeded in parsing our</FONT></DIV>
<DIV><FONT face=Arial size=2>PSM look-alike and create decode threads etc. I
even succeeded in creating video on screen and</FONT></DIV>
<DIV><FONT face=Arial size=2>audio from the speakers (if I am able to do this,
the code-base must be built really good and structured :) )</FONT></DIV>
<DIV><FONT face=Arial size=2>However, now I need to do something special just
before calling 'input_DecodePES( p_es->p_decoder_fifo, p_pes
)'</FONT></DIV>
<DIV><FONT face=Arial size=2>namely descramble the pes payload. I could of
course include all functions of mpeg_system.c into my plugin,</FONT></DIV>
<DIV><FONT face=Arial size=2>but I was wondering whether it is possible to use
some form of overloading or function table and just change the</FONT></DIV>
<DIV><FONT face=Arial size=2>used Decode_PES function.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Stephane van Hardeveld</FONT></DIV>
<DIV><FONT face=Arial size=2>VirtuosoMedia</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV> </DIV></BLOCKQUOTE></BODY></HTML>