1 /*****************************************************************************
2 * input_dummy.c: dummy input plugin, to manage "vlc:***" special options
3 *****************************************************************************
4 * Copyright (C) 2001, 2002 the VideoLAN team
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
33 #include <vlc_interface.h>
34 #include <vlc_access.h>
35 #include <vlc_demux.h>
36 #include <vlc_playlist.h>
40 /*****************************************************************************
42 *****************************************************************************/
43 static int AccessRead( access_t *p_access, uint8_t *p, int i_size )
46 memset( p, 0, i_size );
49 static int AccessControl( access_t *p_access, int i_query, va_list args )
59 case ACCESS_CAN_FASTSEEK:
60 case ACCESS_CAN_PAUSE:
61 case ACCESS_CAN_CONTROL_PACE:
62 pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
68 pi_int = (int*)va_arg( args, int * );
72 case ACCESS_GET_PTS_DELAY:
73 pi_64 = (int64_t*)va_arg( args, int64_t * );
74 *pi_64 = DEFAULT_PTS_DELAY * 1000;
78 case ACCESS_SET_PAUSE_STATE:
79 case ACCESS_GET_TITLE_INFO:
81 case ACCESS_SET_TITLE:
82 case ACCESS_SET_SEEKPOINT:
86 msg_Err( p_access, "unimplemented query in control" );
92 int E_(OpenAccess)( vlc_object_t *p_this )
94 access_t *p_access = (access_t*)p_this;
97 p_access->pf_read = AccessRead;
98 p_access->pf_block = NULL;
99 p_access->pf_seek = NULL;
100 p_access->pf_control = AccessControl;
101 p_access->info.i_update = 0;
102 p_access->info.i_size = 0;
103 p_access->info.i_pos = 0;
104 p_access->info.b_eof = VLC_FALSE;
105 p_access->info.i_title = 0;
106 p_access->info.i_seekpoint = 0;
107 p_access->p_sys = NULL;
109 /* Force dummy demux plug-in */
110 p_access->psz_demux = strdup( "vlc" );
116 /*****************************************************************************
118 *****************************************************************************/
121 /* The real command */
124 /* Used for the pause command */
127 /* The command to run */
137 static int Demux( demux_t * );
138 static int DemuxControl( demux_t *, int, va_list );
141 /*****************************************************************************
142 * OpenDemux: initialize the target, ie. parse the command
143 *****************************************************************************/
144 int E_(OpenDemux) ( vlc_object_t *p_this )
146 demux_t *p_demux = (demux_t*)p_this;
147 char * psz_name = p_demux->psz_path;
149 int i_len = strlen( psz_name );
153 p_demux->pf_demux = Demux;
154 p_demux->pf_control = DemuxControl;
155 p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
157 /* Check for a "vlc:nop" command */
158 if( i_len == 3 && !strncasecmp( psz_name, "nop", 3 ) )
160 msg_Info( p_demux, "command `nop'" );
161 p_sys->i_command = COMMAND_NOP;
165 /* Check for a "vlc:quit" command */
166 if( i_len == 4 && !strncasecmp( psz_name, "quit", 4 ) )
168 msg_Info( p_demux, "command `quit'" );
169 p_sys->i_command = COMMAND_QUIT;
173 /* Check for a "vlc:pause:***" command */
174 if( i_len > 6 && !strncasecmp( psz_name, "pause:", 6 ) )
176 i_arg = atoi( psz_name + 6 );
177 msg_Info( p_demux, "command `pause %i'", i_arg );
178 p_sys->i_command = COMMAND_PAUSE;
179 p_sys->expiration = mdate() + (mtime_t)i_arg * (mtime_t)1000000;
183 msg_Err( p_demux, "unknown command `%s'", psz_name );
189 /*****************************************************************************
190 * CloseDemux: initialize the target, ie. parse the command
191 *****************************************************************************/
192 void E_(CloseDemux) ( vlc_object_t *p_this )
194 demux_t *p_demux = (demux_t*)p_this;
196 free( p_demux->p_sys );
199 /*****************************************************************************
200 * Demux: do what the command says
201 *****************************************************************************/
202 static int Demux( demux_t *p_demux )
204 demux_sys_t *p_sys = p_demux->p_sys;
205 playlist_t *p_playlist;
206 vlc_bool_t b_eof = VLC_FALSE;
208 p_playlist = vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST, FIND_PARENT );
210 if( p_playlist == NULL )
212 msg_Err( p_demux, "we are not attached to a playlist" );
216 switch( p_sys->i_command )
220 vlc_object_kill( p_demux->p_libvlc );
224 if( mdate() >= p_sys->expiration )
236 vlc_object_release( p_playlist );
237 return b_eof ? 0 : 1;
240 static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
242 return demux2_vaControlHelper( p_demux->s,