Wed Jan 8 2020 09:49:50

Asterisk developer's documentation


rtp_engine.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2009, Digium, Inc.
5  *
6  * Mark Spencer <markster@digium.com>
7  * Joshua Colp <jcolp@digium.com>
8  *
9  * See http://www.asterisk.org for more information about
10  * the Asterisk project. Please do not directly contact
11  * any of the maintainers of this project for assistance;
12  * the project provides a web site, mailing lists and IRC
13  * channels for your use.
14  *
15  * This program is free software, distributed under the terms of
16  * the GNU General Public License Version 2. See the LICENSE file
17  * at the top of the source tree.
18  */
19 
20 /*! \file
21  * \brief Pluggable RTP Architecture
22  * \author Joshua Colp <jcolp@digium.com>
23  * \ref AstRTPEngine
24  */
25 
26 /*!
27  * \page AstRTPEngine Asterisk RTP Engine API
28  *
29  * The purpose of this API is to provide a way for multiple RTP stacks to be
30  * used inside of Asterisk without any module that uses RTP knowing any
31  * different. To the module each RTP stack behaves the same.
32  *
33  * An RTP session is called an instance and is made up of a combination of codec
34  * information, RTP engine, RTP properties, and address information. An engine
35  * name may be passed in to explicitly choose an RTP stack to be used but a
36  * default one will be used if none is provided. An address to use for RTP may
37  * also be provided but the underlying RTP engine may choose a different address
38  * depending on it's configuration.
39  *
40  * An RTP engine is the layer between the RTP engine core and the RTP stack
41  * itself. The RTP engine core provides a set of callbacks to do various things
42  * (such as write audio out) that the RTP engine has to have implemented.
43  *
44  * Glue is what binds an RTP instance to a channel. It is used to retrieve RTP
45  * instance information when performing remote or local bridging and is used to
46  * have the channel driver tell the remote side to change destination of the RTP
47  * stream.
48  *
49  * Statistics from an RTP instance can be retrieved using the
50  * ast_rtp_instance_get_stats API call. This essentially asks the RTP engine in
51  * use to fill in a structure with the requested values. It is not required for
52  * an RTP engine to support all statistic values.
53  *
54  * Properties allow behavior of the RTP engine and RTP engine core to be
55  * changed. For example, there is a property named AST_RTP_PROPERTY_NAT which is
56  * used to tell the RTP engine to enable symmetric RTP if it supports it. It is
57  * not required for an RTP engine to support all properties.
58  *
59  * Codec information is stored using a separate data structure which has it's
60  * own set of API calls to add/remove/retrieve information. They are used by the
61  * module after an RTP instance is created so that payload information is
62  * available for the RTP engine.
63  */
64 
65 #ifndef _ASTERISK_RTP_ENGINE_H
66 #define _ASTERISK_RTP_ENGINE_H
67 
68 #if defined(__cplusplus) || defined(c_plusplus)
69 extern "C" {
70 #endif
71 
72 #include "asterisk/astobj2.h"
73 #include "asterisk/frame.h"
74 #include "asterisk/netsock2.h"
75 #include "asterisk/sched.h"
76 #include "asterisk/res_srtp.h"
77 
78 /* Maximum number of payloads supported */
79 #define AST_RTP_MAX_PT 256
80 
81 /* Maximum number of generations */
82 #define AST_RED_MAX_GENERATION 5
83 
84 struct ast_rtp_instance;
85 struct ast_rtp_glue;
86 
87 /*! RTP Properties that can be set on an RTP instance */
89  /*! Enable symmetric RTP support */
91  /*! RTP instance will be carrying DTMF (using RFC2833) */
93  /*! Expect unreliable DTMF from remote party */
95  /*! Enable STUN support */
97  /*! Enable RTCP support */
99 
100  /*!
101  * \brief Maximum number of RTP properties supported
102  *
103  * \note THIS MUST BE THE LAST ENTRY IN THIS ENUM.
104  */
106 };
107 
108 /*! Additional RTP options */
110  /*! Remote side is using non-standard G.726 */
112 };
113 
114 /*! RTP DTMF Modes */
116  /*! No DTMF is being carried over the RTP stream */
118  /*! DTMF is being carried out of band using RFC2833 */
120  /*! DTMF is being carried inband over the RTP stream */
122 };
123 
124 /*! Result codes when RTP glue is queried for information */
126  /*! No remote or local bridging is permitted */
128  /*! Move RTP stream to be remote between devices directly */
130  /*! Perform RTP engine level bridging if possible */
132 };
133 
134 /*! Field statistics that can be retrieved from an RTP instance */
136  /*! Retrieve quality information */
138  /*! Retrieve quality information about jitter */
140  /*! Retrieve quality information about packet loss */
142  /*! Retrieve quality information about round trip time */
144 };
145 
146 /*! Statistics that can be retrieved from an RTP instance */
148  /*! Retrieve all statistics */
150  /*! Retrieve number of packets transmitted */
152  /*! Retrieve number of packets received */
154  /*! Retrieve ALL statistics relating to packet loss */
156  /*! Retrieve number of packets lost for transmitting */
158  /*! Retrieve number of packets lost for receiving */
160  /*! Retrieve maximum number of packets lost on remote side */
162  /*! Retrieve minimum number of packets lost on remote side */
164  /*! Retrieve average number of packets lost on remote side */
166  /*! Retrieve standard deviation of packets lost on remote side */
168  /*! Retrieve maximum number of packets lost on local side */
170  /*! Retrieve minimum number of packets lost on local side */
172  /*! Retrieve average number of packets lost on local side */
174  /*! Retrieve standard deviation of packets lost on local side */
176  /*! Retrieve ALL statistics relating to jitter */
178  /*! Retrieve jitter on transmitted packets */
180  /*! Retrieve jitter on received packets */
182  /*! Retrieve maximum jitter on remote side */
184  /*! Retrieve minimum jitter on remote side */
186  /*! Retrieve average jitter on remote side */
188  /*! Retrieve standard deviation jitter on remote side */
190  /*! Retrieve maximum jitter on local side */
192  /*! Retrieve minimum jitter on local side */
194  /*! Retrieve average jitter on local side */
196  /*! Retrieve standard deviation jitter on local side */
198  /*! Retrieve ALL statistics relating to round trip time */
200  /*! Retrieve round trip time */
202  /*! Retrieve maximum round trip time */
204  /*! Retrieve minimum round trip time */
206  /*! Retrieve average round trip time */
208  /*! Retrieve standard deviation round trip time */
210  /*! Retrieve local SSRC */
212  /*! Retrieve remote SSRC */
214 };
215 
216 /* Codes for RTP-specific data - not defined by our AST_FORMAT codes */
217 /*! DTMF (RFC2833) */
218 #define AST_RTP_DTMF (1 << 0)
219 /*! 'Comfort Noise' (RFC3389) */
220 #define AST_RTP_CN (1 << 1)
221 /*! DTMF (Cisco Proprietary) */
222 #define AST_RTP_CISCO_DTMF (1 << 2)
223 /*! Maximum RTP-specific code */
224 #define AST_RTP_MAX AST_RTP_CISCO_DTMF
225 
226 /*! Structure that represents a payload */
228  /*! Is this an Asterisk value */
230  /*! Actual internal value of the payload */
232 };
233 
234 /*! Structure that represents statistics from an RTP instance */
236  /*! Number of packets transmitted */
237  unsigned int txcount;
238  /*! Number of packets received */
239  unsigned int rxcount;
240  /*! Jitter on transmitted packets */
241  double txjitter;
242  /*! Jitter on received packets */
243  double rxjitter;
244  /*! Maximum jitter on remote side */
246  /*! Minimum jitter on remote side */
248  /*! Average jitter on remote side */
250  /*! Standard deviation jitter on remote side */
252  /*! Maximum jitter on local side */
254  /*! Minimum jitter on local side */
256  /*! Average jitter on local side */
258  /*! Standard deviation jitter on local side */
260  /*! Number of transmitted packets lost */
261  unsigned int txploss;
262  /*! Number of received packets lost */
263  unsigned int rxploss;
264  /*! Maximum number of packets lost on remote side */
266  /*! Minimum number of packets lost on remote side */
268  /*! Average number of packets lost on remote side */
270  /*! Standard deviation packets lost on remote side */
272  /*! Maximum number of packets lost on local side */
274  /*! Minimum number of packets lost on local side */
276  /*! Average number of packets lost on local side */
278  /*! Standard deviation packets lost on local side */
280  /*! Total round trip time */
281  double rtt;
282  /*! Maximum round trip time */
283  double maxrtt;
284  /*! Minimum round trip time */
285  double minrtt;
286  /*! Average round trip time */
287  double normdevrtt;
288  /*! Standard deviation round trip time */
289  double stdevrtt;
290  /*! Our SSRC */
291  unsigned int local_ssrc;
292  /*! Their SSRC */
293  unsigned int remote_ssrc;
294 };
295 
296 #define AST_RTP_STAT_SET(current_stat, combined, placement, value) \
297 if (stat == current_stat || stat == AST_RTP_INSTANCE_STAT_ALL || (combined >= 0 && combined == current_stat)) { \
298 placement = value; \
299 if (stat == current_stat) { \
300 return 0; \
301 } \
302 }
303 
304 #define AST_RTP_STAT_TERMINATOR(combined) \
305 if (stat == combined) { \
306 return 0; \
307 }
308 
309 /*! Structure that represents an RTP stack (engine) */
311  /*! Name of the RTP engine, used when explicitly requested */
312  const char *name;
313  /*! Module this RTP engine came from, used for reference counting */
314  struct ast_module *mod;
315  /*! Callback for setting up a new RTP instance */
316  int (*new)(struct ast_rtp_instance *instance, struct sched_context *sched, struct ast_sockaddr *sa, void *data);
317  /*! Callback for destroying an RTP instance */
318  int (*destroy)(struct ast_rtp_instance *instance);
319  /*! Callback for writing out a frame */
320  int (*write)(struct ast_rtp_instance *instance, struct ast_frame *frame);
321  /*! Callback for stopping the RTP instance */
322  void (*stop)(struct ast_rtp_instance *instance);
323  /*! Callback for starting RFC2833 DTMF transmission */
324  int (*dtmf_begin)(struct ast_rtp_instance *instance, char digit);
325  /*! Callback for stopping RFC2833 DTMF transmission */
326  int (*dtmf_end)(struct ast_rtp_instance *instance, char digit);
327  int (*dtmf_end_with_duration)(struct ast_rtp_instance *instance, char digit, unsigned int duration);
328  /*! Callback to indicate that we should update the marker bit */
329  void (*update_source)(struct ast_rtp_instance *instance);
330  /*! Callback to indicate that we should update the marker bit and ssrc */
331  void (*change_source)(struct ast_rtp_instance *instance);
332  /*! Callback for setting an extended RTP property */
333  int (*extended_prop_set)(struct ast_rtp_instance *instance, int property, void *value);
334  /*! Callback for getting an extended RTP property */
335  void *(*extended_prop_get)(struct ast_rtp_instance *instance, int property);
336  /*! Callback for setting an RTP property */
337  void (*prop_set)(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value);
338  /*! Callback for setting a payload */
339  void (*payload_set)(struct ast_rtp_instance *instance, int payload, int astformat, format_t format);
340  /*! Callback for setting packetization preferences */
341  void (*packetization_set)(struct ast_rtp_instance *instance, struct ast_codec_pref *pref);
342  /*! Callback for setting the remote address that RTP is to be sent to */
343  void (*remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa);
344  /*! Callback for setting an alternate remote address */
345  void (*alt_remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa);
346  /*! Callback for changing DTMF mode */
347  int (*dtmf_mode_set)(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode);
348  /*! Callback for getting DTMF mode */
350  /*! Callback for retrieving statistics */
351  int (*get_stat)(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat);
352  /*! Callback for setting QoS values */
353  int (*qos)(struct ast_rtp_instance *instance, int tos, int cos, const char *desc);
354  /*! Callback for retrieving a file descriptor to poll on, not always required */
355  int (*fd)(struct ast_rtp_instance *instance, int rtcp);
356  /*! Callback for initializing RED support */
357  int (*red_init)(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations);
358  /*! Callback for buffering a frame using RED */
359  int (*red_buffer)(struct ast_rtp_instance *instance, struct ast_frame *frame);
360  /*! Callback for reading a frame from the RTP engine */
361  struct ast_frame *(*read)(struct ast_rtp_instance *instance, int rtcp);
362  /*! Callback to locally bridge two RTP instances */
363  int (*local_bridge)(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1);
364  /*! Callback to set the read format */
365  int (*set_read_format)(struct ast_rtp_instance *instance, format_t format);
366  /*! Callback to set the write format */
368  /*! Callback to make two instances compatible */
369  int (*make_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1);
370  /*! Callback to see if two instances are compatible with DTMF */
371  int (*dtmf_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1);
372  /*! Callback to indicate that packets will now flow */
373  int (*activate)(struct ast_rtp_instance *instance);
374  /*! Callback to request that the RTP engine send a STUN BIND request */
375  void (*stun_request)(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username);
376  /*! Callback to get the transcodeable formats supported */
377  format_t (*available_formats)(struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk);
378  /*! Callback to send CNG */
379  int (*sendcng)(struct ast_rtp_instance *instance, int level);
380  /*! Linked list information */
382 };
383 
384 /*! Structure that represents codec and packetization information */
386  /*! Codec packetization preferences */
387  struct ast_codec_pref pref;
388  /*! Payloads present */
390 };
391 
392 /*! Structure that represents the glue that binds an RTP instance to a channel */
393 struct ast_rtp_glue {
394  /*! Name of the channel driver that this glue is responsible for */
395  const char *type;
396  /*! Module that the RTP glue came from */
397  struct ast_module *mod;
398  /*!
399  * \brief Callback for retrieving the RTP instance carrying audio
400  * \note This function increases the reference count on the returned RTP instance.
401  */
402  enum ast_rtp_glue_result (*get_rtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
403  /*!
404  * \brief Callback for retrieving the RTP instance carrying video
405  * \note This function increases the reference count on the returned RTP instance.
406  */
407  enum ast_rtp_glue_result (*get_vrtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
408  /*!
409  * \brief Callback for retrieving the RTP instance carrying text
410  * \note This function increases the reference count on the returned RTP instance.
411  */
412  enum ast_rtp_glue_result (*get_trtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance);
413  /*! Callback for updating the destination that the remote side should send RTP to */
414  int (*update_peer)(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, format_t codecs, int nat_active);
415  /*! Callback for retrieving codecs that the channel can do
416  * \note chan will be locked when this function is called
417  */
418  format_t (*get_codec)(struct ast_channel *chan);
419  /*! Linked list information */
421 };
422 
423 #define ast_rtp_engine_register(engine) ast_rtp_engine_register2(engine, ast_module_info->self)
424 
425 /*!
426  * \brief Register an RTP engine
427  *
428  * \param engine Structure of the RTP engine to register
429  * \param module Module that the RTP engine is part of
430  *
431  * \retval 0 success
432  * \retval -1 failure
433  *
434  * Example usage:
435  *
436  * \code
437  * ast_rtp_engine_register2(&example_rtp_engine, NULL);
438  * \endcode
439  *
440  * This registers the RTP engine declared as example_rtp_engine with the RTP engine core, but does not
441  * associate a module with it.
442  *
443  * \note It is recommended that you use the ast_rtp_engine_register macro so that the module is
444  * associated with the RTP engine and use counting is performed.
445  *
446  * \since 1.8
447  */
448 int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module);
449 
450 /*!
451  * \brief Unregister an RTP engine
452  *
453  * \param engine Structure of the RTP engine to unregister
454  *
455  * \retval 0 success
456  * \retval -1 failure
457  *
458  * Example usage:
459  *
460  * \code
461  * ast_rtp_engine_unregister(&example_rtp_engine);
462  * \endcode
463  *
464  * This unregisters the RTP engine declared as example_rtp_engine from the RTP engine core. If a module
465  * reference was provided when it was registered then this will only be called once the RTP engine is no longer in use.
466  *
467  * \since 1.8
468  */
469 int ast_rtp_engine_unregister(struct ast_rtp_engine *engine);
470 
472 
475 
476 #define ast_rtp_glue_register(glue) ast_rtp_glue_register2(glue, ast_module_info->self)
477 
478 /*!
479  * \brief Register RTP glue
480  *
481  * \param glue The glue to register
482  * \param module Module that the RTP glue is part of
483  *
484  * \retval 0 success
485  * \retval -1 failure
486  *
487  * Example usage:
488  *
489  * \code
490  * ast_rtp_glue_register2(&example_rtp_glue, NULL);
491  * \endcode
492  *
493  * This registers the RTP glue declared as example_rtp_glue with the RTP engine core, but does not
494  * associate a module with it.
495  *
496  * \note It is recommended that you use the ast_rtp_glue_register macro so that the module is
497  * associated with the RTP glue and use counting is performed.
498  *
499  * \since 1.8
500  */
501 int ast_rtp_glue_register2(struct ast_rtp_glue *glue, struct ast_module *module);
502 
503 /*!
504  * \brief Unregister RTP glue
505  *
506  * \param glue The glue to unregister
507  *
508  * \retval 0 success
509  * \retval -1 failure
510  *
511  * Example usage:
512  *
513  * \code
514  * ast_rtp_glue_unregister(&example_rtp_glue);
515  * \endcode
516  *
517  * This unregisters the RTP glue declared as example_rtp_gkue from the RTP engine core. If a module
518  * reference was provided when it was registered then this will only be called once the RTP engine is no longer in use.
519  *
520  * \since 1.8
521  */
522 int ast_rtp_glue_unregister(struct ast_rtp_glue *glue);
523 
524 /*!
525  * \brief Create a new RTP instance
526  *
527  * \param engine_name Name of the engine to use for the RTP instance
528  * \param sched Scheduler context that the RTP engine may want to use
529  * \param sa Address we want to bind to
530  * \param data Unique data for the engine
531  *
532  * \retval non-NULL success
533  * \retval NULL failure
534  *
535  * Example usage:
536  *
537  * \code
538  * struct ast_rtp_instance *instance = NULL;
539  * instance = ast_rtp_instance_new(NULL, sched, &sin, NULL);
540  * \endcode
541  *
542  * This creates a new RTP instance using the default engine and asks the RTP engine to bind to the address given
543  * in the address structure.
544  *
545  * \note The RTP engine does not have to use the address provided when creating an RTP instance. It may choose to use
546  * another depending on it's own configuration.
547  *
548  * \since 1.8
549  */
550 struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name,
551  struct sched_context *sched, const struct ast_sockaddr *sa,
552  void *data);
553 
554 /*!
555  * \brief Destroy an RTP instance
556  *
557  * \param instance The RTP instance to destroy
558  *
559  * \retval 0 success
560  * \retval -1 failure
561  *
562  * Example usage:
563  *
564  * \code
565  * ast_rtp_instance_destroy(instance);
566  * \endcode
567  *
568  * This destroys the RTP instance pointed to by instance. Once this function returns instance no longer points to valid
569  * memory and may not be used again.
570  *
571  * \since 1.8
572  */
573 int ast_rtp_instance_destroy(struct ast_rtp_instance *instance);
574 
575 /*!
576  * \brief Set the data portion of an RTP instance
577  *
578  * \param instance The RTP instance to manipulate
579  * \param data Pointer to data
580  *
581  * Example usage:
582  *
583  * \code
584  * ast_rtp_instance_set_data(instance, blob);
585  * \endcode
586  *
587  * This sets the data pointer on the RTP instance pointed to by 'instance' to
588  * blob.
589  *
590  * \since 1.8
591  */
592 void ast_rtp_instance_set_data(struct ast_rtp_instance *instance, void *data);
593 
594 /*!
595  * \brief Get the data portion of an RTP instance
596  *
597  * \param instance The RTP instance we want the data portion from
598  *
599  * Example usage:
600  *
601  * \code
602  * struct *blob = ast_rtp_instance_get_data(instance);
603  ( \endcode
604  *
605  * This gets the data pointer on the RTP instance pointed to by 'instance'.
606  *
607  * \since 1.8
608  */
609 void *ast_rtp_instance_get_data(struct ast_rtp_instance *instance);
610 
611 /*!
612  * \brief Send a frame out over RTP
613  *
614  * \param instance The RTP instance to send frame out on
615  * \param frame the frame to send out
616  *
617  * \retval 0 success
618  * \retval -1 failure
619  *
620  * Example usage:
621  *
622  * \code
623  * ast_rtp_instance_write(instance, frame);
624  * \endcode
625  *
626  * This gives the frame pointed to by frame to the RTP engine being used for the instance
627  * and asks that it be transmitted to the current remote address set on the RTP instance.
628  *
629  * \since 1.8
630  */
631 int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame);
632 
633 /*!
634  * \brief Receive a frame over RTP
635  *
636  * \param instance The RTP instance to receive frame on
637  * \param rtcp Whether to read in RTCP or not
638  *
639  * \retval non-NULL success
640  * \retval NULL failure
641  *
642  * Example usage:
643  *
644  * \code
645  * struct ast_frame *frame;
646  * frame = ast_rtp_instance_read(instance, 0);
647  * \endcode
648  *
649  * This asks the RTP engine to read in RTP from the instance and return it as an Asterisk frame.
650  *
651  * \since 1.8
652  */
653 struct ast_frame *ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp);
654 
655 /*!
656  * \brief Set the address of the remote endpoint that we are sending RTP to
657  *
658  * \param instance The RTP instance to change the address on
659  * \param address Address to set it to
660  *
661  * \retval 0 success
662  * \retval -1 failure
663  *
664  * Example usage:
665  *
666  * \code
667  * ast_rtp_instance_set_remote_address(instance, &sin);
668  * \endcode
669  *
670  * This changes the remote address that RTP will be sent to on instance to the address given in the sin
671  * structure.
672  *
673  * \since 1.8
674  */
675 int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address);
676 
677 
678 /*!
679  * \brief Set the address of an an alternate RTP address to receive from
680  *
681  * \param instance The RTP instance to change the address on
682  * \param address Address to set it to
683  *
684  * \retval 0 success
685  * \retval -1 failure
686  *
687  * Example usage:
688  *
689  * \code
690  * ast_rtp_instance_set_alt_remote_address(instance, &address);
691  * \endcode
692  *
693  * This changes the alternate remote address that RTP will be sent to on instance to the address given in the sin
694  * structure.
695  *
696  * \since 1.8
697  */
698 int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address);
699 
700 /*!
701  * \brief Set the address that we are expecting to receive RTP on
702  *
703  * \param instance The RTP instance to change the address on
704  * \param address Address to set it to
705  *
706  * \retval 0 success
707  * \retval -1 failure
708  *
709  * Example usage:
710  *
711  * \code
712  * ast_rtp_instance_set_local_address(instance, &sin);
713  * \endcode
714  *
715  * This changes the local address that RTP is expected on to the address given in the sin
716  * structure.
717  *
718  * \since 1.8
719  */
721  const struct ast_sockaddr *address);
722 
723 /*!
724  * \brief Get the local address that we are expecting RTP on
725  *
726  * \param instance The RTP instance to get the address from
727  * \param address The variable to store the address in
728  *
729  * Example usage:
730  *
731  * \code
732  * struct ast_sockaddr address;
733  * ast_rtp_instance_get_local_address(instance, &address);
734  * \endcode
735  *
736  * This gets the local address that we are expecting RTP on and stores it in the 'address' structure.
737  *
738  * \since 1.8
739  */
740 void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
741 
742 /*!
743  * \brief Get the address of the local endpoint that we are sending RTP to, comparing its address to another
744  *
745  * \param instance The instance that we want to get the local address for
746  * \param address An initialized address that may be overwritten if the local address is different
747  *
748  * \retval 0 address was not changed
749  * \retval 1 address was changed
750  * Example usage:
751  *
752  * \code
753  * struct ast_sockaddr address;
754  * int ret;
755  * ret = ast_rtp_instance_get_and_cmp_local_address(instance, &address);
756  * \endcode
757  *
758  * This retrieves the current local address set on the instance pointed to by instance and puts the value
759  * into the address structure.
760  *
761  * \since 1.8
762  */
763 int ast_rtp_instance_get_and_cmp_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
764 
765 /*!
766  * \brief Get the address of the remote endpoint that we are sending RTP to
767  *
768  * \param instance The instance that we want to get the remote address for
769  * \param address A structure to put the address into
770  *
771  * Example usage:
772  *
773  * \code
774  * struct ast_sockaddr address;
775  * ast_rtp_instance_get_remote_address(instance, &address);
776  * \endcode
777  *
778  * This retrieves the current remote address set on the instance pointed to by instance and puts the value
779  * into the address structure.
780  *
781  * \since 1.8
782  */
783 void ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
784 
785 /*!
786  * \brief Get the address of the remote endpoint that we are sending RTP to, comparing its address to another
787  *
788  * \param instance The instance that we want to get the remote address for
789  * \param address An initialized address that may be overwritten if the remote address is different
790  *
791  * \retval 0 address was not changed
792  * \retval 1 address was changed
793  * Example usage:
794  *
795  * \code
796  * struct ast_sockaddr address;
797  * int ret;
798  * ret = ast_rtp_instance_get_and_cmp_remote_address(instance, &address);
799  * \endcode
800  *
801  * This retrieves the current remote address set on the instance pointed to by instance and puts the value
802  * into the address structure.
803  *
804  * \since 1.8
805  */
806 
807 int ast_rtp_instance_get_and_cmp_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
808 
809 /*!
810  * \brief Set the value of an RTP instance extended property
811  *
812  * \param instance The RTP instance to set the extended property on
813  * \param property The extended property to set
814  * \param value The value to set the extended property to
815  *
816  * \since 1.8
817  */
818 void ast_rtp_instance_set_extended_prop(struct ast_rtp_instance *instance, int property, void *value);
819 
820 /*!
821  * \brief Get the value of an RTP instance extended property
822  *
823  * \param instance The RTP instance to get the extended property on
824  * \param property The extended property to get
825  *
826  * \since 1.8
827  */
828 void *ast_rtp_instance_get_extended_prop(struct ast_rtp_instance *instance, int property);
829 
830 /*!
831  * \brief Set the value of an RTP instance property
832  *
833  * \param instance The RTP instance to set the property on
834  * \param property The property to modify
835  * \param value The value to set the property to
836  *
837  * Example usage:
838  *
839  * \code
840  * ast_rtp_instance_set_prop(instance, AST_RTP_PROPERTY_NAT, 1);
841  * \endcode
842  *
843  * This enables the AST_RTP_PROPERTY_NAT property on the instance pointed to by instance.
844  *
845  * \since 1.8
846  */
847 void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value);
848 
849 /*!
850  * \brief Get the value of an RTP instance property
851  *
852  * \param instance The RTP instance to get the property from
853  * \param property The property to get
854  *
855  * \retval Current value of the property
856  *
857  * Example usage:
858  *
859  * \code
860  * ast_rtp_instance_get_prop(instance, AST_RTP_PROPERTY_NAT);
861  * \endcode
862  *
863  * This returns the current value of the NAT property on the instance pointed to by instance.
864  *
865  * \since 1.8
866  */
867 int ast_rtp_instance_get_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property);
868 
869 /*!
870  * \brief Get the codecs structure of an RTP instance
871  *
872  * \param instance The RTP instance to get the codecs structure from
873  *
874  * Example usage:
875  *
876  * \code
877  * struct ast_rtp_codecs *codecs = ast_rtp_instance_get_codecs(instance);
878  * \endcode
879  *
880  * This gets the codecs structure on the RTP instance pointed to by 'instance'.
881  *
882  * \since 1.8
883  */
885 
886 /*!
887  * \brief Clear payload information from an RTP instance
888  *
889  * \param codecs The codecs structure that payloads will be cleared from
890  * \param instance Optionally the instance that the codecs structure belongs to
891  *
892  * Example usage:
893  *
894  * \code
895  * struct ast_rtp_codecs codecs;
896  * ast_rtp_codecs_payloads_clear(&codecs, NULL);
897  * \endcode
898  *
899  * This clears the codecs structure and puts it into a pristine state.
900  *
901  * \since 1.8
902  */
903 void ast_rtp_codecs_payloads_clear(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance);
904 
905 /*!
906  * \brief Set payload information on an RTP instance to the default
907  *
908  * \param codecs The codecs structure to set defaults on
909  * \param instance Optionally the instance that the codecs structure belongs to
910  *
911  * Example usage:
912  *
913  * \code
914  * struct ast_rtp_codecs codecs;
915  * ast_rtp_codecs_payloads_default(&codecs, NULL);
916  * \endcode
917  *
918  * This sets the default payloads on the codecs structure.
919  *
920  * \since 1.8
921  */
922 void ast_rtp_codecs_payloads_default(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance);
923 
924 /*!
925  * \brief Copy payload information from one RTP instance to another
926  *
927  * \param src The source codecs structure
928  * \param dest The destination codecs structure that the values from src will be copied to
929  * \param instance Optionally the instance that the dst codecs structure belongs to
930  *
931  * Example usage:
932  *
933  * \code
934  * ast_rtp_codecs_payloads_copy(&codecs0, &codecs1, NULL);
935  * \endcode
936  *
937  * This copies the payloads from the codecs0 structure to the codecs1 structure, overwriting any current values.
938  *
939  * \since 1.8
940  */
941 void ast_rtp_codecs_payloads_copy(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance);
942 
943 /*!
944  * \brief Record payload information that was seen in an m= SDP line
945  *
946  * \param codecs The codecs structure to muck with
947  * \param instance Optionally the instance that the codecs structure belongs to
948  * \param payload Numerical payload that was seen in the m= SDP line
949  *
950  * Example usage:
951  *
952  * \code
953  * ast_rtp_codecs_payloads_set_m_type(&codecs, NULL, 0);
954  * \endcode
955  *
956  * This records that the numerical payload '0' was seen in the codecs structure.
957  *
958  * \since 1.8
959  */
960 void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload);
961 
962 /*!
963  * \brief Record payload information that was seen in an a=rtpmap: SDP line
964  *
965  * \param codecs The codecs structure to muck with
966  * \param instance Optionally the instance that the codecs structure belongs to
967  * \param payload Numerical payload that was seen in the a=rtpmap: SDP line
968  * \param mimetype The string mime type that was seen
969  * \param mimesubtype The strin mime sub type that was seen
970  * \param options Optional options that may change the behavior of this specific payload
971  *
972  * \retval 0 success
973  * \retval -1 failure, invalid payload numbe
974  * \retval -2 failure, unknown mimetype
975  *
976  * Example usage:
977  *
978  * \code
979  * ast_rtp_codecs_payloads_set_rtpmap_type(&codecs, NULL, 0, "audio", "PCMU", 0);
980  * \endcode
981  *
982  * This records that the numerical payload '0' was seen with mime type 'audio' and sub mime type 'PCMU' in the codecs structure.
983  *
984  * \since 1.8
985  */
986 int ast_rtp_codecs_payloads_set_rtpmap_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload, char *mimetype, char *mimesubtype, enum ast_rtp_options options);
987 
988 /*!
989  * \brief Set payload type to a known MIME media type for a codec with a specific sample rate
990  *
991  * \param codecs RTP structure to modify
992  * \param instance Optionally the instance that the codecs structure belongs to
993  * \param pt Payload type entry to modify
994  * \param mimetype top-level MIME type of media stream (typically "audio", "video", "text", etc.)
995  * \param mimesubtype MIME subtype of media stream (typically a codec name)
996  * \param options Zero or more flags from the ast_rtp_options enum
997  * \param sample_rate The sample rate of the media stream
998  *
999  * This function 'fills in' an entry in the list of possible formats for
1000  * a media stream associated with an RTP structure.
1001  *
1002  * \retval 0 on success
1003  * \retval -1 if the payload type is out of range
1004  * \retval -2 if the mimeType/mimeSubtype combination was not found
1005  *
1006  * \since 1.8
1007  */
1008 int ast_rtp_codecs_payloads_set_rtpmap_type_rate(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int pt,
1009  char *mimetype, char *mimesubtype,
1010  enum ast_rtp_options options,
1011  unsigned int sample_rate);
1012 
1013 /*!
1014  * \brief Remove payload information
1015  *
1016  * \param codecs The codecs structure to muck with
1017  * \param instance Optionally the instance that the codecs structure belongs to
1018  * \param payload Numerical payload to unset
1019  *
1020  * Example usage:
1021  *
1022  * \code
1023  * ast_rtp_codecs_payloads_unset(&codecs, NULL, 0);
1024  * \endcode
1025  *
1026  * This clears the payload '0' from the codecs structure. It will be as if it was never set.
1027  *
1028  * \since 1.8
1029  */
1030 void ast_rtp_codecs_payloads_unset(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload);
1031 
1032 /*!
1033  * \brief Retrieve payload information by payload
1034  *
1035  * \param codecs Codecs structure to look in
1036  * \param payload Numerical payload to look up
1037  *
1038  * \retval Payload information
1039  *
1040  * Example usage:
1041  *
1042  * \code
1043  * struct ast_rtp_payload_type payload_type;
1044  * payload_type = ast_rtp_codecs_payload_lookup(&codecs, 0);
1045  * \endcode
1046  *
1047  * This looks up the information for payload '0' from the codecs structure.
1048  *
1049  * \since 1.8
1050  */
1051 struct ast_rtp_payload_type ast_rtp_codecs_payload_lookup(struct ast_rtp_codecs *codecs, int payload);
1052 
1053 /*!
1054  * \brief Get the sample rate associated with known RTP payload types
1055  *
1056  * \param asterisk_format True if the value in the 'code' parameter is an AST_FORMAT value
1057  * \param code Format code, either from AST_FORMAT list or from AST_RTP list
1058  *
1059  * \return the sample rate if the format was found, zero if it was not found
1060  *
1061  * \since 1.8
1062  */
1064 
1065 /*!
1066  * \brief Retrieve all formats that were found
1067  *
1068  * \param codecs Codecs structure to look in
1069  * \param astformats An integer to put the Asterisk formats in
1070  * \param nonastformats An integer to put the non-Asterisk formats in
1071  *
1072  * Example usage:
1073  *
1074  * \code
1075  * int astformats, nonastformats;
1076  * ast_rtp_codecs_payload_Formats(&codecs, &astformats, &nonastformats);
1077  * \endcode
1078  *
1079  * This retrieves all the formats known about in the codecs structure and puts the Asterisk ones in the integer
1080  * pointed to by astformats and the non-Asterisk ones in the integer pointed to by nonastformats.
1081  *
1082  * \since 1.8
1083  */
1084 void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, format_t *astformats, int *nonastformats);
1085 
1086 /*!
1087  * \brief Retrieve a payload based on whether it is an Asterisk format and the code
1088  *
1089  * \param codecs Codecs structure to look in
1090  * \param asterisk_format Non-zero if the given code is an Asterisk format value
1091  * \param code The format to look for
1092  *
1093  * \retval Numerical payload
1094  *
1095  * Example usage:
1096  *
1097  * \code
1098  * int payload = ast_rtp_codecs_payload_code(&codecs, 1, AST_FORMAT_ULAW);
1099  * \endcode
1100  *
1101  * This looks for the numerical payload for ULAW in the codecs structure.
1102  *
1103  * \since 1.8
1104  */
1105 int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const format_t code);
1106 
1107 /*!
1108  * \brief Retrieve mime subtype information on a payload
1109  *
1110  * \param asterisk_format Non-zero if the given code is an Asterisk format value
1111  * \param code Format to look up
1112  * \param options Additional options that may change the result
1113  *
1114  * \retval Mime subtype success
1115  * \retval NULL failure
1116  *
1117  * Example usage:
1118  *
1119  * \code
1120  * const char *subtype = ast_rtp_lookup_mime_subtype2(1, AST_FORMAT_ULAW, 0);
1121  * \endcode
1122  *
1123  * This looks up the mime subtype for the ULAW format.
1124  *
1125  * \since 1.8
1126  */
1127 const char *ast_rtp_lookup_mime_subtype2(const int asterisk_format, const format_t code, enum ast_rtp_options options);
1128 
1129 /*!
1130  * \brief Convert formats into a string and put them into a buffer
1131  *
1132  * \param buf Buffer to put the mime output into
1133  * \param capability Formats that we are looking up
1134  * \param asterisk_format Non-zero if the given capability are Asterisk format capabilities
1135  * \param options Additional options that may change the result
1136  *
1137  * \retval non-NULL success
1138  * \retval NULL failure
1139  *
1140  * Example usage:
1141  *
1142  * \code
1143  * char buf[256] = "";
1144  * char *mime = ast_rtp_lookup_mime_multiple2(&buf, sizeof(buf), AST_FORMAT_ULAW | AST_FORMAT_ALAW, 1, 0);
1145  * \endcode
1146  *
1147  * This returns the mime values for ULAW and ALAW in the buffer pointed to by buf.
1148  *
1149  * \since 1.8
1150  */
1151 char *ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const format_t capability, const int asterisk_format, enum ast_rtp_options options);
1152 
1153 /*!
1154  * \brief Set codec packetization preferences
1155  *
1156  * \param codecs Codecs structure to muck with
1157  * \param instance Optionally the instance that the codecs structure belongs to
1158  * \param prefs Codec packetization preferences
1159  *
1160  * Example usage:
1161  *
1162  * \code
1163  * ast_rtp_codecs_packetization_set(&codecs, NULL, &prefs);
1164  * \endcode
1165  *
1166  * This sets the packetization preferences pointed to by prefs on the codecs structure pointed to by codecs.
1167  *
1168  * \since 1.8
1169  */
1170 void ast_rtp_codecs_packetization_set(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, struct ast_codec_pref *prefs);
1171 
1172 /*!
1173  * \brief Begin sending a DTMF digit
1174  *
1175  * \param instance The RTP instance to send the DTMF on
1176  * \param digit What DTMF digit to send
1177  *
1178  * \retval 0 success
1179  * \retval -1 failure
1180  *
1181  * Example usage:
1182  *
1183  * \code
1184  * ast_rtp_instance_dtmf_begin(instance, '1');
1185  * \endcode
1186  *
1187  * This starts sending the DTMF '1' on the RTP instance pointed to by instance. It will
1188  * continue being sent until it is ended.
1189  *
1190  * \since 1.8
1191  */
1192 int ast_rtp_instance_dtmf_begin(struct ast_rtp_instance *instance, char digit);
1193 
1194 /*!
1195  * \brief Stop sending a DTMF digit
1196  *
1197  * \param instance The RTP instance to stop the DTMF on
1198  * \param digit What DTMF digit to stop
1199  *
1200  * \retval 0 success
1201  * \retval -1 failure
1202  *
1203  * Example usage:
1204  *
1205  * \code
1206  * ast_rtp_instance_dtmf_end(instance, '1');
1207  * \endcode
1208  *
1209  * This stops sending the DTMF '1' on the RTP instance pointed to by instance.
1210  *
1211  * \since 1.8
1212  */
1213 int ast_rtp_instance_dtmf_end(struct ast_rtp_instance *instance, char digit);
1214 int ast_rtp_instance_dtmf_end_with_duration(struct ast_rtp_instance *instance, char digit, unsigned int duration);
1215 
1216 /*!
1217  * \brief Set the DTMF mode that should be used
1218  *
1219  * \param instance the RTP instance to set DTMF mode on
1220  * \param dtmf_mode The DTMF mode that is in use
1221  *
1222  * \retval 0 success
1223  * \retval -1 failure
1224  *
1225  * Example usage:
1226  *
1227  * \code
1228  * ast_rtp_instance_dtmf_mode_set(instance, AST_RTP_DTMF_MODE_RFC2833);
1229  * \endcode
1230  *
1231  * This sets the RTP instance to use RFC2833 for DTMF transmission and receiving.
1232  *
1233  * \since 1.8
1234  */
1235 int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode);
1236 
1237 /*!
1238  * \brief Get the DTMF mode of an RTP instance
1239  *
1240  * \param instance The RTP instance to get the DTMF mode of
1241  *
1242  * \retval DTMF mode
1243  *
1244  * Example usage:
1245  *
1246  * \code
1247  * enum ast_rtp_dtmf_mode dtmf_mode = ast_rtp_instance_dtmf_mode_get(instance);
1248  * \endcode
1249  *
1250  * This gets the DTMF mode set on the RTP instance pointed to by 'instance'.
1251  *
1252  * \since 1.8
1253  */
1255 
1256 /*!
1257  * \brief Indicate that the RTP marker bit should be set on an RTP stream
1258  *
1259  * \param instance Instance that the new media source is feeding into
1260  *
1261  * Example usage:
1262  *
1263  * \code
1264  * ast_rtp_instance_update_source(instance);
1265  * \endcode
1266  *
1267  * This indicates that the source of media that is feeding the instance pointed to by
1268  * instance has been updated and that the marker bit should be set.
1269  *
1270  * \since 1.8
1271  */
1272 void ast_rtp_instance_update_source(struct ast_rtp_instance *instance);
1273 
1274 /*!
1275  * \brief Indicate a new source of audio has dropped in and the ssrc should change
1276  *
1277  * \param instance Instance that the new media source is feeding into
1278  *
1279  * Example usage:
1280  *
1281  * \code
1282  * ast_rtp_instance_change_source(instance);
1283  * \endcode
1284  *
1285  * This indicates that the source of media that is feeding the instance pointed to by
1286  * instance has changed and that the marker bit should be set and the SSRC updated.
1287  *
1288  * \since 1.8
1289  */
1290 void ast_rtp_instance_change_source(struct ast_rtp_instance *instance);
1291 
1292 /*!
1293  * \brief Set QoS parameters on an RTP session
1294  *
1295  * \param instance Instance to set the QoS parameters on
1296  * \param tos Terms of service value
1297  * \param cos Class of service value
1298  * \param desc What is setting the QoS values
1299  *
1300  * \retval 0 success
1301  * \retval -1 failure
1302  *
1303  * Example usage:
1304  *
1305  * \code
1306  * ast_rtp_instance_set_qos(instance, 0, 0, "Example");
1307  * \endcode
1308  *
1309  * This sets the TOS and COS values to 0 on the instance pointed to by instance.
1310  *
1311  * \since 1.8
1312  */
1313 int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc);
1314 
1315 /*!
1316  * \brief Stop an RTP instance
1317  *
1318  * \param instance Instance that media is no longer going to at this time
1319  *
1320  * Example usage:
1321  *
1322  * \code
1323  * ast_rtp_instance_stop(instance);
1324  * \endcode
1325  *
1326  * This tells the RTP engine being used for the instance pointed to by instance
1327  * that media is no longer going to it at this time, but may in the future.
1328  *
1329  * \since 1.8
1330  */
1331 void ast_rtp_instance_stop(struct ast_rtp_instance *instance);
1332 
1333 /*!
1334  * \brief Get the file descriptor for an RTP session (or RTCP)
1335  *
1336  * \param instance Instance to get the file descriptor for
1337  * \param rtcp Whether to retrieve the file descriptor for RTCP or not
1338  *
1339  * \retval fd success
1340  * \retval -1 failure
1341  *
1342  * Example usage:
1343  *
1344  * \code
1345  * int rtp_fd = ast_rtp_instance_fd(instance, 0);
1346  * \endcode
1347  *
1348  * This retrieves the file descriptor for the socket carrying media on the instance
1349  * pointed to by instance.
1350  *
1351  * \since 1.8
1352  */
1353 int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp);
1354 
1355 /*!
1356  * \brief Get the RTP glue that binds a channel to the RTP engine
1357  *
1358  * \param type Name of the glue we want
1359  *
1360  * \retval non-NULL success
1361  * \retval NULL failure
1362  *
1363  * Example usage:
1364  *
1365  * \code
1366  * struct ast_rtp_glue *glue = ast_rtp_instance_get_glue("Example");
1367  * \endcode
1368  *
1369  * This retrieves the RTP glue that has the name 'Example'.
1370  *
1371  * \since 1.8
1372  */
1373 struct ast_rtp_glue *ast_rtp_instance_get_glue(const char *type);
1374 
1375 /*!
1376  * \brief Bridge two channels that use RTP instances
1377  *
1378  * \param c0 First channel part of the bridge
1379  * \param c1 Second channel part of the bridge
1380  * \param flags Bridging flags
1381  * \param fo If a frame needs to be passed up it is stored here
1382  * \param rc Channel that passed the above frame up
1383  * \param timeoutms How long the channels should be bridged for
1384  *
1385  * \retval Bridge result
1386  *
1387  * \note This should only be used by channel drivers in their technology declaration.
1388  *
1389  * \since 1.8
1390  */
1391 enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
1392 
1393 /*!
1394  * \brief Get the other RTP instance that an instance is bridged to
1395  *
1396  * \param instance The RTP instance that we want
1397  *
1398  * \retval non-NULL success
1399  * \retval NULL failure
1400  *
1401  * Example usage:
1402  *
1403  * \code
1404  * struct ast_rtp_instance *bridged = ast_rtp_instance_get_bridged(instance0);
1405  * \endcode
1406  *
1407  * This gets the RTP instance that instance0 is bridged to.
1408  *
1409  * \since 1.8
1410  */
1412 
1413 /*!
1414  * \brief Make two channels compatible for early bridging
1415  *
1416  * \param c_dst Destination channel to copy to
1417  * \param c_src Source channel to copy from
1418  *
1419  * \since 1.8
1420  */
1421 void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c_dst, struct ast_channel *c_src);
1422 
1423 /*!
1424  * \brief Early bridge two channels that use RTP instances
1425  *
1426  * \param c0 First channel part of the bridge
1427  * \param c1 Second channel part of the bridge
1428  *
1429  * \retval 0 success
1430  * \retval -1 failure
1431  *
1432  * \note This should only be used by channel drivers in their technology declaration.
1433  *
1434  * \since 1.8
1435  */
1436 int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1);
1437 
1438 /*!
1439  * \brief Initialize RED support on an RTP instance
1440  *
1441  * \param instance The instance to initialize RED support on
1442  * \param buffer_time How long to buffer before sending
1443  * \param payloads Payload values
1444  * \param generations Number of generations
1445  *
1446  * \retval 0 success
1447  * \retval -1 failure
1448  *
1449  * \since 1.8
1450  */
1451 int ast_rtp_red_init(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations);
1452 
1453 /*!
1454  * \brief Buffer a frame in an RTP instance for RED
1455  *
1456  * \param instance The instance to buffer the frame on
1457  * \param frame Frame that we want to buffer
1458  *
1459  * \retval 0 success
1460  * \retval -1 failure
1461  *
1462  * \since 1.8
1463  */
1464 int ast_rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame);
1465 
1466 /*!
1467  * \brief Retrieve statistics about an RTP instance
1468  *
1469  * \param instance Instance to get statistics on
1470  * \param stats Structure to put results into
1471  * \param stat What statistic(s) to retrieve
1472  *
1473  * \retval 0 success
1474  * \retval -1 failure
1475  *
1476  * Example usage:
1477  *
1478  * \code
1479  * struct ast_rtp_instance_stats stats;
1480  * ast_rtp_instance_get_stats(instance, &stats, AST_RTP_INSTANCE_STAT_ALL);
1481  * \endcode
1482  *
1483  * This retrieves all statistics the underlying RTP engine supports and puts the values into the
1484  * stats structure.
1485  *
1486  * \since 1.8
1487  */
1488 int ast_rtp_instance_get_stats(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat);
1489 
1490 /*!
1491  * \brief Set standard statistics from an RTP instance on a channel
1492  *
1493  * \param chan Channel to set the statistics on
1494  * \param instance The RTP instance that statistics will be retrieved from
1495  *
1496  * Example usage:
1497  *
1498  * \code
1499  * ast_rtp_instance_set_stats_vars(chan, rtp);
1500  * \endcode
1501  *
1502  * This retrieves standard statistics from the RTP instance rtp and sets it on the channel pointed to
1503  * by chan.
1504  *
1505  * \since 1.8
1506  */
1507 void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_instance *instance);
1508 
1509 /*!
1510  * \brief Retrieve quality statistics about an RTP instance
1511  *
1512  * \param instance Instance to get statistics on
1513  * \param field What quality statistic to retrieve
1514  * \param buf What buffer to put the result into
1515  * \param size Size of the above buffer
1516  *
1517  * \retval non-NULL success
1518  * \retval NULL failure
1519  *
1520  * Example usage:
1521  *
1522  * \code
1523  * char quality[AST_MAX_USER_FIELD];
1524  * ast_rtp_instance_get_quality(instance, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, &buf, sizeof(buf));
1525  * \endcode
1526  *
1527  * This retrieves general quality statistics and places a text representation into the buf pointed to by buf.
1528  *
1529  * \since 1.8
1530  */
1531 char *ast_rtp_instance_get_quality(struct ast_rtp_instance *instance, enum ast_rtp_instance_stat_field field, char *buf, size_t size);
1532 
1533 /*!
1534  * \brief Request that the underlying RTP engine provide audio frames in a specific format
1535  *
1536  * \param instance The RTP instance to change read format on
1537  * \param format Format that frames are wanted in
1538  *
1539  * \retval 0 success
1540  * \retval -1 failure
1541  *
1542  * Example usage:
1543  *
1544  * \code
1545  * ast_rtp_instance_set_read_format(instance, AST_FORMAT_ULAW);
1546  * \endcode
1547  *
1548  * This requests that the RTP engine provide audio frames in the ULAW format.
1549  *
1550  * \since 1.8
1551  */
1553 
1554 /*!
1555  * \brief Tell underlying RTP engine that audio frames will be provided in a specific format
1556  *
1557  * \param instance The RTP instance to change write format on
1558  * \param format Format that frames will be provided in
1559  *
1560  * \retval 0 success
1561  * \retval -1 failure
1562  *
1563  * Example usage:
1564  *
1565  * \code
1566  * ast_rtp_instance_set_write_format(instance, AST_FORMAT_ULAW);
1567  * \endcode
1568  *
1569  * This tells the underlying RTP engine that audio frames will be provided to it in ULAW format.
1570  *
1571  * \since 1.8
1572  */
1574 
1575 /*!
1576  * \brief Request that the underlying RTP engine make two RTP instances compatible with eachother
1577  *
1578  * \param chan Our own Asterisk channel
1579  * \param instance The first RTP instance
1580  * \param peer The peer Asterisk channel
1581  *
1582  * \retval 0 success
1583  * \retval -1 failure
1584  *
1585  * Example usage:
1586  *
1587  * \code
1588  * ast_rtp_instance_make_compatible(instance, peer);
1589  * \endcode
1590  *
1591  * This makes the RTP instance for 'peer' compatible with 'instance' and vice versa.
1592  *
1593  * \since 1.8
1594  */
1595 int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_channel *peer);
1596 
1597 /*! \brief Request the formats that can be transcoded
1598  *
1599  * \param instance The RTP instance
1600  * \param to_endpoint Formats being sent/received towards the endpoint
1601  * \param to_asterisk Formats being sent/received towards Asterisk
1602  *
1603  * \retval supported formats
1604  *
1605  * Example usage:
1606  *
1607  * \code
1608  * ast_rtp_instance_available_formats(instance, AST_FORMAT_ULAW, AST_FORMAT_SLINEAR);
1609  * \endcode
1610  *
1611  * This sees if it is possible to have ulaw communicated to the endpoint but signed linear received into Asterisk.
1612  *
1613  * \since 1.8
1614  */
1615 format_t ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk);
1616 
1617 /*!
1618  * \brief Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance
1619  *
1620  * \param instance The RTP instance
1621  *
1622  * \retval 0 success
1623  * \retval -1 failure
1624  *
1625  * Example usage:
1626  *
1627  * \code
1628  * ast_rtp_instance_activate(instance);
1629  * \endcode
1630  *
1631  * This tells the underlying RTP engine of instance that packets will now flow.
1632  *
1633  * \since 1.8
1634  */
1635 int ast_rtp_instance_activate(struct ast_rtp_instance *instance);
1636 
1637 /*!
1638  * \brief Request that the underlying RTP engine send a STUN BIND request
1639  *
1640  * \param instance The RTP instance
1641  * \param suggestion The suggested destination
1642  * \param username Optionally a username for the request
1643  *
1644  * Example usage:
1645  *
1646  * \code
1647  * ast_rtp_instance_stun_request(instance, NULL, NULL);
1648  * \endcode
1649  *
1650  * This requests that the RTP engine send a STUN BIND request on the session pointed to by
1651  * 'instance'.
1652  *
1653  * \since 1.8
1654  */
1655 void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username);
1656 
1657 /*!
1658  * \brief Set the RTP timeout value
1659  *
1660  * \param instance The RTP instance
1661  * \param timeout Value to set the timeout to
1662  *
1663  * Example usage:
1664  *
1665  * \code
1666  * ast_rtp_instance_set_timeout(instance, 5000);
1667  * \endcode
1668  *
1669  * This sets the RTP timeout value on 'instance' to be 5000.
1670  *
1671  * \since 1.8
1672  */
1673 void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout);
1674 
1675 /*!
1676  * \brief Set the RTP timeout value for when the instance is on hold
1677  *
1678  * \param instance The RTP instance
1679  * \param timeout Value to set the timeout to
1680  *
1681  * Example usage:
1682  *
1683  * \code
1684  * ast_rtp_instance_set_hold_timeout(instance, 5000);
1685  * \endcode
1686  *
1687  * This sets the RTP hold timeout value on 'instance' to be 5000.
1688  *
1689  * \since 1.8
1690  */
1691 void ast_rtp_instance_set_hold_timeout(struct ast_rtp_instance *instance, int timeout);
1692 
1693 /*!
1694  * \brief Set the RTP keepalive interval
1695  *
1696  * \param instance The RTP instance
1697  * \param period Value to set the keepalive interval to
1698  *
1699  * Example usage:
1700  *
1701  * \code
1702  * ast_rtp_instance_set_keepalive(instance, 5000);
1703  * \endcode
1704  *
1705  * This sets the RTP keepalive interval on 'instance' to be 5000.
1706  *
1707  * \since 1.8
1708  */
1709 void ast_rtp_instance_set_keepalive(struct ast_rtp_instance *instance, int timeout);
1710 
1711 /*!
1712  * \brief Get the RTP timeout value
1713  *
1714  * \param instance The RTP instance
1715  *
1716  * \retval timeout value
1717  *
1718  * Example usage:
1719  *
1720  * \code
1721  * int timeout = ast_rtp_instance_get_timeout(instance);
1722  * \endcode
1723  *
1724  * This gets the RTP timeout value for the RTP instance pointed to by 'instance'.
1725  *
1726  * \since 1.8
1727  */
1728 int ast_rtp_instance_get_timeout(struct ast_rtp_instance *instance);
1729 
1730 /*!
1731  * \brief Get the RTP timeout value for when an RTP instance is on hold
1732  *
1733  * \param instance The RTP instance
1734  *
1735  * \retval timeout value
1736  *
1737  * Example usage:
1738  *
1739  * \code
1740  * int timeout = ast_rtp_instance_get_hold_timeout(instance);
1741  * \endcode
1742  *
1743  * This gets the RTP hold timeout value for the RTP instance pointed to by 'instance'.
1744  *
1745  * \since 1.8
1746  */
1748 
1749 /*!
1750  * \brief Get the RTP keepalive interval
1751  *
1752  * \param instance The RTP instance
1753  *
1754  * \retval period Keepalive interval value
1755  *
1756  * Example usage:
1757  *
1758  * \code
1759  * int interval = ast_rtp_instance_get_keepalive(instance);
1760  * \endcode
1761  *
1762  * This gets the RTP keepalive interval value for the RTP instance pointed to by 'instance'.
1763  *
1764  * \since 1.8
1765  */
1766 int ast_rtp_instance_get_keepalive(struct ast_rtp_instance *instance);
1767 
1768 /*!
1769  * \brief Get the RTP engine in use on an RTP instance
1770  *
1771  * \param instance The RTP instance
1772  *
1773  * \retval pointer to the engine
1774  *
1775  * Example usage:
1776  *
1777  * \code
1778  * struct ast_rtp_engine *engine = ast_rtp_instance_get_engine(instance);
1779  * \endcode
1780  *
1781  * This gets the RTP engine currently in use on the RTP instance pointed to by 'instance'.
1782  *
1783  * \since 1.8
1784  */
1786 
1787 /*!
1788  * \brief Get the RTP glue in use on an RTP instance
1789  *
1790  * \param instance The RTP instance
1791  *
1792  * \retval pointer to the glue
1793  *
1794  * Example:
1795  *
1796  * \code
1797  * struct ast_rtp_glue *glue = ast_rtp_instance_get_active_glue(instance);
1798  * \endcode
1799  *
1800  * This gets the RTP glue currently in use on the RTP instance pointed to by 'instance'.
1801  *
1802  * \since 1.8
1803  */
1805 
1806 /*!
1807  * \brief Get the channel that is associated with an RTP instance while in a bridge
1808  *
1809  * \param instance The RTP instance
1810  *
1811  * \retval pointer to the channel
1812  *
1813  * Example:
1814  *
1815  * \code
1816  * struct ast_channel *chan = ast_rtp_instance_get_chan(instance);
1817  * \endcode
1818  *
1819  * This gets the channel associated with the RTP instance pointed to by 'instance'.
1820  *
1821  * \note This will only return a channel while in a local or remote bridge.
1822  *
1823  * \since 1.8
1824  */
1825 struct ast_channel *ast_rtp_instance_get_chan(struct ast_rtp_instance *instance);
1826 
1827 /*!
1828  * \brief Send a comfort noise packet to the RTP instance
1829  *
1830  * \param instance The RTP instance
1831  * \param level Magnitude of the noise level
1832  *
1833  * \retval 0 Success
1834  * \retval non-zero Failure
1835  */
1836 int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level);
1837 
1838 /*!
1839  * \brief Add or replace the SRTP policies for the given RTP instance
1840  *
1841  * \param instance the RTP instance
1842  * \param remote_policy the remote endpoint's policy
1843  * \param local_policy our policy for this RTP instance's remote endpoint
1844  *
1845  * \retval 0 Success
1846  * \retval non-zero Failure
1847  */
1848 int ast_rtp_instance_add_srtp_policy(struct ast_rtp_instance *instance, struct ast_srtp_policy* remote_policy, struct ast_srtp_policy *local_policy);
1849 
1850 /*!
1851  * \brief Obtain the SRTP instance associated with an RTP instance
1852  *
1853  * \param instance the RTP instance
1854  * \retval the SRTP instance on success
1855  * \retval NULL if no SRTP instance exists
1856  */
1857 struct ast_srtp *ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance);
1858 
1859 #if defined(__cplusplus) || defined(c_plusplus)
1860 }
1861 #endif
1862 
1863 #endif /* _ASTERISK_RTP_ENGINE_H */
void ast_rtp_codecs_packetization_set(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, struct ast_codec_pref *prefs)
Set codec packetization preferences.
Definition: rtp_engine.c:727
int(* qos)(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
Definition: rtp_engine.h:353
int ast_rtp_instance_activate(struct ast_rtp_instance *instance)
Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance...
Definition: rtp_engine.c:1744
enum ast_rtp_dtmf_mode(* dtmf_mode_get)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:349
Main Channel structure associated with a channel.
Definition: channel.h:742
int(* activate)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:373
int ast_rtp_red_init(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations)
Initialize RED support on an RTP instance.
Definition: rtp_engine.c:1594
ast_rtp_options
Definition: rtp_engine.h:109
void(* stun_request)(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username)
Definition: rtp_engine.h:375
void * ast_rtp_instance_get_extended_prop(struct ast_rtp_instance *instance, int property)
Get the value of an RTP instance extended property.
Definition: rtp_engine.c:460
int(* set_write_format)(struct ast_rtp_instance *instance, format_t format)
Definition: rtp_engine.h:367
int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
Set the DTMF mode that should be used.
Definition: rtp_engine.c:750
struct ast_rtp_payload_type ast_rtp_codecs_payload_lookup(struct ast_rtp_codecs *codecs, int payload)
Retrieve payload information by payload.
Definition: rtp_engine.c:618
void ast_rtp_instance_change_source(struct ast_rtp_instance *instance)
Indicate a new source of audio has dropped in and the ssrc should change.
Definition: rtp_engine.c:767
int(* dtmf_end)(struct ast_rtp_instance *instance, char digit)
Definition: rtp_engine.h:326
void(* stop)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:322
int ast_rtp_instance_get_stats(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
Retrieve statistics about an RTP instance.
Definition: rtp_engine.c:1604
static unsigned int tos
Definition: chan_h323.c:146
int(* red_buffer)(struct ast_rtp_instance *instance, struct ast_frame *frame)
Definition: rtp_engine.h:359
int ast_rtp_instance_get_timeout(struct ast_rtp_instance *instance)
Get the RTP timeout value.
Definition: rtp_engine.c:1773
int ast_rtp_glue_register2(struct ast_rtp_glue *glue, struct ast_module *module)
Register RTP glue.
Definition: rtp_engine.c:237
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
Definition: rtp_engine.c:483
struct ast_rtp_glue * ast_rtp_instance_get_active_glue(struct ast_rtp_instance *instance)
Get the RTP glue in use on an RTP instance.
Definition: rtp_engine.c:1793
int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Set the address of an an alternate RTP address to receive from.
Definition: rtp_engine.c:405
int(* extended_prop_set)(struct ast_rtp_instance *instance, int property, void *value)
Definition: rtp_engine.h:333
unsigned int txcount
Definition: rtp_engine.h:237
int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
Early bridge two channels that use RTP instances.
Definition: rtp_engine.c:1509
int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
Set QoS parameters on an RTP session.
Definition: rtp_engine.c:774
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
Definition: rtp_engine.c:374
Definition: sched.c:57
int(* write)(struct ast_rtp_instance *instance, struct ast_frame *frame)
Definition: rtp_engine.h:320
unsigned int rxploss
Definition: rtp_engine.h:263
void(* remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa)
Definition: rtp_engine.h:343
int(* destroy)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:318
int(* dtmf_begin)(struct ast_rtp_instance *instance, char digit)
Definition: rtp_engine.h:324
void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout)
Set the RTP timeout value.
Definition: rtp_engine.c:1758
int(* dtmf_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1)
Definition: rtp_engine.h:371
int ast_rtp_instance_make_compatible(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_channel *peer)
Request that the underlying RTP engine make two RTP instances compatible with eachother.
Definition: rtp_engine.c:1693
int(* make_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1)
Definition: rtp_engine.h:369
int ast_rtp_instance_add_srtp_policy(struct ast_rtp_instance *instance, struct ast_srtp_policy *remote_policy, struct ast_srtp_policy *local_policy)
Add or replace the SRTP policies for the given RTP instance.
Definition: rtp_engine.c:1829
int(* get_stat)(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
Definition: rtp_engine.h:351
int(* sendcng)(struct ast_rtp_instance *instance, int level)
Definition: rtp_engine.h:379
int value
Definition: syslog.c:39
static struct ast_srtp_res srtp_res
Definition: res_srtp.c:89
struct ast_srtp * ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance)
Obtain the SRTP instance associated with an RTP instance.
Definition: rtp_engine.c:1849
Socket address structure.
Definition: netsock2.h:63
const char * type
Definition: rtp_engine.h:395
void ast_rtp_engine_unregister_srtp(void)
Definition: rtp_engine.c:1818
int(* dtmf_end_with_duration)(struct ast_rtp_instance *instance, char digit, unsigned int duration)
Definition: rtp_engine.h:327
struct sched_context * sched
Definition: chan_sip.c:782
void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username)
Request that the underlying RTP engine send a STUN BIND request.
Definition: rtp_engine.c:1749
#define AST_RTP_MAX_PT
Definition: rtp_engine.h:79
void ast_rtp_instance_stop(struct ast_rtp_instance *instance)
Stop an RTP instance.
Definition: rtp_engine.c:779
void(* payload_set)(struct ast_rtp_instance *instance, int payload, int astformat, format_t format)
Definition: rtp_engine.h:339
int ast_rtp_engine_unregister(struct ast_rtp_engine *engine)
Unregister an RTP engine.
Definition: rtp_engine.c:222
void ast_rtp_instance_set_data(struct ast_rtp_instance *instance, void *data)
Set the data portion of an RTP instance.
Definition: rtp_engine.c:364
ast_rtp_instance_stat
Definition: rtp_engine.h:147
Maximum number of RTP properties supported.
Definition: rtp_engine.h:105
Asterisk internal frame definitions.
Scheduler Routines (derived from cheops)
int(* dtmf_mode_set)(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
Definition: rtp_engine.h:347
int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Set the address of the remote endpoint that we are sending RTP to.
Definition: rtp_engine.c:391
struct ast_channel * chan
Definition: rtp_engine.c:78
struct ast_rtp_engine * ast_rtp_instance_get_engine(struct ast_rtp_instance *instance)
Get the RTP engine in use on an RTP instance.
Definition: rtp_engine.c:1788
void(* packetization_set)(struct ast_rtp_instance *instance, struct ast_codec_pref *pref)
Definition: rtp_engine.h:341
void ast_rtp_instance_set_extended_prop(struct ast_rtp_instance *instance, int property, void *value)
Set the value of an RTP instance extended property.
Definition: rtp_engine.c:453
char * ast_rtp_instance_get_quality(struct ast_rtp_instance *instance, enum ast_rtp_instance_stat_field field, char *buf, size_t size)
Retrieve quality statistics about an RTP instance.
Definition: rtp_engine.c:1609
ast_rtp_glue_result
Definition: rtp_engine.h:125
static struct ast_srtp_policy_res policy_res
Definition: res_srtp.c:101
int ast_rtp_codecs_payloads_set_rtpmap_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload, char *mimetype, char *mimesubtype, enum ast_rtp_options options)
Record payload information that was seen in an a=rtpmap: SDP line.
Definition: rtp_engine.c:597
Network socket handling.
unsigned int rxcount
Definition: rtp_engine.h:239
int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Set the address that we are expecting to receive RTP on.
Definition: rtp_engine.c:384
struct ast_module * mod
Definition: rtp_engine.h:314
static const char desc[]
Definition: cdr_radius.c:85
int ast_rtp_engine_register_srtp(struct ast_srtp_res *srtp_res, struct ast_srtp_policy_res *policy_res)
Definition: rtp_engine.c:1803
int ast_rtp_instance_get_hold_timeout(struct ast_rtp_instance *instance)
Get the RTP timeout value for when an RTP instance is on hold.
Definition: rtp_engine.c:1778
int(* local_bridge)(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1)
Definition: rtp_engine.h:363
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
int64_t format_t
Definition: frame_defs.h:32
unsigned int local_ssrc
Definition: rtp_engine.h:291
int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level)
Send a comfort noise packet to the RTP instance.
Definition: rtp_engine.c:1854
static struct ast_codec_pref prefs
Definition: chan_iax2.c:258
int(* red_init)(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations)
Definition: rtp_engine.h:357
unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, format_t code)
Get the sample rate associated with known RTP payload types.
Definition: rtp_engine.c:690
void(* prop_set)(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Definition: rtp_engine.h:337
struct ast_module * mod
Definition: rtp_engine.h:397
int ast_rtp_instance_dtmf_begin(struct ast_rtp_instance *instance, char digit)
Begin sending a DTMF digit.
Definition: rtp_engine.c:736
void(* change_source)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:331
int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, format_t format)
Request that the underlying RTP engine provide audio frames in a specific format. ...
Definition: rtp_engine.c:1683
int(* set_read_format)(struct ast_rtp_instance *instance, format_t format)
Definition: rtp_engine.h:365
struct ast_channel * ast_rtp_instance_get_chan(struct ast_rtp_instance *instance)
Get the channel that is associated with an RTP instance while in a bridge.
Definition: rtp_engine.c:1798
unsigned int txploss
Definition: rtp_engine.h:261
void * ast_rtp_instance_get_data(struct ast_rtp_instance *instance)
Get the data portion of an RTP instance.
Definition: rtp_engine.c:369
void ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the address of the remote endpoint that we are sending RTP to.
Definition: rtp_engine.c:447
void ast_rtp_instance_set_hold_timeout(struct ast_rtp_instance *instance, int timeout)
Set the RTP timeout value for when the instance is on hold.
Definition: rtp_engine.c:1763
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
Definition: rtp_engine.c:786
static format_t capability
Definition: chan_mgcp.c:228
const char * name
Definition: rtp_engine.h:312
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
Definition: rtp_engine.c:308
const char * ast_rtp_lookup_mime_subtype2(const int asterisk_format, const format_t code, enum ast_rtp_options options)
Retrieve mime subtype information on a payload.
Definition: rtp_engine.c:673
ast_rtp_dtmf_mode
Definition: rtp_engine.h:115
void(* update_source)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:329
static const char type[]
Definition: chan_nbs.c:57
void ast_rtp_codecs_payloads_clear(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance)
Clear payload information from an RTP instance.
Definition: rtp_engine.c:488
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
Definition: rtp_engine.c:430
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
Definition: rtp_engine.c:301
ast_rtp_property
Definition: rtp_engine.h:88
#define AST_RWLIST_ENTRY
Definition: linkedlists.h:414
void ast_rtp_instance_set_keepalive(struct ast_rtp_instance *instance, int timeout)
Set the RTP keepalive interval.
Definition: rtp_engine.c:1768
void ast_rtp_codecs_payloads_copy(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
Copy payload information from one RTP instance to another.
Definition: rtp_engine.c:516
ast_rtp_instance_stat_field
Definition: rtp_engine.h:135
int(* fd)(struct ast_rtp_instance *instance, int rtcp)
Definition: rtp_engine.h:355
format_t ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk)
Request the formats that can be transcoded.
Definition: rtp_engine.c:1733
int ast_rtp_red_buffer(struct ast_rtp_instance *instance, struct ast_frame *frame)
Buffer a frame in an RTP instance for RED.
Definition: rtp_engine.c:1599
void ast_rtp_codecs_payloads_unset(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
Remove payload information.
Definition: rtp_engine.c:602
struct ast_rtp_instance * ast_rtp_instance_get_bridged(struct ast_rtp_instance *instance)
Get the other RTP instance that an instance is bridged to.
Definition: rtp_engine.c:1418
int ast_rtp_engine_srtp_is_registered(void)
Definition: rtp_engine.c:1824
int ast_rtp_glue_unregister(struct ast_rtp_glue *glue)
Unregister RTP glue.
Definition: rtp_engine.c:266
int ast_rtp_instance_get_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property)
Get the value of an RTP instance property.
Definition: rtp_engine.c:478
format_t(* available_formats)(struct ast_rtp_instance *instance, format_t to_endpoint, format_t to_asterisk)
Definition: rtp_engine.h:377
int ast_rtp_codecs_payloads_set_rtpmap_type_rate(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int pt, char *mimetype, char *mimesubtype, enum ast_rtp_options options, unsigned int sample_rate)
Set payload type to a known MIME media type for a codec with a specific sample rate.
Definition: rtp_engine.c:548
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance)
Get the DTMF mode of an RTP instance.
Definition: rtp_engine.c:755
void ast_rtp_instance_set_stats_vars(struct ast_channel *chan, struct ast_rtp_instance *instance)
Set standard statistics from an RTP instance on a channel.
Definition: rtp_engine.c:1649
Data structure associated with a single frame of data.
Definition: frame.h:142
int ast_rtp_instance_get_keepalive(struct ast_rtp_instance *instance)
Get the RTP keepalive interval.
Definition: rtp_engine.c:1783
int ast_rtp_instance_get_and_cmp_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the address of the local endpoint that we are sending RTP to, comparing its address to another...
Definition: rtp_engine.c:419
SRTP resource.
static void update_peer(struct sip_peer *p, int expire)
Update peer data in database (if used)
Definition: chan_sip.c:4883
void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Set the value of an RTP instance property.
Definition: rtp_engine.c:469
int ast_rtp_instance_get_and_cmp_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the address of the remote endpoint that we are sending RTP to, comparing its address to another...
Definition: rtp_engine.c:436
void(* alt_remote_address_set)(struct ast_rtp_instance *instance, struct ast_sockaddr *sa)
Definition: rtp_engine.h:345
int ast_rtp_instance_dtmf_end_with_duration(struct ast_rtp_instance *instance, char digit, unsigned int duration)
Definition: rtp_engine.c:745
static unsigned int cos
Definition: chan_h323.c:147
int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, format_t format)
Tell underlying RTP engine that audio frames will be provided in a specific format.
Definition: rtp_engine.c:1688
struct ast_rtp_glue * ast_rtp_instance_get_glue(const char *type)
Get the RTP glue that binds a channel to the RTP engine.
Definition: rtp_engine.c:791
void ast_rtp_instance_early_bridge_make_compatible(struct ast_channel *c_dst, struct ast_channel *c_src)
Make two channels compatible for early bridging.
Definition: rtp_engine.c:1423
char * ast_rtp_lookup_mime_multiple2(struct ast_str *buf, const format_t capability, const int asterisk_format, enum ast_rtp_options options)
Convert formats into a string and put them into a buffer.
Definition: rtp_engine.c:703
void ast_rtp_instance_update_source(struct ast_rtp_instance *instance)
Indicate that the RTP marker bit should be set on an RTP stream.
Definition: rtp_engine.c:760
static snd_pcm_format_t format
Definition: chan_alsa.c:93
int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const format_t code)
Retrieve a payload based on whether it is an Asterisk format and the code.
Definition: rtp_engine.c:654
void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
Record payload information that was seen in an m= SDP line.
Definition: rtp_engine.c:532
void ast_rtp_codecs_payloads_default(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance)
Set payload information on an RTP instance to the default.
Definition: rtp_engine.c:501
int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module)
Register an RTP engine.
Definition: rtp_engine.c:188
struct ast_rtp_codecs codecs
Definition: rtp_engine.c:68
void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, format_t *astformats, int *nonastformats)
Retrieve all formats that were found.
Definition: rtp_engine.c:636
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
Definition: rtp_engine.c:379
unsigned int remote_ssrc
Definition: rtp_engine.h:293
ast_bridge_result
Definition: channel.h:168
enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
Bridge two channels that use RTP instances.
Definition: rtp_engine.c:1274
int ast_rtp_instance_dtmf_end(struct ast_rtp_instance *instance, char digit)
Stop sending a DTMF digit.
Definition: rtp_engine.c:741