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