Commit 0b6ec0bd authored by Jean-Paul Saman's avatar Jean-Paul Saman

Runtime adding of programs to broadcast through the telnet interface. It is...

Runtime adding of programs to broadcast through the telnet interface. It is implemented for the input of type "local". The telnet command is used like this:
config <input> <program> <filename> <type>. Beware only input checking is performed for <input>.
parent 07a30d27
......@@ -2,7 +2,7 @@
* dvbinput.cpp: DVB streams
*-------------------------------------------------------------------------------
* (c)1999-2002 VideoLAN
* $Id: dvbinput.cpp,v 1.6 2002/06/26 22:57:03 tooney Exp $
* $Id: dvbinput.cpp,v 1.7 2002/07/12 14:38:56 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -648,4 +648,10 @@ void C_DvbInput::OnStopStreaming(C_Broadcast* pBroadcast)
delete pStreamer;
}
//------------------------------------------------------------------------------
// Update configuration dynamically
//------------------------------------------------------------------------------
void C_DvbInput::OnUpdateConfiguration(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.3 2002/04/02 15:22:08 bozo Exp $
* $Id: dvbinput.h,v 1.4 2002/07/12 14:38:56 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -48,7 +48,8 @@ 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 C_List<C_Program> OnGetAvailablePgrms();
// Hardware specific PID selection (demux)
......
......@@ -2,7 +2,7 @@
* dvdreader.cpp: DVD reader
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: dvdreader.cpp,v 1.3 2002/05/14 22:10:08 bozo Exp $
* $Id: dvdreader.cpp,v 1.4 2002/07/12 14:38:56 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -525,3 +525,9 @@ int C_DvdMpegReader::ReadBlock(bool bFill)
return 1;
}
s64 C_DvdMpegReader::GetPos()
{
ASSERT(false);
return 0;
}
......@@ -2,7 +2,7 @@
* dvdreader.h: DVD reader
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: dvdreader.h,v 1.1 2001/11/28 19:32:23 bozo Exp $
* $Id: dvdreader.h,v 1.2 2002/07/12 14:38:56 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -58,6 +58,7 @@ public:
virtual int Read(byte* pBuff, int iSize);
virtual int Seek(s64 iOffset, int bStartPos);
virtual s64 Size();
virtual s64 GetPos();
void SetPgrmDescriptor(C_ProgramDescriptor* pPgrmDescriptor)
{
......
......@@ -2,7 +2,7 @@
* filereader.cpp: file reader
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: filereader.cpp,v 1.3 2002/04/26 15:42:29 asmax Exp $
* $Id: filereader.cpp,v 1.4 2002/07/12 14:38:56 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -83,6 +83,11 @@ C_FileMpegReader::C_FileMpegReader(C_Module* pModule,
m_bLoop = true;
else
m_bLoop = false;
if(pBroadcast->GetOption("end") == "1")
m_bEnd = true;
else
m_bEnd = false;
}
......@@ -92,6 +97,15 @@ C_FileMpegReader::C_FileMpegReader(C_Module* pModule,
void C_FileMpegReader::Init()
{
m_cFile.Open("rb");
// Jump to end of buffer to a distance of about 3 seconds from end
if (m_bEnd)
{
if (m_cFile.Seek( (long)-(3*8*188*1024), FILE_SEEK_END)==-1)
printf( "Option --end failed to start.\n");
else
printf( "Option --end started.\n" );
}
}
......@@ -147,3 +161,10 @@ s64 C_FileMpegReader::Size()
}
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
s64 C_FileMpegReader::GetPos()
{
return m_cFile.GetPos();
}
......@@ -2,7 +2,7 @@
* filereader.h: file reader
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: filereader.h,v 1.1 2001/11/28 19:32:23 bozo Exp $
* $Id: filereader.h,v 1.2 2002/07/12 14:38:56 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -45,11 +45,13 @@ public:
virtual int Read(byte* pBuff, int iSize);
virtual int Seek(s64 iOffset, int bStartPos);
virtual s64 Size();
virtual s64 GetPos();
protected:
C_File m_cFile;
bool m_bLoop;
bool m_bEnd;
};
......
......@@ -2,7 +2,7 @@
* localinput.cpp: Local streams
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: localinput.cpp,v 1.6 2002/05/14 22:10:08 bozo Exp $
* $Id: localinput.cpp,v 1.7 2002/07/12 14:38:56 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -34,7 +34,6 @@
#include "../../mpeg/mpeg.h"
#include "../../mpeg/ts.h"
#include "../../server/program.h"
#include "../../server/buffer.h"
#include "../../server/output.h"
......@@ -414,4 +413,38 @@ void C_LocalInput::OnStopStreaming(C_Broadcast* pBroadcast)
}
}
//------------------------------------------------------------------------------
// Rewind the reception of the given program with specified speed
//------------------------------------------------------------------------------
void C_LocalInput::OnUpdateConfiguration(C_String strProgram,
C_String strFileName, C_String strType)
{
C_String strPgrmCount = m_cSettings.GetSetting("Input.ProgramCount", "0");
unsigned int uiPgrmCount = strPgrmCount.ToInt();
if(uiPgrmCount)
{
uiPgrmCount++;
C_String strKey = C_String(uiPgrmCount)+ ".Name";
m_cSettings.Update(strKey.ToLower(),strProgram);
strKey = C_String(uiPgrmCount)+ ".FileName";
m_cSettings.Update(strKey.ToLower(), strFileName);
strKey = C_String(uiPgrmCount)+ ".Type";
m_cSettings.Update(strKey.ToLower(), strType);
strKey = C_String("Input.ProgramCount");
m_cSettings.Update(strKey.ToLower(), C_String(uiPgrmCount));
// add to m_vProgramNames
C_String strName = m_cSettings.GetSetting(C_String(uiPgrmCount) + ".Name",
C_String("Pgrm") + uiPgrmCount);
C_String* pStr = new C_String(strName);
m_vProgramNames.Add(pStr);
}
else
{
Log(m_hLog, LOG_WARN,
"The \"ProgramCount\" variable isn't specified in the file \"" +
m_strConfigPath + "/input.cfg\"");
}
}
......@@ -2,7 +2,7 @@
* localinput.h: Local Input class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: localinput.h,v 1.1 2001/11/29 16:11:42 bozo Exp $
* $Id: localinput.h,v 1.2 2002/07/12 14:38:56 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 C_List<C_Program> OnGetAvailablePgrms();
private:
......
......@@ -2,7 +2,7 @@
* videoinput.cpp: Video4linux streams
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: videoinput.cpp,v 1.7 2002/05/14 22:10:08 bozo Exp $
* $Id: videoinput.cpp,v 1.8 2002/07/12 14:38:56 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......@@ -348,3 +348,10 @@ void C_VideoInput::OnStopStreaming(C_Broadcast* pBroadcast)
}
}
//------------------------------------------------------------------------------
// Update configuration dynamically
//------------------------------------------------------------------------------
void C_VideoInput::OnUpdateConfiguration(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.2 2001/12/05 11:14:58 asmax Exp $
* $Id: videoinput.h,v 1.3 2002/07/12 14:38:56 jpsaman Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
*
......@@ -51,6 +51,8 @@ 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 C_List<C_Program> OnGetAvailablePgrms();
......
......@@ -2,7 +2,7 @@
* reader.h: Stream readers
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: reader.h,v 1.1 2001/11/28 19:32:23 bozo Exp $
* $Id: reader.h,v 1.2 2002/07/12 14:38:56 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -59,6 +59,7 @@ public:
virtual int Read(byte* pBuff, int iSize) = 0;
virtual int Seek(s64 iOffset, int bStartPos) = 0;
virtual s64 Size() = 0;
virtual s64 GetPos() = 0;
bool HasDiscontinuity()
{ return m_bDiscontinuity; };
......
......@@ -2,7 +2,7 @@
* admin.cpp:
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: admin.cpp,v 1.8 2002/06/20 20:01:32 massiot Exp $
* $Id: admin.cpp,v 1.9 2002/07/12 14:38:57 jpsaman Exp $
*
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
......@@ -245,7 +245,22 @@ int C_Admin::Init()
pCmdDesc->m_vOptionalArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- start <program> <channel> <input> [--loop]
// -- config <input> <program> <filename> <type>
pCmdDesc = new C_CommandDesc("config",
"configure an input with programs.",
"\"config\" adds a configuration 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("filename");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("type");
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pCmdDesc->BuildUsage();
m_cCmdDescriptions.Add(pCmdDesc->m_strName, pCmdDesc);
// -- start <program> <channel> <input> [--loop] [--end]
pCmdDesc = new C_CommandDesc("start",
"launches a program.",
"\"start\" launches the specified program of the specified input"
......@@ -258,6 +273,8 @@ int C_Admin::Init()
pCmdDesc->m_vMandatoryArgs.Add(pStr);
pStr = new C_String("loop");
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);
......
......@@ -2,7 +2,7 @@
* input.cpp: Input streams
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: input.cpp,v 1.2 2001/11/21 18:51:02 bozo Exp $
* $Id: input.cpp,v 1.3 2002/07/12 14:38:57 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -236,12 +236,16 @@ C_Answer C_Input::ResumeStreaming(C_Broadcast* pBroadcast)
try
{
// Ask the child to resume the streaming
if(pBroadcast->GetStatus() == BROADCAST_SUSPENDED)
if((pBroadcast->GetStatus() == BROADCAST_SUSPENDED))
{
LogDbg(m_hLog, "Resuming reception of pgrm "+strPgrmName);
OnResumeStreaming(pBroadcast);
pBroadcast->SetStatus(BROADCAST_RUNNING);
LogDbg(m_hLog, "Pgrm "+strPgrmName+" resumed");
// Build the answer
cAnswer.SetStatus(NO_ERR);
cAnswer.AddMessage("Program " + strPgrmName + " resumed");
}
else
{
......@@ -278,12 +282,16 @@ C_Answer C_Input::SuspendStreaming(C_Broadcast* pBroadcast)
try
{
// Ask the child to suspend the streaming
if(pBroadcast->GetStatus() == BROADCAST_RUNNING)
if( (pBroadcast->GetStatus() == BROADCAST_RUNNING))
{
LogDbg(m_hLog, "Suspending reception of pgrm "+strPgrmName);
OnSuspendStreaming(pBroadcast);
pBroadcast->SetStatus(BROADCAST_SUSPENDED);
LogDbg(m_hLog, "Pgrm "+strPgrmName+" suspended");
// Build the answer
cAnswer.SetStatus(NO_ERR);
cAnswer.AddMessage("Program " + strPgrmName + " suspended");
}
else
{
......@@ -321,12 +329,16 @@ C_Answer C_Input::StopStreaming(C_Broadcast* pBroadcast)
try
{
// Ask the child to stop the streaming
if(pBroadcast->GetStatus() == BROADCAST_RUNNING)
if((pBroadcast->GetStatus() == BROADCAST_RUNNING))
{
LogDbg(m_hLog, "Stopping reception of pgrm "+strPgrmName);
OnStopStreaming(pBroadcast);
pBroadcast->SetStatus(BROADCAST_STOPPED);
LogDbg(m_hLog, "Pgrm "+strPgrmName+" stopped");
// Build the answer
cAnswer.SetStatus(NO_ERR);
cAnswer.AddMessage("Program " + strPgrmName + " stopped");
}
else
{
......@@ -343,6 +355,36 @@ C_Answer C_Input::StopStreaming(C_Broadcast* pBroadcast)
return cAnswer;
}
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
C_Answer C_Input::UpdateConfiguration(C_String strProgram, C_String strFileName,
C_String strType)
{
C_Answer cAnswer(GetName());
try
{
LogDbg(m_hLog, "Configuration Program "+strProgram+" added.");
OnUpdateConfiguration(strProgram, strFileName, strType);
// Build the answer
cAnswer.SetStatus(NO_ERR);
cAnswer.AddMessage("Configuration 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.2 2001/11/21 18:51:02 bozo Exp $
* $Id: input.h,v 1.3 2002/07/12 14:38:57 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -82,6 +82,8 @@ 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_String strType);
// List of available programs
C_List<C_Program> GetAvailablePgrms();
......@@ -100,6 +102,8 @@ 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,
C_String strType) = 0;
// Child program table browsing
virtual C_List<C_Program> OnGetAvailablePgrms() = 0;
// Input internal failure management
......
......@@ -2,7 +2,7 @@
* manager.cpp: Vls manager
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: manager.cpp,v 1.7 2002/03/25 01:23:54 bozo Exp $
* $Id: manager.cpp,v 1.8 2002/07/12 14:38:57 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -424,7 +424,7 @@ C_Answer C_Manager::HandleRequest(const C_Request& cRequest)
ASSERT(false);
}
else if(strCmd == "unload")
{
{
// Unload the input: Not yet implemented
ASSERT(false);
}
......@@ -448,6 +448,10 @@ C_Answer C_Manager::HandleRequest(const C_Request& cRequest)
{
cAnswer = Stop(cRequest);
}
else if(strCmd == "config")
{
cAnswer = Config(cRequest);
}
else
{
cAnswer.SetStatus(GEN_ERR);
......@@ -833,3 +837,66 @@ C_Answer C_Manager::Stop(const C_Request& cRequest)
return cAnswer;
}
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
C_Answer C_Manager::Config(const C_Request& cRequest)
{
C_Answer cAnswer("Manager");
cAnswer.SetStatus(NO_ERR);
C_String strProgram = cRequest.GetArg("program");
ASSERT(strProgram != "");
C_String strFileName = cRequest.GetArg("filename");
ASSERT(strFileName != "");
C_String strType = cRequest.GetArg("type");
ASSERT(strType != "");
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
{
// Lock the input repository and the program list
m_cProgramList.Lock();
m_cInputList.Lock();
// First update C_Settigs in pInput
C_Answer cInputAnswer = pInput->UpdateConfiguration(strProgram,strFileName,strType);
if(cInputAnswer.GetStatus())
{
cAnswer.SetStatus(cInputAnswer.GetStatus());
}
cAnswer.Add(cInputAnswer);
// Then Update m_cProgramList
C_List<C_Program> cInputPgrms = pInput->GetAvailablePgrms();
unsigned int iPgrmNumber = cInputPgrms.Size();
if (iPgrmNumber>0)
m_cProgramList.Add(cInputPgrms[iPgrmNumber-1], pInput);
else
{
cAnswer.SetStatus(GEN_ERR);
cAnswer.AddMessage("ProgramList is empty.");
}
// debug
Log(m_hLog, LOG_NOTE, "Program Configuration Changed." );
for(unsigned int j = 0; j < iPgrmNumber; j++)
{
Log(m_hLog, LOG_NOTE, "Program: " + cInputPgrms[j].GetName() );
}
// Unlock the input repository and the program list
m_cInputList.UnLock();
m_cProgramList.UnLock();
}
return cAnswer;
}
......@@ -2,7 +2,7 @@
* manager.h: Manager class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: manager.h,v 1.1 2001/10/06 21:23:37 bozo Exp $
* $Id: manager.h,v 1.2 2002/07/12 14:38:57 jpsaman Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -67,6 +67,7 @@ class C_Manager : public C_RequestHandler, public C_EventHandler,
C_Answer Resume(const C_Request& cRequest);
C_Answer Suspend(const C_Request& cRequest);
C_Answer Stop(const C_Request& cRequest);
C_Answer Config(const C_Request& cRequest);
// C_Thread APIs to isolate events
virtual void InitWork();
......
......@@ -15,7 +15,7 @@ BEGIN "Groups"
# groupname = "cmd1|cmd2|..."
# --- Example:
monitor = "help|browse|logout"
master = "help|browse|start|resume|suspend|stop|shutdown|logout"
master = "help|browse|start|resume|suspend|stop|shutdown|logout|config"
END
# The section "Users" describes each user
......
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