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