- don't use the File input and the Dvd input any more. File has been

    rewritten and extended, Dvd wasn't really dvd but just Mpeg2 PS;
  - merge both inputs into "local" input (inputs/local directory);
  - Makefile split/modif/masterization (main Makefile, Makefile.opts,
    Makefile.input, and input specific Makefiles). Recursive Makefiles for
    the inputs;
  - suspend/resume commands;
  - vls.cfg up-to-date.

Current status of the "local" input:
  - Mpeg1 PS (file) : not yet supported (the converter doesn't work);
  - Mpeg2 PS (file) : supported;
  - Mpeg2 TS (file) : supported;
  - DVD (device)    : not yet supported (TODO list);

  - need a config file named "input.cfg" (format is comming soon with the doc)
  - --loop option supported;
  - suspend/resume commands work.

Bug fixes:
  - don't throw an exception after a try to stop a thread that wasn't started;
  - settings: small bug (tm);
  - here and there: string building bugs fixed.

TODO:
  - write a exhaustive documentation (first place in the fifo (after some
    sleep in the real life the one with pizzas...);
  - write a DVD reader (IFO, CSS...);
  - write a "seek" command;
  - write a real library manager like the plugin bank of the vlc;
  - previous commit's TODO list (shell like parser).

*paf* (I hope nothing is broken) -- bozo "brain damage"
parent 19887e02
......@@ -3,50 +3,18 @@
# (c)1999-2000 VideoLAN
################################################################################
# Main Makefile to build the VideoLAN Server
################################################################################
# Configuration
# Common options
################################################################################
#
# Target environnement
#
TARGET=LINUX
#TARGET=SOLARIS
#TARGET=WIN32
#
# Build control
#
BUILD=DEBUG
#BUILD=PROFILING
#BUILD=BASE_RELEASE
#BUILD=OPTIM_RELASE
################################################################################
# Generic settings
################################################################################
#
# C compiler flags: dependancies generation
#
# nothing
#
# C compiler flags: compilation
#
CCFLAGS+=-D$(TARGET)
CCFLAGS+=-DBUGGY_VLC
#
# C compiler flags: linking
#
LCFLAGS+=-D$(TARGET)
-include Makefile.opts
# Use -rdynamic to share the code with libraries => libs are smaller.
CCFLAGS+=-rdynamic
LCFLAGS+=-rdynamic
################################################################################
......@@ -57,46 +25,26 @@ LCFLAGS+=-D$(TARGET)
# Linux
#
ifeq ($(TARGET), LINUX)
CC=g++
LC=g++
DCFLAGS+=-Wall
DCFLAGS+=-MM
CCFLAGS+=-Wall
CCFLAGS+=-D_REENTRANT
LCFLAGS+=-D_REENTRANT
TARGET+=-DUNIX
LIB+=-lpthread
LIB+=-lcrypt
LIB+=-ldl
TARGET+=-DUNIX
endif
#
# Solaris
#
ifeq ($(TARGET), SOLARIS)
CC=CC
LC=CC
DCFLAGS+=+w
DCFLAGS+=-xM1
CCFLAGS+=+w
CCFLAGS+=-mt
CCFLAGS+=-I/mroot/src/ext/stlport-312b/include # kludgy :)
LCFLAGS+=-mt
TARGET+=-DUNIX
#LIB+=-lpthread
LIB+=-lcrypt
LIB+=-ldl
LIB+=-lsocket
LIB+=-lnsl
LIB+=-lposix4
endif
TARGET+=-DUNIX
endif
################################################################################
......@@ -140,11 +88,20 @@ SERVERSRC= server/admin.cpp \
server/nativeadmin.cpp \
server/vls.cpp \
server/tsstreamer.cpp \
server/file/fileinput.cpp \
server/dvd/dvdinput.cpp \
# server/file/fileinput.cpp \
# server/dvd/dvdinput.cpp \
# server/remote/remoteinput.cpp \
# server/satellite/satinput.cpp \
# server/vod/vod.cpp \
#
#
# Input libraries
#
INPUTS= local
INPUTTARGETS:=$(INPUTS:%:bin/%.so)
#REMOTESRC= server/remote/remoteinput.cpp \
......@@ -173,46 +130,6 @@ REMOTEDEP:=$(REMOTESRC:%.cpp=dep/%.d)
DEP:=$(COREDEP) $(MPEGDEP) $(SHAREDDEP) $(SERVERDEP) $(REMOTEDEP)
################################################################################
# Build control
################################################################################
#
# Debug mode
#
ifeq ($(BUILD), DEBUG)
CCFLAGS+=-DDEBUG
CCFLAGS+=-g
#LIB+=-ldmalloc
#LIB+=-lefence
#LC:=purify -log-File=purify.log $(LC)
#LC:=purify $(LC)
endif
#
# Profiling mode
#
ifeq ($(BUILD), PROFILING)
CCFLAGS+=-pg
endif
#
# Standard release mode
#
ifeq ($(BUILD), BASE_RELEASE)
CCFLAGS+=-O
endif
#
# Optimsed release mode
#
ifeq ($(BUILD), OPTIM_RELEASE)
CCFLAGS+=-O6
endif
################################################################################
# Targets definition
################################################################################
......@@ -220,15 +137,19 @@ endif
#
# Build rules
#
all: vls # libremote
all: $(INPUTS) vls
clean:
rm -Rf obj/*
for input in "$(INPUTS)" ; do \
( cd inputs/$$input && $(MAKE) clean ) ; done
distclean: clean
rm -f bin/vls bin/libsat
rm -f bin/vls
rm -Rf dep/*
rm -Rf *.log *.dbg
for input in "$(INPUTS)" ; do \
( cd inputs/$$input && $(MAKE) distclean ) ; done
dep: $(DEP)
......@@ -238,11 +159,8 @@ vls: $(COREOBJ) $(MPEGOBJ) $(SHAREDOBJ) $(SERVEROBJ)
$(LC) $(LCFLAGS) -o bin/$@ $^ $(LIB)
chmod 755 bin/$@
#libremote: $(REMOTEOBJ)
# @echo "Linking $@..."
# @test -d bin || mkdir -p bin
# $(LC) $(LCFLAGS) -shared -o bin/$@ $^ $(LIB)
# chmod 755 bin/$@
$(INPUTS): %: inputs/%/Makefile
cd inputs/$* && $(MAKE) ../../bin/$*.so
$(OBJ): obj/%.o: dep/%.d
$(OBJ): obj/%.o: %.cpp
......@@ -250,12 +168,6 @@ $(OBJ): obj/%.o: %.cpp
@echo "Compiling $<..."
$(CC) $(CFLAGS) $(CCFLAGS) $(INCLUDE) -o $@ -c $<
$(LIBOBJ): obj/%.o: dep/%.d
$(LIBOBJ): obj/%.o: %.cpp
@test -d obj/$(dir $*) || mkdir -p obj/$(dir $*)
@echo "Compiling $<..."
$(CC) $(CFLAGS) $(CCFLAGS) $(INCLUDE) -fPIC -o $@ -c $<
$(DEP): Makefile
$(DEP): dep/%.d: %.cpp
@test -d dep/$(dir $*) || mkdir -p dep/$(dir $*)
......
################################################################################
# vls Makefile.input
# (c)1999-2000 VideoLAN
################################################################################
# Makefile skeleton for inputs building
# The Makefile which includes this file at the end must define at least
# - INPUT which is the name of the input;
# - SRC which contains the files to be built.
################################################################################
# Common options
################################################################################
-include ../../Makefile.opts
################################################################################
# Environnement specific settings
################################################################################
#
# Linux
#
ifeq ($(TARGET), LINUX)
TARGET+=-DUNIX
endif
#
# Solaris
#
ifeq ($(TARGET), SOLARIS)
TARGET+=-DUNIX
endif
################################################################################
# Files description
################################################################################
#
# Object files
#
OBJ:=$(SRC:%.cpp=obj/%.o)
#
# Dependancies
#
DEP:=$(SRC:%.cpp=dep/%.d)
################################################################################
# Targets definition
################################################################################
#
# Build rules
#
clean:
rm -Rf obj/*
distclean: clean
rm -f ../../bin/$(INPUT).so
rm -Rf dep/*
rm -Rf *.log *.dbg
dep: $(DEP)
../../bin/$(INPUT).so: $(OBJ)
@echo "Linking $@..."
@test -d ../../bin || mkdir -p ../../bin
$(LC) $(LCFLAGS) -shared -o $@ $^ $(LIB)
chmod 755 $@
$(OBJ): obj/%.o: dep/%.d
$(OBJ): obj/%.o: %.cpp
@test -d obj/$(dir $*) || mkdir -p obj/$(dir $*)
@echo "Compiling $<..."
$(CC) $(CFLAGS) $(CCFLAGS) $(INCLUDE) -fPIC -o $@ -c $<
$(DEP): Makefile
$(DEP): dep/%.d: %.cpp
@test -d dep/$(dir $*) || mkdir -p dep/$(dir $*)
@echo "Generating dependancies for $<..."
@$(SHELL) -ec '$(CC) $(CFLAGS) $(DCFLAGS) $(INCLUDE) $< \
| sed '\''s/$(subst .,\.,$(notdir $*))\.o[ :]*/$(subst /,\/,$*).o \
dep\/$(subst /,\/,$*).d : /g'\'' > $@; \
[ -s $@ ] || rm -f $@'
#
# Dependancies inclusion
#
ifneq ($(MAKECMDGOALS), clean)
ifneq ($(MAKECMDGOALS), distclean)
-include $(DEP)
endif
endif
################################################################################
# Notes
################################################################################
# Look at the main Makefile for more information.
################################################################################
# vls Makefile.opts
# (c)1999-2000 VideoLAN
################################################################################
# Common options for the VideoLAN Server's Makefiles
################################################################################
# Configuration
################################################################################
#
# Target environnement
#
TARGET=LINUX
#TARGET=SOLARIS
#TARGET=WIN32
#
# Build control
#
BUILD=DEBUG
#BUILD=PROFILING
#BUILD=BASE_RELEASE
#BUILD=OPTIM_RELASE
################################################################################
# Generic settings
################################################################################
#
# C compiler flags: dependancies generation
#
# nothing
#
# C compiler flags: compilation
#
CCFLAGS+=-D$(TARGET)
CCFLAGS+=-DBUGGY_VLC
#
# C compiler flags: linking
#
LCFLAGS+=-D$(TARGET)
################################################################################
# Environnement specific settings
################################################################################
#
# Linux
#
ifeq ($(TARGET), LINUX)
MAKE=make
CC=g++
LC=g++
DCFLAGS+=-Wall
DCFLAGS+=-MM
CCFLAGS+=-Wall
CCFLAGS+=-D_REENTRANT
LCFLAGS+=-D_REENTRANT
endif
#
# Solaris
#
ifeq ($(TARGET), SOLARIS)
MAKE=make
CC=CC
LC=CC
DCFLAGS+=+w
DCFLAGS+=-xM1
CCFLAGS+=+w
CCFLAGS+=-mt
CCFLAGS+=-I/mroot/src/ext/stlport-312b/include # kludgy :)
LCFLAGS+=-mt
endif
################################################################################
# Build control
################################################################################
#
# Debug mode
#
ifeq ($(BUILD), DEBUG)
CCFLAGS+=-DDEBUG
CCFLAGS+=-g
#LIB+=-ldmalloc
#LIB+=-lefence
#LC:=purify -log-File=purify.log $(LC)
#LC:=purify $(LC)
endif
#
# Profiling mode
#
ifeq ($(BUILD), PROFILING)
CCFLAGS+=-pg
endif
#
# Standard release mode
#
ifeq ($(BUILD), BASE_RELEASE)
CCFLAGS+=-O
endif
#
# Optimsed release mode
#
ifeq ($(BUILD), OPTIM_RELEASE)
CCFLAGS+=-O6
endif
......@@ -34,8 +34,10 @@ class C_Application
virtual ~C_Application();
// Access to the appliction object
static void SetApp(C_Application* pApp)
{ s_pApplication = pApp; };
static C_Application* GetApp()
{ ASSERT(s_pApplication); return s_pApplication; }
{ ASSERT(s_pApplication); return s_pApplication; };
// Application control
int Init(int iArgc, char* paArg[]);
......
......@@ -42,7 +42,7 @@ extern "C" { \
{ return new class(val); } \
\
int InitLib(C_Application* pApp) \
{ C_Application::s_pApplication = pApp; return NO_ERR; } \
{ C_Application::SetApp(pApp); return NO_ERR; } \
}
......
......@@ -146,8 +146,8 @@ void C_CfgFileParser::Parse(const C_String& strFileName, bool bCompletePath)
(pMatch->GetSubExpr(3) != ""))
{
throw E_Parser(GEN_ERR,
"Error in the configuration file at line " +
m_iLineNumber);
C_String("Error in the configuration file at line ") +
m_iLineNumber);
}
else
{
......@@ -164,8 +164,8 @@ void C_CfgFileParser::Parse(const C_String& strFileName, bool bCompletePath)
if((pMatch->GetSubExpr(2) != "") || (strSection == ""))
{
throw E_Parser(GEN_ERR,
"Error in the configuration file at line " +
m_iLineNumber);
C_String("Error in the configuration file at line ") +
m_iLineNumber);
}
else if(m_cContextStack.Size() == m_cContextStack.Capacity())
{
......@@ -191,8 +191,8 @@ void C_CfgFileParser::Parse(const C_String& strFileName, bool bCompletePath)
(!bValue && (bName || bEqual)))
{
throw E_Parser(GEN_ERR,
"Error in the configuration file at line " +
m_iLineNumber);
C_String("Error in the configuration file at line ") +
m_iLineNumber);
}
else if(strFirstToken != "")
{
......@@ -206,7 +206,7 @@ void C_CfgFileParser::Parse(const C_String& strFileName, bool bCompletePath)
else
{
throw E_Parser(GEN_ERR,
"Error in the configuration file at line " +
C_String("Error in the configuration file at line ") +
m_iLineNumber);
}
}
......
......@@ -178,7 +178,7 @@ C_Vector<C_Setting> C_Settings::GetSettings(const C_String& strSection) const
C_HashTableNode<C_String, C_String>* pNode = cIterator.GetNext();
C_String strName = pNode->GetKey();
C_String* pstrValue = pNode->GetValue();
if(strName.StartsWith(strSection))
if(strName.StartsWith(strSection + "."))
{
// Strip the initial section name
unsigned int iOffset = strSection.Length() + 1;
......
......@@ -192,6 +192,8 @@ C_Thread::C_Thread(unsigned int iProperties)
{
m_iFlags = iProperties;
m_bStarted = false;
#ifdef UNIX
ZERO(tId);
#elif defined WIN32
......@@ -297,7 +299,10 @@ void C_Thread::Stop()
{
s_cThreadKiller.Kill(this);
}
else
// Don't join if not started
// It avoids exception's generation because pthread_join returns an error
// when the thread was not started.
else if(m_bStarted)
{
// Ask the user work routine to stop its normal processing
StopWork();
......@@ -423,6 +428,8 @@ void* C_Thread::StartRoutine(void* pThread)
C_Thread* pThis = (C_Thread*)pThread;
E_Exception* p_eError = NULL;
pThis->m_bStarted = true;
try
{
pThis->DoWork();
......
......@@ -90,6 +90,9 @@ class C_Thread
// Thread properties
unsigned int m_iFlags;
// Flag to avoid joining a non-started thread
bool m_bStarted;
// Thread identity
#ifdef UNIX
pthread_t tId;
......
################################################################################
# vls Makefile
# (c)1999-2000 VideoLAN
################################################################################
################################################################################
# Files description
################################################################################
#
# Input name
#
INPUT=local
#
# Source files
#
SRC= converter.cpp \
reader.cpp \
localinput.cpp \
################################################################################
# Makefile skeleton
################################################################################
-include ../../Makefile.input
################################################################################
# Notes
################################################################################
# Look at the Makefile.input file for more information.
/*******************************************************************************
* converter.cpp: Threaded Mpeg converters *
* (c)2001 VideoLAN *
*------------------------------------------------------------------------------*
* *
*******************************************************************************/
//------------------------------------------------------------------------------
// Preamble
//------------------------------------------------------------------------------
#include "../../core/core.h"
#include "../../mpeg/mpeg.h"
#include "../../mpeg/ts.h"
#include "../../mpeg/streamdescr.h"
#include "../../mpeg/ps2ts.h"
#include "../../server/buffer.h"
#include "../../server/program.h"
#include "../../server/broadcast.h"
#include "../../server/request.h"
#include "../../server/input.h"
#include "reader.h"
#include "converter.h"
#include "../../mpeg/ps2ts.cpp"
#define STATUS_RUNNING 0
#define STATUS_PAUSE_REQUEST 1
#define STATUS_PAUSED 2
/*******************************************************************************
* C_MpegConverter
********************************************************************************
*
*******************************************************************************/
//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------
C_MpegConverter::C_MpegConverter(handle hLog, C_Broadcast* pBroadcast,
C_MpegReader* pReader,
C_NetList* pTsProvider, C_SyncFifo* pBuffer,
C_EventHandler* pEventHandler)
{
ASSERT(hLog);
ASSERT(pBroadcast);
ASSERT(pReader);
ASSERT(pTsProvider);
ASSERT(pBuffer);
ASSERT(pEventHandler);
m_hLog = hLog;
m_pBroadcast = pBroadcast;
m_pReader = pReader;
m_pTsProvider = pTsProvider;
m_pBuffer = pBuffer;
m_pEventHandler = pEventHandler;
}
//------------------------------------------------------------------------------
// Destructor
//------------------------------------------------------------------------------
C_MpegConverter::~C_MpegConverter()
{
delete m_pReader;
};
//------------------------------------------------------------------------------
// Initialization
//------------------------------------------------------------------------------
void C_MpegConverter::InitWork()
{
m_iShortPauseStatus = m_iLongPauseStatus = STATUS_RUNNING;
m_cResumeCond.Protect();
m_bStop = false;
}
//------------------------------------------------------------------------------
// Stop request
//------------------------------------------------------------------------------
void C_MpegConverter::StopWork()
{
m_bStop = true;
}
//------------------------------------------------------------------------------
// Resume streaming
//------------------------------------------------------------------------------
void C_MpegConverter::Resume()
{
m_cResumeCond.Signal();
m_cResumeCond.Release();
}
//------------------------------------------------------------------------------
// Suspend streaming
//------------------------------------------------------------------------------
void C_MpegConverter::Suspend()
{
m_iLongPauseStatus = STATUS_PAUSE_REQUEST;
m_cResumeCond.Protect();
}
//------------------------------------------------------------------------------
// Short pause (use it to access for a very short time to the reader
//------------------------------------------------------------------------------
void C_MpegConverter::ShortPause()
{
m_iShortPauseStatus = STATUS_PAUSE_REQUEST;
m_cResumeCond.Protect();
}
/*******************************************************************************
* C_Ts2TsConverter
********************************************************************************
*
*******************************************************************************/
//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------
C_Ts2TsConverter::C_Ts2TsConverter(handle hLog, C_Broadcast* pBroadcast,
C_MpegReader* pReader,
C_NetList* pTsProvider, C_SyncFifo* pBuffer,
C_EventHandler* pEventHandler) :
C_MpegConverter(hLog, pBroadcast,
pReader,
pTsProvider, pBuffer,
pEventHandler)
{
}
//------------------------------------------------------------------------------
// Initialization
//------------------------------------------------------------------------------
void C_Ts2TsConverter::InitWork()
{
// Inherited method
C_MpegConverter::InitWork();
int iRc = 0;
// Fill the buffer