Commit 5aca99f9 authored by Clément Stenac's avatar Clément Stenac

Use timestamps for session id and version

parent 4bcb42e5
......@@ -32,6 +32,8 @@
#include <vector>
using namespace std;
#include <sys/time.h>
#include "sapserver.h"
#include "program.h"
#include "message.h"
......@@ -133,8 +135,17 @@ void Message::AddProgram(Program *p)
* and only a MPEG2 TS stream announce is supported
* RFC 2327 Compliance ? */
char id[40];
struct timeval tv;
gettimeofday( &tv, NULL );
sprintf( id, " %lli %lli ",((int64_t)tv.tv_sec*1000000 + tv.tv_usec),
((int64_t)tv.tv_sec*1000000 + tv.tv_usec));
string v="v=0\n"; // SDP version
string o="o="+p->GetUser()+" 3247692199 3247895918 IN IP4 "+
string o="o="+p->GetUser()+ id +" IN IP4 "+
p->GetMachine()+"\n";
string s="s="+p->GetName()+"\n";
string u="u="+p->GetSite()+"\n";
......@@ -174,10 +185,10 @@ void Message::AddProgram(Program *p)
{
a+= "a=type:http\n";
a+= "a=http-path:"+p->GetHTTPPath()+"\n";
}
}
else
{
a= "a=type:udp\n";
a= "a=type:udp\n";
}
a+= "a=mux:m2t\n";
a+= "a=packetformat:RAW\n";
......
......@@ -138,7 +138,7 @@ int main(int argc, char *argv[])
else
{
fprintf(stdout,"+ Using IPv4\n");
i_init_status=broadcast->Initv4();
i_init_status=broadcast->Initv4();
}
......@@ -155,68 +155,71 @@ int main(int argc, char *argv[])
daemon(0,0);
}
vector<Message *> messages;
for (unsigned int i=0; i<config->Programs.size(); i++)
{
/* Create a new message */
message=new Message(SAP_ANNOUNCE, 0x4212+i, "1.2.3.4");
/* Build the message header */
message->BuildHeader("application/sdp");
/* Add the program */
message->AddProgram(config->Programs[i]);
messages.push_back( message );
}
while(1)
{
for (unsigned int i=0; i<config->Programs.size(); i++)
for( unsigned int i = 0; i< messages.size() ; i ++ )
{
/* Create a new message */
message=new Message(SAP_ANNOUNCE, 0x4212+i, "1.2.3.4");
/* Build the message header */
message->BuildHeader("application/sdp");
/* Add the program */
message->AddProgram(config->Programs[i]);
Message *message = messages[i];
/* Send the message */
if(broadcast->Send( message , config->GetIPVersion() ))
fprintf(stderr,"- Message send failed\n");
/* Delete the message */
delete message;
fprintf(stderr,"- Message send failed\n");
if(config->GetDotMode())
fprintf(stdout,".");
/* Wait for next sending */
usleep( 1+ (config->GetDelay() * 1000000 / config->Programs.size() ) );
}
fflush(stdout);
}
}
else
else
{
#ifndef CONFIG_SLP
fprintf(stderr,"- SLP not compiled in...Aborting\n");
return -1;
#endif
#ifdef CONFIG_SLP
#ifndef CONFIG_SLP
fprintf(stderr,"- SLP not compiled in...Aborting\n");
return -1;
#endif
#ifdef CONFIG_SLP
slp = new SLP();
slp = new SLP();
for(unsigned int i=0 ; i<config->Programs.size(); i++)
{
for(unsigned int i=0 ; i<config->Programs.size(); i++)
{
if(!config->GetReverse())
{
slp->Register(config->Programs[i]);
}
else
{
slp->UnRegister(config->Programs[i]);
}
}
if(!config->GetReverse())
{
slp->Register(config->Programs[i]);
fprintf(stdout,"+ Programs registered. To unregister them, run" \
"me with -u\n");
}
else
{
slp->UnRegister(config->Programs[i]);
}
}
if(!config->GetReverse())
{
fprintf(stdout,"+ Programs registered. To unregister them, run" \
"me with -u\n");
}
else
{
fprintf(stdout,"+ Programs unregistered\n");
}
fflush(stdout);
delete slp;
#endif
{
fprintf(stdout,"+ Programs unregistered\n");
}
fflush(stdout);
delete slp;
#endif
}
fprintf(stdout,"Done");
fprintf(stdout,"Done");
return 0;
}
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