Commit 4636637e authored by Damien Lucas's avatar Damien Lucas

. more on the config --save command

. add < and > operators on C_Setting
. more on the tcpinput/tcpreader
parent 5d46bf4a
......@@ -2,7 +2,7 @@
* settings.cpp: Application settings management
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: settings.cpp,v 1.16 2003/08/14 08:50:14 nitrox Exp $
* $Id: settings.cpp,v 1.17 2003/08/29 10:20:52 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -122,9 +122,9 @@ void C_SettingsHandler::OnStartSection(const C_String& strName)
#ifdef DEBUG
printf("Implicit declaration of input 'local1'\n");
#endif
OnStartSection("Inputs");
OnStartSection("inputs");
OnProperty("local1", "local");
OnEndSection("Inputs");
OnEndSection("inputs");
m_strPrefix += "local1.";
m_iLocalCount++;
const C_String strN = m_iLocalCount;
......@@ -201,8 +201,6 @@ void C_SettingsHandler::OnProperty(const C_String& strName,
//******************************************************************************
// class C_Settings
//******************************************************************************
......
......@@ -2,7 +2,7 @@
* settings.h: Settings class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: settings.h,v 1.6 2003/06/02 09:22:45 nitrox Exp $
* $Id: settings.h,v 1.7 2003/08/29 10:20:52 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -43,12 +43,17 @@ class C_Setting
C_Setting* Clone() const
{ return new C_Setting(*this); }
const C_String& GetName() const
{ return m_strName; }
const C_String& GetValue() const
{ return m_strValue; }
bool operator < (const C_Setting& sArg) const
{ return (m_strName < sArg.GetName()); }
bool operator > (const C_Setting& sArg) const
{ return (m_strName > sArg.GetName()); }
private:
C_String m_strName;
C_String m_strValue;
......
......@@ -2,7 +2,7 @@
* vector.cpp: Vectors manipulation
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: vector.cpp,v 1.4 2003/08/28 18:03:26 tooney Exp $
* $Id: vector.cpp,v 1.5 2003/08/29 10:20:52 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -310,7 +310,7 @@ template <class T> void C_Vector<T>::Empty()
// Skip already handled items
if(m_apElems[j] == NULL)
continue;
// Find all the copies of the current item
for(unsigned int k = j+1; k < m_uiSize; k++)
{
......@@ -319,13 +319,13 @@ template <class T> void C_Vector<T>::Empty()
}
// Delete the first occurence of the current item
delete m_apElems[j];
delete m_apElems[j];
}
break;
}
default:
{
ASSERT(false);
ASSERT(false);
break;
}
}
......@@ -351,12 +351,12 @@ template <class T> void C_Vector<T>::QuickSort(int iLeft, int iRight)
for (iCurrent = iLeft + 1; iCurrent <= iRight; iCurrent++)
if ( *m_apElems[iCurrent] < *m_apElems[iLeft] )
Swap(++iPrevious, iCurrent);
Swap(iLeft, iPrevious);
QuickSort(iLeft, iPrevious-1);
QuickSort(iPrevious+1, iRight);
}
template <class T> void C_Vector<T>::Swap(unsigned int i, unsigned int j)
......
......@@ -2,7 +2,7 @@
* tcpinput.cpp: Input for spawning a tcp reader
*-------------------------------------------------------------------------------
* (c)2003 Anevia
* $Id: tcpinput.cpp,v 1.1 2003/08/25 12:45:59 nitrox Exp $
* $Id: tcpinput.cpp,v 1.2 2003/08/29 10:20:52 nitrox Exp $
*
* Authors: Damien Lucas <damien.lucas@anevia.com>
*
......@@ -132,9 +132,31 @@ C_List<C_Program> C_TcpInput::OnGetAvailablePgrms()
void C_TcpInput::OnStartStreaming(C_Broadcast* pBroadcast)
{
C_String strReaderType = "tcp";
C_String strConverterType = "ts2ts";
C_String strConverterType;
C_String strTrickPlayType = "normal";
// Get the converter required, configure the broadcast
C_Application* pApp = C_Application::GetApp();
C_String strType = pApp->GetSetting(GetName() + ".type", "mpeg2-ts");
if ( strType == "mpeg2-ts" )
{
strConverterType = "ts2ts";
pBroadcast->SetOption("mpegversion", "2");
pBroadcast->SetOption("preparse", "0");
}
else if ( strType == "mpeg2-ps" )
{
strConverterType = "ps2ts";
pBroadcast->SetOption("mpegversion", "2");
pBroadcast->SetOption("preparse", "0");
}
else if ( strType == "mpeg1-ps" )
{
strConverterType = "ps2ts";
pBroadcast->SetOption("mpegversion", "2");
pBroadcast->SetOption("preparse", "0");
}
// Create the netlist and the fifo
const C_Channel* pChannel = pBroadcast->GetChannel();
C_NetList* pTsProvider = new C_NetList(3*3*797);
......
......@@ -2,7 +2,7 @@
* TCP reader.cpp: TCP reader
*-------------------------------------------------------------------------------
* (c)2003 Anevia
* $Id: tcpreader.cpp,v 1.1 2003/08/25 12:45:59 nitrox Exp $
* $Id: tcpreader.cpp,v 1.2 2003/08/29 10:20:53 nitrox Exp $
*
* Authors: Damien Lucas <damien.lucas@anevia.com>
*
......@@ -78,6 +78,7 @@ C_TcpMpegReader::C_TcpMpegReader(C_Module* pModule,
C_Broadcast* pBroadcast) :
C_MpegReader(pModule, pBroadcast)
{
m_bXOR=0;
}
//------------------------------------------------------------------------------
......@@ -119,9 +120,18 @@ s64 C_TcpMpegReader::Read(byte* pBuff, s64 iSize)
{
unsigned int iRc = m_cSocket.Read((char*)pBuff,iSize);
CS_XOR(pBuff, iSize);
if(iRc<iSize) fprintf(stderr, "EOF reached\n");
return iRc;
}
void C_TcpMpegReader::CS_XOR(byte* pBuff, s64 iSize)
{
for(unsigned int i=0; i<iSize; i++) m_bXOR ^= pBuff[i];
}
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
* TCPreader.h: TCP reader
*-------------------------------------------------------------------------------
* (c)2003 Anevia
* $Id: tcpreader.h,v 1.1 2003/08/25 12:45:59 nitrox Exp $
* $Id: tcpreader.h,v 1.2 2003/08/29 10:20:53 nitrox Exp $
*
* Authors: Damien Lucas <damien.lucas@anevia.com>
*
......@@ -30,7 +30,7 @@
//------------------------------------------------------------------------------
// C_MpegXXXReader class
// C_MpegTcpReader class
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
......@@ -51,12 +51,20 @@ public:
virtual s64 GetPos();
virtual void ResetEndOfStream();
byte CS_XOR_Get() {return m_bXOR;};
protected:
C_Socket m_cSocket;
bool m_bEnd;
private:
void CS_XOR(byte*, s64);
byte m_bXOR;
};
// Declaration and implementation of C_TcpMpegReaderModule
DECLARE_MODULE(Tcp, MpegReader, "tcp", C_Broadcast*);
......
......@@ -2,7 +2,7 @@
* manager.cpp: Vls manager
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: manager.cpp,v 1.41 2003/08/14 11:12:54 nitrox Exp $
* $Id: manager.cpp,v 1.42 2003/08/29 10:20:53 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -59,7 +59,6 @@
#include "repository.cpp"
//TODO change the name
typedef C_Answer (C_Manager::*zzzz)(C_Request&);
#define AddFunction(y,z) \
......@@ -653,34 +652,47 @@ C_Answer C_Manager::Config(C_Request& cRequest)
m_cChannelList.Lock();
// Dump all settings
// TODO should sort the vector to group properties before
// -- nitrox
C_Application* pApp = C_Application::GetApp();
C_Vector<C_Setting> cConfig=pApp->GetAllSettings();
cConfig.Sort();
unsigned int k,i;
unsigned int iTokenCount[cConfig.Size()];
C_StringTokenizer** cTokens;
cTokens = new C_StringTokenizer*[cConfig.Size()];
for(k=0; k<cConfig.Size(); k++)
{
cTokens[k] = new C_StringTokenizer(cConfig[k].GetName(),'.');
iTokenCount[k] = cTokens[k]->CountTokens();
}
FILE* fd=fopen(strFileName.GetString(), "w");
for(unsigned int i=0; i<cConfig.Size(); i++)
WRITE_BEGINS(fd, iTokenCount[0], cTokens[0], 0);
for(i=0; i<cConfig.Size(); i++)
{
C_StringTokenizer cTokens(cConfig[i].GetName(), '.');
unsigned int iTokenCount=cTokens.CountTokens();
for(unsigned int k=0; k<iTokenCount-1; k++)
if(i)
{
for (unsigned int l=0; l<k; l++) fprintf(fd, " ");
fprintf(fd,"BEGIN \"%s\"\n", cTokens.NextToken().GetString());
//Compare tokens
cTokens[i]->Reset();
cTokens[i-1]->Reset();
for (k=0;
k<iTokenCount[i-1] &&
k<iTokenCount[i] &&
(cTokens[i]->NextToken()==
cTokens[i-1]->NextToken());
k++);
// k is the number of similar tokens
cTokens[i]->Reset(); cTokens[i-1]->Reset();
WRITE_ENDS(fd, iTokenCount[i-1], cTokens[i-1], k);
WRITE_BEGINS(fd, iTokenCount[i], cTokens[i], k);
}
//Indentation
for(unsigned int k=0;k<iTokenCount-1;k++)
{
fprintf(fd, " ");
}
fprintf(fd, "%s = \"%s\"\n", cTokens.NextToken().GetString(),
cConfig[i].GetValue().GetString());
for(unsigned int k=iTokenCount-1; k!=0; k--)
{
for (unsigned int l=0; l<k-1; l++) fprintf(fd, " ");
fprintf(fd,"END\n");
}
fprintf(fd, "\n");
WRITE_PROPERTY(fd, iTokenCount[i], cTokens[i]);
cTokens[i]->Reset();
}
WRITE_ENDS(fd, iTokenCount[i-1], cTokens[i-1], 0);
fclose(fd);
Log(m_hLog, LOG_NOTE, "Configuration written");
......
......@@ -2,7 +2,7 @@
* manager.h: Manager class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: manager.h,v 1.10 2003/08/13 15:59:31 nitrox Exp $
* $Id: manager.h,v 1.11 2003/08/29 10:20:53 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -119,6 +119,31 @@ private:
};
// Macro for writing configuration file
// TODO should be integrated in the parser part
#define WRITE_BEGINS(fd, iT, cT, v) \
for ( unsigned int km=0; km<v; km++) \
{ \
cT->NextToken(); \
} \
for ( unsigned int km=v; km<iT-1; km++) \
{ \
for (unsigned int l=0; l<km; l++) fprintf(fd, " "); \
fprintf(fd,"BEGIN \"%s\"\n", cT->NextToken().GetString()); \
}
#define WRITE_ENDS(fd, iT, cT, v) \
for(unsigned int km=iT-1; km>v; km--) \
{ \
for (unsigned int l=0; l<km-1; l++) fprintf(fd, " "); \
fprintf(fd,"END\n"); \
} \
if(v!=iT-1) fprintf(fd, "\n");
#define WRITE_PROPERTY(fd, iT, cT) \
for(unsigned int km=0;km<iT-1;km++) fprintf(fd, " "); \
fprintf(fd, "%s = \"%s\"\n", cT->NextToken().GetString(), \
cConfig[i].GetValue().GetString());
#else
#error "Multiple inclusions of manager.h"
......
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