Emeric Vigier | 2f62582 | 2012-08-06 11:09:52 -0400 | [diff] [blame] | 1 | // Copyright (C) 2002 Federico Montesino Pouzols <fedemp@altern.org>. |
| 2 | // |
| 3 | // This program is free software; you can redistribute it and/or modify |
| 4 | // it under the terms of the GNU General Public License as published by |
| 5 | // the Free Software Foundation; either version 2 of the License, or |
| 6 | // (at your option) any later version. |
| 7 | // |
| 8 | // This program is distributed in the hope that it will be useful, |
| 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | // GNU General Public License for more details. |
| 12 | // |
| 13 | // You should have received a copy of the GNU General Public License |
| 14 | // along with this program; if not, write to the Free Software |
| 15 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 16 | // |
| 17 | // As a special exception, you may use this file as part of a free software |
| 18 | // library without restriction. Specifically, if other files instantiate |
| 19 | // templates or use macros or inline functions from this file, or you compile |
| 20 | // this file and link it with other files to produce an executable, this |
| 21 | // file does not by itself cause the resulting executable to be covered by |
| 22 | // the GNU General Public License. This exception does not however |
| 23 | // invalidate any other reasons why the executable file might be covered by |
| 24 | // the GNU General Public License. |
| 25 | // |
| 26 | // This exception applies only to the code released under the name GNU |
| 27 | // ccRTP. If you copy code from other releases into a copy of GNU |
| 28 | // ccRTP, as the General Public License permits, the exception does |
| 29 | // not apply to the code that you add in this way. To avoid misleading |
| 30 | // anyone as to the status of such modified files, you must delete |
| 31 | // this exception notice from them. |
| 32 | // |
| 33 | // If you write modifications of your own for GNU ccRTP, it is your choice |
| 34 | // whether to permit this exception to apply to your modifications. |
| 35 | // If you do not wish that, delete this exception notice. |
| 36 | // |
| 37 | |
| 38 | #ifndef CCXX_RTP_FORMATS_H_ |
| 39 | #define CCXX_RTP_FORMATS_H_ |
| 40 | |
| 41 | #ifdef CCXX_NAMESPACES |
| 42 | namespace ost { |
| 43 | #endif |
| 44 | |
| 45 | /** |
| 46 | * @file formats.h |
| 47 | * |
| 48 | * @short Payload types and formats. |
| 49 | **/ |
| 50 | |
| 51 | /** |
| 52 | * @defgroup payload Payload types and formats. |
| 53 | * @{ |
| 54 | **/ |
| 55 | |
| 56 | /** |
| 57 | * @typedef PayloadType |
| 58 | * |
| 59 | * @short RTP payload type numeric identifier. |
| 60 | * |
| 61 | * At the RTP level a payload format is identified with a 7 bit |
| 62 | * number. This number is binded to a payload format through non-RTP |
| 63 | * means (SIP, SAP, application specific rules, etc.) |
| 64 | **/ |
| 65 | typedef uint8 PayloadType; |
| 66 | |
| 67 | /// Predefined value for invalid or uninitialized payload type variables. |
| 68 | const PayloadType ptINVALID = 128; |
| 69 | |
| 70 | /** |
| 71 | * @enum StaticPayloadType |
| 72 | * |
| 73 | * @short RTP static payload types (default bindings) defined in the |
| 74 | * AVP profile. |
| 75 | **/ |
| 76 | typedef enum { |
| 77 | // Types for audio formats: |
| 78 | sptPCMU = 0, ///< ITU-T G.711. mu-law audio 8 Khz (RFC 1890) |
| 79 | firstStaticPayloadType = sptPCMU, |
| 80 | // 1016 static payload type is now deprecated. Type 1 is reserved. |
| 81 | // spt1016, ///< CELP audio (FED-STD 1016) (RFC 1890) |
| 82 | sptG726_32 = 2, ///< ITU-T G.726. ADPCM audio (RFC 1890) |
| 83 | sptGSM, ///< GSM audio (RFC 1890) |
| 84 | sptG723, ///< ITU-T G.723. MP-MLQ ACELP audio (RFC 1890) |
| 85 | sptDVI4_8000, ///< Modified IMA ADPCM audio 8Khz (RFC 1890) |
| 86 | sptDVI4_16000, ///< Modified IMA ADPCM audio 16Khz (RFC 1890) |
| 87 | sptLPC, ///< LPC audio (RFC 1890) |
| 88 | sptPCMA, ///< ITU-T G.711 A-law audio 8 Khz (RFC 1890) |
| 89 | sptG722, ///< Audio (RFCs 1890, 3047) |
| 90 | sptL16_DUAL, ///< Linear uncompressed dual audio (RFC 1890) |
| 91 | sptL16_MONO, ///< Linear uncompressed mono audio (RFC 1890) |
| 92 | sptQCELP, ///< Audio at 8000 hz. |
| 93 | // Type 13 is reserved. |
| 94 | sptMPA = 14, ///< MPEG Audio elem. stream (RFCs 1890, 2250) |
| 95 | sptG728, ///< ITU-T G.728. LD-CELP audio |
| 96 | sptDVI4_11025, ///< DVI audio at 11025 hz (by Joseph Di Pol) |
| 97 | sptDVI4_22050, ///< DVI audio at 22050 hz (by Joseph Di Pol) |
| 98 | sptG729, ///< ITU-T G.729. CS-ACELP audio |
| 99 | // Type 19 is reserved. Types 20 - 23 are unassigned. |
| 100 | lastStaticAudioPayloadType = sptG729, |
| 101 | |
| 102 | // Types for video formats: |
| 103 | // Type 24 is unassigned. |
| 104 | sptCELB = 25, ///< Sun's propietary video (RFCs 1890, 2029) |
| 105 | sptJPEG, ///< JPEG (ISO 10918) video (RFCs 1890, 2435) |
| 106 | // Type 27 is unassigned. |
| 107 | sptNV = 28, ///< Ron Frederick's nv audio (RFC 1890) |
| 108 | // Types 29 and 30 are unassigned. |
| 109 | sptH261 = 31, ///< ITU-T H.261 video (RFCs 1890, 2032) |
| 110 | sptMPV, ///< MPEG Video elem. stream (RFCs 1890, 2250) |
| 111 | sptMP2T, ///< MPEG 2 Transport stream (RFCs 1890, 2250) |
| 112 | sptH263, ///< ITU-T H.263 video (RFCs 2190, 2429) |
| 113 | // Types 35 - 71 are unassigned. |
| 114 | // Types 72 - 76 are reserved. |
| 115 | // Types 96 - 127 are dynamic. |
| 116 | lastStaticPayloadType = sptH263 |
| 117 | } StaticPayloadType; |
| 118 | |
| 119 | /** |
| 120 | * @class PayloadFormat |
| 121 | * @short Base payload format class. |
| 122 | * |
| 123 | * The properties of a payload format that, as an RTP stack, ccRTP |
| 124 | * takes into account are the payload type (numeric identifier) and |
| 125 | * the RTP clock rate. |
| 126 | * |
| 127 | * This is a base class for both StaticPayloadFormat and |
| 128 | * DynamicPayloadFormat. |
| 129 | * |
| 130 | * @author Federico Montesino Pouzols <fedemp@altern.org> |
| 131 | **/ |
| 132 | class __EXPORT PayloadFormat |
| 133 | { |
| 134 | public: |
| 135 | /** |
| 136 | * Get payload type numeric identifier carried in RTP packets. |
| 137 | * |
| 138 | * @return payload type numeric identifier. |
| 139 | **/ |
| 140 | inline PayloadType getPayloadType() const |
| 141 | { return payloadType; } |
| 142 | |
| 143 | /** |
| 144 | * Get RTP clock rate for this payload format. Note this |
| 145 | * method provides the RTP clock rate (for the timestamp in |
| 146 | * RTP data packets headers), which is not necessarily the |
| 147 | * same as the codec clock rate. |
| 148 | * |
| 149 | * @return RTP clock rate in Hz. |
| 150 | **/ |
| 151 | inline uint32 getRTPClockRate() const |
| 152 | { return RTPClockRate; } |
| 153 | |
| 154 | protected: |
| 155 | /** |
| 156 | * PayloadFormat must not be used but as base class. |
| 157 | **/ |
| 158 | PayloadFormat() |
| 159 | { } |
| 160 | |
| 161 | /** |
| 162 | * PayloadFormat must not be used but as base class. |
| 163 | **/ |
| 164 | inline virtual ~PayloadFormat() |
| 165 | { } |
| 166 | |
| 167 | /** |
| 168 | * Set payload type numeric identifier carried in RTP packets. |
| 169 | * |
| 170 | * @param pt payload type number. |
| 171 | **/ |
| 172 | inline void setPayloadType(PayloadType pt) |
| 173 | { payloadType = pt; } |
| 174 | |
| 175 | /** |
| 176 | * Set RTP clock rate. |
| 177 | * |
| 178 | * @param rate RTP clock rate in Hz. |
| 179 | **/ |
| 180 | inline void setRTPClockRate(uint32 rate) |
| 181 | { RTPClockRate = rate; } |
| 182 | |
| 183 | // default clock rate |
| 184 | static const uint32 defaultRTPClockRate; |
| 185 | |
| 186 | private: |
| 187 | PayloadType payloadType; ///< Numeric identifier. |
| 188 | uint32 RTPClockRate; ///< Rate in Hz. |
| 189 | }; |
| 190 | |
| 191 | /** |
| 192 | * @class StaticPayloadFormat |
| 193 | * @short Static payload format objects. |
| 194 | * |
| 195 | * Class of payload formats objects for payload types statically |
| 196 | * assigned. Because these payloads have an RTP clock rate assigned, |
| 197 | * it is not specified to the constructor. A call to |
| 198 | * StaticPayloadFormat(sptPCMU) will set the proper clock rate and any |
| 199 | * other parameters for that static payload type. |
| 200 | * |
| 201 | * @author Federico Montesino Pouzols <fedemp@altern.org> |
| 202 | **/ |
| 203 | class __EXPORT StaticPayloadFormat : public PayloadFormat |
| 204 | { |
| 205 | public: |
| 206 | /** |
| 207 | * Constructor. Builds a payload format from a static payload |
| 208 | * binding identifier, assigning the numeric identifier and |
| 209 | * RTP clock rate statically bounded. |
| 210 | * |
| 211 | * @param type Numeric identifier in the range 0-96. |
| 212 | * @note some identifiers are reserved. |
| 213 | **/ |
| 214 | StaticPayloadFormat(StaticPayloadType type); |
| 215 | |
| 216 | private: |
| 217 | /** |
| 218 | * RTP clock rate for static payload types. There is no need |
| 219 | * for a table like this for video types, since they all have |
| 220 | * 90000 Khz rate. |
| 221 | **/ |
| 222 | static uint32 staticAudioTypesRates[lastStaticAudioPayloadType - |
| 223 | firstStaticPayloadType + 1]; |
| 224 | }; |
| 225 | |
| 226 | /** |
| 227 | * @class DynamicPayloadFormat |
| 228 | * @short Dynamic payload format objects. |
| 229 | * |
| 230 | * Class of payload formats objects for payload types dynamically |
| 231 | * negotiated. Because these payloads do not have a fix RTP clock rate |
| 232 | * assigned, it must be specified to the constructor. This class will |
| 233 | * be used by applications that support dynamic payload negotiation. |
| 234 | * |
| 235 | * @author Federico Montesino Pouzols <fedemp@altern.org> |
| 236 | **/ |
| 237 | class __EXPORT DynamicPayloadFormat : public PayloadFormat |
| 238 | { |
| 239 | public: |
| 240 | /** |
| 241 | * Constructor. Builds a dynamic payload format from payload |
| 242 | * numeric identifier and the corresponding RTP clock rate. |
| 243 | * |
| 244 | * @param type payload type numeric identifier. |
| 245 | * @param rate RTP clock rate. |
| 246 | **/ |
| 247 | DynamicPayloadFormat(PayloadType type, uint32 rate); |
| 248 | }; |
| 249 | |
| 250 | /** @}*/ // payload |
| 251 | |
| 252 | #ifdef CCXX_NAMESPACES |
| 253 | } |
| 254 | #endif |
| 255 | |
| 256 | #endif // ndef CCXX_RTP_FORMATS_H_ |
| 257 | |
| 258 | /** EMACS ** |
| 259 | * Local variables: |
| 260 | * mode: c++ |
| 261 | * c-basic-offset: 8 |
| 262 | * End: |
| 263 | */ |