a-oRTP  5.2.0
payloadtype.h
Go to the documentation of this file.
1 /*
2  The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
3  Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 
26 #ifndef PAYLOADTYPE_H
27 #define PAYLOADTYPE_H
28 #include <ortp/port.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /* flags for PayloadType::flags */
35 
36 #define PAYLOAD_TYPE_ALLOCATED (1)
37 /* private flags for future use by ortp */
38 #define PAYLOAD_TYPE_PRIV1 (1 << 1)
39 #define PAYLOAD_TYPE_PRIV2 (1 << 2)
40 #define PAYLOAD_TYPE_PRIV3 (1 << 3)
41 /* user flags, can be used by the application on top of oRTP */
42 #define PAYLOAD_TYPE_USER_FLAG_0 (1 << 4)
43 #define PAYLOAD_TYPE_USER_FLAG_1 (1 << 5)
44 #define PAYLOAD_TYPE_USER_FLAG_2 (1 << 6)
45 /* ask for more if you need*/
46 
47 #define PAYLOAD_AUDIO_CONTINUOUS 0
48 #define PAYLOAD_AUDIO_PACKETIZED 1
49 #define PAYLOAD_VIDEO 2
50 #define PAYLOAD_OTHER 3 /* ?? */
51 
52 struct _PayloadType {
53  int type;
54  int clock_rate;
55  char bits_per_sample; /* in case of continuous audio data */
56  char *zero_pattern;
57  int pattern_length;
58  /* other useful information for the application*/
59  int normal_bitrate; /*in bit/s */
60  char *mime_type;
61  int channels;
62  char *recv_fmtp; /* various format parameters for the incoming stream */
63  char *send_fmtp; /* various format parameters for the outgoing stream */
64  int flags;
65  void *user_data;
66 };
67 
68 #ifndef PayloadType_defined
69 #define PayloadType_defined
70 typedef struct _PayloadType PayloadType;
71 #endif
72 
73 #define payload_type_set_flag(pt, flag) (pt)->flags |= ((int) flag)
74 #define payload_type_unset_flag(pt, flag) (pt)->flags &= (~(int) flag)
75 #define payload_type_get_flags(pt) (pt)->flags
76 
77 #define RTP_PROFILE_MAX_PAYLOADS 128
78 
84 struct _RtpProfile {
85  char *name;
86  PayloadType *payload[RTP_PROFILE_MAX_PAYLOADS];
87 };
88 
89 typedef struct _RtpProfile RtpProfile;
90 
91 PayloadType *payload_type_new(void);
92 PayloadType *payload_type_clone(PayloadType *payload);
93 char *payload_type_get_rtpmap(PayloadType *pt);
94 void payload_type_destroy(PayloadType *pt);
95 void payload_type_set_recv_fmtp(PayloadType *pt, const char *fmtp);
96 void payload_type_set_send_fmtp(PayloadType *pt, const char *fmtp);
97 void payload_type_append_recv_fmtp(PayloadType *pt, const char *fmtp);
98 void payload_type_append_send_fmtp(PayloadType *pt, const char *fmtp);
99 
100 #define payload_type_get_bitrate(pt) ((pt)->normal_bitrate)
101 #define payload_type_get_rate(pt) ((pt)->clock_rate)
102 #define payload_type_get_mime(pt) ((pt)->mime_type)
103 
104 bool_t fmtp_get_value(const char *fmtp, const char *param_name, char *result, size_t result_len);
105 
106 VAR_DECLSPEC RtpProfile av_profile;
107 
108 #define payload_type_set_user_data(pt, p) (pt)->user_data = (p)
109 #define payload_type_get_user_data(pt) ((pt)->user_data)
110 
111 #define rtp_profile_get_name(profile) (const char *) ((profile)->name)
112 
113 void rtp_profile_set_payload(RtpProfile *prof, int idx, PayloadType *pt);
114 
121 #define rtp_profile_clear_payload(profile, index) rtp_profile_set_payload(profile, index, NULL)
122 
123 /* I prefer have this function inlined because it is very often called in the code */
132 static inline PayloadType *rtp_profile_get_payload(RtpProfile *prof, int idx) {
133  if (idx < 0 || idx >= RTP_PROFILE_MAX_PAYLOADS) {
134  return NULL;
135  }
136  return prof->payload[idx];
137 }
138 void rtp_profile_clear_all(RtpProfile *prof);
139 void rtp_profile_set_name(RtpProfile *prof, const char *name);
140 PayloadType *rtp_profile_get_payload_from_mime(RtpProfile *profile, const char *mime);
141 PayloadType *rtp_profile_get_payload_from_rtpmap(RtpProfile *profile, const char *rtpmap);
142 int rtp_profile_get_payload_number_from_mime(RtpProfile *profile, const char *mime);
143 int rtp_profile_get_payload_number_from_rtpmap(RtpProfile *profile, const char *rtpmap);
144 int rtp_profile_find_payload_number(RtpProfile *prof, const char *mime, int rate, int channels);
145 PayloadType *rtp_profile_find_payload(RtpProfile *prof, const char *mime, int rate, int channels);
146 int rtp_profile_move_payload(RtpProfile *prof, int oldpos, int newpos);
147 
148 RtpProfile *rtp_profile_new(const char *name);
149 /* clone a profile, payload are not cloned */
150 RtpProfile *rtp_profile_clone(RtpProfile *prof);
151 
152 /*clone a profile and its payloads (ie payload type are newly allocated, not reusing payload types of the reference profile) */
153 RtpProfile *rtp_profile_clone_full(RtpProfile *prof);
154 /* frees the profile and all its PayloadTypes*/
155 void rtp_profile_destroy(RtpProfile *prof);
156 
157 /* some payload types */
158 /* audio */
159 VAR_DECLSPEC PayloadType payload_type_pcmu8000;
160 VAR_DECLSPEC PayloadType payload_type_pcma8000;
161 VAR_DECLSPEC PayloadType payload_type_pcm8000;
162 VAR_DECLSPEC PayloadType payload_type_l16_mono;
163 VAR_DECLSPEC PayloadType payload_type_l16_stereo;
164 VAR_DECLSPEC PayloadType payload_type_lpc1016;
165 VAR_DECLSPEC PayloadType payload_type_g729;
166 VAR_DECLSPEC PayloadType payload_type_g729d;
167 VAR_DECLSPEC PayloadType payload_type_g729e;
168 VAR_DECLSPEC PayloadType payload_type_g728;
169 VAR_DECLSPEC PayloadType payload_type_g7291;
170 VAR_DECLSPEC PayloadType payload_type_g7231;
171 VAR_DECLSPEC PayloadType payload_type_g7221;
172 VAR_DECLSPEC PayloadType payload_type_g722;
173 VAR_DECLSPEC PayloadType payload_type_g726_40;
174 VAR_DECLSPEC PayloadType payload_type_g726_32;
175 VAR_DECLSPEC PayloadType payload_type_g726_24;
176 VAR_DECLSPEC PayloadType payload_type_g726_16;
177 VAR_DECLSPEC PayloadType payload_type_gsm;
178 VAR_DECLSPEC PayloadType payload_type_lpc;
179 VAR_DECLSPEC PayloadType payload_type_lpc1015;
180 VAR_DECLSPEC PayloadType payload_type_speex_nb;
181 VAR_DECLSPEC PayloadType payload_type_speex_wb;
182 VAR_DECLSPEC PayloadType payload_type_speex_uwb;
183 VAR_DECLSPEC PayloadType payload_type_ilbc;
184 VAR_DECLSPEC PayloadType payload_type_isac_wb;
185 VAR_DECLSPEC PayloadType payload_type_opus;
186 VAR_DECLSPEC PayloadType payload_type_amr;
187 VAR_DECLSPEC PayloadType payload_type_amrwb;
188 VAR_DECLSPEC PayloadType payload_type_aaceld_16k;
189 VAR_DECLSPEC PayloadType payload_type_aaceld_32k;
190 VAR_DECLSPEC PayloadType payload_type_truespeech;
191 VAR_DECLSPEC PayloadType payload_type_evrc0;
192 VAR_DECLSPEC PayloadType payload_type_evrcb0;
193 VAR_DECLSPEC PayloadType payload_type_silk_nb;
194 VAR_DECLSPEC PayloadType payload_type_silk_mb;
195 VAR_DECLSPEC PayloadType payload_type_silk_wb;
196 VAR_DECLSPEC PayloadType payload_type_silk_swb;
197 
198 /* video */
199 VAR_DECLSPEC PayloadType payload_type_mpv;
200 VAR_DECLSPEC PayloadType payload_type_h261;
201 VAR_DECLSPEC PayloadType payload_type_h263;
202 VAR_DECLSPEC PayloadType payload_type_h263_1998;
203 VAR_DECLSPEC PayloadType payload_type_h263_2000;
204 VAR_DECLSPEC PayloadType payload_type_mp4v;
205 VAR_DECLSPEC PayloadType payload_type_theora;
206 VAR_DECLSPEC PayloadType payload_type_h264;
207 VAR_DECLSPEC PayloadType payload_type_x_snow;
208 VAR_DECLSPEC PayloadType payload_type_x_ffv1;
209 VAR_DECLSPEC PayloadType payload_type_vp8;
210 VAR_DECLSPEC PayloadType payload_type_vp8multi;
211 VAR_DECLSPEC PayloadType payload_type_vp8low;
212 VAR_DECLSPEC PayloadType payload_type_xvp9;
213 VAR_DECLSPEC PayloadType payload_type_vp9;
214 VAR_DECLSPEC PayloadType payload_type_jpeg;
215 
216 VAR_DECLSPEC PayloadType payload_type_t140;
217 
218 /* non standard file transfer over UDP */
219 VAR_DECLSPEC PayloadType payload_type_x_udpftp;
220 VAR_DECLSPEC PayloadType payload_type_x_dataevents;
221 
222 /* telephone-event */
223 VAR_DECLSPEC PayloadType payload_type_telephone_event;
224 
225 #ifdef __cplusplus
226 }
227 #endif
228 
229 #endif
Definition: payloadtype.h:52
int clock_rate
Definition: payloadtype.h:54
int channels
Definition: payloadtype.h:61
int type
Definition: payloadtype.h:53
char * mime_type
Definition: payloadtype.h:60
Definition: payloadtype.h:84