Commit 8e8eebe4 authored by Damien Lucas's avatar Damien Lucas

. Makefile: when profiling with gcc/gprof you have to link with -pg option

. dummyinterface: add a m_bStop attribute so that we can stop it
                  change the sleep delay for 2 sec (delay when stopping)
. normaltrickplay: add a todo : we should not release a lock that another
                    thread locked
. telnetinterface: adds a path notion : when in 'xxxxxx' directory 'yy'
   command launches xxxxxx_yy()
. interface.cpp: unref the module count in the destructor so that we are
    able to unload the module at shutdown

. ALL :
    1/ change the following functions:
        . added 'cd'
        .  changed the 'help' command
        . added 'broadcast/ls'
        . added 'broadcast/add'
        . added 'broadcast/del'
        . added 'broadcast/help'
        . added 'channel/ls'
        . added 'channel/add'
        . added 'channel/del'
        . added 'channel/help'

    2/ the manager.cpp file has been split in 3
        . manager_broadcast.cpp contains all the broadcasts related functions
        . manager_channel.cpp contains all the channels related functions

    3/ thread structure:
        . all the interface are now threaded and not only the (n-1) first ones.
        . main thread is not any more the last interface one but is now the
          manager one (C_Manager does not inheritate from C_Thread any more)

    4/ shutdown
        . fix all the shutdown bugs : vls now shuts down correctly when Ctrl-C
          and when shutdowing from interface



Plans for a 0.6.0 version
-------------------------
  I think you should plan a 0.6.0 release. Major improvements would be:
    . interface modularisation
    . v4l input
    . trickplay (even if there is no new feature so far )
    . new telnet command architecture

  I identify the following bugs that need to be fixed for the release:
    . v4l input broken since trickplay commit (assigned to tooney)
    . ps2ts converter broken since trickplay commit (assigned to jpsaman)
    . dvb input to be re-wrote (trickplay  & libdvb use) (assigned to me)

if you want to had any new code in that release, please tell us quickly.
if you know any ug that is not mention here, please tell us too.

thanks


regards,
parent 85573fe7
......@@ -2,7 +2,7 @@
* thread.cpp: thread management
*-------------------------------------------------------------------------------
* (c)1999-2003 VideoLAN
* $Id: thread.cpp,v 1.8 2003/07/02 15:05:28 jpsaman Exp $
* $Id: thread.cpp,v 1.9 2003/08/04 08:27:23 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -192,8 +192,8 @@ void C_Thread::Stop()
if (GetCurrentThread() == hThread)
#endif
{
ASSERT(false);
//s_cThreadKiller.Kill(this);
ASSERT(false);
//s_cThreadKiller.Kill(this);
}
// Don't join if not started
......
......@@ -2,7 +2,7 @@
* dummyinterface.cpp:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: dummyinterface.cpp,v 1.4 2003/06/02 19:50:35 jpsaman Exp $
* $Id: dummyinterface.cpp,v 1.5 2003/08/04 08:27:23 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -101,6 +101,7 @@ C_DummyInterface::C_DummyInterface(C_Module* pModule,
C_InterfaceConfig& cConfig) :
C_Interface(pModule,cConfig)
{
m_bStop=0;
}
......@@ -129,9 +130,9 @@ void C_DummyInterface::InitSession()
//------------------------------------------------------------------------------
void C_DummyInterface::RunSession()
{
while(1)
while(!m_bStop)
{
sleep(5000);
sleep(2);
}
}
......@@ -140,6 +141,7 @@ void C_DummyInterface::RunSession()
//------------------------------------------------------------------------------
void C_DummyInterface::StopSession()
{
m_bStop=true;
}
//------------------------------------------------------------------------------
......
......@@ -2,7 +2,7 @@
* dummyinterface.h:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: dummyinterface.h,v 1.1 2003/02/16 15:41:28 tooney Exp $
* $Id: dummyinterface.h,v 1.2 2003/08/04 08:27:23 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -69,6 +69,8 @@ class C_DummyInterface : public C_Interface
virtual void RunSession();
virtual void DestroySession();
private:
bool m_bStop;
};
......
......@@ -3,7 +3,7 @@
* start, stop, suspend and resume operations.
*-------------------------------------------------------------------------------
* (c)1999-2003 VideoLAN
* $Id: normaltrickplay.cpp,v 1.4 2003/07/31 14:46:37 nitrox Exp $
* $Id: normaltrickplay.cpp,v 1.5 2003/08/04 08:27:23 nitrox Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -172,6 +172,8 @@ void C_NormalTrickPlay::StopWork()
// Should test the resumecond state before releasing it
// debuggers like valgrind really don't like that
// nitrox
// We can't Release if another thread locked it !!!
m_cResumeCond.Release();
C_TrickPlay::StopWork();
}
......
......@@ -2,7 +2,7 @@
* telnetinterface.cpp:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: telnetinterface.cpp,v 1.2 2003/07/30 09:36:22 nitrox Exp $
* $Id: telnetinterface.cpp,v 1.3 2003/08/04 08:27:23 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -76,8 +76,8 @@ C_Module* NewBuiltin_telnetinterface(handle hLog)
#define WELCOME "Videolan Server Administration System"
#define LOGIN "Login: "
#define PASSWD "Password: "
#define PROMPT "vls> "
#define PROMPT "vls:"
#define PROMPTEND "# "
//------------------------------------------------------------------------------
// Telnet protocol constants
......@@ -289,10 +289,14 @@ C_Buffer<byte> C_TelnetInterfaceCmdLine::Edit(const C_Buffer<byte>& cCmd)
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
C_String C_TelnetInterfaceCmdLine::GetCmdLine()
C_String C_TelnetInterfaceCmdLine::GetCmdLine(C_String strPath)
{
// Strip line
C_String strResult = m_strLine.Strip(" \t");
if(strPath!="" && strResult.SubString(0,2) != "cd")
{
strResult = strPath + "_" + strResult;
}
return strResult;
}
......@@ -305,7 +309,7 @@ C_String C_TelnetInterfaceCmdLine::GetCmdLine()
void C_TelnetInterfaceCmdLine::StartNewLine()
{
// Store current line if not empty
C_String strLine = GetCmdLine();
C_String strLine = GetCmdLine("");
if(strLine.Length() > 0)
{
m_cHistory.PushStart(new C_String(strLine));
......@@ -587,21 +591,21 @@ void C_TelnetInterfaceSession::ExecLogin()
if(m_iPhase == LOGIN_PHASE)
{
// This is the login which has just been entered
m_strLogin = m_cCmdLine.GetCmdLine();
m_strLogin = m_cCmdLine.GetCmdLine("");
m_strPrompt = PASSWD;
m_iPhase = PASSWD_PHASE;
}
else
{
// Login has been entered before, this is the passwd
C_String strPasswd = m_cCmdLine.GetCmdLine();
C_String strPasswd = m_cCmdLine.GetCmdLine("");
// Authentication (to do)
int iRc = Authenticate(m_strLogin, strPasswd);
if(!iRc)
{
m_strPrompt = m_strLogin + "@" + PROMPT;
m_strPrompt = m_strLogin + "@" + PROMPT + m_strPath + PROMPTEND;
m_iPhase = COMMAND_PHASE;
}
else
......@@ -624,7 +628,7 @@ void C_TelnetInterfaceSession::ExecCommand()
{
ASSERT(m_iPhase == COMMAND_PHASE);
C_String strCmd = m_cCmdLine.GetCmdLine();
C_String strCmd = m_cCmdLine.GetCmdLine(m_strPath);
C_Request cRequest("");
C_Answer cAdminAnswer = m_pAdmin->ParseCmdLine(this, strCmd, cRequest);
......@@ -635,6 +639,32 @@ void C_TelnetInterfaceSession::ExecCommand()
{
throw E_TelnetInterface("logout requested");
}
else if (cRequest.GetCmd() == "cd")
{
// TODO find something a bit more generic ;-)
// nitrox
if(m_strPath == "" && cRequest.GetArg("path") == "broadcast")
{
m_strPath = "broadcast";
}
else if( cRequest.GetArg("path") == "..")
{
m_strPath = "";
}
else if( m_strPath == "" && cRequest.GetArg("path") == "channel")
{
m_strPath = "channel";
}
else if( m_strPath == "" && cRequest.GetArg("path") == "channel")
{
m_strPath = "input";
}
else if( m_strPath == "" && cRequest.GetArg("path") == "channel")
{
m_strPath = "program";
}
m_strPrompt = m_strLogin + "@" + PROMPT + m_strPath + PROMPTEND;
}
else
{
C_Answer cAnswer = m_pAdmin->HandleRequest(cRequest);
......
......@@ -2,7 +2,7 @@
* telnetinterface.h: Telnet class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: telnetinterface.h,v 1.2 2003/06/02 14:10:45 nitrox Exp $
* $Id: telnetinterface.h,v 1.3 2003/08/04 08:27:23 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -112,7 +112,7 @@ class C_TelnetInterfaceCmdLine
void DropLine();
// Cmd line retrieval
C_String GetCmdLine();
C_String GetCmdLine(C_String);
private:
// Current command line
......@@ -158,6 +158,7 @@ class C_TelnetInterfaceSession : public C_InterfaceSession
int m_iMode;
// Internal data
C_String m_strPath;
C_String m_strPrompt;
C_String m_strLogin;
C_TelnetInterfaceCmdLine m_cCmdLine;
......
......@@ -2,7 +2,7 @@
* admin.cpp:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: admin.cpp,v 1.25 2003/08/01 16:07:09 nitrox Exp $
* $Id: admin.cpp,v 1.26 2003/08/04 08:27:23 nitrox Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -234,6 +234,14 @@ int C_Admin::Init()
pCmdDesc->m_vOptionalArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// cd (interface specific command)
pCmdDesc = new C_CommandDesc("cd",
"change directories.",
"Called with one argument, \"cd\" changes the current directory.");
pStr = new C_String("path");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- browse [input]
pCmdDesc = new C_CommandDesc("browse",
"gives the program list",
......@@ -473,6 +481,89 @@ int C_Admin::Init()
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// ******** BROADCAST LOW LEVEL COMMANDS ******
// -- broadcast_ls
pCmdDesc = new C_CommandDesc("broadcast_ls",
"lists all the defined broadcasts and their states.",
"\"broadcast_ls\" lists all the defined broadcasts and their states");
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- broadcast_add
pCmdDesc = new C_CommandDesc("broadcast_add",
"adds a new broadcast.",
"\"broadcast_add\" adds a new broadcast to the list."
"It becomes available for streaming\n");
pStr = new C_String("name");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("channel");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("program");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("input");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- broadcast_del
pCmdDesc = new C_CommandDesc("broadcast_del",
"deletes a configured broadcast.",
"\"broadcast_del\" deletes a configures broadcast."
"\n");
pStr = new C_String("name");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("force");
pCmdDesc->m_vBooleans.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- broadcast_help
pCmdDesc = new C_CommandDesc("broadcast_help",
"display the list of availables commands.",
"\"broadcast_help\" displays help on the broadcast commands."
"\n");
pStr = new C_String("command");
pCmdDesc->m_vOptionalArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// ******** CHANNEL LOW LEVEL COMMANDS ******
// -- channel_ls
pCmdDesc = new C_CommandDesc("channel_ls",
"lists all the defined channels and their properties.",
"\"channel_ls\" lists all the defined channels and their properties");
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- channel_add <name> <type> <dest_host> <dest_port> <streamtype>
// [domain] [ttl] [intf]
pCmdDesc = new C_CommandDesc("channel_add",
"adds a new channel.",
"\"add\" adds a channel definition."
" it becomes available for broadcast.");
pStr = new C_String("name");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("type");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("dest_host");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("dest_port");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("stream_type");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("domain");
pCmdDesc->m_vOptionalArgs.Add(pStr);
pStr = new C_String("ttl");
pCmdDesc->m_vOptionalArgs.Add(pStr);
pStr = new C_String("interface");
pCmdDesc->m_vOptionalArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- broadcast_del
pCmdDesc = new C_CommandDesc("channel_del",
"deletes a configured channel.",
"\"del\" deletes a configured channel."
"\n");
pStr = new C_String("name");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// Groups
C_Vector<C_Setting> vGroups = pApp->GetSettings("Groups");
......@@ -598,7 +689,7 @@ int C_Admin::Init()
//------------------------------------------------------------------------------
int C_Admin::Run()
{
m_cInterfaceList.Lock();
/*m_cInterfaceList.Lock();
C_RepositoryBrowser<C_String, C_Interface> cIterator =
m_cInterfaceList.CreateBrowser();
m_cInterfaceList.UnLock();
......@@ -609,14 +700,15 @@ int C_Admin::Run()
try
{
pInterface->Run();
pInterface->Create();
//pInterface->Run();
}
catch(E_Exception e)
{
C_String strInterfaceName = pInterface->GetName();
Log(m_hLog, LOG_ERROR,"Unable to run "+strInterfaceName);
}
}
}*/
// Unlock the Interface repository
//
......@@ -625,9 +717,7 @@ int C_Admin::Run()
// -- nitrox
// m_cInterfaceList.UnLock();
int iRc = FullStop();
return iRc;
return 0;
}
......@@ -648,16 +738,15 @@ int C_Admin::Stop()
try
{
//m_cInterfaceList.Remove(strInterfaceName);
pInterface->StopInterface();
pInterface->Stop();
//m_cInterfaceList.Remove(strInterfaceName);
}
catch(E_Exception e)
{
Log(m_hLog, LOG_ERROR, "Unable to stop "+strInterfaceName);
}
}
// Unlock the Interface repository
m_cInterfaceList.UnLock();
......@@ -1006,7 +1095,7 @@ C_Answer C_Admin::HandleRequest(const C_Request& cRequest)
m_cRequestLock.Lock();
C_String strCmd = cRequest.GetCmd();
if(strCmd == "help")
if(strCmd.Find("help") != GEN_ERR)
{
C_String strArg = cRequest.GetArg("command");
if(strArg.Length() == 0)
......@@ -1019,11 +1108,31 @@ C_Answer C_Admin::HandleRequest(const C_Request& cRequest)
C_HashTableNode<C_String, C_CommandDesc>* pNode =
cIterator.GetNext();
C_CommandDesc* pCmdDesc = pNode->GetValue();
cAnswer.AddMessage(pCmdDesc->m_strName + ": " + pCmdDesc->m_strHelp);
int iHelp = strCmd.Find("_");
int iCmd = pCmdDesc->m_strName.Find("_");
if(iHelp == GEN_ERR && iCmd == GEN_ERR)
{
cAnswer.AddMessage(pCmdDesc->m_strName + ": " + pCmdDesc->m_strHelp);
}
else if (iHelp != GEN_ERR && iCmd != GEN_ERR)
{
C_String helpRoot = strCmd.SubString(0, iHelp);
C_String cmdRoot = pCmdDesc->m_strName.SubString(0, iCmd);
C_String strMessage;
strMessage = pCmdDesc->m_strName.SubString(iCmd+1,
pCmdDesc->m_strName.Length());
strMessage += ": ";
strMessage += pCmdDesc->m_strHelp;
if(helpRoot == cmdRoot) cAnswer.AddMessage(strMessage);
}
}
}
else
{
int iCmd;
if((iCmd = strCmd.Find("_")) != GEN_ERR)
strArg = strCmd.SubString(0, iCmd+1) + strArg;
C_CommandDesc* pCmdDesc = m_cCmdDescriptions.Get(strArg);
if(pCmdDesc)
{
......@@ -1148,13 +1257,14 @@ void C_Admin::InitInterfaces()
Log(m_hLog, LOG_NOTE, "Starting interface '"+strInterfaceName+"'");
try
{
pInterface->SetConfig( (i != vInterfaces.Size()-1), strInterfaceName);
pInterface->SetConfig( strInterfaceName );
// Initialize the interface
pInterface->Init();
// Last Interface shall not be run as a separate thread
if ( i != vInterfaces.Size()-1 ) pInterface->Create();
// if ( i != vInterfaces.Size()-1 )
pInterface->Create();
// And register it
m_cInterfaceList.Add(strInterfaceName, pInterface);
......
......@@ -2,7 +2,7 @@
* adminintf.cpp:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: interface.cpp,v 1.3 2003/07/31 14:46:37 nitrox Exp $
* $Id: interface.cpp,v 1.4 2003/08/04 08:27:23 nitrox Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -172,15 +172,24 @@ C_Interface::C_Interface(C_Module* pModule, C_InterfaceConfig& cConfig) //:
m_hLog = cConfig.hLog;
m_pAdmin = cConfig.pAdmin;
m_pModule = pModule;
}
//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
C_Interface::~C_Interface() //:
{
m_pModule->Unref();;
}
//------------------------------------------------------------------------------
// Parameters
//------------------------------------------------------------------------------
void C_Interface::SetConfig(bool bIsThreaded, C_String sModuleName)
void C_Interface::SetConfig(C_String sModuleName)
{
m_bIsThreaded = bIsThreaded;
m_sInterfaceName = sModuleName;
}
......@@ -221,14 +230,8 @@ int C_Interface::StopInterface()
try
{
if (!m_bIsThreaded)
{
StopSession();
}
else
{
this->Stop();
}
//We have to stop all sessions
StopSession();
}
catch(E_Exception e)
{
......@@ -282,12 +285,10 @@ void C_Interface::InitWork()
//------------------------------------------------------------------------------
void C_Interface::DoWork()
{
ASSERT(m_bIsThreaded);
try
{
RunSession();
Log(m_hLog, LOG_NOTE, m_sInterfaceName + " interface started");
}
catch(E_Exception e)
{
......@@ -302,7 +303,6 @@ void C_Interface::DoWork()
//------------------------------------------------------------------------------
void C_Interface::StopWork()
{
ASSERT(m_bIsThreaded);
StopSession();
}
......@@ -314,6 +314,5 @@ void C_Interface::StopWork()
//------------------------------------------------------------------------------
void C_Interface::CleanWork()
{
ASSERT(m_bIsThreaded);
}
......@@ -2,7 +2,7 @@
* interface.h:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: interface.h,v 1.3 2003/07/31 14:46:37 nitrox Exp $
* $Id: interface.h,v 1.4 2003/08/04 08:27:23 nitrox Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -95,6 +95,7 @@ class C_Interface : public C_Thread
{
public:
C_Interface(C_Module* pModule, C_InterfaceConfig& cConfig);
~C_Interface();
virtual void PropagateEvent(const C_Event& cEvent);
......@@ -103,7 +104,7 @@ public:
int StopInterface();
int Destroy();
void SetConfig(bool bIsThreaded, C_String sModuleName);
void SetConfig(C_String sModuleName);
C_String GetName() {return m_sInterfaceName;};
......@@ -124,13 +125,13 @@ protected:
// Helpers
handle m_hLog;
C_Admin* m_pAdmin;
bool m_bIsThreaded;
// Event fifo
C_Vector<C_Event> m_cEvents;
C_Mutex m_cEventsLock;
C_String m_sInterfaceName;
C_Module* m_pModule;
};
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* manager.h: Manager class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: manager.h,v 1.6 2003/07/30 15:55:07 nitrox Exp $
* $Id: manager.h,v 1.7 2003/08/04 08:27:23 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -32,8 +32,7 @@
//------------------------------------------------------------------------------
// C_Manager : manage all the inputs and their programs
//------------------------------------------------------------------------------
class C_Manager : public C_RequestHandler, public C_EventHandler,
public C_Thread
class C_Manager : public C_RequestHandler, public C_EventHandler
{
public:
C_Manager(handle hLog, C_EventHub* pEventHub);
......@@ -77,11 +76,13 @@ class C_Manager : public C_RequestHandler, public C_EventHandler,
C_Answer Forward(const C_Request& cRequest);
C_Answer Rewind(const C_Request& cRequest);
// C_Thread APIs to isolate events
virtual void InitWork();
virtual void DoWork();
virtual void StopWork();
virtual void CleanWork();
C_Answer Broadcast_Ls(const C_Request& cRequest);
C_Answer Broadcast_Add(const C_Request& cRequest);
C_Answer Broadcast_Del(const C_Request& cRequest);
C_Answer Channel_Ls(const C_Request& cRequest);
C_Answer Channel_Add(const C_Request& cRequest);
C_Answer Channel_Del(const C_Request& cRequest);
private:
virtual void PrivHandleEvent(const C_Event& cEvent);
......@@ -106,7 +107,7 @@ class C_Manager : public C_RequestHandler, public C_EventHandler,
C_PgrmDirectory m_cProgramList;
// Running broadcasts
C_Repository<C_String, C_Broadcast> m_cBroadcasts;
C_Repository<C_String, C_Broadcast> m_cBroadcastsList;
};
......
/*******************************************************************************
* manager_broadcast.cpp: Brodacast mtehods for Vls manager
*-------------------------------------------------------------------------------
* (c)1999-2003 VideoLAN
* $Id: manager_broadcast.cpp,v 1.1 2003/08/04 08:27:23 nitrox Exp $
*
* Authors: Damien Lucas <damien.lucas@anevia.com>
* Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*-------------------------------------------------------------------------------
*
*******************************************************************************/
C_Broadcast* C_Manager::CreateBroadcast(C_String& strName,
C_String& strChannel,
C_String& strPgrm,
C_String& strInput,
C_Answer* cAnswer)
{
C_Broadcast* pBroadcast = NULL;
// Find the channel
ASSERT(strChannel != "");
C_Channel* pChannel = m_cChannelList.Get(strChannel);
if(!pChannel)
{
cAnswer->SetStatus(ANS_CHANNEL_UNKNOWN);
cAnswer->AddMessage("Unknown channel");
}
else if(!pChannel->IsFree())
{
cAnswer->SetStatus(ANS_CHANNEL_BUSY);
cAnswer->AddMessage("Channel is busy");
pChannel = NULL;
}
// Find the pgrm
ASSERT(strPgrm != "");
const C_Program* pPgrm = m_cProgramList.GetPgrm(strPgrm);
if(!pPgrm)
{
cAnswer->SetStatus(ANS_PROGRAM_UNKNOWN);
cAnswer->AddMessage("Unknown pgrm "+strPgrm);
}
// Find the input
C_Input* pInput = m_cInputList.Get(strInput);
if(!pInput)
{
cAnswer->SetStatus(ANS_INPUT_UNKNOWN);
cAnswer->AddMessage("input doesn't exist");
}
// We have all the elements, we can create the broadcast
if(pPgrm && pInput && pChannel)
{
pBroadcast = new C_Broadcast(pPgrm, pInput, pChannel, strName);
m_cBroadcastsList.Lock();
m_cBroadcastsList.Add(strName, pBroadcast);
m_cBroadcastsList.UnLock();
}
else if(pInput)
{
m_cInputList.Release(strInput);
}
return pBroadcast;
}
C_Answer C_Manager::Broadcast_Ls(const C_Request& cRequest)
{
C_Answer cAnswer("Manager");
cAnswer.AddMessage("broadcasts");
// Lock Broadcast repository
m_cBroadcastsList.Lock();
C_RepositoryBrowser<C_String, C_Broadcast> cIterator1 =
m_cBroadcastsList.CreateBrowser();
while(cIterator1.HasNextItem())
{
C_Broadcast* pBroadcast = cIterator1.GetNextItem();
C_Answer cBroadcast(pBroadcast->GetChannel()->GetName());
cBroadcast.SetStatus(NO_ERR);
cBroadcast.AddMessage("channel "+pBroadcast->GetChannel()->GetName());
cBroadcast.AddMessage("program "+pBroadcast->GetProgram()->GetName());
cBroadcast.AddMessage("input "+pBroadcast->GetInput()->GetName());
cBroadcast.AddMessage("status "+C_String(pBroadcast->GetStatus()));
cBroadcast.AddMessage("rtp "+pBroadcast->GetOption("rtp"));
cBroadcast.AddMessage("end "+pBroadcast->GetOption("end"));
cBroadcast.AddMessage("loop "+pBroadcast->GetOption("loop"));
cAnswer.Add(cBroadcast);
}
// UnLock Broadcast repository
m_cBroadcastsList.UnLock();
cAnswer.SetStatus(ANS_NO_ERR);
return cAnswer;
}
C_Answer C_Manager::Broadcast_Add(const C_Request& cRequest)