oRTP  0.16.1
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 
53 {
54  int type;
55  int clock_rate;
56  char bits_per_sample; /* in case of continuous audio data */
57  char *zero_pattern;
58  int pattern_length;
59  /* other useful information for the application*/
60  int normal_bitrate; /*in bit/s */
61  char *mime_type;
62  int channels;
63  char *recv_fmtp; /* various format parameters for the incoming stream */
64  char *send_fmtp; /* various format parameters for the outgoing stream */
65  int flags;
66  void *user_data;
67 };
68 
69 #ifndef PayloadType_defined
70 #define PayloadType_defined
71 typedef struct _PayloadType PayloadType;
72 #endif
73 
74 #define payload_type_set_flag(pt,flag) (pt)->flags|=((int)flag)
75 #define payload_type_unset_flag(pt,flag) (pt)->flags&=(~(int)flag)
76 #define payload_type_get_flags(pt) (pt)->flags
77 
78 #define RTP_PROFILE_MAX_PAYLOADS 128
79 
86 {
87  char *name;
88  PayloadType *payload[RTP_PROFILE_MAX_PAYLOADS];
89 };
90 
91 
92 typedef struct _RtpProfile RtpProfile;
93 
94 PayloadType *payload_type_new(void);
95 PayloadType *payload_type_clone(PayloadType *payload);
96 char *payload_type_get_rtpmap(PayloadType *pt);
97 void payload_type_destroy(PayloadType *pt);
98 void payload_type_set_recv_fmtp(PayloadType *pt, const char *fmtp);
99 void payload_type_set_send_fmtp(PayloadType *pt, const char *fmtp);
100 void payload_type_append_recv_fmtp(PayloadType *pt, const char *fmtp);
101 void payload_type_append_send_fmtp(PayloadType *pt, const char *fmtp);
102 
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) \
122  rtp_profile_set_payload(profile,index,NULL)
123 
124 /* I prefer have this function inlined because it is very often called in the code */
133 static inline PayloadType * rtp_profile_get_payload(RtpProfile *prof, int idx){
134  if (idx<0 || idx>=RTP_PROFILE_MAX_PAYLOADS) {
135  return NULL;
136  }
137  return prof->payload[idx];
138 }
139 void rtp_profile_clear_all(RtpProfile *prof);
140 void rtp_profile_set_name(RtpProfile *prof, const char *name);
141 PayloadType * rtp_profile_get_payload_from_mime(RtpProfile *profile,const char *mime);
142 PayloadType * rtp_profile_get_payload_from_rtpmap(RtpProfile *profile, const char *rtpmap);
143 int rtp_profile_get_payload_number_from_mime(RtpProfile *profile,const char *mime);
144 int rtp_profile_get_payload_number_from_rtpmap(RtpProfile *profile, const char *rtpmap);
145 int rtp_profile_find_payload_number(RtpProfile *prof,const char *mime,int rate, int channels);
146 PayloadType * rtp_profile_find_payload(RtpProfile *prof,const char *mime,int rate, int channels);
147 int rtp_profile_move_payload(RtpProfile *prof,int oldpos,int newpos);
148 
149 RtpProfile * rtp_profile_new(const char *name);
150 /* clone a profile, payload are not cloned */
151 RtpProfile * rtp_profile_clone(RtpProfile *prof);
152 
153 
154 /*clone a profile and its payloads (ie payload type are newly allocated, not reusing payload types of the reference profile) */
155 RtpProfile * rtp_profile_clone_full(RtpProfile *prof);
156 /* frees the profile and all its PayloadTypes*/
157 void rtp_profile_destroy(RtpProfile *prof);
158 
159 
160 /* some payload types */
161 /* audio */
162 VAR_DECLSPEC PayloadType payload_type_pcmu8000;
163 VAR_DECLSPEC PayloadType payload_type_pcma8000;
164 VAR_DECLSPEC PayloadType payload_type_pcm8000;
165 VAR_DECLSPEC PayloadType payload_type_l16_mono;
166 VAR_DECLSPEC PayloadType payload_type_l16_stereo;
167 VAR_DECLSPEC PayloadType payload_type_lpc1016;
168 VAR_DECLSPEC PayloadType payload_type_g729;
169 VAR_DECLSPEC PayloadType payload_type_g7231;
170 VAR_DECLSPEC PayloadType payload_type_g7221;
171 VAR_DECLSPEC PayloadType payload_type_g726_40;
172 VAR_DECLSPEC PayloadType payload_type_g726_32;
173 VAR_DECLSPEC PayloadType payload_type_g726_24;
174 VAR_DECLSPEC PayloadType payload_type_g726_16;
175 VAR_DECLSPEC PayloadType payload_type_gsm;
176 VAR_DECLSPEC PayloadType payload_type_lpc;
177 VAR_DECLSPEC PayloadType payload_type_lpc1015;
178 VAR_DECLSPEC PayloadType payload_type_speex_nb;
179 VAR_DECLSPEC PayloadType payload_type_speex_wb;
180 VAR_DECLSPEC PayloadType payload_type_speex_uwb;
181 VAR_DECLSPEC PayloadType payload_type_ilbc;
182 VAR_DECLSPEC PayloadType payload_type_amr;
183 VAR_DECLSPEC PayloadType payload_type_amrwb;
184 VAR_DECLSPEC PayloadType payload_type_truespeech;
185 VAR_DECLSPEC PayloadType payload_type_evrc0;
186 VAR_DECLSPEC PayloadType payload_type_evrcb0;
187 
188 /* video */
189 VAR_DECLSPEC PayloadType payload_type_mpv;
190 VAR_DECLSPEC PayloadType payload_type_h261;
191 VAR_DECLSPEC PayloadType payload_type_h263;
192 VAR_DECLSPEC PayloadType payload_type_h263_1998;
193 VAR_DECLSPEC PayloadType payload_type_h263_2000;
194 VAR_DECLSPEC PayloadType payload_type_mp4v;
195 VAR_DECLSPEC PayloadType payload_type_theora;
196 VAR_DECLSPEC PayloadType payload_type_h264;
197 VAR_DECLSPEC PayloadType payload_type_x_snow;
198 VAR_DECLSPEC PayloadType payload_type_t140;
199 
200 /* non standard file transfer over UDP */
201 VAR_DECLSPEC PayloadType payload_type_x_udpftp;
202 
203 /* telephone-event */
204 VAR_DECLSPEC PayloadType payload_type_telephone_event;
205 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif