Commit 72f3067a authored by Michel Kaempf's avatar Michel Kaempf

Initial revision

parents
################################################################################
# vlc (VideoLAN Client) main makefile
# (c)1998 VideoLAN
################################################################################
# This makefile is the main makefile for the VideoLAN client.
################################################################################
################################################################################
# Configuration
################################################################################
#CC = gcc
#SHELL = /bin/sh
################################################################################
# Settings and other variables
################################################################################
#
# C headers directories
#
INCLUDE += -Iinclude
INCLUDE += -I/usr/X11R6/include/X11
#
# Libraries
#
LIB += -L/usr/X11R6/lib
LIB += -lX11
LIB += -lXext
LIB += -lpthread
LIB += -lXpm
#
# C compiler flags: compilation
#
CCFLAGS += $(INCLUDE)
CCFLAGS += -Wall
CCFLAGS += -D_REENTRANT
CCFLAGS += -D_GNU_SOURCE
# Optimizations : don't compile debug versions with them
#CCFLAGS += -O8
#CCFLAGS += -s -fargument-noalias-global -fexpensive-optimizations -ffast-math -funroll-loops -fomit-frame-pointer #-march=pentiumpro
#(Uncomment -march=pentiumpro if it applies)
#
# C compiler flags: dependancies
#
DCFLAGS += $(INCLUDE)
DCFLAGS += -MM
#
# C compiler flags: linking
#
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.*\.\.\."
#
# C compiler flags: common flags
#
# CFLAGS
#
# Additionnal debugging flags
#
# Debugging settings: electric fence, debuging symbols and profiling support.
# Note that electric fence and accurate profiling are quite uncompatible.
CCFLAGS += -g
#CCFLAGS += -pg
#LIB += -ldmalloc
#LIB += -lefence
#################################################################################
# Objects and files
#################################################################################
#
# Objects
#
interface_obj = interface/main.o \
interface/interface.o \
interface/intf_msg.o \
interface/intf_cmd.o \
interface/intf_ctrl.o \
interface/control.o \
interface/xconsole.o
input_obj = input/input_vlan.o \
input/input_file.o \
input/input_netlist.o \
input/input_network.o \
input/input_ctrl.o \
input/input_pcr.o \
input/input_psi.o \
input/input.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
audio_decoder_obj = audio_decoder/audio_decoder.o
generic_decoder_obj = generic_decoder/generic_decoder.o
video_decoder_obj = video_decoder/video_decoder.o
misc_obj = misc/mtime.o \
misc/xutils.o \
misc/rsc_files.o \
misc/netutils.o
OBJ = $(interface_obj) \
$(input_obj) \
$(audio_output_obj) \
$(video_output_obj) \
$(audio_decoder_obj) \
$(generic_decoder_obj) \
$(video_decoder_obj) \
$(vlan_obj) \
$(misc_obj)
#
# Other lists of files
#
sources := $(OBJ:%.o=%.c)
dependancies := $(sources:%.c=dep/%.d)
# All symbols must be exported
export
################################################################################
# Targets
################################################################################
#
# Virtual targets
#
all: vlc
clean:
rm -f $(OBJ)
distclean: clean
rm -f **/*.o **/*~ *.log
rm -f vlc gmon.out core Documentation/cflow
rm -rf dep
FORCE:
#
# Real targets
#
vlc: $(OBJ)
$(CC) $(LCFLAGS) $(CFLAGS) -o $@ $(OBJ)
Documentation/cflow: $(sources)
cflow $(FCFLAGS) $(CFLAGS) $(sources) | $(FFILTER) > $@
#
# Generic rules (see below)
#
$(dependancies): %.d: FORCE
@make -s --no-print-directory -f Makefile.dep $@
$(OBJ): %.o: dep/%.d
$(OBJ): %.o: %.c
$(CC) $(CCFLAGS) $(CFLAGS) -c -o $@ $<
################################################################################
# Note on generic rules and dependancies
################################################################################
# Note on dependancies: each .c file is associated with a .d file, which
# depends of it. The .o file associated with a .c file depends of the .d, of the
# .c itself, and of Makefile. The .d files are stored in a separate dep/
# directory.
# The dep directory should be ignored by CVS.
# Note on inclusions: depending of the target, the dependancies files must
# or must not be included. The problem is that if we ask make to include a file,
# and this file does not exist, it is made before it can be included. In a
# general way, a .d file should be included if and only if the corresponding .o
# needs to be re-made.
# Two makefiles are used: the main one (this one) has regular generic rules,
# except for .o files, for which it calls the object Makefile. Dependancies
# are not included in this file.
# The object Makefile known how to make a .o from a .c, and includes dependancies
# for the target, but only those required.
################################################################################
# vlc (VideoLAN Client) dependancies makefile
# (c)1998 VideoLAN
################################################################################
# This Makefile is dedicated to build of .d files. It should not be called
# directly by user, but only through main Makefile.
# See notes at the end of the main makefile for explanations.
################################################################################
# All settings and options are passed through main Makefile
################################################################################
# Default target
################################################################################
default:
@echo "This Makefile should not be called directly - see notes at end of"
@echo "main Makefile."
################################################################################
# Dependancies creation
################################################################################
# A dependancies file needs to be rebuilt if the .c changed or if one of the
# dependancies files have been changed. In other words, it depends from the
# .c and from itself.
-include $(MAKECMDGOALS)
$(dependancies): dep/%.d: %.c
@test -d dep/$(dir $*) || mkdir -p dep/$(dir $*)
@echo "generating dependancies for $*.c"
@$(SHELL) -ec '$(CC) $(DCFLAGS) $(CFLAGS) $< \
| sed '\''s/$(subst .,\.,$(notdir $*))\.o[ :]*/$(subst /,\/,$*).o \
dep\/$(subst /,\/,$*).d : /g'\'' > $@; \
[ -s $@ ] || rm -f $@'
* interface :
Il semble que si l'on envoie 2 messages de logs l'un immediatement apres
l'autre, le 2e ne soit jamais affiche (cf debut du DemuxPES)
* video output/X11 :
quand une XShmImage n'a jamais été affichée, la fermer provoque une erreur
(fatale ?) du serveur -> plantage de vout_thread.
* video output/X11 :
erreur lors de la fermeture 'brutale' de la fenêtre
Ptyx: en cours de correction - j'ai trouvé comment signaler au WM qu'une
fenêtre est capable de se fermer propremenet sur un ClientMessage, mais
pas encore comment intercepter ce ClientMessage :-\
* interface :
l'envoi repeté de commandes dans la console provoque un
segfault
Ptyx: ce bug est du à la xconsole, qu'il faudra de toute manière
reprogrammer avec un widget quelconque (je recommande wx, qui est portable,
mais moche il est vrai), donc je vais pas me casser à le corriger.
Ptyx: vérifier qu'il est bien du à xconsole et non à intf_ExecCommand :-\
* input :
= segfault au `quit' lorsqu'un thread input et un thread décodeur sont
spawnés (MaXX)
- Meuuh et MaXX: le thread input demande à ses décodeurs de se tuer
et se tue immédiatement, sans attendre leur mort effective, alors
que ces décodeurs accèdent encore à sa structure
= le flag b_random_access est activé dans tous les paquets PES (MaXX)
= le flag b_data_alignment n'est activé dans aucun paquet PES (MaXX)
* input :
= lorsque le pid 120 est sélectionné le vlc segfaulte (MaXX)
%
% common.tex: common definitions for LaTeX files.
% (c)1999 VideoLAN
%
% Included packages
\usepackage{alltt}
% C-related commands
\newcommand{\csymbol}[1]{\texttt{#1}}
% C-related environments
\newenvironment{csource}
{\begin{alltt}}
{\end{alltt}}
- Pas de tabulations dans les sources
- Pas de include dans les headers sauf all.h
- Utiliser systématiquement NULL pour les pointeurs nuls, et non pas 0
- Eviter le if( (a=toto()) != b ), preferer l'ecriture sur 2 lignes, en
particulier pour les malloc(s):
a = toto();
if( a != b )
- A propos des mallocs, plus une remarque qu'une convention: il n'est
spécifié nul part que errno est mis à jour si malloc renvoie NULL.
Préférez donc strerror(ENOMEM) à strerror(errno) !
Schma de dpendance des headers et rgles d'criture
=====================================================
Ce document dcrit les dpendances entre les diffrents headers utiliss
par le projet, ainsi que l'ordre dans lequel ils devraient tre appels.
La totalit de ces headers, dans l'ordre, est regroup dans le fichier
"all.h", pour faciliter la mise en place de nouvelles structures.
Les headers inscrits entre parenthses sont ncessaires indirectement.
Merci de maintenir ce fichier jour.
Headers systmes (appels par ordre de repertoire et alphabetique)
------------------------------------------------------------------
#include <pthread.h>
#include <netinet/in.h>
#include <sys/soundcard.h>
#include <sys/uio.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include <X11/xpm.h>
Headers communs
---------------
#include "config.h"
#include "common.h" -> may depend of "config.h"
#include "mtime.h"
#include "netutils.h" -> <netinet/in.h>
#include "xutils.h" -> <X11/Xlib.h>
Input
-----
#include "input.h" -> <pthread.h>, <sys/uio.h>, "config.h", "common.h"
#include "input_vlan.h" -> <pthread>, <netinet/in.h>
#include "decoder_fifo.h" -> <pthread.h>, (<sys/uio.h>), ("config.h"), ("common.h"), "input.h"
#include "netlist.h" -> <prhtread.h>, (<sys/uio.h>), "config.h", ("common.h"), "input.h"
#include "pcr.h" -> (<pthread.h>), (<sys/uio.h>), ("config.h"), ("common.h"), "input.h"
#include "psi.h" -> (<pthread.h>), (<sys/uio.h>), ("config.h"), ("common.h"), "input.h"
Audio
-----
#include "audio_decoder.h" -> *le nant :)*
#include "audio_output.h" -> <pthread.h>, <sys/soundcard.h>, "config.h", "common.h", "mtime.h"
#include "audio_dsp.h" -> (<pthread.h>), (<sys/soundcard.h>), ("config.h"), ("common.h"),
("mtime.h"), "audio_output.h"
Video
-----
#include "video.h" -> ("config.h"), "common.h", "mtime.h"
#include "video_graphics.h" -> ("config.h"), ("common.h"), ("mtime.h"), "video.h"
#include "video_output.h" -> <pthread.h>, "config.h", "common.h", ("mtime.h"), "video.h"
#include "video_x11.h" -> (<pthread.h>) <X11/Xlib.h>, <X11/extensions/XShm.h>,
("config.h"), ("common.h"), ("mtime.h"), "video.h", "video_output.h"
#include "video_decoder.h" -> <pthread.h>, (<sys/uio.h>), ("config.h"), "common.h", ("mtime.h"),
"input.h", "decoder_fifo.h", ("video.h"), "video_output.h"
Interface
---------
#include "xconsole.h" -> <X11/Xlib.h>, "config.h"
#include "interface.h" -> (<pthread.h>), (<sys/uio.h>), (<X11/Xlib.h>),
(<X11/extensions/XShm.h>), "config.h", "common.h", ("mtime.h"),
"input.h", ("video.h"), "video_output.h", "xconsole.h"
#include "intf_msg.h" -> <pthread.h>, "config.h", "common.h", "mtime.h"
#include "intf_cmd.h"
#include "control.h" -> ??
#include "intf_ctrl.h" -> "intf_cmd.h"
Ressources partages
--------------------
#include "pgm_data.h" -> (<pthread.h>), (<netinet/in.h>), (<sys/soundcard.h>), (<sys/uio.h>),
(<X11/Xlib.h>),
(<X11/extensions/XShm.h>), ("config.h"), "common.h", ("mtime.h"),
"input.h", "input_vlan.h", "audio_output.h" , "video.h",
("video_output.h"), "xconsole.h", "interface.h", "intf_msg.h"
Autres headers, qui sont condamns disparaitre ou ne sont pas utiliss
------------------------------------------------------------------------
#include "network.h" illisible, uniquement utilis dans network.c
#include "rsc_files.h"
xconsole will also change
%
% main.tex: structure of the vlc LaTeX documentation
% (c)1999 VideoLAN
%
\documentclass[a4paper]{report}
%
% Packages and definitions
%
\usepackage{graphicx}
\include{common}
\newcommand{\VideoLAN}{\textit{Video}\textsc{lan}}
%
% Document
%
\begin{document}
% Title page and table of contents
\begin{titlepage}
\VideoLAN project
\begin{center}
\resizebox{\textwidth}{!}{vlc: the \VideoLAN\ client}
\bigskip
a real-time MPEG-2 software decoder and player
\end{center}
\end{titlepage}
\tableofcontents
% General description of the project
\part{General description}
\chapter{The goal}
\chapter{??}
\chapter{vlc: the \VideoLAN\ client}
\chapter{Continuation of the project}
% Project organization
\part{Project organization}
\chapter{Team and communication}
\chapter{Source control}
\chapter{Coding conventions}
\include{threads}
% Code description
\part{Code description}
\end{document}
This diff is collapsed.
FreeBSD:
-#ifdef __FreeBSD__
-remplacer les sys/soundcard.h par machine/soundcard.c
-problme avec getopt
LinuxPPC:
-problme avec la libpthreads ? (ou avec le serveur X ?)
%
% threads.tex: description of threads interface for VideoLAN client
% (c)1999 VideoLAN
%
\section{A common thread interface}
This document describes how the different threads in the VideoLAN client are
organized, their API and functionnment.
%
% Thread properties
%
\subsection{Thread properties}
A thread is described by a \csymbol{X\_thread\_t} structure (i.e.
\csymbol{vout\_thread\_t}), which is used to reference the thread in calls to
its API. This structure includes beside following thread-specific data the
following fields:
\begin{csource}
typedef struct X_thread_s \{
pthread_t thread_id; /* thread id for pthreads */
boolean_t b_die; /* `die' flag */
boolean_t b_run; /* `run' flag */
boolean_t b_error; /* `error' flag */
boolean_t b_active; /* `active' flag */
... other fields ...
\} X_thread_t;
\end{csource}
%
% Meaning of common flags
%
\subsection{Meaning of common flags}
\begin{description}
\item[\csymbol{die}]:
The \csymbol{die} flag means that the thread received a destruction request
from another thread. It must terminate as soon as possible. This field is
written (set to 1) by other threads and read by the thread itself. It cannot
be reset to 0 once it has been set.
Note that when the \csymbol{die} flag is set, no other thread should feed the
dying one, and all shared structures should have been freed (i.e. the images
and video streams for the video output thread).
\item[\csymbol{run}]:
The \csymbol{run} flag tells the other threads that the concerned thread is
ready to receive data. It is set to 1 by the thread itself when the second
phase of the initialization has succeeded, and set to 0 again by the thread
once it exited.
\item[\csymbol{error}]:
The \csymbol{error} flag tells the other threads that a fatal error occured in
the concerned thread. It can be set by all threads, and is read by the thread
itself and the controlling thread.
When a thread is in \csymbol{error} state, it runs in a special loop,
accepting feed from other threads, but trashing eveything, waiting for a
\csymbol{die} signal.
Therefore, the controlling thread should check periodically if a thread has an
\csymbol{error} set and, if yes, set its \csymbol{die} flag after having
destroyed all depending threads.
This flag is optionnal, but recommanded if an error can be envisaged in a later
extension.
\item[\csymbol{active}]:
This flag's purpose is to avoid using useless resources. An in-\csymbol{active}
thread must accept input as if it was inactive, but can treat its input
differently.
In example: the video output thread will set itself as in-\csymbol{active}
when it is unmapped, and continue to sort and trash images, but will not
render or display them to avoid consumming useless CPU. When a video decoder
thread will detect that its related output thread is inactive, it will set
itself inactive and trash everything except I images.
The \csymbol{active} flag can be set and read by anyone. Precautions should be
taken to avoid too long wake-up times.
This flag is optionnal, but recommanded if its use can be envisaged in a later
extension.
\end{description}
%
% API
%
\subsection{API}
This API is only a recommandation.
% Creation
\subsubsection{Creation}
\begin{csource}
X_thread_t * X_CreateThread( X_cfg_t *p_cfg )
\end{csource}
This function will allocate thread descriptor, perform basic (and fast)
initialization steps, and create the thread itself using
\csymbol{pthread\_create}.
Once it has been called, all flags are set to 0. It will return the thread
descriptor or \csymbol{NULL} on failure.
% Termination
\subsubsection{Termination}
\begin{csource}
void X_TerminateThread( X_thread_t * p_X );
\end{csource}
This function will set the \csymbol{die} flag of the thread and and return
immediately.
% Destruction
\subsubsection{Destruction}
\begin{csource}
int X_DestroyThread( X_thread_t *p_X );
\end{csource}
This function will try to destroy the thread descriptor, if it is possible
(if the \csymbol{run} flag is not set). It will return 0 if it succeeded,
and non 0 if the thread was still active.
%
% Local functions names
%
\subsection{Local functions names}
The following functions names are recommanded to implement the different
parts of the thread creation and destruction:
\begin{csource}
int InitThread(); /* second phase of initialization */
int RunThread(); /* main loop */
int RunError(); /* error loop */
int DestroyThread(); /* thread destruction */
\end{csource}
\csymbol{X\_CreateThread()} will spawn a thread using \csymbol{RunThread()}
function, which will call \csymbol{InitThread()}, enter its main loop,
eventually call \csymbol{RunError()} and finally calls \csymbol{DestroyThread}
when \csymbol{die} is received.
%
% Order of operations
%
\subsection{Order of operations}
% Creation
\subsubsection{Creation}
\begin{tabular}{l|l}
Controlling thread & Thread \\
\hline
\csymbol{p\_X = X\_CreateThread( p\_cfg )}: & \\
descriptor allocation and initialization & \\
all flags are set to 0 & \\
base structures initialization & \\
If \csymbol{p\_X == NULL}: error & \\
\csymbol{X\_DestroyThread( p\_X )}: & \\
destruction of the descriptor & \\
end...
Else, continuation.... & \csymbol{pthread\_create()} \\
& Second step of initialization \\
& On error: \\
& \csymbol{b\_error = 1} \\
& destruction of structures \\
& Else: \\
& \csymbol{b\_run = 1} \\
& beginning of main loop \\
\hline
Wait for \csymbol{b\_run} or \csymbol{b\_error}...& main loop... \\
If \csymbol{b\_error}: & \\
\csymbol{X\_DestroyThread( p\_X )} & \\
end... & \\
Else (\csymbol{b\_run == 1}): & \\
the thread is ready and can be feeded... & \\
\hline
\end{tabular}
Notes:
\begin{enumerate}
\item The configuration structure can have been destroyed just after
\csymbol{X\_CreateThread()}. Therefore, it should not be used during second
initialization step.
\item When an error occurs during second initialization step, the allocated structures
are automatically destroyed (except the thread descriptor). Therefore, a call to
\csymbol{X\_TerminateThread} is not required.
\end{enumerate}
% Main loop
\subsubsection{Main loop}
\begin{tabular}{l|l}
Controlling thread & Thread \\
\hline
Periodically check for \csymbol{b\_error} & Periodically check for \\
If set, then: & \csymbol{b\_error} and \csymbol{b\_die}\\
terminate all dependant threads & \\
destroy all dependant threads & \\
terminate and destroy thread & \\
\hline
\end{tabular}
% Destruction
\subsubsection{Destruction}
\begin{tabular}{l|l}
Controlling thread & Thread \\
\hline
\csymbol{X\_TerminateThread( p\_X )}: & \\
set \csymbol{b\_die} & \\
all flags are set to 0 & If \csymbol{DEBUG}, check if \\
& all shared structures are ok. \\
& Destroy and close everything, but \\
& keep descriptor. \\
& Set \csymbol{b\_run} to 0. \\
& Exit thread. \\
\hline
Loop until \csymbol{X\_DestroyThread} is 0: & \\
check if \csymbol{b\_run == 0} & \\
if yes: & \\
destroy descriptor & \\
return 0 & \\
else: & \\
return 1 & \\
\hline
\end{tabular}
-----------------------------------------------------------------------------
* marque les points prioritaires
+ les points à ne pas oublier avant la fin de l'année
- les trucs qu'il faudra faire, mais qui ne sont pas urgent
? les idées à discuter
-----------------------------------------------------------------------------
Input
=====
? utilisation de la NAT pour convoyer des infos sur les vlans
* gestion du décodeur générique/par défaut
- passage en b_run
+ trouver des flux de test bien tordus pour tester l'update des
PSI, les discontinuites, la gestion des PCR, etc...
Input: vlan method
==================
+ faire une libvlan rapide (benny est dessus)
- reconcevoir l'API et les dialogues du vlan serveur, faire une
libvlan avancée, l'encapsuler proprement dans input_vlan,
refaire le vlan server
Main
====
- lire un fichier de config en plus de la ligne de commande
Audio output
============
- detection automatique du materiel
? penser à une nouvelle manière de remplir le buffer de sortie, tout en
conservant l'algorithme de rééchantillonage...
Audio decoder
=============
* tout tout tout
Video output
============
+ nettoyer la boucle principale
+ tenir compte du fait que lorsque b_die est mis, normalement tous
les flux et images doivent déjà être detruits -> afficher une
erreur plutôt que de les supprimer
+ gestion de b_active
+ arbre de décisions avec goto pour les passes
* convertion et affichage des images
* gestion des couleurs X11
? interpolation pour des display ratios < 1
? utiliser XDGA pour accelerer
Video graphics
==============
+ tout reste à implementer
+ rajouter les convertions rgb->pixel
Video decoder
=============
* tout tout tout
+ sur p_vout->b_active == 0, trasher tout sauf I
* parser/trasher de PES
Generic decoder
===============
* identification des paquets
* sauvegarde d'un flux multiplexé
* sauvegarde de flux demultiplexés
Interface
=========
- incrustation d'infos sur les buffers
+ réagir aux signaux
Interface: commandes
====================
- Plein de commandes à implémenter
Interface: console
==================
- Utiliser un widget quelconque (portable de préférence) et renommer
en intf_console si la portabilité est atteinte (sinon, x11console).
- Utilisation des pixmaps pour egayer un peu en début de ligne
- Gestion des fontes et couleurs
- Choix d'une couleur de bg en l'absende de pixmap
- Ascenceur pour la zone de texte
- Unicité des enregistrements de l'history - sauvegarde de l'history
- Gestion de la souris (copier/coller)
General: sources
================
+ déclarer en extern inline les fonctions de mtime et netlist...
- Eliminer les headers superflus des sources, bien indiquer les dépendances
- conserver la cohérence des sources: input_psi plutot que psi par exemple.
+ vérifier que des messages sont bien émis partout (faire une recherche sur
les 'returns'... En particulier dans video_output).
General: processus
==================
* définir l'ordre de fermeture et les accès
- identifier les threads (pour ps)
? penser au mode mono-thread
+ utiliser les messages b_die, b_error, b_active et b_run
General: X11
============
- detection de fermeture des fenêtres
- déclaration des icones pour les window managers
- implémentation de X{En|Dis}ableScreenSaver dans xutils
Documentation
=============
- documentation des interfaces de programmation dès qu'elles sont
au point. En LaTeX ? (pour latex2html).
Vlan server protocol and library *draft*
========================================
telnet-based protocol. Client commands are text, server responses are numbers followed by
an explicative text (like irc). Common messages number should probalbly be grouped.
Two different notions: session and connexion
session has a long timeout (several hours), and should not use server-side resources
connexion has a short timeout (a few minutes) and can use server-side resources (thread)
A vlan resource (switch+port) is identified by a unique id. Changes can obviously be done
with this id, but also, for administrative facilities, with other identifiers.
Client commands:
LOGIN <login> [<application>]
-> open connexion, required before any communication with server. Login and password should
correspond to groups (admin, users...) rather than individual ids. Application is for stats.
answers: 100: ok
101: rejected, invalid login
102: rejected, too many connexions
103: rejected, forbidden source
104: rejected, already logged in
109: rejected, other reason
password required
PASS <password>
LOGOUT -> close connexion
answer: 200: ok, session closed
OPEN <client-session-id>
-> open session. required before any write operations
answers: 300: <server-session-id>
301: rejected, not authorized
302: rejected, too many sessions
399: rejected, other reason
RECOVER <client-session-id> <server-session-id>
-> recover session. Both id are required for security.
answer: 400: ok
401: rejected, not authorized (invalid login or something else)
402: rejected, invalid ids
403: rejected, session already active on another connexion
499: rejected, other reason
CLOSE [<server-session-id>]
-> close session. Session must be active for normal users.
answer: 500: ok, session closed
501: error, not loged in
502: error: active session
503: error: not authorized
STATUS ME
STATUS MAC <mac>
STATUS IP <ip>
STATUS ID <rsc-id>
give informations about something
answer: 600: mark beginning of status info
601: mark end of status info
602: error, not authorized
603: error, unknown
604: error, request failed
610: <rsc-id>
611: <vlan>
612: <ip>
613: <mac>
614: <switch-ip>
615: <switch-port>
616: <number of interfaces dependant of this resource>
617: <lock info>
699: error, other reason
LOCK ME
LOCK MAC <mac>
LOCK IP <ip>
LOCK ID <rsc-id>
lock a resource id (session required)
answers:
UNLOCK ME
UNLOCK MAC <mac>
UNLOCK IP <ip>
UNLOCK ID <id>
unlock a resource id (session required)
answers:
CHANGE ME <vlan>
CHANGE MAC <mac> <vlan>
CHANGE IP <ip> <vlan>
CHANGE ID <id> <vlan>
change a vlan (session required)
Administrative commands:
HELP
print list of commands
answer:
KICK
RESET
LIST IDS
LIST MACS
LIST IPS
LIST SESSIONS
LIST CONNECTIONS
LIST LOGINS
QUIT
CONFIRM
/*******************************************************************************
* all.h: all headers
* (c)1998 VideoLAN
*******************************************************************************
* This header includes all vlc .h headers and depending headers. A source file
* including it would also be able to use any of the structures of the project.
* Note that functions or system headers specific to the file itself are not
* included.
*******************************************************************************
* required headers:
* none
*******************************************************************************/
/* System headers */
#include <pthread.h>
#include <netinet/in.h>
#include <sys/soundcard.h>
#include <sys/uio.h>
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
/* Common headers */
#include "config.h"
#include "common.h"
#include "mtime.h"
/* Input */
#include "input.h"
#include "input_vlan.h"
#include "decoder_fifo.h"
/* Audio */
#include "audio_output.h"
#include "audio_decoder.h"
/* Video */
#include "video.h"
#include "video_output.h"
#include "video_decoder.h"
/* Interface */
#include "xconsole.h"
#include "interface.h"
#include "intf_msg.h"
/* Shared resources */
#include "pgm_data.h"
This diff is collapsed.
This diff is collapsed.
/******************************************************************************
* audio_dsp.h : header of the dsp functions library
* (c)1999 VideoLAN
******************************************************************************
* Required headers:
* - "common.h" ( byte_t )
* - "audio_output.h" ( aout_dsp_t )
******************************************************************************/
/******************************************************************************
* Prototypes
******************************************************************************/
int aout_dspOpen ( aout_dsp_t *p_dsp );
int aout_dspReset ( aout_dsp_t *p_dsp );
int aout_dspSetFormat ( aout_dsp_t *p_dsp );
int aout_dspSetChannels( aout_dsp_t *p_dsp );
int aout_dspSetRate ( aout_dsp_t *p_dsp );
void aout_dspGetBufInfo ( aout_dsp_t *p_dsp );
void aout_dspPlaySamples( aout_dsp_t *p_dsp, byte_t *buffer, int i_size );
void aout_dspClose ( aout_dsp_t *p_dsp );
/******************************************************************************
* audio_output.h : audio output thread interface
* (c)1999 VideoLAN
******************************************************************************
* Required headers:
* - <pthread.h> ( pthread_t )
* - <sys/soundcard.h> ( audio_buf_info )
* - "common.h" ( boolean_t )
* - "mtime.h" ( mtime_t )
******************************************************************************/
/* TODO :
*
* - Créer un flag destroy dans les fifos audio pour indiquer au thread audio
* qu'il peut libérer la mémoire occupée par le buffer de la fifo lorsqu'il
* le désire (fin du son ou fin du thread)
* - Redéplacer les #define dans config.h
*
*/
/*
* Defines => "config.h"
*/
/* Default output device. You probably should not change this. */
#define AOUT_DEFAULT_DEVICE "/dev/dsp"
/* Default audio output format (AFMT_S16_NE = Native Endianess) */
#define AOUT_DEFAULT_FORMAT AFMT_S16_NE
/* Default stereo mode (0 stands for mono, 1 for stereo) */
#define AOUT_DEFAULT_STEREO 1
/* Audio output rate, in Hz */
#define AOUT_MIN_RATE 22050 /* ?? */
#define AOUT_DEFAULT_RATE 44100
#define AOUT_MAX_RATE 48000
/* Number of audio samples (s16 integers) contained in an audio output frame...
* - Layer I : a decoded frame contains 384 samples
* - Layer II & III : a decoded frame contains 1192 = 3*384 samples */
#define AOUT_FRAME_SIZE 384
/* Number of audio output frames contained in an audio output fifo.
* (AOUT_FIFO_SIZE + 1) must be a power of 2, in order to optimise the
* %(AOUT_FIFO_SIZE + 1) operation with an &AOUT_FIFO_SIZE.
* With 511 we have at least 511*384/2/48000=2 seconds of sound */
#define AOUT_FIFO_SIZE 511
/* Maximum number of audio fifos. The value of AOUT_MAX_FIFOS should be a power
* of two, in order to optimize the '/AOUT_MAX_FIFOS' and '*AOUT_MAX_FIFOS'
* operations with '>>' and '<<' (gcc changes this at compilation-time) */
#define AOUT_MAX_FIFOS 4
/* Duration (in microseconds) of an audio output buffer should be :
* - short, in order to be able to play a new song very quickly (especially a
* song from the interface)
* - long, in order to perform the buffer calculations as few as possible */
#define AOUT_BUFFER_DURATION 100000
/*
* Macros
*/
#define AOUT_FIFO_ISEMPTY( fifo ) ( (fifo).l_end_frame == (fifo).i_start_frame )
#define AOUT_FIFO_ISFULL( fifo ) ( ((((fifo).l_end_frame + 1) - (fifo).l_start_frame) & AOUT_FIFO_SIZE) == 0 )
/******************************************************************************
* aout_dsp_t
******************************************************************************/
typedef struct
{
/* Path to the audio output device (default is set to "/dev/dsp") */
char * psz_device;
int i_fd;
/* Format of the audio output samples (see <sys/soundcard.h>) */
int i_format;
/* Following boolean is set to 0 if output sound is mono, 1 if stereo */
boolean_t b_stereo;
/* Rate of the audio output sound (in Hz) */
long l_rate;
/* Buffer information structure, used by aout_dspGetBufInfo() to store the
* current state of the internal sound card buffer */
audio_buf_info buf_info;
} aout_dsp_t;
/******************************************************************************
* aout_increment_t
******************************************************************************
* This structure is used to keep the progression of an index up-to-date, in
* order to avoid rounding problems and heavy computations, as the function
* that handles this structure only uses additions.
******************************************************************************/
typedef struct
{
/* The remainder is used to keep track of the fractional part of the
* index. */
long l_remainder;
/*
* The increment structure is initialized with the result of an euclidean
* division :
*
* l_euclidean_numerator l_euclidean_remainder
* ----------------------- = l_euclidean_integer + -----------------------
* l_euclidean_denominator l_euclidean_denominator
*
*/
long l_euclidean_integer;
long l_euclidean_remainder;
long l_euclidean_denominator;
} aout_increment_t;
/******************************************************************************
* aout_frame_t
******************************************************************************/
typedef s16 aout_frame_t[ AOUT_FRAME_SIZE ];
/******************************************************************************
* aout_fifo_t
******************************************************************************/
typedef struct
{
/* See the fifo types below */
int i_type;
boolean_t b_die;
boolean_t b_stereo;
long l_rate;
pthread_mutex_t data_lock;
pthread_cond_t data_wait;
void * buffer;
mtime_t * date;
/* The start frame is the first frame in the buffer that contains decoded
* audio data. It it also the first frame in the current timestamped frame
* area, ie the first dated frame in the decoded part of the buffer. :-p */
long l_start_frame;
boolean_t b_start_frame;
/* The next frame is the end frame of the current timestamped frame area,
* ie the first dated frame after the start frame. */
long l_next_frame;
boolean_t b_next_frame;
/* The end frame is the first frame, after the start frame, that doesn't
* contain decoded audio data. That's why the end frame is the first frame
* where the audio decoder can store its decoded audio frames. */
long l_end_frame;
long l_unit;
aout_increment_t unit_increment;
/* The following variable is used to store the number of remaining audio
* units in the current timestamped frame area. */
long l_units;
} aout_fifo_t;
#define AOUT_EMPTY_FIFO 0
#define AOUT_INTF_MONO_FIFO 1
#define AOUT_INTF_STEREO_FIFO 2
#define AOUT_ADEC_MONO_FIFO 3
#define AOUT_ADEC_STEREO_FIFO 4
/******************************************************************************
* aout_thread_t
******************************************************************************/
typedef struct aout_thread_s
{
pthread_t thread_id;
boolean_t b_die;
aout_dsp_t dsp;
pthread_mutex_t fifos_lock;
aout_fifo_t fifo[ AOUT_MAX_FIFOS ];
void * buffer;
/* The s32 buffer is used to mix all the audio fifos together before
* converting them and storing them in the audio output buffer */
s32 * s32_buffer;
/* The size of the audio output buffer is kept in audio units, as this is
* the only unit that is common with every audio decoder and audio fifo */
long l_units;
mtime_t date;
/* date is the moment where the first audio unit of the output buffer
* should be played and is kept up-to-date with the following incremental
* structure */
aout_increment_t date_increment;
} aout_thread_t;
/******************************************************************************
* 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_fifo_t * aout_CreateFifo ( aout_thread_t *p_aout, aout_fifo_t *p_fifo );
void aout_DestroyFifo ( aout_fifo_t *p_fifo );
/*******************************************************************************
* common.h: common definitions
* (c)1998 VideoLAN
*******************************************************************************
* Collection of usefull common types and macros definitions
*******************************************************************************
* required headers:
* config.h
*******************************************************************************/
/*******************************************************************************
* Types definitions
*******************************************************************************/
/* Basic types definitions */
typedef signed char s8;
typedef signed short s16;
typedef signed int s32;
typedef signed long long s64;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef u8 byte_t;
/* Boolean type */
typedef int boolean_t;
/* Counter for statistics and profiling */
typedef unsigned long count_t;
/*******************************************************************************
* Macros and inline functions
*******************************************************************************/
/* CEIL: division with round to nearest greater integer */
#define CEIL(n, d) ( ((n) / (d)) + ( ((n) % (d)) ? 1 : 0) )
/* PAD: PAD(n, d) = CEIL(n ,d) * d */
#define PAD(n, d) ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) )
/* MAX and MIN: self explanatory */
#define MAX(a, b) ( ((a) > (b)) ? (a) : (b) )
#define MIN(a, b) ( ((a) < (b)) ? (a) : (b) )
/* MSB (big endian)/LSB (little endian) convertions - network order is always
* MSB, and should be used for both network communications and files. Note that
* byte orders other than little and big endians are not supported, but only
* the VAX seems to have such exotic properties - note that these 'functions'
* needs <netinet/in.h> or the local equivalent. */
/* ?? hton64 should be declared as an extern inline function to avoid border
* effects (see byteorder.h) */
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define hton16 htons
#define hton32 htonl
#define hton64(i) ( ((u64)(htonl((i) & 0xffffffff)) << 32) | htonl(((i) >> 32) & 0xffffffff ) )
#define ntoh16 ntohs
#define ntoh32 ntohl
#define ntoh64 hton64
#elif __BYTE_ORDER == __BIG_ENDIAN
#define hton16 htons
#define hton32 htonl
#define hton64(i) ( i )
#define ntoh16 ntohs
#define ntoh32 ntohl
#define ntoh64(i) ( i )
#else
/* ?? cause a compilation error */
#endif
/* Macros used by input to access the TS buffer */
#define U32_AT(p) ( ntohl ( *( (u32 *)(p) ) ) )
#define U16_AT(p) ( ntohs ( *( (u16 *)(p) ) ) )
This diff is collapsed.
/*******************************************************************************
* control.h: user control functions
* (c)1999 VideoLAN
*******************************************************************************
* Library of functions common to all interfaces, allowing access to various
* structures and settings. Interfaces should only use those functions
* to read or write informations from other threads.
*******************************************************************************
* Required headers:
* <pthread.h>
* <sys/uio.h>
* <X11/Xlib.h>
* <X11/extensions/XShm.h>
* "config.h"
* "common.h"
* "mtime.h"
* "input.h"
* "video.h"
* "video_output.h"
* "xconsole.h"
* "interface.h"
*******************************************************************************/
/*******************************************************************************
* 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,
int i_vout, int i_id );
void intf_DeselectVideoStream( intf_thread_t *p_intf, int i_input, int i_id );
/*******************************************************************************
* debug.h: vlc debug macros
* (c)1999 VideoLAN
*******************************************************************************
* Stand alone file
*******************************************************************************
* Required headers:
* - <string.h>
* - intf_msg.h
*******************************************************************************/
/*******************************************************************************
* ASSERT
*******************************************************************************
* This macro is used to test that a pointer is not nul. It insert the needed
* code when the program is compiled with the debug option, but does nothing
* in release program.
*******************************************************************************/
#ifdef DEBUG
#define ASSERT(p_Mem) \
if (!(p_Mem)) \
intf_ErrMsg("Void pointer error: %s line %d (variable %s at address %p)\n", \
__FILE__, __LINE__, #p_Mem, &p_Mem);
#else
#define ASSERT(p_Mem)
#endif
/*******************************************************************************
* RZERO
*******************************************************************************
* This macro is used to initialise a variable to 0. It is very useful when
* used with the ASSERT macro. It also only insert the needed code when the
* program is compiled with the debug option.
*******************************************************************************/
#ifdef DEBUG
#define RZERO(r_Var) \
bzero(&(r_Var), sizeof((r_Var)));
#else
#define RZERO(r_Var)
#endif
/*******************************************************************************
* PZERO
*******************************************************************************
* This macro is used to initiase the memory pointed out by a pointer to 0.
* It has the same purpose than RZERO, but for pointers.
*******************************************************************************/
#ifdef DEBUG
#define PZERO(p_Mem) \
bzero((p_Mem), sizeof(*(p_Mem)));
#else
#define PZERO(p_Mem)
#endif
/*******************************************************************************
* AZERO
*******************************************************************************
* This macro is used to initiase an array of variables to 0.
* It has the same purpose than RZERO or PZERO, but for array
*******************************************************************************/
#ifdef DEBUG
#define AZERO(p_Array, i_Size) \
bzero((p_Array), (i_Size)*sizeof(*(p_Array)));
#else
#define ZERO(p_Array, i_Size)
#endif
/******************************************************************************
* decoder_fifo.h: interface for decoders PES fifo
* (c)1999 VideoLAN
******************************************************************************
* Required headers:
* - <pthread.h>
* - "config.h"
* - "common.h"
* - "input.h"
******************************************************************************/
/******************************************************************************
* Macros
******************************************************************************/
/* ?? move to inline functions */
#define DECODER_FIFO_ISEMPTY( fifo ) ( (fifo).i_start == (fifo).i_end )
#define DECODER_FIFO_ISFULL( fifo ) ( ( ( (fifo).i_end + 1 - (fifo).i_start ) \
& FIFO_SIZE ) == 0 )
#define DECODER_FIFO_START( fifo ) ( (fifo).buffer[ (fifo).i_start ] )
#define DECODER_FIFO_INCSTART( fifo ) ( (fifo).i_start = ((fifo).i_start + 1) \
& FIFO_SIZE )
#define DECODER_FIFO_END( fifo ) ( (fifo).buffer[ (fifo).i_end ] )
#define DECODER_FIFO_INCEND( fifo ) ( (fifo).i_end = ((fifo).i_end + 1) \
& FIFO_SIZE )
/******************************************************************************
* decoder_fifo_t
******************************************************************************
* This rotative FIFO contains PES packets that are to be decoded...
******************************************************************************/
typedef struct
{
pthread_mutex_t data_lock; /* fifo data lock */
pthread_cond_t data_wait; /* fifo data conditional variable */
/* buffer is an array of PES packets pointers */
pes_packet_t * buffer[FIFO_SIZE + 1];
int i_start;
int i_end;
} decoder_fifo_t;
/*******************************************************************************
* generic_decoder.h : generic decoder thread
* (c)1999 VideoLAN
*******************************************************************************
* Requires:
* <pthread.h>
* "config.h"
* "common.h"
* "mtime.h"
* "input.h"
* "decoder_fifo.h"
* ??
*******************************************************************************/
/*******************************************************************************
* gdec_cfg_t: generic decoder configuration structure
*******************************************************************************
* This structure is passed as an initializer when a generic decoder thread is
* created.
*******************************************************************************/
typedef struct gdec_cfg_s
{
u64 i_properties;
int i_actions; /* decoder actions */
char * psz_base_filename; /* base demux file name */
} gdec_cfg_t;
/* Properties flags */
#define GDEC_CFG_ACTIONS (1 << 0)
#define GDEC_CFG_FILENAME (1 << 1)
/*******************************************************************************
* gdec_thread_t: generic decoder thread descriptor
*******************************************************************************
* This type describes a generic decoder thread.
*******************************************************************************/
typedef struct gdec_thread_s
{
/* Thread properties and locks */
boolean_t b_die; /* `die' flag */
boolean_t b_error; /* `error' flag */
boolean_t b_active; /* `active' flag */
pthread_t thread_id; /* id for pthread functions */
/* Thread configuration */
int i_actions; /* decoder actions */
/* Input properties */
input_thread_t * p_input; /* input thread */
decoder_fifo_t fifo; /* PES input fifo */
/* ?? status info */
int * pi_status;
/* Files array - these files are used to extract ES streams from a
* demultiplexed stream */
/* ?? */
#ifdef STATS
/* Statistics */
count_t c_loops; /* number of loops */
count_t c_idle_loops; /* number of idle loops */
count_t c_pes; /* number of PES packets read */
#endif
} gdec_thread_t;
/* Decoder actions - this flags select which actions the decoder will perform
* when it receives a PES packet */
#define GDEC_IDENTIFY (1 << 0) /* update input's ES tables */
#define GDEC_SAVE (1 << 1) /* save all PES to a same file */
#define GDEC_SAVE_DEMUX (1 << 2) /* save PES to files by stream id */
#define GDEC_PRINT (1 << 3) /* print PES informations */
/*******************************************************************************
* Prototypes
*******************************************************************************/
/* Thread management functions */
gdec_thread_t * gdec_CreateThread ( gdec_cfg_t *p_cfg,
input_thread_t *p_input, int *pi_status );
void gdec_DestroyThread ( gdec_thread_t *p_gdec, int *pi_status );
/* Time management functions */
/* ?? */
/* Dynamic thread settings */
/* ?? */
This diff is collapsed.
/*******************************************************************************
* input_ctrl.h: Decodeur control
* (c)1999 VideoLAN
*******************************************************************************
* Requires:
* "config.h"
* "common.h"
* "mtime.h"
******************************************************************************/
/******************************************************************************
* Prototypes
******************************************************************************/
int input_AddPgrmElem( input_thread_t *p_input, int i_current_pid );
int input_DelPgrmElem( input_thread_t *p_input, int i_current_pid );
boolean_t input_IsElemRecv( input_thread_t *p_input, int i_pid );
/*******************************************************************************
* file.h: file streams functions interface
* (c)1999 VideoLAN
*******************************************************************************/
/******************************************************************************
* Prototypes
******************************************************************************/
int input_FileCreateMethod( input_thread_t *p_input ,
input_cfg_t *p_cfg );
int input_FileRead( input_thread_t *p_input, const struct iovec *p_vector,
size_t i_count );
void input_FileDestroyMethod( input_thread_t *p_input );
/*******************************************************************************
* input_netlist.h: netlist interface
* (c)1998 VideoLAN
*******************************************************************************
* The netlists are an essential part of the input structure. We maintain a
* list of free TS packets and free PES packets to avoid continuous malloc
* and free.
*******************************************************************************/
/******************************************************************************
* Prototypes
******************************************************************************/
int input_NetlistOpen( input_thread_t *p_input );
void input_NetlistClean( input_thread_t *p_input );
/* ?? implement also a "normal" (non inline, non static) function in input_netlist.c,
which will be used when inline is disabled */
/* ?? test */ static __inline__ void input_NetlistFreePES( input_thread_t *p_input,
pes_packet_t *p_pes_packet );
static __inline__ void input_NetlistFreeTS( input_thread_t *p_input,
ts_packet_t *p_ts_packet );
static __inline__ pes_packet_t* input_NetlistGetPES( input_thread_t *p_input );
/*******************************************************************************
* input_NetlistFreePES: add a PES packet to the netlist
*******************************************************************************
* Add a PES packet to the PES netlist, so that the packet can immediately be
* reused by the demultiplexer. We put this function directly in the .h file,
* because it is very frequently called.
*******************************************************************************/
static __inline__ void input_NetlistFreePES( input_thread_t *p_input,
pes_packet_t *p_pes_packet )
{
int i_dummy;
ts_packet_t * p_ts_packet;
ASSERT(p_pes_packet);
/* We will be playing with indexes, so we take a lock. */
pthread_mutex_lock( &p_input->netlist.lock );
/* Free all TS packets in this PES structure. */
p_ts_packet = p_pes_packet->p_first_ts;
for( i_dummy = 0; i_dummy < p_pes_packet->i_ts_packets; i_dummy++ )
{
ASSERT(p_ts_packet);
#ifdef INPUT_LIFO_TS_NETLIST
p_input->netlist.i_ts_index--;
p_input->netlist.p_ts_free[p_input->netlist.i_ts_index].iov_base
= p_ts_packet;
#else /* FIFO */
p_input->netlist.p_ts_free[p_input->netlist.i_ts_end].iov_base
= p_ts_packet;
p_input->netlist.i_ts_end++;
p_input->netlist.i_ts_end &= INPUT_MAX_TS; /* loop */
#endif
p_ts_packet = p_ts_packet->p_next_ts;
}
/* Free the PES structure. */
#ifdef INPUT_LIFO_PES_NETLIST
p_input->netlist.i_pes_index--;
p_input->netlist.p_pes_free[p_input->netlist.i_pes_index] = p_pes_packet;
#else /* FIFO */
p_input->netlist.p_pes_free[p_input->netlist.i_pes_end] = p_pes_packet;
p_input->netlist.i_pes_end++;
p_input->netlist.i_pes_end &= INPUT_MAX_PES; /* loop */
#endif
pthread_mutex_unlock( &p_input->netlist.lock );
}
/*******************************************************************************
* input_NetlistFreeTS: add a TS packet to the netlist
*******************************************************************************
* Add a TS packet to the TS netlist, so that the packet can immediately be
* reused by the demultiplexer. Shouldn't be called by other threads (they
* should only use input_FreePES.
*******************************************************************************/
static __inline__ void input_NetlistFreeTS( input_thread_t *p_input,
ts_packet_t *p_ts_packet )
{
ASSERT(p_ts_packet);
/* We will be playing with indexes, so we take a lock. */
pthread_mutex_lock( &p_input->netlist.lock );
/* Free the TS structure. */
#ifdef INPUT_LIFO_TS_NETLIST
p_input->netlist.i_ts_index--;
p_input->netlist.p_ts_free[p_input->netlist.i_ts_index].iov_base = p_ts_packet;
#else /* FIFO */
p_input->netlist.p_ts_free[p_input->netlist.i_ts_end].iov_base = p_ts_packet;
p_input->netlist.i_ts_end++;
p_input->netlist.i_ts_end &= INPUT_MAX_TS; /* loop */
#endif
pthread_mutex_unlock( &p_input->netlist.lock );
}
/*******************************************************************************
* input_NetlistGetPES: remove a PES packet from the netlist
*******************************************************************************
* Add a TS packet to the TS netlist, so that the packet can immediately be
* reused by the demultiplexer. Shouldn't be called by other threads (they
* should only use input_FreePES.
*******************************************************************************/
static __inline__ pes_packet_t* input_NetlistGetPES( input_thread_t *p_input )
{
pes_packet_t * p_pes_packet;
#ifdef INPUT_LIFO_PES_NETLIST
/* i_pes_index might be accessed by a decoder thread to give back a
* packet. */
pthread_mutex_lock( &p_input->netlist.lock );
/* Verify that we still have PES packet in the netlist */
if( (INPUT_MAX_PES - p_input->netlist.i_pes_index ) <= 1 )
{
intf_ErrMsg("input error: PES netlist is empty !\n");
return( NULL );
}
/* Fetch a new PES packet */
p_pes_packet = p_input->netlist.p_pes_free[p_input->netlist.i_pes_index];
p_input->netlist.i_pes_index++;
pthread_mutex_unlock( &p_input->netlist.lock );
#else /* FIFO */
/* No need to lock, since we are the only ones accessing i_pes_start. */
/* Verify that we still have PES packet in the netlist */
if( ((p_input->netlist.i_pes_end -1 - p_input->netlist.i_pes_start) & INPUT_MAX_PES) <= 1 )
{
intf_ErrMsg("input error: PES netlist is empty !\n");
return( NULL );
}
p_pes_packet = p_input->netlist.p_pes_free[p_input->netlist.i_pes_start];
p_input->netlist.i_pes_start++;
p_input->netlist.i_pes_start &= INPUT_MAX_PES; /* loop */
#endif /* netlist type */
/* Initialize PES flags. */
p_pes_packet->b_data_loss = 0;
p_pes_packet->b_data_alignment = 0;
p_pes_packet->b_has_pts = 0;
p_pes_packet->b_random_access = 0;
p_pes_packet->b_discard_payload = 0;
p_pes_packet->i_pes_size = 0;
p_pes_packet->i_ts_packets = 0;
p_pes_packet->p_first_ts = NULL;
p_pes_packet->p_last_ts = NULL;
return( p_pes_packet );
}
/*******************************************************************************
* network.h: network functions interface
* (c)1999 VideoLAN
*******************************************************************************/
/*
needs :
- <sys/uio.h>
- <sys/socket.h>
- <unistd.h>
- <netinet/in.h>
- <netdb.h>
- <arpa/inet.h>
- <stdio.h>
- <sys/ioctl.h>
- <net/if.h>
*/
/******************************************************************************
* Prototypes
******************************************************************************/
int input_NetworkCreateMethod( input_thread_t *p_input,
input_cfg_t *p_cfg );
int input_NetworkRead( input_thread_t *p_input, const struct iovec *p_vector,
size_t i_count );
void input_NetworkDestroyMethod( input_thread_t *p_input );
/*******************************************************************************
* input_pcr.h: PCR management interface
* (c)1999 VideoLAN
*******************************************************************************/
/* Maximum number of samples used to compute the dynamic average value,
* it is also the maximum of c_average in the pcr_descriptor_struct.
* We use the following formula :
* new_average = (old_average * c_average + new_sample_value) / (c_average +1) */
#define PCR_MAX_AVERAGE_COUNTER 40
/******************************************************************************
* Prototypes
******************************************************************************/
int input_PcrInit ( input_thread_t *p_input );
void input_PcrDecode ( input_thread_t *p_input, es_descriptor_t* p_es,
u8* p_pcr_data );
void input_PcrClean ( input_thread_t *p_input );
/*******************************************************************************
* psi.h: PSI management interface
* (c)1999 VideoLAN
*******************************************************************************
* Requires:
* "config.h"
* "common.h"
* "mtime.h"
******************************************************************************/
/******************************************************************************
* Prototypes
******************************************************************************/
int input_PsiInit( input_thread_t *p_input );
void input_PsiDecode( input_thread_t *p_input, psi_section_t* p_psi_section );
void input_PsiRead( input_thread_t *p_input /* ??? */ );
int input_PsiClean( input_thread_t *p_input );
This diff is collapsed.
/******************************************************************************
* interface.h: interface access for other threads
* (c)1999 VideoLAN
******************************************************************************
* This library provides basic functions for threads to interact with user
* interface, such as message output.
******************************************************************************
* Required headers:
* <pthread.h>
* <sys/uio.h>
* <X11/Xlib.h>
* <X11/extensions/XShm.h>
* "config.h"
* "common.h"
* "mtime.h"
* "input.h"
* "video.h"
* "video_output.h"
* "audio_output.h"
* "xconsole.h"
******************************************************************************/
/******************************************************************************
* intf_thread_t: describe an interface thread
******************************************************************************
* This structe describes all interface-specific data of the main (interface)
* thread.
******************************************************************************/
typedef struct
{
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 */
} intf_thread_t;
/******************************************************************************
* Prototypes
******************************************************************************/
int intf_Run( intf_thread_t * p_intf );
This diff is collapsed.
/*******************************************************************************
* intf_ctrl.h: interface commands access to control functions
* (c)1999 VideoLAN
*******************************************************************************
* Library of functions common to all interfaces, allowing access to various
* structures and settings. Interfaces should only use those functions
* to read or write informations from other threads.
*******************************************************************************
* Required headers:
* none
*******************************************************************************/
/*******************************************************************************
* Extern variables
*******************************************************************************/
extern const intf_command_t control_command[];
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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