1 /*****************************************************************************
2 * input_dummy.c: dummy input plugin, to manage "vlc:***" special options
3 *****************************************************************************
4 * Copyright (C) 2001, 2002 VideoLAN
5 * $Id: input.c,v 1.1 2002/08/04 17:23:43 sam Exp $
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
28 #include <sys/types.h>
34 #include <vlc/input.h>
36 /*****************************************************************************
38 *****************************************************************************/
39 static int Demux ( input_thread_t * );
41 /*****************************************************************************
42 * access_sys_t: private input data
43 *****************************************************************************/
46 /* The real command */
49 /* Used for the pause command */
54 #define COMMAND_QUIT 1
55 #define COMMAND_LOOP 2
56 #define COMMAND_PAUSE 3
58 /*****************************************************************************
59 * OpenAccess: open the target, ie. do nothing
60 *****************************************************************************/
61 int E_(OpenAccess) ( vlc_object_t *p_this )
63 input_thread_t *p_input = (input_thread_t *)p_this;
65 p_input->stream.i_method = INPUT_METHOD_NONE;
67 /* Force dummy demux plug-in */
68 p_input->psz_demux = "vlc";
73 /*****************************************************************************
74 * OpenDemux: initialize the target, ie. parse the command
75 *****************************************************************************/
76 int E_(OpenDemux) ( vlc_object_t *p_this )
78 input_thread_t *p_input = (input_thread_t *)p_this;
79 char * psz_name = p_input->psz_name;
80 int i_len = strlen( psz_name );
81 struct demux_sys_t * p_method;
84 p_input->stream.b_seekable = 0;
85 p_input->pf_demux = Demux;
86 p_input->pf_rewind = NULL;
88 p_method = malloc( sizeof( struct demux_sys_t ) );
89 if( p_method == NULL )
91 msg_Err( p_input, "out of memory" );
95 p_input->p_demux_data = p_method;
96 p_input->stream.p_demux_data = NULL;
98 /* Check for a "vlc:nop" command */
99 if( i_len == 3 && !strncasecmp( psz_name, "nop", 3 ) )
101 msg_Info( p_input, "command `nop'" );
102 p_method->i_command = COMMAND_NOP;
106 /* Check for a "vlc:quit" command */
107 if( i_len == 4 && !strncasecmp( psz_name, "quit", 4 ) )
109 msg_Info( p_input, "command `quit'" );
110 p_method->i_command = COMMAND_QUIT;
114 /* Check for a "vlc:loop" command */
115 if( i_len == 4 && !strncasecmp( psz_name, "loop", 4 ) )
117 msg_Info( p_input, "command `loop'" );
118 p_method->i_command = COMMAND_LOOP;
122 /* Check for a "vlc:pause:***" command */
123 if( i_len > 6 && !strncasecmp( psz_name, "pause:", 6 ) )
125 i_arg = atoi( psz_name + 6 );
126 msg_Info( p_input, "command `pause %i'", i_arg );
127 p_method->i_command = COMMAND_PAUSE;
128 p_method->expiration = mdate() + (mtime_t)i_arg * (mtime_t)1000000;
132 msg_Err( p_input, "unknown command `%s'", psz_name );
133 free( p_input->p_demux_data );
134 p_input->b_error = 1;
139 /*****************************************************************************
140 * CloseDemux: initialize the target, ie. parse the command
141 *****************************************************************************/
142 void E_(CloseDemux) ( vlc_object_t *p_this )
144 input_thread_t *p_input = (input_thread_t *)p_this;
146 free( p_input->p_demux_data );
149 /*****************************************************************************
150 * Demux: do what the command says
151 *****************************************************************************/
152 static int Demux( input_thread_t *p_input )
154 struct demux_sys_t * p_method = p_input->p_demux_data;
155 playlist_t *p_playlist;
157 p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_PARENT );
159 if( p_playlist == NULL )
161 msg_Err( p_input, "we are not attached to a playlist" );
162 p_input->b_error = 1;
166 switch( p_method->i_command )
169 p_input->p_vlc->b_die = 1;
173 playlist_Goto( p_playlist, 0 );
177 if( mdate() < p_method->expiration )
193 vlc_object_release( p_playlist );