File: input_dummy.c

package info (click to toggle)
vlc 0.2.92-8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,076 kB
  • ctags: 7,147
  • sloc: ansic: 62,829; cpp: 5,824; sh: 2,469; xml: 2,351; makefile: 1,291; python: 503; perl: 19
file content (176 lines) | stat: -rw-r--r-- 5,713 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*****************************************************************************
 * input_dummy.c: dummy input plugin, to manage "vlc:***" special options
 *****************************************************************************
 * Copyright (C) 2001 VideoLAN
 * $Id: input_dummy.c,v 1.9 2001/12/07 18:33:07 sam Exp $
 *
 * Authors: Samuel Hocevar <sam@zoy.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

#define MODULE_NAME dummy
#include "modules_inner.h"

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include "defs.h"

#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <errno.h>

#ifdef STRNCASECMP_IN_STRINGS_H
#   include <strings.h>
#endif

#include "common.h"
#include "intf_msg.h"
#include "threads.h"
#include "mtime.h"
#include "tests.h"

#include "interface.h"
#include "intf_playlist.h"

#include "modules.h"
#include "modules_export.h"

#include "stream_control.h"
#include "input_ext-intf.h"
#include "input_ext-dec.h"
#include "input_ext-plugins.h"

/*****************************************************************************
 * Local prototypes
 *****************************************************************************/
static int  DummyProbe     ( probedata_t * );
static void DummyOpen      ( struct input_thread_s * );
static void DummyClose     ( struct input_thread_s * );

/*****************************************************************************
 * Functions exported as capabilities. They are declared as static so that
 * we don't pollute the namespace too much.
 *****************************************************************************/
void _M( input_getfunctions )( function_list_t * p_function_list )
{
#define input p_function_list->functions.input
    p_function_list->pf_probe = DummyProbe;
    input.pf_init             = NULL; /* Not needed, open is called first */
    input.pf_open             = DummyOpen;
    input.pf_close            = DummyClose;
    input.pf_end              = NULL;
    input.pf_set_area         = NULL;
    input.pf_read             = NULL;
    input.pf_demux            = NULL;
    input.pf_new_packet       = NULL;
    input.pf_new_pes          = NULL;
    input.pf_delete_packet    = NULL;
    input.pf_delete_pes       = NULL;
    input.pf_rewind           = NULL;
    input.pf_seek             = NULL;
#undef input
}

/*
 * Data reading functions
 */

/*****************************************************************************
 * DummyProbe: verifies that the input is a vlc command
 *****************************************************************************/
static int DummyProbe( probedata_t *p_data )
{
    input_thread_t *p_input = (input_thread_t *)p_data;
    char *psz_name = p_input->p_source;

    if( TestMethod( INPUT_METHOD_VAR, "dummy" ) )
    {
        return( 999 );
    }

    if( ( strlen(psz_name) > 4 ) && !strncasecmp( psz_name, "vlc:", 4 ) )
    {
        /* If the user specified "vlc:" then it's probably a file */
        return( 100 );
    }

    return( 1 );
}

/*****************************************************************************
 * DummyOpen: open the target, ie. do what the command says
 *****************************************************************************/
static void DummyOpen( input_thread_t * p_input )
{
    char *psz_name = p_input->p_source;
    int   i_len = strlen( psz_name );
    int   i_arg;
    
    /* XXX: Tell the input layer to quit immediately, there must
     * be a nicer way to do this. */
    p_input->b_error = 1;

    if( ( i_len <= 4 ) || strncasecmp( psz_name, "vlc:", 4 ) )
    {
        /* If the command doesn't start with "vlc:" then it's not for us */
        return;
    }

    /* We don't need the "vlc:" stuff any more */
    psz_name += 4;
    i_len -= 4;

    /* Check for a "vlc:quit" command */
    if( i_len == 4 && !strncasecmp( psz_name, "quit", 4 ) )
    {
        intf_WarnMsg( 2, "input: command `quit'" );
        p_main->p_intf->b_die = 1;
        return;
    }

    /* Check for a "vlc:loop" command */
    if( i_len == 4 && !strncasecmp( psz_name, "loop", 4 ) )
    {
        intf_WarnMsg( 2, "input: command `loop'" );
        intf_PlaylistJumpto( p_main->p_playlist, -1 );
        return;
    }

    /* Check for a "vlc:pause:***" command */
    if( i_len > 6 && !strncasecmp( psz_name, "pause:", 6 ) )
    {
        i_arg = atoi( psz_name + 6 );

        intf_WarnMsgImm( 2, "input: command `pause %i'", i_arg );

        msleep( i_arg * 1000000 );
        return;
    }

    intf_ErrMsg( "input error: unknown command `%s'", psz_name );

}

/*****************************************************************************
 * DummyClose: close the target, ie. do nothing
 *****************************************************************************/
static void DummyClose( input_thread_t * p_input )
{
    return;
}