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_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         char *recv_fmtp; /* various format parameters for the incoming stream */
00063         char *send_fmtp; /* various format parameters for the outgoing stream */
00064         int flags;
00065         void *user_data;
00066 };
00067 
00068 #ifndef PayloadType_defined
00069 #define PayloadType_defined
00070 typedef struct _PayloadType PayloadType;
00071 #endif
00072 
00073 #define payload_type_set_flag(pt,flag) (pt)->flags|=((int)flag)
00074 #define payload_type_unset_flag(pt,flag) (pt)->flags&=(~(int)flag)
00075 #define payload_type_get_flags(pt)      (pt)->flags
00076 
00077 #define RTP_PROFILE_MAX_PAYLOADS 128
00078 
00084 struct _RtpProfile
00085 {
00086         char *name;
00087         PayloadType *payload[RTP_PROFILE_MAX_PAYLOADS];
00088 };
00089 
00090 
00091 typedef struct _RtpProfile RtpProfile;
00092 
00093 PayloadType *payload_type_new(void);
00094 PayloadType *payload_type_clone(PayloadType *payload);
00095 void payload_type_destroy(PayloadType *pt);
00096 void payload_type_set_recv_fmtp(PayloadType *pt, const char *fmtp);
00097 void payload_type_set_send_fmtp(PayloadType *pt, const char *fmtp);
00098 
00099 bool_t fmtp_get_value(const char *fmtp, const char *param_name, char *result, size_t result_len);
00100 
00101 VAR_DECLSPEC RtpProfile av_profile;
00102 
00103 #define payload_type_set_user_data(pt,p)        (pt)->user_data=(p)
00104 #define payload_type_get_user_data(pt)          ((pt)->user_data)
00105 
00106 #define rtp_profile_get_name(profile)   (const char*)((profile)->name)
00107 
00108 void rtp_profile_set_payload(RtpProfile *prof, int idx, PayloadType *pt);
00109 
00116 #define rtp_profile_clear_payload(profile,index) \
00117         rtp_profile_set_payload(profile,index,NULL)     
00118 
00119 /* I prefer have this function inlined because it is very often called in the code */
00128 static inline PayloadType * rtp_profile_get_payload(RtpProfile *prof, int idx){
00129         if (idx<0 || idx>=RTP_PROFILE_MAX_PAYLOADS) {
00130                 return NULL;
00131         }
00132         return prof->payload[idx];
00133 }
00134 void rtp_profile_clear_all(RtpProfile *prof);
00135 void rtp_profile_set_name(RtpProfile *prof, const char *name);
00136 PayloadType * rtp_profile_get_payload_from_mime(RtpProfile *profile,const char *mime);
00137 PayloadType * rtp_profile_get_payload_from_rtpmap(RtpProfile *profile, const char *rtpmap);
00138 int rtp_profile_get_payload_number_from_mime(RtpProfile *profile,const char *mime);
00139 int rtp_profile_get_payload_number_from_rtpmap(RtpProfile *profile, const char *rtpmap);
00140 int rtp_profile_find_payload_number(RtpProfile *prof,const char *mime,int rate);
00141 PayloadType * rtp_profile_find_payload(RtpProfile *prof,const char *mime,int rate);
00142 int rtp_profile_move_payload(RtpProfile *prof,int oldpos,int newpos);
00143 
00144 RtpProfile * rtp_profile_new(const char *name);
00145 /* clone a profile, payload are not cloned */
00146 RtpProfile * rtp_profile_clone(RtpProfile *prof);
00147 
00148 
00149 /*clone a profile and its payloads (ie payload type are newly allocated, not reusing payload types of the reference profile) */
00150 RtpProfile * rtp_profile_clone_full(RtpProfile *prof);
00151 /* frees the profile and all its PayloadTypes*/
00152 void rtp_profile_destroy(RtpProfile *prof);
00153 
00154 
00155 /* some payload types */
00156 /* audio */
00157 VAR_DECLSPEC PayloadType payload_type_pcmu8000;
00158 VAR_DECLSPEC PayloadType payload_type_pcma8000;
00159 VAR_DECLSPEC PayloadType payload_type_pcm8000;
00160 VAR_DECLSPEC PayloadType payload_type_lpc1016;
00161 VAR_DECLSPEC PayloadType payload_type_g729;
00162 VAR_DECLSPEC PayloadType payload_type_g7231;
00163 VAR_DECLSPEC PayloadType payload_type_gsm;
00164 VAR_DECLSPEC PayloadType payload_type_lpc1015;
00165 VAR_DECLSPEC PayloadType payload_type_speex_nb;
00166 VAR_DECLSPEC PayloadType payload_type_speex_wb;
00167 VAR_DECLSPEC PayloadType payload_type_ilbc;
00168 VAR_DECLSPEC PayloadType payload_type_amr;
00169 VAR_DECLSPEC PayloadType payload_type_amrwb;
00170 VAR_DECLSPEC PayloadType payload_type_truespeech;
00171 VAR_DECLSPEC PayloadType payload_type_evrc0;
00172 
00173 /* video */
00174 VAR_DECLSPEC PayloadType payload_type_mpv;
00175 VAR_DECLSPEC PayloadType payload_type_h261;
00176 VAR_DECLSPEC PayloadType payload_type_h263;
00177 VAR_DECLSPEC PayloadType payload_type_h263_1998;
00178 VAR_DECLSPEC PayloadType payload_type_h263_2000;
00179 VAR_DECLSPEC PayloadType payload_type_mp4v;
00180 VAR_DECLSPEC PayloadType payload_type_theora;
00181 
00182 /* telephone-event */
00183 VAR_DECLSPEC PayloadType payload_type_telephone_event;
00184 
00185 #ifdef __cplusplus
00186 }
00187 #endif
00188 
00189 #endif

Generated on Thu Apr 5 18:59:20 2007 for oRTP by  doxygen 1.5.1