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

Support for custom SDP file

Patch by Mo McRoberts <mo@nevali.net>
parent 5202876a
...@@ -100,11 +100,17 @@ Message::~Message(void) ...@@ -100,11 +100,17 @@ Message::~Message(void)
bool Message::AddProgram(Program *p) bool Message::AddProgram(Program *p)
{ {
string sdp = "v=0\r\n"; // SDP version
/* FIXME */ /* FIXME */
/* RFC 2327 Compliance ? */ /* RFC 2327 Compliance ? */
if (p->HasCustomSDP())
{
sdp = p->GetCustomSDP();
}
else
{
string ipv = (p->GetAddress().find(':') == string::npos) ? "IP4" : "IP6"; string ipv = (p->GetAddress().find(':') == string::npos) ? "IP4" : "IP6";
string sdp = "v=0\r\n"; // SDP version
string ver=""; string ver="";
stringstream ssin(ver); stringstream ssin(ver);
ssin << version; ssin << version;
...@@ -152,7 +158,7 @@ bool Message::AddProgram(Program *p) ...@@ -152,7 +158,7 @@ bool Message::AddProgram(Program *p)
} }
sdp += m; sdp += m;
}
puts (sdp.c_str ()); puts (sdp.c_str ());
if (msg_len + sdp.length () > 1024) if (msg_len + sdp.length () > 1024)
......
...@@ -373,6 +373,12 @@ int Config::Parse() ...@@ -373,6 +373,12 @@ int Config::Parse()
something=1; something=1;
pp->SetPort(atoi(tline)); pp->SetPort(atoi(tline));
} }
if(strstr(line,"customsdp="))
{
strgeta(line,tline,'=');
something=1;
pp->SetCustomSDP(tline);
}
} }
if(something) if(something)
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h>
#include <string> #include <string>
#include <vector> #include <vector>
using namespace std; using namespace std;
...@@ -47,6 +48,7 @@ Program::Program() : b_rtp(false), b_has_pl_group(false) ...@@ -47,6 +48,7 @@ Program::Program() : b_rtp(false), b_has_pl_group(false)
machine = "localhost"; machine = "localhost";
user = "VideoLAN"; user = "VideoLAN";
site = "http://www.videolan.org"; site = "http://www.videolan.org";
custom_sdp = "";
} }
Program::~Program() {return;} Program::~Program() {return;}
...@@ -58,11 +60,11 @@ string Program::GetAddress(void){return address;} ...@@ -58,11 +60,11 @@ string Program::GetAddress(void){return address;}
uint16_t 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;}
string Program::GetCustomSDP(void){return custom_sdp;}
bool Program::IsPermanent(void){return permanent;} bool Program::IsPermanent(void){return permanent;}
bool Program::IsRTP(void){return b_rtp;} bool Program::IsRTP(void){return b_rtp;}
bool Program::HasPlGroup(void){return b_has_pl_group;} bool Program::HasPlGroup(void){return b_has_pl_group;}
bool Program::HasCustomSDP(void){return custom_sdp.size() ? true : false;}
void Program::SetName(const char* n){name=n;} void Program::SetName(const char* n){name=n;}
void Program::SetUser(const char* u){user=u;} void Program::SetUser(const char* u){user=u;}
void Program::SetMachine(const char* m){machine=m;} void Program::SetMachine(const char* m){machine=m;}
...@@ -72,7 +74,6 @@ void Program::SetPlGroup(const char *h){pl_group=h;} ...@@ -72,7 +74,6 @@ 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(uint16_t p) { port = p; } void Program::SetPort(uint16_t p) { port = p; }
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,uint16_t p) Program::Program(string n, string u, string m, string s, string a,uint16_t p)
...@@ -86,3 +87,25 @@ Program::Program(string n, string u, string m, string s, string a,uint16_t p) ...@@ -86,3 +87,25 @@ Program::Program(string n, string u, string m, string s, string a,uint16_t p)
port=p; port=p;
permanent=true; permanent=true;
} }
void Program::SetCustomSDP(const char *fname)
{
/* Although it's a (relatively small) fixed-sized buffer, we can't serve
* SDP any larger than this in any case - see the condition in
* Message::AddProgram():
* if(msg_len + sdp.length () > 1024) - RFC 2974 Chap 6.
*/
char buf[1024];
FILE *f;
ssize_t l;
if(NULL == (f = fopen(fname, "rb")))
{
fprintf(stderr, "%s: %s\n", fname, strerror(errno));
exit(1);
}
l = fread(buf, 1, sizeof(buf) - 1, f);
fclose(f);
buf[l] = '\0';
custom_sdp = buf;
}
...@@ -38,6 +38,7 @@ class Program ...@@ -38,6 +38,7 @@ class Program
uint16_t GetPort(); uint16_t GetPort();
string GetTTL(); string GetTTL();
string GetPlGroup(); string GetPlGroup();
string GetCustomSDP();
/* Functions to set the values */ /* Functions to set the values */
void SetName(const char*); void SetName(const char*);
...@@ -50,10 +51,12 @@ class Program ...@@ -50,10 +51,12 @@ class Program
void SetPlGroup(const char *); void SetPlGroup(const char *);
void SetHasPlGroup(bool); void SetHasPlGroup(bool);
void SetRTP(bool); void SetRTP(bool);
void SetCustomSDP(const char *);
bool IsPermanent(); bool IsPermanent();
bool IsRTP(); bool IsRTP();
bool HasPlGroup(); bool HasPlGroup();
bool HasCustomSDP();
private: private:
string name; string name;
...@@ -63,6 +66,7 @@ class Program ...@@ -63,6 +66,7 @@ class Program
string address; string address;
string program_ttl; string program_ttl;
string pl_group; string pl_group;
string custom_sdp;
bool permanent; bool permanent;
bool b_rtp; bool b_rtp;
bool b_has_pl_group; bool b_has_pl_group;
......
...@@ -39,7 +39,9 @@ port=1234 ...@@ -39,7 +39,9 @@ port=1234
# The name of the playlistgroup your announce will be part of in the VLC playlist # The name of the playlistgroup your announce will be part of in the VLC playlist
playlist_group=organisationTV playlist_group=organisationTV
# If you wish to send custom SDP to clients, specify the full path to the
# SDP file
#customsdp=/path/to/broadcast.sdp
# IPv6 example # IPv6 example
[program] [program]
......
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