Commit 8da73496 authored by Damien Lucas's avatar Damien Lucas

. more compliance with SDP RFC

. Set the time 't=' option to 'permanent' instead of an invalid date
parent 8ace455f
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* message.cpp : SAP Message class * message.cpp : SAP Message class
**************************************************************************** ****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: message.cpp,v 1.1 2003/05/22 02:22:45 nitrox Exp $ * $Id: message.cpp,v 1.2 2003/05/25 16:36:00 nitrox Exp $
* *
* Authors: Damien Lucas <nitrox@videolan.org> * Authors: Damien Lucas <nitrox@videolan.org>
* *
...@@ -78,17 +78,16 @@ void Message::SetCompressed(void) ...@@ -78,17 +78,16 @@ void Message::SetCompressed(void)
/***************************************************************************** /*****************************************************************************
* BuildHeader - Build the Message Header once initialized * BuildHeader - Build the Message Header once initialized
* According to RFC 2974 * According to RFC 2974 (SAP)
*****************************************************************************/ *****************************************************************************/
void Message::BuildHeader(void) void Message::BuildHeader(const char* payload_type)
{ {
unsigned int mh_size; unsigned int mh_size;
mh_size = 4; mh_size = 4;
mh_size += 4; //(IPv4 specific) mh_size += 4; //(IPv4 specific)
// size+= authentification length (N/A) // size+= authentification length (N/A)
// size+= optional payload type (N/A) (always 3 for stuffing) mh_size += strlen(payload_type+1);
mh_size += 3;
sap=(char*)malloc(mh_size*sizeof(char)); sap=(char*)malloc(mh_size*sizeof(char));
...@@ -118,28 +117,40 @@ void Message::BuildHeader(void) ...@@ -118,28 +117,40 @@ void Message::BuildHeader(void)
sap[6]=ip_server>>16; sap[6]=ip_server>>16;
sap[7]=ip_server>>24; sap[7]=ip_server>>24;
sap[8]='v'; strncpy(sap+8, payload_type, 15);
sap[9]='='; sap[8+strlen(payload_type)]='\0';
sap[10]='0';
header_len=11; header_len=9+strlen(payload_type);
return; return;
} }
void Message::AddProgram(Program *p) void Message::AddProgram(Program *p)
{ {
// TODO Ugly, only , ... more than one program ?? // TODO Ugly, ... more than one program ??
// RFC 2327 Compliance ? // RFC 2327 Compliance ?
string v="v=0\n"; // SDP version
string o="o="+p->GetUser()+" 3247692199 3247895918 IN IP4 "+ string o="o="+p->GetUser()+" 3247692199 3247895918 IN IP4 "+
p->GetMachine()+" \n"; p->GetMachine()+"\n";
string s="s="+p->GetName()+" \n"; string s="s="+p->GetName()+"\n";
string u="u="+p->GetSite()+" \n"; string u="u="+p->GetSite()+"\n";
string t="t=3247691400 32501 17800 \n"; string t;
string a="a=type:test \n"; if(p->IsPermanent() == true)
string m="m=audio 1234 udp 14 \n"; {
string c="c=IN IP4 "+p->GetAddress()+"/15 \n"; t="t=0 0\n";
}
sdp += o + s + u + t + a + m + c; else
{
/* TODO */
t="t=0 0\n";
fprintf(stderr, "Non permanent program not supported ...\n");
fprintf(stderr, "Announcing permanent session instead\n");
}
string m="m=audio 1234 udp 14\n";
string c="c=IN IP4 "+p->GetAddress()+"/15\n";
// TODO ttl type should be specified
string a="a=type:test\n";
sdp += v + o + s + u + t + m + c + a;
return; return;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* message.h : SAP Message Class definition * message.h : SAP Message Class definition
**************************************************************************** ****************************************************************************
* Copyright (C) 1998-2003 VideoLAN * Copyright (C) 1998-2003 VideoLAN
* $Id: message.h,v 1.1 2003/05/22 02:22:45 nitrox Exp $ * $Id: message.h,v 1.2 2003/05/25 16:36:00 nitrox Exp $
* *
* Authors: Damien Lucas <nitrox@videolan.org> * Authors: Damien Lucas <nitrox@videolan.org>
* *
...@@ -32,7 +32,7 @@ class Message { ...@@ -32,7 +32,7 @@ class Message {
public: public:
Message(char message_type, uint16_t version, const char* ip); Message(char message_type, uint16_t version, const char* ip);
~Message(); ~Message();
void BuildHeader(void); void BuildHeader(const char* payload_type);
void AddProgram(Program*); void AddProgram(Program*);
void SetEncrypted(); void SetEncrypted();
void SetCompressed(); void SetCompressed();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* program.cpp : SAP Program class * program.cpp : SAP Program class
**************************************************************************** ****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: program.cpp,v 1.1 2003/05/22 02:22:45 nitrox Exp $ * $Id: program.cpp,v 1.2 2003/05/25 16:36:00 nitrox Exp $
* *
* Authors: Damien Lucas <nitrox@videolan.org> * Authors: Damien Lucas <nitrox@videolan.org>
* *
...@@ -33,7 +33,11 @@ using namespace std; ...@@ -33,7 +33,11 @@ using namespace std;
#include "program.h" #include "program.h"
Program::Program() {return;} Program::Program()
{
permanent=true;
return;
}
Program::~Program() {return;} Program::~Program() {return;}
string Program::GetName(void) {return name;} string Program::GetName(void) {return name;}
...@@ -41,6 +45,7 @@ string Program::GetUser(void) {return user;} ...@@ -41,6 +45,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;}
bool Program::IsPermanent(void){return permanent;}
void Program::SetName(char* n){name=n;} void Program::SetName(char* n){name=n;}
void Program::SetUser(char* u){user=u;} void Program::SetUser(char* u){user=u;}
...@@ -55,4 +60,5 @@ Program::Program(string n, string u, string m, string s, string a) ...@@ -55,4 +60,5 @@ Program::Program(string n, string u, string m, string s, string a)
machine=m; machine=m;
site=s; site=s;
address=a; address=a;
permanent=true;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* program.h : SAP programs classes definition * program.h : SAP programs classes definition
**************************************************************************** ****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: program.h,v 1.1 2003/05/22 02:22:45 nitrox Exp $ * $Id: program.h,v 1.2 2003/05/25 16:36:00 nitrox Exp $
* *
* Authors: Damien Lucas <nitrox@videolan.org> * Authors: Damien Lucas <nitrox@videolan.org>
* *
...@@ -38,7 +38,7 @@ class Program ...@@ -38,7 +38,7 @@ class Program
void SetMachine(char*); void SetMachine(char*);
void SetSite(char*); void SetSite(char*);
void SetAddress(char*); void SetAddress(char*);
bool IsPermanent();
private: private:
string name; string name;
...@@ -46,4 +46,8 @@ class Program ...@@ -46,4 +46,8 @@ class Program
string machine; string machine;
string site; string site;
string address; string address;
bool permanent;
uint32_t start_time;
uint32_t stop_time;
/* TODO support for periodical programs */
}; };
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sapserver.cpp : SAP discovery service mini-server * sapserver.cpp : SAP discovery service mini-server
**************************************************************************** ****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: sapserver.cpp,v 1.6 2003/05/22 02:22:45 nitrox Exp $ * $Id: sapserver.cpp,v 1.7 2003/05/25 16:36:00 nitrox Exp $
* *
* Authors: Fabrice Ollivier <cif@via.ecp.fr> * Authors: Fabrice Ollivier <cif@via.ecp.fr>
* Arnaud Schauly <gitan@via.ecp.fr> * Arnaud Schauly <gitan@via.ecp.fr>
...@@ -125,7 +125,7 @@ int main(int argc, char *argv[]) ...@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
/* Create a new message */ /* Create a new message */
message=new Message(SAP_ANNOUNCE, 0x4212, "1.2.3.4"); message=new Message(SAP_ANNOUNCE, 0x4212, "1.2.3.4");
/* Build the message header */ /* Build the message header */
message->BuildHeader(); message->BuildHeader("application/sdp");
/* Add the program */ /* Add the program */
message->AddProgram(config->Programs[i]); message->AddProgram(config->Programs[i]);
/* Send the message */ /* Send the message */
......
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