1 /*****************************************************************************
2 * input_dummy.c: dummy input plugin, to manage "vlc:***" special options
3 *****************************************************************************
4 * Copyright (C) 2001, 2002 VideoLAN
5 * $Id: input_dummy.c,v 1.17 2002/03/02 03:51:23 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>
32 #include <videolan/vlc.h>
34 #include "interface.h"
35 #include "intf_playlist.h"
37 #include "stream_control.h"
38 #include "input_ext-intf.h"
39 #include "input_ext-dec.h"
40 #include "input_ext-plugins.h"
42 /*****************************************************************************
44 *****************************************************************************/
45 static int DummyInit ( struct input_thread_s * );
46 static int DummyOpen ( struct input_thread_s * );
47 static void DummyClose ( struct input_thread_s * );
48 static void DummyEnd ( struct input_thread_s * );
49 static int DummyDemux ( struct input_thread_s * );
51 /*****************************************************************************
52 * access_sys_t: private input data
53 *****************************************************************************/
56 /* The real command */
59 /* Used for the pause command */
64 #define COMMAND_QUIT 1
65 #define COMMAND_LOOP 2
66 #define COMMAND_PAUSE 3
68 /*****************************************************************************
69 * Functions exported as capabilities. They are declared as static so that
70 * we don't pollute the namespace too much.
71 *****************************************************************************/
72 void _M( access_getfunctions )( function_list_t * p_function_list )
74 #define input p_function_list->functions.access
75 input.pf_open = DummyOpen;
77 input.pf_close = DummyClose;
78 input.pf_set_program = NULL;
79 input.pf_set_area = NULL;
84 void _M( demux_getfunctions )( function_list_t * p_function_list )
86 #define input p_function_list->functions.demux
87 input.pf_init = DummyInit;
88 input.pf_end = DummyEnd;
89 input.pf_demux = DummyDemux;
90 input.pf_rewind = NULL;
94 /*****************************************************************************
95 * DummyOpen: open the target, ie. do nothing
96 *****************************************************************************/
97 static int DummyOpen( input_thread_t * p_input )
99 p_input->stream.i_method = INPUT_METHOD_NONE;
101 /* Force dummy demux plug-in */
102 p_input->psz_demux = "vlc";
106 /*****************************************************************************
107 * DummyClose: close the target, ie. do nothing
108 *****************************************************************************/
109 static void DummyClose( input_thread_t * p_input )
113 /*****************************************************************************
114 * DummyInit: initialize the target, ie. parse the command
115 *****************************************************************************/
116 static int DummyInit( struct input_thread_s *p_input )
118 char * psz_name = p_input->psz_name;
119 int i_len = strlen( psz_name );
120 struct demux_sys_s * p_method;
123 p_input->stream.b_seekable = 0;
125 p_method = malloc( sizeof( struct demux_sys_s ) );
126 if( p_method == NULL )
128 intf_ErrMsg( "input: out of memory" );
132 p_input->p_demux_data = p_method;
133 p_input->stream.p_demux_data = NULL;
135 /* Check for a "vlc:nop" command */
136 if( i_len == 3 && !strncasecmp( psz_name, "nop", 3 ) )
138 intf_WarnMsg( 2, "input: command `nop'" );
139 p_method->i_command = COMMAND_NOP;
143 /* Check for a "vlc:quit" command */
144 if( i_len == 4 && !strncasecmp( psz_name, "quit", 4 ) )
146 intf_WarnMsg( 2, "input: command `quit'" );
147 p_method->i_command = COMMAND_QUIT;
151 /* Check for a "vlc:loop" command */
152 if( i_len == 4 && !strncasecmp( psz_name, "loop", 4 ) )
154 intf_WarnMsg( 2, "input: command `loop'" );
155 p_method->i_command = COMMAND_LOOP;
159 /* Check for a "vlc:pause:***" command */
160 if( i_len > 6 && !strncasecmp( psz_name, "pause:", 6 ) )
162 i_arg = atoi( psz_name + 6 );
163 intf_WarnMsg( 2, "input: command `pause %i'", i_arg );
164 p_method->i_command = COMMAND_PAUSE;
165 p_method->expiration = mdate() + (mtime_t)i_arg * (mtime_t)1000000;
169 intf_ErrMsg( "input error: unknown command `%s'", psz_name );
170 free( p_input->p_demux_data );
171 p_input->b_error = 1;
176 /*****************************************************************************
177 * DummyEnd: end the target, ie. do nothing
178 *****************************************************************************/
179 static void DummyEnd( struct input_thread_s *p_input )
181 free( p_input->p_demux_data );
184 /*****************************************************************************
185 * DummyDemux: do what the command says
186 *****************************************************************************/
187 static int DummyDemux( struct input_thread_s *p_input )
189 struct demux_sys_s * p_method = p_input->p_demux_data;
191 switch( p_method->i_command )
194 p_main->p_intf->b_die = 1;
199 intf_PlaylistJumpto( p_main->p_playlist, -1 );
204 if( mdate() < p_method->expiration )