oRTP 0.16.3
|
00001 /* 00002 The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack. 00003 Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 */ 00019 00026 #ifndef PAYLOADTYPE_H 00027 #define PAYLOADTYPE_H 00028 #include <ortp/port.h> 00029 00030 #ifdef __cplusplus 00031 extern "C"{ 00032 #endif 00033 00034 /* flags for PayloadType::flags */ 00035 00036 #define PAYLOAD_TYPE_ALLOCATED (1) 00037 /* private flags for future use by ortp */ 00038 #define PAYLOAD_TYPE_PRIV1 (1<<1) 00039 #define PAYLOAD_TYPE_PRIV2 (1<<2) 00040 #define PAYLOAD_TYPE_PRIV3 (1<<3) 00041 /* user flags, can be used by the application on top of oRTP */ 00042 #define PAYLOAD_TYPE_USER_FLAG_0 (1<<4) 00043 #define PAYLOAD_TYPE_USER_FLAG_1 (1<<5) 00044 #define PAYLOAD_TYPE_USER_FLAG_2 (1<<6) 00045 /* ask for more if you need*/ 00046 00047 #define PAYLOAD_AUDIO_CONTINUOUS 0 00048 #define PAYLOAD_AUDIO_PACKETIZED 1 00049 #define PAYLOAD_VIDEO 2 00050 #define PAYLOAD_OTHER 3 /* ?? */ 00051 00052 struct _PayloadType 00053 { 00054 int type; 00055 int clock_rate; 00056 char bits_per_sample; /* in case of continuous audio data */ 00057 char *zero_pattern; 00058 int pattern_length; 00059 /* other useful information for the application*/ 00060 int normal_bitrate; /*in bit/s */ 00061 char *mime_type; 00062 int channels; 00063 char *recv_fmtp; /* various format parameters for the incoming stream */ 00064 char *send_fmtp; /* various format parameters for the outgoing stream */ 00065 int flags; 00066 void *user_data; 00067 }; 00068 00069 #ifndef PayloadType_defined 00070 #define PayloadType_defined 00071 typedef struct _PayloadType PayloadType; 00072 #endif 00073 00074 #define payload_type_set_flag(pt,flag) (pt)->flags|=((int)flag) 00075 #define payload_type_unset_flag(pt,flag) (pt)->flags&=(~(int)flag) 00076 #define payload_type_get_flags(pt) (pt)->flags 00077 00078 #define RTP_PROFILE_MAX_PAYLOADS 128 00079 00085 struct _RtpProfile 00086 { 00087 char *name; 00088 PayloadType *payload[RTP_PROFILE_MAX_PAYLOADS]; 00089 }; 00090 00091 00092 typedef struct _RtpProfile RtpProfile; 00093 00094 PayloadType *payload_type_new(void); 00095 PayloadType *payload_type_clone(PayloadType *payload); 00096 char *payload_type_get_rtpmap(PayloadType *pt); 00097 void payload_type_destroy(PayloadType *pt); 00098 void payload_type_set_recv_fmtp(PayloadType *pt, const char *fmtp); 00099 void payload_type_set_send_fmtp(PayloadType *pt, const char *fmtp); 00100 void payload_type_append_recv_fmtp(PayloadType *pt, const char *fmtp); 00101 void payload_type_append_send_fmtp(PayloadType *pt, const char *fmtp); 00102 00103 #define payload_type_get_bitrate(pt) ((pt)->normal_bitrate) 00104 #define payload_type_get_rate(pt) ((pt)->clock_rate) 00105 #define payload_type_get_mime(pt) ((pt)->mime_type) 00106 00107 bool_t fmtp_get_value(const char *fmtp, const char *param_name, char *result, size_t result_len); 00108 00109 VAR_DECLSPEC RtpProfile av_profile; 00110 00111 #define payload_type_set_user_data(pt,p) (pt)->user_data=(p) 00112 #define payload_type_get_user_data(pt) ((pt)->user_data) 00113 00114 #define rtp_profile_get_name(profile) (const char*)((profile)->name) 00115 00116 void rtp_profile_set_payload(RtpProfile *prof, int idx, PayloadType *pt); 00117 00124 #define rtp_profile_clear_payload(profile,index) \ 00125 rtp_profile_set_payload(profile,index,NULL) 00126 00127 /* I prefer have this function inlined because it is very often called in the code */ 00136 static inline PayloadType * rtp_profile_get_payload(RtpProfile *prof, int idx){ 00137 if (idx<0 || idx>=RTP_PROFILE_MAX_PAYLOADS) { 00138 return NULL; 00139 } 00140 return prof->payload[idx]; 00141 } 00142 void rtp_profile_clear_all(RtpProfile *prof); 00143 void rtp_profile_set_name(RtpProfile *prof, const char *name); 00144 PayloadType * rtp_profile_get_payload_from_mime(RtpProfile *profile,const char *mime); 00145 PayloadType * rtp_profile_get_payload_from_rtpmap(RtpProfile *profile, const char *rtpmap); 00146 int rtp_profile_get_payload_number_from_mime(RtpProfile *profile,const char *mime); 00147 int rtp_profile_get_payload_number_from_rtpmap(RtpProfile *profile, const char *rtpmap); 00148 int rtp_profile_find_payload_number(RtpProfile *prof,const char *mime,int rate, int channels); 00149 PayloadType * rtp_profile_find_payload(RtpProfile *prof,const char *mime,int rate, int channels); 00150 int rtp_profile_move_payload(RtpProfile *prof,int oldpos,int newpos); 00151 00152 RtpProfile * rtp_profile_new(const char *name); 00153 /* clone a profile, payload are not cloned */ 00154 RtpProfile * rtp_profile_clone(RtpProfile *prof); 00155 00156 00157 /*clone a profile and its payloads (ie payload type are newly allocated, not reusing payload types of the reference profile) */ 00158 RtpProfile * rtp_profile_clone_full(RtpProfile *prof); 00159 /* frees the profile and all its PayloadTypes*/ 00160 void rtp_profile_destroy(RtpProfile *prof); 00161 00162 00163 /* some payload types */ 00164 /* audio */ 00165 VAR_DECLSPEC PayloadType payload_type_pcmu8000; 00166 VAR_DECLSPEC PayloadType payload_type_pcma8000; 00167 VAR_DECLSPEC PayloadType payload_type_pcm8000; 00168 VAR_DECLSPEC PayloadType payload_type_l16_mono; 00169 VAR_DECLSPEC PayloadType payload_type_l16_stereo; 00170 VAR_DECLSPEC PayloadType payload_type_lpc1016; 00171 VAR_DECLSPEC PayloadType payload_type_g729; 00172 VAR_DECLSPEC PayloadType payload_type_g7231; 00173 VAR_DECLSPEC PayloadType payload_type_g7221; 00174 VAR_DECLSPEC PayloadType payload_type_g726_40; 00175 VAR_DECLSPEC PayloadType payload_type_g726_32; 00176 VAR_DECLSPEC PayloadType payload_type_g726_24; 00177 VAR_DECLSPEC PayloadType payload_type_g726_16; 00178 VAR_DECLSPEC PayloadType payload_type_gsm; 00179 VAR_DECLSPEC PayloadType payload_type_lpc; 00180 VAR_DECLSPEC PayloadType payload_type_lpc1015; 00181 VAR_DECLSPEC PayloadType payload_type_speex_nb; 00182 VAR_DECLSPEC PayloadType payload_type_speex_wb; 00183 VAR_DECLSPEC PayloadType payload_type_speex_uwb; 00184 VAR_DECLSPEC PayloadType payload_type_ilbc; 00185 VAR_DECLSPEC PayloadType payload_type_amr; 00186 VAR_DECLSPEC PayloadType payload_type_amrwb; 00187 VAR_DECLSPEC PayloadType payload_type_truespeech; 00188 VAR_DECLSPEC PayloadType payload_type_evrc0; 00189 VAR_DECLSPEC PayloadType payload_type_evrcb0; 00190 00191 /* video */ 00192 VAR_DECLSPEC PayloadType payload_type_mpv; 00193 VAR_DECLSPEC PayloadType payload_type_h261; 00194 VAR_DECLSPEC PayloadType payload_type_h263; 00195 VAR_DECLSPEC PayloadType payload_type_h263_1998; 00196 VAR_DECLSPEC PayloadType payload_type_h263_2000; 00197 VAR_DECLSPEC PayloadType payload_type_mp4v; 00198 VAR_DECLSPEC PayloadType payload_type_theora; 00199 VAR_DECLSPEC PayloadType payload_type_h264; 00200 VAR_DECLSPEC PayloadType payload_type_x_snow; 00201 VAR_DECLSPEC PayloadType payload_type_jpeg; 00202 00203 VAR_DECLSPEC PayloadType payload_type_t140; 00204 00205 /* non standard file transfer over UDP */ 00206 VAR_DECLSPEC PayloadType payload_type_x_udpftp; 00207 00208 /* telephone-event */ 00209 VAR_DECLSPEC PayloadType payload_type_telephone_event; 00210 00211 #ifdef __cplusplus 00212 } 00213 #endif 00214 00215 #endif