Commit 1a1ae383 authored by Vincent Seguin's avatar Vincent Seguin

A tout kass�.

parent 7929ae1b
......@@ -9,32 +9,71 @@
# Configuration
################################################################################
# Environment
#CC = gcc
#SHELL = /bin/sh
# Video output settings
VIDEO=X11
#VIDEO=DGA
#VIDEO=FB
#VIDEO=BEOS
# Target architecture and optimization
#ARCH=
ARCH=MMX
#ARCH=PPC
#----------------- do not change anything below this line ----------------------
################################################################################
# Configuration pre-processing
################################################################################
# DEFINE will contain all the constants definitions decided in Makefile
DEFINE = -DVIDEO_$(VIDEO)
# video is a lowercase version of VIDEO used for filenames
video = $(shell echo $(VIDEO) | tr 'A-Z' 'a-z')
################################################################################
# Settings and other variables
# Tunning and other variables
################################################################################
#
# Transformation for video decompression (Fourier or cosine)
#
TRANSFORM=vdec_idct
#TRANSFORM=vdec_idft
#
# C headers directories
#
INCLUDE += -Iinclude
ifeq ($(VIDEO),X11)
INCLUDE += -I/usr/X11R6/include/X11
endif
#
# Libraries
#
LIB += -lpthread
ifeq ($(VIDEO),X11)
LIB += -L/usr/X11R6/lib
LIB += -lX11
LIB += -lXext
LIB += -lpthread
LIB += -lXpm
endif
# System dependant libraries
#??LIB += -lXxf86dga
#
# C compiler flags: compilation
#
CCFLAGS += $(INCLUDE)
CCFLAGS += $(DEFINE) $(INCLUDE)
CCFLAGS += -Wall
CCFLAGS += -D_REENTRANT
CCFLAGS += -D_GNU_SOURCE
......@@ -44,21 +83,24 @@ CCFLAGS += -O6
CCFLAGS += -ffast-math -funroll-loops -fargument-noalias-global
CCFLAGS += -fomit-frame-pointer
#CCFLAGS += -fomit-frame-pointer -s
#LCFLAGS += -s
# Platform-specific optimizations
# Optimizations for x86 familiy :
# Optimizations for x86 familiy, without MMX
ifeq ($(ARCH),)
CCFLAGS += -malign-double
CCFLAGS += -march=pentiumpro
#CCFLAGS += -march=pentium
endif
# MMX support :
CFLAGS += -DHAVE_MMX
ASM_OBJ = video_decoder_ref/idctmmx.o \
video_decoder_ref/yuv12-rgb16.o
# Optimization for x86 with MMX support
ifeq ($(ARCH),MMX)
CCFLAGS += -malign-double
CCFLAGS += -march=pentiumpro
endif
#Optimizations for PowerPC :
#CCFLAGS += -mcpu=604e -mmultiple -mhard-float -mstring
# Optimizations for PowerPC
ifeq ($(ARCH),PPC)
CCFLAGS += -mcpu=604e -mmultiple -mhard-float -mstring
endif
#
# C compiler flags: dependancies
......@@ -71,31 +113,16 @@ DCFLAGS += -MM
#
LCFLAGS += $(LIB)
LCFLAGS += -Wall
#
# C compiler flags: functions flow
#
FCFLAGS += $(INCLUDE)
FCFLAGS += -A
FCFLAGS += -P
FCFLAGS += -v
FCFLAGS += -a
FCFLAGS += -X errno.h
FCFLAGS += -X fcntl.h
FCFLAGS += -X signal.h
FCFLAGS += -X stdio.h
FCFLAGS += -X stdlib.h
FCFLAGS += -X string.h
FCFLAGS += -X unistd.h
FCFLAGS += -X sys/ioctl.h
FCFLAGS += -X sys/stat.h
FCFLAGS += -X X11/Xlib.h
FFILTER = grep -v "intf_.*Msg.*\.\.\."
#LCFLAGS += -s
#
# C compiler flags: common flags
#
# CFLAGS
# Optimizations for x86 with MMX support
ifeq ($(ARCH),MMX)
CFLAGS += -DHAVE_MMX
endif
#
# Additionnal debugging flags
......@@ -104,7 +131,7 @@ FFILTER = grep -v "intf_.*Msg.*\.\.\."
# Note that electric fence and accurate profiling are quite uncompatible.
#CCFLAGS += -g
#CCFLAGS += -pg
#LCFLAGS += -g
#LCFLAGS += -g
#LCFLAGS += -pg
#LIB += -ldmalloc
#LIB += -lefence
......@@ -122,7 +149,8 @@ interface_obj = interface/main.o \
interface/intf_cmd.o \
interface/intf_ctrl.o \
interface/control.o \
interface/xconsole.o
interface/intf_console.o \
interface/intf_$(video).o
input_obj = input/input_vlan.o \
input/input_file.o \
......@@ -136,14 +164,14 @@ input_obj = input/input_vlan.o \
audio_output_obj = audio_output/audio_output.o \
audio_output/audio_dsp.o
#video_output_obj = video_output/video_output.o \
# video_output/video_x11.o \
# video_output/video_graphics.o
video_output_obj = video_output/video_output.o \
video_output/video_$(video).o
audio_decoder_obj = audio_decoder/audio_decoder.o \
audio_decoder/audio_math.o
#generic_decoder_obj = generic_decoder/generic_decoder.o
#??generic_decoder_obj = generic_decoder/generic_decoder.o
# remeber to add it to OBJ
video_decoder_obj = video_decoder_ref/video_decoder.o \
video_decoder_ref/display.o \
......@@ -155,7 +183,8 @@ video_decoder_obj = video_decoder_ref/video_decoder.o \
video_decoder_ref/motion.o \
video_decoder_ref/mpeg2dec.o \
video_decoder_ref/recon.o \
video_decoder_ref/spatscal.o
video_decoder_ref/spatscal.o
# video_decoder_ref/$(TRANSFORM).o
#video_parser_obj = video_parser/video_parser.o \
# video_parser/vpar_headers.o \
......@@ -173,6 +202,12 @@ misc_obj = misc/mtime.o \
misc/rsc_files.o \
misc/netutils.o
ifeq ($(ARCH),MMX)
ASM_OBJ = video_decoder_ref/idctmmx.o \
video_decoder_ref/yuv12-rgb16.o
endif
C_OBJ = $(interface_obj) \
$(input_obj) \
$(audio_output_obj) \
......@@ -182,7 +217,7 @@ C_OBJ = $(interface_obj) \
$(video_parser_obj) \
$(video_decoder_obj) \
$(vlan_obj) \
$(misc_obj) \
$(misc_obj)
#
# Other lists of files
......@@ -207,7 +242,7 @@ clean:
distclean: clean
rm -f **/*.o **/*~ *.log
rm -f vlc gmon.out core Documentation/cflow
rm -f vlc gmon.out core
rm -rf dep
FORCE:
......@@ -218,9 +253,6 @@ FORCE:
vlc: $(C_OBJ) $(ASM_OBJ)
$(CC) $(LCFLAGS) $(CFLAGS) -o $@ $(C_OBJ) $(ASM_OBJ)
Documentation/cflow: $(sources)
cflow $(FCFLAGS) $(CFLAGS) $(sources) | $(FFILTER) > $@
#
# Generic rules (see below)
#
......@@ -232,7 +264,7 @@ $(C_OBJ): %.o: dep/%.d
$(C_OBJ): %.o: %.c
$(CC) $(CCFLAGS) $(CFLAGS) -c -o $@ $<
$(ASM_OBJ): %.o: %.S
$(CC) -c -o $@ $<
$(CC) $(CFLAGS) -c -o $@ $<
################################################################################
# Note on generic rules and dependancies
......
......@@ -200,10 +200,9 @@ typedef struct aout_thread_s
/******************************************************************************
* Prototypes
******************************************************************************/
int aout_Open ( aout_thread_t *p_aout );
int aout_SpawnThread ( aout_thread_t *p_aout );
void aout_CancelThread ( aout_thread_t *p_aout );
void aout_Close ( aout_thread_t *p_aout );
aout_thread_t * aout_CreateThread ( int *pi_status );
void aout_DestroyThread ( aout_thread_t *p_aout, int *pi_status );
aout_fifo_t * aout_CreateFifo ( aout_thread_t *p_aout, aout_fifo_t *p_fifo );
void aout_DestroyFifo ( aout_fifo_t *p_fifo );
......@@ -9,7 +9,7 @@
*******************************************************************************/
/*******************************************************************************
* Types definitions
* Basic types definitions
*******************************************************************************/
/* Basic types definitions */
......@@ -30,6 +30,48 @@ typedef int boolean_t;
/* Counter for statistics and profiling */
typedef unsigned long count_t;
/*******************************************************************************
* Classes declaration
*******************************************************************************/
/* Interface */
struct intf_thread_s;
struct intf_sys_s;
struct intf_console_s;
struct intf_msg_s;
typedef struct intf_thread_s * p_intf_thread_t;
typedef struct intf_sys_s * p_intf_sys_t;
typedef struct intf_console_s * p_intf_console_t;
typedef struct intf_msg_s * p_intf_msg_t;
/* Input */
struct input_thread_s;
struct input_vlan_method_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_cfg_s * p_input_cfg_t;
/* Audio */
struct aout_thread_s;
typedef struct aout_thread_s * p_aout_thread_t;
/* Video */
struct vout_thread_s;
struct vout_sys_s;
struct vdec_thread_s;
struct vpar_thread_s;
struct video_parser_s;
typedef struct vout_thread_s * p_vout_thread_t;
typedef struct vout_sys_s * p_vout_sys_t;
typedef struct vdec_thread_s * p_vdec_thread_t;
typedef struct vpar_thread_s * p_vpar_thread_t;
typedef struct video_parser_s * p_video_parser_t;
/*******************************************************************************
* Macros and inline functions
*******************************************************************************/
......
......@@ -3,17 +3,29 @@
* (c)1999 VideoLAN
*******************************************************************************
* Defines all compilation-time configuration constants and size limits
*******************************************************************************
* required headers:
* none
*******************************************************************************/
/* Conventions regarding names of symbols and variables
* ----------------------------------------------------
*
* - Symbols should begin with a prefix indicating in which module they are
* used, such as INTF_, VOUT_ or ADEC_.
*
* - Regarding environment variables, which are used as initialization parameters
* for threads :
* + variable names should end with '_VAR'
* + environment variable default value should end with '_DEFAULT'
* + values having a special meaning with '_VAL'
* + complete environment strings with '_ENV'
*
*/
/*******************************************************************************
* Program information
*******************************************************************************/
/* Program version and copyright message */
#define PROGRAM_VERSION "0.0.x"
#define PROGRAM_VERSION "DR 2.1"
#define COPYRIGHT_MESSAGE "VideoLAN Client v" PROGRAM_VERSION " (" __DATE__ ") - (c)1999 VideoLAN\n"
/*******************************************************************************
......@@ -45,6 +57,10 @@
/* General debugging support */
#define DEBUG
/* Extended debugging support - in this mode, debugging messages will have their
* date and context printed */
#define DEBUG_CONTEXT
/* Modules specific debugging */
#define DEBUG_INTF
#define DEBUG_INPUT
......@@ -54,10 +70,9 @@
/* Debugging log file - if defined, a file can be used to store all messages. If
* DEBUG_LOG_ONLY is defined, debug messages will only be printed to the log and
* will not appear on the screen */
//#define DEBUG_LOG "vlc-debug.log"
//#define DEBUG_LOG_ONLY
#define DEBUG_LOG "vlc-debug.log"
#define DEBUG_LOG_ONLY
/* ?? VOUT_DEBUG and co have changed ! */
/*******************************************************************************
* Common settings
......@@ -67,7 +82,8 @@
#define AUTO_SPAWN
/* Startup script */
#define INIT_SCRIPT "vlc.init"
#define INTF_INIT_SCRIPT_VAR "vlc_init"
#define INTF_INIT_SCRIPT_DEFAULT "vlc.init"
/* ?? */
#define THREAD_SLEEP 100000
......@@ -164,11 +180,23 @@
#define VLAN_DEFAULT_SERVER_PORT 6010
/*******************************************************************************
* Audio output thread configuration
* Audio configuration
*******************************************************************************/
/* Environment variable used to store dsp device name, and default value */
#define AOUT_DSP_VAR "vlc_dsp"
#define AOUT_DSP_DEFAULT "/dev/dsp"
/* Environment variable for stereo, and default value */
#define AOUT_STEREO_VAR "vlc_stereo"
#define AOUT_STEREO_DEFAULT 1
/* Environment variable for output rate, and default value */
#define AOUT_RATE_VAR "vlc_audio_rate"
#define AOUT_RATE_DEFAULT 44100
/*******************************************************************************
* Video output thread configuration
* Video configuration
*******************************************************************************/
/*
......@@ -176,34 +204,19 @@
*/
/* Title of the window */
#define VOUT_TITLE "VideoLAN Client: output"
#define VOUT_TITLE "VideoLAN Client"
/* Default use of XShm extension */
#define VOUT_SHM_EXT 1
/* Dimensions for display window */
/* Default dimensions for display window - these dimensions are the standard
* width and height for broadcasted MPEG-2 */
#define VOUT_WIDTH 544
#define VOUT_HEIGHT 576
/* Default heap size */
#define VOUT_HEAP_SIZE 100
/*
* Limitations
*/
/* Maximum number of video output threads - this value is used exclusively by
* interface, and is in fact an interface limitation */
#define VOUT_MAX_THREADS 10
/* Maximum number of video streams per video output thread */
#define VOUT_MAX_STREAMS 10
/* Maximum number of pictures which can be rendered in one loop, plus one */
/* Default video heap size - remember that a decompressed picture is big
* (~1 Mbyte) before using huge values */
#define VOUT_MAX_PICTURES 10
/*
* Other settings
* Time settings
*/
/* Time during which the thread will sleep if it has nothing to
......@@ -219,12 +232,12 @@
/* ?? this constant will probably evolve to a calculated value */
#define VOUT_DISPLAY_DELAY 150000
/* Maximum lap of time during which images are rendered in the same
* time. It should be greater than the maximum time between two succesive
* images to avoid useless renderings and calls to the display driver,
* but not to high to avoid desynchronization */
/* ?? this constant will probably evolve to a calculated value */
#define VOUT_DISPLAY_TOLERANCE 150000
/*
* Environment settings
*/
/* Allow use of X11 XShm (shared memory) extension if possible */
#define VOUT_XSHM 1
/*******************************************************************************
* Video parser configuration
......@@ -277,28 +290,12 @@
/* Maximal size of a command line in a script */
#define INTF_MAX_CMD_SIZE 240
/*
* Messages functions
* X11 interface properties
*/
/* Maximal size of the message queue - in case of overflow, all messages in the
* queue are printed by the calling thread */
#define INTF_MSG_QSIZE 32
/* Define to enable messages queues - disabling messages queue can be usefull
* when debugging, since it allows messages which would not otherwise be printed,
* due to a crash, to be printed anyway */
/*#define INTF_MSG_QUEUE*/
/* Format of the header for debug messages. The arguments following this header
* are the file (char *), the function (char *) and the line (int) in which the
* message function was called */
#define INTF_MSG_DBG_FORMAT "## %s:%s(),%i: "
/* Filename to log message
* Note that messages are only logged when debugging */
//#define INTF_MSG_LOGFILE "vlc.log"
#define INTF_APP_CLASS "vlc"
#define INTF_APP_NAME "vlc"
//??#define
/*
* X11 console properties
......@@ -323,15 +320,37 @@
#define INTF_XCONSOLE_FONT "-*-helvetica-medium-r-normal-*-18-*-*-*-*-*-iso8859-1"
/* Number of memorized lines in X11 console window text zone */
#define INTF_XCONSOLE_MAX_LINES 100
#define INTF_CONSOLE_MAX_TEXT 100
/* Maximal number of commands which can be saved in history list */
#define INTF_XCONSOLE_HISTORY_SIZE 20
#define INTF_CONSOLE_MAX_HISTORY 20
/* Maximum width of a line in an X11 console window. If a larger line is
* printed, it will be wrapped. */
#define INTF_XCONSOLE_MAX_LINE_WIDTH 120
#define ENV_VLC_DISPLAY "vlc_DISPLAY"
#define INTF_MAIN_WIDTH 600
#define INTF_MAIN_HEIGHT 600
/*******************************************************************************
* Interface messages functions
*******************************************************************************/
/* Maximal size of the message queue - in case of overflow, all messages in the
* queue are printed by the calling thread */
#define INTF_MSG_QSIZE 32
/* Define to enable messages queues - disabling messages queue can be usefull
* when debugging, since it allows messages which would not otherwise be printed,
* due to a crash, to be printed anyway */
//#define INTF_MSG_QUEUE
/* Format of the header for debug messages. The arguments following this header
* are the file (char *), the function (char *) and the line (int) in which the
* message function was called */
#define INTF_MSG_DBG_FORMAT "## %s:%s(),%i: "
/*******************************************************************************
* Network and VLAN management
......
......@@ -24,12 +24,6 @@
/*******************************************************************************
* Prototypes
*******************************************************************************/
int intf_CreateVoutThread ( intf_thread_t *p_intf, char *psz_title,
int i_width, int i_height );
void intf_DestroyVoutThread ( intf_thread_t *p_intf, int i_thread );
int intf_CreateInputThread ( intf_thread_t *p_intf, input_cfg_t* p_cfg );
void intf_DestroyInputThread ( intf_thread_t *p_intf, int i_thread );
int intf_SelectAudioStream ( intf_thread_t *p_intf, int i_input, int i_id );
void intf_DeselectAudioStream( intf_thread_t *p_intf, int i_input, int i_id );
int intf_SelectVideoStream ( intf_thread_t *p_intf, int i_input,
......
......@@ -310,7 +310,7 @@ typedef int (*f_read_t)( struct input_thread_struct *, const struct iovec *,
size_t );
typedef void (*f_clean_t)( struct input_thread_struct * );
typedef struct input_thread_struct
typedef struct input_thread_s
{
/* Thread properties and locks */
boolean_t b_die; /* 'die' flag */
......@@ -369,7 +369,7 @@ typedef struct input_thread_struct
* properties, asking the called function to use default settings for
* the other ones.
******************************************************************************/
typedef struct input_cfg_struct
typedef struct input_cfg_s
{
u64 i_properties;
......
......@@ -38,72 +38,11 @@
#define VLAN_ID_VLAN( vlan_id ) ( (vlan_id) & 0xff )
#define VLAN_ID( iface, vlan ) ( ((iface) << 8) | (vlan) )
/*******************************************************************************
* input_vlan_server_t: vlan server
*******************************************************************************
* This structure describes a vlan server.
*******************************************************************************/
typedef struct
{
struct sockaddr_in sa_in; /* server address */
int i_socket; /* socket descriptor */
/* Login informations */
char * psz_login; /* server login */
char * psz_passwd; /* server password */
} input_vlan_server_t;
/*******************************************************************************
* input_vlan_iface_t: vlan-capable network interface
*******************************************************************************
* This structure describes the abilities of a network interface capable of
* vlan management. Note that an interface could have several IP adresses, but
* since only the MAC address is used to change vlan, only one needs to be
* retrieved.
* ?? it could be interesting to send a port id on vlan request, to know if two
* interfaces are dependant regarding vlan changes.
*******************************************************************************/
typedef struct
{
char * psz_name; /* interface name */
struct sockaddr_in sa_in; /* interface IP */
char psz_mac[20]; /* interface MAC */
/* Hardware properties */
int i_master; /* master interface index */
int i_switch; /* switch number */
int i_port; /* port number */
int i_sharers; /* number of MACs on this port */
/* Vlan properties - these are only used if i_master is negative */
int i_refcount; /* locks counter */
int i_vlan; /* current vlan */
int i_default_vlan; /* default vlan */
} input_vlan_iface_t;
/*******************************************************************************
* vlan_method_data_t
*******************************************************************************
* Store global vlan library data.
*******************************************************************************/
typedef struct
{
vlc_mutex_t lock; /* library lock */
/* Server */
input_vlan_server_t server; /* vlan server */
/* Network interfaces */
int i_ifaces; /* number of vlan-compliant interfaces */
input_vlan_iface_t * p_iface; /* interfaces */
} input_vlan_method_t;
/*******************************************************************************
* Prototypes
*******************************************************************************/
int input_VlanMethodInit ( input_vlan_method_t *p_method,
char *psz_server, int i_port);
void input_VlanMethodFree ( input_vlan_method_t *p_method );
int input_VlanCreate ( void );
void input_VlanDestroy ( void );
int input_VlanId ( char *psz_iface, int i_vlan );
int input_VlanJoin ( int i_vlan_id );
......
......@@ -26,23 +26,25 @@
* This structe describes all interface-specific data of the main (interface)
* thread.
******************************************************************************/
typedef struct
typedef struct intf_thread_s
{
boolean_t b_die; /* `die' flag */
/* Threads control */
input_thread_t * pp_input[INPUT_MAX_THREADS]; /* input threads */
vout_thread_t * pp_vout[VOUT_MAX_THREADS]; /* vout threads */
aout_thread_t * p_aout; /* aout thread */
int i_input; /* default input thread */
int i_vout; /* default output thread */
/* Specific interfaces */
xconsole_t xconsole; /* X11 console */
p_intf_console_t p_console; /* console */
p_intf_sys_t p_sys; /* system interface */
/* Main threads - NULL if not active */
p_vout_thread_t p_vout;
p_input_thread_t p_input;
} intf_thread_t;
/******************************************************************************
* Prototypes
******************************************************************************/
int intf_Run( intf_thread_t * p_intf );
intf_thread_t * intf_Create ( void );
void intf_Run ( intf_thread_t * p_intf );
void intf_Destroy ( intf_thread_t * p_intf );
int intf_SelectInput ( intf_thread_t * p_intf, p_input_cfg_t p_cfg );
/*******************************************************************************
* intf_console.h: generic console methods for interface
* (c)1998 VideoLAN
*******************************************************************************/
/*******************************************************************************
* Prototypes
*******************************************************************************/
p_intf_console_t intf_ConsoleCreate ( void );
void intf_ConsoleDestroy ( p_intf_console_t p_console );
void intf_ConsoleClear ( p_intf_console_t p_console );
void intf_ConsolePrint ( p_intf_console_t p_console, char *psz_str );
void intf_ConsoleExec ( p_intf_console_t p_console, char *psz_str );
......@@ -3,75 +3,8 @@
* (c)1999 VideoLAN
*******************************************************************************
* This library provides basic functions for threads to interact with user
* interface, such as message output. If INTF_MSG_QUEUE is defined (which is the
* defaul), messages are not printed directly by threads, to bypass console
* limitations and slow printf() calls, but sent to a queue and printed later by
* interface thread.
* If INTF_MSG_QUEUE is not defined, output is directly performed on stderr.
*******************************************************************************
* required headers:
* "config.h"
* "mtime.h"
* "vlc_thread.h"
*******************************************************************************/
/*******************************************************************************
* interface_message_t
*******************************************************************************
* Store a single message. Messages have a maximal size of INTF_MSG_MSGSIZE.
* If DEBUG is defined, messages have a date field and debug messages are
* printed with a date to allow more precise profiling.
*******************************************************************************/
typedef struct
{
int i_type; /* message type, see below */
char * psz_msg; /* the message itself */
#ifdef DEBUG
/* Debugging informations - in DEBUG mode, all messages are dated and debug
* messages have calling location informations printed */
mtime_t date; /* date of the message (all messages) */
char * psz_file; /* file in which the function was called */
char * psz_function; /* function from which the function was called */
int i_line; /* line at which the function was called */
#endif
} interface_msg_message_t;
/* Message types */
#define INTF_MSG_STD 0 /* standard message */
#define INTF_MSG_ERR 1 /* error message */
#define INTF_MSG_INTF 2 /* interface message */
#define INTF_MSG_DBG 3 /* debug message */
/*******************************************************************************
* interface_msg_t
*******************************************************************************
* Store all data requiered by messages interfaces. It has a singe instance in
* program_data.
* interface, such as message output. See config.h for output configuration.
*******************************************************************************/
typedef struct
{
#ifdef INTF_MSG_QUEUE
/* Message queue */
vlc_mutex_t lock; /* message queue lock */
int i_count; /* number of messages stored */
interface_msg_message_t msg[INTF_MSG_QSIZE]; /* message queue */
#endif
#ifdef DEBUG_LOG
/* Log file */
FILE * p_log_file; /* log file */
#endif
#ifndef INTF_MSG_QUEUE
#ifndef DEBUG_LOG
/* If neither messages queue, neither log file is used, then the structure
* is empty. However, empty structures are not allowed in C. Therefore, a
* dummy integer is used to fill it. */
int i_dummy; /* unused filler */
#endif
#endif
} interface_msg_t;
/*******************************************************************************
* intf_DbgMsg macros and functions
......@@ -125,14 +58,12 @@ void intf_FlushMsg ( void );
/*******************************************************************************
* Prototypes
*******************************************************************************/
int intf_InitMsg ( interface_msg_t *p_intf_msg );
void intf_TerminateMsg ( interface_msg_t *p_intf_msg );
void intf_Msg ( char *psz_format, ... );
void intf_ErrMsg ( char *psz_format, ... );
void intf_IntfMsg ( char *psz_format, ... );
void intf_MsgImm ( char *psz_format, ... );
void intf_ErrMsgImm ( char *psz_format, ... );
p_intf_msg_t intf_MsgCreate ( void );
void intf_MsgDestroy ( void );
void intf_Msg ( char *psz_format, ... );
void intf_ErrMsg ( char *psz_format, ... );
void intf_IntfMsg ( char *psz_format, ... );
void intf_MsgImm ( char *psz_format, ... );
void intf_ErrMsgImm ( char *psz_format, ... );
/*******************************************************************************
* intf_sys.h: system dependant interface API
* (c)1999 VideoLAN
*******************************************************************************/
/*******************************************************************************
* Prototypes
*******************************************************************************/
int intf_SysCreate ( p_intf_thread_t p_intf );
void intf_SysDestroy( p_intf_thread_t p_intf );
void intf_SysManage ( p_intf_thread_t p_intf );
/*******************************************************************************
* pgm_data.h: access to all program variables
* main.h: access to all program variables
* (c)1999 VideoLAN
*******************************************************************************
* This header provides structures to access to all program variables. It should
* only be used by interface.
*******************************************************************************
* Required headers:
* <netinet/in.h>
* <sys/soundcard.h>
* <sys/uio.h>
* <X11/Xlib.h>
* <X11/extensions/XShm.h>
* "config.h"
* "common.h"
* "mtime.h"
* "vlc_thread.h"
* "input.h"
* "input_vlan.h"
* "audio_output.h"
* "video.h"
* "video_output.h"
* "xconsole.h"
* "interface.h"
* "intf_msg.h"
* Declaration and extern access to global program object.
*******************************************************************************/
/*******************************************************************************
* main_config_t
*******************************************************************************
* Store the main configuration (non thread-dependant configuration), such as
* parameters read from command line and name of configuration file
*******************************************************************************/
typedef struct
{
boolean_t b_audio; /* is audio output allowed ? */
boolean_t b_video; /* is video output allowed ? */
boolean_t b_vlans; /* are vlans supported ? */
/* Vlan input method configuration */
char * psz_input_vlan_server; /* vlan server */
int i_input_vlan_server_port; /* vlan server port */
} main_config_t;
/*******************************************************************************
* program_data_t, p_program_data (global variable)
* main_t, p_main (global variable)
*******************************************************************************
* This structure has an unique instance, declared in main and pointed by the
* only global variable of the program. It should allow access to any variable
......@@ -55,23 +18,31 @@ typedef struct
typedef struct
{
/* Global properties */
int i_argc; /* command line arguments count */
char ** ppsz_argv; /* command line arguments */
char ** ppsz_env; /* environment variables */
int i_argc; /* command line arguments count */
char ** ppsz_argv; /* command line arguments */
char ** ppsz_env; /* environment variables */
/* Generic settings */
boolean_t b_audio; /* is audio output allowed ? */
boolean_t b_video; /* is video output allowed ? */
boolean_t b_vlans; /* are vlans supported ? */
/* Configurations */
main_config_t cfg; /* general configuration */
video_cfg_t vout_cfg; /* video output configuration */
/* Unique threads */
p_aout_thread_t p_aout; /* audio output thread */
p_intf_thread_t p_intf; /* main interface thread */
/* Threads */
aout_thread_t aout_thread; /* audio output thread */
intf_thread_t intf_thread; /* interface thread */
/* 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 */
} main_t;
/* Shared data - these structures are accessed directly from p_program_data
* by several libraries */
interface_msg_t intf_msg; /* messages interface data */
input_vlan_method_t input_vlan_method; /* vlan input method */
} program_data_t;
extern main_t *p_main;
extern program_data_t *p_program_data;
/*******************************************************************************
* Prototypes - these methods are used to get default values for some threads
* and modules.
*******************************************************************************/
int main_GetIntVariable( char *psz_name, int i_default );
char * main_GetPszVariable( char *psz_name, char *psz_default );
/*******************************************************************************
* thread.h: threads status constants
* (c)1999 VideoLAN
*******************************************************************************
* These constants are used by all threads in *_CreateThread() and
* *_DestroyThreads() functions. Since those calls are non-blocking, an integer
* value is used as a shared flag to represent the status of the thread.
*******************************************************************************
* Requires:
* none
*******************************************************************************/
/* Void status - this value can be used to be sure, in an array of recorded
* threads, that no operation is currently in progress on the concerned thread */
#define THREAD_NOP 0 /* nothing happened */
/* Creation status */
#define THREAD_CREATE 10 /* thread is initializing */
#define THREAD_START 11 /* thread has forked */
#define THREAD_READY 19 /* thread is ready */
/* Destructions status */
#define THREAD_DESTROY 20 /* destruction order has been sent */
#define THREAD_END 21 /* destruction order has been received */
#define THREAD_OVER 29 /* thread does not exist any more */
/* Error status */
#define THREAD_ERROR 30 /* an error occured */
#define THREAD_FATAL 31 /* an fatal error occured - program must end */
This diff is collapsed.
......@@ -65,7 +65,7 @@ typedef struct vdec_thread_s
*******************************************************************************/
/* Thread management functions */
vdec_thread_t * vdec_CreateThread ( /* video_cfg_t *p_cfg, */ input_thread_t *p_input /*,
p_vdec_thread_t vdec_CreateThread ( /* video_cfg_t *p_cfg, */ input_thread_t *p_input /*,
vout_thread_t *p_vout, int *pi_status */ );
void vdec_DestroyThread ( vdec_thread_t *p_vdec /*, int *pi_status */ );
......
......@@ -16,38 +16,4 @@
* Prototypes
*******************************************************************************/
/* Pictures management functions */
picture_t * video_CreatePicture ( video_cfg_t *p_cfg );
picture_t * video_CopyPicture ( picture_t *p_pic );
picture_t * video_ReplicatePicture ( picture_t *p_pic );
void video_DestroyPicture ( picture_t *p_pic );
/* Files functions */
picture_t * video_ReadPicture ( int i_file );
/* Drawing functions */
void video_ClearPicture ( picture_t *p_pic );
void video_DrawPixel ( picture_t *p_pic, int i_x, int i_y, pixel_t value );
void video_DrawHLine ( picture_t *p_pic, int i_x, int i_y, int i_width, pixel_t value );
void video_DrawVLine ( picture_t *p_pic, int i_x, int i_y, int i_height, pixel_t value );
void video_DrawLine ( picture_t *p_pic, int i_x1, int i_y1,
int i_x2, int i_y2, pixel_t value );
void video_DrawBar ( picture_t *p_pic, int i_x, int i_y, int i_width,
int i_height, pixel_t value );
void video_DrawRectangle ( picture_t *p_pic, int i_x, int i_y,
int i_width, int i_height, pixel_t color );
void video_DrawPicture ( picture_t *p_pic, picture_t *p_insert, int i_x, int i_y );
void video_DrawText ( picture_t *p_pic, int i_x, int i_y, char *psz_text,
int i_size, pixel_t color );
/* Convertion functions */
/* ?? rgb->pixel, pixel->rgb */
/* Low-level shared functions */
void video_CopyPictureDescriptor ( picture_t *p_dest, picture_t *p_src );
int video_CreatePictureBody ( picture_t *p_pic, video_cfg_t *p_cfg );
#ifdef DEBUG
/* Debugging functions */
void video_PrintPicture ( picture_t *p_pic, char *psz_str );
#endif
......@@ -14,45 +14,6 @@
* "video.h"
*******************************************************************************/
/* ?? this over-complicated API and code should be re-designed, with a simple
* video-stream associated to a window (each window designed to be openned in
* a parent one and probably without border), and have an api looking like
* vout_CreateWindow
* vout_DestroyWindow
* vout_AddPicture
* vout_RemovePicture
* vout_ReservePicture
* vout_AddReservedPicture
* vout_Clear
* vout_Refresh
*
* the overlay/transparent, permanent and such stuff should disapear.
*/
/*******************************************************************************
* vout_stream_t: video stream descriptor
*******************************************************************************
* Each video stream has a set of properties, stored in this structure. It is
* part of vout_thread_t and is not supposed to be used anywhere else.
*******************************************************************************/
typedef struct
{
int i_status; /* is stream active ? */
picture_t * p_next_picture; /* next picture to be displayed */
#ifdef STATS
/* Statistics */
count_t c_pictures; /* total number of pictures added */
count_t c_rendered_pictures; /* number of rendered pictures */
#endif
} vout_stream_t;
/* Video stream status */
#define VOUT_INACTIVE_STREAM 0 /* stream is inactive (empty) */
#define VOUT_ACTIVE_STREAM 1 /* stream is active */
#define VOUT_ENDING_STREAM 2 /* stream will be destroyed when empty */
#define VOUT_DESTROYED_STREAM 3 /* stream must be destroyed */
/*******************************************************************************
* vout_thread_t: video output thread descriptor
*******************************************************************************
......@@ -65,9 +26,8 @@ typedef struct vout_thread_s
boolean_t b_die; /* `die' flag */
boolean_t b_error; /* `error' flag */
boolean_t b_active; /* `active' flag */
vlc_thread_t thread_id; /* id for thread functions */
vlc_mutex_t streams_lock; /* streams modification lock */
vlc_mutex_t pictures_lock; /* pictures modification lock */
pthread_t thread_id; /* id for pthread functions */
pthread_mutex_t lock; /* thread lock */
int * pi_status; /* temporary status flag */
/* Common display properties */
......@@ -75,30 +35,27 @@ typedef struct vout_thread_s
int i_height; /* current output method height */
int i_screen_depth; /* bits per pixel */
int i_bytes_per_pixel; /* real screen depth */
float f_x_ratio; /* horizontal display ratio */
float f_y_ratio; /* vertical display ratio */
/* Output method */
struct vout_x11_s * p_x11; /* X11 output method */
p_vout_sys_t p_sys; /* system output method */
/* Video heap */
int i_max_pictures; /* heap maximal size */
int i_pictures; /* current heap size */
picture_t * p_picture; /* pictures */
/* Streams data */
vout_stream_t p_stream[VOUT_MAX_STREAMS]; /* streams data */
picture_t p_picture[VOUT_MAX_PICTURES]; /* pictures */
#ifdef STATS
/* Statistics */
count_t c_loops; /* number of loops */
count_t c_idle_loops; /* number of idle loops */
count_t c_pictures; /* number of pictures added to heap */
count_t c_rendered_pictures; /* number of pictures rendered */
#endif
/* Rendering functions - these functions are of vout_render_blank_t and
* vout_render_line_t, but are not declared here using these types since
* they require vout_thread_t to be defined */
void (* RenderRGBBlank) ( struct vout_thread_s *p_vout, pixel_t pixel,
/* void (* RenderRGBBlank) ( struct vout_thread_s *p_vout, pixel_t pixel,
int i_x, int i_y, int i_width, int i_height );
void (* RenderPixelBlank) ( struct vout_thread_s *p_vout, pixel_t pixel,
int i_x, int i_y, int i_width, int i_height );
......@@ -114,64 +71,30 @@ typedef struct vout_thread_s
void (* RenderPixelMaskLine) ( struct vout_thread_s *p_vout, picture_t *p_pic,
int i_x, int i_y, int i_pic_x, int i_pic_y,
int i_width, int i_line_width, int i_ratio );
/* ?? add YUV types */
*/ /* ?? add YUV types */
} vout_thread_t;
/*******************************************************************************
* vout_render_blank_t: blank rendering function
* vout_render_line_t: rectangle rendering functions
*******************************************************************************
* All rendering functions should be of these types - for blank pictures
* (pictures with uniform color), blank rendering functions are called once. For
* other pictures, each function is called once for each picture line. Note that
* the part of the picture sent to the rendering functions is in the output
* window, since the clipping is done before.
* p_vout is the calling thread
* pixel is the color or pixel value of the rectange to be drawn
* p_pic is the picture to be rendered
* i_x, i_y is the absolute position in output window
* i_pic_x is the first pixel to be drawn in the picture
* i_pic_y is the line of the picture to be drawn
* i_width is the width of the area to be rendered in the picture (not in the
* output window), except for blank pictures, where it is the absolute size
* of the area to be rendered
* i_height is the height og the area to be rendered
* i_line_width is the number of time the line must be copied
* i_ratio is the horizontal display ratio
*******************************************************************************/
typedef void (vout_render_blank_t)( vout_thread_t *p_vout, pixel_t pixel,
int i_x, int i_y, int i_width, int i_height );
typedef void (vout_render_line_t) ( vout_thread_t *p_vout, picture_t *p_pic,
int i_x, int i_y, int i_pic_x, int i_pic_y,
int i_width, int i_line_width, int i_ratio );
/*******************************************************************************
* Prototypes
*******************************************************************************/
vout_thread_t * vout_CreateThread ( video_cfg_t *p_cfg, int *pi_status );
void vout_DestroyThread ( vout_thread_t *p_vout, int *pi_status );
picture_t * vout_DisplayPicture ( vout_thread_t *p_vout, picture_t *p_pic );
picture_t * vout_DisplayPictureCopy ( vout_thread_t *p_vout, picture_t *p_pic );
picture_t * vout_DisplayPictureReplicate ( vout_thread_t *p_vout, picture_t *p_pic );
picture_t * vout_DisplayReservedPicture ( vout_thread_t *p_vout, picture_t *p_pic );
picture_t * vout_CreateReservedPicture ( vout_thread_t *p_vout, video_cfg_t *p_cfg );
picture_t * vout_ReservePicture ( vout_thread_t *p_vout, picture_t *p_pic );
picture_t * vout_ReservePictureCopy ( vout_thread_t *p_vout, picture_t *p_pic );
picture_t * vout_ReservePictureReplicate ( vout_thread_t *p_vout, picture_t *p_pic );
void vout_RemovePicture ( vout_thread_t *p_vout, picture_t *p_pic );
vout_thread_t * vout_CreateThread (
#if defined(VIDEO_X11)
Display *p_display, Window root_window,
#elif defined(VIDEO_FB)
//??void
#endif
int i_width, int i_height, int *pi_status
);
void vout_RefreshPermanentPicture ( vout_thread_t *p_vout, picture_t *p_pic,
mtime_t displa_date );
void vout_DestroyThread ( vout_thread_t *p_vout, int *pi_status );
picture_t * vout_CreatePicture ( vout_thread_t *p_vout, int i_type,
int i_width, int i_height, int i_bytes_per_line );
void vout_DestroyPicture ( vout_thread_t *p_vout, picture_t *p_pic );
void vout_DisplayPicture ( vout_thread_t *p_vout, picture_t *p_pic );
void vout_LinkPicture ( vout_thread_t *p_vout, picture_t *p_pic );
void vout_UnlinkPicture ( vout_thread_t *p_vout, picture_t *p_pic );
int vout_CreateStream ( vout_thread_t *p_vout );
void vout_EndStream ( vout_thread_t *p_vout, int i_stream );
void vout_DestroyStream ( vout_thread_t *p_vout, int i_stream );
#ifdef DEBUG
void vout_PrintHeap ( vout_thread_t *p_vout, char *psz_str );
#endif
......@@ -182,3 +105,12 @@ void vout_PrintHeap ( vout_thread_t *p_vout, char *p
/*******************************************************************************
* video_sys.h: system dependant video output display method API
* (c)1999 VideoLAN
*******************************************************************************/
/*******************************************************************************
* Prototypes
*******************************************************************************/
#if defined(VIDEO_X11)
int vout_SysCreate ( p_vout_thread_t p_vout, Display *p_display, Window root_window );
#elif defined(VIDEO_FB)
int vout_SysCreate ( p_vout_thread_t p_vout );
#endif
int vout_SysInit ( p_vout_thread_t p_vout );
void vout_SysEnd ( p_vout_thread_t p_vout );
void vout_SysDestroy ( p_vout_thread_t p_vout );
int vout_SysManage ( p_vout_thread_t p_vout );
void vout_SysDisplay ( p_vout_thread_t p_vout );
/*******************************************************************************
* all.h: all headers
* vlc.h: all headers
* (c)1998 VideoLAN
*******************************************************************************
* This header includes all vlc .h headers and depending headers. A source file
......@@ -12,22 +12,54 @@
*******************************************************************************/
/* System headers */
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.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>
#include <sys/uio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/XShm.h>
#include <X11/extensions/xf86dga.h>
/* Common headers */
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "netutils.h"
#include "debug.h"
#include "xutils.h"
#include "intf_msg.h"
/* Input */
#include "input.h"
#include "input_psi.h"
#include "input_pcr.h"
#include "input_netlist.h"
#include "input_vlan.h"
#include "decoder_fifo.h"
#include "input_file.h"
#include "input_network.h"
/* Audio */
#include "audio_output.h"
......@@ -35,16 +67,17 @@
/* Video */
#include "video.h"
#include "video_sys.h"
#include "video_output.h"
#include "video_decoder.h"
/* Interface */
#include "xconsole.h"
#include "intf_cmd.h"
#include "intf_ctrl.h"
#include "intf_sys.h"
#include "intf_console.h"
#include "interface.h"
#include "intf_msg.h"
/* Shared resources */
#include "pgm_data.h"
#include "main.h"
/*******************************************************************************
* vlc_thread.h : thread implementation for vieolan client
* (c)1999 VideoLAN
******************************************************************************/
*******************************************************************************
* This header is supposed to provide a portable threads implementation.
* Currently, it is a wrapper to the POSIX pthreads library.
*******************************************************************************/
#include <pthread.h>
/*******************************************************************************
* types definition
******************************************************************************/
/******************************************************************************
* Constants
******************************************************************************
* These constants are used by all threads in *_CreateThread() and
* *_DestroyThreads() functions. Since those calls are non-blocking, an integer
* value is used as a shared flag to represent the status of the thread.
*******************************************************************************/
/* Void status - this value can be used to be sure, in an array of recorded
* threads, that no operation is currently in progress on the concerned thread */
#define THREAD_NOP 0 /* nothing happened */
/* Creation status */
#define THREAD_CREATE 10 /* thread is initializing */
#define THREAD_START 11 /* thread has forked */
#define THREAD_READY 19 /* thread is ready */
/* Destructions status */
#define THREAD_DESTROY 20 /* destruction order has been sent */
#define THREAD_END 21 /* destruction order has been received */
#define THREAD_OVER 29 /* thread does not exist any more */
/* Error status */
#define THREAD_ERROR 30 /* an error occured */
#define THREAD_FATAL 31 /* an fatal error occured - program must end */
/******************************************************************************
* Types definition
******************************************************************************/
typedef pthread_t vlc_thread_t;
typedef pthread_mutex_t vlc_mutex_t;
typedef pthread_cond_t vlc_cond_t;
typedef void *(*vlc_thread_func)(void *data);
typedef void *(*vlc_thread_func_t)(void *p_data);
/******************************************************************************
* Prototypes
******************************************************************************/
static __inline__ int vlc_thread_create ( vlc_thread_t * thread, char * name,
vlc_thread_func func, void * data );
static __inline__ void vlc_thread_exit ( );
static __inline__ void vlc_thread_join ( vlc_thread_t thread );
static __inline__ int vlc_thread_create( vlc_thread_t *p_thread, char *psz_name,
vlc_thread_func_t func, void *p_data );
static __inline__ void vlc_thread_exit ( void );
static __inline__ void vlc_thread_join ( vlc_thread_t thread );
static __inline__ int vlc_mutex_init ( vlc_mutex_t * mutex );
static __inline__ int vlc_mutex_lock ( vlc_mutex_t * mutex );
static __inline__ int vlc_mutex_unlock ( vlc_mutex_t * mtex );
static __inline__ int vlc_mutex_init ( vlc_mutex_t *p_mutex );
static __inline__ int vlc_mutex_lock ( vlc_mutex_t *p_mutex );
static __inline__ int vlc_mutex_unlock ( vlc_mutex_t *p_mutex );
static __inline__ int vlc_cond_init ( vlc_cond_t * condvar );
static __inline__ int vlc_cond_signal ( vlc_cond_t * condvar );
static __inline__ int vlc_cond_wait ( vlc_cond_t * condvar, vlc_mutex_t * mutex );
static __inline__ int vlc_cond_init ( vlc_cond_t *p_condvar );
static __inline__ int vlc_cond_signal ( vlc_cond_t *p_condvar );
static __inline__ int vlc_cond_wait ( vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex );
//static _inline__ int vlc_cond_timedwait ( vlc_cond_t * condvar, vlc_mutex_t * mutex,
// mtime_t absoute_timeout_time );
/*******************************************************************************
* vlc_thread_create
* vlc_thread_create: create a thread
******************************************************************************/
static __inline__ int vlc_thread_create(
vlc_thread_t * thread,
char * name,
vlc_thread_func func,
void * data)
static __inline__ int vlc_thread_create( vlc_thread_t *p_thread,
char *psz_name, vlc_thread_func_t func,
void *p_data)
{
return pthread_create( thread, NULL, func, data );
return pthread_create( p_thread, NULL, func, p_data );
}
/******************************************************************************
* vlc_thread_exit
* vlc_thread_exit: terminate a thread
*******************************************************************************/
static __inline__ void vlc_thread_exit()
static __inline__ void vlc_thread_exit( void )
{
pthread_exit( 0 );
}
/*******************************************************************************
* vlc_thread_exit
* vlc_thread_join: wait until a thread exits
******************************************************************************/
static __inline__ void vlc_thread_join( vlc_thread_t thread )
{
pthread_join( thread, NULL );
}
/*******************************************************************************
* vlc_mutex_init
* vlc_mutex_init: initialize a mutex
*******************************************************************************/
static __inline__ int vlc_mutex_init( vlc_mutex_t * mutex )
static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex )
{
return pthread_mutex_init( mutex, NULL );
return pthread_mutex_init( p_mutex, NULL );
}
/*******************************************************************************
* vlc_mutex_lock
* vlc_mutex_lock: lock a mutex
*******************************************************************************/
static __inline__ int vlc_mutex_lock( vlc_mutex_t * mutex )
static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex )
{
return pthread_mutex_lock( mutex );
return pthread_mutex_lock( p_mutex );
}
/*******************************************************************************
* vlc_mutex_unlock
* vlc_mutex_unlock: unlock a mutex
*******************************************************************************/
static __inline__ int vlc_mutex_unlock( vlc_mutex_t * mutex )
static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex )
{
return pthread_mutex_unlock( mutex );
return pthread_mutex_unlock( p_mutex );
}
/*******************************************************************************
* vlc_cond_init
* vlc_cond_init: initialize a condition
*******************************************************************************/
static __inline__ int vlc_cond_init( vlc_cond_t * condvar )
static __inline__ int vlc_cond_init( vlc_cond_t *p_condvar )
{
return pthread_cond_init( condvar, NULL );
return pthread_cond_init( p_condvar, NULL );
}
/*******************************************************************************
* vlc_cond_signal
* vlc_cond_signal: start a thread on condition completion
*******************************************************************************/
static __inline__ int vlc_cond_signal( vlc_cond_t * condvar )
static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar )
{
return pthread_cond_signal( condvar );
return pthread_cond_signal( p_condvar );
}
/*******************************************************************************
* vlc_cond_wait
* vlc_cond_wait: wait until condition completion
*******************************************************************************/
static __inline__ int vlc_cond_wait( vlc_cond_t * condvar, vlc_mutex_t * mutex )
static __inline__ int vlc_cond_wait( vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex )
{
return pthread_cond_wait( condvar, mutex );
return pthread_cond_wait( p_condvar, p_mutex );
}
/*******************************************************************************
* xconsole.h: X11 console for interface
* (c)1998 VideoLAN
*******************************************************************************
* The X11 console is a simple way to get interactive input from the user. It
* does not disturbs the standard terminal output. In theory, multiple consoles
* could be openned on different displays.
*?? will probably evolve
*******************************************************************************/
/*******************************************************************************
* xconsole_t: X11 console descriptor
*******************************************************************************
* The display pointer is specific to this structure since in theory, multiple
* console could be openned on different displays. A console is divided in two
* sections. The lower one is a single line edit control. Above, a multi-line
* output zone allow to send messages.
*******************************************************************************/
typedef struct
{
/* Initialization fields - those fields should be initialized before
* calling intf_OpenX11Console(). */
char * psz_display; /* display name */
char * psz_geometry; /* window geometry */
/* following fields are internal */
/* Settings and display properties */
Display * p_display; /* display pointer */
int i_screen; /* screen number */
XFontStruct * p_font; /* used font */
Window window; /* window instance handler */
/* Graphic contexts */
GC default_gc; /* graphic context for default text */
/* Pixmaps */
Pixmap background_pixmap; /* window background */
/* Window properties */
int i_width, i_height; /* window dimensions */
int i_text_offset; /* text zone placement from bottom */
int i_text_line_height;/* height of a single text line */
int i_edit_height; /* total edit zone height */
int i_edit_offset; /* edit zone placement from bottom */
/* Text array */
char * psz_text[INTF_XCONSOLE_MAX_LINES]; /* text */
int i_text_index; /* last line index */
/* Edit lines properties. The line has one more character than
* maximum width to allow adding a terminal '\0' when it is sent to
* execution or text zone. The size must stay between 0 (included) and
* INTF_X11_CONSOLE_MAX_LINE_WIDTH (included). The cursor position (index)
* can be between 0 (included) and size (included). */
char sz_edit[INTF_XCONSOLE_MAX_LINE_WIDTH + 1];
int i_edit_index; /* cursor position */
int i_edit_size; /* total size of edit text */
/* History. The history array (composed of asciiz strings) has a base,
* marking the *next* registered line, and an index, marking the actual
* line browsed. When an history browse is started, the current line is
* stored at base (but base isn't increased), and index is modified.
* When a command is executed, it is registered at base and base is
* increased. */
char * psz_history[INTF_XCONSOLE_HISTORY_SIZE + 1];
int i_history_index; /* index in history */
int i_history_base; /* history base */
} xconsole_t;
/*******************************************************************************
* Prototypes
*******************************************************************************/
int intf_OpenXConsole ( xconsole_t *p_console );
void intf_CloseXConsole ( xconsole_t *p_console );
void intf_ManageXConsole ( xconsole_t *p_console );
void intf_ClearXConsole ( xconsole_t *p_console );
void intf_PrintXConsole ( xconsole_t *p_console, char *psz_str );
......@@ -110,7 +110,7 @@ adec_thread_t * adec_CreateThread( input_thread_t * p_input )
p_adec->p_aout_fifo = NULL;
/* Spawn the audio decoder thread */
if ( vlc_thread_create(&p_adec->thread_id, "audio decoder", (vlc_thread_func)RunThread, (void *)p_adec) )
if ( vlc_thread_create(&p_adec->thread_id, "audio decoder", (vlc_thread_func_t)RunThread, (void *)p_adec) )
{
intf_ErrMsg("adec error: can't spawn audio decoder thread\n");
free( p_adec );
......
......@@ -34,11 +34,15 @@
#include "audio_output.h"
#include "audio_dsp.h"
#include "main.h"
/******************************************************************************
* Local prototypes
******************************************************************************/
static int aout_SpawnThread( aout_thread_t * p_aout );
/* Creating as much aout_Thread functions as configurations is one solution,
* examining the different cases in the Thread loop of an unique function is
* another. I chose the first solution. */
......@@ -55,56 +59,87 @@ static __inline__ void InitializeIncrement( aout_increment_t * p_increment, long
static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo/*, mtime_t aout_date*/ );
/******************************************************************************
* aout_Open
* aout_CreateThread: initialize audio thread
******************************************************************************/
int aout_Open( aout_thread_t * p_aout )
aout_thread_t *aout_CreateThread( int *pi_status )
{
if ( aout_dspOpen( &p_aout->dsp ) )
aout_thread_t * p_aout; /* thread descriptor */
int i_status; /* thread status */
/* Allocate descriptor */
p_aout = (aout_thread_t *) malloc( sizeof(aout_thread_t) );
if( p_aout == NULL )
{
return( -1 );
return( NULL );
}
//???? kludge to initialize some audio parameters - place this section somewhere
//???? else
p_aout->dsp.i_format = AOUT_DEFAULT_FORMAT;
p_aout->dsp.psz_device = main_GetPszVariable( AOUT_DSP_VAR, AOUT_DSP_DEFAULT );
p_aout->dsp.b_stereo = main_GetIntVariable( AOUT_STEREO_VAR, AOUT_STEREO_DEFAULT );
p_aout->dsp.l_rate = main_GetIntVariable( AOUT_RATE_VAR, AOUT_RATE_DEFAULT );
// ???? end of kludge
/*
* Initialize DSP
*/
if ( aout_dspOpen( &p_aout->dsp ) )
{
free( p_aout );
return( NULL );
}
if ( aout_dspReset( &p_aout->dsp ) )
{
aout_dspClose( &p_aout->dsp );
return( -1 );
free( p_aout );
return( NULL );
}
if ( aout_dspSetFormat( &p_aout->dsp ) )
{
aout_dspClose( &p_aout->dsp );
return( -1 );
free( p_aout );
return( NULL );
}
if ( aout_dspSetChannels( &p_aout->dsp ) )
{
aout_dspClose( &p_aout->dsp );
return( -1 );
free( p_aout );
return( NULL );
}
if ( aout_dspSetRate( &p_aout->dsp ) )
{
aout_dspClose( &p_aout->dsp );
return( -1 );
free( p_aout );
return( NULL );
}
intf_DbgMsg("aout debug: audio device (%s) opened (format=%i, stereo=%i, rate=%li)\n",
p_aout->dsp.psz_device,
p_aout->dsp.i_format,
p_aout->dsp.b_stereo, p_aout->dsp.l_rate);
return( 0 );
//?? maybe it would be cleaner to change SpawnThread prototype
//?? see vout to handle status correctly - however, it is not critical since
//?? this thread is only called in main is all calls are blocking
if( aout_SpawnThread( p_aout ) )
{
aout_dspClose( &p_aout->dsp );
free( p_aout );
return( NULL );
}
return( p_aout );
}
/******************************************************************************
* aout_SpawnThread
******************************************************************************/
int aout_SpawnThread( aout_thread_t * p_aout )
static int aout_SpawnThread( aout_thread_t * p_aout )
{
int i_fifo;
long l_bytes;
s64 s64_numerator, s64_denominator;
void * aout_thread = NULL;
int i_fifo;
long l_bytes;
s64 s64_numerator, s64_denominator;
void * aout_thread = NULL;
intf_DbgMsg("aout debug: spawning audio output thread (%p)\n", p_aout);
......@@ -239,7 +274,7 @@ int aout_SpawnThread( aout_thread_t * p_aout )
p_aout->date = mdate();
/* Launch the thread */
if ( vlc_thread_create( &p_aout->thread_id, "audio output", (vlc_thread_func)aout_thread, p_aout ) )
if ( vlc_thread_create( &p_aout->thread_id, "audio output", (vlc_thread_func_t)aout_thread, p_aout ) )
{
intf_ErrMsg("aout error: can't spawn audio output thread (%p)\n", p_aout);
free( p_aout->buffer );
......@@ -252,28 +287,26 @@ int aout_SpawnThread( aout_thread_t * p_aout )
}
/******************************************************************************
* aout_CancelThread
* aout_DestroyThread
******************************************************************************/
void aout_CancelThread( aout_thread_t * p_aout )
void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status )
{
//???? pi_status is not handled correctly: check vout how to do!
intf_DbgMsg("aout debug: requesting termination of audio output thread (%p)\n", p_aout);
/* Ask thread to kill itself and wait until it's done */
p_aout->b_die = 1;
vlc_thread_join( p_aout->thread_id );
vlc_thread_join( p_aout->thread_id ); // only if pi_status is NULL
/* Free the allocated memory */
free( p_aout->buffer );
free( p_aout->s32_buffer );
}
/******************************************************************************
* aout_Close
******************************************************************************/
void aout_Close( aout_thread_t * p_aout )
{
/* Free the structure */
aout_dspClose( &p_aout->dsp );
intf_DbgMsg("aout debug: audio device (%s) closed\n", p_aout->dsp.psz_device);
free( p_aout );
}
/******************************************************************************
......
......@@ -14,8 +14,10 @@
/******************************************************************************
* Preamble
******************************************************************************/
#include <errno.h>
*******************************************************************************/
#include "vlc.h"
/*#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
......@@ -31,8 +33,8 @@
#include "thread.h"
#include "intf_msg.h"
#include "debug.h" /* ?? temporaire, requis par netlist.h */
#include "debug.h" */
/*
#include "input.h"
#include "input_netlist.h"
#include "decoder_fifo.h"
......@@ -41,7 +43,7 @@
#include "video.h"
#include "video_output.h"
#include "video_decoder.h"
#include "video_decoder.h"*/
/*
* Local prototypes
......
......@@ -8,19 +8,22 @@
/*******************************************************************************
* Preamble
******************************************************************************/
*******************************************************************************/
#include "vlc.h"
/*
#include <errno.h>
#include <sys/uio.h> /* iovec */
#include <sys/uio.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include <sys/soundcard.h>
#include <stdlib.h> /* atoi(), malloc(), free() */
#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h> /* ioctl() */
#include <net/if.h> /* ifreq */
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include "common.h"
......@@ -44,6 +47,7 @@
#include "video.h"
#include "video_output.h"
#include "video_decoder.h"
*/
/******************************************************************************
* Local prototypes
......@@ -192,7 +196,7 @@ input_thread_t *input_CreateThread( input_cfg_t *p_cfg )
#ifdef NO_THREAD
input_Thread( p_input );
#else
if( vlc_thread_create(&p_input->thread_id, "input", (vlc_thread_func)input_Thread,
if( vlc_thread_create(&p_input->thread_id, "input", (vlc_thread_func_t)input_Thread,
(void *) p_input) )
{
intf_ErrMsg("input error: can't spawn input thread (%s)\n",
......@@ -304,7 +308,7 @@ static void input_Thread( input_thread_t *p_input )
EndThread( p_input );
intf_DbgMsg("input debug: thread %p destroyed\n", p_input);
vlc_thread_exit( 0 );
vlc_thread_exit();
}
......
......@@ -9,9 +9,12 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include "vlc.h"
/*
#include <errno.h>
#include <sys/uio.h> /* iovec */
#include <stdlib.h> /* atoi(), malloc(), free() */
#include <sys/uio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
......@@ -19,7 +22,7 @@
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include <sys/soundcard.h>
#include <netinet/in.h> /* ntohs */
#include <netinet/in.h>
#include "common.h"
#include "config.h"
......@@ -39,8 +42,7 @@
#include "video.h"
#include "video_output.h"
#include "video_decoder.h"
#include "video_decoder.h" */
/******************************************************************************
* input_AddPgrmElem: Start the extraction and the decoding of a program element
......
......@@ -8,13 +8,18 @@
/*******************************************************************************
* Preamble
******************************************************************************/
*******************************************************************************/
#include "vlc.h"
/*
#include <errno.h>
#include <pthread.h>
#include <errno.h>
#include <stdio.h>
#include <sys/uio.h> /* iovec */
#include <stdlib.h> /* atoi(), malloc(), free() */
#include <sys/uio.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h> /* ntohs */
#include <netinet/in.h>
#include <sys/soundcard.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
......@@ -37,7 +42,7 @@
#include "xconsole.h"
#include "interface.h"
#include "pgm_data.h"
#include "pgm_data.h"*/
/*
* Precalculated 32-bits CRC table, shared by all instances of the PSI decoder
......@@ -50,7 +55,7 @@ u32 i_crc_32_table[256];
* the option (audio and video) passed to the VideoLAN client.
*/
#ifdef AUTO_SPAWN
extern program_data_t *p_program_data;
//??extern program_data_t *p_main;
#endif
/*
......@@ -627,7 +632,7 @@ static void DecodePgrmMapSection( u8* p_pms, input_thread_t* p_input )
{
case MPEG1_VIDEO_ES:
case MPEG2_VIDEO_ES:
if( p_program_data->cfg.b_video )
if( p_main->b_video )
{
/* Spawn a video thread */
input_AddPgrmElem( p_input,
......@@ -636,7 +641,7 @@ static void DecodePgrmMapSection( u8* p_pms, input_thread_t* p_input )
break;
case MPEG1_AUDIO_ES:
case MPEG2_AUDIO_ES:
if( p_program_data->cfg.b_audio )
if( p_main->b_audio )
{
/* Spawn an audio thread */
input_AddPgrmElem( p_input,
......
......@@ -28,6 +28,10 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include "vlc.h"
/*#include <errno.h>
#include <pthread.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
......@@ -60,7 +64,67 @@
#include "interface.h"
#include "intf_msg.h"
#include "pgm_data.h"
#include "pgm_data.h"*/
/*******************************************************************************
* input_vlan_iface_t: vlan-capable network interface
*******************************************************************************
* This structure describes the abilities of a network interface capable of
* vlan management. Note that an interface could have several IP adresses, but
* since only the MAC address is used to change vlan, only one needs to be
* retrieved.
* ?? it could be interesting to send a port id on vlan request, to know if two
* interfaces are dependant regarding vlan changes.
*******************************************************************************/
typedef struct
{
char * psz_name; /* interface name */
struct sockaddr_in sa_in; /* interface IP */
char psz_mac[20]; /* interface MAC */
/* Hardware properties */
int i_master; /* master interface index */
int i_switch; /* switch number */
int i_port; /* port number */
int i_sharers; /* number of MACs on this port */
/* Vlan properties - these are only used if i_master is negative */
int i_refcount; /* locks counter */
int i_vlan; /* current vlan */
int i_default_vlan; /* default vlan */
} input_vlan_iface_t;
/*******************************************************************************
* input_vlan_server_t: vlan server
*******************************************************************************
* This structure describes a vlan server.
*******************************************************************************/
typedef struct
{
struct sockaddr_in sa_in; /* server address */
int i_socket; /* socket descriptor */
/* Login informations */
char * psz_login; /* server login */
char * psz_passwd; /* server password */
} input_vlan_server_t;
/*******************************************************************************
* vlan_method_data_t
*******************************************************************************
* Store global vlan library data.
*******************************************************************************/
typedef struct input_vlan_method_s
{
vlc_mutex_t lock; /* library lock */
/* Server */
input_vlan_server_t server; /* vlan server */
/* Network interfaces */
int i_ifaces; /* number of vlan-compliant interfaces */
input_vlan_iface_t * p_iface; /* interfaces */
} input_vlan_method_t;
/*
* Constants
......@@ -82,16 +146,19 @@ static int ServerRequestInfo ( input_vlan_server_t *p_server,
input_vlan_iface_t *p_iface );
/*******************************************************************************
* input_VlanMethodInit: initialize global vlan method data
* input_VlanCreate: initialize global vlan method data
*******************************************************************************
* Initialize vlan input method global data. This function should be called
* once before any input thread is created or any call to other input_Vlan*()
* function is attempted.
*******************************************************************************/
int input_VlanMethodInit( input_vlan_method_t *p_method, char *psz_server, int i_port )
int input_VlanCreate( void )
{
char * psz_server; // ??? get from environment
int i_port; // ??? get from environment
int i_index; /* interface/servers index */
input_vlan_iface_t * p_iface; /* interfaces */
input_vlan_method_t *p_method = p_main->p_input_vlan; //??
/* Build vlan server descriptor */
if( BuildInetAddr( &p_method->server.sa_in, psz_server, i_port ) )
......@@ -179,14 +246,15 @@ int input_VlanMethodInit( input_vlan_method_t *p_method, char *psz_server, int i
}
/*******************************************************************************
* input_VlanMethodFree: free global vlan method data
* input_VlanDestroy: free global vlan method data
*******************************************************************************
* Free resources allocated by input_VlanMethodInit. This function should be
* called at the end of the program.
*******************************************************************************/
void input_VlanMethodFree( input_vlan_method_t *p_method )
void input_VlanDestroy( void )
{
int i_index; /* server/interface index */
input_vlan_method_t *p_method = p_main->p_input_vlan; // ??
/* Leave all remaining vlans */
for( i_index = 0; i_index < p_method->i_ifaces; i_index++ )
......@@ -222,7 +290,7 @@ int input_VlanId( char *psz_iface, int i_vlan )
input_vlan_method_t * p_method; /* method global data */
int i_index; /* interface index */
p_method = &p_program_data->input_vlan_method;
p_method = p_main->p_input_vlan;
/* If psz_iface is NULL, use first (default) interface (if there is one) */
if( psz_iface == NULL )
......@@ -231,10 +299,10 @@ int input_VlanId( char *psz_iface, int i_vlan )
}
/* Browse all interfaces */
for( i_index = 0; i_index < p_program_data->input_vlan_method.i_ifaces ; i_index++ )
for( i_index = 0; i_index < p_main->p_input_vlan->i_ifaces ; i_index++ )
{
/* If interface has been found, return */
if( !strcmp( p_program_data->input_vlan_method.p_iface[i_index].psz_name, psz_iface ) )
if( !strcmp( p_main->p_input_vlan->p_iface[i_index].psz_name, psz_iface ) )
{
return( VLAN_ID( i_index, i_vlan ) );
}
......@@ -262,7 +330,7 @@ int input_VlanJoin( int i_vlan_id )
/* Initialize shortcuts, and use master if interface is dependant */
i_err = 0;
p_method = &p_program_data->input_vlan_method;
p_method = p_main->p_input_vlan;
p_iface = &p_method->p_iface[ VLAN_ID_IFACE( i_vlan_id ) ];
if( p_iface->i_master >= 0 )
{
......@@ -319,7 +387,7 @@ void input_VlanLeave( int i_vlan_id )
/* Initialize shortcuts, and use master if interface is dependant */
i_err = 0;
p_method = &p_program_data->input_vlan_method;
p_method = p_main->p_input_vlan;
p_iface = &p_method->p_iface[ VLAN_ID_IFACE( i_vlan_id ) ];
if( p_iface->i_master >= 0 )
{
......@@ -348,7 +416,7 @@ int input_VlanRequest( char *psz_iface )
input_vlan_method_t * p_method; /* method global data */
int i_index; /* interface index */
p_method = &p_program_data->input_vlan_method;
p_method = p_main->p_input_vlan;
/* If psz_iface is NULL, use first (default) interface (if there is one) -
* note that interface 0 can't be dependant, so dependance does not need
......@@ -390,8 +458,12 @@ int input_VlanSynchronize( void )
int i_vlan; /* vlan for current interface */
/* Get lock */
p_method = p_main->p_input_vlan;
pthread_mutex_lock( &p_method->lock );
/* ??
p_method = &p_program_data->input_vlan_method;
vlc_mutex_lock( &p_method->lock );
*/
for( i_index = 0; i_index < p_method->i_ifaces; i_index++ )
{
......
......@@ -10,6 +10,9 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include "vlc.h"
/*??
#include <pthread.h>
#include <stdio.h>
#include <netinet/in.h>
#include <sys/soundcard.h>
......@@ -35,137 +38,6 @@
#include "intf_msg.h"
#include "control.h"
#include "pgm_data.h"
#include "pgm_data.h"*/
/*******************************************************************************
* intf_CreateVoutThread: create video output thread in interface
*******************************************************************************
* This function creates - if possible - a new video output thread in the
* interface registery, using interface default settings. It returns the
* thread number for the interface, or a negative number.
* If video is desactivated, nothing will be done. If psz_title is not NULL, it
* will be used as window's title, and width and height will also be used if
* they are positive.
*******************************************************************************/
int intf_CreateVoutThread( intf_thread_t *p_intf, char *psz_title, int i_width, int i_height )
{
#if 0
int i_thread; /* thread index */
video_cfg_t cfg; /* thread configuration */
/* Verify that video is enabled */
if( !p_program_data->cfg.b_video )
{
return( -1 );
}
/* Set configuration */
memcpy( &cfg, &p_program_data->vout_cfg, sizeof( cfg ) );
if( psz_title != NULL )
{
cfg.i_properties |= VIDEO_CFG_TITLE;
cfg.psz_title = psz_title;
}
if( i_width > 0 )
{
cfg.i_properties |= VIDEO_CFG_WIDTH;
cfg.i_width = i_width;
}
if( i_height > 0 )
{
cfg.i_properties |= VIDEO_CFG_HEIGHT;
cfg.i_height = i_height;
}
/* Find an empty place */
for( i_thread = 0; i_thread < VOUT_MAX_THREADS; i_thread++ )
{
if( p_intf->pp_vout[i_thread] == NULL )
{
/* The current place is empty: create a thread */
p_intf->pp_vout[i_thread] = vout_CreateThread( &cfg, NULL );
if( p_intf->pp_vout[i_thread] == NULL ) /* error */
{
return( -1 );
}
}
}
/* No empty place has been found */
return( -1 );
#endif
}
/*******************************************************************************
* intf_DestroyVoutThread: destroy video output thread in interface
*******************************************************************************
* This function destroy a video output thread created with
* intf_CreateVoutThread().
*******************************************************************************/
void intf_DestroyVoutThread( intf_thread_t *p_intf, int i_thread )
{
#if 0
#ifdef DEBUG
/* Check if thread still exists */
if( p_intf->pp_vout[i_thread] == NULL )
{
intf_DbgMsg("intf error: destruction of an inexistant vout thread\n");
return;
}
#endif
/* Destroy thread and marks its place as empty */
vout_DestroyThread( p_intf->pp_vout[i_thread], NULL );
p_intf->pp_vout[i_thread] = NULL;
#endif
}
/*******************************************************************************
* intf_CreateInputThread: create input thread in interface
*******************************************************************************
* This function creates - if possible - a new input thread in the
* interface registery, using interface default settings. It returns the
* thread number for the interface, or a negative number.
*******************************************************************************/
int intf_CreateInputThread( intf_thread_t *p_intf, input_cfg_t* p_cfg )
{
int i_thread; /* thread index */
/* Find an empty place */
for( i_thread = 0; i_thread < INPUT_MAX_THREADS; i_thread++ )
{
if( p_intf->pp_input[i_thread] == NULL )
{
/* The current place is empty: create a thread and return */
p_intf->pp_input[i_thread] = input_CreateThread( p_cfg );
return( (p_intf->pp_input[i_thread] != NULL) ? i_thread : -1 );
}
}
/* No empty place has been found */
return( -1 );
}
/*******************************************************************************
* intf_DestroyInputThread: destroy input thread in interface
*******************************************************************************
* This function destroy aa input thread created with
* intf_CreateInputThread().
*******************************************************************************/
void intf_DestroyInputThread( intf_thread_t *p_intf, int i_thread )
{
#ifdef DEBUG
/* Check if thread still exists */
if( p_intf->pp_input[i_thread] == NULL )
{
intf_DbgMsg("intf error: destruction of an inexistant input thread\n");
return;
}
#endif
/* Destroy thread and marks its place as empty */
input_DestroyThread( p_intf->pp_input[i_thread] );
p_intf->pp_input[i_thread] = NULL;
}
......@@ -9,194 +9,142 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/soundcard.h>
#include <sys/uio.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/uio.h> /* for input.h */
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "thread.h"
#include "debug.h"
#include "input.h"
#include "intf_msg.h"
#include "interface.h"
#include "intf_cmd.h"
#include "intf_console.h"
#include "main.h"
#include "input.h"
#include "input_netlist.h"
#include "input_vlan.h"
#include "decoder_fifo.h"
#include "intf_sys.h"
#include "audio_output.h"
#include "audio_decoder.h"
#include "video.h"
#include "video_output.h"
#include "video_decoder.h"
/*******************************************************************************
* intf_Create: prepare interface before main loop
*******************************************************************************
* This function opens output devices and create specific interfaces. It send
* it's own error messages.
*******************************************************************************/
intf_thread_t* intf_Create( void )
{
intf_thread_t *p_intf;
#include "xconsole.h"
#include "interface.h"
#include "intf_cmd.h"
/* Allocate structure */
p_intf = malloc( sizeof( intf_thread_t ) );
if( !p_intf )
{
errno = ENOMEM;
return( NULL );
}
p_intf->b_die = 0;
intf_DbgMsg( "0x%x\n", p_intf );
/* Initialize structure */
p_intf->p_vout = NULL;
p_intf->p_input = NULL;
#include "pgm_data.h"
/* ?? remove useless headers */
/* Start interfaces */
p_intf->p_console = intf_ConsoleCreate();
if( p_intf->p_console == NULL )
{
intf_ErrMsg("intf error: can't create control console\n");
free( p_intf );
return( NULL );
}
if( intf_SysCreate( p_intf ) )
{
intf_ErrMsg("intf error: can't create interface\n");
intf_ConsoleDestroy( p_intf->p_console );
free( p_intf );
return( NULL );
}
/*
* Local prototypes
*/
static int StartInterface ( intf_thread_t *p_intf );
static void EndInterface ( intf_thread_t *p_intf );
return( p_intf );
}
/*******************************************************************************
* intf_Run
*******************************************************************************
* what it does:
* - Create an X11 console
* - wait for a command and try to execute it
* - interpret the order returned after the command execution
* - print the messages of the message queue (intf_FlushMsg)
* return value: 0 if successful, < 0 otherwise
* Initialization script and main interface loop.
*******************************************************************************/
int intf_Run( intf_thread_t *p_intf )
{
/* When it is started, interface won't die immediatly */
p_intf->b_die = 0;
if( StartInterface( p_intf ) ) /* error */
void intf_Run( intf_thread_t *p_intf )
{
intf_DbgMsg("0x%x begin\n", p_intf );
/* Execute the initialization script - if a positive number is returned,
* the script could be executed but failed */
if( intf_ExecScript( main_GetPszVariable( INTF_INIT_SCRIPT_VAR, INTF_INIT_SCRIPT_DEFAULT ) ) > 0 )
{
return( 1 );
intf_ErrMsg("intf error: error during initialization script\n");
}
/* Main loop */
while(!p_intf->b_die)
{
/* Flush waiting messages */
intf_FlushMsg();
#ifndef FRAMEBUFFER
/* Manage specific interfaces */
intf_ManageXConsole( &p_intf->xconsole ); /* X11 console */
#endif
/* Manage specific interface */
intf_SysManage( p_intf );
/* Sleep to avoid using all CPU - since some interfaces needs to access
* keyboard events, a 100ms delay is a good compromise */
msleep( INTF_IDLE_SLEEP );
}
/* End of interface thread - the main() function will close all remaining
* output threads */
EndInterface( p_intf );
return ( 0 );
intf_DbgMsg("0x%x end\n", p_intf );
}
/* following functions are local */
/*******************************************************************************
* StartInterface: prepare interface before main loop
* intf_Destroy: clean interface after main loop
*******************************************************************************
* This function opens output devices and create specific interfaces. It send
* it's own error messages.
* This function destroys specific interfaces and close output devices.
*******************************************************************************/
static int StartInterface( intf_thread_t *p_intf )
void intf_Destroy( intf_thread_t *p_intf )
{
int i_thread; /* thread index */
#ifdef INIT_SCRIPT
int fd;
#endif
#if 0
/* Empty all threads array */
for( i_thread = 0; i_thread < VOUT_MAX_THREADS; i_thread++ )
{
p_intf->pp_vout[i_thread] = NULL;
}
#endif
for( i_thread = 0; i_thread < INPUT_MAX_THREADS; i_thread++ )
{
p_intf->pp_input[i_thread] = NULL;
}
#ifdef FRAMEBUFFER
intf_DbgMsg("intf debug: not opening X11 console\n");
#else
/* Start X11 Console*/
if( intf_OpenXConsole( &p_intf->xconsole ) )
{
intf_ErrMsg("intf error: can't open X11 console\n");
return( 1 );
}
#endif
intf_DbgMsg("0x%x\n", p_intf );
#ifdef INIT_SCRIPT
/* Execute the initialization script (typically spawn an input thread) */
if ( (fd = open( INIT_SCRIPT, O_RDONLY )) != -1 )
{
/* Startup script does exist */
close( fd );
intf_ExecScript( INIT_SCRIPT );
}
#endif
/* Destroy interfaces */
intf_SysDestroy( p_intf );
intf_ConsoleDestroy( p_intf->p_console );
return( 0 );
/* Free structure */
free( p_intf );
}
/*******************************************************************************
* EndInterface: clean interface after main loop
* intf_SelectInput: change input stream
*******************************************************************************
* This function destroys specific interfaces and close output devices.
* Kill existing input, if any, and try to open a new one. If p_cfg is NULL,
* no new input will be openned.
*******************************************************************************/
static void EndInterface( intf_thread_t *p_intf )
int intf_SelectInput( intf_thread_t * p_intf, input_cfg_t *p_cfg )
{
int i_thread; /* thread index */
boolean_t b_thread; /* flag for remaing threads */
int pi_vout_status[VOUT_MAX_THREADS]; /* vout threads status */
intf_DbgMsg("0x%x\n", p_intf );
/* Kill existing input, if any */
if( p_intf->p_input != NULL )
{
input_DestroyThread( p_intf->p_input /*??, NULL*/ );
p_intf->p_input = NULL;
}
#ifndef FRAMEBUFFER
/* Close X11 console */
intf_CloseXConsole( &p_intf->xconsole );
#endif
/* Destroy all remaining input threads */
for( i_thread = 0; i_thread < INPUT_MAX_THREADS; i_thread++ )
{
if( p_intf->pp_input[i_thread] != NULL )
{
input_DestroyThread( p_intf->pp_input[i_thread] );
}
/* Open new one */
if( p_cfg != NULL )
{
p_intf->p_input = input_CreateThread( p_cfg /*??, NULL*/ );
}
return( (p_cfg != NULL) && (p_intf->p_input == NULL) );
}
#if 0
/* Destroy all remaining video output threads - all destruction orders are send,
* then all THREAD_OVER status are received */
for( i_thread = 0, b_thread = 0; i_thread < VOUT_MAX_THREADS; i_thread++ )
{
if( p_intf->pp_vout[i_thread] != NULL )
{
vout_DestroyThread( p_intf->pp_vout[i_thread], &pi_vout_status[i_thread] );
b_thread = 1;
}
}
while( b_thread )
{
msleep( INTF_IDLE_SLEEP );
b_thread = 0;
for( i_thread = 0; i_thread < VOUT_MAX_THREADS; i_thread++ )
{
if( (p_intf->pp_vout[i_thread] != NULL)
&& (pi_vout_status[i_thread] != THREAD_OVER) )
{
b_thread = 1;
}
}
}
#endif
}
......@@ -10,6 +10,9 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include "vlc.h"
/*
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
......@@ -38,8 +41,7 @@
#include "intf_msg.h"
#include "intf_cmd.h"
#include "intf_ctrl.h"
#include "pgm_data.h"
*/
/*
* Local prototypes
......@@ -111,7 +113,7 @@ int intf_ExecCommand( char *psz_cmd )
case INTF_FATAL_ERROR: /* fatal error */
/* Print message and terminates the interface thread */
intf_ErrMsg( "intf fatal: in command `%s'\n", psz_argv[0] );
p_program_data->intf_thread.b_die = 1;
p_main->p_intf->b_die = 1;
break;
case INTF_CRITICAL_ERROR: /* critical error */
......
/*******************************************************************************
* intf_console.c: generic console for interface
* (c)1998 VideoLAN
*******************************************************************************/
/*******************************************************************************
* Preamble
*******************************************************************************/
#include <stdlib.h>
#include "config.h"
/*******************************************************************************
* intf_console_t: console descriptor
*******************************************************************************
* Generic console object. This object will have a representation depending of
* the interface.
*******************************************************************************/
typedef struct intf_console_s
{
/* Text and history arrays - last line/command has indice 0 */
char * psz_text[INTF_CONSOLE_MAX_TEXT];
char * psz_history[INTF_CONSOLE_MAX_HISTORY];
} intf_console_t;
/*******************************************************************************
* Local prototypes
*******************************************************************************/
/*******************************************************************************
* intf_ConsoleCreate: create console
*******************************************************************************
* This function will initialize the console object.
* It returns NULL on error.
*******************************************************************************/
intf_console_t *intf_ConsoleCreate( void )
{
intf_console_t *p_console;
p_console = malloc( sizeof( intf_console_t ) );
return( p_console );
}
/*******************************************************************************
* intf_ConsoleDestroy
*******************************************************************************
* Destroy the console instance initialized by intf_ConsoleCreate.
*******************************************************************************/
void intf_ConsoleDestroy( intf_console_t *p_console )
{
free( p_console );
}
/*******************************************************************************
* intf_ConsoleClear: clear console
*******************************************************************************
* Empty all text.
*******************************************************************************/
void intf_ConsoleClear( intf_console_t *p_console )
{
//??
}
/*******************************************************************************
* intf_ConsolePrint: print a message to console
*******************************************************************************
* Print a message to the console.
*******************************************************************************/
void intf_ConsolePrint( intf_console_t *p_console, char *psz_str )
{
//??
}
/*******************************************************************************
* intf_ConsoleExec: execute a command in console
*******************************************************************************
* This function will run a command and print its result in console.
*******************************************************************************/
void intf_ConsoleExec( intf_console_t *p_console, char *psz_str )
{
//??
}
/* following functions are local */
......@@ -24,7 +24,8 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include <errno.h>
#include "vlc.h"
/*??#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <stdio.h>
......@@ -67,6 +68,7 @@
#include "intf_ctrl.h"
#include "pgm_data.h"
*/
/*
* Local prototypes
......@@ -309,7 +311,7 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv )
struct stat stat_buffer; /* needed to find out the size of psz_file */
int i_arg; /* argument index */
if ( !p_program_data->cfg.b_audio ) /* audio is disabled */
if ( !p_main->b_audio ) /* audio is disabled */
{
intf_IntfMsg("play-audio error: audio is disabled");
return( INTF_NO_ERROR );
......@@ -383,10 +385,10 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv )
close( i_fd );
/* Now we can work out how many output units we can compute with the fifo */
fifo.l_units = (long)(((s64)fifo.l_units*(s64)p_program_data->aout_thread.dsp.l_rate)/(s64)fifo.l_rate);
fifo.l_units = (long)(((s64)fifo.l_units*(s64)p_main->p_aout->dsp.l_rate)/(s64)fifo.l_rate);
/* Create the fifo */
if ( aout_CreateFifo(&p_program_data->aout_thread, &fifo) == NULL )
if ( aout_CreateFifo(p_main->p_aout, &fifo) == NULL )
{
intf_IntfMsg("play-audio error: can't create audio fifo");
free( fifo.buffer );
......@@ -414,7 +416,7 @@ static int PlayVideo( int i_argc, intf_arg_t *p_argv )
*******************************************************************************/
static int Quit( int i_argc, intf_arg_t *p_argv )
{
p_program_data->intf_thread.b_die = 1;
p_main->p_intf->b_die = 1;
return( INTF_NO_ERROR );
}
......@@ -435,6 +437,7 @@ static int SelectPID( int i_argc, intf_arg_t *p_argv )
switch( p_argv[i_arg].i_index )
{
case 0:
// ?? useless
i_input = p_argv[i_arg].i_num;
break;
case 1:
......@@ -445,20 +448,10 @@ static int SelectPID( int i_argc, intf_arg_t *p_argv )
/* Find to which input this command is destinated */
if(i_input < INPUT_MAX_THREADS )
{
if( p_program_data->intf_thread.pp_input[i_input] )
{
intf_IntfMsg( "Adding PID %d to input %d\n", i_pid, i_input );
input_AddPgrmElem( p_program_data->intf_thread.pp_input[i_input],
i_pid );
return( INTF_NO_ERROR );
}
}
/* No such input was created */
intf_IntfMsg("No such input thread is currently running: %d\n", i_input);
return( INTF_OTHER_ERROR );
intf_IntfMsg( "Adding PID %d to input %d\n", i_pid, i_input );
//???? input_AddPgrmElem( p_main->p_intf->p_x11->p_input,
//???? i_pid );
return( INTF_NO_ERROR );
}
......@@ -528,10 +521,10 @@ static int SpawnInput( int i_argc, intf_arg_t *p_argv )
}
/* Default settings for the decoder threads */
cfg.p_aout = p_program_data->intf_thread.p_aout;
cfg.p_aout = p_main->p_aout;
/* Create the input thread */
if( intf_CreateInputThread( &p_program_data->intf_thread, &cfg ) == -1)
if( intf_SelectInput( p_main->p_intf, &cfg ) == -1)
{
return( INTF_OTHER_ERROR );
}
......@@ -551,15 +544,15 @@ static int Test( int i_argc, intf_arg_t *p_argv )
{
int i_thread;
if( i_argc == 1 )
/*?? if( i_argc == 1 )
{
i_thread = intf_CreateVoutThread( &p_program_data->intf_thread, NULL, -1, -1);
i_thread = intf_CreateVoutThread( &p_main->intf_thread, NULL, -1, -1);
intf_IntfMsg("return value: %d", i_thread );
}
else
else*/
{
i_thread = p_argv[1].i_num;
intf_DestroyVoutThread( &p_program_data->intf_thread, i_thread );
//?? intf_DestroyVoutThread( &p_main->intf_thread, i_thread );
}
return( INTF_NO_ERROR );
......@@ -576,7 +569,7 @@ static int Vlan( int i_argc, intf_arg_t *p_argv )
int i_command; /* command argument number */
/* Do not try anything if vlans are desactivated */
if( !p_program_data->cfg.b_vlans )
if( !p_main->b_vlans )
{
intf_IntfMsg("vlans are desactivated");
return( INTF_OTHER_ERROR );
......@@ -629,19 +622,7 @@ static int Psi( int i_argc, intf_arg_t *p_argv )
{
int i_index = p_argv[1].i_num;
if(i_index < INPUT_MAX_THREADS )
{
if(p_program_data->intf_thread.pp_input[i_index])
{
/* Read the Psi table for that thread */
intf_IntfMsg("Reading PSI table for input %d\n", i_index);
input_PsiRead(p_program_data->intf_thread.pp_input[i_index]);
return( INTF_NO_ERROR );
}
}
/* No such input was created */
intf_IntfMsg("No such input thread is currently running: %d\n", i_index);
return( INTF_OTHER_ERROR );
intf_IntfMsg("Reading PSI table for input %d\n", i_index);
//???? input_PsiRead(p_main->p_intf->p_x11->p_input );
return( INTF_NO_ERROR );
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -8,6 +8,10 @@
/*******************************************************************************
* Preamble
*******************************************************************************/
#include "vlc.h"
/*#include <errno.h>
#include <pthread.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
......@@ -23,13 +27,15 @@
#include "vlc_thread.h"
#include "intf_msg.h"
#include "debug.h" /* ?? temporaire, requis par netlist.h */
#include "debug.h"
#include "input.h"
#include "input_netlist.h"
#include "decoder_fifo.h"
#include "video.h"
#include "video_output.h"
#include "video_decoder.h"*/
#include "vdec_idct.h"
#include "video_decoder.h"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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