00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __OPAL_SDP_H
00033 #define __OPAL_SDP_H
00034
00035 #ifdef P_USE_PRAGMA
00036 #pragma interface
00037 #endif
00038
00039
00040 #include <opal/transports.h>
00041 #include <opal/mediafmt.h>
00042 #include <rtp/rtp.h>
00043
00044
00046
00047 class SDPMediaFormat : public PObject
00048 {
00049 PCLASSINFO(SDPMediaFormat, PObject);
00050 public:
00051
00052 enum NTEEvent {
00053 Digit0 = 0,
00054 Digit1 = 1,
00055 Digit2 = 2,
00056 Digit3 = 3,
00057 Digit4 = 4,
00058 Digit5 = 5,
00059 Digit6 = 6,
00060 Digit7 = 7,
00061 Digit8 = 8,
00062 Digit9 = 9,
00063 Star = 10,
00064 Hash = 11,
00065 A = 12,
00066 B = 13,
00067 C = 14,
00068 D = 15,
00069 Flash = 16
00070 };
00071
00072 SDPMediaFormat(
00073 RTP_DataFrame::PayloadTypes payloadType,
00074 const char * name = NULL
00075 );
00076
00077 SDPMediaFormat(
00078 const OpalMediaFormat & mediaFormat,
00079 RTP_DataFrame::PayloadTypes pt,
00080 const char * nteString = NULL
00081 );
00082
00083 void PrintOn(ostream & str) const;
00084
00085 RTP_DataFrame::PayloadTypes GetPayloadType() const { return payloadType; }
00086
00087 PString GetEncodingName() const { return encodingName; }
00088 void SetEncodingName(const PString & v) { encodingName = v; }
00089
00090 void SetFMTP(const PString & _fmtp);
00091 PString GetFMTP() const;
00092
00093 unsigned GetClockRate(void) { return clockRate ; }
00094 void SetClockRate(unsigned v) { clockRate = v; }
00095
00096 void SetParameters(const PString & v) { parameters = v; }
00097
00098 void SetPacketTime(const PString & optionName, unsigned ptime);
00099
00100 const OpalMediaFormat & GetMediaFormat() const;
00101
00102 bool ToNormalisedOptions();
00103
00104 protected:
00105 void AddNTEString(const PString & str);
00106 void AddNTEToken(const PString & ostr);
00107 PString GetNTEString() const;
00108
00109 #if OPAL_T38FAX
00110 void AddNSEString(const PString & str);
00111 void AddNSEToken(const PString & ostr);
00112 PString GetNSEString() const;
00113 #endif
00114
00115 void AddNXEString(POrdinalSet & nxeSet, const PString & str);
00116 void AddNXEToken(POrdinalSet & nxeSet, const PString & ostr);
00117 PString GetNXEString(POrdinalSet & nxeSet) const;
00118
00119 mutable OpalMediaFormat mediaFormat;
00120 RTP_DataFrame::PayloadTypes payloadType;
00121
00122 unsigned clockRate;
00123 PString encodingName;
00124 PString parameters;
00125 PString fmtp;
00126
00127 mutable POrdinalSet nteSet;
00128 #if OPAL_T38FAX
00129 mutable POrdinalSet nseSet;
00130 #endif
00131 };
00132
00133 PLIST(SDPMediaFormatList, SDPMediaFormat);
00134
00135
00137
00138 class SDPBandwidth : public std::map<PString, unsigned>
00139 {
00140 public:
00141 unsigned & operator[](const PString & type);
00142 unsigned operator[](const PString & type) const;
00143 friend ostream & operator<<(ostream & out, const SDPBandwidth & bw);
00144 bool Parse(const PString & param);
00145 };
00146
00147
00149
00150 class SDPMediaDescription : public PObject
00151 {
00152 PCLASSINFO(SDPMediaDescription, PObject);
00153 public:
00154
00155
00156 enum Direction {
00157 Undefined = -1,
00158 Inactive,
00159 RecvOnly,
00160 SendOnly,
00161 SendRecv
00162 };
00163
00164 enum MediaType {
00165 Audio,
00166 Video,
00167 Application,
00168 Image,
00169 Unknown,
00170 NumMediaTypes
00171 };
00172 #if PTRACING
00173 friend ostream & operator<<(ostream & out, MediaType type);
00174 #endif
00175
00176 SDPMediaDescription(
00177 const OpalTransportAddress & address,
00178 MediaType mediaType = Unknown
00179 );
00180
00181 void PrintOn(ostream & strm) const;
00182 void PrintOn(const OpalTransportAddress & commonAddr, ostream & str) const;
00183
00184 bool Decode(const PString & value);
00185 bool Decode(char key, const PString & value);
00186 virtual bool PostDecode();
00187
00188 MediaType GetMediaType() const { return mediaType; }
00189
00190 const SDPMediaFormatList & GetSDPMediaFormats() const
00191 { return formats; }
00192
00193 OpalMediaFormatList GetMediaFormats(unsigned) const;
00194 void CreateRTPMap(unsigned sessionID, RTP_DataFrame::PayloadMapType & map) const;
00195
00196 void AddSDPMediaFormat(SDPMediaFormat * sdpMediaFormat);
00197
00198 void AddMediaFormat(const OpalMediaFormat & mediaFormat, const RTP_DataFrame::PayloadMapType & map);
00199 void AddMediaFormats(const OpalMediaFormatList & mediaFormats, unsigned session, const RTP_DataFrame::PayloadMapType & map);
00200
00201 void SetAttribute(const PString & attr, const PString & value);
00202
00203 void SetDirection(const Direction & d) { direction = d; }
00204 Direction GetDirection() const { return direction; }
00205
00206 const OpalTransportAddress & GetTransportAddress() const { return transportAddress; }
00207 PBoolean SetTransportAddress(const OpalTransportAddress &t);
00208
00209 PString GetTransport() const { return transport; }
00210 void SetTransport(const PString & v) { transport = v; }
00211
00212 WORD GetPort() const { return port; }
00213
00214 PCaselessString GetMedia() const { return media; }
00215 void SetMedia(const PCaselessString & mediaStr) { media = mediaStr;}
00216
00217 unsigned GetBandwidth(const PString & type) const { return bandwidth[type]; }
00218 void SetBandwidth(const PString & type, unsigned value) { bandwidth[type] = value; }
00219
00220 void RemoveSDPMediaFormat(const SDPMediaFormat & sdpMediaFormat);
00221
00222 protected:
00223 void PrintOn(ostream & strm, const PString & str) const;
00224 SDPMediaFormat * FindFormat(PString & str) const;
00225 void SetPacketTime(const PString & optionName, const PString & value);
00226
00227 MediaType mediaType;
00228 WORD portCount;
00229 PCaselessString media;
00230 PCaselessString transport;
00231 OpalTransportAddress transportAddress;
00232 WORD port;
00233
00234 Direction direction;
00235
00236 SDPMediaFormatList formats;
00237 SDPBandwidth bandwidth;
00238
00239 #if OPAL_T38FAX
00240 PStringToString t38Attributes;
00241 #endif // OPAL_T38FAX
00242 };
00243
00244 PARRAY(SDPMediaDescriptionArray, SDPMediaDescription);
00245
00246
00248
00249 class SDPSessionDescription : public PObject
00250 {
00251 PCLASSINFO(SDPSessionDescription, PObject);
00252 public:
00253 SDPSessionDescription(
00254 const OpalTransportAddress & address = OpalTransportAddress()
00255 );
00256
00257 void PrintOn(ostream & strm) const;
00258 PString Encode() const;
00259 PBoolean Decode(const PString & str);
00260
00261 void SetSessionName(const PString & v) { sessionName = v; }
00262 PString GetSessionName() const { return sessionName; }
00263
00264 void SetUserName(const PString & v) { ownerUsername = v; }
00265 PString GetUserName() const { return ownerUsername; }
00266
00267 const SDPMediaDescriptionArray & GetMediaDescriptions() const { return mediaDescriptions; }
00268
00269 SDPMediaDescription * GetMediaDescription(
00270 SDPMediaDescription::MediaType rtpMediaType
00271 ) const;
00272 void AddMediaDescription(SDPMediaDescription * md) { mediaDescriptions.Append(md); }
00273
00274 void SetDirection(const SDPMediaDescription::Direction & d) { direction = d; }
00275 SDPMediaDescription::Direction GetDirection(unsigned) const;
00276
00277 const OpalTransportAddress & GetDefaultConnectAddress() const { return defaultConnectAddress; }
00278 void SetDefaultConnectAddress(
00279 const OpalTransportAddress & address
00280 );
00281
00282 PINDEX GetOwnerSessionId() const { return ownerSessionId; }
00283 void SetOwnerSessionId(PINDEX value) { ownerSessionId = value; }
00284
00285 PINDEX GetOwnerVersion() const { return ownerVersion; }
00286 void SetOwnerVersion(PINDEX value) { ownerVersion = value; }
00287
00288 OpalTransportAddress GetOwnerAddress() const { return ownerAddress; }
00289 void SetOwnerAddress(OpalTransportAddress addr) { ownerAddress = addr; }
00290
00291 unsigned GetBandwidth(const PString & type) const { return bandwidth[type]; }
00292 void SetBandwidth(const PString & type, unsigned value) { bandwidth[type] = value; }
00293
00294 static const PString & ConferenceTotalBandwidthType();
00295 static const PString & ApplicationSpecificBandwidthType();
00296
00297 protected:
00298 void ParseOwner(const PString & str);
00299
00300 SDPMediaDescriptionArray mediaDescriptions;
00301 SDPMediaDescription::Direction direction;
00302
00303 PINDEX protocolVersion;
00304 PString sessionName;
00305
00306 PString ownerUsername;
00307 unsigned ownerSessionId;
00308 unsigned ownerVersion;
00309 OpalTransportAddress ownerAddress;
00310 OpalTransportAddress defaultConnectAddress;
00311
00312 SDPBandwidth bandwidth;
00313 };
00314
00316
00317
00318 #endif // __OPAL_SDP_H
00319
00320
00321