Commit 07fc0626 authored by Damien Lucas's avatar Damien Lucas

new command line functionnalities:

  . -d option : syntax is protocol:arg1[:arg2]
     ex: rtp:192.168.0.2
         udp:192.168.0.2:1234
         file:/mnt/video/stream.ts

  . MPEG1-PS streams are autodected (in an ugly way, but detected ;-)
parent 865113b2
......@@ -2,7 +2,7 @@
* application.cpp: Application class
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: application.cpp,v 1.12 2002/11/05 02:10:53 nitrox Exp $
* $Id: application.cpp,v 1.13 2002/11/05 19:54:07 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -375,9 +375,8 @@ int C_Application::RetrieveConfig(int iArgc, char* paArg[])
C_String strCfgFile;
C_String strDest;
int iRc = NO_ERR;
int opt;
int iCommandline=0;
int opt;
#ifndef _WIN32
C_String strName = m_strName.ToLower() + ".cfg";
strCfgFile = CONFIG_PATH "/" + strName;
......@@ -432,12 +431,12 @@ int C_Application::RetrieveConfig(int iArgc, char* paArg[])
}
if(optind<iArgc) //Use cmdline
{
C_String sTags="";
try
{
if(GetSetting("program1.loop", "false")=="true")
m_cSettings.AddCmdLineTarget(paArg[optind], true);
else
m_cSettings.AddCmdLineTarget(paArg[optind], false);
if(GetSetting("program1.loop", "false")=="true") sTags+="--loop ";
if(GetSetting("output1.protocol", "udp")=="rtp") sTags+="--rtp ";
m_cSettings.AddCmdLineTarget(paArg[optind], sTags);
}
catch(E_Exception e)
{
......
......@@ -2,7 +2,7 @@
* parsers.cpp: Command line and configuration files parsers
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: parsers.cpp,v 1.5 2002/11/05 02:10:53 nitrox Exp $
* $Id: parsers.cpp,v 1.6 2002/11/05 19:54:07 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -234,35 +234,66 @@ extern "C" int yywrap(void)
void C_CfgFileParser::AddCmdLineSetting(unsigned char sOption, C_String sValue)
{
C_String sPDest;
C_String sIPDest;
C_String sMeth;
C_String sDest1;
C_String sDest2;
switch(sOption)
{
case 'd': /* Destination spec */
if(sValue=="") throw E_Parser(GEN_ERR, "-d option needs argument");
/* Format string should be methode:/dest:port */
if(sValue=="") throw E_Parser(GEN_ERR, "-d option needs argument");
/* On rcupre le port de destination s'ilest prcis */
if(sValue.Find(':', 1)!=GEN_ERR)
{
sIPDest=sValue.SubString(0,sValue.Find(':', 1));
sPDest=sValue.SubString(sValue.Find(':', 1)+1,
sMeth=sValue.SubString(0,sValue.Find(':', 1));
sValue=sValue.SubString(sValue.Find(':', 1)+1,
strlen(sValue.GetString()));
if(sValue.Find(':', 1)!=GEN_ERR)
{
sDest1=sValue.SubString(0,sValue.Find(':', 1));
sDest2=sValue.SubString(sValue.Find(':', 1)+1,
strlen(sValue.GetString()));
}
else
{
sDest1=sValue;
sDest2="";
}
}
else
{
sPDest="1234";
sIPDest=sValue;
throw E_Parser(GEN_ERR, "No methode specified for output");
}
if(sMeth=="udp" || sMeth=="rtp")
{
if(sDest1=="") throw E_Parser(GEN_ERR, "No IP destination specified");
if(sDest2.ToInt()<=0 && sDest2!="")
throw E_Parser(GEN_ERR, "Invalid port specification");
m_pCallBack->OnStartSection("Channels");
m_pCallBack->OnProperty("output1", "network");
m_pCallBack->OnEndSection("Channels");
m_pCallBack->OnStartSection("output1");
m_pCallBack->OnProperty("DstHost", sDest1);
if(sDest2!="") m_pCallBack->OnProperty("DstPort", sDest2);
if(sDest1.ToInt()<=239 && sDest1.ToInt()>=234)
m_pCallBack->OnProperty("Type", "multicast");
if(sMeth=="udp") m_pCallBack->OnProperty("Protocol", "udp");
else m_pCallBack->OnProperty("Protocol", "rtp");
m_pCallBack->OnEndSection("output1");
}
else if (sMeth=="file")
{
printf("**** method: file -- Filename: %s\n", sDest1.GetString());
if(sDest1=="") throw E_Parser(GEN_ERR, "No Filname specified");
m_pCallBack->OnStartSection("Channels");
m_pCallBack->OnProperty("output1", "file");
m_pCallBack->OnEndSection("Channels");
m_pCallBack->OnStartSection("output1");
m_pCallBack->OnProperty("FileName", sDest1);
m_pCallBack->OnProperty("Append", "no");
m_pCallBack->OnEndSection("output1");
}
if(sIPDest=="") throw E_Parser(GEN_ERR, "No IP destination specified");
if(sPDest.ToInt()<=0) throw E_Parser(GEN_ERR, "Invalid port specification");
m_pCallBack->OnStartSection("Channels");
m_pCallBack->OnProperty("channel1", "network");
m_pCallBack->OnEndSection("Channels");
m_pCallBack->OnStartSection("channel1");
m_pCallBack->OnProperty("DstHost", sIPDest);
m_pCallBack->OnProperty("Dstport", sPDest);
if(sIPDest.ToInt()<=239 && sIPDest.ToInt()>=234)
m_pCallBack->OnProperty("Type", "multicast");
m_pCallBack->OnEndSection("channel1");
break;
case 't':
......@@ -296,7 +327,7 @@ void C_CfgFileParser::AddCmdLineSetting(unsigned char sOption, C_String sValue)
}
}
void C_CfgFileParser::AddCmdLineTarget(C_String sTarget, bool bLoop)
void C_CfgFileParser::AddCmdLineTarget(C_String sTarget, C_String sTags)
{
C_String sMeth;
C_String sFile;
......@@ -341,18 +372,17 @@ void C_CfgFileParser::AddCmdLineTarget(C_String sTarget, bool bLoop)
fFile.Open("r");
byte bFormat;
fFile.Read(&bFormat, 1);
if(bFormat==0x47) m_pCallBack->OnProperty("Type", "MPEG2-TS");
fFile.Seek(4+1, SEEK_CUR);
fFile.Read(&bFormat, 1);
if(bFormat==0x01) m_pCallBack->OnProperty("Type", "MPEG1-PS");
else if(bFormat==0x04) m_pCallBack->OnProperty("Type", "MPEG2-PS");
fFile.Close();
if(bFormat==0x47) m_pCallBack->OnProperty("Type", "MPEG2-TS");
else m_pCallBack->OnProperty("Type", "MPEG2-PS");
}
m_pCallBack->OnEndSection("1");
/* Automatic start section */
m_pCallBack->OnStartSection("LaunchOnStartUp");
if(bLoop==true)
m_pCallBack->OnProperty("command1", "start program1 channel1 input1 --loop");
else
m_pCallBack->OnProperty("command1", "start program1 channel1 input1");
m_pCallBack->OnProperty("command1", "start program1 output1 input1 "+sTags);
m_pCallBack->OnEndSection("LaunchOnStartUp");
}
......@@ -2,7 +2,7 @@
* parsers.h: Command line and configuration files parsers
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: parsers.h,v 1.3 2002/11/05 02:10:53 nitrox Exp $
* $Id: parsers.h,v 1.4 2002/11/05 19:54:07 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
......@@ -81,7 +81,7 @@ class C_CfgFileParser
// Parse the data on the given stream
void Parse(const C_String& strFileName, bool bCompletePath);
void AddCmdLineSetting(unsigned char sOption, C_String sValue);
void AddCmdLineTarget(C_String sTarget, bool bLoop);
void AddCmdLineTarget(C_String sTarget, C_String sTags);
protected:
// Callback
C_ParserHandler* m_pCallBack;
......
......@@ -2,7 +2,7 @@
* settings.cpp: Application settings management
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: settings.cpp,v 1.8 2002/11/05 02:10:53 nitrox Exp $
* $Id: settings.cpp,v 1.9 2002/11/05 19:54:07 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -161,11 +161,11 @@ void C_Settings::Load(const C_String& strDefaultCfgFile, bool bReadCmdLine)
cParser.Parse(strDefaultCfgFile, true);
}
void C_Settings::AddCmdLineTarget(C_String sTarget, bool bLoop)
void C_Settings::AddCmdLineTarget(C_String sTarget, C_String sTags)
{
C_SettingsHandler cHandler(this);
C_CfgFileParser cParser(&cHandler);
cParser.AddCmdLineTarget(sTarget, bLoop);
cParser.AddCmdLineTarget(sTarget, sTags);
}
void C_Settings::AddCmdLineSetting(char sOption, C_String sValue)
......
......@@ -2,7 +2,7 @@
* settings.h: Settings class definition
*-------------------------------------------------------------------------------
* (c)1999-2001 VideoLAN
* $Id: settings.h,v 1.4 2002/11/05 02:10:53 nitrox Exp $
* $Id: settings.h,v 1.5 2002/11/05 19:54:07 nitrox Exp $
*
* Authors: Benoit Steiner <benny@via.ecp.fr>
*
......@@ -69,7 +69,7 @@ class C_Settings
// Retrieve the config from both command line and config file
void Load(const C_String& strDefaultCfgFile, bool bReadCmdLine = true);
void AddCmdLineTarget(C_String sTarget, bool iLoop);
void AddCmdLineTarget(C_String sTarget, C_String sTags);
void AddCmdLineSetting(char sOption, C_String sValue);
// Store it in an updated version of the cfg file
void Store();
......
......@@ -111,10 +111,10 @@ BEGIN "Channels"
# ChannelName = "Type"
# --- Example:
multi3 = "network"
# client1 = "network"
client1 = "network"
# client2 = "network"
# multicast = "network"
# localfile = "file"
localfile = "file"
END
# Channels configuration
......@@ -123,10 +123,10 @@ BEGIN "localhost" # The client is on the same host as the server
DstPort = "1234"
END
#BEGIN "client1" # unicast example
# DstHost = "192.168.1.2" # destination host
# DstPort = "1234" # destination port
#END
BEGIN "client1" # unicast example
DstHost = "127.0.0.1" # destination host
DstPort = "1234" # destination port
END
#BEGIN "client2" # unicast with IPv6 example
# Domain = "inet6"
......@@ -141,15 +141,15 @@ BEGIN "multi3" # multicast example
DstPort = "1234" # destination port
END
#BEGIN "localfile" # file output example
# FileName = "stream.ts"
# Append = "no" # rewrite the file if it exists
#END
BEGIN "localfile" # file output example
FileName = "/home/nitrox/stream.ts"
Append = "no" # rewrite the file if it exists
END
# Commands automatically lanched on Startup
# Commands shall be like they would be typed in a telnet console.
BEGIN "LaunchOnStartUp"
command1 = "start stream1 multi3 local1 --loop"
command1 = "start stream1 client1 local1 --loop"
END
......@@ -169,8 +169,8 @@ END
# --- Example:
BEGIN "1" # MPEG2 stream stored in /mnt/video/stream1.ts
Name = "stream1"
FileName = "/mnt/video/stream1.ts"
Type = "Mpeg2-TS"
FileName = "/mnt/video/Dolby_Canyon.mpeg"
Type = "Mpeg1-PS"
END
BEGIN "2" # Dvd
......
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