Commit 68998b36 authored by Damien Lucas's avatar Damien Lucas

. Retro Compatibility for configuration files

. ProgramCount is not needed anymore for local input

. You can define local input just with:
    BEGIN "xxx"  where xxx is a number
     ...
    END
  The 'local1' input is implicitly declared

. Compilation warnings fixed
parent b2741fa8
......@@ -2,7 +2,7 @@
* parsers.cpp: Command line and configuration files parsers
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: parsers.cpp,v 1.10 2002/12/08 15:55:29 nitrox Exp $
* $Id: parsers.cpp,v 1.11 2002/12/09 01:36:24 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -117,16 +117,27 @@ C_CfgFileParser::C_CfgFileParser(C_ParserHandler* pCallBack) :
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
void C_CfgFileParser::Parse(const C_String& strFileName, bool bCompletePath)
C_Vector<C_String> C_CfgFileParser::Parse(const C_String& strFileName, bool bCompletePath,
const C_String& strRoot)
{
C_Vector<C_String> vInclude;
ASSERT(m_pCallBack);
m_pCallBack->SetRoot(strRoot);
#ifdef DEBUG
if(strRoot!="")
fprintf(stderr, "Reading file %s for module '%s'\n", strFileName.GetString(),
strRoot.GetString());
else
fprintf(stderr, "Reading file %s for base configuration\n",
strFileName.GetString());
#endif
try
{
// Open the cfg file
C_File* pCfgFile = new C_File(strFileName);
pCfgFile->Open("r");
yyin = pCfgFile->GetHandle();
// Parse the file
......@@ -201,12 +212,23 @@ void C_CfgFileParser::Parse(const C_String& strFileName, bool bCompletePath)
C_String strValue(yytext);
// Remove the quotes. FIXME: should be done by the lexer
C_String strStrippedValue(strValue.SubString(1, strValue.Length()-1));
m_pCallBack->OnProperty(strFirstToken, strStrippedValue);
if (yylex() == TOK_NEWLINE)
if(strFirstToken=="ConfigPath")
{
C_String* strInc=new C_String(strStrippedValue+"/input.cfg");
C_String* strIncRoot=new C_String(m_pCallBack->GetSection());
vInclude.Add(strInc);
vInclude.Add(strIncRoot);
}
else
{
m_pCallBack->OnProperty(strFirstToken, strStrippedValue);
}
if (yylex() == TOK_NEWLINE)
{
m_iLineNumber++;
}
else {
else
{
throw E_Parser(GEN_ERR,
C_String("Error in the configuration file at line ") +
m_iLineNumber);
......@@ -216,7 +238,8 @@ void C_CfgFileParser::Parse(const C_String& strFileName, bool bCompletePath)
{
m_iLineNumber++;
}
else {
else
{
throw E_Parser(GEN_ERR,
C_String("Error in the configuration file at line ") +
m_iLineNumber);
......@@ -226,8 +249,19 @@ void C_CfgFileParser::Parse(const C_String& strFileName, bool bCompletePath)
catch(E_Exception e)
{
throw E_Parser(GEN_ERR, "Parsing of file '" + strFileName + "' failed", e);
}
if(strRoot=="")
{
m_pCallBack->OnStartSection("local1");
m_pCallBack->OnProperty("ProgramCount", m_pCallBack->GetLocalCount());
m_pCallBack->OnEndSection("local1");
}
else
{
m_pCallBack->OnProperty("ProgramCount", m_pCallBack->GetLocalCount());
}
return vInclude;
}
// Needed for flex functions
......
......@@ -2,7 +2,7 @@
* parsers.h: Command line and configuration files parsers
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: parsers.h,v 1.4 2002/11/05 19:54:07 nitrox Exp $
* $Id: parsers.h,v 1.5 2002/12/09 01:36:24 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -58,6 +58,12 @@ class C_ParserHandler
virtual void OnEndSection(const C_String& strName) = 0;
// Called when an entry is parsed
virtual void OnProperty(const C_String& strName, const C_String& strVal) = 0;
// To know the current section
virtual C_String GetSection()=0;
//KLUDGE
virtual void ResetLocalCount()=0;
virtual int GetLocalCount()=0;
virtual void SetRoot(const C_String& strR)=0;
};
......@@ -79,7 +85,7 @@ class C_CfgFileParser
C_CfgFileParser(C_ParserHandler* pCallBack);
// Parse the data on the given stream
void Parse(const C_String& strFileName, bool bCompletePath);
C_Vector<C_String> Parse(const C_String& strFileName, bool bCompletePath, const C_String& strRoot);
void AddCmdLineSetting(unsigned char sOption, C_String sValue);
void AddCmdLineTarget(C_String sTarget, C_String sTags);
protected:
......
......@@ -2,7 +2,7 @@
* settings.cpp: Application settings management
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: settings.cpp,v 1.9 2002/11/05 19:54:07 nitrox Exp $
* $Id: settings.cpp,v 1.10 2002/12/09 01:36:24 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -78,9 +78,16 @@ public:
virtual void OnEndSection(const C_String& strName);
virtual void OnProperty(const C_String& strName, const C_String& strVal);
C_String GetSection();
int GetLocalCount(); //KLUDGE
void ResetLocalCount(); //KLUDGE
void SetRoot(const C_String& strR);
private:
int m_iLocalCount; //KLUDGE
C_Settings* m_pSettings;
C_String m_strPrefix;
C_String m_strRoot;
};
......@@ -91,6 +98,7 @@ C_SettingsHandler::C_SettingsHandler(C_Settings* pSettings)
{
ASSERT(pSettings);
m_pSettings = pSettings;
m_iLocalCount = 0;
}
......@@ -108,21 +116,75 @@ C_SettingsHandler::~C_SettingsHandler()
//------------------------------------------------------------------------------
void C_SettingsHandler::OnStartSection(const C_String& strName)
{
m_strPrefix += strName + ".";
if(strName.ToInt()!=0) // Guess we have a file program
{
if(m_strPrefix.Find('.', 0)==GEN_ERR)
{
#ifdef DEBUG
printf("Implicit declaration of input 'local1'\n");
#endif
OnStartSection("inputs");
OnProperty("local1", "local");
OnEndSection("Inputs");
m_strPrefix += "local1.";
}
m_iLocalCount++;
const C_String strN = m_iLocalCount;
m_strPrefix += strN + ".";
}
else
{
m_strPrefix += strName + ".";
}
}
C_String C_SettingsHandler::GetSection(void)
{
return m_strPrefix;
}
void C_SettingsHandler::SetRoot(const C_String& strR)
{
m_strRoot=strR;
m_strPrefix=m_strRoot;
return;
}
int C_SettingsHandler::GetLocalCount(void)
{
return m_iLocalCount;
}
void C_SettingsHandler::ResetLocalCount(void)
{
m_iLocalCount=0;
return;
}
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
void C_SettingsHandler::OnEndSection(const C_String& strName)
{
ASSERT(m_strPrefix.Length() - strName.Length() >= 0);
unsigned int iEnd = m_strPrefix.Length() - strName.Length() - 1;
m_strPrefix = m_strPrefix.SubString(0, iEnd);
if(strName.ToInt()!=0)
{
const C_String strN = m_iLocalCount;
ASSERT(m_strPrefix.Length() - strN.Length() >= 0);
unsigned int iEnd = m_strPrefix.Length() - strN.Length() - 1;
m_strPrefix = m_strPrefix.SubString(0, iEnd);
}
else
{
ASSERT(m_strPrefix.Length() - strName.Length() >= 0);
unsigned int iEnd = m_strPrefix.Length() - strName.Length() - 1;
m_strPrefix = m_strPrefix.SubString(0, iEnd);
}
if(m_strPrefix.Find('.')!=GEN_ERR)
{
m_strPrefix=m_strRoot;
}
}
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
......@@ -156,9 +218,17 @@ C_Settings::C_Settings() : m_cSettings(31)
//------------------------------------------------------------------------------
void C_Settings::Load(const C_String& strDefaultCfgFile, bool bReadCmdLine)
{
C_Vector<C_String> vInclude;
C_SettingsHandler cHandler(this);
C_CfgFileParser cParser(&cHandler);
cParser.Parse(strDefaultCfgFile, true);
vInclude=cParser.Parse(strDefaultCfgFile, true, "");
for(unsigned int i=0; i<vInclude.Size(); i+=2)
{
// Only one inclusion level is allowed
// fileName is in vInclude[i] and root is in vInclude[i+1]
cHandler.ResetLocalCount();
cParser.Parse(vInclude[i], true, vInclude[i+1]);
}
}
void C_Settings::AddCmdLineTarget(C_String sTarget, C_String sTags)
......
......@@ -2,7 +2,7 @@
* localinput.cpp: Local streams
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: localinput.cpp,v 1.12 2002/11/05 02:10:53 nitrox Exp $
* $Id: localinput.cpp,v 1.13 2002/12/09 01:36:24 nitrox Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -49,6 +49,7 @@
#include "localinput.h"
#define MAX_FILES_NUMBER 4096
//------------------------------------------------------------------------------
// Library declaration
......@@ -103,25 +104,15 @@ void C_LocalInput::OnInit()
ASSERT(pApp);
// Build the program list
C_String strPgrmCount = pApp->GetSetting("Input.ProgramCount", "0");
unsigned int uiPgrmCount = strPgrmCount.ToInt();
if(uiPgrmCount)
for(int ui = 1;
ui <= pApp->GetSetting(GetName()+".ProgramCount", "0").ToInt(); ui++)
{
for(unsigned int ui = 1; ui <= uiPgrmCount; ui++)
{
C_String strName = pApp->GetSetting(C_String(ui) + ".Name",
C_String("Pgrm") + ui);
C_String* pStr = new C_String(strName);
m_vProgramNames.Add(pStr);
Log(m_hLog, LOG_NOTE, "Added program '" + *pStr+"'");
}
}
else
{
Log(m_hLog, LOG_WARN,
"The \"ProgramCount\" variable isn't specified in the file \"" +
m_strConfigPath + "/input.cfg\"");
C_String strName = pApp->GetSetting(GetName()+"."+C_String(ui)
+ ".Name", C_String("Pgrm") + ui);
C_String* pStr = new C_String(strName);
m_vProgramNames.Add(pStr);
Log(m_hLog, LOG_NOTE, "Added program '" + *pStr+"'");
}
}
......@@ -176,7 +167,8 @@ void C_LocalInput::OnStartStreaming(C_Broadcast* pBroadcast)
unsigned int uiId =
m_vProgramNames.Find(pBroadcast->GetProgram()->GetName()) + 1;
ASSERT(uiId > 0);
C_String strType = pApp->GetSetting(C_String(uiId) + ".Type",
C_String strId = GetName() + "." + uiId;
C_String strType = pApp->GetSetting(strId + ".Type",
"Mpeg2-TS").ToLower();
C_String strReaderType;
......@@ -191,7 +183,7 @@ void C_LocalInput::OnStartStreaming(C_Broadcast* pBroadcast)
// Reader configuration
strReaderType = "file";
C_String strFile = m_strFilesPath +
pApp->GetSetting(C_String(uiId)+".FileName", "");
pApp->GetSetting(strId+".FileName", "");
pBroadcast->SetOption("filename", strFile);
// Converter configuration
......@@ -207,7 +199,7 @@ void C_LocalInput::OnStartStreaming(C_Broadcast* pBroadcast)
// Reader configuration
strReaderType = "file";
C_String strFile = m_strFilesPath +
pApp->GetSetting(C_String(uiId)+".FileName", "");
pApp->GetSetting(strId+".FileName", "");
pBroadcast->SetOption("filename", strFile);
// Converter configuration
......@@ -222,7 +214,7 @@ void C_LocalInput::OnStartStreaming(C_Broadcast* pBroadcast)
// Reader configuration
strReaderType = "file";
C_String strFile = m_strFilesPath +
pApp->GetSetting(C_String(uiId)+".FileName", "");
pApp->GetSetting(strId+".FileName", "");
pBroadcast->SetOption("filename", strFile);
// Converter configuration
......@@ -235,7 +227,7 @@ void C_LocalInput::OnStartStreaming(C_Broadcast* pBroadcast)
pBuffer = new C_SyncFifo(uiSize);
// Reader configuration
strReaderType = "dvd";
C_String strDevice = pApp->GetSetting(C_String(uiId)+".Device", "");
C_String strDevice = pApp->GetSetting(strId+".Device", "");
pBroadcast->SetOption("device", strDevice);
// Converter configuration
......@@ -444,9 +436,7 @@ void C_LocalInput::OnUpdateProgram(C_String strProgram,
}
else
{
throw E_Exception(GEN_ERR,
"The \"ProgramCount\" variable isn't specified in the file \"" +
m_strConfigPath + "/input.cfg\"");
throw E_Exception(GEN_ERR, "No files defined in vls.cfg");
}
}
......
......@@ -2,7 +2,7 @@
* manager.cpp: Vls manager
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: manager.cpp,v 1.21 2002/11/19 14:08:07 nitrox Exp $
* $Id: manager.cpp,v 1.22 2002/12/09 01:36:24 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -401,8 +401,13 @@ void C_Manager::StopPrograms()
HandleRequest(cRequest);
LogDbg(m_hLog, "Remove the broadcast");
m_cBroadcasts.Lock();
#ifdef DEBUG
int iRc = m_cBroadcasts.Remove(cRequest.GetArg("program") + ":" +
cRequest.GetArg("input"));
#else
m_cBroadcasts.Remove(cRequest.GetArg("program") + ":" +
cRequest.GetArg("input"));
#endif
m_cBroadcasts.UnLock();
LogDbg(m_hLog, C_String("Broadcast removed with status ") + iRc);
}
......@@ -950,7 +955,11 @@ C_Answer C_Manager::Stop(const C_Request& cRequest)
m_cInputList.Release(pInput->GetName());
LogDbg(m_hLog, "Remove the broadcast");
#ifdef DEBUG
int iRc = m_cBroadcasts.Remove(strChannel);
#else
m_cBroadcasts.Remove(strChannel);
#endif
LogDbg(m_hLog, C_String("Broadcast removed with status ") + iRc);
}
else
......@@ -1418,62 +1427,6 @@ C_Answer C_Manager::Input(const C_Request& cRequest)
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage( "Input type \"dvb\" expects \"device number\"." );
}
strDeviceType = cRequest.GetArg("device_type");
ASSERT( strDeviceType != "" );
if (strDeviceType == "")
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage( "Input type \"dvb\" expects \"device type\" (nova)." );
}
strFrequency = cRequest.GetArg("frequency");
ASSERT( strFrequency != "" );
if (strFrequency == "")
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage( "Input type \"dvb\" expects \"transponder frequency\"." );
}
strPolarization = cRequest.GetArg("polarization");
ASSERT( strPolarization != "" );
if (strPolarization == "")
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage( "Input type \"dvb\" expects \"polarization\" (0 is vertical and 1 is horizontal)." );
}
strSymbolRate = cRequest.GetArg("symbol_rate");
ASSERT( strSymbolRate != "" );
if (strSymbolRate == "")
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage( "Input type \"dvb\" expects \"symbol rate\"." );
}
strUseDiSEqC = cRequest.GetArg("use_disecq");
ASSERT( strUseDiSEqC != "" );
if (strUseDiSEqC == "")
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage( "Input type \"dvb\" expects \"use DiSEqC\" (0 is false and 1 is true)." );
}
strLNB_Lof1 = cRequest.GetArg("lnb_lof1");
ASSERT( strLNB_Lof1 != "" );
if (strLNB_Lof1 == "")
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage( "Input type \"dvb\" expects \"LNB_Lof1\"." );
}
strLNB_Lof2 = cRequest.GetArg("lnb_lof2");
ASSERT( strLNB_Lof2 != "" );
if (strLNB_Lof2 == "")
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage( "Input type \"dvb\" expects \"LNB_Lof2\"." );
}
strLNB_SLof = cRequest.GetArg("lnb_slof");
ASSERT( strLNB_SLof != "" );
if (strLNB_SLof == "")
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage( "Input type \"dvb\" expects \"SLNB_Lof\"." );
}
}
// Check for errors in command syntax
if (cAnswer.GetStatus() == GEN_ERR)
......@@ -1537,22 +1490,6 @@ C_Answer C_Manager::Input(const C_Request& cRequest)
{
strKey = strInputName+C_String(".DeviceNumber");
pApp->SetSettings( strKey, strDeviceNumber );
strKey = strInputName+C_String(".DeviceType");
pApp->SetSettings( strKey, strDeviceType );
strKey = strInputName+C_String(".Frequency");
pApp->SetSettings( strKey, strFrequency );
strKey = strInputName+C_String(".Polarization");
pApp->SetSettings( strKey, strPolarization );
strKey = strInputName+C_String(".SymbolRate");
pApp->SetSettings( strKey, strSymbolRate );
strKey = strInputName+C_String(".DiSEqc");
pApp->SetSettings( strKey, strUseDiSEqC );
strKey = strInputName+C_String(".LNB_Lof1");
pApp->SetSettings( strKey, strLNB_Lof1 );
strKey = strInputName+C_String(".LNB_Lof2");
pApp->SetSettings( strKey, strLNB_Lof2 );
strKey = strInputName+C_String(".LNB_SLof");
pApp->SetSettings( strKey, strLNB_SLof );
}
// Create the input for the given source
......@@ -1656,30 +1593,6 @@ C_Answer C_Manager::Input(const C_Request& cRequest)
strKey = strInputName+C_String(".DeviceNumber");
if (pApp->GetSetting(strKey, "") != "")
pApp->DeleteSetting(strKey);
strKey = strInputName+C_String(".DeviceType");
if (pApp->GetSetting(strKey, "") != "")
pApp->DeleteSetting(strKey);
strKey = strInputName+C_String(".Frequency");
if (pApp->GetSetting(strKey, "") != "")
pApp->DeleteSetting(strKey);
strKey = strInputName+C_String(".Polarization");
if (pApp->GetSetting(strKey, "") != "")
pApp->DeleteSetting(strKey);
strKey = strInputName+C_String(".SymbolRate");
if (pApp->GetSetting(strKey, "") != "")
pApp->DeleteSetting(strKey);
strKey = strInputName+C_String(".DiSEqc");
if (pApp->GetSetting(strKey, "") != "")
pApp->DeleteSetting(strKey);
strKey = strInputName+C_String(".LNB_Lof1");
if (pApp->GetSetting(strKey, "") != "")
pApp->DeleteSetting(strKey);
strKey = strInputName+C_String(".LNB_Lof2");
if (pApp->GetSetting(strKey, "") != "")
pApp->DeleteSetting(strKey);
strKey = strInputName+C_String(".LNB_SLof");
if (pApp->GetSetting(strKey, "") != "")
pApp->DeleteSetting(strKey);
}
Log(m_hLog, LOG_NOTE, "Input '" + strInputName + "' removed !");
}
......
......@@ -2,7 +2,7 @@
* output.cpp: output streams
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: output.cpp,v 1.5 2002/09/24 13:09:14 asmax Exp $
* $Id: output.cpp,v 1.6 2002/12/09 01:36:24 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -122,7 +122,11 @@ void C_Output::Send(C_TsPacket* pPacket, bool RtpEncapsulation)
ASSERT(pPacket);
// Append the packet to the buffer for later write to the output
#ifdef DEBUG
int iRc = m_cTsBuff.Push(pPacket);
#else
m_cTsBuff.Push(pPacket);
#endif
ASSERT(!iRc);
if(m_cTsBuff.Size() == m_cTsBuff.Capacity())
......
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