Commit 92c69994 authored by Vincent Seguin's avatar Vincent Seguin

Changement de chaine. Delicat encore, mais il marche. Quelques corrections

esthetiques, un timeout pour les vlans et le frame buffer et c'est la
release d�mo (en ce qui me concerne) !
parent 07686534
......@@ -47,11 +47,11 @@ typedef struct intf_msg_s * p_intf_msg_t;
/* Input */
struct input_thread_s;
struct input_vlan_method_s;
struct input_vlan_s;
struct input_cfg_s;
typedef struct input_thread_s * p_input_thread_t;
typedef struct input_vlan_method_s * p_input_vlan_method_t;
typedef struct input_vlan_s * p_input_vlan_t;
typedef struct input_cfg_s * p_input_cfg_t;
/* Audio */
......
......@@ -181,18 +181,18 @@
/* Use a LIFO or FIFO for PES netlist ? */
#undef INPUT_LIFO_PES_NETLIST
/* Maximum length of a hostname */
#define INPUT_MAX_HOSTNAME_LENGTH 100
/* Maximum length of a hostname or source name */
#define INPUT_MAX_SOURCE_LENGTH 100
/* Default input method */
#define INPUT_DEFAULT_METHOD INPUT_METHOD_TS_UCAST
/* Default remote server */
#define VIDEOLAN_DEFAULT_SERVER "vod.via.ecp.fr"
#define INPUT_DEFAULT_SERVER "138.195.143.220"
/* Default videolan port */
#define VIDEOLAN_DEFAULT_PORT 1234
/* Default input port */
#define INPUT_DEFAULT_PORT 1234
/* Default videolan VLAN */
#define VIDEOLAN_DEFAULT_VLAN 3
......@@ -201,9 +201,15 @@
* Vlan method
*/
/* Default VLAN server */
#define VLAN_DEFAULT_SERVER "vlanserver.via.ecp.fr"
#define VLAN_DEFAULT_SERVER_PORT 6010
/* Default network interface and environment variable */
#define INPUT_IFACE_VAR "vlc_iface"
#define INPUT_IFACE_DEFAULT "eth0"
/* Default server and port */
#define INPUT_VLAN_SERVER_VAR "vlc_vlan_server"
#define INPUT_VLAN_SERVER_DEFAULT "138.195.140.31"
#define INPUT_VLAN_PORT_VAR "vlc_vlan_port"
#define INPUT_VLAN_PORT_DEFAULT 6010
/*******************************************************************************
* Audio configuration
......
......@@ -3,21 +3,6 @@
* (c)1999 VideoLAN
******************************************************************************/
/* needs : "netlist.h", "config.h", "mtime.h" */
/* ?? missing:
* tables version control */
/******************************************************************************
* External structures
******************************************************************************
* These structures, required here only as pointers destinations, are declared
* in other headers.
******************************************************************************/
struct video_cfg_s; /* video configuration descriptor */
struct vout_thread_s; /* video output thread */
struct stream_descriptor_s; /* PSI tables */
/******************************************************************************
* Constants related to input
******************************************************************************/
......@@ -30,7 +15,7 @@ struct stream_descriptor_s; /* PSI tables */
******************************************************************************
* Describe a TS packet.
******************************************************************************/
typedef struct ts_packet_struct
typedef struct ts_packet_s
{
/* Nothing before this line, the code relies on that */
byte_t buffer[TS_PACKET_SIZE]; /* raw TS data packet */
......@@ -41,18 +26,17 @@ typedef struct ts_packet_struct
unsigned int i_payload_end; /* guess ? :-) */
/* Used to chain the TS packets that carry data for a same PES or PSI */
struct ts_packet_struct * p_prev_ts;
struct ts_packet_struct * p_next_ts;
struct ts_packet_s * p_prev_ts;
struct ts_packet_s * p_next_ts;
} ts_packet_t;
/******************************************************************************
* pes_packet_t
******************************************************************************
* Describes an PES packet, with its properties, and pointers to the TS packets
* containing it.
******************************************************************************/
typedef struct
typedef struct pes_packet_s
{
/* PES properties */
boolean_t b_data_loss; /* The previous (at least) PES packet
......@@ -82,14 +66,13 @@ typedef struct
* (used by the demultiplexer). */
} pes_packet_t;
/******************************************************************************
* psi_section_t
******************************************************************************
* Describes a PSI section. Beware, it doesn't contain pointers to the TS
* packets that contain it as for a PES, but the data themselves
******************************************************************************/
typedef struct
typedef struct psi_section_s
{
byte_t buffer[PSI_SECTION_SIZE];
......@@ -106,7 +89,7 @@ typedef struct
* Describes an elementary stream, and includes fields required to handle and
* demultiplex this elementary stream.
******************************************************************************/
typedef struct
typedef struct es_descriptor_t
{
u16 i_id; /* stream ID, PID for TS streams */
u8 i_type; /* stream type */
......@@ -293,6 +276,8 @@ typedef struct
#endif
} input_netlist_t;
/******************************************************************************
* input_thread_t
******************************************************************************
......@@ -302,14 +287,13 @@ typedef struct
* update all reference to it each time the table would be reallocated
******************************************************************************/
/* function pointers */
struct input_thread_s;
struct input_cfg_s;
typedef int (*f_open_t)( struct input_thread_s *, struct input_cfg_s *);
typedef int (*f_read_t)( struct input_thread_s *, const struct iovec *,
size_t );
typedef void (*f_clean_t)( struct input_thread_s * );
/* Function pointers used in structure */
typedef int (input_open_t) ( p_input_thread_t p_input );
typedef int (input_read_t) ( p_input_thread_t p_input, const struct iovec *p_vector,
size_t i_count );
typedef void (input_close_t) ( p_input_thread_t p_input );
/* Structure */
typedef struct input_thread_s
{
/* Thread properties and locks */
......@@ -318,14 +302,17 @@ typedef struct input_thread_s
vlc_thread_t thread_id; /* id for thread functions */
vlc_mutex_t programs_lock; /* programs modification lock */
vlc_mutex_t es_lock; /* es modification lock */
int * pi_status; /* temporary status flag */
/* Input method description */
int i_method; /* input method */
int i_handle; /* file/socket descriptor */
int i_vlan_id; /* id for vlan method */
f_open_t p_open; /* pointer to the opener of the method */
f_read_t p_read; /* pointer to the reading function */
f_clean_t p_clean; /* pointer to the destroying function */
char * psz_source; /* source */
int i_port; /* port number */
int i_vlan; /* id for vlan method */
input_open_t * p_Open; /* opener of the method */
input_read_t * p_Read; /* reading function */
input_close_t * p_Close; /* destroying function */
/* General stream description */
stream_descriptor_t * p_stream; /* PAT tables */
......@@ -338,17 +325,17 @@ typedef struct input_thread_s
/* Netlists */
input_netlist_t netlist; /* see above */
/* ?? default settings for new decoders */
struct aout_thread_s * p_aout; /* audio output thread structure */
/* Default settings for spawned decoders */
p_aout_thread_t p_aout; /* audio output thread structure */
p_vout_thread_t p_vout; /* video output thread */
#ifdef STATS
/* Stats */
/* Statistics */
count_t c_loops; /* number of loops */
count_t c_bytes; /* total of bytes read */
count_t c_payload_bytes; /* total of payload useful bytes */
count_t c_ts_packets_read; /* total of packets read */
count_t c_ts_packets_trashed; /* total of trashed packets */
/* ?? ... other stats */
count_t c_bytes; /* bytes read */
count_t c_payload_bytes; /* payload useful bytes */
count_t c_packets_read; /* packets read */
count_t c_packets_trashed; /* trashed packets */
#endif
} input_thread_t;
......@@ -360,52 +347,16 @@ typedef struct input_thread_s
#define INPUT_METHOD_TS_BCAST 22 /* TS UDP broadcast */
#define INPUT_METHOD_TS_VLAN_BCAST 32 /* TS UDP broadcast with VLANs */
/******************************************************************************
* input_cfg_t: input thread configuration structure
******************************************************************************
* This structure is passed as a parameter to input_CreateTtread(). It includes
* several fields describing potential properties of a new object.
* The 'i_properties' field allow to set only a subset of the required
* properties, asking the called function to use default settings for
* the other ones.
******************************************************************************/
typedef struct input_cfg_s
{
u64 i_properties;
/* Input method properties */
int i_method; /* input method */
char * psz_filename; /* filename */
char * psz_hostname; /* server hostname */
char * psz_ip; /* server IP */
int i_port; /* port */
int i_vlan; /* vlan number */
/* ??... default settings for new decoders */
struct aout_thread_s * p_aout; /* audio output thread structure */
} input_cfg_t;
/* Properties flags */
#define INPUT_CFG_METHOD (1 << 0)
#define INPUT_CFG_FILENAME (1 << 4)
#define INPUT_CFG_HOSTNAME (1 << 8)
#define INPUT_CFG_IP (1 << 9)
#define INPUT_CFG_PORT (1 << 10)
#define INPUT_CFG_VLAN (1 << 11)
/*****************************************************************************
* Prototypes
*****************************************************************************/
input_thread_t *input_CreateThread ( input_cfg_t *p_cfg );
void input_DestroyThread ( input_thread_t *p_input );
input_thread_t *input_CreateThread ( int i_method, char *psz_source, int i_port,
int i_vlan, p_vout_thread_t p_vout,
p_aout_thread_t p_aout, int *pi_status );
void input_DestroyThread ( input_thread_t *p_input, int *pi_status );
int input_OpenAudioStream ( input_thread_t *p_input, int i_pid
/* ?? , struct audio_cfg_s * p_cfg */ );
int input_OpenAudioStream ( input_thread_t *p_input, int i_pid );
void input_CloseAudioStream ( input_thread_t *p_input, int i_pid );
int input_OpenVideoStream ( input_thread_t *p_input,
struct vout_thread_s *p_vout, struct video_cfg_s * p_cfg );
int input_OpenVideoStream ( input_thread_t *p_input, int i_pid );
void input_CloseVideoStream ( input_thread_t *p_input, int i_pid );
/* ?? settings functions */
/* ?? info functions */
/*******************************************************************************
* file.h: file streams functions interface
* input_file.h: file streams functions interface
* (c)1999 VideoLAN
*******************************************************************************/
/******************************************************************************
* Prototypes
******************************************************************************/
int input_FileCreateMethod( input_thread_t *p_input ,
input_cfg_t *p_cfg );
int input_FileRead( input_thread_t *p_input, const struct iovec *p_vector,
int input_FileOpen ( input_thread_t *p_input );
int input_FileRead ( input_thread_t *p_input, const struct iovec *p_vector,
size_t i_count );
void input_FileDestroyMethod( input_thread_t *p_input );
void input_FileClose ( input_thread_t *p_input );
......@@ -10,17 +10,14 @@
/******************************************************************************
* Prototypes
******************************************************************************/
int input_NetlistOpen( input_thread_t *p_input );
void input_NetlistClean( input_thread_t *p_input );
/* ?? implement also a "normal" (non inline, non static) function in input_netlist.c,
which will be used when inline is disabled */
/* ?? test */ static __inline__ void input_NetlistFreePES( input_thread_t *p_input,
pes_packet_t *p_pes_packet );
static __inline__ void input_NetlistFreeTS( input_thread_t *p_input,
ts_packet_t *p_ts_packet );
int input_NetlistInit ( input_thread_t *p_input );
void input_NetlistEnd ( input_thread_t *p_input );
static __inline__ void input_NetlistFreePES( input_thread_t *p_input, pes_packet_t *p_pes_packet );
static __inline__ void input_NetlistFreeTS( input_thread_t *p_input, ts_packet_t *p_ts_packet );
static __inline__ pes_packet_t* input_NetlistGetPES( input_thread_t *p_input );
/*******************************************************************************
/******************************************************************************
* input_NetlistFreePES: add a PES packet to the netlist
*******************************************************************************
* Add a PES packet to the PES netlist, so that the packet can immediately be
......
/*******************************************************************************
* network.h: network functions interface
* input_network.h: network functions interface
* (c)1999 VideoLAN
*******************************************************************************/
/*
needs :
- <sys/uio.h>
- <sys/socket.h>
- <unistd.h>
- <netinet/in.h>
- <netdb.h>
- <arpa/inet.h>
- <stdio.h>
- <sys/ioctl.h>
- <net/if.h>
*/
/******************************************************************************
* Prototypes
******************************************************************************/
int input_NetworkCreateMethod( input_thread_t *p_input,
input_cfg_t *p_cfg );
int input_NetworkRead( input_thread_t *p_input, const struct iovec *p_vector,
int input_NetworkOpen ( input_thread_t *p_input );
int input_NetworkRead ( input_thread_t *p_input, const struct iovec *p_vector,
size_t i_count );
void input_NetworkDestroyMethod( input_thread_t *p_input );
void input_NetworkClose ( input_thread_t *p_input );
......@@ -23,4 +23,4 @@
int input_PcrInit ( input_thread_t *p_input );
void input_PcrDecode ( input_thread_t *p_input, es_descriptor_t* p_es,
u8* p_pcr_data );
void input_PcrClean ( input_thread_t *p_input );
void input_PcrEnd ( input_thread_t *p_input );
/*******************************************************************************
* psi.h: PSI management interface
* (c)1999 VideoLAN
*******************************************************************************
* Requires:
* "config.h"
* "common.h"
* "mtime.h"
******************************************************************************/
/******************************************************************************
* Prototypes
******************************************************************************/
int input_PsiInit( input_thread_t *p_input );
void input_PsiDecode( input_thread_t *p_input, psi_section_t* p_psi_section );
void input_PsiRead( input_thread_t *p_input /* ??? */ );
int input_PsiClean( input_thread_t *p_input );
int input_PsiInit ( input_thread_t *p_input );
void input_PsiDecode ( input_thread_t *p_input, psi_section_t* p_psi_section );
void input_PsiRead ( input_thread_t *p_input );
int input_PsiEnd ( input_thread_t *p_input );
......@@ -9,46 +9,13 @@
* "vlc_thread.h"
*******************************************************************************/
/*******************************************************************************
* Vlan server related constants
*******************************************************************************/
#define VLAN_SERVER_MSG_LENGTH 256 /* maximum length of a message */
#define VLAN_CLIENT_VERSION "1.3.0" /* vlan client version */
/* Messages codes */
#define VLAN_LOGIN_REQUEST 98 /* login: <version> <login> <passwd> */
#define VLAN_LOGIN_ANSWER 97 /* login accepted: [msg] */
#define VLAN_LOGIN_REJECTED 96 /* login rejected: [msg] */
#define VLAN_LOGOUT 99 /* logout */
#define VLAN_INFO_REQUEST 31 /* info: no argument */
#define VLAN_INFO_ANSWER 32/* info ok: <switch> <port> <vlan> <sharers> */
#define VLAN_INFO_REJECTED 33 /* info rejected: [msg] */
#define VLAN_CHANGE_REQUEST 21/* change: <mac> [ip] <vlan dest> [vlan src] */
#define VLAN_CHANGE_ANSWER 22 /* change ok: [msg] */
#define VLAN_CHANGE_REJECTED 23 /* change failed: [msg] */
/*******************************************************************************
* Macros to build/extract vlan_ids
*******************************************************************************/
#define VLAN_ID_IFACE( vlan_id ) ( ((vlan_id) >> 8) & 0xff )
#define VLAN_ID_VLAN( vlan_id ) ( (vlan_id) & 0xff )
#define VLAN_ID( iface, vlan ) ( ((iface) << 8) | (vlan) )
/*******************************************************************************
* Prototypes
*******************************************************************************/
int input_VlanCreate ( void );
void input_VlanDestroy ( void );
int input_VlanId ( char *psz_iface, int i_vlan );
int input_VlanJoin ( int i_vlan_id );
void input_VlanLeave ( int i_vlan_id );
int input_VlanRequest ( char *psz_iface );
int input_VlanSynchronize ( void );
......@@ -34,7 +34,7 @@ typedef struct
/* Shared data - these structures are accessed directly from p_main by
* several modules */
p_intf_msg_t p_msg; /* messages interface data */
p_input_vlan_method_t p_input_vlan; /* vlan input method */
p_input_vlan_t p_vlan; /* vlan library data */
} main_t;
extern main_t *p_main;
......
......@@ -22,13 +22,12 @@
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/shm.h>
#include <sys/soundcard.h>
......@@ -70,6 +69,7 @@
/* Video */
#include "video.h"
#include "video_output.h"
#include "vdec_idct.h"
#ifdef OLD_DECODER
#include "video_decoder.h"
......@@ -87,10 +87,14 @@
/* Interface */
#include "intf_cmd.h"
#include "intf_ctrl.h"
#ifndef OLD_DECODER
#include "intf_sys.h"
#include "intf_console.h"
#endif
#include "interface.h"
#include "main.h"
......@@ -52,9 +52,10 @@
/******************************************************************************
* Local prototypes
******************************************************************************/
static void input_Thread( input_thread_t *p_input );
static void ErrorThread( input_thread_t *p_input );
static void EndThread( input_thread_t *p_input );
static void RunThread ( input_thread_t *p_input );
static void ErrorThread ( input_thread_t *p_input );
static void EndThread ( input_thread_t *p_input );
static __inline__ int input_ReadPacket( input_thread_t *p_input );
static __inline__ void input_SortPacket( input_thread_t *p_input,
ts_packet_t *ts_packet );
......@@ -71,160 +72,154 @@ static __inline__ void input_DemuxPSI( input_thread_t *p_input,
boolean_t b_unit_start, boolean_t b_packet_lost );
/*******************************************************************************
* input_CreateThread: initialize and spawn an input thread
* input_CreateThread: creates a new input thread
*******************************************************************************
* This function initializes and spawns an input thread. It returns NULL on
* failure. If you want a better understanding of the input thread, don't start
* by reading this function :-).
* This function creates a new input, and returns a pointer
* to its description. On error, it returns NULL.
* If pi_status is NULL, then the function will block until the thread is ready.
* If not, it will be updated using one of the THREAD_* constants.
*******************************************************************************/
input_thread_t *input_CreateThread( input_cfg_t *p_cfg )
input_thread_t *input_CreateThread ( int i_method, char *psz_source, int i_port, int i_vlan,
p_vout_thread_t p_vout, p_aout_thread_t p_aout, int *pi_status )
{
input_thread_t * p_input;
int i_index;
intf_DbgMsg("input debug 1-1: creating thread (cfg : %p)\n", p_cfg );
input_thread_t * p_input; /* thread descriptor */
int i_status; /* thread status */
int i_index; /* index for tables initialization */
/* Allocate input_thread_t structure. */
if( !( p_input = (input_thread_t *)malloc(sizeof(input_thread_t)) ) )
/* Allocate descriptor */
intf_DbgMsg("\n");
p_input = (input_thread_t *)malloc( sizeof(input_thread_t) );
if( p_input == NULL )
{
intf_ErrMsg("input error: can't allocate input thread structure (%s)\n",
strerror(errno));
intf_ErrMsg("error: %s\n", strerror(ENOMEM));
return( NULL );
}
/* Init it */
bzero( p_input, sizeof(input_thread_t));
for( i_index = 0; i_index < INPUT_MAX_ES; i_index++ )
{
p_input->p_es[i_index].i_id = EMPTY_PID;
}
/* Find out which method we are gonna use and retrieve pointers. */
if( !((p_cfg->i_properties) & INPUT_CFG_METHOD) )
/* Initialize thread properties */
p_input->b_die = 0;
p_input->b_error = 0;
p_input->pi_status = (pi_status != NULL) ? pi_status : &i_status;
*p_input->pi_status = THREAD_CREATE;
/* Initialize input method description */
p_input->i_method = i_method;
p_input->psz_source = psz_source;
p_input->i_port = i_port;
p_input->i_vlan = i_vlan;
switch( i_method )
{
case INPUT_METHOD_TS_FILE: /* file methods */
p_input->p_Open = input_FileOpen;
p_input->p_Read = input_FileRead;
p_input->p_Close = input_FileClose;
break;
case INPUT_METHOD_TS_VLAN_BCAST: /* vlan network method */
if( !p_main->b_vlans )
{
/* i_method is not set. */
intf_DbgMsg("input debug: using default method (%d)\n",
INPUT_DEFAULT_METHOD);
p_cfg->i_method = INPUT_DEFAULT_METHOD;
p_cfg->i_properties |= INPUT_CFG_METHOD;
intf_ErrMsg("error: vlans are not activated\n");
free( p_input );
return( NULL );
}
p_input->i_method = p_cfg->i_method;
switch( p_cfg->i_method )
{
/* File methods */
case INPUT_METHOD_TS_FILE:
#ifdef OLD_DECODER
p_input->p_open = &input_FileCreateMethod;
p_input->p_read = &input_FileRead;
p_input->p_clean = &input_FileDestroyMethod;
#else
p_input->p_open = input_FileCreateMethod;
p_input->p_read = input_FileRead;
p_input->p_clean = input_FileDestroyMethod;
#endif
break;
/* Network methods */
case INPUT_METHOD_TS_UCAST:
/* ... pass through */
case INPUT_METHOD_TS_UCAST: /* network methods */
case INPUT_METHOD_TS_MCAST:
case INPUT_METHOD_TS_BCAST:
case INPUT_METHOD_TS_VLAN_BCAST:
#ifdef OLD_DECODER
p_input->p_open = &input_NetworkCreateMethod;
p_input->p_read = &input_NetworkRead;
p_input->p_clean = &input_NetworkDestroyMethod;
#else
p_input->p_open = input_NetworkCreateMethod;
p_input->p_read = input_NetworkRead;
p_input->p_clean = input_NetworkDestroyMethod;
#endif
p_input->p_Open = input_NetworkOpen;
p_input->p_Read = input_NetworkRead;
p_input->p_Close = input_NetworkClose;
break;
case INPUT_METHOD_NONE:
default:
#ifdef DEBUG
/* Internal error, which should never happen */
intf_DbgMsg("input debug: unknow method type %d\n",
p_cfg->i_method);
intf_ErrMsg("error: unknow input method\n");
free( p_input );
return( NULL );
#endif
break;
}
/* Initialize PSI decoder. */
intf_DbgMsg("Initializing PSI decoder\n");
if( input_PsiInit( p_input ) == -1 )
/* Initialize stream description */
for( i_index = 0; i_index < INPUT_MAX_ES; i_index++ )
{
p_input->p_es[i_index].i_id = EMPTY_PID;
}
/* Initialize default settings for spawned decoders */
p_input->p_aout = p_aout;
p_input->p_vout = p_vout;
#ifdef STATS
/* Initialize statistics */
p_input->c_loops = 0;
p_input->c_bytes = 0;
p_input->c_payload_bytes = 0;
p_input->c_packets_read = 0;
p_input->c_packets_trashed = 0;
#endif
/* Initialize PSI and PCR decoders */
if( input_PsiInit( p_input ) )
{
free( p_input );
return( NULL );
}
/* Initialize PCR decoder. */
intf_DbgMsg("Initializing PCR decoder\n");
if( input_PcrInit( p_input ) == -1 )
if( input_PcrInit( p_input ) )
{
input_PsiClean( p_input );
input_PsiEnd( p_input );
free( p_input );
return( NULL );
}
/* Initialize netlists. */
if( input_NetlistOpen( p_input ) )