oRTP  0.18.0
include/ortp/payloadtype.h
Go to the documentation of this file.
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_TEXT 4
00051 #define PAYLOAD_OTHER 3  /* ?? */
00052 
00053 struct _PayloadType
00054 {
00055         int type; 
00056         int clock_rate; 
00057         char bits_per_sample;   /* in case of continuous audio data */
00058         char *zero_pattern;
00059         int pattern_length;
00060         /* other useful information for the application*/
00061         int normal_bitrate;     /*in bit/s */
00062         char *mime_type; 
00063         int channels; 
00064         char *recv_fmtp; /* various format parameters for the incoming stream */
00065         char *send_fmtp; /* various format parameters for the outgoing stream */
00066         int flags;
00067         void *user_data;
00068 };
00069 
00070 #ifndef PayloadType_defined
00071 #define PayloadType_defined
00072 typedef struct _PayloadType PayloadType;
00073 #endif
00074 
00075 #define payload_type_set_flag(pt,flag) (pt)->flags|=((int)flag)
00076 #define payload_type_unset_flag(pt,flag) (pt)->flags&=(~(int)flag)
00077 #define payload_type_get_flags(pt)      (pt)->flags
00078 
00079 #define RTP_PROFILE_MAX_PAYLOADS 128
00080 
00086 struct _RtpProfile
00087 {
00088         char *name;
00089         PayloadType *payload[RTP_PROFILE_MAX_PAYLOADS];
00090 };
00091 
00092 
00093 typedef struct _RtpProfile RtpProfile;
00094 
00095 PayloadType *payload_type_new(void);
00096 PayloadType *payload_type_clone(PayloadType *payload);
00097 char *payload_type_get_rtpmap(PayloadType *pt);
00098 void payload_type_destroy(PayloadType *pt);
00099 void payload_type_set_recv_fmtp(PayloadType *pt, const char *fmtp);
00100 void payload_type_set_send_fmtp(PayloadType *pt, const char *fmtp);
00101 void payload_type_append_recv_fmtp(PayloadType *pt, const char *fmtp);
00102 void payload_type_append_send_fmtp(PayloadType *pt, const char *fmtp);
00103 
00104 #define payload_type_get_bitrate(pt)    ((pt)->normal_bitrate)
00105 #define payload_type_get_rate(pt)               ((pt)->clock_rate)
00106 #define payload_type_get_mime(pt)               ((pt)->mime_type)
00107 
00108 bool_t fmtp_get_value(const char *fmtp, const char *param_name, char *result, size_t result_len);
00109 
00110 VAR_DECLSPEC RtpProfile av_profile;
00111 
00112 #define payload_type_set_user_data(pt,p)        (pt)->user_data=(p)
00113 #define payload_type_get_user_data(pt)          ((pt)->user_data)
00114 
00115 #define rtp_profile_get_name(profile)   (const char*)((profile)->name)
00116 
00117 void rtp_profile_set_payload(RtpProfile *prof, int idx, PayloadType *pt);
00118 
00125 #define rtp_profile_clear_payload(profile,index) \
00126         rtp_profile_set_payload(profile,index,NULL)     
00127 
00128 /* I prefer have this function inlined because it is very often called in the code */
00137 static inline PayloadType * rtp_profile_get_payload(RtpProfile *prof, int idx){
00138         if (idx<0 || idx>=RTP_PROFILE_MAX_PAYLOADS) {
00139                 return NULL;
00140         }
00141         return prof->payload[idx];
00142 }
00143 void rtp_profile_clear_all(RtpProfile *prof);
00144 void rtp_profile_set_name(RtpProfile *prof, const char *name);
00145 PayloadType * rtp_profile_get_payload_from_mime(RtpProfile *profile,const char *mime);
00146 PayloadType * rtp_profile_get_payload_from_rtpmap(RtpProfile *profile, const char *rtpmap);
00147 int rtp_profile_get_payload_number_from_mime(RtpProfile *profile,const char *mime);
00148 int rtp_profile_get_payload_number_from_rtpmap(RtpProfile *profile, const char *rtpmap);
00149 int rtp_profile_find_payload_number(RtpProfile *prof,const char *mime,int rate, int channels);
00150 PayloadType * rtp_profile_find_payload(RtpProfile *prof,const char *mime,int rate, int channels);
00151 int rtp_profile_move_payload(RtpProfile *prof,int oldpos,int newpos);
00152 
00153 RtpProfile * rtp_profile_new(const char *name);
00154 /* clone a profile, payload are not cloned */
00155 RtpProfile * rtp_profile_clone(RtpProfile *prof);
00156 
00157 
00158 /*clone a profile and its payloads (ie payload type are newly allocated, not reusing payload types of the reference profile) */
00159 RtpProfile * rtp_profile_clone_full(RtpProfile *prof);
00160 /* frees the profile and all its PayloadTypes*/
00161 void rtp_profile_destroy(RtpProfile *prof);
00162 
00163 
00164 /* some payload types */
00165 /* audio */
00166 VAR_DECLSPEC PayloadType payload_type_pcmu8000;
00167 VAR_DECLSPEC PayloadType payload_type_pcma8000;
00168 VAR_DECLSPEC PayloadType payload_type_pcm8000;
00169 VAR_DECLSPEC PayloadType payload_type_l16_mono;
00170 VAR_DECLSPEC PayloadType payload_type_l16_stereo;
00171 VAR_DECLSPEC PayloadType payload_type_lpc1016;
00172 VAR_DECLSPEC PayloadType payload_type_g729;
00173 VAR_DECLSPEC PayloadType payload_type_g7231;
00174 VAR_DECLSPEC PayloadType payload_type_g7221;
00175 VAR_DECLSPEC PayloadType payload_type_g726_40;
00176 VAR_DECLSPEC PayloadType payload_type_g726_32;
00177 VAR_DECLSPEC PayloadType payload_type_g726_24;
00178 VAR_DECLSPEC PayloadType payload_type_g726_16;
00179 VAR_DECLSPEC PayloadType payload_type_aal2_g726_40;
00180 VAR_DECLSPEC PayloadType payload_type_aal2_g726_32;
00181 VAR_DECLSPEC PayloadType payload_type_aal2_g726_24;
00182 VAR_DECLSPEC PayloadType payload_type_aal2_g726_16;
00183 VAR_DECLSPEC PayloadType payload_type_gsm;
00184 VAR_DECLSPEC PayloadType payload_type_lpc;
00185 VAR_DECLSPEC PayloadType payload_type_lpc1015;
00186 VAR_DECLSPEC PayloadType payload_type_speex_nb;
00187 VAR_DECLSPEC PayloadType payload_type_speex_wb;
00188 VAR_DECLSPEC PayloadType payload_type_speex_uwb;
00189 VAR_DECLSPEC PayloadType payload_type_ilbc;
00190 VAR_DECLSPEC PayloadType payload_type_amr;
00191 VAR_DECLSPEC PayloadType payload_type_amrwb;
00192 VAR_DECLSPEC PayloadType payload_type_truespeech;
00193 VAR_DECLSPEC PayloadType payload_type_evrc0;
00194 VAR_DECLSPEC PayloadType payload_type_evrcb0;
00195 VAR_DECLSPEC PayloadType payload_type_silk_nb;  
00196 VAR_DECLSPEC PayloadType payload_type_silk_mb;
00197 VAR_DECLSPEC PayloadType payload_type_silk_wb;
00198 VAR_DECLSPEC PayloadType payload_type_silk_swb;
00199 
00200         /* video */
00201 VAR_DECLSPEC PayloadType payload_type_mpv;
00202 VAR_DECLSPEC PayloadType payload_type_h261;
00203 VAR_DECLSPEC PayloadType payload_type_h263;
00204 VAR_DECLSPEC PayloadType payload_type_h263_1998;
00205 VAR_DECLSPEC PayloadType payload_type_h263_2000;
00206 VAR_DECLSPEC PayloadType payload_type_mp4v;
00207 VAR_DECLSPEC PayloadType payload_type_theora;
00208 VAR_DECLSPEC PayloadType payload_type_h264;
00209 VAR_DECLSPEC PayloadType payload_type_x_snow;
00210 VAR_DECLSPEC PayloadType payload_type_jpeg;
00211 VAR_DECLSPEC PayloadType payload_type_vp8;
00212 
00213 VAR_DECLSPEC PayloadType payload_type_g722;
00214 
00215 /* text */
00216 VAR_DECLSPEC PayloadType payload_type_t140;
00217 VAR_DECLSPEC PayloadType payload_type_t140_red;
00218 
00219 /* non standard file transfer over UDP */
00220 VAR_DECLSPEC PayloadType payload_type_x_udpftp;
00221 
00222 /* telephone-event */
00223 VAR_DECLSPEC PayloadType payload_type_telephone_event;
00224 
00225 #ifdef __cplusplus
00226 }
00227 #endif
00228 
00229 #endif