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.5 2003/11/28 22:16:30 gbazin 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 *****************************************************************************/
32 #include <vlc/input.h>
34 /*****************************************************************************
36 *****************************************************************************/
37 static int Demux ( input_thread_t * );
39 /*****************************************************************************
40 * access_sys_t: private input data
41 *****************************************************************************/
44 /* The real command */
47 /* Used for the pause command */
52 #define COMMAND_QUIT 1
53 #define COMMAND_LOOP 2
54 #define COMMAND_PAUSE 3
56 /*****************************************************************************
57 * OpenAccess: open the target, ie. do nothing
58 *****************************************************************************/
59 int E_(OpenAccess) ( vlc_object_t *p_this )
61 input_thread_t *p_input = (input_thread_t *)p_this;
63 p_input->stream.i_method = INPUT_METHOD_NONE;
65 /* Force dummy demux plug-in */
66 p_input->psz_demux = "vlc,none";
71 /*****************************************************************************
72 * OpenDemux: initialize the target, ie. parse the command
73 *****************************************************************************/
74 int E_(OpenDemux) ( vlc_object_t *p_this )
76 input_thread_t *p_input = (input_thread_t *)p_this;
77 char * psz_name = p_input->psz_name;
78 int i_len = strlen( psz_name );
79 struct demux_sys_t * p_method;
82 p_input->stream.b_seekable = 0;
83 p_input->pf_demux = Demux;
84 p_input->pf_rewind = NULL;
85 p_input->pf_demux_control = demux_vaControlDefault;
87 p_method = malloc( sizeof( struct demux_sys_t ) );
88 if( p_method == NULL )
90 msg_Err( p_input, "out of memory" );
94 p_input->p_demux_data = p_method;
95 p_input->stream.p_demux_data = NULL;
97 /* Check for a "vlc:nop" command */
98 if( i_len == 3 && !strncasecmp( psz_name, "nop", 3 ) )
100 msg_Info( p_input, "command `nop'" );
101 p_method->i_command = COMMAND_NOP;
105 /* Check for a "vlc:quit" command */
106 if( i_len == 4 && !strncasecmp( psz_name, "quit", 4 ) )
108 msg_Info( p_input, "command `quit'" );
109 p_method->i_command = COMMAND_QUIT;
113 /* Check for a "vlc:loop" command */
114 if( i_len == 4 && !strncasecmp( psz_name, "loop", 4 ) )
116 msg_Info( p_input, "command `loop'" );
117 p_method->i_command = COMMAND_LOOP;
121 /* Check for a "vlc:pause:***" command */
122 if( i_len > 6 && !strncasecmp( psz_name, "pause:", 6 ) )
124 i_arg = atoi( psz_name + 6 );
125 msg_Info( p_input, "command `pause %i'", i_arg );
126 p_method->i_command = COMMAND_PAUSE;
127 p_method->expiration = mdate() + (mtime_t)i_arg * (mtime_t)1000000;
131 msg_Err( p_input, "unknown command `%s'", psz_name );
132 free( p_input->p_demux_data );
133 p_input->b_error = 1;
138 /*****************************************************************************
139 * CloseDemux: initialize the target, ie. parse the command
140 *****************************************************************************/
141 void E_(CloseDemux) ( vlc_object_t *p_this )
143 input_thread_t *p_input = (input_thread_t *)p_this;
145 free( p_input->p_demux_data );
148 /*****************************************************************************
149 * Demux: do what the command says
150 *****************************************************************************/
151 static int Demux( input_thread_t *p_input )
153 struct demux_sys_t * p_method = p_input->p_demux_data;
154 playlist_t *p_playlist;
156 p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_PARENT );
158 if( p_playlist == NULL )
160 msg_Err( p_input, "we are not attached to a playlist" );
161 p_input->b_error = 1;
165 switch( p_method->i_command )
168 p_input->p_vlc->b_die = 1;
172 playlist_Goto( p_playlist, 0 );
176 if( mdate() < p_method->expiration )
192 vlc_object_release( p_playlist );