]> git.sesse.net Git - vlc/blob - plugins/dummy/input_dummy.c
Fixed a cosmetic issue.
[vlc] / plugins / dummy / input_dummy.c
1 /*****************************************************************************
2  * input_dummy.c: dummy input plugin, to manage "vlc:***" special options
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: input_dummy.c,v 1.9 2001/12/07 18:33:07 sam Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
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.
13  * 
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.
18  *
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  *****************************************************************************/
23
24 #define MODULE_NAME dummy
25 #include "modules_inner.h"
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #include "defs.h"
31
32 #include <stdlib.h>
33 #include <sys/types.h>
34 #include <string.h>
35 #include <errno.h>
36
37 #ifdef STRNCASECMP_IN_STRINGS_H
38 #   include <strings.h>
39 #endif
40
41 #include "common.h"
42 #include "intf_msg.h"
43 #include "threads.h"
44 #include "mtime.h"
45 #include "tests.h"
46
47 #include "interface.h"
48 #include "intf_playlist.h"
49
50 #include "modules.h"
51 #include "modules_export.h"
52
53 #include "stream_control.h"
54 #include "input_ext-intf.h"
55 #include "input_ext-dec.h"
56 #include "input_ext-plugins.h"
57
58 /*****************************************************************************
59  * Local prototypes
60  *****************************************************************************/
61 static int  DummyProbe     ( probedata_t * );
62 static void DummyOpen      ( struct input_thread_s * );
63 static void DummyClose     ( struct input_thread_s * );
64
65 /*****************************************************************************
66  * Functions exported as capabilities. They are declared as static so that
67  * we don't pollute the namespace too much.
68  *****************************************************************************/
69 void _M( input_getfunctions )( function_list_t * p_function_list )
70 {
71 #define input p_function_list->functions.input
72     p_function_list->pf_probe = DummyProbe;
73     input.pf_init             = NULL; /* Not needed, open is called first */
74     input.pf_open             = DummyOpen;
75     input.pf_close            = DummyClose;
76     input.pf_end              = NULL;
77     input.pf_set_area         = NULL;
78     input.pf_read             = NULL;
79     input.pf_demux            = NULL;
80     input.pf_new_packet       = NULL;
81     input.pf_new_pes          = NULL;
82     input.pf_delete_packet    = NULL;
83     input.pf_delete_pes       = NULL;
84     input.pf_rewind           = NULL;
85     input.pf_seek             = NULL;
86 #undef input
87 }
88
89 /*
90  * Data reading functions
91  */
92
93 /*****************************************************************************
94  * DummyProbe: verifies that the input is a vlc command
95  *****************************************************************************/
96 static int DummyProbe( probedata_t *p_data )
97 {
98     input_thread_t *p_input = (input_thread_t *)p_data;
99     char *psz_name = p_input->p_source;
100
101     if( TestMethod( INPUT_METHOD_VAR, "dummy" ) )
102     {
103         return( 999 );
104     }
105
106     if( ( strlen(psz_name) > 4 ) && !strncasecmp( psz_name, "vlc:", 4 ) )
107     {
108         /* If the user specified "vlc:" then it's probably a file */
109         return( 100 );
110     }
111
112     return( 1 );
113 }
114
115 /*****************************************************************************
116  * DummyOpen: open the target, ie. do what the command says
117  *****************************************************************************/
118 static void DummyOpen( input_thread_t * p_input )
119 {
120     char *psz_name = p_input->p_source;
121     int   i_len = strlen( psz_name );
122     int   i_arg;
123     
124     /* XXX: Tell the input layer to quit immediately, there must
125      * be a nicer way to do this. */
126     p_input->b_error = 1;
127
128     if( ( i_len <= 4 ) || strncasecmp( psz_name, "vlc:", 4 ) )
129     {
130         /* If the command doesn't start with "vlc:" then it's not for us */
131         return;
132     }
133
134     /* We don't need the "vlc:" stuff any more */
135     psz_name += 4;
136     i_len -= 4;
137
138     /* Check for a "vlc:quit" command */
139     if( i_len == 4 && !strncasecmp( psz_name, "quit", 4 ) )
140     {
141         intf_WarnMsg( 2, "input: command `quit'" );
142         p_main->p_intf->b_die = 1;
143         return;
144     }
145
146     /* Check for a "vlc:loop" command */
147     if( i_len == 4 && !strncasecmp( psz_name, "loop", 4 ) )
148     {
149         intf_WarnMsg( 2, "input: command `loop'" );
150         intf_PlaylistJumpto( p_main->p_playlist, -1 );
151         return;
152     }
153
154     /* Check for a "vlc:pause:***" command */
155     if( i_len > 6 && !strncasecmp( psz_name, "pause:", 6 ) )
156     {
157         i_arg = atoi( psz_name + 6 );
158
159         intf_WarnMsgImm( 2, "input: command `pause %i'", i_arg );
160
161         msleep( i_arg * 1000000 );
162         return;
163     }
164
165     intf_ErrMsg( "input error: unknown command `%s'", psz_name );
166
167 }
168
169 /*****************************************************************************
170  * DummyClose: close the target, ie. do nothing
171  *****************************************************************************/
172 static void DummyClose( input_thread_t * p_input )
173 {
174     return;
175 }
176