Commit 5658c1d9 authored by Christophe Massiot's avatar Christophe Massiot

* IPv6 network module, courtesy of Alexis Guillard <alexis.guillard@bt.com>,

for BT ;
* --6 and --4 options to force IPv6 or IPv4 (FIXME: it should be -6 and
-4 but I don't know how to do it with the new configuration module) ;
* Channel manager now uses a socket from the network plug-in and is more
portable (and probably broken, too :) ;
* input_ReadPS and input_ReadTS are now in mpeg_system.c to be more
easily reused by plug-ins other than mpeg_ps and mpeg_ts.

That's all for tonight.
parent f0426503
...@@ -125,6 +125,10 @@ E: jeanphi@via.ecp.fr ...@@ -125,6 +125,10 @@ E: jeanphi@via.ecp.fr
C: jeanphi C: jeanphi
D: Bug fixes D: Bug fixes
N: Alexis Guillard
E: alexis.guillard@bt.com
D: IPv6
N: Shane Harper N: Shane Harper
E: shanegh@optusnet.com.au E: shanegh@optusnet.com.au
D: SDL plugin fixes and enhancements D: SDL plugin fixes and enhancements
......
...@@ -125,6 +125,7 @@ PLUGINS_TARGETS := ac3_adec/ac3_adec \ ...@@ -125,6 +125,7 @@ PLUGINS_TARGETS := ac3_adec/ac3_adec \
mpeg_adec/mpeg_adec \ mpeg_adec/mpeg_adec \
mpeg_vdec/mpeg_vdec \ mpeg_vdec/mpeg_vdec \
network/ipv4 \ network/ipv4 \
network/ipv6 \
qnx/qnx \ qnx/qnx \
qt/qt \ qt/qt \
sdl/sdl \ sdl/sdl \
......
This diff is collapsed.
...@@ -960,6 +960,12 @@ then ...@@ -960,6 +960,12 @@ then
PLUGINS="${PLUGINS} null" PLUGINS="${PLUGINS} null"
fi fi
dnl
dnl ipv6 plugin
dnl
AC_EGREP_HEADER(in6_addr,netinet/in.h,[
PLUGINS="${PLUGINS} ipv6"])
dnl dnl
dnl rc plugin dnl rc plugin
dnl dnl
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions * Collection of useful common types and macros definitions
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: common.h,v 1.83 2002/03/03 04:37:29 sam Exp $ * $Id: common.h,v 1.84 2002/03/04 23:56:37 massiot Exp $
* *
* Authors: Samuel Hocevar <sam@via.ecp.fr> * Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -552,8 +552,12 @@ typedef struct module_symbols_s ...@@ -552,8 +552,12 @@ typedef struct module_symbols_s
struct pes_packet_s * ); struct pes_packet_s * );
struct es_descriptor_s * ( * input_ParsePS ) ( struct input_thread_s *, struct es_descriptor_s * ( * input_ParsePS ) ( struct input_thread_s *,
struct data_packet_s * ); struct data_packet_s * );
ssize_t ( * input_ReadPS ) ( struct input_thread_s *,
struct data_packet_s ** );
void ( * input_DemuxPS ) ( struct input_thread_s *, void ( * input_DemuxPS ) ( struct input_thread_s *,
struct data_packet_s * ); struct data_packet_s * );
ssize_t ( * input_ReadTS ) ( struct input_thread_s *,
struct data_packet_s ** );
void ( * input_DemuxTS ) ( struct input_thread_s *, void ( * input_DemuxTS ) ( struct input_thread_s *,
struct data_packet_s * ); struct data_packet_s * );
void ( * input_DemuxPSI ) ( struct input_thread_s *, void ( * input_DemuxPSI ) ( struct input_thread_s *,
......
...@@ -346,6 +346,9 @@ ...@@ -346,6 +346,9 @@
#define INPUT_DVD_DEVICE_VAR "dvd_device" #define INPUT_DVD_DEVICE_VAR "dvd_device"
/* VCD defaults */ /* VCD defaults */
#define INPUT_VCD_DEVICE_VAR "vcd_device" #define INPUT_VCD_DEVICE_VAR "vcd_device"
/* IPv6, IPv4 */
#define INPUT_IPV6_VAR "6"
#define INPUT_IPV4_VAR "4"
/* /*
* Decoders option names * Decoders option names
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* but exported to plug-ins * but exported to plug-ins
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2002 VideoLAN * Copyright (C) 1999-2002 VideoLAN
* $Id: input_ext-plugins.h,v 1.20 2002/03/02 03:53:54 xav Exp $ * $Id: input_ext-plugins.h,v 1.21 2002/03/04 23:56:37 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -193,6 +193,7 @@ static __inline__ void input_NullPacket( input_thread_t * p_input, ...@@ -193,6 +193,7 @@ static __inline__ void input_NullPacket( input_thread_t * p_input,
* Constants * Constants
*****************************************************************************/ *****************************************************************************/
#define TS_PACKET_SIZE 188 /* Size of a TS packet */ #define TS_PACKET_SIZE 188 /* Size of a TS packet */
#define TS_SYNC_CODE 0x47 /* First byte of a TS packet */
#define PSI_SECTION_SIZE 4096 /* Maximum size of a PSI section */ #define PSI_SECTION_SIZE 4096 /* Maximum size of a PSI section */
#define PAT_UNINITIALIZED (1 << 6) #define PAT_UNINITIALIZED (1 << 6)
...@@ -286,8 +287,10 @@ typedef struct stream_ps_data_s ...@@ -286,8 +287,10 @@ typedef struct stream_ps_data_s
void input_ParsePES ( struct input_thread_s *, struct es_descriptor_s * ); void input_ParsePES ( struct input_thread_s *, struct es_descriptor_s * );
void input_GatherPES ( struct input_thread_s *, struct data_packet_s *, void input_GatherPES ( struct input_thread_s *, struct data_packet_s *,
struct es_descriptor_s *, boolean_t, boolean_t ); struct es_descriptor_s *, boolean_t, boolean_t );
ssize_t input_ReadPS ( struct input_thread_s *, struct data_packet_s ** );
es_descriptor_t * input_ParsePS( struct input_thread_s *, es_descriptor_t * input_ParsePS( struct input_thread_s *,
struct data_packet_s * ); struct data_packet_s * );
ssize_t input_ReadTS ( struct input_thread_s *, struct data_packet_s ** );
void input_DemuxPS ( struct input_thread_s *, struct data_packet_s * ); void input_DemuxPS ( struct input_thread_s *, struct data_packet_s * );
void input_DemuxTS ( struct input_thread_s *, struct data_packet_s * ); void input_DemuxTS ( struct input_thread_s *, struct data_packet_s * );
void input_DemuxPSI ( struct input_thread_s *, struct data_packet_s *, void input_DemuxPSI ( struct input_thread_s *, struct data_packet_s *,
...@@ -295,8 +298,10 @@ void input_DemuxPSI ( struct input_thread_s *, struct data_packet_s *, ...@@ -295,8 +298,10 @@ void input_DemuxPSI ( struct input_thread_s *, struct data_packet_s *,
#else #else
# define input_ParsePES p_symbols->input_ParsePES # define input_ParsePES p_symbols->input_ParsePES
# define input_GatherPES p_symbols->input_GatherPES # define input_GatherPES p_symbols->input_GatherPES
# define input_ReadPS p_symbols->input_ReadPS
# define input_ParsePS p_symbols->input_ParsePS # define input_ParsePS p_symbols->input_ParsePS
# define input_DemuxPS p_symbols->input_DemuxPS # define input_DemuxPS p_symbols->input_DemuxPS
# define input_ReadTS p_symbols->input_ReadTS
# define input_DemuxTS p_symbols->input_DemuxTS # define input_DemuxTS p_symbols->input_DemuxTS
# define input_DemuxPSI p_symbols->input_DemuxPSI # define input_DemuxPSI p_symbols->input_DemuxPSI
#endif #endif
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* http.c: HTTP access plug-in * http.c: HTTP access plug-in
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: http.c,v 1.1 2002/03/01 00:33:18 massiot Exp $ * $Id: http.c,v 1.2 2002/03/04 23:56:37 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -230,6 +230,14 @@ static int HTTPOpen( input_thread_t * p_input ) ...@@ -230,6 +230,14 @@ static int HTTPOpen( input_thread_t * p_input )
} }
p_access_data->psz_network = NULL; p_access_data->psz_network = NULL;
if( config_GetIntVariable( INPUT_IPV4_VAR ) )
{
p_access_data->psz_network = "ipv4";
}
if( config_GetIntVariable( INPUT_IPV6_VAR ) )
{
p_access_data->psz_network = "ipv6";
}
if( p_input->psz_access != NULL ) if( p_input->psz_access != NULL )
{ {
/* Find out which shortcut was used */ /* Find out which shortcut was used */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* udp.c: raw UDP access plug-in * udp.c: raw UDP access plug-in
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: udp.c,v 1.1 2002/03/01 00:33:18 massiot Exp $ * $Id: udp.c,v 1.2 2002/03/04 23:56:37 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -107,6 +107,15 @@ static int UDPOpen( input_thread_t * p_input ) ...@@ -107,6 +107,15 @@ static int UDPOpen( input_thread_t * p_input )
int i_bind_port = 0, i_server_port = 0; int i_bind_port = 0, i_server_port = 0;
network_socket_t socket_desc; network_socket_t socket_desc;
if( config_GetIntVariable( INPUT_IPV4_VAR ) )
{
psz_network = "ipv4";
}
if( config_GetIntVariable( INPUT_IPV6_VAR ) )
{
psz_network = "ipv6";
}
if( p_input->psz_access != NULL ) if( p_input->psz_access != NULL )
{ {
/* Find out which shortcut was used */ /* Find out which shortcut was used */
...@@ -129,9 +138,17 @@ static int UDPOpen( input_thread_t * p_input ) ...@@ -129,9 +138,17 @@ static int UDPOpen( input_thread_t * p_input )
psz_server_addr = psz_parser; psz_server_addr = psz_parser;
while( *psz_parser && *psz_parser != ':' && *psz_parser != '@' ) while( *psz_parser && *psz_parser != ':' && *psz_parser != '@' )
{
if( *psz_parser == '[' )
{
/* IPv6 address */
while( *psz_parser && *psz_parser != ']' )
{ {
psz_parser++; psz_parser++;
} }
}
psz_parser++;
}
if( *psz_parser == ':' ) if( *psz_parser == ':' )
{ {
...@@ -150,7 +167,8 @@ static int UDPOpen( input_thread_t * p_input ) ...@@ -150,7 +167,8 @@ static int UDPOpen( input_thread_t * p_input )
if( *psz_parser == '@' ) if( *psz_parser == '@' )
{ {
/* Found bind address or bind port */ /* Found bind address or bind port */
*psz_parser = '\0'; /* Terminate server port or name if necessary */ psz_parser++; *psz_parser = '\0'; /* Terminate server port or name if necessary */
psz_parser++;
if( *psz_parser && *psz_parser != ':' ) if( *psz_parser && *psz_parser != ':' )
{ {
...@@ -159,6 +177,14 @@ static int UDPOpen( input_thread_t * p_input ) ...@@ -159,6 +177,14 @@ static int UDPOpen( input_thread_t * p_input )
while( *psz_parser && *psz_parser != ':' ) while( *psz_parser && *psz_parser != ':' )
{ {
if( *psz_parser == '[' )
{
/* IPv6 address */
while( *psz_parser && *psz_parser != ']' )
{
psz_parser++;
}
}
psz_parser++; psz_parser++;
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mpeg_ps.c : Program Stream input module for vlc * mpeg_ps.c : Program Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: mpeg_ps.c,v 1.4 2002/03/01 00:33:18 massiot Exp $ * $Id: mpeg_ps.c,v 1.5 2002/03/04 23:56:37 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -83,113 +83,6 @@ static void input_getfunctions( function_list_t * p_function_list ) ...@@ -83,113 +83,6 @@ static void input_getfunctions( function_list_t * p_function_list )
#undef input #undef input
} }
/*
* Data reading functions
*/
/*****************************************************************************
* PSRead: reads one PS packet
*****************************************************************************/
#define PEEK( SIZE ) \
i_error = input_Peek( p_input, &p_peek, SIZE ); \
if( i_error == -1 ) \
{ \
return( -1 ); \
} \
else if( i_error < SIZE ) \
{ \
/* EOF */ \
return( 0 ); \
}
static __inline__ ssize_t PSRead( input_thread_t * p_input,
data_packet_t ** pp_data )
{
byte_t * p_peek;
size_t i_packet_size;
ssize_t i_error, i_read;
/* Read what we believe to be a packet header. */
PEEK( 4 );
if( *p_peek || *(p_peek + 1) || *(p_peek + 2) != 1 )
{
if( *p_peek || *(p_peek + 1) || *(p_peek + 2) )
{
/* It is common for MPEG-1 streams to pad with zeros
* (although it is forbidden by the recommendation), so
* don't bother everybody in this case. */
intf_WarnMsg( 3, "input warning: garbage at input (0x%x%x%x%x)",
*p_peek, *(p_peek + 1), *(p_peek + 2), *(p_peek + 3) );
}
/* This is not the startcode of a packet. Read the stream
* until we find one. */
while( *p_peek || *(p_peek + 1) || *(p_peek + 2) != 1 )
{
p_input->p_current_data++;
PEEK( 4 );
}
/* Packet found. */
}
/* 0x1B9 == SYSTEM_END_CODE, it is only 4 bytes long. */
if( p_peek[3] != 0xB9 )
{
/* The packet is at least 6 bytes long. */
PEEK( 6 );
if( p_peek[3] != 0xBA )
{
/* That's the case for all packets, except pack header. */
i_packet_size = (p_peek[4] << 8) | p_peek[5];
}
else
{
/* Pack header. */
if( (p_peek[4] & 0xC0) == 0x40 )
{
/* MPEG-2 */
i_packet_size = 8;
}
else if( (p_peek[4] & 0xF0) == 0x20 )
{
/* MPEG-1 */
i_packet_size = 6;
}
else
{
intf_ErrMsg( "Unable to determine stream type" );
return( -1 );
}
}
}
else
{
/* System End Code */
i_packet_size = -2;
}
/* Fetch a packet of the appropriate size. */
i_read = input_SplitBuffer( p_input, pp_data, i_packet_size + 6 );
if( i_read <= 0 )
{
return( i_read );
}
/* In MPEG-2 pack headers we still have to read stuffing bytes. */
if( ((*pp_data)->p_demux_start[3] == 0xBA) && (i_packet_size == 8) )
{
size_t i_stuffing = ((*pp_data)->p_demux_start[13] & 0x7);
/* Force refill of the input buffer - though we don't care
* about p_peek. Please note that this is unoptimized. */
PEEK( i_stuffing );
p_input->p_current_data += i_stuffing;
}
return( 1 );
}
/***************************************************************************** /*****************************************************************************
* PSInit: initializes PS structures * PSInit: initializes PS structures
*****************************************************************************/ *****************************************************************************/
...@@ -266,7 +159,7 @@ static int PSInit( input_thread_t * p_input ) ...@@ -266,7 +159,7 @@ static int PSInit( input_thread_t * p_input )
ssize_t i_result; ssize_t i_result;
data_packet_t * p_data; data_packet_t * p_data;
i_result = PSRead( p_input, &p_data ); i_result = input_ReadPS( p_input, &p_data );
if( i_result == 0 ) if( i_result == 0 )
{ {
...@@ -413,7 +306,7 @@ static int PSDemux( input_thread_t * p_input ) ...@@ -413,7 +306,7 @@ static int PSDemux( input_thread_t * p_input )
data_packet_t * p_data; data_packet_t * p_data;
ssize_t i_result; ssize_t i_result;
i_result = PSRead( p_input, &p_data ); i_result = input_ReadPS( p_input, &p_data );
if( i_result <= 0 ) if( i_result <= 0 )
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mpeg_ts.c : Transport Stream input module for vlc * mpeg_ts.c : Transport Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: mpeg_ts.c,v 1.4 2002/03/01 00:33:18 massiot Exp $ * $Id: mpeg_ts.c,v 1.5 2002/03/04 23:56:37 massiot Exp $
* *
* Authors: Henri Fallon <henri@via.ecp.fr> * Authors: Henri Fallon <henri@via.ecp.fr>
* *
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
* Constants * Constants
*****************************************************************************/ *****************************************************************************/
#define TS_READ_ONCE 200 #define TS_READ_ONCE 200
#define TS_PACKET_SIZE 188
#define TS_SYNC_CODE 0x47
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
...@@ -163,18 +161,6 @@ static void TSEnd( input_thread_t * p_input ) ...@@ -163,18 +161,6 @@ static void TSEnd( input_thread_t * p_input )
* Returns -1 in case of error, 0 in case of EOF, otherwise the number of * Returns -1 in case of error, 0 in case of EOF, otherwise the number of
* packets. * packets.
*****************************************************************************/ *****************************************************************************/
#define PEEK( SIZE ) \
i_error = input_Peek( p_input, &p_peek, SIZE ); \
if( i_error == -1 ) \
{ \
return( -1 ); \
} \
else if( i_error < SIZE ) \
{ \
/* EOF */ \
return( 0 ); \
}
static int TSDemux( input_thread_t * p_input ) static int TSDemux( input_thread_t * p_input )
{ {
int i_read_once = (p_input->i_mtu ? int i_read_once = (p_input->i_mtu ?
...@@ -185,38 +171,13 @@ static int TSDemux( input_thread_t * p_input ) ...@@ -185,38 +171,13 @@ static int TSDemux( input_thread_t * p_input )
for( i = 0; i < i_read_once; i++ ) for( i = 0; i < i_read_once; i++ )
{ {
data_packet_t * p_data; data_packet_t * p_data;
ssize_t i_read, i_error; ssize_t i_result;
byte_t * p_peek;
PEEK( 1 );
if( *p_peek != TS_SYNC_CODE )
{
intf_WarnMsg( 3, "input warning: garbage at input (%x)", *p_peek );
if( p_input->i_mtu )
{
/* Try to resync on next packet. */
PEEK( TS_PACKET_SIZE );
p_input->p_current_data += TS_PACKET_SIZE;
}
else
{
/* Move forward until we find 0x47 (and hope it's the good
* one... FIXME) */
while( *p_peek != TS_SYNC_CODE )
{
p_input->p_current_data++;
PEEK( 1 );
}
}
}
i_read = input_SplitBuffer( p_input, &p_data, TS_PACKET_SIZE ); i_result = input_ReadTS( p_input, &p_data );
if( i_read <= 0 ) if( i_result <= 0 )
{ {
return( i_read ); return( i_result );
} }
input_DemuxTS( p_input, p_data ); input_DemuxTS( p_input, p_data );
......
ipv4_SOURCES = ipv4.c ipv4_SOURCES = ipv4.c
ipv6_SOURCES = ipv6.c
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
* ipv4.c: IPv4 network abstraction layer * ipv4.c: IPv4 network abstraction layer
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: ipv4.c,v 1.3 2002/03/02 03:53:55 xav Exp $ * $Id: ipv4.c,v 1.4 2002/03/04 23:56:37 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Mathias Kretschmer <mathias@research.att.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -153,7 +154,9 @@ static int OpenUDP( network_socket_t * p_socket ) ...@@ -153,7 +154,9 @@ static int OpenUDP( network_socket_t * p_socket )
int i_bind_port = p_socket->i_bind_port; int i_bind_port = p_socket->i_bind_port;
char * psz_server_addr = p_socket->psz_server_addr; char * psz_server_addr = p_socket->psz_server_addr;
int i_server_port = p_socket->i_server_port; int i_server_port = p_socket->i_server_port;
#ifdef WIN32
char * psz_bind_win32; /* WIN32 multicast kludge */ char * psz_bind_win32; /* WIN32 multicast kludge */
#endif
int i_handle, i_opt, i_opt_size; int i_handle, i_opt, i_opt_size;
struct sockaddr_in sock; struct sockaddr_in sock;
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mpeg_system.c: TS, PS and PES management * mpeg_system.c: TS, PS and PES management
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: mpeg_system.c,v 1.81 2002/03/01 00:33:18 massiot Exp $ * $Id: mpeg_system.c,v 1.82 2002/03/04 23:56:37 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr> * Michel Lespinasse <walken@via.ecp.fr>
...@@ -639,6 +639,110 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data ) ...@@ -639,6 +639,110 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data )
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
} }
/*****************************************************************************
* input_ReadPS: store a PS packet into a data_buffer_t
*****************************************************************************/
#define PEEK( SIZE ) \
i_error = input_Peek( p_input, &p_peek, SIZE ); \
if( i_error == -1 ) \
{ \
return( -1 ); \
} \
else if( i_error < SIZE ) \
{ \
/* EOF */ \
return( 0 ); \
}
ssize_t input_ReadPS( input_thread_t * p_input, data_packet_t ** pp_data )
{
byte_t * p_peek;
size_t i_packet_size;
ssize_t i_error, i_read;
/* Read what we believe to be a packet header. */
PEEK( 4 );
if( *p_peek || *(p_peek + 1) || *(p_peek + 2) != 1 )
{
if( *p_peek || *(p_peek + 1) || *(p_peek + 2) )
{
/* It is common for MPEG-1 streams to pad with zeros
* (although it is forbidden by the recommendation), so
* don't bother everybody in this case. */
intf_WarnMsg( 3, "input warning: garbage at input (0x%x%x%x%x)",
*p_peek, *(p_peek + 1), *(p_peek + 2), *(p_peek + 3) );
}
/* This is not the startcode of a packet. Read the stream
* until we find one. */
while( *p_peek || *(p_peek + 1) || *(p_peek + 2) != 1 )
{
p_input->p_current_data++;
PEEK( 4 );
}
/* Packet found. */
}
/* 0x1B9 == SYSTEM_END_CODE, it is only 4 bytes long. */
if( p_peek[3] != 0xB9 )
{
/* The packet is at least 6 bytes long. */
PEEK( 6 );
if( p_peek[3] != 0xBA )
{
/* That's the case for all packets, except pack header. */
i_packet_size = (p_peek[4] << 8) | p_peek[5];
}
else
{
/* Pack header. */
if( (p_peek[4] & 0xC0) == 0x40 )
{
/* MPEG-2 */
i_packet_size = 8;
}
else if( (p_peek[4] & 0xF0) == 0x20 )
{
/* MPEG-1 */
i_packet_size = 6;
}
else
{
intf_ErrMsg( "Unable to determine stream type" );
return( -1 );
}
}
}
else
{
/* System End Code */
i_packet_size = -2;
}
/* Fetch a packet of the appropriate size. */
i_read = input_SplitBuffer( p_input, pp_data, i_packet_size + 6 );
if( i_read <= 0 )
{
return( i_read );
}
/* In MPEG-2 pack headers we still have to read stuffing bytes. */
if( ((*pp_data)->p_demux_start[3] == 0xBA) && (i_packet_size == 8) )
{
size_t i_stuffing = ((*pp_data)->p_demux_start[13] & 0x7);
/* Force refill of the input buffer - though we don't care
* about p_peek. Please note that this is unoptimized. */
PEEK( i_stuffing );
p_input->p_current_data += i_stuffing;
}
return( 1 );
}
#undef PEEK
/***************************************************************************** /*****************************************************************************
* input_ParsePS: read the PS header * input_ParsePS: read the PS header
*****************************************************************************/ *****************************************************************************/
...@@ -923,6 +1027,63 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data ) ...@@ -923,6 +1027,63 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data )
* TS Demultiplexing * TS Demultiplexing
*/ */
/*****************************************************************************
* input_ReadTS: store a TS packet into a data_buffer_t
*****************************************************************************/
#define PEEK( SIZE ) \
i_error = input_Peek( p_input, &p_peek, SIZE ); \
if( i_error == -1 ) \
{ \
return( -1 ); \
} \
else if( i_error < SIZE ) \
{ \
/* EOF */ \
return( 0 ); \
}
ssize_t input_ReadTS( input_thread_t * p_input, data_packet_t ** pp_data )
{
byte_t * p_peek;
ssize_t i_error, i_read;
PEEK( 1 );
if( *p_peek != TS_SYNC_CODE )
{
intf_WarnMsg( 3, "input warning: garbage at input (%x)", *p_peek );
if( p_input->i_mtu )
{
while( *p_peek != TS_SYNC_CODE )
{
/* Try to resync on next packet. */
PEEK( TS_PACKET_SIZE );
p_input->p_current_data += TS_PACKET_SIZE;
PEEK( 1 );
}
}
else
{
/* Move forward until we find 0x47 (and hope it's the good
* one... FIXME) */
while( *p_peek != TS_SYNC_CODE )
{
p_input->p_current_data++;
PEEK( 1 );
}
}
}
i_read = input_SplitBuffer( p_input, pp_data, TS_PACKET_SIZE );
if( i_read <= 0 )
{
return( i_read );
}
return( 1 );
}
/***************************************************************************** /*****************************************************************************
* input_DemuxTS: first step of demultiplexing: the TS header * input_DemuxTS: first step of demultiplexing: the TS header
*****************************************************************************/ *****************************************************************************/
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* and spawn threads. * and spawn threads.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: main.c,v 1.159 2002/03/04 22:18:25 gbazin Exp $ * $Id: main.c,v 1.160 2002/03/04 23:56:38 massiot Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -169,6 +169,8 @@ ADD_INTEGER ( INPUT_SUBTITLE_VAR, -1, NULL, "choose subtitles", NULL ) ...@@ -169,6 +169,8 @@ ADD_INTEGER ( INPUT_SUBTITLE_VAR, -1, NULL, "choose subtitles", NULL )
ADD_STRING ( INPUT_DVD_DEVICE_VAR, "/dev/dvd", NULL, "DVD device", NULL ) ADD_STRING ( INPUT_DVD_DEVICE_VAR, "/dev/dvd", NULL, "DVD device", NULL )
ADD_STRING ( INPUT_VCD_DEVICE_VAR, "/dev/cdrom", NULL, "VCD device", NULL ) ADD_STRING ( INPUT_VCD_DEVICE_VAR, "/dev/cdrom", NULL, "VCD device", NULL )
ADD_BOOL ( INPUT_IPV6_VAR, NULL, "force IPv6", NULL )
ADD_BOOL ( INPUT_IPV4_VAR, NULL, "force IPv4", NULL )
/* Decoder options */ /* Decoder options */
ADD_CATEGORY_HINT( "Decoders Options", NULL ) ADD_CATEGORY_HINT( "Decoders Options", NULL )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* modules_plugin.h : Plugin management functions used by the core application. * modules_plugin.h : Plugin management functions used by the core application.
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: modules_plugin.h,v 1.13 2002/03/01 00:33:18 massiot Exp $ * $Id: modules_plugin.h,v 1.14 2002/03/04 23:56:38 massiot Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -209,8 +209,10 @@ module_error( void ) ...@@ -209,8 +209,10 @@ module_error( void )
(p_symbols)->input_ParsePES = input_ParsePES; \ (p_symbols)->input_ParsePES = input_ParsePES; \
(p_symbols)->input_GatherPES = input_GatherPES; \ (p_symbols)->input_GatherPES = input_GatherPES; \
(p_symbols)->input_DecodePES = input_DecodePES; \ (p_symbols)->input_DecodePES = input_DecodePES; \
(p_symbols)->input_ReadPS = input_ReadPS; \
(p_symbols)->input_ParsePS = input_ParsePS; \ (p_symbols)->input_ParsePS = input_ParsePS; \
(p_symbols)->input_DemuxPS = input_DemuxPS; \ (p_symbols)->input_DemuxPS = input_DemuxPS; \
(p_symbols)->input_ReadTS = input_ReadTS; \
(p_symbols)->input_DemuxTS = input_DemuxTS; \ (p_symbols)->input_DemuxTS = input_DemuxTS; \
(p_symbols)->input_DemuxPSI = input_DemuxPSI; \ (p_symbols)->input_DemuxPSI = input_DemuxPSI; \
(p_symbols)->input_ClockManageControl = input_ClockManageControl; \ (p_symbols)->input_ClockManageControl = input_ClockManageControl; \
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* netutils.c: various network functions * netutils.c: various network functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: netutils.c,v 1.58 2002/02/27 04:49:55 sam Exp $ * $Id: netutils.c,v 1.59 2002/03/04 23:56:38 massiot Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Benoit Steiner <benny@via.ecp.fr> * Benoit Steiner <benny@via.ecp.fr>
...@@ -35,10 +35,6 @@ ...@@ -35,10 +35,6 @@
#include <videolan/vlc.h> #include <videolan/vlc.h>
#ifdef STRNCASECMP_IN_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> /* gethostname() */ # include <unistd.h> /* gethostname() */
#elif defined( _MSC_VER ) && defined( _WIN32 ) #elif defined( _MSC_VER ) && defined( _WIN32 )
...@@ -81,6 +77,7 @@ ...@@ -81,6 +77,7 @@
#include "netutils.h" #include "netutils.h"
#include "intf_playlist.h" #include "intf_playlist.h"
#include "network.h"
/***************************************************************************** /*****************************************************************************
* input_channel_t: channel library data * input_channel_t: channel library data
...@@ -104,53 +101,6 @@ static int GetMacAddress ( int i_fd, char *psz_mac ); ...@@ -104,53 +101,6 @@ static int GetMacAddress ( int i_fd, char *psz_mac );
static int GetAdapterInfo ( int i_adapter, char *psz_string ); static int GetAdapterInfo ( int i_adapter, char *psz_string );
#endif #endif
/*****************************************************************************
* network_BuildAddr : fill a sockaddr_in structure
*****************************************************************************/
int network_BuildAddr( struct sockaddr_in * p_socket,
char * psz_address, int i_port )
{
#if 0
intf_ErrMsg( "error: networking is not yet supported under BeOS" );
return( 1 );
#else
/* Reset struct */
memset( p_socket, 0, sizeof( struct sockaddr_in ) );
p_socket->sin_family = AF_INET; /* family */
p_socket->sin_port = htons( i_port );
if( psz_address == NULL )
{
p_socket->sin_addr.s_addr = INADDR_ANY;
}
else
{
struct hostent * p_hostent;
/* Try to convert address directly from in_addr - this will work if
* psz_broadcast is dotted decimal. */
#ifdef HAVE_ARPA_INET_H
if( !inet_aton( psz_address, &p_socket->sin_addr) )
#else
if( (p_socket->sin_addr.s_addr = inet_addr( psz_address )) == -1 )
#endif
{
/* We have a fqdn, try to find its address */
if ( (p_hostent = gethostbyname( psz_address )) == NULL )
{
intf_ErrMsg( "BuildLocalAddr: unknown host %s", psz_address );
return( -1 );
}
/* Copy the first address of the host in the socket address */
memcpy( &p_socket->sin_addr, p_hostent->h_addr_list[0],
p_hostent->h_length );
}
}
return( 0 );
#endif
}
/***************************************************************************** /*****************************************************************************
* network_ChannelCreate: initialize global channel method data * network_ChannelCreate: initialize global channel method data
***************************************************************************** *****************************************************************************
...@@ -160,7 +110,10 @@ int network_BuildAddr( struct sockaddr_in * p_socket, ...@@ -160,7 +110,10 @@ int network_BuildAddr( struct sockaddr_in * p_socket,
*****************************************************************************/ *****************************************************************************/
int network_ChannelCreate( void ) int network_ChannelCreate( void )
{ {
#if defined( SYS_LINUX ) || defined( WIN32 ) #if !defined( SYS_LINUX ) && !defined( WIN32 )
intf_ErrMsg( "channel warning: VLAN-based channels are not supported"
" under this architecture" );
#endif
/* Allocate structure */ /* Allocate structure */
p_main->p_channel = malloc( sizeof( input_channel_t ) ); p_main->p_channel = malloc( sizeof( input_channel_t ) );
...@@ -176,12 +129,6 @@ int network_ChannelCreate( void ) ...@@ -176,12 +129,6 @@ int network_ChannelCreate( void )
intf_WarnMsg( 2, "network: channels initialized" ); intf_WarnMsg( 2, "network: channels initialized" );
return( 0 ); return( 0 );
#else
intf_ErrMsg( "network error : channels not supported on this platform" );
return( 1 );
#endif
} }
/***************************************************************************** /*****************************************************************************
...@@ -197,17 +144,16 @@ int network_ChannelCreate( void ) ...@@ -197,17 +144,16 @@ int network_ChannelCreate( void )
*****************************************************************************/ *****************************************************************************/
int network_ChannelJoin( int i_channel ) int network_ChannelJoin( int i_channel )
{ {
#if defined( SYS_LINUX ) || defined( WIN32 )
#define VLCS_VERSION 13 #define VLCS_VERSION 13
#define MESSAGE_LENGTH 256 #define MESSAGE_LENGTH 256
struct module_s * p_network;
char * psz_network = NULL;
network_socket_t socket_desc;
char psz_mess[ MESSAGE_LENGTH ]; char psz_mess[ MESSAGE_LENGTH ];
char psz_mac[ 40 ]; char psz_mac[ 40 ];
int i_fd, i_dummy, i_port; int i_fd, i_port;
char *psz_vlcs; char *psz_vlcs;
struct sockaddr_in sa_server;
struct sockaddr_in sa_client;
struct timeval delay; struct timeval delay;
fd_set fds; fd_set fds;
...@@ -223,26 +169,18 @@ int network_ChannelJoin( int i_channel ) ...@@ -223,26 +169,18 @@ int network_ChannelJoin( int i_channel )
{ {
intf_WarnMsg( 2, "network: waiting before changing channel" ); intf_WarnMsg( 2, "network: waiting before changing channel" );
/* XXX Isn't this completely brain-damaged ??? -- Sam */ /* XXX Isn't this completely brain-damaged ??? -- Sam */
/* Yes it is. I don't think this is still justified with the new
* vlanserver --Meuuh */
mwait( p_main->p_channel->last_change + INPUT_CHANNEL_CHANGE_DELAY ); mwait( p_main->p_channel->last_change + INPUT_CHANNEL_CHANGE_DELAY );
} }
/* Initializing the socket */ if( config_GetIntVariable( INPUT_IPV4_VAR ) )
i_fd = socket( AF_INET, SOCK_DGRAM, 0 );
if( i_fd < 0 )
{ {
intf_ErrMsg( "network error: unable to create vlcs socket (%s)", psz_network = "ipv4";
strerror( errno ) );
return -1;
} }
if( config_GetIntVariable( INPUT_IPV6_VAR ) )
i_dummy = 1;
if( setsockopt( i_fd, SOL_SOCKET, SO_REUSEADDR,
(void *) &i_dummy, sizeof( i_dummy ) ) == -1 )
{ {
intf_ErrMsg( "network error: can't SO_REUSEADDR vlcs socket (%s)", psz_network = "ipv6";
strerror(errno));
close( i_fd );
return -1;
} }
/* Getting information about the channel server */ /* Getting information about the channel server */
...@@ -255,31 +193,27 @@ int network_ChannelJoin( int i_channel ) ...@@ -255,31 +193,27 @@ int network_ChannelJoin( int i_channel )
i_port = config_GetIntVariable( INPUT_CHANNEL_PORT_VAR ); i_port = config_GetIntVariable( INPUT_CHANNEL_PORT_VAR );
intf_WarnMsg( 5, "network: socket %i, vlcs '%s', port %d", intf_WarnMsg( 5, "channel: connecting to %s:%d",
i_fd, psz_vlcs, i_port ); psz_vlcs, i_port );
memset( &sa_client, 0x00, sizeof(struct sockaddr_in) ); /* Prepare the network_socket_t structure */
memset( &sa_server, 0x00, sizeof(struct sockaddr_in) ); socket_desc.i_type = NETWORK_UDP;
sa_client.sin_family = AF_INET; socket_desc.psz_bind_addr = NULL;
sa_server.sin_family = AF_INET; socket_desc.i_bind_port = 4321;
sa_client.sin_port = htons( 4312 ); socket_desc.psz_server_addr = psz_vlcs;
sa_server.sin_port = htons( i_port ); socket_desc.i_server_port = i_port;
sa_client.sin_addr.s_addr = INADDR_ANY;
#ifdef HAVE_ARPA_INET_H
inet_aton( psz_vlcs, &sa_server.sin_addr );
#else
sa_server.sin_addr.s_addr = inet_addr( psz_vlcs );
#endif
free( psz_vlcs );
/* Bind the socket */ /* Find an appropriate network module */
if( bind( i_fd, (struct sockaddr*)(&sa_client), sizeof(sa_client) ) ) p_network = module_Need( MODULE_CAPABILITY_NETWORK, psz_network,
&socket_desc );
if( p_network == NULL )
{ {
intf_ErrMsg( "network: unable to bind vlcs socket (%s)", return( -1 );
strerror( errno ) );
close( i_fd );
return -1;
} }
module_Unneed( p_network );
free( psz_vlcs ); /* Do we really need this ? -- Meuuh */
i_fd = socket_desc.i_handle;
/* Look for the interface MAC address */ /* Look for the interface MAC address */
if( GetMacAddress( i_fd, psz_mac ) ) if( GetMacAddress( i_fd, psz_mac ) )
...@@ -297,8 +231,7 @@ int network_ChannelJoin( int i_channel ) ...@@ -297,8 +231,7 @@ int network_ChannelJoin( int i_channel )
psz_mac ); psz_mac );
/* Send the message */ /* Send the message */
sendto( i_fd, psz_mess, MESSAGE_LENGTH, 0, send( i_fd, psz_mess, MESSAGE_LENGTH, 0 );
(struct sockaddr *)(&sa_server), sizeof(struct sockaddr) );
intf_WarnMsg( 2, "network: attempting to join channel %d", i_channel ); intf_WarnMsg( 2, "network: attempting to join channel %d", i_channel );
...@@ -327,10 +260,8 @@ int network_ChannelJoin( int i_channel ) ...@@ -327,10 +260,8 @@ int network_ChannelJoin( int i_channel )
break; break;
} }
i_dummy = sizeof( struct sockaddr ); recv( i_fd, psz_mess, MESSAGE_LENGTH, 0 );
recvfrom( i_fd, psz_mess, MESSAGE_LENGTH, 0, psz_mess[ MESSAGE_LENGTH - 1 ] = '\0';
(struct sockaddr *)(&sa_client), &i_dummy);
psz_mess[ MESSAGE_LENGTH - 1 ] = 0;
if( !strncasecmp( psz_mess, "E: ", 3 ) ) if( !strncasecmp( psz_mess, "E: ", 3 ) )
{ {
...@@ -366,12 +297,6 @@ int network_ChannelJoin( int i_channel ) ...@@ -366,12 +297,6 @@ int network_ChannelJoin( int i_channel )
close( i_fd ); close( i_fd );
return 0; return 0;
#else
intf_ErrMsg( "network error: channels not supported on this platform" );
return -1;
#endif
} }
/* Following functions are local */ /* Following functions are local */
...@@ -444,7 +369,8 @@ static int GetMacAddress( int i_fd, char *psz_mac ) ...@@ -444,7 +369,8 @@ static int GetMacAddress( int i_fd, char *psz_mac )
return( i_ret ); return( i_ret );
#else #else
return( -1); strcpy( psz_mac, "00:00:00:00:00:00" );
return( 0 );
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment