NEW SDP parser, have fun :D (and test...)

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@791 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Mikkel Liisberg 18 years ago
parent 3440914e38
commit ff075f58de

File diff suppressed because it is too large Load Diff

@ -31,6 +31,7 @@
#include <string>
#include <map>
#include <vector>
#include <netinet/in.h>
using std::string;
@ -50,9 +51,9 @@ enum NetworkType { NT_OTHER=0, NT_IN };
/** address type */
enum AddressType { AT_NONE=0, AT_V4, AT_V6 };
/** media type */
enum MediaType { MT_NONE=0, MT_AUDIO, MT_VIDEO, MT_APPLICATION, MT_DATA };
enum MediaType { MT_NONE=0, MT_AUDIO, MT_VIDEO, MT_APPLICATION, MT_TEXT, MT_MESSAGE };
/** transport protocol */
enum TransProt { TP_NONE=0, TP_RTPAVP, TP_UDP };
enum TransProt { TP_NONE=0, TP_RTPAVP, TP_UDP, TP_RTPSAVP };
/** \brief c=... line in SDP*/
struct SdpConnection
@ -61,6 +62,9 @@ struct SdpConnection
int network;
/** @see AddressType */
int addrType;
struct sockaddr_in ipv4;
struct sockaddr_in6 ipv6;
/** IP address */
string address;
@ -82,18 +86,21 @@ struct SdpOrigin
*/
struct SdpPayload
{
int type;
int int_pt; // internal payload type
int payload_type; // SDP payload type
string encoding_name;
int clock_rate; // sample rate (Hz)
string format;
string sdp_format_parameters;
int encoding_param;
SdpPayload() : int_pt(-1), payload_type(-1), clock_rate(-1) {}
SdpPayload() : int_pt(-1), payload_type(-1), clock_rate(-1), encoding_param(-1) {}
SdpPayload(int pt) : int_pt(-1), payload_type(pt), clock_rate(-1) {}
SdpPayload(int pt) : int_pt(-1), payload_type(pt), clock_rate(-1), encoding_param(-1) {}
SdpPayload(int pt, const string& name, int rate)
: int_pt(-1), payload_type(pt), encoding_name(name), clock_rate(rate) {}
SdpPayload(int pt, const string& name, int rate, int param)
: int_pt(-1), payload_type(pt), encoding_name(name), clock_rate(rate), encoding_param(param) {}
bool operator == (int r);
};
@ -110,6 +117,7 @@ struct SdpMedia
int type;
unsigned int port;
unsigned int nports;
int transport;
SdpConnection conn; // c=
Direction dir; // a=direction
@ -147,7 +155,7 @@ public:
unsigned int version; // v=
SdpOrigin origin; // o=
string sessionName; // s=
string uri; // u=
string uri; // u=
SdpConnection conn; // c=
std::vector<SdpMedia> media; // m= ... [a=rtpmap:...]+

@ -165,10 +165,21 @@ bool str2i(char*& str, unsigned int& result, char sep)
ret=ret*10+*str-'0';
i++;
if (i>10) goto error_digits;
} else if( *str == sep )
} else {
bool eol = false;
switch(*str){
case 0xd:
case 0xa:
case 0x0:
eol = true;
}
if( (*str != sep) && !eol )
goto error_char;
break;
else
goto error_char;
}
}
result = ret;
@ -178,7 +189,7 @@ bool str2i(char*& str, unsigned int& result, char sep)
DBG("str2i: too many letters in [%s]\n", init);
return true;
error_char:
DBG("str2i: unexpected char %c in %s\n", *str, init);
DBG("str2i: unexpected char 0x%x in %s\n", *str, init);
return true;
}

@ -0,0 +1,92 @@
/*
*
*/
#ifndef __ErrorSdp__
#define __ErrorSdp__
#include <string>
#include <stdio.h>
#include <iostream>
#include "log.h"
using namespace std;
/*
*Check if known media type is used
*/
static int media_type(string media)
{
if(media == "audio")
return 1;
else if(media == "video")
return 2;
else if(media == "application")
return 3;
else if(media == "text")
return 4;
else if(media == "message")
return 5;
else
return -1;
}
static int transport_type(string transport)
{
if(transport == "RTP/AVP")
return 1;
else if(transport == "UDP")
return 2;
else if(transport == "RTP/SAVP")
return 3;
else
return -1;
}
/*
*Check if known attribute name is used
*/
static bool attr_check(string attr)
{
if(attr == "cat")
return true;
else if(attr == "keywds")
return true;
else if(attr == "tool")
return true;
else if(attr == "ptime")
return true;
else if(attr == "maxptime")
return true;
else if(attr == "recvonly")
return true;
else if(attr == "sendrecv")
return true;
else if(attr == "sendonly")
return true;
else if(attr == "inactive")
return true;
else if(attr == "orient")
return true;
else if(attr == "type")
return true;
else if(attr == "charset")
return true;
else if(attr == "sdplang")
return true;
else if(attr == "lang")
return true;
else if(attr == "framerate")
return true;
else if(attr == "quality")
return true;
else
{
DBG("sdp_parse_attr: Unknow attribute name used: %s, plz see RFC4566\n", (char*)attr.c_str());
return false;
}
}
#endif
Loading…
Cancel
Save