oRTP  0.20.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_TEXT 4
51 #define PAYLOAD_OTHER 3 /* ?? */
52 
54 {
55  int type;
56  int clock_rate;
57  char bits_per_sample; /* in case of continuous audio data */
58  char *zero_pattern;
59  int pattern_length;
60  /* other useful information for the application*/
61  int normal_bitrate; /*in bit/s */
62  char *mime_type;
63  int channels;
64  char *recv_fmtp; /* various format parameters for the incoming stream */
65  char *send_fmtp; /* various format parameters for the outgoing stream */
66  int flags;
67  void *user_data;
68 };
69 
70 #ifndef PayloadType_defined
71 #define PayloadType_defined
72 typedef struct _PayloadType PayloadType;
73 #endif
74 
75 #define payload_type_set_flag(pt,flag) (pt)->flags|=((int)flag)
76 #define payload_type_unset_flag(pt,flag) (pt)->flags&=(~(int)flag)
77 #define payload_type_get_flags(pt) (pt)->flags
78 
79 #define RTP_PROFILE_MAX_PAYLOADS 128
80 
87 {
88  char *name;
89  PayloadType *payload[RTP_PROFILE_MAX_PAYLOADS];
90 };
91 
92 
93 typedef struct _RtpProfile RtpProfile;
94 
95 PayloadType *payload_type_new(void);
96 PayloadType *payload_type_clone(PayloadType *payload);
97 char *payload_type_get_rtpmap(PayloadType *pt);
98 void payload_type_destroy(PayloadType *pt);
99 void payload_type_set_recv_fmtp(PayloadType *pt, const char *fmtp);
100 void payload_type_set_send_fmtp(PayloadType *pt, const char *fmtp);
101 void payload_type_append_recv_fmtp(PayloadType *pt, const char *fmtp);
102 void payload_type_append_send_fmtp(PayloadType *pt, const char *fmtp);
103 
104 #define payload_type_get_bitrate(pt) ((pt)->normal_bitrate)
105 #define payload_type_get_rate(pt) ((pt)->clock_rate)
106 #define payload_type_get_mime(pt) ((pt)->mime_type)
107 
108 bool_t fmtp_get_value(const char *fmtp, const char *param_name, char *result, size_t result_len);
109 
110 VAR_DECLSPEC RtpProfile av_profile;
111 
112 #define payload_type_set_user_data(pt,p) (pt)->user_data=(p)
113 #define payload_type_get_user_data(pt) ((pt)->user_data)
114 
115 #define rtp_profile_get_name(profile) (const char*)((profile)->name)
116 
117 void rtp_profile_set_payload(RtpProfile *prof, int idx, PayloadType *pt);
118 
125 #define rtp_profile_clear_payload(profile,index) \
126  rtp_profile_set_payload(profile,index,NULL)
127 
128 /* I prefer have this function inlined because it is very often called in the code */
137 static inline PayloadType * rtp_profile_get_payload(RtpProfile *prof, int idx){
138  if (idx<0 || idx>=RTP_PROFILE_MAX_PAYLOADS) {
139  return NULL;
140  }
141  return prof->payload[idx];
142 }
143 void rtp_profile_clear_all(RtpProfile *prof);
144 void rtp_profile_set_name(RtpProfile *prof, const char *name);
145 PayloadType * rtp_profile_get_payload_from_mime(RtpProfile *profile,const char *mime);
146 PayloadType * rtp_profile_get_payload_from_rtpmap(RtpProfile *profile, const char *rtpmap);
147 int rtp_profile_get_payload_number_from_mime(RtpProfile *profile,const char *mime);
148 int rtp_profile_get_payload_number_from_rtpmap(RtpProfile *profile, const char *rtpmap);
149 int rtp_profile_find_payload_number(RtpProfile *prof,const char *mime,int rate, int channels);
150 PayloadType * rtp_profile_find_payload(RtpProfile *prof,const char *mime,int rate, int channels);
151 int rtp_profile_move_payload(RtpProfile *prof,int oldpos,int newpos);
152 
153 RtpProfile * rtp_profile_new(const char *name);
154 /* clone a profile, payload are not cloned */
155 RtpProfile * rtp_profile_clone(RtpProfile *prof);
156 
157 
158 /*clone a profile and its payloads (ie payload type are newly allocated, not reusing payload types of the reference profile) */
159 RtpProfile * rtp_profile_clone_full(RtpProfile *prof);
160 /* frees the profile and all its PayloadTypes*/
161 void rtp_profile_destroy(RtpProfile *prof);
162 
163 
164 /* some payload types */
165 /* audio */
166 VAR_DECLSPEC PayloadType payload_type_pcmu8000;
167 VAR_DECLSPEC PayloadType payload_type_pcma8000;
168 VAR_DECLSPEC PayloadType payload_type_pcm8000;
169 VAR_DECLSPEC PayloadType payload_type_l16_mono;
170 VAR_DECLSPEC PayloadType payload_type_l16_stereo;
171 VAR_DECLSPEC PayloadType payload_type_lpc1016;
172 VAR_DECLSPEC PayloadType payload_type_g729;
173 VAR_DECLSPEC PayloadType payload_type_g7231;
174 VAR_DECLSPEC PayloadType payload_type_g7221;
175 VAR_DECLSPEC PayloadType payload_type_g726_40;
176 VAR_DECLSPEC PayloadType payload_type_g726_32;
177 VAR_DECLSPEC PayloadType payload_type_g726_24;
178 VAR_DECLSPEC PayloadType payload_type_g726_16;
179 VAR_DECLSPEC PayloadType payload_type_aal2_g726_40;
180 VAR_DECLSPEC PayloadType payload_type_aal2_g726_32;
181 VAR_DECLSPEC PayloadType payload_type_aal2_g726_24;
182 VAR_DECLSPEC PayloadType payload_type_aal2_g726_16;
183 VAR_DECLSPEC PayloadType payload_type_gsm;
184 VAR_DECLSPEC PayloadType payload_type_lpc;
185 VAR_DECLSPEC PayloadType payload_type_lpc1015;
186 VAR_DECLSPEC PayloadType payload_type_speex_nb;
187 VAR_DECLSPEC PayloadType payload_type_speex_wb;
188 VAR_DECLSPEC PayloadType payload_type_speex_uwb;
189 VAR_DECLSPEC PayloadType payload_type_ilbc;
190 VAR_DECLSPEC PayloadType payload_type_amr;
191 VAR_DECLSPEC PayloadType payload_type_amrwb;
192 VAR_DECLSPEC PayloadType payload_type_truespeech;
193 VAR_DECLSPEC PayloadType payload_type_evrc0;
194 VAR_DECLSPEC PayloadType payload_type_evrcb0;
195 VAR_DECLSPEC PayloadType payload_type_silk_nb;
196 VAR_DECLSPEC PayloadType payload_type_silk_mb;
197 VAR_DECLSPEC PayloadType payload_type_silk_wb;
198 VAR_DECLSPEC PayloadType payload_type_silk_swb;
199 
200  /* video */
201 VAR_DECLSPEC PayloadType payload_type_mpv;
202 VAR_DECLSPEC PayloadType payload_type_h261;
203 VAR_DECLSPEC PayloadType payload_type_h263;
204 VAR_DECLSPEC PayloadType payload_type_h263_1998;
205 VAR_DECLSPEC PayloadType payload_type_h263_2000;
206 VAR_DECLSPEC PayloadType payload_type_mp4v;
207 VAR_DECLSPEC PayloadType payload_type_theora;
208 VAR_DECLSPEC PayloadType payload_type_h264;
209 VAR_DECLSPEC PayloadType payload_type_x_snow;
210 VAR_DECLSPEC PayloadType payload_type_jpeg;
211 VAR_DECLSPEC PayloadType payload_type_vp8;
212 
213 VAR_DECLSPEC PayloadType payload_type_g722;
214 
215 /* text */
216 VAR_DECLSPEC PayloadType payload_type_t140;
217 VAR_DECLSPEC PayloadType payload_type_t140_red;
218 
219 /* non standard file transfer over UDP */
220 VAR_DECLSPEC PayloadType payload_type_x_udpftp;
221 
222 /* telephone-event */
223 VAR_DECLSPEC PayloadType payload_type_telephone_event;
224 
225 #ifdef __cplusplus
226 }
227 #endif
228 
229 #endif