Commit c412d82b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Store port number into as an integer

parent 9c46e1c0
...@@ -130,7 +130,10 @@ bool Message::AddProgram(Program *p) ...@@ -130,7 +130,10 @@ bool Message::AddProgram(Program *p)
sdp += "a=type:broadcast\r\n"; sdp += "a=type:broadcast\r\n";
sdp += "a=charset:UTF-8\r\n"; sdp += "a=charset:UTF-8\r\n";
string m = "m=video " + p->GetPort() + " " char portbuf[6];
snprintf(portbuf, sizeof(portbuf), "%u", (unsigned)p->GetPort());
string port = portbuf;
string m = "m=video " + port + " "
+ (p->IsRTP() ? "RTP/AVP 33" : "udp mpeg") +"\r\n"; + (p->IsRTP() ? "RTP/AVP 33" : "udp mpeg") +"\r\n";
if (p->IsRTP()) if (p->IsRTP())
......
...@@ -257,7 +257,7 @@ int Config::Parse() ...@@ -257,7 +257,7 @@ int Config::Parse()
if(something) if(something)
{ {
/* We were in a program with at least one field filled */ /* We were in a program with at least one field filled */
if (!pp->GetPort().length()) if (!pp->GetPort())
{ {
pp->SetPort(DEFAULT_PORT); pp->SetPort(DEFAULT_PORT);
} }
...@@ -371,13 +371,13 @@ int Config::Parse() ...@@ -371,13 +371,13 @@ int Config::Parse()
{ {
strgeta(line,tline,'='); strgeta(line,tline,'=');
something=1; something=1;
pp->SetPort(tline); pp->SetPort(atoi(tline));
} }
} }
if(something) if(something)
{ {
if (!pp->GetPort().length()) if (!pp->GetPort())
{ {
pp->SetPort(DEFAULT_PORT); pp->SetPort(DEFAULT_PORT);
} }
......
...@@ -37,7 +37,7 @@ Program::Program() : b_rtp(false), b_has_pl_group(false) ...@@ -37,7 +37,7 @@ Program::Program() : b_rtp(false), b_has_pl_group(false)
{ {
/* Set default Values */ /* Set default Values */
address=""; address="";
port=""; port=0;
permanent = true; permanent = true;
program_ttl = "255"; program_ttl = "255";
machine = "localhost"; machine = "localhost";
...@@ -51,7 +51,7 @@ string Program::GetUser(void) {return user;} ...@@ -51,7 +51,7 @@ string Program::GetUser(void) {return user;}
string Program::GetMachine(void) {return machine;} string Program::GetMachine(void) {return machine;}
string Program::GetSite(void) {return site;} string Program::GetSite(void) {return site;}
string Program::GetAddress(void){return address;} string Program::GetAddress(void){return address;}
string Program::GetPort(void){return port;} uint16_t Program::GetPort(void){return port;}
string Program::GetTTL(void){return program_ttl;} string Program::GetTTL(void){return program_ttl;}
string Program::GetPlGroup(void){return pl_group;} string Program::GetPlGroup(void){return pl_group;}
...@@ -67,17 +67,11 @@ void Program::SetAddress(const char* a){address=a;} ...@@ -67,17 +67,11 @@ void Program::SetAddress(const char* a){address=a;}
void Program::SetPlGroup(const char *h){pl_group=h;} void Program::SetPlGroup(const char *h){pl_group=h;}
void Program::SetRTP(bool b){b_rtp = b;} void Program::SetRTP(bool b){b_rtp = b;}
void Program::SetHasPlGroup(bool b){b_has_pl_group = b ;} void Program::SetHasPlGroup(bool b){b_has_pl_group = b ;}
void Program::SetPort(const char* p) void Program::SetPort(uint16_t p) { port = p; }
{
char psz_port[6];
snprintf(psz_port, sizeof (psz_port), "%d", atoi(p));
port = psz_port;
}
void Program::SetTTL(const char *p){program_ttl=p;} void Program::SetTTL(const char *p){program_ttl=p;}
Program::Program(string n, string u, string m, string s, string a,string p) Program::Program(string n, string u, string m, string s, string a,uint16_t p)
: b_has_pl_group (false) : b_has_pl_group (false)
{ {
name=n; name=n;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
class Program class Program
{ {
public: public:
Program(string, string, string, string, string,string); Program(string, string, string, string, string, uint16_t);
Program(); Program();
~Program(); ~Program();
...@@ -35,7 +35,7 @@ class Program ...@@ -35,7 +35,7 @@ class Program
string GetMachine(); string GetMachine();
string GetSite(); string GetSite();
string GetAddress(); string GetAddress();
string GetPort(); uint16_t GetPort();
string GetTTL(); string GetTTL();
string GetPlGroup(); string GetPlGroup();
...@@ -45,7 +45,7 @@ class Program ...@@ -45,7 +45,7 @@ class Program
void SetMachine(const char*); void SetMachine(const char*);
void SetSite(const char*); void SetSite(const char*);
void SetAddress(const char*); void SetAddress(const char*);
void SetPort(const char *); void SetPort(uint16_t);
void SetTTL(const char *); void SetTTL(const char *);
void SetPlGroup(const char *); void SetPlGroup(const char *);
void SetHasPlGroup(bool); void SetHasPlGroup(bool);
...@@ -61,12 +61,12 @@ class Program ...@@ -61,12 +61,12 @@ class Program
string machine; string machine;
string site; string site;
string address; string address;
string port;
string program_ttl; string program_ttl;
string pl_group; string pl_group;
bool permanent; bool permanent;
bool b_rtp; bool b_rtp;
bool b_has_pl_group; bool b_has_pl_group;
uint16_t port;
uint32_t start_time; uint32_t start_time;
uint32_t stop_time; uint32_t stop_time;
/* TODO support for periodical programs */ /* TODO support for periodical programs */
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define DEFAULT_CONF SYSCONFDIR"/sap.cfg" #define DEFAULT_CONF SYSCONFDIR"/sap.cfg"
#define DEFAULT_TTL 255 #define DEFAULT_TTL 255
#define DEFAULT_SCOPE '8' #define DEFAULT_SCOPE '8'
#define DEFAULT_PORT "1234" #define DEFAULT_PORT 1234
#define DEFAULT_DELAY 5 /* wait DELAY seconds before each sending */ #define DEFAULT_DELAY 5 /* wait DELAY seconds before each sending */
......
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