/*****************************************************************************
* tcp.c: TCP input module
*****************************************************************************
- * Copyright (C) 2003-2004 VideoLAN
+ * Copyright (C) 2003-2004 the VideoLAN team
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <stdlib.h>
#include <vlc/vlc.h>
-#include <vlc/input.h>
+#include <vlc_access.h>
-#include "network.h"
+#include <vlc_network.h>
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define CACHING_TEXT N_("Caching value in ms")
#define CACHING_LONGTEXT N_( \
- "Allows you to modify the default caching value for TCP streams. This " \
- "value should be set in millisecond units." )
+ "Caching value for TCP streams. This " \
+ "value should be set in milliseconds." )
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
vlc_module_begin();
+ set_shortname( _("TCP") );
set_description( _("TCP input") );
+ set_category( CAT_INPUT );
+ set_subcategory( SUBCAT_INPUT_ACCESS );
add_integer( "tcp-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT,
CACHING_LONGTEXT, VLC_TRUE );
char *psz_parser = psz_dup;
/* Parse server:port */
- while( *psz_parser && *psz_parser != ':' )
+ if( *psz_parser == '[' )
{
- if( *psz_parser == '[' )
- {
- /* IPV6 */
- while( *psz_parser && *psz_parser != ']' )
- {
- psz_parser++;
- }
- }
- psz_parser++;
+ psz_parser = strchr( psz_parser, ']' );
+ if( psz_parser == NULL )
+ psz_parser = psz_dup;
}
- if( *psz_parser != ':' || psz_parser == psz_dup )
- {
- msg_Err( p_access, "you have to provide server:port addresse" );
- free( psz_dup );
- return VLC_EGENERIC;
- }
- *psz_parser++ = '\0';
+ psz_parser = strchr( psz_parser, ':' );
- if( atoi( psz_parser ) <= 0 )
+ if( psz_parser == NULL )
{
- msg_Err( p_access, "invalid port number (%d)", atoi( psz_parser ) );
+ msg_Err( p_access, "missing port number : %s", psz_dup );
free( psz_dup );
return VLC_EGENERIC;
}
+ *psz_parser++ = '\0';
+
/* Init p_access */
- p_access->pf_read = Read;
- p_access->pf_block = NULL;
- p_access->pf_control = Control;
- p_access->pf_seek = NULL;
- p_access->info.i_update = 0;
- p_access->info.i_size = 0;
- p_access->info.i_pos = 0;
- p_access->info.b_eof = VLC_FALSE;
- p_access->info.i_title = 0;
- p_access->info.i_seekpoint = 0;
- p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
-
- p_sys->fd = net_OpenTCP( p_access, psz_dup, atoi( psz_parser ) );
+ access_InitFields( p_access ); \
+ ACCESS_SET_CALLBACKS( Read, NULL, Control, NULL ); \
+ MALLOC_ERR( p_access->p_sys, access_sys_t ); \
+ p_sys = p_access->p_sys; memset( p_sys, 0, sizeof( access_sys_t ) );
+
+ p_sys->fd = net_ConnectTCP( p_access, psz_dup, atoi( psz_parser ) );
free( psz_dup );
if( p_sys->fd < 0 )
if( p_access->info.b_eof )
return 0;
- i_read = net_Read( p_access, p_sys->fd, p_buffer, i_len, VLC_FALSE );
+ i_read = net_Read( p_access, p_sys->fd, NULL, p_buffer, i_len,
+ VLC_FALSE );
if( i_read == 0 )
p_access->info.b_eof = VLC_TRUE;
else if( i_read > 0 )
case ACCESS_GET_TITLE_INFO:
case ACCESS_SET_TITLE:
case ACCESS_SET_SEEKPOINT:
+ case ACCESS_SET_PRIVATE_ID_STATE:
+ case ACCESS_GET_CONTENT_TYPE:
return VLC_EGENERIC;
default:
- msg_Err( p_access, "unimplemented query in control" );
+ msg_Warn( p_access, "unimplemented query in control" );
return VLC_EGENERIC;
}