FreeSWITCH API Documentation  1.7.0
switch_rtp.h
Go to the documentation of this file.
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 
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_MAX_CRYPTO_LEN 64
48 //#define SWITCH_RTP_KEY_LEN 30
49 //#define SWITCH_RTP_CRYPTO_KEY_32 "AES_CM_128_HMAC_SHA1_32"
50 #define SWITCH_RTP_CRYPTO_KEY_80 "AES_CM_128_HMAC_SHA1_80"
51 
52 typedef struct {
54  char body[SWITCH_RTP_MAX_BUF_LEN+4+sizeof(char *)];
56 
57 typedef enum {
64 
66  char *name;
68  int keylen;
70 
71 
73  uint32_t index;
78 };
80 
81 typedef enum {
84 } ice_proto_t;
85 
86 
87 
88 typedef struct icand_s {
89  char *foundation;
91  char *transport;
92  uint32_t priority;
93  char *con_addr;
95  char *cand_type;
96  char *raddr;
98  char *generation;
99  uint8_t ready;
100 } icand_t;
101 
102 #define MAX_CAND 50
103 typedef struct ice_s {
104 
106  int cand_idx[2];
107  int chosen[2];
108  int is_chosen[2];
109  char *ufrag;
110  char *pwd;
111  char *options;
112 
113 } ice_t;
114 
115 typedef enum { /* RTCP Control Packet types (PT) http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-4 */
116  _RTCP_PT_IJ = 195, /* IJ: Extended inter-arrival jitter report RFC5450*/
117  _RTCP_PT_SR = 200, /* SR: sender report RFC3550 */
118  _RTCP_PT_RR = 201, /* RR: receiver report RFC3550 */
119  _RTCP_PT_SDES = 202, /* SDES: source description RFC3550 */
120  _RTCP_PT_BYE = 203, /* BYE: goodbye RFC3550 */
121  _RTCP_PT_APP = 204, /* APP: application-defined RFC3550 */
122  _RTCP_PT_RTPFB = 205, /* RTPFB: RTCP Transport layer FB message RFC4585 */
123  _RTCP_PT_PSFB = 206, /* PSFB: RTCP Payload-specific FB message RFC4585 */
124  _RTCP_PT_XR = 207, /* XR: extended report RFC3611 */
125  _RTCP_PT_AVB = 208, /* AVB: "Standard for Layer 3 Transport Protocol for Time Sensitive Applications in Local Area Networks." Work in progress. */
126  _RTCP_PT_RSI = 209, /* RSI: Receiver Summary Information RFC5760 */
127  _RTCP_PT_TOKEN = 210, /* TOKEN: Port Mapping RFC6284 */
128  _RTCP_PT_IDMS = 211, /* IDMS: IDMS Settings RFC7272 */
129  _RTCP_PT_LAST = 255 /* RESERVED */
130 } rtcp_pt_t;
131 
132 typedef enum { /* RTP SDES item types http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-5 */
133  _RTCP_SDES_END = 0, /* END: end of sdes list RFC3550 */
134  _RTCP_SDES_CNAME = 1, /* CNAME: canonical name RFC3550 */
135  _RTCP_SDES_NAME = 2, /* NAME: user name RFC3550 */
136  _RTCP_SDES_EMAIL = 3, /* EMAIL: user's electronic mail address RFC3550 */
137  _RTCP_SDES_PHONE = 4, /* PHONE: user's phone number RFC3550 */
138  _RTCP_SDES_LOC = 5, /* LOC: geographic user location RFC3550 */
139  _RTCP_SDES_TOOL = 6, /* TOOL: name of application or tool RFC3550 */
140  _RTCP_SDES_NOTE = 7, /* NOTE: notice about the source RFC3550 */
141  _RTCP_SDES_PRIV = 8, /* PRIV: private extensions RFC3550 */
142  _RTCP_SDES_H323 = 9, /* H323-CADDR: H.323 callable address [Vineet Kumar] */
143  _RTCP_SDES_APSI = 10 /* APSI: Application specific identifer RFC6776 */
144 } rtcp_sdes_t;
145 
146 typedef enum { /* FMT Values for RTPFB Payload Types http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-8 */
147  _RTCP_RTPFB_NACK = 1, /* Generic NACK: Generic negative acknowledgement RFC4585 */
148  _RTCP_RTPFB_TMMBR = 3, /* TMMBR: Temporary Maximum Media Stream Bit Rate Request RFC5104 */
149  _RTCP_RTPFB_TMMBN = 4, /* TMMBN: Temporary Maximum Media Stream Bit Rate Notification RFC5104 */
150  _RTCP_RTPFB_SR_REQ = 5, /* RTCP-SR-REQ: TCP Rapid Resynchronisation Request RFC6051*/
151  _RTCP_RTPFB_RAMS = 6, /* RAMS: Rapid Acquisition of Multicast Sessions RFC6285 */
152  _RTCP_RTPFB_TLLEI = 7, /* TLLEI: Transport-Layer Third-Party Loss Early Indication RFC6642 */
153  _RTCP_RTPFB_ECN_FB = 8 /* RTCP-ECN-FB: RTCP ECN Feedback RFC6679*/
154 } rtcp_rtpfb_t;
155 
156 typedef enum { /* FMT Values for PSFB Payload Types http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-9 */
157  _RTCP_PSFB_PLI = 1, /* PLI: Picture Loss Indication RFC4585 */
158  _RTCP_PSFB_SLI = 2, /* SLI: Slice Loss Indication RFC4585 */
159  _RTCP_PSFB_RPSI = 3, /* RPSI: Reference Picture Selection Indication RFC4585 */
160  _RTCP_PSFB_FIR = 4, /* FIR: Full Intra Request Command RFC5104 */
161  _RTCP_PSFB_TSTR = 5, /* TSTR: Temporal-Spatial Trade-off Request RFC5104 */
162  _RTCP_PSFB_TSTN = 6, /* TSTN: Temporal-Spatial Trade-off Notification RFC5104 */
163  _RTCP_PSFB_VBCM = 7, /* VBCM: Video Back Channel Message RFC5104 */
164  _RTCP_PSFB_PSLEI = 8, /* PSLEI: Payload-Specific Third-Party Loss Early Indication RFC6642*/
165  _RTCP_PSFB_AFB = 15 /* AFB Application layer FB */
166 } rtcp_psfb_t;
167 
168 
169 
172  uint32_t index, switch_rtp_crypto_key_type_t type, unsigned char *key, switch_size_t keylen);
173 
174 ///\defgroup rtp RTP (RealTime Transport Protocol)
175 ///\ingroup core1
176 ///\{
177  typedef void (*switch_rtp_invalid_handler_t) (switch_rtp_t *rtp_session,
178  switch_socket_t *sock, void *data, switch_size_t datalen, switch_sockaddr_t *from_addr);
179 
180 
181 SWITCH_DECLARE(void) switch_rtp_get_random(void *buf, uint32_t len);
182 /*!
183  \brief Initilize the RTP System
184  \param pool the memory pool to use for long term allocations
185  \note Generally called by the core_init
186 */
189 
190 /*!
191  \brief Set/Get RTP start port
192  \param port new value (if > 0)
193  \return the current RTP start port
194 */
196 
197 SWITCH_DECLARE(switch_status_t) switch_rtp_set_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc);
199 
200 /*!
201  \brief Set/Get RTP end port
202  \param port new value (if > 0)
203  \return the current RTP end port
204 */
206 
207 /*!
208  \brief Request a new port to be used for media
209  \param ip the ip to request a port from
210  \return the new port to use
211 */
213 SWITCH_DECLARE(void) switch_rtp_release_port(const char *ip, switch_port_t port);
214 
215 SWITCH_DECLARE(switch_status_t) switch_rtp_set_interval(switch_rtp_t *rtp_session, uint32_t ms_per_packet, uint32_t samples_per_interval);
216 
217 SWITCH_DECLARE(switch_status_t) switch_rtp_change_interval(switch_rtp_t *rtp_session, uint32_t ms_per_packet, uint32_t samples_per_interval);
218 /*!
219  \brief create a new RTP session handle
220  \param new_rtp_session a poiter to aim at the new session
221  \param payload the IANA payload number
222  \param samples_per_interval the default samples_per_interval
223  \param ms_per_packet time in microseconds per packet
224  \param flags flags to control behaviour
225  \param timer_name timer interface to use
226  \param err a pointer to resolve error messages
227  \param pool a memory pool to use for the session
228  \return the new RTP session or NULL on failure
229 */
231  switch_payload_t payload,
232  uint32_t samples_per_interval,
233  uint32_t ms_per_packet,
234  switch_rtp_flag_t flags[], char *timer_name, const char **err, switch_memory_pool_t *pool);
235 
236 
237 /*!
238  \brief prepare a new RTP session handle and fully initilize it
239  \param rx_host the local address
240  \param rx_port the local port
241  \param tx_host the remote address
242  \param tx_port the remote port
243  \param payload the IANA payload number
244  \param samples_per_interval the default samples_per_interval
245  \param ms_per_packet time in microseconds per packet
246  \param flags flags to control behaviour
247  \param timer_name timer interface to use
248  \param err a pointer to resolve error messages
249  \param pool a memory pool to use for the session
250  \return the new RTP session or NULL on failure
251 */
252 SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host,
253  switch_port_t rx_port,
254  const char *tx_host,
255  switch_port_t tx_port,
256  switch_payload_t payload,
257  uint32_t samples_per_interval,
258  uint32_t ms_per_packet,
259  switch_rtp_flag_t flags[], char *timer_name, const char **err, switch_memory_pool_t *pool);
260 
261 
262 /*!
263  \brief Assign a remote address to the RTP session
264  \param rtp_session an RTP session to assign the remote address to
265  \param host the ip or fqhn of the remote address
266  \param port the remote port
267  \param err pointer for error messages
268 */
269 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,
270  switch_bool_t change_adv_addr, const char **err);
271 
276 SWITCH_DECLARE(void) switch_rtp_set_max_missed_packets(switch_rtp_t *rtp_session, uint32_t max);
277 
279 SWITCH_DECLARE(void) switch_rtp_reset(switch_rtp_t *rtp_session);
280 
281 /*!
282  \brief Assign a local address to the RTP session
283  \param rtp_session an RTP session to assign the local address to
284  \param host the ip or fqhn of the local address
285  \param port the local port
286  \param change_adv_addr change the advertised address for doing compare
287  \param err pointer for error messages
288  \note this call also binds the RTP session's socket to the new address
289 */
290 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);
291 
292 /*!
293  \brief Kill the socket on an existing RTP session
294  \param rtp_session an RTP session to kill the socket of
295 */
297 
298 SWITCH_DECLARE(void) switch_rtp_break(switch_rtp_t *rtp_session);
299 SWITCH_DECLARE(void) switch_rtp_flush(switch_rtp_t *rtp_session);
300 
301 /*!
302  \brief Test if an RTP session is ready
303  \param rtp_session an RTP session to test
304  \return a true value if it's ready
305 */
306 SWITCH_DECLARE(uint8_t) switch_rtp_ready(switch_rtp_t *rtp_session);
307 
308 /*!
309  \brief Destroy an RTP session
310  \param rtp_session an RTP session to destroy
311 */
312 SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp_t **rtp_session);
313 
315 
316 /*!
317  \brief Acvite ICE on an RTP session
318  \return SWITCH_STATUS_SUCCESS
319 */
320 SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_session, char *login, char *rlogin,
321  const char *password, const char *rpassword, ice_proto_t proto,
322  switch_core_media_ice_type_t type, ice_t *ice_params);
323 
324 /*!
325  \brief Activate sending RTCP Sender Reports (SR's)
326  \param send_rate interval in milliseconds to send at
327  \return SWITCH_STATUS_SUCCESS
328 */
330 
331 
333 
334 SWITCH_DECLARE(switch_status_t) switch_rtp_set_video_buffer_size(switch_rtp_t *rtp_session, uint32_t frames, uint32_t max_frames);
335 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);
336 
337 /*!
338  \brief Acvite a jitter buffer on an RTP session
339  \param rtp_session the rtp session
340  \param queue_frames the number of frames to delay
341  \return SWITCH_STATUS_SUCCESS
342 */
344  uint32_t queue_frames,
345  uint32_t max_queue_frames,
346  uint32_t samples_per_packet, uint32_t samples_per_second);
347 
349 
353 
354 
355 
356 
357 /*!
358  \brief Set an RTP Flag
359  \param rtp_session the RTP session
360  \param flags the flags to set
361 */
364 SWITCH_DECLARE(void) switch_rtp_clear_flags(switch_rtp_t *rtp_session, switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID]);
365 
366 /*!
367  \brief Test an RTP Flag
368  \param rtp_session the RTP session
369  \param flags the flags to test
370  \return TRUE or FALSE
371 */
373 
374 /*!
375  \brief Clear an RTP Flag
376  \param rtp_session the RTP session
377  \param flags the flags to clear
378 */
380 
381 /*!
382  \brief Retrieve the socket from an existing RTP session
383  \param rtp_session the RTP session to retrieve the socket from
384  \return the socket from the RTP session
385 */
387 SWITCH_DECLARE(void) switch_rtp_ping(switch_rtp_t *rtp_session);
388 /*!
389  \brief Get the default samples per interval for a given RTP session
390  \param rtp_session the RTP session to get the samples per interval from
391  \return the default samples per interval of the RTP session
392 */
394 
395 /*!
396  \brief Set the default payload number for a given RTP session
397  \param rtp_session the RTP session to set the payload number on
398  \param payload the new default payload number
399 */
401 
402 /*!
403  \brief Get the default payload number for a given RTP session
404  \param rtp_session the RTP session to get the payload number from
405  \return the default payload of the RTP session
406 */
408 
409 
410 /*!
411  \brief Set a callback function to execute when an invalid RTP packet is encountered
412  \param rtp_session the RTP session
413  \param on_invalid the function to set
414  \return
415 */
417 
418 /*!
419  \brief Read data from a given RTP session
420  \param rtp_session the RTP session to read from
421  \param data the data to read
422  \param datalen a pointer to the datalen
423  \param payload_type the IANA payload of the packet
424  \param flags flags
425  \param io_flags i/o flags
426  \return the number of bytes read
427 */
428 SWITCH_DECLARE(switch_status_t) switch_rtp_read(switch_rtp_t *rtp_session, void *data, uint32_t *datalen,
429  switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags);
430 
431 /*!
432  \brief Queue RFC2833 DTMF data into an RTP Session
433  \param rtp_session the rtp session to use
434  \param dtmf the dtmf digits to queue
435  \return SWITCH_STATUS_SUCCESS on success
436 */
438 
439 /*!
440  \brief Queue RFC2833 DTMF data into an RTP Session
441  \param rtp_session the rtp session to use
442  \param dtmf the dtmf digits to queue
443  \return SWITCH_STATUS_SUCCESS on success
444 */
446 
447 /*!
448  \brief Test for presence of DTMF on a given RTP session
449  \param rtp_session session to test
450  \return number of digits in the queue
451 */
453 
454 /*!
455  \brief Retrieve DTMF digits from a given RTP session
456  \param rtp_session RTP session to retrieve digits from
457  \param dtmf the dtmf
458  \return number of bytes read into the buffer
459 */
461 
462 /*!
463  \brief Read data from a given RTP session without copying
464  \param rtp_session the RTP session to read from
465  \param data a pointer to point directly to the RTP read buffer
466  \param datalen a pointer to the datalen
467  \param payload_type the IANA payload of the packet
468  \param flags flags
469  \param io_flags i/o flags
470  \return the number of bytes read
471 */
473  void **data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags,
474  switch_io_flag_t io_flags);
475 
476 /*!
477  \brief Read data from a given RTP session without copying
478  \param rtp_session the RTP session to read from
479  \param frame a frame to populate with information
480  \param io_flags i/o flags
481  \return the number of bytes read
482 */
484 
485 
486 /*!
487  \brief Read RTCP data from a given RTP session without copying
488  \param rtp_session the RTP session to read from
489  \param frame an RTCP frame to populate with information
490  \return the number of bytes read
491 */
493 
495 
496 /*!
497  \brief Enable VAD on an RTP Session
498  \param rtp_session the RTP session
499  \param session the core session associated with the RTP session
500  \param codec the codec the channel is currenty using
501  \param flags flags for control
502  \return SWITCH_STAUTS_SUCCESS on success
503 */
505  switch_codec_t *codec, switch_vad_flag_t flags);
506 
507 /*!
508  \brief Disable VAD on an RTP Session
509  \param rtp_session the RTP session
510  \return SWITCH_STAUTS_SUCCESS on success
511 */
513 
514 /*!
515  \brief Write data to a given RTP session
516  \param rtp_session the RTP session to write to
517  \param frame the frame to write
518  \return the number of bytes written
519 */
521 
522 /*!
523  \brief Write data with a specified payload and sequence number to a given RTP session
524  \param rtp_session the RTP session to write to
525  \param data data to write
526  \param datalen the size of the data
527  \param m set mark bit or not
528  \param payload the IANA payload number
529  \param ts then number of bytes to increment the timestamp by
530  \param flags frame flags
531  \return the number of bytes written
532 */
534  void *data, uint32_t datalen, uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags);
535 
536 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);
537 
538 /*!
539  \brief Retrieve the SSRC from a given RTP session
540  \param rtp_session the RTP session to retrieve from
541  \return the SSRC
542 */
543 SWITCH_DECLARE(uint32_t) switch_rtp_get_ssrc(switch_rtp_t *rtp_session);
544 
545 /*!
546  \brief Associate an arbitrary data pointer with and RTP session
547  \param rtp_session the RTP session to assign the pointer to
548  \param private_data the private data to assign
549 */
550 SWITCH_DECLARE(void) switch_rtp_set_private(switch_rtp_t *rtp_session, void *private_data);
551 
552 /*!
553  \brief Set the payload type to consider RFC2833 DTMF
554  \param rtp_session the RTP session to modify
555  \param te the payload type
556 */
559 
560 /*!
561  \brief Set the payload type for comfort noise
562  \param rtp_session the RTP session to modify
563  \param pt the payload type
564 */
566 
567 /*!
568  \brief Retrieve the private data from a given RTP session
569  \param rtp_session the RTP session to retrieve the data from
570  \return the pointer to the private data
571 */
575 
578 SWITCH_DECLARE(void) switch_rtp_set_interdigit_delay(switch_rtp_t *rtp_session, uint32_t delay);
579 
583 
585 
590 
591 /*!
592  \}
593 */
594 
596 #endif
597 /* For Emacs:
598  * Local Variables:
599  * mode:c
600  * indent-tabs-mode:t
601  * tab-width:4
602  * c-basic-offset:4
603  * End:
604  * For VIM:
605  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
606  */
char * generation
Definition: switch_rtp.h:98
int cand_idx[2]
Definition: switch_rtp.h:106
switch_status_t switch_rtp_activate_rtcp(switch_rtp_t *rtp_session, int send_rate, switch_port_t remote_port, switch_bool_t mux)
Activate sending RTCP Sender Reports (SR's)
Definition: switch_rtp.c:4186
uint8_t switch_rtp_ready(switch_rtp_t *rtp_session)
Test if an RTP session is ready.
Definition: switch_rtp.c:4452
switch_status_t switch_rtp_del_dtls(switch_rtp_t *rtp_session, dtls_type_t type)
Definition: switch_rtp.c:3232
switch_rtp_crypto_key_type_t
switch_socket_t * switch_rtp_get_rtp_socket(switch_rtp_t *rtp_session)
Retrieve the socket from an existing RTP session.
Definition: switch_rtp.c:4635
switch_rtp_flush_t
Definition: switch_types.h:696
rtcp_psfb_t
Definition: switch_rtp.h:156
void switch_rtp_reset(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:2789
uint32_t switch_io_flag_t
switch_status_t switch_rtp_ack_bitrate(switch_rtp_t *rtp_session, uint32_t bps)
Definition: switch_rtp.c:4351
#define SWITCH_END_EXTERN_C
Definition: switch.h:43
switch_rtp_hdr_t header
Definition: switch_rtp.h:53
int chosen[2]
Definition: switch_rtp.h:107
switch_bool_t
Definition: switch_types.h:405
switch_size_t keylen
Definition: switch_rtp.h:76
char * foundation
Definition: switch_rtp.h:89
ice_proto_t
Definition: switch_rtp.h:81
switch_memory_pool_t * pool
char * raddr
Definition: switch_rtp.h:96
#define SWITCH_RTP_MAX_BUF_LEN
Definition: switch_rtp.h:44
switch_rtp_crypto_direction_t
Definition: switch_rtp.h:57
switch_status_t switch_rtp_pause_jitter_buffer(switch_rtp_t *rtp_session, switch_bool_t pause)
Definition: switch_rtp.c:4059
dtls_state_t switch_rtp_dtls_state(switch_rtp_t *rtp_session, dtls_type_t type)
Definition: switch_rtp.c:3215
switch_status_t switch_rtp_set_payload_map(switch_rtp_t *rtp_session, payload_map_t **pmap)
Definition: switch_rtp.c:2454
switch_status_t switch_rtp_add_crypto_key(switch_rtp_t *rtp_session, switch_rtp_crypto_direction_t direction, uint32_t index, switch_rtp_crypto_key_type_t type, unsigned char *key, switch_size_t keylen)
Definition: switch_rtp.c:3468
void switch_rtp_intentional_bugs(switch_rtp_t *rtp_session, switch_rtp_bug_flag_t bugs)
Definition: switch_rtp.c:2467
void switch_rtp_set_telephony_recv_event(switch_rtp_t *rtp_session, switch_payload_t te)
Definition: switch_rtp.c:4022
void switch_rtp_set_private(switch_rtp_t *rtp_session, void *private_data)
Associate an arbitrary data pointer with and RTP session.
Definition: switch_rtp.c:8094
Abstract handler to a timer module.
switch_port_t switch_rtp_set_start_port(switch_port_t port)
Set/Get RTP start port.
Definition: switch_rtp.c:2387
switch_status_t switch_rtp_zerocopy_read(switch_rtp_t *rtp_session, void **data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags)
Read data from a given RTP session without copying.
Definition: switch_rtp.c:7135
uint8_t switch_byte_t
Definition: switch_types.h:246
void switch_rtp_set_max_missed_packets(switch_rtp_t *rtp_session, uint32_t max)
Definition: switch_rtp.c:2753
switch_port_t switch_rtp_get_remote_port(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:2827
void rtp_flush_read_buffer(switch_rtp_t *rtp_session, switch_rtp_flush_t flush)
Definition: switch_rtp.c:4940
switch_status_t switch_rtp_udptl_mode(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:2843
void switch_rtp_reset_media_timer(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:2817
void switch_rtp_set_telephony_event(switch_rtp_t *rtp_session, switch_payload_t te)
Set the payload type to consider RFC2833 DTMF.
Definition: switch_rtp.c:4014
void switch_rtp_init(switch_memory_pool_t *pool)
Initilize the RTP System.
Definition: switch_rtp.c:1442
void switch_rtp_destroy(switch_rtp_t **rtp_session)
Destroy an RTP session.
Definition: switch_rtp.c:4491
uint32_t switch_vad_flag_t
Definition: switch_types.h:616
switch_status_t switch_rtp_deactivate_jitter_buffer(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:4079
switch_jb_t * switch_rtp_get_jitter_buffer(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:4050
switch_status_t switch_rtp_zerocopy_read_frame(switch_rtp_t *rtp_session, switch_frame_t *frame, switch_io_flag_t io_flags)
Read data from a given RTP session without copying.
Definition: switch_rtp.c:7036
switch_byte_t switch_byte_t * buf
switch_status_t switch_rtp_activate_jitter_buffer(switch_rtp_t *rtp_session, uint32_t queue_frames, uint32_t max_queue_frames, uint32_t samples_per_packet, uint32_t samples_per_second)
Acvite a jitter buffer on an RTP session.
Definition: switch_rtp.c:4146
struct ice_s ice_t
struct apr_sockaddr_t switch_sockaddr_t
Definition: switch_apr.h:1029
int switch_rtp_has_dtls(void)
Definition: switch_rtp.c:3207
#define SWITCH_RTP_MAX_CRYPTO_LEN
Definition: switch_rtp.h:47
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)
Definition: switch_rtp.c:4091
switch_rtp_bug_flag_t
Definition: switch_types.h:771
rtcp_rtpfb_t
Definition: switch_rtp.h:146
switch_status_t switch_rtp_activate_ice(switch_rtp_t *rtp_session, char *login, char *rlogin, const char *password, const char *rpassword, ice_proto_t proto, switch_core_media_ice_type_t type, ice_t *ice_params)
Acvite ICE on an RTP session.
Definition: switch_rtp.c:4241
void switch_rtp_set_flags(switch_rtp_t *rtp_session, switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID])
Definition: switch_rtp.c:4660
switch_port_t switch_rtp_set_end_port(switch_port_t port)
Set/Get RTP end port.
Definition: switch_rtp.c:2401
switch_status_t switch_rtp_disable_vad(switch_rtp_t *rtp_session)
Disable VAD on an RTP Session.
Definition: switch_rtp.c:7654
char * con_addr
Definition: switch_rtp.h:93
void switch_rtp_video_loss(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:4374
switch_status_t switch_rtp_create(switch_rtp_t **new_rtp_session, switch_payload_t payload, uint32_t samples_per_interval, uint32_t ms_per_packet, switch_rtp_flag_t flags[], char *timer_name, const char **err, switch_memory_pool_t *pool)
create a new RTP session handle
switch_status_t switch_rtp_set_remote_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc)
Definition: switch_rtp.c:3733
switch_status_t switch_rtp_set_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc)
Definition: switch_rtp.c:3725
char * cand_type
Definition: switch_rtp.h:95
switch_rtp_crypto_key_type_t type
Definition: switch_rtp.h:74
switch_byte_t switch_rtp_check_auto_adj(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:6893
An abstraction of a data frame.
Definition: switch_frame.h:43
uint32_t switch_rtp_get_default_payload(switch_rtp_t *rtp_session)
Get the default payload number for a given RTP session.
Definition: switch_rtp.c:4650
char * options
Definition: switch_rtp.h:111
uintptr_t switch_size_t
uint8_t ready
Definition: switch_rtp.h:99
uint16_t switch_port_t
switch_size_t switch_rtp_has_dtmf(switch_rtp_t *rtp_session)
Test for presence of DTMF on a given RTP session.
Definition: switch_rtp.c:6898
void * switch_rtp_get_private(switch_rtp_t *rtp_session)
Retrieve the private data from a given RTP session.
Definition: switch_rtp.c:8099
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, switch_bool_t change_adv_addr, const char **err)
Assign a remote address to the RTP session.
Definition: switch_rtp.c:2913
uint32_t switch_frame_flag_t
char * ufrag
Definition: switch_rtp.h:109
void switch_rtp_set_cng_pt(switch_rtp_t *rtp_session, switch_payload_t pt)
Set the payload type for comfort noise.
Definition: switch_rtp.c:4030
dtls_type_t
Definition: switch_core.h:157
switch_status_t switch_rtp_write_raw(switch_rtp_t *rtp_session, void *data, switch_size_t *bytes, switch_bool_t process_encryption)
Definition: switch_rtp.c:8006
void switch_rtp_shutdown(void)
Definition: switch_rtp.c:2348
char * transport
Definition: switch_rtp.h:91
uint32_t switch_rtp_get_default_samples_per_interval(switch_rtp_t *rtp_session)
Get the default samples per interval for a given RTP session.
Definition: switch_rtp.c:4640
rtcp_sdes_t
Definition: switch_rtp.h:132
void switch_rtp_clear_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flag)
Clear an RTP Flag.
Definition: switch_rtp.c:4747
switch_port_t switch_rtp_request_port(const char *ip)
Request a new port to be used for media.
Definition: switch_rtp.c:2431
void switch_rtp_set_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flag)
Set an RTP Flag.
Definition: switch_rtp.c:4702
char * switch_rtp_get_remote_host(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:2822
switch_status_t
Common return values.
switch_timer_t * switch_rtp_get_media_timer(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:4036
uint32_t switch_rtp_get_ssrc(switch_rtp_t *rtp_session)
Retrieve the SSRC from a given RTP session.
Definition: switch_rtp.c:8089
void(* switch_rtp_invalid_handler_t)(switch_rtp_t *rtp_session, switch_socket_t *sock, void *data, switch_size_t datalen, switch_sockaddr_t *from_addr)
Definition: switch_rtp.h:177
dtls_state_t
Definition: switch_core.h:164
void switch_rtp_ping(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:2333
switch_size_t switch_rtp_dequeue_dtmf(switch_rtp_t *rtp_session, switch_dtmf_t *dtmf)
Retrieve DTMF digits from a given RTP session.
Definition: switch_rtp.c:6911
void switch_rtp_flush(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:4331
#define MAX_CAND
Definition: switch_rtp.h:102
void switch_rtp_break(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:4385
rtcp_pt_t
Definition: switch_rtp.h:115
void switch_rtp_reset_jb(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:2769
An abstraction of a rtcp frame.
switch_rtp_flag_t
RTP Related Flags.
Definition: switch_types.h:723
char * pwd
Definition: switch_rtp.h:110
unsigned char key[SWITCH_RTP_MAX_CRYPTO_LEN]
Definition: switch_rtp.h:75
switch_status_t switch_rtp_set_interval(switch_rtp_t *rtp_session, uint32_t ms_per_packet, uint32_t samples_per_interval)
Definition: switch_rtp.c:3674
void switch_rtp_get_random(void *buf, uint32_t len)
Definition: switch_rtp.c:2338
switch_status_t switch_rtp_queue_rfc2833(switch_rtp_t *rtp_session, const switch_dtmf_t *dtmf)
Queue RFC2833 DTMF data into an RTP Session.
Definition: switch_rtp.c:6935
void switch_rtp_set_default_payload(switch_rtp_t *rtp_session, switch_payload_t payload)
Set the default payload number for a given RTP session.
Definition: switch_rtp.c:4645
int component_id
Definition: switch_rtp.h:90
#define SWITCH_DECLARE(type)
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)
Definition: switch_rtp.c:3294
struct switch_srtp_crypto_suite_s switch_srtp_crypto_suite_t
void switch_rtp_clear_flags(switch_rtp_t *rtp_session, switch_rtp_flag_t flags[SWITCH_RTP_FLAG_INVALID])
Definition: switch_rtp.c:4691
int switch_rtp_write_frame(switch_rtp_t *rtp_session, switch_frame_t *frame)
Write data to a given RTP session.
Definition: switch_rtp.c:7726
switch_rtp_stats_t * switch_rtp_get_stats(switch_rtp_t *rtp_session, switch_memory_pool_t *pool)
Definition: switch_rtp.c:7928
switch_rtp_t * switch_rtp_new(const char *rx_host, switch_port_t rx_port, const char *tx_host, switch_port_t tx_port, switch_payload_t payload, uint32_t samples_per_interval, uint32_t ms_per_packet, switch_rtp_flag_t flags[], char *timer_name, const char **err, switch_memory_pool_t *pool)
prepare a new RTP session handle and fully initilize it
switch_status_t switch_rtp_set_video_buffer_size(switch_rtp_t *rtp_session, uint32_t frames, uint32_t max_frames)
Definition: switch_rtp.c:4101
switch_status_t switch_rtp_change_interval(switch_rtp_t *rtp_session, uint32_t ms_per_packet, uint32_t samples_per_interval)
Definition: switch_rtp.c:3687
switch_status_t switch_rtp_debug_jitter_buffer(switch_rtp_t *rtp_session, const char *name)
Definition: switch_rtp.c:4126
icand_t cands[MAX_CAND][2]
Definition: switch_rtp.h:105
int is_chosen[2]
Definition: switch_rtp.h:108
switch_status_t switch_rtp_set_local_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port, const char **err)
Assign a local address to the RTP session.
Definition: switch_rtp.c:2585
struct apr_pool_t switch_memory_pool_t
switch_status_t switch_rtp_enable_vad(switch_rtp_t *rtp_session, switch_core_session_t *session, switch_codec_t *codec, switch_vad_flag_t flags)
Enable VAD on an RTP Session.
Definition: switch_rtp.c:7669
void switch_rtp_release_port(const char *ip, switch_port_t port)
Definition: switch_rtp.c:2415
uint32_t switch_rtp_test_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flags)
Test an RTP Flag.
Definition: switch_rtp.c:4742
void switch_rtp_set_invalid_handler(switch_rtp_t *rtp_session, switch_rtp_invalid_handler_t on_invalid)
Set a callback function to execute when an invalid RTP packet is encountered.
Definition: switch_rtp.c:4655
uint32_t priority
Definition: switch_rtp.h:92
switch_status_t switch_rtp_queue_rfc2833_in(switch_rtp_t *rtp_session, const switch_dtmf_t *dtmf)
Queue RFC2833 DTMF data into an RTP Session.
Definition: switch_rtp.c:6961
struct icand_s icand_t
void switch_rtp_kill_socket(switch_rtp_t *rtp_session)
Kill the socket on an existing RTP session.
Definition: switch_rtp.c:4425
switch_core_media_ice_type_t
struct apr_socket_t switch_socket_t
Definition: switch_apr.h:1026
void switch_rtp_video_refresh(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:4362
struct switch_rtp_crypto_key * next
Definition: switch_rtp.h:77
switch_status_t switch_rtp_req_bitrate(switch_rtp_t *rtp_session, uint32_t bps)
Definition: switch_rtp.c:4340
switch_status_t switch_rtcp_zerocopy_read_frame(switch_rtp_t *rtp_session, switch_rtcp_frame_t *frame)
Read RTCP data from a given RTP session without copying.
Definition: switch_rtp.c:7016
switch_status_t switch_rtp_read(switch_rtp_t *rtp_session, void *data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags)
Read data from a given RTP session.
Definition: switch_rtp.c:6986
void switch_rtp_set_interdigit_delay(switch_rtp_t *rtp_session, uint32_t delay)
Definition: switch_rtp.c:4630
switch_status_t switch_rtp_sync_stats(switch_rtp_t *rtp_session)
Definition: switch_rtp.c:4468
uint8_t switch_payload_t
switch_port_t con_port
Definition: switch_rtp.h:94
switch_port_t rport
Definition: switch_rtp.h:97
int switch_rtp_write_manual(switch_rtp_t *rtp_session, void *data, uint32_t datalen, uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags)
Write data with a specified payload and sequence number to a given RTP session.
Definition: switch_rtp.c:7955
switch_rtp_crypto_key_type_t type
Definition: switch_rtp.h:67
#define SWITCH_BEGIN_EXTERN_C
Definition: switch.h:42