Commit 62813ed3 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Added all dynamic configuration stuff (not finished yet).

- config changed into program
- config only accepts load/save now
- other commands talked about
Fixed a bug in src/core/stream.cpp line 332.

Hopefully I did not break anything ;-). With thanks to Tristan Leteurtre for helping out on this.
parent ed1a0ae2
......@@ -2,7 +2,7 @@
* application.h: Application class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: application.h,v 1.3 2002/08/14 11:13:27 tooney Exp $
* $Id: application.h,v 1.4 2002/09/04 10:56:34 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -70,6 +70,10 @@ class C_Application
{ return m_cSettings.GetSetting(strSetting, strDflt); }
C_Vector<C_Setting> GetSettings(const C_String& strSettingsGroup) const
{ return m_cSettings.GetSettings(strSettingsGroup); }
void SetSettings(C_String& strKey, C_String& strValue)
{ m_cSettings.Update(strKey.ToLower(), strValue.ToLower()); }
void DeleteSetting(C_String& strKey)
{ m_cSettings.Delete(strKey); }
// Access to the logging service
handle StartLog(const C_String& strClientDescr, u8 iFlags);
......
......@@ -2,7 +2,7 @@
* settings.cpp: Application settings management
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: settings.cpp,v 1.6 2002/04/10 10:47:18 asmax Exp $
* $Id: settings.cpp,v 1.7 2002/09/04 10:56:34 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -170,6 +170,11 @@ void C_Settings::Update(const C_String& strName, const C_String& strValue)
m_cSettings.Update(strName, new C_String(strValue));
}
void C_Settings::Delete(const C_String& strName)
{
m_cSettings.Delete(strName);
}
//------------------------------------------------------------------------------
......@@ -200,13 +205,14 @@ 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.ToLower() + "."))
{
// Strip the initial section name
unsigned int iOffset = strSection.Length() + 1;
unsigned int iLength = strName.Length();
C_String strSetting = strName.SubString(iOffset, iLength);
// Add the setting to the result
C_Setting* pSetting = new C_Setting(strSetting, *pstrValue);
vValues.Add(pSetting);
......@@ -215,4 +221,3 @@ C_Vector<C_Setting> C_Settings::GetSettings(const C_String& strSection) const
return vValues;
}
......@@ -2,7 +2,7 @@
* settings.h: Settings class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: settings.h,v 1.2 2001/10/18 06:29:11 benny Exp $
* $Id: settings.h,v 1.3 2002/09/04 10:56:34 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -75,6 +75,7 @@ class C_Settings
// Update the value for a given property, or add it if it is not already
// defined
void Update(const C_String& strName, const C_String& strValue);
void Delete(const C_String& strName);
// Access to the properties
C_String GetSetting(const C_String& strName, const C_String& strDflt) const;
......
......@@ -2,7 +2,7 @@
* stream.cpp: Stream class
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: stream.cpp,v 1.2 2002/06/19 22:53:51 massiot Exp $
* $Id: stream.cpp,v 1.3 2002/09/04 10:56:34 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -329,7 +329,7 @@ template <class IOStream>
do
{
int iRc = m_pIOStream->Read(aBytes+iOffset, iByteCount-iOffset);
ASSERT(iRc >= 0 || iRc = FILE_EOF);
ASSERT(iRc >= 0 || iRc == FILE_EOF);
iOffset += iRc;
}
while(iByteCount > 0 && iRc != FILE_EOF);
......
......@@ -2,7 +2,7 @@
* dvbinput.cpp: DVB streams
*-------------------------------------------------------------------------------
* (c)1999-2002 VideoLAN
* $Id: dvbinput.cpp,v 1.10 2002/08/09 13:42:32 tooney Exp $
* $Id: dvbinput.cpp,v 1.11 2002/09/04 10:56:34 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -659,7 +659,7 @@ void C_DvbInput::OnStopStreaming(C_Broadcast* pBroadcast)
//------------------------------------------------------------------------------
// Update configuration dynamically
//------------------------------------------------------------------------------
void C_DvbInput::OnUpdateConfiguration(C_String strProgram,
void C_DvbInput::OnUpdateProgram(C_String strProgram,
C_String strFileName, C_String strType)
{
}
......@@ -2,7 +2,7 @@
* dvbinput.h: DVB Input class definition
*-------------------------------------------------------------------------------
* (c)1999-2002 VideoLAN
* $Id: dvbinput.h,v 1.4 2002/07/12 14:38:56 jpsaman Exp $
* $Id: dvbinput.h,v 1.5 2002/09/04 10:56:34 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -48,7 +48,7 @@ protected:
virtual void OnResumeStreaming(C_Broadcast* pBroadcast);
virtual void OnSuspendStreaming(C_Broadcast* pBroadcast);
virtual void OnStopStreaming(C_Broadcast* pBroadcast);
virtual void OnUpdateConfiguration(C_String strProgram,
virtual void OnUpdateProgram(C_String strProgram,
C_String strFileName, C_String strType);
virtual C_List<C_Program> OnGetAvailablePgrms();
......
......@@ -2,7 +2,7 @@
* dvdreader.cpp: DVD reader
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: dvdreader.cpp,v 1.5 2002/07/29 22:56:36 massiot Exp $
* $Id: dvdreader.cpp,v 1.6 2002/09/04 10:56:34 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -538,4 +538,3 @@ s64 C_DvdMpegReader::GetPos()
ASSERT(false);
return 0;
}
......@@ -2,7 +2,7 @@
* localinput.cpp: Local streams
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: localinput.cpp,v 1.8 2002/08/09 13:42:32 tooney Exp $
* $Id: localinput.cpp,v 1.9 2002/09/04 10:56:34 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -417,7 +417,7 @@ void C_LocalInput::OnStopStreaming(C_Broadcast* pBroadcast)
//------------------------------------------------------------------------------
// Rewind the reception of the given program with specified speed
//------------------------------------------------------------------------------
void C_LocalInput::OnUpdateConfiguration(C_String strProgram,
void C_LocalInput::OnUpdateProgram(C_String strProgram,
C_String strFileName, C_String strType)
{
C_String strPgrmCount = m_cSettings.GetSetting("Input.ProgramCount", "0");
......
......@@ -2,7 +2,7 @@
* localinput.h: Local Input class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: localinput.h,v 1.2 2002/07/12 14:38:56 jpsaman Exp $
* $Id: localinput.h,v 1.3 2002/09/04 10:56:34 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -55,7 +55,7 @@ protected:
virtual void OnResumeStreaming(C_Broadcast* pBroadcast);
virtual void OnSuspendStreaming(C_Broadcast* pBroadcast);
virtual void OnStopStreaming(C_Broadcast* pBroadcast);
virtual void OnUpdateConfiguration(C_String strProgram,C_String strFileName, C_String strType);
virtual void OnUpdateProgram(C_String strProgram,C_String strFileName, C_String strType);
virtual C_List<C_Program> OnGetAvailablePgrms();
private:
......
......@@ -2,7 +2,7 @@
* videoinput.cpp: Video4linux streams
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: videoinput.cpp,v 1.9 2002/08/09 13:42:32 tooney Exp $
* $Id: videoinput.cpp,v 1.10 2002/09/04 10:56:34 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......@@ -352,7 +352,7 @@ void C_VideoInput::OnStopStreaming(C_Broadcast* pBroadcast)
//------------------------------------------------------------------------------
// Update configuration dynamically
//------------------------------------------------------------------------------
void C_VideoInput::OnUpdateConfiguration(C_String strProgram,
void C_VideoInput::OnUpdateProgram(C_String strProgram,
C_String strFileName, C_String strType)
{
}
......@@ -2,7 +2,7 @@
* videoinput.h: Video Input class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: videoinput.h,v 1.3 2002/07/12 14:38:56 jpsaman Exp $
* $Id: videoinput.h,v 1.4 2002/09/04 10:56:34 jpsaman Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
*
......@@ -51,7 +51,7 @@ protected:
virtual void OnResumeStreaming(C_Broadcast* pBroadcast);
virtual void OnSuspendStreaming(C_Broadcast* pBroadcast);
virtual void OnStopStreaming(C_Broadcast* pBroadcast);
virtual void OnUpdateConfiguration(C_String strProgram,
virtual void OnUpdateProgram(C_String strProgram,
C_String strFileName, C_String strType);
virtual C_List<C_Program> OnGetAvailablePgrms();
......
......@@ -2,7 +2,7 @@
* admin.cpp:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: admin.cpp,v 1.11 2002/08/09 13:42:32 tooney Exp $
* $Id: admin.cpp,v 1.12 2002/09/04 10:56:35 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -245,19 +245,108 @@ int C_Admin::Init()
pCmdDesc->m_vOptionalArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- config <input> <program> <filename> <type>
// -- config <filename> [--load] [--save]
pCmdDesc = new C_CommandDesc("config",
"load and save configuration file.",
"\"config\" loads or saves a configuration to a specified file."
" It stops all broadcasts before clearing the current configuration."
" After load the new configuration becomes available for broadcast.");
pStr = new C_String("config");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("load");
pCmdDesc->m_vBooleans.Add(pStr);
pStr = new C_String("save");
pCmdDesc->m_vBooleans.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- program <program> <input> <filename> <type> [--add] [--delete]
pCmdDesc = new C_CommandDesc("program",
"configure an input with programs.",
"\"config\" adds a configuration to a specified input"
"\"program\" adds a program definition to a specified input"
" it becomes available for broadcast.");
pStr = new C_String("input");
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);
pStr = new C_String("filename");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("type");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
// add or delete
pStr = new C_String("add");
pCmdDesc->m_vBooleans.Add(pStr);
pStr = new C_String("delete");
pCmdDesc->m_vBooleans.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- input <name> <type> [dir] [--add] [--delete]
pCmdDesc = new C_CommandDesc("input",
"configure a new input.",
"\"input\" adds a input definition of type local, video or dvb."
" it becomes available for broadcast and program configuration.");
pStr = new C_String("input");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("name");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("type");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
// for type=local
pStr = new C_String("dir");
pCmdDesc->m_vOptionalArgs.Add(pStr);
// for type=video
pStr = new C_String("device");
pCmdDesc->m_vOptionalArgs.Add(pStr);
pStr = new C_String("format");
pCmdDesc->m_vOptionalArgs.Add(pStr);
// for type=dvb
pStr = new C_String("card_number");
pCmdDesc->m_vOptionalArgs.Add(pStr);
pStr = new C_String("frequency");
pCmdDesc->m_vOptionalArgs.Add(pStr);
pStr = new C_String("polarization");
pCmdDesc->m_vOptionalArgs.Add(pStr);
pStr = new C_String("symbol_rate");
pCmdDesc->m_vOptionalArgs.Add(pStr);
pStr = new C_String("use_disecq");
pCmdDesc->m_vOptionalArgs.Add(pStr);
pStr = new C_String("lnb_lof1");
pCmdDesc->m_vOptionalArgs.Add(pStr);
pStr = new C_String("lnb_lof2");
pCmdDesc->m_vOptionalArgs.Add(pStr);
pStr = new C_String("lnb_slof");
pCmdDesc->m_vOptionalArgs.Add(pStr);
// add or delete
pStr = new C_String("add");
pCmdDesc->m_vBooleans.Add(pStr);
pStr = new C_String("delete");
pCmdDesc->m_vBooleans.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- channel <name> <type> <dest_host> <dest_port> <streamtype> [domain] [ttl] [intf] [--add] [--delete]
pCmdDesc = new C_CommandDesc("channel",
"configure a new channel.",
"\"channel\" 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);
pStr = new C_String("add");
pCmdDesc->m_vBooleans.Add(pStr);
pStr = new C_String("delete");
pCmdDesc->m_vBooleans.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- start <program> <channel> <input> [--loop] [--end]
......@@ -277,39 +366,32 @@ int C_Admin::Init()
pCmdDesc->m_vBooleans.Add(pStr);
pStr = new C_String("rtp");
pCmdDesc->m_vBooleans.Add(pStr);
pStr = new C_String("end"); // jump to end of file
pCmdDesc->m_vBooleans.Add(pStr);
pCmdDesc->m_bExtendedOptions = true;
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- resume <input> <program>
pCmdDesc = new C_CommandDesc("resume",
"resumes streaming.",
"\"resume\" resumes the broadcast of the specified program of the"
" specified input.");
pStr = new C_String("input");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("program");
"\"resume\" resumes the broadcast to specified channel.");
pStr = new C_String("channel");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- suspend <input> <program>
pCmdDesc = new C_CommandDesc("suspend",
"suspends streaming.",
"\"suspend\" suspends the broadcast of the specified program of the"
" specified input.");
pStr = new C_String("input");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("program");
"\"suspend\" suspends the broadcast to the specified channel.");
pStr = new C_String("channel");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- stop <input> <program>
pCmdDesc = new C_CommandDesc("stop",
"stops a program.",
"\"stop\" ends the broadcast of the specified program of the"
" specified input.");
pStr = new C_String("input");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("program");
"\"stop\" ends the broadcast to the specified channel.");
pStr = new C_String("channel");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
......
......@@ -2,7 +2,7 @@
* input.cpp: Input streams
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: input.cpp,v 1.5 2002/08/14 11:13:27 tooney Exp $
* $Id: input.cpp,v 1.6 2002/09/04 10:56:35 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -313,6 +313,36 @@ C_Answer C_Input::SuspendStreaming(C_Broadcast* pBroadcast)
return cAnswer;
}
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
C_Answer C_Input::UpdateProgram(C_String strProgram, C_String strFileName,
C_String strType)
{
C_Answer cAnswer(GetName());
try
{
LogDbg(m_hLog, "Program "+strProgram+" added.");
OnUpdateProgram(strProgram, strFileName, strType);
// Build the answer
cAnswer.SetStatus(NO_ERR);
cAnswer.AddMessage("Program " + strProgram + " added.");
}
catch(E_Exception e)
{
// Build the answer
cAnswer.SetStatus(e.GetCode());
cAnswer.AddMessage("Unable to add program "+strProgram);
cAnswer.AddMessage(e.Dump());
}
return cAnswer;
}
//------------------------------------------------------------------------------
//
......
......@@ -2,7 +2,7 @@
* input.h: Input class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: input.h,v 1.3 2002/07/12 14:38:57 jpsaman Exp $
* $Id: input.h,v 1.4 2002/09/04 10:56:35 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -82,7 +82,7 @@ class C_Input
C_Answer ResumeStreaming(C_Broadcast* pBroadcast);
C_Answer SuspendStreaming(C_Broadcast* pBroadcast);
C_Answer StopStreaming(C_Broadcast* pBroadcast);
C_Answer UpdateConfiguration(C_String strProgram, C_String strFileName,
C_Answer UpdateProgramC_String strProgram, C_String strFileName,
C_String strType);
// List of available programs
......@@ -102,7 +102,7 @@ class C_Input
virtual void OnResumeStreaming(C_Broadcast* pBroadcast) = 0;
virtual void OnSuspendStreaming(C_Broadcast* pBroadcast) = 0;
virtual void OnStopStreaming(C_Broadcast* pBroadcast) = 0;
virtual void OnUpdateConfiguration(C_String strProgram, C_String strFileName,
virtual void OnUpdateProgram(C_String strProgram, C_String strFileName,
C_String strType) = 0;
// Child program table browsing
virtual C_List<C_Program> OnGetAvailablePgrms() = 0;
......
......@@ -2,7 +2,7 @@
* manager.cpp: Vls manager
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: manager.cpp,v 1.9 2002/08/09 13:42:32 tooney Exp $
* $Id: manager.cpp,v 1.10 2002/09/04 10:56:35 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -385,8 +385,7 @@ void C_Manager::StopPrograms()
{
C_Broadcast* pBroadcast = cIterator1.GetNextItem();
C_Request* pRequest = new C_Request("stop");
pRequest->SetArg("input", pBroadcast->GetInput()->GetName());
pRequest->SetArg("program", pBroadcast->GetProgram()->GetName());
pRequest->SetArg("channel", pBroadcast->GetChannel()->GetName());
cRequests.Add(pRequest);
}
......@@ -453,6 +452,22 @@ C_Answer C_Manager::HandleRequest(const C_Request& cRequest)
{
cAnswer = Config(cRequest);
}
else if(strCmd == "config")
{
cAnswer = Config(cRequest);
}
else if(strCmd == "program")
{
cAnswer = Program(cRequest);
}
else if(strCmd == "input")
{
cAnswer = Input(cRequest);
}
else if(strCmd == "channel")
{
cAnswer = Channel(cRequest);
}
else
{
cAnswer.SetStatus(GEN_ERR);
......@@ -651,11 +666,6 @@ C_Answer C_Manager::Start(const C_Request& cRequest)
// Find the input
C_String strInput = cRequest.GetArg("input");
// if(strInput == "")
// {
// strInput = m_cPgrmList.GetInput(strPgrm);
// }
// ASSERT(strInput != "");
C_Input* pInput = m_cInputList.Get(strInput);
if(!pInput)
{
......@@ -674,7 +684,7 @@ C_Answer C_Manager::Start(const C_Request& cRequest)
if(!cInputAnswer.GetStatus())
{
m_cBroadcasts.Lock();
m_cBroadcasts.Add(strPgrm + ":" + strInput, pBroadcast);
m_cBroadcasts.Add(strChannel, pBroadcast);
m_cBroadcasts.UnLock();
}
else
......@@ -699,41 +709,33 @@ C_Answer C_Manager::Resume(const C_Request& cRequest)
C_Answer cAnswer("Manager");
cAnswer.SetStatus(NO_ERR);
C_String strPgrm = cRequest.GetArg("program");
ASSERT(strPgrm != "");
C_String strChannel = cRequest.GetArg("channel");
ASSERT(strChannel != "");
C_String strInput = cRequest.GetArg("input");
C_Input* pInput = m_cInputList.Get(strInput);
if(!pInput)
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("input doesn't exist");
}
else
m_cBroadcasts.Lock();
C_Broadcast* pBroadcast = m_cBroadcasts.Find(strChannel);
if (pBroadcast)
{
m_cBroadcasts.Lock();
C_Broadcast* pBroadcast = m_cBroadcasts.Find(strPgrm + ":" + strInput);
if (pBroadcast)
{
C_Answer cInputAnswer = pInput->ResumeStreaming(pBroadcast);
if(cInputAnswer.GetStatus())
{
cAnswer.SetStatus(cInputAnswer.GetStatus());
}
cAnswer.Add(cInputAnswer);
C_Input* pInput = pBroadcast->GetInput();
// Release repository items (Channel, Program, Input)
m_cChannelList.Release(pBroadcast->GetChannel()->GetName());
m_cProgramList.ReleasePgrm(strPgrm);
m_cInputList.Release(strInput);
}
else
C_Answer cInputAnswer = pInput->ResumeStreaming(pBroadcast);
if(cInputAnswer.GetStatus())
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("Pgrm was not broadcasted");
cAnswer.SetStatus(cInputAnswer.GetStatus());
}
m_cBroadcasts.UnLock();
cAnswer.Add(cInputAnswer);
// Release repository items (Channel, Program, Input)
m_cChannelList.Release(strChannel);
m_cProgramList.ReleasePgrm(pBroadcast->GetProgram()->GetName());
m_cInputList.Release(pInput->GetName());
}
else
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("Nothing broadcasted to channel " + strChannel);
}
m_cBroadcasts.UnLock();
return cAnswer;
}
......@@ -744,49 +746,40 @@ C_Answer C_Manager::Resume(const C_Request& cRequest)
//------------------------------------------------------------------------------
C_Answer C_Manager::Suspend(const C_Request& cRequest)
{
C_Answer cAnswer("Manager");
cAnswer.SetStatus(NO_ERR);
C_String strPgrm = cRequest.GetArg("program");
ASSERT(strPgrm != "");
C_String strInput = cRequest.GetArg("input");
C_Input* pInput = m_cInputList.Get(strInput);
if(!pInput)
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("input doesn't exist");
}
else
{
m_cBroadcasts.Lock();
C_Broadcast* pBroadcast = m_cBroadcasts.Find(strPgrm + ":" + strInput);
if (pBroadcast)
{
C_Answer cInputAnswer = pInput->SuspendStreaming(pBroadcast);
if(cInputAnswer.GetStatus())
{
cAnswer.SetStatus(cInputAnswer.GetStatus());
}
cAnswer.Add(cInputAnswer);
// Release repository items (Channel, Program, Input)
m_cChannelList.Release(pBroadcast->GetChannel()->GetName());
m_cProgramList.ReleasePgrm(strPgrm);
m_cInputList.Release(strInput);
}
else
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("Pgrm was not broadcasted");
}
m_cBroadcasts.UnLock();
}
return cAnswer;
C_Answer cAnswer("Manager");
cAnswer.SetStatus(NO_ERR);
C_String strChannel = cRequest.GetArg("channel");
ASSERT(strChannel != "");
m_cBroadcasts.Lock();
C_Broadcast* pBroadcast = m_cBroadcasts.Find(strChannel);
if (pBroadcast)
{
C_Input* pInput = pBroadcast->GetInput();
C_Answer cInputAnswer = pInput->SuspendStreaming(pBroadcast);
if(cInputAnswer.GetStatus())
{
cAnswer.SetStatus(cInputAnswer.GetStatus());
}
cAnswer.Add(cInputAnswer);
// Release repository items (Channel, Program, Input)
m_cChannelList.Release(strChannel);
m_cProgramList.ReleasePgrm(pBroadcast->GetProgram()->GetName());
m_cInputList.Release(pInput->GetName());
}
else
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("Nothing broadcasted to channel " + strChannel);
}
m_cBroadcasts.UnLock();
return cAnswer;
}
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
......@@ -795,45 +788,37 @@ C_Answer C_Manager::Stop(const C_Request& cRequest)
C_Answer cAnswer("Manager");
cAnswer.SetStatus(NO_ERR);
C_String strPgrm = cRequest.GetArg("program");
ASSERT(strPgrm != "");
C_String strChannel = cRequest.GetArg("channel");
ASSERT(strChannel != "");
C_String strInput = cRequest.GetArg("input");
C_Input* pInput = m_cInputList.Get(strInput);
if(!pInput)
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("input doesn't exist");
}
else
m_cBroadcasts.Lock();
C_Broadcast* pBroadcast = m_cBroadcasts.Find(strChannel);
if (pBroadcast)
{
m_cBroadcasts.Lock();
C_Broadcast* pBroadcast = m_cBroadcasts.Find(strPgrm + ":" + strInput);
if (pBroadcast)
{
C_Answer cInputAnswer = pInput->StopStreaming(pBroadcast);
if(cInputAnswer.GetStatus())
{
cAnswer.SetStatus(cInputAnswer.GetStatus());
}
cAnswer.Add(cInputAnswer);
// Release repository items (Channel, Program, Input)
m_cChannelList.Release(pBroadcast->GetChannel()->GetName());
m_cProgramList.ReleasePgrm(strPgrm);
m_cInputList.Release(strInput);
C_Input* pInput = pBroadcast->GetInput();
C_Answer cInputAnswer = pInput->StopStreaming(pBroadcast);
LogDbg(m_hLog, "Remove the broadcast");
int iRc = m_cBroadcasts.Remove(strPgrm + ":" + strInput);
LogDbg(m_hLog, C_String("Broadcast removed with status ") + iRc);
}
else
if(cInputAnswer.GetStatus())
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("Pgrm was not broadcasted");
cAnswer.SetStatus(cInputAnswer.GetStatus());
}
m_cBroadcasts.UnLock();
cAnswer.Add(cInputAnswer);
// Release repository items (Channel, Program, Input)
m_cChannelList.Release(strChannel);
m_cProgramList.ReleasePgrm(pBroadcast->GetProgram()->GetName());
m_cInputList.Release(pInput->GetName());
LogDbg(m_hLog, "Remove the broadcast");
int iRc = m_cBroadcasts.Remove(strChannel);
LogDbg(m_hLog, C_String("Broadcast removed with status ") + iRc);
}
else
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("Nothing broadcasted to channel " + strChannel);
}
m_cBroadcasts.UnLock();
return