blob: 7efc7ac723a58f524deb9604c4741d516a7f2ffd [file] [log] [blame]
Emeric Vigier2f625822012-08-06 11:09:52 -04001// Copyright (C) 2002 Federico Montesino Pouzols <fedemp@altern.org>.
Alexandre Lisionddd731e2014-01-31 11:50:08 -05002//
Emeric Vigier2f625822012-08-06 11:09:52 -04003// 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.
Alexandre Lisionddd731e2014-01-31 11:50:08 -05007//
Emeric Vigier2f625822012-08-06 11:09:52 -04008// 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.
Alexandre Lisionddd731e2014-01-31 11:50:08 -050012//
Emeric Vigier2f625822012-08-06 11:09:52 -040013// You should have received a copy of the GNU General Public License
Alexandre Lisionddd731e2014-01-31 11:50:08 -050014// along with this program; if not, write to the Free Software
Emeric Vigier2f625822012-08-06 11:09:52 -040015// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Alexandre Lisionddd731e2014-01-31 11:50:08 -050016//
Emeric Vigier2f625822012-08-06 11:09:52 -040017// 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
Alexandre Lisionddd731e2014-01-31 11:50:08 -050022// the GNU General Public License. This exception does not however
Emeric Vigier2f625822012-08-06 11:09:52 -040023// invalidate any other reasons why the executable file might be covered by
Alexandre Lisionddd731e2014-01-31 11:50:08 -050024// the GNU General Public License.
Emeric Vigier2f625822012-08-06 11:09:52 -040025//
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
Alexandre Lisionddd731e2014-01-31 11:50:08 -050038#ifndef CCXX_RTP_FORMATS_H_
Emeric Vigier2f625822012-08-06 11:09:52 -040039#define CCXX_RTP_FORMATS_H_
40
Alexandre Lisionddd731e2014-01-31 11:50:08 -050041NAMESPACE_COMMONCPP
Emeric Vigier2f625822012-08-06 11:09:52 -040042
Alexandre Lisionddd731e2014-01-31 11:50:08 -050043/**
44 * @file formats.h
Emeric Vigier2f625822012-08-06 11:09:52 -040045 *
46 * @short Payload types and formats.
47 **/
48
49/**
50 * @defgroup payload Payload types and formats.
51 * @{
52 **/
53
54/**
55 * @typedef PayloadType
56 *
57 * @short RTP payload type numeric identifier.
58 *
59 * At the RTP level a payload format is identified with a 7 bit
60 * number. This number is binded to a payload format through non-RTP
61 * means (SIP, SAP, application specific rules, etc.)
62 **/
63typedef uint8 PayloadType;
64
65/// Predefined value for invalid or uninitialized payload type variables.
66const PayloadType ptINVALID = 128;
67
68/**
69 * @enum StaticPayloadType
70 *
71 * @short RTP static payload types (default bindings) defined in the
72 * AVP profile.
73 **/
74typedef enum {
Alexandre Lisionddd731e2014-01-31 11:50:08 -050075 // Types for audio formats:
76 sptPCMU = 0, ///< ITU-T G.711. mu-law audio 8 Khz (RFC 1890)
77 firstStaticPayloadType = sptPCMU,
78 // 1016 static payload type is now deprecated. Type 1 is reserved.
79 // spt1016, ///< CELP audio (FED-STD 1016) (RFC 1890)
80 sptG726_32 = 2, ///< ITU-T G.726. ADPCM audio (RFC 1890)
81 sptGSM, ///< GSM audio (RFC 1890)
82 sptG723, ///< ITU-T G.723. MP-MLQ ACELP audio (RFC 1890)
83 sptDVI4_8000, ///< Modified IMA ADPCM audio 8Khz (RFC 1890)
84 sptDVI4_16000, ///< Modified IMA ADPCM audio 16Khz (RFC 1890)
85 sptLPC, ///< LPC audio (RFC 1890)
86 sptPCMA, ///< ITU-T G.711 A-law audio 8 Khz (RFC 1890)
87 sptG722, ///< Audio (RFCs 1890, 3047)
88 sptL16_DUAL, ///< Linear uncompressed dual audio (RFC 1890)
89 sptL16_MONO, ///< Linear uncompressed mono audio (RFC 1890)
90 sptQCELP, ///< Audio at 8000 hz.
91 // Type 13 is reserved.
92 sptMPA = 14, ///< MPEG Audio elem. stream (RFCs 1890, 2250)
93 sptG728, ///< ITU-T G.728. LD-CELP audio
94 sptDVI4_11025, ///< DVI audio at 11025 hz (by Joseph Di Pol)
95 sptDVI4_22050, ///< DVI audio at 22050 hz (by Joseph Di Pol)
96 sptG729, ///< ITU-T G.729. CS-ACELP audio
97 // Type 19 is reserved. Types 20 - 23 are unassigned.
98 lastStaticAudioPayloadType = sptG729,
Emeric Vigier2f625822012-08-06 11:09:52 -040099
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500100 // Types for video formats:
101 // Type 24 is unassigned.
102 sptCELB = 25, ///< Sun's propietary video (RFCs 1890, 2029)
103 sptJPEG, ///< JPEG (ISO 10918) video (RFCs 1890, 2435)
104 // Type 27 is unassigned.
105 sptNV = 28, ///< Ron Frederick's nv audio (RFC 1890)
106 // Types 29 and 30 are unassigned.
107 sptH261 = 31, ///< ITU-T H.261 video (RFCs 1890, 2032)
108 sptMPV, ///< MPEG Video elem. stream (RFCs 1890, 2250)
109 sptMP2T, ///< MPEG 2 Transport stream (RFCs 1890, 2250)
110 sptH263, ///< ITU-T H.263 video (RFCs 2190, 2429)
111 // Types 35 - 71 are unassigned.
112 // Types 72 - 76 are reserved.
113 // Types 96 - 127 are dynamic.
114 lastStaticPayloadType = sptH263
115} StaticPayloadType;
Emeric Vigier2f625822012-08-06 11:09:52 -0400116
117/**
118 * @class PayloadFormat
119 * @short Base payload format class.
120 *
121 * The properties of a payload format that, as an RTP stack, ccRTP
122 * takes into account are the payload type (numeric identifier) and
123 * the RTP clock rate.
124 *
125 * This is a base class for both StaticPayloadFormat and
126 * DynamicPayloadFormat.
127 *
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500128 * @author Federico Montesino Pouzols <fedemp@altern.org>
Emeric Vigier2f625822012-08-06 11:09:52 -0400129 **/
130class __EXPORT PayloadFormat
131{
132public:
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500133 /**
134 * Get payload type numeric identifier carried in RTP packets.
135 *
136 * @return payload type numeric identifier.
137 **/
138 inline PayloadType getPayloadType() const
139 { return payloadType; }
Emeric Vigier2f625822012-08-06 11:09:52 -0400140
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500141 /**
142 * Get RTP clock rate for this payload format. Note this
143 * method provides the RTP clock rate (for the timestamp in
144 * RTP data packets headers), which is not necessarily the
145 * same as the codec clock rate.
146 *
147 * @return RTP clock rate in Hz.
148 **/
149 inline uint32 getRTPClockRate() const
150 { return RTPClockRate; }
151
Emeric Vigier2f625822012-08-06 11:09:52 -0400152protected:
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500153 /**
154 * PayloadFormat must not be used but as base class.
155 **/
156 PayloadFormat()
157 { }
Emeric Vigier2f625822012-08-06 11:09:52 -0400158
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500159 /**
160 * PayloadFormat must not be used but as base class.
161 **/
162 inline virtual ~PayloadFormat()
163 { }
Emeric Vigier2f625822012-08-06 11:09:52 -0400164
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500165 /**
166 * Set payload type numeric identifier carried in RTP packets.
167 *
168 * @param pt payload type number.
169 **/
170 inline void setPayloadType(PayloadType pt)
171 { payloadType = pt; }
Emeric Vigier2f625822012-08-06 11:09:52 -0400172
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500173 /**
174 * Set RTP clock rate.
175 *
176 * @param rate RTP clock rate in Hz.
177 **/
178 inline void setRTPClockRate(uint32 rate)
179 { RTPClockRate = rate; }
180
181 // default clock rate
182 static const uint32 defaultRTPClockRate;
Emeric Vigier2f625822012-08-06 11:09:52 -0400183
184private:
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500185 PayloadType payloadType; ///< Numeric identifier.
186 uint32 RTPClockRate; ///< Rate in Hz.
Emeric Vigier2f625822012-08-06 11:09:52 -0400187};
188
189/**
190 * @class StaticPayloadFormat
191 * @short Static payload format objects.
192 *
193 * Class of payload formats objects for payload types statically
194 * assigned. Because these payloads have an RTP clock rate assigned,
195 * it is not specified to the constructor. A call to
196 * StaticPayloadFormat(sptPCMU) will set the proper clock rate and any
197 * other parameters for that static payload type.
198 *
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500199 * @author Federico Montesino Pouzols <fedemp@altern.org>
200 **/
Emeric Vigier2f625822012-08-06 11:09:52 -0400201class __EXPORT StaticPayloadFormat : public PayloadFormat
202{
203public:
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500204 /**
205 * Constructor. Builds a payload format from a static payload
206 * binding identifier, assigning the numeric identifier and
207 * RTP clock rate statically bounded.
208 *
209 * @param type Numeric identifier in the range 0-96.
210 * @note some identifiers are reserved.
211 **/
212 StaticPayloadFormat(StaticPayloadType type);
213
Emeric Vigier2f625822012-08-06 11:09:52 -0400214private:
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500215 /**
216 * RTP clock rate for static payload types. There is no need
217 * for a table like this for video types, since they all have
218 * 90000 Khz rate.
219 **/
220 static uint32 staticAudioTypesRates[lastStaticAudioPayloadType -
221 firstStaticPayloadType + 1];
Emeric Vigier2f625822012-08-06 11:09:52 -0400222};
223
224/**
225 * @class DynamicPayloadFormat
226 * @short Dynamic payload format objects.
227 *
228 * Class of payload formats objects for payload types dynamically
229 * negotiated. Because these payloads do not have a fix RTP clock rate
230 * assigned, it must be specified to the constructor. This class will
231 * be used by applications that support dynamic payload negotiation.
232 *
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500233 * @author Federico Montesino Pouzols <fedemp@altern.org>
234 **/
Emeric Vigier2f625822012-08-06 11:09:52 -0400235class __EXPORT DynamicPayloadFormat : public PayloadFormat
236{
237public:
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500238 /**
239 * Constructor. Builds a dynamic payload format from payload
240 * numeric identifier and the corresponding RTP clock rate.
241 *
242 * @param type payload type numeric identifier.
243 * @param rate RTP clock rate.
244 **/
245 DynamicPayloadFormat(PayloadType type, uint32 rate);
Emeric Vigier2f625822012-08-06 11:09:52 -0400246};
247
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500248/** @}*/ // payload
Emeric Vigier2f625822012-08-06 11:09:52 -0400249
Alexandre Lisionddd731e2014-01-31 11:50:08 -0500250END_NAMESPACE
Emeric Vigier2f625822012-08-06 11:09:52 -0400251
252#endif // ndef CCXX_RTP_FORMATS_H_
253
254/** EMACS **
255 * Local variables:
256 * mode: c++
257 * c-basic-offset: 8
258 * End:
259 */