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 #ifndef __OPAL_SDP_H
00094 #define __OPAL_SDP_H
00095
00096 #ifdef P_USE_PRAGMA
00097 #pragma interface
00098 #endif
00099
00100
00101 #include <opal/transports.h>
00102 #include <opal/mediafmt.h>
00103 #include <rtp/rtp.h>
00104
00105
00107
00108 class SDPMediaFormat : public PObject
00109 {
00110 PCLASSINFO(SDPMediaFormat, PObject);
00111 public:
00112
00113 enum NTEEvent {
00114 Digit0 = 0,
00115 Digit1 = 1,
00116 Digit2 = 2,
00117 Digit3 = 3,
00118 Digit4 = 4,
00119 Digit5 = 5,
00120 Digit6 = 6,
00121 Digit7 = 7,
00122 Digit8 = 8,
00123 Digit9 = 9,
00124 Star = 10,
00125 Hash = 11,
00126 A = 12,
00127 B = 13,
00128 C = 14,
00129 D = 15,
00130 Flash = 16
00131 };
00132
00133 SDPMediaFormat(
00134 RTP_DataFrame::PayloadTypes payloadType,
00135 const char * name = "-",
00136 unsigned rate = 8000,
00137 const char * param = ""
00138 );
00139
00140 SDPMediaFormat(const PString & fmtp, RTP_DataFrame::PayloadTypes pt);
00141
00142 void PrintOn(ostream & str) const;
00143
00144 RTP_DataFrame::PayloadTypes GetPayloadType() const { return payloadType; }
00145
00146 PString GetEncodingName() const { return encodingName; }
00147 void SetEncodingName(const PString & v) { encodingName = v; }
00148
00149 void SetFMTP(const PString & _fmtp);
00150 PString GetFMTP() const;
00151
00152 unsigned GetClockRate(void) { return clockRate ; }
00153 void SetClockRate(unsigned v) { clockRate = v; }
00154
00155 void SetParameters(const PString & v) { parameters = v; }
00156
00157 OpalMediaFormat GetMediaFormat() const;
00158
00159 protected:
00160 void AddNTEString(const PString & str);
00161 void AddNTEToken(const PString & ostr);
00162 PString GetNTEString() const;
00163
00164 RTP_DataFrame::PayloadTypes payloadType;
00165
00166 unsigned clockRate;
00167 PString encodingName;
00168 PString parameters;
00169 PString fmtp;
00170
00171 POrdinalSet nteSet;
00172 };
00173
00174 PLIST(SDPMediaFormatList, SDPMediaFormat);
00175
00176
00178
00179 class SDPMediaDescription : public PObject
00180 {
00181 PCLASSINFO(SDPMediaDescription, PObject);
00182 public:
00183 enum Direction {
00184 RecvOnly,
00185 SendOnly,
00186 SendRecv,
00187 Inactive,
00188 Undefined
00189 };
00190
00191 enum MediaType {
00192 Audio,
00193 Video,
00194 Application,
00195 Unknown,
00196 NumMediaTypes
00197 };
00198 #if PTRACING
00199 friend ostream & operator<<(ostream & out, MediaType type);
00200 #endif
00201
00202 SDPMediaDescription(
00203 const OpalTransportAddress & address,
00204 MediaType mediaType = Unknown
00205 );
00206
00207 void PrintOn(ostream & strm) const;
00208 void PrintOn(const OpalTransportAddress & commonAddr, ostream & str) const;
00209
00210 BOOL Decode(const PString & str);
00211
00212 MediaType GetMediaType() const { return mediaType; }
00213
00214 const SDPMediaFormatList & GetSDPMediaFormats() const
00215 { return formats; }
00216
00217 OpalMediaFormatList GetMediaFormats(unsigned) const;
00218 void CreateRTPMap(unsigned sessionID, RTP_DataFrame::PayloadMapType & map) const;
00219
00220 void AddSDPMediaFormat(SDPMediaFormat * sdpMediaFormat);
00221
00222 void AddMediaFormat(const OpalMediaFormat & mediaFormat, const RTP_DataFrame::PayloadMapType & map);
00223 void AddMediaFormats(const OpalMediaFormatList & mediaFormats, unsigned session, const RTP_DataFrame::PayloadMapType & map);
00224
00225 void SetAttribute(const PString & attr);
00226
00227 void SetDirection(const Direction & d) { direction = d; }
00228 Direction GetDirection() const { return direction; }
00229
00230 const OpalTransportAddress & GetTransportAddress() const { return transportAddress; }
00231
00232 PString GetTransport() const { return transport; }
00233 void SetTransport(const PString & v) { transport = v; }
00234
00235 PINDEX GetPacketTime () const { return packetTime; }
00236 void SetPacketTime (PINDEX milliseconds) { packetTime = milliseconds; }
00237
00238 protected:
00239 void PrintOn(ostream & strm, const PString & str) const;
00240 MediaType mediaType;
00241 WORD portCount;
00242 PCaselessString media;
00243 PCaselessString transport;
00244 OpalTransportAddress transportAddress;
00245
00246 Direction direction;
00247
00248 SDPMediaFormatList formats;
00249 PINDEX packetTime;
00250 };
00251
00252 PLIST(SDPMediaDescriptionList, SDPMediaDescription);
00253
00254
00256
00257 class SDPSessionDescription : public PObject
00258 {
00259 PCLASSINFO(SDPSessionDescription, PObject);
00260 public:
00261 SDPSessionDescription(
00262 const OpalTransportAddress & address = OpalTransportAddress()
00263 );
00264
00265 void PrintOn(ostream & strm) const;
00266 PString Encode() const;
00267 BOOL Decode(const PString & str);
00268
00269 void SetSessionName(const PString & v) { sessionName = v; }
00270 PString GetSessionName() const { return sessionName; }
00271
00272 void SetUserName(const PString & v) { ownerUsername = v; }
00273 PString GetUserName() const { return ownerUsername; }
00274
00275 const SDPMediaDescriptionList & GetMediaDescriptions() const { return mediaDescriptions; }
00276
00277 SDPMediaDescription * GetMediaDescription(
00278 SDPMediaDescription::MediaType rtpMediaType
00279 ) const;
00280 void AddMediaDescription(SDPMediaDescription * md) { mediaDescriptions.Append(md); }
00281
00282 void SetDirection(const SDPMediaDescription::Direction & d) { direction = d; }
00283 SDPMediaDescription::Direction GetDirection(unsigned) const;
00284
00285 const OpalTransportAddress & GetDefaultConnectAddress() const { return defaultConnectAddress; }
00286 void SetDefaultConnectAddress(
00287 const OpalTransportAddress & address
00288 ) { defaultConnectAddress = address; }
00289
00290
00291 protected:
00292 void ParseOwner(const PString & str);
00293
00294 SDPMediaDescriptionList mediaDescriptions;
00295 SDPMediaDescription::Direction direction;
00296
00297 PINDEX protocolVersion;
00298 PString sessionName;
00299
00300 PString ownerUsername;
00301 unsigned ownerSessionId;
00302 unsigned ownerVersion;
00303 OpalTransportAddress ownerAddress;
00304 OpalTransportAddress defaultConnectAddress;
00305 };
00306
00308
00309
00310 #endif // __OPAL_SDP_H
00311
00312
00313