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
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 #ifndef __OPAL_SDP_H
00125 #define __OPAL_SDP_H
00126
00127 #ifdef P_USE_PRAGMA
00128 #pragma interface
00129 #endif
00130
00131
00132 #include <opal/transports.h>
00133 #include <opal/mediafmt.h>
00134 #include <rtp/rtp.h>
00135
00136
00138
00139 class SDPMediaFormat : public PObject
00140 {
00141 PCLASSINFO(SDPMediaFormat, PObject);
00142 public:
00143
00144 enum NTEEvent {
00145 Digit0 = 0,
00146 Digit1 = 1,
00147 Digit2 = 2,
00148 Digit3 = 3,
00149 Digit4 = 4,
00150 Digit5 = 5,
00151 Digit6 = 6,
00152 Digit7 = 7,
00153 Digit8 = 8,
00154 Digit9 = 9,
00155 Star = 10,
00156 Hash = 11,
00157 A = 12,
00158 B = 13,
00159 C = 14,
00160 D = 15,
00161 Flash = 16
00162 };
00163
00164 SDPMediaFormat(
00165 RTP_DataFrame::PayloadTypes payloadType,
00166 const char * name = NULL
00167 );
00168
00169 SDPMediaFormat(
00170 const OpalMediaFormat & mediaFormat,
00171 RTP_DataFrame::PayloadTypes pt,
00172 const char * nteString = NULL
00173 );
00174
00175 void PrintOn(ostream & str) const;
00176
00177 RTP_DataFrame::PayloadTypes GetPayloadType() const { return payloadType; }
00178
00179 PString GetEncodingName() const { return encodingName; }
00180 void SetEncodingName(const PString & v) { encodingName = v; }
00181
00182 void SetFMTP(const PString & _fmtp);
00183 PString GetFMTP() const;
00184
00185 unsigned GetClockRate(void) { return clockRate ; }
00186 void SetClockRate(unsigned v) { clockRate = v; }
00187
00188 void SetParameters(const PString & v) { parameters = v; }
00189
00190 void SetPacketTime(const PString & optionName, unsigned ptime);
00191
00192 const OpalMediaFormat & GetMediaFormat() const;
00193
00194 protected:
00195 void AddNTEString(const PString & str);
00196 void AddNTEToken(const PString & ostr);
00197 PString GetNTEString() const;
00198
00199 #if OPAL_T38FAX
00200 void AddNSEString(const PString & str);
00201 void AddNSEToken(const PString & ostr);
00202 PString GetNSEString() const;
00203 #endif
00204
00205 void AddNXEString(POrdinalSet & nxeSet, const PString & str);
00206 void AddNXEToken(POrdinalSet & nxeSet, const PString & ostr);
00207 PString GetNXEString(POrdinalSet & nxeSet) const;
00208
00209 mutable OpalMediaFormat mediaFormat;
00210 RTP_DataFrame::PayloadTypes payloadType;
00211
00212 unsigned clockRate;
00213 PString encodingName;
00214 PString parameters;
00215 PString fmtp;
00216
00217 mutable POrdinalSet nteSet;
00218 #if OPAL_T38FAX
00219 mutable POrdinalSet nseSet;
00220 #endif
00221 };
00222
00223 PLIST(SDPMediaFormatList, SDPMediaFormat);
00224
00225
00227
00228 class SDPMediaDescription : public PObject
00229 {
00230 PCLASSINFO(SDPMediaDescription, PObject);
00231 public:
00232 enum Direction {
00233 RecvOnly,
00234 SendOnly,
00235 SendRecv,
00236 Inactive,
00237 Undefined
00238 };
00239
00240 enum MediaType {
00241 Audio,
00242 Video,
00243 Application,
00244 Image,
00245 Unknown,
00246 NumMediaTypes
00247 };
00248 #if PTRACING
00249 friend ostream & operator<<(ostream & out, MediaType type);
00250 #endif
00251
00252 SDPMediaDescription(
00253 const OpalTransportAddress & address,
00254 MediaType mediaType = Unknown
00255 );
00256
00257 void PrintOn(ostream & strm) const;
00258 void PrintOn(const OpalTransportAddress & commonAddr, ostream & str) const;
00259
00260 BOOL Decode(const PString & str);
00261
00262 MediaType GetMediaType() const { return mediaType; }
00263
00264 const SDPMediaFormatList & GetSDPMediaFormats() const
00265 { return formats; }
00266
00267 OpalMediaFormatList GetMediaFormats(unsigned) const;
00268 void CreateRTPMap(unsigned sessionID, RTP_DataFrame::PayloadMapType & map) const;
00269
00270 void AddSDPMediaFormat(SDPMediaFormat * sdpMediaFormat);
00271
00272 void AddMediaFormat(const OpalMediaFormat & mediaFormat, const RTP_DataFrame::PayloadMapType & map);
00273 void AddMediaFormats(const OpalMediaFormatList & mediaFormats, unsigned session, const RTP_DataFrame::PayloadMapType & map);
00274
00275 void SetAttribute(const PString & attr, const PString & value);
00276
00277 void SetDirection(const Direction & d) { direction = d; }
00278 Direction GetDirection() const { return direction; }
00279
00280 const OpalTransportAddress & GetTransportAddress() const { return transportAddress; }
00281 BOOL SetTransportAddress(const OpalTransportAddress &t);
00282
00283 PString GetTransport() const { return transport; }
00284 void SetTransport(const PString & v) { transport = v; }
00285
00286 WORD GetPort() const { return port; }
00287
00288 protected:
00289 void PrintOn(ostream & strm, const PString & str) const;
00290 SDPMediaFormat * FindFormat(PString & str) const;
00291 void SetPacketTime(const PString & optionName, const PString & value);
00292
00293 MediaType mediaType;
00294 WORD portCount;
00295 PCaselessString media;
00296 PCaselessString transport;
00297 OpalTransportAddress transportAddress;
00298 WORD port;
00299
00300 Direction direction;
00301
00302 SDPMediaFormatList formats;
00303
00304 #if OPAL_T38FAX
00305 PStringToString t38Attributes;
00306 #endif // OPAL_T38FAX
00307 };
00308
00309 PLIST(SDPMediaDescriptionList, SDPMediaDescription);
00310
00311
00313
00314 class SDPSessionDescription : public PObject
00315 {
00316 PCLASSINFO(SDPSessionDescription, PObject);
00317 public:
00318 SDPSessionDescription(
00319 const OpalTransportAddress & address = OpalTransportAddress()
00320 );
00321
00322 void PrintOn(ostream & strm) const;
00323 PString Encode() const;
00324 BOOL Decode(const PString & str);
00325
00326 void SetSessionName(const PString & v) { sessionName = v; }
00327 PString GetSessionName() const { return sessionName; }
00328
00329 void SetUserName(const PString & v) { ownerUsername = v; }
00330 PString GetUserName() const { return ownerUsername; }
00331
00332 const SDPMediaDescriptionList & GetMediaDescriptions() const { return mediaDescriptions; }
00333
00334 SDPMediaDescription * GetMediaDescription(
00335 SDPMediaDescription::MediaType rtpMediaType
00336 ) const;
00337 void AddMediaDescription(SDPMediaDescription * md) { mediaDescriptions.Append(md); }
00338
00339 void SetDirection(const SDPMediaDescription::Direction & d) { direction = d; }
00340 SDPMediaDescription::Direction GetDirection(unsigned) const;
00341
00342 const OpalTransportAddress & GetDefaultConnectAddress() const { return defaultConnectAddress; }
00343 void SetDefaultConnectAddress(
00344 const OpalTransportAddress & address
00345 ) { defaultConnectAddress = address; }
00346
00347 const PString & GetBandwidthModifier() const { return bandwidthModifier; }
00348 void SetBandwidthModifier(const PString & modifier) { bandwidthModifier = modifier; }
00349
00350 PINDEX GetBandwidthValue() const { return bandwidthValue; }
00351 void SetBandwidthValue(PINDEX value) { bandwidthValue = value; }
00352
00353 static const PString & ConferenceTotalBandwidthModifier();
00354 static const PString & ApplicationSpecificBandwidthModifier();
00355
00356 protected:
00357 void ParseOwner(const PString & str);
00358
00359 SDPMediaDescriptionList mediaDescriptions;
00360 SDPMediaDescription::Direction direction;
00361
00362 PINDEX protocolVersion;
00363 PString sessionName;
00364
00365 PString ownerUsername;
00366 unsigned ownerSessionId;
00367 unsigned ownerVersion;
00368 OpalTransportAddress ownerAddress;
00369 OpalTransportAddress defaultConnectAddress;
00370 WORD defaultConnectPort;
00371
00372 PString bandwidthModifier;
00373 PINDEX bandwidthValue;
00374 };
00375
00377
00378
00379 #endif // __OPAL_SDP_H
00380
00381
00382