1 /*****************************************************************************
2 * tcp.c: TCP input module
3 *****************************************************************************
4 * Copyright (C) 2003-2004 VLC authors and VideoLAN
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
30 #include <vlc_common.h>
31 #include <vlc_plugin.h>
32 #include <vlc_access.h>
36 static ssize_t
Read(stream_t
*access
, void *buf
, size_t len
)
38 return vlc_tls_Read(access
->p_sys
, buf
, len
, false);
41 static int Control( stream_t
*p_access
, int i_query
, va_list args
)
48 case STREAM_CAN_FASTSEEK
:
49 pb_bool
= va_arg( args
, bool * );
52 case STREAM_CAN_PAUSE
:
53 pb_bool
= va_arg( args
, bool * );
54 *pb_bool
= true; /* FIXME */
56 case STREAM_CAN_CONTROL_PACE
:
57 pb_bool
= va_arg( args
, bool * );
58 *pb_bool
= true; /* FIXME */
61 case STREAM_GET_PTS_DELAY
:
62 *va_arg( args
, vlc_tick_t
* ) =
63 VLC_TICK_FROM_MS(var_InheritInteger( p_access
, "network-caching" ));
66 case STREAM_SET_PAUSE_STATE
:
76 static int Open(vlc_object_t
*obj
)
78 stream_t
*access
= (stream_t
*)obj
;
82 if (vlc_UrlParse(&url
, access
->psz_url
)
83 || url
.psz_host
== NULL
|| url
.i_port
== 0)
85 msg_Err(access
, "invalid location: %s", access
->psz_location
);
90 sock
= vlc_tls_SocketOpenTCP(obj
, url
.psz_host
, url
.i_port
);
96 access
->pf_read
= Read
;
97 access
->pf_block
= NULL
;
98 access
->pf_control
= Control
;
99 access
->pf_seek
= NULL
;
103 static void Close( vlc_object_t
*p_this
)
105 stream_t
*access
= (stream_t
*)p_this
;
107 vlc_tls_SessionDelete(access
->p_sys
);
110 /*****************************************************************************
112 *****************************************************************************/
114 set_shortname( N_("TCP") )
115 set_description( N_("TCP input") )
116 set_category( CAT_INPUT
)
117 set_subcategory( SUBCAT_INPUT_ACCESS
)
119 set_capability( "access", 0 )
120 add_shortcut( "tcp" )
121 set_callbacks( Open
, Close
)