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