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 @@
* message.cpp : SAP Message class
****************************************************************************
* 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>
*
......@@ -78,17 +78,16 @@ void Message::SetCompressed(void)
/*****************************************************************************
* 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;
mh_size = 4;
mh_size += 4; //(IPv4 specific)
// size+= authentification length (N/A)
// size+= optional payload type (N/A) (always 3 for stuffing)
mh_size += 3;
mh_size += strlen(payload_type+1);
sap=(char*)malloc(mh_size*sizeof(char));
......@@ -118,28 +117,40 @@ void Message::BuildHeader(void)
sap[6]=ip_server>>16;
sap[7]=ip_server>>24;
sap[8]='v';
sap[9]='=';
sap[10]='0';
strncpy(sap+8, payload_type, 15);
sap[8+strlen(payload_type)]='\0';
header_len=11;
header_len=9+strlen(payload_type);
return;
}
void Message::AddProgram(Program *p)
{
// TODO Ugly, only , ... more than one program ??
// TODO Ugly, ... more than one program ??
// RFC 2327 Compliance ?
string v="v=0\n"; // SDP version
string o="o="+p->GetUser()+" 3247692199 3247895918 IN IP4 "+
p->GetMachine()+" \n";
string s="s="+p->GetName()+" \n";
string u="u="+p->GetSite()+" \n";
string t="t=3247691400 32501 17800 \n";
string a="a=type:test \n";
string m="m=audio 1234 udp 14 \n";
string c="c=IN IP4 "+p->GetAddress()+"/15 \n";
sdp += o + s + u + t + a + m + c;
p->GetMachine()+"\n";
string s="s="+p->GetName()+"\n";
string u="u="+p->GetSite()+"\n";
string t;
if(p->IsPermanent() == true)
{
t="t=0 0\n";
}
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;
}
......
......@@ -2,7 +2,7 @@
* message.h : SAP Message Class definition
****************************************************************************
* 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>
*
......@@ -32,7 +32,7 @@ class Message {
public:
Message(char message_type, uint16_t version, const char* ip);
~Message();
void BuildHeader(void);
void BuildHeader(const char* payload_type);
void AddProgram(Program*);
void SetEncrypted();
void SetCompressed();
......
......@@ -2,7 +2,7 @@
* program.cpp : SAP Program class
****************************************************************************
* 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>
*
......@@ -33,7 +33,11 @@ using namespace std;
#include "program.h"
Program::Program() {return;}
Program::Program()
{
permanent=true;
return;
}
Program::~Program() {return;}
string Program::GetName(void) {return name;}
......@@ -41,6 +45,7 @@ string Program::GetUser(void) {return user;}
string Program::GetMachine(void) {return machine;}
string Program::GetSite(void) {return site;}
string Program::GetAddress(void){return address;}
bool Program::IsPermanent(void){return permanent;}
void Program::SetName(char* n){name=n;}
void Program::SetUser(char* u){user=u;}
......@@ -55,4 +60,5 @@ Program::Program(string n, string u, string m, string s, string a)
machine=m;
site=s;
address=a;
permanent=true;
}
......@@ -2,7 +2,7 @@
* program.h : SAP programs classes definition
****************************************************************************
* 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>
*
......@@ -38,7 +38,7 @@ class Program
void SetMachine(char*);
void SetSite(char*);
void SetAddress(char*);
bool IsPermanent();
private:
string name;
......@@ -46,4 +46,8 @@ class Program
string machine;
string site;
string address;
bool permanent;
uint32_t start_time;
uint32_t stop_time;
/* TODO support for periodical programs */
};
......@@ -2,7 +2,7 @@
* sapserver.cpp : SAP discovery service mini-server
****************************************************************************
* 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>
* Arnaud Schauly <gitan@via.ecp.fr>
......@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
/* Create a new message */
message=new Message(SAP_ANNOUNCE, 0x4212, "1.2.3.4");
/* Build the message header */
message->BuildHeader();
message->BuildHeader("application/sdp");
/* Add the program */
message->AddProgram(config->Programs[i]);
/* 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