oRTP  0.16.3
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);
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 #define payload_type_get_bitrate(pt) ((pt)->normal_bitrate)
104 #define payload_type_get_rate(pt) ((pt)->clock_rate)
105 #define payload_type_get_mime(pt) ((pt)->mime_type)
106 
107 bool_t fmtp_get_value(const char *fmtp, const char *param_name, char *result, size_t result_len);
108 
109 VAR_DECLSPEC RtpProfile av_profile;
110 
111 #define payload_type_set_user_data(pt,p) (pt)->user_data=(p)
112 #define payload_type_get_user_data(pt) ((pt)->user_data)
113 
114 #define rtp_profile_get_name(profile) (const char*)((profile)->name)
115 
116 void rtp_profile_set_payload(RtpProfile *prof, int idx, PayloadType *pt);
117 
124 #define rtp_profile_clear_payload(profile,index) \
125  rtp_profile_set_payload(profile,index,NULL)
126 
127 /* I prefer have this function inlined because it is very often called in the code */
136 static inline PayloadType * rtp_profile_get_payload(RtpProfile *prof, int idx){
137  if (idx<0 || idx>=RTP_PROFILE_MAX_PAYLOADS) {
138  return NULL;
139  }
140  return prof->payload[idx];
141 }
143 void rtp_profile_set_name(RtpProfile *prof, const char *name);
144 PayloadType * rtp_profile_get_payload_from_mime(RtpProfile *profile,const char *mime);
145 PayloadType * rtp_profile_get_payload_from_rtpmap(RtpProfile *profile, const char *rtpmap);
146 int rtp_profile_get_payload_number_from_mime(RtpProfile *profile,const char *mime);
147 int rtp_profile_get_payload_number_from_rtpmap(RtpProfile *profile, const char *rtpmap);
148 int rtp_profile_find_payload_number(RtpProfile *prof,const char *mime,int rate, int channels);
149 PayloadType * rtp_profile_find_payload(RtpProfile *prof,const char *mime,int rate, int channels);
150 int rtp_profile_move_payload(RtpProfile *prof,int oldpos,int newpos);
151 
152 RtpProfile * rtp_profile_new(const char *name);
153 /* clone a profile, payload are not cloned */
154 RtpProfile * rtp_profile_clone(RtpProfile *prof);
155 
156 
157 /*clone a profile and its payloads (ie payload type are newly allocated, not reusing payload types of the reference profile) */
158 RtpProfile * rtp_profile_clone_full(RtpProfile *prof);
159 /* frees the profile and all its PayloadTypes*/
160 void rtp_profile_destroy(RtpProfile *prof);
161 
162 
163 /* some payload types */
164 /* audio */
165 VAR_DECLSPEC PayloadType payload_type_pcmu8000;
166 VAR_DECLSPEC PayloadType payload_type_pcma8000;
167 VAR_DECLSPEC PayloadType payload_type_pcm8000;
168 VAR_DECLSPEC PayloadType payload_type_l16_mono;
169 VAR_DECLSPEC PayloadType payload_type_l16_stereo;
170 VAR_DECLSPEC PayloadType payload_type_lpc1016;
171 VAR_DECLSPEC PayloadType payload_type_g729;
172 VAR_DECLSPEC PayloadType payload_type_g7231;
173 VAR_DECLSPEC PayloadType payload_type_g7221;
174 VAR_DECLSPEC PayloadType payload_type_g726_40;
175 VAR_DECLSPEC PayloadType payload_type_g726_32;
176 VAR_DECLSPEC PayloadType payload_type_g726_24;
177 VAR_DECLSPEC PayloadType payload_type_g726_16;
178 VAR_DECLSPEC PayloadType payload_type_gsm;
179 VAR_DECLSPEC PayloadType payload_type_lpc;
180 VAR_DECLSPEC PayloadType payload_type_lpc1015;
181 VAR_DECLSPEC PayloadType payload_type_speex_nb;
182 VAR_DECLSPEC PayloadType payload_type_speex_wb;
183 VAR_DECLSPEC PayloadType payload_type_speex_uwb;
184 VAR_DECLSPEC PayloadType payload_type_ilbc;
185 VAR_DECLSPEC PayloadType payload_type_amr;
186 VAR_DECLSPEC PayloadType payload_type_amrwb;
187 VAR_DECLSPEC PayloadType payload_type_truespeech;
188 VAR_DECLSPEC PayloadType payload_type_evrc0;
189 VAR_DECLSPEC PayloadType payload_type_evrcb0;
190 
191 /* video */
192 VAR_DECLSPEC PayloadType payload_type_mpv;
193 VAR_DECLSPEC PayloadType payload_type_h261;
194 VAR_DECLSPEC PayloadType payload_type_h263;
195 VAR_DECLSPEC PayloadType payload_type_h263_1998;
196 VAR_DECLSPEC PayloadType payload_type_h263_2000;
197 VAR_DECLSPEC PayloadType payload_type_mp4v;
198 VAR_DECLSPEC PayloadType payload_type_theora;
199 VAR_DECLSPEC PayloadType payload_type_h264;
200 VAR_DECLSPEC PayloadType payload_type_x_snow;
201 VAR_DECLSPEC PayloadType payload_type_jpeg;
202 
203 VAR_DECLSPEC PayloadType payload_type_t140;
204 
205 /* non standard file transfer over UDP */
206 VAR_DECLSPEC PayloadType payload_type_x_udpftp;
207 
208 /* telephone-event */
209 VAR_DECLSPEC PayloadType payload_type_telephone_event;
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 
215 #endif
void payload_type_set_send_fmtp(PayloadType *pt, const char *fmtp)
Definition: payloadtype.c:85
Definition: payloadtype.h:52
bool_t fmtp_get_value(const char *fmtp, const char *param_name, char *result, size_t result_len)
Definition: payloadtype.c:142
void rtp_profile_set_payload(RtpProfile *prof, int idx, PayloadType *pt)
Definition: payloadtype.c:285
void rtp_profile_set_name(RtpProfile *prof, const char *name)
Definition: payloadtype.c:312
int clock_rate
Definition: payloadtype.h:55
void rtp_profile_clear_all(RtpProfile *prof)
Definition: payloadtype.c:298
char * mime_type
Definition: payloadtype.h:61
int channels
Definition: payloadtype.h:62
void payload_type_set_recv_fmtp(PayloadType *pt, const char *fmtp)
Definition: payloadtype.c:72
int type
Definition: payloadtype.h:54
Definition: payloadtype.h:85
void payload_type_destroy(PayloadType *pt)
Definition: payloadtype.c:123