1 /* 2 * The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) implementation with additional features. 3 * Copyright (C) 2017 Belledonne Communications SARL 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program 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 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 */ 19 20 /** 21 * \file payloadtype.h 22 * \brief Definition of payload types 23 * 24 **/ 25 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 /*payload type represents a VBR codec*/ 38 #define PAYLOAD_TYPE_IS_VBR (1<<1) 39 #define PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED (1<<2) 40 /* private flags for future use by ortp */ 41 #define PAYLOAD_TYPE_PRIV1 (1<<3) 42 /* user flags, can be used by the application on top of oRTP */ 43 #define PAYLOAD_TYPE_USER_FLAG_0 (1<<4) 44 #define PAYLOAD_TYPE_USER_FLAG_1 (1<<5) 45 #define PAYLOAD_TYPE_USER_FLAG_2 (1<<6) 46 #define PAYLOAD_TYPE_USER_FLAG_3 (1<<7) 47 #define PAYLOAD_TYPE_USER_FLAG_4 (1<<8) 48 /* ask for more if you need*/ 49 50 #define PAYLOAD_TYPE_FLAG_CAN_RECV PAYLOAD_TYPE_USER_FLAG_1 51 #define PAYLOAD_TYPE_FLAG_CAN_SEND PAYLOAD_TYPE_USER_FLAG_2 52 53 #define PAYLOAD_AUDIO_CONTINUOUS 0 54 #define PAYLOAD_AUDIO_PACKETIZED 1 55 #define PAYLOAD_VIDEO 2 56 #define PAYLOAD_TEXT 3 57 #define PAYLOAD_OTHER 4 /* ?? */ 58 59 #define PAYLOAD_TYPE_AVPF_NONE 0 60 #define PAYLOAD_TYPE_AVPF_FIR (1 << 0) 61 #define PAYLOAD_TYPE_AVPF_PLI (1 << 1) 62 #define PAYLOAD_TYPE_AVPF_SLI (1 << 2) 63 #define PAYLOAD_TYPE_AVPF_RPSI (1 << 3) 64 65 struct _PayloadTypeAvpfParams { 66 unsigned char features; /**< A bitmask of PAYLOAD_TYPE_AVPF_* macros. */ 67 bool_t rpsi_compatibility; /*< Linphone uses positive feeback for RPSI. However first versions handling 68 AVPF wrongly declared RPSI as negative feedback, so this is kept for compatibility 69 with these versions but will probably be removed at some point in time. */ 70 uint16_t trr_interval; /**< The interval in milliseconds between regular RTCP packets. */ 71 }; 72 73 struct _OrtpPayloadType 74 { 75 int type; /**< one of PAYLOAD_* macros*/ 76 int clock_rate; /**< rtp clock rate*/ 77 char bits_per_sample; /* in case of continuous audio data */ 78 char *zero_pattern; 79 int pattern_length; 80 /* other useful information for the application*/ 81 int normal_bitrate; /*in bit/s */ 82 char *mime_type; /**<actually the submime, ex: pcm, pcma, gsm*/ 83 int channels; /**< number of channels of audio */ 84 char *recv_fmtp; /* various format parameters for the incoming stream */ 85 char *send_fmtp; /* various format parameters for the outgoing stream */ 86 struct _PayloadTypeAvpfParams avpf; /* AVPF parameters */ 87 int flags; 88 void *user_data; 89 }; 90 91 #ifndef PayloadType_defined 92 #define PayloadType_defined 93 typedef struct _OrtpPayloadType OrtpPayloadType; 94 typedef OrtpPayloadType PayloadType; 95 typedef struct _PayloadTypeAvpfParams PayloadTypeAvpfParams; 96 #endif 97 98 #define payload_type_set_flag(pt,flag) (pt)->flags|=((int)flag) 99 #define payload_type_unset_flag(pt,flag) (pt)->flags&=(~(int)flag) 100 #define payload_type_get_flags(pt) (pt)->flags 101 102 103 ORTP_PUBLIC PayloadType *payload_type_new(void); 104 ORTP_PUBLIC PayloadType *payload_type_clone(const PayloadType *payload); 105 ORTP_PUBLIC char *payload_type_get_rtpmap(PayloadType *pt); 106 ORTP_PUBLIC void payload_type_destroy(PayloadType *pt); 107 ORTP_PUBLIC void payload_type_set_recv_fmtp(PayloadType *pt, const char *fmtp); 108 ORTP_PUBLIC void payload_type_set_send_fmtp(PayloadType *pt, const char *fmtp); 109 ORTP_PUBLIC void payload_type_append_recv_fmtp(PayloadType *pt, const char *fmtp); 110 ORTP_PUBLIC void payload_type_append_send_fmtp(PayloadType *pt, const char *fmtp); 111 #define payload_type_get_avpf_params(pt) ((pt)->avpf) 112 ORTP_PUBLIC void payload_type_set_avpf_params(PayloadType *pt, PayloadTypeAvpfParams params); 113 ORTP_PUBLIC bool_t payload_type_is_vbr(const PayloadType *pt); 114 115 #define payload_type_get_bitrate(pt) ((pt)->normal_bitrate) 116 #define payload_type_get_rate(pt) ((pt)->clock_rate) 117 #define payload_type_get_mime(pt) ((pt)->mime_type) 118 119 ORTP_PUBLIC bool_t fmtp_get_value(const char *fmtp, const char *param_name, char *result, size_t result_len); 120 121 #define payload_type_set_user_data(pt,p) (pt)->user_data=(p) 122 #define payload_type_get_user_data(pt) ((pt)->user_data) 123 124 125 /* some payload types */ 126 /* audio */ 127 ORTP_VAR_PUBLIC PayloadType payload_type_pcmu8000; 128 ORTP_VAR_PUBLIC PayloadType payload_type_pcma8000; 129 ORTP_VAR_PUBLIC PayloadType payload_type_pcm8000; 130 ORTP_VAR_PUBLIC PayloadType payload_type_l16_mono; 131 ORTP_VAR_PUBLIC PayloadType payload_type_l16_stereo; 132 ORTP_VAR_PUBLIC PayloadType payload_type_lpc1016; 133 ORTP_VAR_PUBLIC PayloadType payload_type_g729; 134 ORTP_VAR_PUBLIC PayloadType payload_type_g7231; 135 ORTP_VAR_PUBLIC PayloadType payload_type_g7221; 136 ORTP_VAR_PUBLIC PayloadType payload_type_cn; 137 ORTP_VAR_PUBLIC PayloadType payload_type_g726_40; 138 ORTP_VAR_PUBLIC PayloadType payload_type_g726_32; 139 ORTP_VAR_PUBLIC PayloadType payload_type_g726_24; 140 ORTP_VAR_PUBLIC PayloadType payload_type_g726_16; 141 ORTP_VAR_PUBLIC PayloadType payload_type_aal2_g726_40; 142 ORTP_VAR_PUBLIC PayloadType payload_type_aal2_g726_32; 143 ORTP_VAR_PUBLIC PayloadType payload_type_aal2_g726_24; 144 ORTP_VAR_PUBLIC PayloadType payload_type_aal2_g726_16; 145 ORTP_VAR_PUBLIC PayloadType payload_type_gsm; 146 ORTP_VAR_PUBLIC PayloadType payload_type_lpc; 147 ORTP_VAR_PUBLIC PayloadType payload_type_lpc1015; 148 ORTP_VAR_PUBLIC PayloadType payload_type_speex_nb; 149 ORTP_VAR_PUBLIC PayloadType payload_type_speex_wb; 150 ORTP_VAR_PUBLIC PayloadType payload_type_speex_uwb; 151 ORTP_VAR_PUBLIC PayloadType payload_type_ilbc; 152 ORTP_VAR_PUBLIC PayloadType payload_type_amr; 153 ORTP_VAR_PUBLIC PayloadType payload_type_amrwb; 154 ORTP_VAR_PUBLIC PayloadType payload_type_truespeech; 155 ORTP_VAR_PUBLIC PayloadType payload_type_evrc0; 156 ORTP_VAR_PUBLIC PayloadType payload_type_evrcb0; 157 ORTP_VAR_PUBLIC PayloadType payload_type_silk_nb; 158 ORTP_VAR_PUBLIC PayloadType payload_type_silk_mb; 159 ORTP_VAR_PUBLIC PayloadType payload_type_silk_wb; 160 ORTP_VAR_PUBLIC PayloadType payload_type_silk_swb; 161 ORTP_VAR_PUBLIC PayloadType payload_type_aaceld_16k; 162 ORTP_VAR_PUBLIC PayloadType payload_type_aaceld_22k; 163 ORTP_VAR_PUBLIC PayloadType payload_type_aaceld_32k; 164 ORTP_VAR_PUBLIC PayloadType payload_type_aaceld_44k; 165 ORTP_VAR_PUBLIC PayloadType payload_type_aaceld_48k; 166 ORTP_VAR_PUBLIC PayloadType payload_type_opus; 167 ORTP_VAR_PUBLIC PayloadType payload_type_isac; 168 ORTP_VAR_PUBLIC PayloadType payload_type_gsm_efr; 169 ORTP_VAR_PUBLIC PayloadType payload_type_codec2; 170 ORTP_VAR_PUBLIC PayloadType payload_type_bv16; 171 172 /* video */ 173 ORTP_VAR_PUBLIC PayloadType payload_type_mpv; 174 ORTP_VAR_PUBLIC PayloadType payload_type_h261; 175 ORTP_VAR_PUBLIC PayloadType payload_type_h263; 176 ORTP_VAR_PUBLIC PayloadType payload_type_h263_1998; 177 ORTP_VAR_PUBLIC PayloadType payload_type_h263_2000; 178 ORTP_VAR_PUBLIC PayloadType payload_type_mp4v; 179 ORTP_VAR_PUBLIC PayloadType payload_type_theora; 180 ORTP_VAR_PUBLIC PayloadType payload_type_h264; 181 ORTP_VAR_PUBLIC PayloadType payload_type_x_snow; 182 ORTP_VAR_PUBLIC PayloadType payload_type_jpeg; 183 ORTP_VAR_PUBLIC PayloadType payload_type_vp8; 184 185 ORTP_VAR_PUBLIC PayloadType payload_type_g722; 186 187 /* text */ 188 ORTP_VAR_PUBLIC PayloadType payload_type_t140; 189 ORTP_VAR_PUBLIC PayloadType payload_type_t140_red; 190 191 /* non standard file transfer over UDP */ 192 ORTP_VAR_PUBLIC PayloadType payload_type_x_udpftp; 193 194 /* telephone-event */ 195 ORTP_VAR_PUBLIC PayloadType payload_type_telephone_event; 196 197 #ifdef __cplusplus 198 } 199 #endif 200 201 #endif 202