oRTP: include/ortp/payloadtype.h Source File

- Main Page
- Data Structures
- Files

# 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         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
    00104 bool_t fmtp_get_value(const char *fmtp, const char *param_name, char *result, size_t result_len);
    00105
    00106 VAR_DECLSPEC RtpProfile av_profile;
    00107
    00108 #define payload_type_set_user_data(pt,p)        (pt)->user_data=(p)
    00109 #define payload_type_get_user_data(pt)          ((pt)->user_data)
    00110
    00111 #define rtp_profile_get_name(profile)   (const char*)((profile)->name)
    00112
    00113 void rtp_profile_set_payload(RtpProfile *prof, int idx, PayloadType *pt);
    00114
    00121 #define rtp_profile_clear_payload(profile,index) \
    00122         rtp_profile_set_payload(profile,index,NULL)
    00123
    00124 /* I prefer have this function inlined because it is very often called in the code */
    00133 static inline PayloadType * rtp_profile_get_payload(RtpProfile *prof, int idx){
    00134         if (idx<0 || idx>=RTP_PROFILE_MAX_PAYLOADS) {
    00135                 return NULL;
    00136         }
    00137         return prof->payload[idx];
    00138 }
    00139 void rtp_profile_clear_all(RtpProfile *prof);
    00140 void rtp_profile_set_name(RtpProfile *prof, const char *name);
    00141 PayloadType * rtp_profile_get_payload_from_mime(RtpProfile *profile,const char *mime);
    00142 PayloadType * rtp_profile_get_payload_from_rtpmap(RtpProfile *profile, const char *rtpmap);
    00143 int rtp_profile_get_payload_number_from_mime(RtpProfile *profile,const char *mime);
    00144 int rtp_profile_get_payload_number_from_rtpmap(RtpProfile *profile, const char *rtpmap);
    00145 int rtp_profile_find_payload_number(RtpProfile *prof,const char *mime,int rate, int channels);
    00146 PayloadType * rtp_profile_find_payload(RtpProfile *prof,const char *mime,int rate, int channels);
    00147 int rtp_profile_move_payload(RtpProfile *prof,int oldpos,int newpos);
    00148
    00149 RtpProfile * rtp_profile_new(const char *name);
    00150 /* clone a profile, payload are not cloned */
    00151 RtpProfile * rtp_profile_clone(RtpProfile *prof);
    00152
    00153
    00154 /*clone a profile and its payloads (ie payload type are newly allocated, not reusing payload types of the reference profile) */
    00155 RtpProfile * rtp_profile_clone_full(RtpProfile *prof);
    00156 /* frees the profile and all its PayloadTypes*/
    00157 void rtp_profile_destroy(RtpProfile *prof);
    00158
    00159
    00160 /* some payload types */
    00161 /* audio */
    00162 VAR_DECLSPEC PayloadType payload_type_pcmu8000;
    00163 VAR_DECLSPEC PayloadType payload_type_pcma8000;
    00164 VAR_DECLSPEC PayloadType payload_type_pcm8000;
    00165 VAR_DECLSPEC PayloadType payload_type_l16_mono;
    00166 VAR_DECLSPEC PayloadType payload_type_l16_stereo;
    00167 VAR_DECLSPEC PayloadType payload_type_lpc1016;
    00168 VAR_DECLSPEC PayloadType payload_type_g729;
    00169 VAR_DECLSPEC PayloadType payload_type_g7231;
    00170 VAR_DECLSPEC PayloadType payload_type_g7221;
    00171 VAR_DECLSPEC PayloadType payload_type_g726_40;
    00172 VAR_DECLSPEC PayloadType payload_type_g726_32;
    00173 VAR_DECLSPEC PayloadType payload_type_g726_24;
    00174 VAR_DECLSPEC PayloadType payload_type_g726_16;
    00175 VAR_DECLSPEC PayloadType payload_type_gsm;
    00176 VAR_DECLSPEC PayloadType payload_type_lpc;
    00177 VAR_DECLSPEC PayloadType payload_type_lpc1015;
    00178 VAR_DECLSPEC PayloadType payload_type_speex_nb;
    00179 VAR_DECLSPEC PayloadType payload_type_speex_wb;
    00180 VAR_DECLSPEC PayloadType payload_type_speex_uwb;
    00181 VAR_DECLSPEC PayloadType payload_type_ilbc;
    00182 VAR_DECLSPEC PayloadType payload_type_amr;
    00183 VAR_DECLSPEC PayloadType payload_type_amrwb;
    00184 VAR_DECLSPEC PayloadType payload_type_truespeech;
    00185 VAR_DECLSPEC PayloadType payload_type_evrc0;
    00186
    00187 /* video */
    00188 VAR_DECLSPEC PayloadType payload_type_mpv;
    00189 VAR_DECLSPEC PayloadType payload_type_h261;
    00190 VAR_DECLSPEC PayloadType payload_type_h263;
    00191 VAR_DECLSPEC PayloadType payload_type_h263_1998;
    00192 VAR_DECLSPEC PayloadType payload_type_h263_2000;
    00193 VAR_DECLSPEC PayloadType payload_type_mp4v;
    00194 VAR_DECLSPEC PayloadType payload_type_theora;
    00195 VAR_DECLSPEC PayloadType payload_type_h264;
    00196 VAR_DECLSPEC PayloadType payload_type_x_snow;
    00197 VAR_DECLSPEC PayloadType payload_type_t140;
    00198
    00199 /* non standard file transfer over UDP */
    00200 VAR_DECLSPEC PayloadType payload_type_x_udpftp;
    00201
    00202 /* telephone-event */
    00203 VAR_DECLSPEC PayloadType payload_type_telephone_event;
    00204
    00205 #ifdef __cplusplus
    00206 }
    00207 #endif
    00208
    00209 #endif