sdp.h

Go to the documentation of this file.
00001 /*
00002  * sdp.h
00003  *
00004  * Session Description Protocol
00005  *
00006  * Open Phone Abstraction Library (OPAL)
00007  * Formally known as the Open H323 project.
00008  *
00009  * Copyright (c) 2001 Equivalence Pty. Ltd.
00010  *
00011  * The contents of this file are subject to the Mozilla Public License
00012  * Version 1.0 (the "License"); you may not use this file except in
00013  * compliance with the License. You may obtain a copy of the License at
00014  * http://www.mozilla.org/MPL/
00015  *
00016  * Software distributed under the License is distributed on an "AS IS"
00017  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00018  * the License for the specific language governing rights and limitations
00019  * under the License.
00020  *
00021  * The Original Code is Open Phone Abstraction Library.
00022  *
00023  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00024  *
00025  * Contributor(s): ______________________________________.
00026  *
00027  * $Log: sdp.h,v $
00028  * Revision 2.15.2.1  2006/02/06 04:38:37  csoutheren
00029  * Backported RTP payload mapping fixes from CVS head
00030  *
00031  * Revision 2.16  2006/02/02 07:02:57  csoutheren
00032  * Added RTP payload map to transcoders and connections to allow remote SIP endpoints
00033  * to change the payload type used for outgoing RTP.
00034  *
00035  * Revision 2.15  2005/12/15 21:15:44  dsandras
00036  * Fixed compilation with gcc 4.1.
00037  *
00038  * Revision 2.14  2005/10/04 18:31:01  dsandras
00039  * Allow SetFMTP and GetFMTP to work with any option set for a=fmtp:.
00040  *
00041  * Revision 2.13  2005/09/15 17:01:08  dsandras
00042  * Added support for the direction attributes in the audio & video media descriptions and in the session.
00043  *
00044  * Revision 2.12  2005/07/14 08:52:19  csoutheren
00045  * Modified to output media desscription specific connection address if needed
00046  *
00047  * Revision 2.11  2005/04/28 20:22:52  dsandras
00048  * Applied big sanity patch for SIP thanks to Ted Szoczei <tszoczei@microtronix.ca>.
00049  * Thanks a lot!
00050  *
00051  * Revision 2.10  2005/04/10 20:51:25  dsandras
00052  * Added possibility to set/get the direction of a stream in an SDP.
00053  *
00054  * Revision 2.9  2004/02/09 13:13:01  rjongbloed
00055  * Added debug string output for media type enum.
00056  *
00057  * Revision 2.8  2004/02/07 02:18:19  rjongbloed
00058  * Improved searching for media format to use payload type AND the encoding name.
00059  *
00060  * Revision 2.7  2004/01/08 22:27:03  csoutheren
00061  * Fixed problem with not using session ID when constructing SDP lists
00062  *
00063  * Revision 2.6  2002/09/16 02:52:35  robertj
00064  * Added #define so can select if #pragma interface/implementation is used on
00065  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00066  *
00067  * Revision 2.5  2002/06/16 02:21:56  robertj
00068  * Utilised new standard PWLib class for POrdinalKey
00069  *
00070  * Revision 2.4  2002/03/15 07:08:24  robertj
00071  * Removed redundent return value on SetXXX function.
00072  *
00073  * Revision 2.3  2002/02/13 02:27:50  robertj
00074  * Normalised some function names.
00075  * Fixed incorrect port number usage stopping audio in one direction.
00076  *
00077  * Revision 2.2  2002/02/11 07:34:58  robertj
00078  * Changed SDP to use OpalTransport for hosts instead of IP addresses/ports
00079  *
00080  * Revision 2.1  2002/02/01 04:53:01  robertj
00081  * Added (very primitive!) SIP support.
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     // the following values are mandated by RFC 2833
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;     // used for NTE formats only
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;                  // ptime attribute, in milliseconds
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 // End of File ///////////////////////////////////////////////////////////////

Generated on Mon Jan 7 22:31:19 2008 for OPAL by  doxygen 1.4.6