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

Dummy demux: simplify

parent d489cb7f
...@@ -111,25 +111,25 @@ int OpenAccess( vlc_object_t *p_this ) ...@@ -111,25 +111,25 @@ int OpenAccess( vlc_object_t *p_this )
/***************************************************************************** /*****************************************************************************
* Demux * Demux
*****************************************************************************/ *****************************************************************************/
struct demux_sys_t static int DemuxControl( demux_t *, int, va_list );
{
/* The real command */
int i_command;
/* Used for the pause command */ static int DemuxNoOp( demux_t *demux )
mtime_t expiration; {
}; (void) demux;
return 0;
}
enum static int DemuxPause( demux_t *demux )
{ {
COMMAND_NOP = 0, const mtime_t *p_end = (void *)demux->p_sys;
COMMAND_QUIT = 1, mtime_t now = mdate();
COMMAND_PAUSE= 3,
};
static int Demux( demux_t * ); if( now >= *p_end )
static int DemuxControl( demux_t *, int, va_list ); return 0;
msleep( 10000 ); /* FIXME!!! */
return 1;
}
/***************************************************************************** /*****************************************************************************
* OpenDemux: initialize the target, ie. parse the command * OpenDemux: initialize the target, ie. parse the command
...@@ -139,42 +139,43 @@ int OpenDemux ( vlc_object_t *p_this ) ...@@ -139,42 +139,43 @@ int OpenDemux ( vlc_object_t *p_this )
demux_t *p_demux = (demux_t*)p_this; demux_t *p_demux = (demux_t*)p_this;
char * psz_name = p_demux->psz_path; char * psz_name = p_demux->psz_path;
int i_len = strlen( psz_name );
demux_sys_t *p_sys;
p_demux->pf_demux = Demux;
p_demux->pf_control = DemuxControl; p_demux->pf_control = DemuxControl;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); p_demux->p_sys = NULL;
/* Check for a "vlc://nop" command */ /* Check for a "vlc://nop" command */
if( i_len == 3 && !strncasecmp( psz_name, "nop", 3 ) ) if( !strcasecmp( psz_name, "nop" ) )
{ {
msg_Info( p_demux, "command `nop'" ); msg_Info( p_demux, "command `nop'" );
p_sys->i_command = COMMAND_NOP; p_demux->pf_demux = DemuxNoOp;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/* Check for a "vlc://quit" command */ /* Check for a "vlc://quit" command */
if( i_len == 4 && !strncasecmp( psz_name, "quit", 4 ) ) if( !strcasecmp( psz_name, "quit" ) )
{ {
msg_Info( p_demux, "command `quit'" ); msg_Info( p_demux, "command `quit'" );
p_sys->i_command = COMMAND_QUIT; p_demux->pf_demux = DemuxNoOp;
libvlc_Quit( p_demux->p_libvlc );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/* Check for a "vlc://pause:***" command */ /* Check for a "vlc://pause:***" command */
if( i_len > 6 && !strncasecmp( psz_name, "pause:", 6 ) ) if( !strncasecmp( psz_name, "pause:", 6 ) )
{ {
double f = us_atof( psz_name + 6 ); double f = us_atof( psz_name + 6 );
mtime_t end = mdate() + f * (mtime_t)1000000;
msg_Info( p_demux, "command `pause %f'", f ); msg_Info( p_demux, "command `pause %f'", f );
p_sys->i_command = COMMAND_PAUSE; p_demux->pf_demux = DemuxPause;
p_sys->expiration = mdate() + f * (mtime_t)1000000;
p_demux->p_sys = malloc( sizeof( end ) );
if( p_demux->p_sys == NULL )
return VLC_ENOMEM;
memcpy( p_demux->p_sys, &end, sizeof( end ) );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
msg_Err( p_demux, "unknown command `%s'", psz_name ); msg_Err( p_demux, "unknown command `%s'", psz_name );
free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -188,37 +189,6 @@ void CloseDemux ( vlc_object_t *p_this ) ...@@ -188,37 +189,6 @@ void CloseDemux ( vlc_object_t *p_this )
free( p_demux->p_sys ); free( p_demux->p_sys );
} }
/*****************************************************************************
* Demux: do what the command says
*****************************************************************************/
static int Demux( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
bool b_eof = false;
switch( p_sys->i_command )
{
case COMMAND_QUIT:
b_eof = true;
libvlc_Quit( p_demux->p_libvlc );
break;
case COMMAND_PAUSE:
if( mdate() >= p_sys->expiration )
b_eof = true;
else
msleep( 10000 );
break;
case COMMAND_NOP:
default:
b_eof = true;
break;
}
return b_eof ? 0 : 1;
}
static int DemuxControl( demux_t *p_demux, int i_query, va_list args ) static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
{ {
return demux_vaControlHelper( p_demux->s, return demux_vaControlHelper( p_demux->s,
......
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