1 /* 2 * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application 3 * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org> 4 * 5 * Version: MPL 1.1 6 * 7 * The contents of this file are subject to the Mozilla Public License Version 8 * 1.1 (the "License"); you may not use this file except in compliance with 9 * the License. You may obtain a copy of the License at 10 * http://www.mozilla.org/MPL/ 11 * 12 * Software distributed under the License is distributed on an "AS IS" basis, 13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 14 * for the specific language governing rights and limitations under the 15 * License. 16 * 17 * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application 18 * 19 * The Initial Developer of the Original Code is 20 * Anthony Minessale II <anthm@freeswitch.org> 21 * Portions created by the Initial Developer are Copyright (C) 22 * the Initial Developer. All Rights Reserved. 23 * 24 * Contributor(s): 25 * 26 * Anthony Minessale II <anthm@freeswitch.org> 27 * 28 * 29 * switch_channel.h -- Media Channel Interface 30 * Marcel Barbulescu <marcelbarbulescu@gmail.com> 31 * 32 */ 33 /** 34 * @file switch_rtp.h 35 * @brief RTP 36 * 37 */ 38 39 #ifndef SWITCH_RTP_H 40 #define SWITCH_RTP_H 41 42 SWITCH_BEGIN_EXTERN_C 43 44 #define SWITCH_RTP_MAX_BUF_LEN 16384 45 #define SWITCH_RTCP_MAX_BUF_LEN 16384 46 #define SWITCH_RTP_MAX_BUF_LEN_WORDS 4094 /* (max / 4) - 2 */ 47 //#define SWITCH_RTP_KEY_LEN 30 48 //#define SWITCH_RTP_CRYPTO_KEY_32 "AES_CM_128_HMAC_SHA1_32" 49 #define SWITCH_RTP_CRYPTO_KEY_80 "AES_CM_128_HMAC_SHA1_80" 50 51 #define SWITCH_RTP_BUNDLE_INTERNAL_PT 21 52 53 typedef struct { 54 switch_rtp_hdr_t header; 55 char body[SWITCH_RTP_MAX_BUF_LEN+4+sizeof(char *)]; 56 switch_rtp_hdr_ext_t *ext; 57 char *ebody; 58 } switch_rtp_packet_t; 59 60 typedef enum { 61 SWITCH_RTP_CRYPTO_SEND, 62 SWITCH_RTP_CRYPTO_RECV, 63 SWITCH_RTP_CRYPTO_SEND_RTCP, 64 SWITCH_RTP_CRYPTO_RECV_RTCP, 65 SWITCH_RTP_CRYPTO_MAX 66 } switch_rtp_crypto_direction_t; 67 68 typedef struct switch_srtp_crypto_suite_s { 69 char *name; 70 const char *alias; 71 switch_rtp_crypto_key_type_t type; 72 int keysalt_len; 73 int salt_len; 74 } switch_srtp_crypto_suite_t; 75 76 struct switch_rtp_crypto_key { 77 uint32_t index; 78 switch_rtp_crypto_key_type_t type; 79 unsigned char keysalt[SWITCH_RTP_MAX_CRYPTO_LEN]; 80 switch_size_t keylen; 81 struct switch_rtp_crypto_key *next; 82 }; 83 typedef struct switch_rtp_crypto_key switch_rtp_crypto_key_t; 84 85 typedef enum { 86 IPR_RTP, 87 IPR_RTCP 88 } ice_proto_t; 89 90 91 92 typedef struct icand_s { 93 char *foundation; 94 int component_id; 95 char *transport; 96 uint32_t priority; 97 char *con_addr; 98 switch_port_t con_port; 99 char *cand_type; 100 char *raddr; 101 switch_port_t rport; 102 char *generation; 103 uint8_t ready; 104 } icand_t; 105 106 #define MAX_CAND 50 107 typedef struct ice_s { 108 109 icand_t cands[MAX_CAND][2]; 110 int cand_idx[2]; 111 int chosen[2]; 112 int is_chosen[2]; 113 char *ufrag; 114 char *pwd; 115 char *options; 116 117 } ice_t; 118 119 typedef enum { /* RTCP Control Packet types (PT) http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-4 */ 120 _RTCP_PT_FIR = 192, /* [RFC 2032] RTP Payload Format for H.261 Video Streams. types 192 (FIR) section 5.2.1 */ 121 _RTCP_PT_IJ = 195, /* IJ: Extended inter-arrival jitter report RFC5450*/ 122 _RTCP_PT_SR = 200, /* SR: sender report RFC3550 */ 123 _RTCP_PT_RR = 201, /* RR: receiver report RFC3550 */ 124 _RTCP_PT_SDES = 202, /* SDES: source description RFC3550 */ 125 _RTCP_PT_BYE = 203, /* BYE: goodbye RFC3550 */ 126 _RTCP_PT_APP = 204, /* APP: application-defined RFC3550 */ 127 _RTCP_PT_RTPFB = 205, /* RTPFB: RTCP Transport layer FB message RFC4585 */ 128 _RTCP_PT_PSFB = 206, /* PSFB: RTCP Payload-specific FB message RFC4585 */ 129 _RTCP_PT_XR = 207, /* XR: extended report RFC3611 */ 130 _RTCP_PT_AVB = 208, /* AVB: "Standard for Layer 3 Transport Protocol for Time Sensitive Applications in Local Area Networks." Work in progress. */ 131 _RTCP_PT_RSI = 209, /* RSI: Receiver Summary Information RFC5760 */ 132 _RTCP_PT_TOKEN = 210, /* TOKEN: Port Mapping RFC6284 */ 133 _RTCP_PT_IDMS = 211, /* IDMS: IDMS Settings RFC7272 */ 134 _RTCP_PT_LAST = 255 /* RESERVED */ 135 } rtcp_pt_t; 136 137 typedef enum { /* RTP SDES item types http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-5 */ 138 _RTCP_SDES_END = 0, /* END: end of sdes list RFC3550 */ 139 _RTCP_SDES_CNAME = 1, /* CNAME: canonical name RFC3550 */ 140 _RTCP_SDES_NAME = 2, /* NAME: user name RFC3550 */ 141 _RTCP_SDES_EMAIL = 3, /* EMAIL: user's electronic mail address RFC3550 */ 142 _RTCP_SDES_PHONE = 4, /* PHONE: user's phone number RFC3550 */ 143 _RTCP_SDES_LOC = 5, /* LOC: geographic user location RFC3550 */ 144 _RTCP_SDES_TOOL = 6, /* TOOL: name of application or tool RFC3550 */ 145 _RTCP_SDES_NOTE = 7, /* NOTE: notice about the source RFC3550 */ 146 _RTCP_SDES_PRIV = 8, /* PRIV: private extensions RFC3550 */ 147 _RTCP_SDES_H323 = 9, /* H323-CADDR: H.323 callable address [Vineet Kumar] */ 148 _RTCP_SDES_APSI = 10 /* APSI: Application specific identifer RFC6776 */ 149 } rtcp_sdes_t; 150 151 typedef enum { /* FMT Values for RTPFB Payload Types http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-8 */ 152 _RTCP_RTPFB_NACK = 1, /* Generic NACK: Generic negative acknowledgement RFC4585 */ 153 _RTCP_RTPFB_TMMBR = 3, /* TMMBR: Temporary Maximum Media Stream Bit Rate Request RFC5104 */ 154 _RTCP_RTPFB_TMMBN = 4, /* TMMBN: Temporary Maximum Media Stream Bit Rate Notification RFC5104 */ 155 _RTCP_RTPFB_SR_REQ = 5, /* RTCP-SR-REQ: TCP Rapid Resynchronisation Request RFC6051*/ 156 _RTCP_RTPFB_RAMS = 6, /* RAMS: Rapid Acquisition of Multicast Sessions RFC6285 */ 157 _RTCP_RTPFB_TLLEI = 7, /* TLLEI: Transport-Layer Third-Party Loss Early Indication RFC6642 */ 158 _RTCP_RTPFB_ECN_FB = 8 /* RTCP-ECN-FB: RTCP ECN Feedback RFC6679*/ 159 } rtcp_rtpfb_t; 160 161 typedef enum { /* FMT Values for PSFB Payload Types http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-9 */ 162 _RTCP_PSFB_PLI = 1, /* PLI: Picture Loss Indication RFC4585 */ 163 _RTCP_PSFB_SLI = 2, /* SLI: Slice Loss Indication RFC4585 */ 164 _RTCP_PSFB_RPSI = 3, /* RPSI: Reference Picture Selection Indication RFC4585 */ 165 _RTCP_PSFB_FIR = 4, /* FIR: Full Intra Request Command RFC5104 */ 166 _RTCP_PSFB_TSTR = 5, /* TSTR: Temporal-Spatial Trade-off Request RFC5104 */ 167 _RTCP_PSFB_TSTN = 6, /* TSTN: Temporal-Spatial Trade-off Notification RFC5104 */ 168 _RTCP_PSFB_VBCM = 7, /* VBCM: Video Back Channel Message RFC5104 */ 169 _RTCP_PSFB_PSLEI = 8, /* PSLEI: Payload-Specific Third-Party Loss Early Indication RFC6642*/ 170 _RTCP_PSFB_AFB = 15 /* AFB Application layer FB */ 171 } rtcp_psfb_t; 172 173 174 175 SWITCH_DECLARE(switch_status_t) switch_rtp_add_crypto_key(switch_rtp_t *rtp_session, switch_rtp_crypto_direction_t direction, uint32_t index, switch_secure_settings_t *ssec); 176 177 ///\defgroup rtp RTP (RealTime Transport Protocol) 178 ///\ingroup core1 179 ///\{ 180 typedef void (*switch_rtp_invalid_handler_t) (switch_rtp_t *rtp_session, 181 switch_socket_t *sock, void *data, switch_size_t datalen, switch_sockaddr_t *from_addr); 182 183 184 SWITCH_DECLARE(void) switch_rtp_get_random(void *buf, uint32_t len); 185 /*! 186 \brief Initilize the RTP System 187 \param pool the memory pool to use for long term allocations 188 \note Generally called by the core_init 189 */ 190 SWITCH_DECLARE(void) switch_rtp_init(switch_memory_pool_t *pool); 191 SWITCH_DECLARE(void) switch_rtp_shutdown(void); 192 193 /*! 194 \brief Set/Get RTP start port 195 \param port new value (if > 0) 196 \return the current RTP start port 197 */ 198 SWITCH_DECLARE(switch_port_t) switch_rtp_set_start_port(switch_port_t port); 199 200 SWITCH_DECLARE(switch_status_t) switch_rtp_set_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc); 201 SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc); 202 203 /*! 204 \brief Set/Get RTP end port 205 \param port new value (if > 0) 206 \return the current RTP end port 207 */ 208 SWITCH_DECLARE(switch_port_t) switch_rtp_set_end_port(switch_port_t port); 209 210 /*! 211 \brief Request a new port to be used for media 212 \param ip the ip to request a port from 213 \return the new port to use 214 */ 215 SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(const char *ip); 216 SWITCH_DECLARE(void) switch_rtp_release_port(const char *ip, switch_port_t port); 217 218 SWITCH_DECLARE(switch_status_t) switch_rtp_set_interval(switch_rtp_t *rtp_session, uint32_t ms_per_packet, uint32_t samples_per_interval); 219 220 SWITCH_DECLARE(switch_status_t) switch_rtp_change_interval(switch_rtp_t *rtp_session, uint32_t ms_per_packet, uint32_t samples_per_interval); 221 /*! 222 \brief create a new RTP session handle 223 \param new_rtp_session a poiter to aim at the new session 224 \param payload the IANA payload number 225 \param samples_per_interval the default samples_per_interval 226 \param ms_per_packet time in microseconds per packet 227 \param flags flags to control behaviour 228 \param timer_name timer interface to use 229 \param err a pointer to resolve error messages 230 \param pool a memory pool to use for the session 231 \return the new RTP session or NULL on failure 232 */ 233 SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session, 234 switch_payload_t payload, 235 uint32_t samples_per_interval, 236 uint32_t ms_per_packet, 237 switch_rtp_flag_t flags[], char *timer_name, const char **err, switch_memory_pool_t *pool); 238 239 240 /*! 241 \brief prepare a new RTP session handle and fully initilize it 242 \param rx_host the local address 243 \param rx_port the local port 244 \param tx_host the remote address 245 \param tx_port the remote port 246 \param payload the IANA payload number 247 \param samples_per_interval the default samples_per_interval 248 \param ms_per_packet time in microseconds per packet 249 \param flags flags to control behaviour 250 \param timer_name timer interface to use 251 \param err a pointer to resolve error messages 252 \param pool a memory pool to use for the session 253 \param bundle_port port used by bundled stream locally, for video thread this is the port where it will forward audio (internal bundle port on which audio is listening), and for audio this is the port where it will send RTP (external bundle port where video is listening) 254 \return the new RTP session or NULL on failure 255 */ 256 SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host, 257 switch_port_t rx_port, 258 const char *tx_host, 259 switch_port_t tx_port, 260 switch_payload_t payload, 261 uint32_t samples_per_interval, 262 uint32_t ms_per_packet, 263 switch_rtp_flag_t flags[], char *timer_name, const char **err, switch_memory_pool_t *pool, switch_port_t bundle_internal_ports, switch_port_t bundle_external_port); 264 265 266 /*! 267 \brief Assign a remote address to the RTP session 268 \param rtp_session an RTP session to assign the remote address to 269 \param host the ip or fqhn of the remote address 270 \param port the remote port 271 \param err pointer for error messages 272 */ 273 SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port, switch_port_t remote_rtcp_port, 274 switch_bool_t change_adv_addr, const char **err); 275 276 SWITCH_DECLARE(void) switch_rtp_reset_jb(switch_rtp_t *rtp_session); 277 SWITCH_DECLARE(char *) switch_rtp_get_remote_host(switch_rtp_t *rtp_session); 278 SWITCH_DECLARE(switch_port_t) switch_rtp_get_remote_port(switch_rtp_t *rtp_session); 279 SWITCH_DECLARE(void) switch_rtp_reset_media_timer(switch_rtp_t *rtp_session); 280 SWITCH_DECLARE(void) switch_rtp_set_max_missed_packets(switch_rtp_t *rtp_session, uint32_t max); 281 SWITCH_DECLARE(void) switch_rtp_set_media_timeout(switch_rtp_t *rtp_session, uint32_t ms); 282 283 SWITCH_DECLARE(switch_status_t) switch_rtp_udptl_mode(switch_rtp_t *rtp_session); 284 SWITCH_DECLARE(void) switch_rtp_reset(switch_rtp_t *rtp_session); 285 286 /*! 287 \brief Assign a local address to the RTP session 288 \param rtp_session an RTP session to assign the local address to 289 \param host the ip or fqhn of the local address 290 \param port the local port 291 \param change_adv_addr change the advertised address for doing compare 292 \param err pointer for error messages 293 \note this call also binds the RTP session's socket to the new address 294 */ 295 SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port, const char **err); 296 297 /*! 298 \brief Kill the socket on an existing RTP session 299 \param rtp_session an RTP session to kill the socket of 300 */ 301 SWITCH_DECLARE(void) switch_rtp_kill_socket(switch_rtp_t *rtp_session); 302 303 SWITCH_DECLARE(void) switch_rtp_break(switch_rtp_t *rtp_session); 304 SWITCH_DECLARE(void) switch_rtp_flush(switch_rtp_t *rtp_session); 305 306 /*! 307 \brief Test if an RTP session is ready 308 \param rtp_session an RTP session to test 309 \return a true value if it's ready 310 */ 311 SWITCH_DECLARE(uint8_t) switch_rtp_ready(switch_rtp_t *rtp_session); 312 313 /*! 314 \brief Destroy an RTP session 315 \param rtp_session an RTP session to destroy 316 */ 317 SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session); 318 319 SWITCH_DECLARE(switch_status_t) switch_rtp_sync_stats(switch_rtp_t *rtp_session); 320 321 /*! 322 \brief Acvite ICE on an RTP session 323 \return SWITCH_STATUS_SUCCESS 324 */ 325 SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_session, char *login, char *rlogin, 326 const char *password, const char *rpassword, ice_proto_t proto, 327 switch_core_media_ice_type_t type, ice_t *ice_params); 328 329 /*! 330 \brief Activate sending RTCP Sender Reports (SR's) 331 \param send_rate interval in milliseconds to send at 332 \return SWITCH_STATUS_SUCCESS 333 */ 334 SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_session, int send_rate, switch_port_t remote_port, switch_bool_t mux); 335 336 337 SWITCH_DECLARE(switch_timer_t *) switch_rtp_get_media_timer(switch_rtp_t *rtp_session); 338 339 SWITCH_DECLARE(switch_status_t) switch_rtp_set_video_buffer_size(switch_rtp_t *rtp_session, uint32_t frames, uint32_t max_frames); 340 SWITCH_DECLARE(switch_status_t) switch_rtp_get_video_buffer_size(switch_rtp_t *rtp_session, uint32_t *min_frame_len, uint32_t *max_frame_len, uint32_t *cur_frame_len, uint32_t *highest_frame_len); 341 342 /*! 343 \brief Acvite a jitter buffer on an RTP session 344 \param rtp_session the rtp session 345 \param queue_frames the number of frames to delay 346 \return SWITCH_STATUS_SUCCESS 347 */ 348 SWITCH_DECLARE(switch_status_t) switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session, 349 uint32_t queue_frames, 350 uint32_t max_queue_frames, 351 uint32_t samples_per_packet, uint32_t samples_per_second); 352 353 SWITCH_DECLARE(switch_status_t) switch_rtp_debug_jitter_buffer(switch_rtp_t *rtp_session, const char *name); 354 355 SWITCH_DECLARE(switch_status_t) switch_rtp_deactivate_jitter_buffer(switch_rtp_t *rtp_session); 356 SWITCH_DECLARE(switch_status_t) switch_rtp_pause_jitter_buffer(switch_rtp_t *rtp_session, switch_bool_t pause); 357 SWITCH_DECLARE(switch_jb_t *) switch_rtp_get_jitter_buffer(switch_rtp_t *rtp_session); 358 359 360 361 362 /*! 363 \brief Set an RTP Flag 364 \param rtp_session the RTP session 365 \param flags the flags to set 366 */ 367 SWITCH_DECLARE(void) switch_rtp_set_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flag); 368 SWITCH_DECLARE(void) switch_rtp_set_flags(switch_rtp_t *rtp_session, switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID]); 369 SWITCH_DECLARE(void) switch_rtp_clear_flags(switch_rtp_t *rtp_session, switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID]); 370 371 /*! 372 \brief Test an RTP Flag 373 \param rtp_session the RTP session 374 \param flags the flags to test 375 \return TRUE or FALSE 376 */ 377 SWITCH_DECLARE(uint32_t) switch_rtp_test_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flags); 378 379 /*! 380 \brief Clear an RTP Flag 381 \param rtp_session the RTP session 382 \param flags the flags to clear 383 */ 384 SWITCH_DECLARE(void) switch_rtp_clear_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flag); 385 386 /*! 387 \brief Retrieve the socket from an existing RTP session 388 \param rtp_session the RTP session to retrieve the socket from 389 \return the socket from the RTP session 390 */ 391 SWITCH_DECLARE(switch_socket_t *) switch_rtp_get_rtp_socket(switch_rtp_t *rtp_session); 392 SWITCH_DECLARE(void) switch_rtp_ping(switch_rtp_t *rtp_session); 393 /*! 394 \brief Get the default samples per interval for a given RTP session 395 \param rtp_session the RTP session to get the samples per interval from 396 \return the default samples per interval of the RTP session 397 */ 398 SWITCH_DECLARE(uint32_t) switch_rtp_get_default_samples_per_interval(switch_rtp_t *rtp_session); 399 400 /*! 401 \brief Set the default payload number for a given RTP session 402 \param rtp_session the RTP session to set the payload number on 403 \param payload the new default payload number 404 */ 405 SWITCH_DECLARE(void) switch_rtp_set_default_payload(switch_rtp_t *rtp_session, switch_payload_t payload); 406 407 /*! 408 \brief Get the default payload number for a given RTP session 409 \param rtp_session the RTP session to get the payload number from 410 \return the default payload of the RTP session 411 */ 412 SWITCH_DECLARE(uint32_t) switch_rtp_get_default_payload(switch_rtp_t *rtp_session); 413 414 415 /*! 416 \brief Set a callback function to execute when an invalid RTP packet is encountered 417 \param rtp_session the RTP session 418 \param on_invalid the function to set 419 \return 420 */ 421 SWITCH_DECLARE(void) switch_rtp_set_invalid_handler(switch_rtp_t *rtp_session, switch_rtp_invalid_handler_t on_invalid); 422 423 /*! 424 \brief Read data from a given RTP session 425 \param rtp_session the RTP session to read from 426 \param data the data to read 427 \param datalen a pointer to the datalen 428 \param payload_type the IANA payload of the packet 429 \param flags flags 430 \param io_flags i/o flags 431 \return the number of bytes read 432 */ 433 SWITCH_DECLARE(switch_status_t) switch_rtp_read(switch_rtp_t *rtp_session, void *data, uint32_t *datalen, 434 switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags); 435 436 /*! 437 \brief Queue RFC2833 DTMF data into an RTP Session 438 \param rtp_session the rtp session to use 439 \param dtmf the dtmf digits to queue 440 \return SWITCH_STATUS_SUCCESS on success 441 */ 442 SWITCH_DECLARE(switch_status_t) switch_rtp_queue_rfc2833(switch_rtp_t *rtp_session, const switch_dtmf_t *dtmf); 443 444 /*! 445 \brief Queue RFC2833 DTMF data into an RTP Session 446 \param rtp_session the rtp session to use 447 \param dtmf the dtmf digits to queue 448 \return SWITCH_STATUS_SUCCESS on success 449 */ 450 SWITCH_DECLARE(switch_status_t) switch_rtp_queue_rfc2833_in(switch_rtp_t *rtp_session, const switch_dtmf_t *dtmf); 451 452 /*! 453 \brief Test for presence of DTMF on a given RTP session 454 \param rtp_session session to test 455 \return number of digits in the queue 456 */ 457 SWITCH_DECLARE(switch_size_t) switch_rtp_has_dtmf(switch_rtp_t *rtp_session); 458 459 /*! 460 \brief Retrieve DTMF digits from a given RTP session 461 \param rtp_session RTP session to retrieve digits from 462 \param dtmf the dtmf 463 \return number of bytes read into the buffer 464 */ 465 SWITCH_DECLARE(switch_size_t) switch_rtp_dequeue_dtmf(switch_rtp_t *rtp_session, switch_dtmf_t *dtmf); 466 467 /*! 468 \brief Read data from a given RTP session without copying 469 \param rtp_session the RTP session to read from 470 \param data a pointer to point directly to the RTP read buffer 471 \param datalen a pointer to the datalen 472 \param payload_type the IANA payload of the packet 473 \param flags flags 474 \param io_flags i/o flags 475 \return the number of bytes read 476 */ 477 SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read(switch_rtp_t *rtp_session, 478 void **data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags, 479 switch_io_flag_t io_flags); 480 481 /*! 482 \brief Read data from a given RTP session without copying 483 \param rtp_session the RTP session to read from 484 \param frame a frame to populate with information 485 \param io_flags i/o flags 486 \return the number of bytes read 487 */ 488 SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read_frame(switch_rtp_t *rtp_session, switch_frame_t *frame, switch_io_flag_t io_flags); 489 490 491 /*! 492 \brief Read RTCP data from a given RTP session without copying 493 \param rtp_session the RTP session to read from 494 \param frame an RTCP frame to populate with information 495 \return the number of bytes read 496 */ 497 SWITCH_DECLARE(switch_status_t) switch_rtcp_zerocopy_read_frame(switch_rtp_t *rtp_session, switch_rtcp_frame_t *frame); 498 499 SWITCH_DECLARE(void) rtp_flush_read_buffer(switch_rtp_t *rtp_session, switch_rtp_flush_t flush); 500 501 /*! 502 \brief Enable VAD on an RTP Session 503 \param rtp_session the RTP session 504 \param session the core session associated with the RTP session 505 \param codec the codec the channel is currenty using 506 \param flags flags for control 507 \return SWITCH_STAUTS_SUCCESS on success 508 */ 509 SWITCH_DECLARE(switch_status_t) switch_rtp_enable_vad(switch_rtp_t *rtp_session, switch_core_session_t *session, 510 switch_codec_t *codec, switch_vad_flag_t flags); 511 512 /*! 513 \brief Disable VAD on an RTP Session 514 \param rtp_session the RTP session 515 \return SWITCH_STAUTS_SUCCESS on success 516 */ 517 SWITCH_DECLARE(switch_status_t) switch_rtp_disable_vad(switch_rtp_t *rtp_session); 518 519 /*! 520 \brief Write data to a given RTP session 521 \param rtp_session the RTP session to write to 522 \param frame the frame to write 523 \return the number of bytes written 524 */ 525 SWITCH_DECLARE(int) switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_frame_t *frame); 526 527 /*! 528 \brief Write data with a specified payload and sequence number to a given RTP session 529 \param rtp_session the RTP session to write to 530 \param data data to write 531 \param datalen the size of the data 532 \param m set mark bit or not 533 \param payload the IANA payload number 534 \param ts then number of bytes to increment the timestamp by 535 \param flags frame flags 536 \return the number of bytes written 537 */ 538 SWITCH_DECLARE(int) switch_rtp_write_manual(switch_rtp_t *rtp_session, 539 void *data, uint32_t datalen, uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags); 540 541 SWITCH_DECLARE(switch_status_t) switch_rtp_write_raw(switch_rtp_t *rtp_session, void *data, switch_size_t *bytes, switch_bool_t process_encryption); 542 543 /*! 544 \brief Retrieve the SSRC from a given RTP session 545 \param rtp_session the RTP session to retrieve from 546 \return the SSRC 547 */ 548 SWITCH_DECLARE(uint32_t) switch_rtp_get_ssrc(switch_rtp_t *rtp_session); 549 550 /*! 551 \brief Associate an arbitrary data pointer with and RTP session 552 \param rtp_session the RTP session to assign the pointer to 553 \param private_data the private data to assign 554 */ 555 SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp_t *rtp_session, void *private_data); 556 557 /*! 558 \brief Set the payload type to consider RFC2833 DTMF 559 \param rtp_session the RTP session to modify 560 \param te the payload type 561 */ 562 SWITCH_DECLARE(void) switch_rtp_set_telephony_event(switch_rtp_t *rtp_session, switch_payload_t te); 563 SWITCH_DECLARE(void) switch_rtp_set_telephony_recv_event(switch_rtp_t *rtp_session, switch_payload_t te); 564 565 /*! 566 \brief Set the payload type for comfort noise 567 \param rtp_session the RTP session to modify 568 \param pt the payload type 569 */ 570 SWITCH_DECLARE(void) switch_rtp_set_cng_pt(switch_rtp_t *rtp_session, switch_payload_t pt); 571 572 /*! 573 \brief Retrieve the private data from a given RTP session 574 \param rtp_session the RTP session to retrieve the data from 575 \return the pointer to the private data 576 */ 577 SWITCH_DECLARE(void *) switch_rtp_get_private(switch_rtp_t *rtp_session); 578 SWITCH_DECLARE(switch_status_t) switch_rtp_set_payload_map(switch_rtp_t *rtp_session, payload_map_t **pmap); 579 SWITCH_DECLARE(void) switch_rtp_intentional_bugs(switch_rtp_t *rtp_session, switch_rtp_bug_flag_t bugs); 580 581 SWITCH_DECLARE(switch_rtp_stats_t *) switch_rtp_get_stats(switch_rtp_t *rtp_session, switch_memory_pool_t *pool); 582 SWITCH_DECLARE(switch_byte_t) switch_rtp_check_auto_adj(switch_rtp_t *rtp_session); 583 SWITCH_DECLARE(void) switch_rtp_set_interdigit_delay(switch_rtp_t *rtp_session, uint32_t delay); 584 585 SWITCH_DECLARE(switch_status_t) switch_rtp_add_dtls(switch_rtp_t *rtp_session, dtls_fingerprint_t *local_fp, dtls_fingerprint_t *remote_fp, dtls_type_t type, uint8_t want_DTLSv1_2); 586 SWITCH_DECLARE(switch_status_t) switch_rtp_del_dtls(switch_rtp_t *rtp_session, dtls_type_t type); 587 SWITCH_DECLARE(dtls_state_t) switch_rtp_dtls_state(switch_rtp_t *rtp_session, dtls_type_t type); 588 589 SWITCH_DECLARE(int) switch_rtp_has_dtls(void); 590 591 SWITCH_DECLARE(switch_status_t) switch_rtp_req_bitrate(switch_rtp_t *rtp_session, uint32_t bps); 592 SWITCH_DECLARE(switch_status_t) switch_rtp_ack_bitrate(switch_rtp_t *rtp_session, uint32_t bps); 593 SWITCH_DECLARE(void) switch_rtp_video_refresh(switch_rtp_t *rtp_session); 594 SWITCH_DECLARE(void) switch_rtp_video_loss(switch_rtp_t *rtp_session); 595 596 SWITCH_DECLARE(switch_core_session_t*) switch_rtp_get_core_session(switch_rtp_t *rtp_session); 597 /*! 598 \} 599 */ 600 601 SWITCH_END_EXTERN_C 602 #endif 603 /* For Emacs: 604 * Local Variables: 605 * mode:c 606 * indent-tabs-mode:t 607 * tab-width:4 608 * c-basic-offset:4 609 * End: 610 * For VIM: 611 * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: 612 */ 613