Asterisk - The Open Source Telephony Project GIT-master-77d630f
Data Structures | Macros | Enumerations | Functions
rtp_engine.h File Reference

Pluggable RTP Architecture. More...

#include "asterisk/astobj2.h"
#include "asterisk/frame.h"
#include "asterisk/format_cap.h"
#include "asterisk/netsock2.h"
#include "asterisk/sched.h"
#include "asterisk/res_srtp.h"
#include "asterisk/stasis.h"
#include "asterisk/vector.h"
#include "asterisk/logger_category.h"
Include dependency graph for rtp_engine.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_rtp_codecs
 
struct  ast_rtp_dtls_cfg
 DTLS configuration structure. More...
 
struct  ast_rtp_engine
 
struct  ast_rtp_engine_dtls
 Structure that represents the optional DTLS SRTP support within an RTP engine. More...
 
struct  ast_rtp_engine_ice
 Structure that represents the optional ICE support within an RTP engine. More...
 
struct  ast_rtp_engine_ice_candidate
 Structure for an ICE candidate. More...
 
struct  ast_rtp_glue
 
struct  ast_rtp_instance_stats
 
struct  ast_rtp_payload_type
 
struct  ast_rtp_rtcp_feedback
 An object that represents data received in a feedback report. More...
 
struct  ast_rtp_rtcp_feedback_remb
 A REMB feedback message (see draft-alvestrand-rmcat-remb-03 for details) More...
 
struct  ast_rtp_rtcp_report
 An object that represents data sent during a SR/RR RTCP report. More...
 
struct  ast_rtp_rtcp_report_block
 A report block within a SR/RR report. More...
 

Macros

#define AST_DEBUG_CATEGORY_DTLS   ast_debug_category_dtls_id() /* DTLS debug logging category id */
 
#define AST_DEBUG_CATEGORY_DTLS_PACKET   ast_debug_category_dtls_packet_id() /* DTLS packet debug logging category id */
 
#define AST_DEBUG_CATEGORY_ICE   ast_debug_category_ice_id() /* ICE debug logging category id */
 
#define AST_DEBUG_CATEGORY_RTCP   ast_debug_category_rtcp_id() /* RTCP debug logging category id */
 
#define AST_DEBUG_CATEGORY_RTCP_PACKET   ast_debug_category_rtcp_packet_id() /* RTCP packet debug logging category id */
 
#define AST_DEBUG_CATEGORY_RTP   ast_debug_category_rtp_id() /* RTP debug logging category id */
 
#define AST_DEBUG_CATEGORY_RTP_PACKET   ast_debug_category_rtp_packet_id() /* RTP packet debug logging category id */
 
#define ast_debug_dtls(sublevel, ...)    ast_debug_category(sublevel, AST_DEBUG_CATEGORY_DTLS, __VA_ARGS__)
 Log debug level DTLS information. More...
 
#define ast_debug_dtls_packet_is_allowed    ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_DTLS_PACKET)
 
#define ast_debug_ice(sublevel, ...)    ast_debug_category(sublevel, AST_DEBUG_CATEGORY_ICE, __VA_ARGS__)
 Log debug level ICE information. More...
 
#define ast_debug_rtcp(sublevel, ...)    ast_debug_category(sublevel, AST_DEBUG_CATEGORY_RTCP, __VA_ARGS__)
 Log debug level RTCP information. More...
 
#define ast_debug_rtcp_is_allowed    ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTCP)
 
#define ast_debug_rtcp_packet_is_allowed    ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTCP_PACKET)
 
#define ast_debug_rtp(sublevel, ...)    ast_debug_category(sublevel, AST_DEBUG_CATEGORY_RTP, __VA_ARGS__)
 Log debug level RTP information. More...
 
#define ast_debug_rtp_is_allowed    ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTP)
 
#define ast_debug_rtp_packet_is_allowed    ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTP_PACKET)
 
#define AST_LOG_CATEGORY_DTLS   "dtls"
 
#define AST_LOG_CATEGORY_DTLS_PACKET   "dtls_packet"
 
#define AST_LOG_CATEGORY_ICE   "ice"
 
#define AST_LOG_CATEGORY_RTCP   "rtcp"
 
#define AST_LOG_CATEGORY_RTCP_PACKET   "rtcp_packet"
 
#define AST_LOG_CATEGORY_RTP   "rtp"
 
#define AST_LOG_CATEGORY_RTP_PACKET   "rtp_packet"
 
#define AST_RED_MAX_GENERATION   5
 
#define AST_RTP_CISCO_DTMF   (1 << 2)
 
#define AST_RTP_CN   (1 << 1)
 
#define AST_RTP_CODECS_NULL_INIT
 
#define AST_RTP_DTMF   (1 << 0)
 
#define ast_rtp_engine_register(engine)   ast_rtp_engine_register2(engine, AST_MODULE_SELF)
 
#define ast_rtp_glue_register(glue)   ast_rtp_glue_register2(glue, AST_MODULE_SELF)
 
#define ast_rtp_instance_get_and_cmp_remote_address(instance, address)    ast_rtp_instance_get_and_cmp_requested_target_address((instance), (address))
 Get the address of the remote endpoint that we are sending RTP to, comparing its address to another. More...
 
#define ast_rtp_instance_get_remote_address(instance, address)    ast_rtp_instance_get_incoming_source_address((instance), (address))
 Get the address of the remote endpoint that we are sending RTP to. More...
 
#define ast_rtp_instance_set_remote_address(instance, address)    ast_rtp_instance_set_requested_target_address((instance), (address))
 Set the address of the remote endpoint that we are sending RTP to. More...
 
#define AST_RTP_MAX   AST_RTP_CISCO_DTMF
 
#define AST_RTP_MAX_PT   128
 
#define AST_RTP_PT_FIRST_DYNAMIC   96
 
#define AST_RTP_PT_LAST_REASSIGN   63
 
#define AST_RTP_PT_LAST_STATIC   34
 
#define AST_RTP_RTCP_FMT_FIR   4
 
#define AST_RTP_RTCP_FMT_NACK   1
 
#define AST_RTP_RTCP_FMT_PLI   1
 
#define AST_RTP_RTCP_FMT_REMB   15
 
#define AST_RTP_RTCP_FMT_TRANSPORT_WIDE_CC   15
 
#define AST_RTP_RTCP_PSFB   206
 
#define AST_RTP_RTCP_RR   201
 
#define AST_RTP_RTCP_RTPFB   205
 
#define AST_RTP_RTCP_SR   200
 
#define AST_RTP_STAT_SET(current_stat, combined, placement, value)
 
#define AST_RTP_STAT_STRCPY(current_stat, combined, placement, value)
 
#define AST_RTP_STAT_TERMINATOR(combined)
 
#define DEFAULT_DTMF_SAMPLE_RATE_MS   8000
 
#define MAX_CHANNEL_ID   152
 

Enumerations

enum  ast_rtp_dtls_connection { AST_RTP_DTLS_CONNECTION_NEW , AST_RTP_DTLS_CONNECTION_EXISTING }
 DTLS connection states. More...
 
enum  ast_rtp_dtls_hash { AST_RTP_DTLS_HASH_SHA256 , AST_RTP_DTLS_HASH_SHA1 }
 DTLS fingerprint hashes. More...
 
enum  ast_rtp_dtls_setup { AST_RTP_DTLS_SETUP_ACTIVE , AST_RTP_DTLS_SETUP_PASSIVE , AST_RTP_DTLS_SETUP_ACTPASS , AST_RTP_DTLS_SETUP_HOLDCONN }
 DTLS setup types. More...
 
enum  ast_rtp_dtls_verify { AST_RTP_DTLS_VERIFY_NONE = 0 , AST_RTP_DTLS_VERIFY_FINGERPRINT = (1 << 0) , AST_RTP_DTLS_VERIFY_CERTIFICATE = (1 << 1) }
 DTLS verification settings. More...
 
enum  ast_rtp_dtmf_mode { AST_RTP_DTMF_MODE_NONE = 0 , AST_RTP_DTMF_MODE_RFC2833 , AST_RTP_DTMF_MODE_INBAND }
 
enum  ast_rtp_extension { AST_RTP_EXTENSION_UNSUPPORTED = 0 , AST_RTP_EXTENSION_ABS_SEND_TIME , AST_RTP_EXTENSION_TRANSPORT_WIDE_CC , AST_RTP_EXTENSION_MAX }
 Known RTP extensions. More...
 
enum  ast_rtp_extension_direction {
  AST_RTP_EXTENSION_DIRECTION_NONE , AST_RTP_EXTENSION_DIRECTION_SENDRECV , AST_RTP_EXTENSION_DIRECTION_SENDONLY , AST_RTP_EXTENSION_DIRECTION_RECVONLY ,
  AST_RTP_EXTENSION_DIRECTION_INACTIVE
}
 Directions for RTP extensions. More...
 
enum  ast_rtp_glue_result { AST_RTP_GLUE_RESULT_FORBID = 0 , AST_RTP_GLUE_RESULT_REMOTE , AST_RTP_GLUE_RESULT_LOCAL }
 
enum  ast_rtp_ice_candidate_type { AST_RTP_ICE_CANDIDATE_TYPE_HOST , AST_RTP_ICE_CANDIDATE_TYPE_SRFLX , AST_RTP_ICE_CANDIDATE_TYPE_RELAYED }
 ICE candidate types. More...
 
enum  ast_rtp_ice_component_type { AST_RTP_ICE_COMPONENT_RTP = 1 , AST_RTP_ICE_COMPONENT_RTCP = 2 }
 ICE component types. More...
 
enum  ast_rtp_ice_role { AST_RTP_ICE_ROLE_CONTROLLED , AST_RTP_ICE_ROLE_CONTROLLING }
 ICE role during negotiation. More...
 
enum  ast_rtp_instance_rtcp { AST_RTP_INSTANCE_RTCP_DISABLED = 0 , AST_RTP_INSTANCE_RTCP_STANDARD , AST_RTP_INSTANCE_RTCP_MUX }
 
enum  ast_rtp_instance_stat {
  AST_RTP_INSTANCE_STAT_ALL = 0 , AST_RTP_INSTANCE_STAT_TXCOUNT , AST_RTP_INSTANCE_STAT_RXCOUNT , AST_RTP_INSTANCE_STAT_COMBINED_LOSS ,
  AST_RTP_INSTANCE_STAT_TXPLOSS , AST_RTP_INSTANCE_STAT_RXPLOSS , AST_RTP_INSTANCE_STAT_REMOTE_MAXRXPLOSS , AST_RTP_INSTANCE_STAT_REMOTE_MINRXPLOSS ,
  AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVRXPLOSS , AST_RTP_INSTANCE_STAT_REMOTE_STDEVRXPLOSS , AST_RTP_INSTANCE_STAT_LOCAL_MAXRXPLOSS , AST_RTP_INSTANCE_STAT_LOCAL_MINRXPLOSS ,
  AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVRXPLOSS , AST_RTP_INSTANCE_STAT_LOCAL_STDEVRXPLOSS , AST_RTP_INSTANCE_STAT_COMBINED_JITTER , AST_RTP_INSTANCE_STAT_TXJITTER ,
  AST_RTP_INSTANCE_STAT_RXJITTER , AST_RTP_INSTANCE_STAT_REMOTE_MAXJITTER , AST_RTP_INSTANCE_STAT_REMOTE_MINJITTER , AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVJITTER ,
  AST_RTP_INSTANCE_STAT_REMOTE_STDEVJITTER , AST_RTP_INSTANCE_STAT_LOCAL_MAXJITTER , AST_RTP_INSTANCE_STAT_LOCAL_MINJITTER , AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVJITTER ,
  AST_RTP_INSTANCE_STAT_LOCAL_STDEVJITTER , AST_RTP_INSTANCE_STAT_COMBINED_RTT , AST_RTP_INSTANCE_STAT_RTT , AST_RTP_INSTANCE_STAT_MAX_RTT ,
  AST_RTP_INSTANCE_STAT_MIN_RTT , AST_RTP_INSTANCE_STAT_NORMDEVRTT , AST_RTP_INSTANCE_STAT_STDEVRTT , AST_RTP_INSTANCE_STAT_LOCAL_SSRC ,
  AST_RTP_INSTANCE_STAT_REMOTE_SSRC , AST_RTP_INSTANCE_STAT_CHANNEL_UNIQUEID , AST_RTP_INSTANCE_STAT_TXOCTETCOUNT , AST_RTP_INSTANCE_STAT_RXOCTETCOUNT ,
  AST_RTP_INSTANCE_STAT_COMBINED_MES , AST_RTP_INSTANCE_STAT_TXMES , AST_RTP_INSTANCE_STAT_RXMES , AST_RTP_INSTANCE_STAT_REMOTE_MAXMES ,
  AST_RTP_INSTANCE_STAT_REMOTE_MINMES , AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVMES , AST_RTP_INSTANCE_STAT_REMOTE_STDEVMES , AST_RTP_INSTANCE_STAT_LOCAL_MAXMES ,
  AST_RTP_INSTANCE_STAT_LOCAL_MINMES , AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVMES , AST_RTP_INSTANCE_STAT_LOCAL_STDEVMES
}
 
enum  ast_rtp_instance_stat_field {
  AST_RTP_INSTANCE_STAT_FIELD_QUALITY = 0 , AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER , AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS , AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT ,
  AST_RTP_INSTANCE_STAT_FIELD_QUALITY_MES
}
 
enum  ast_rtp_options { AST_RTP_OPT_G726_NONSTANDARD = (1 << 0) }
 
enum  ast_rtp_property {
  AST_RTP_PROPERTY_NAT = 0 , AST_RTP_PROPERTY_DTMF , AST_RTP_PROPERTY_DTMF_COMPENSATE , AST_RTP_PROPERTY_STUN ,
  AST_RTP_PROPERTY_RTCP , AST_RTP_PROPERTY_ASYMMETRIC_CODEC , AST_RTP_PROPERTY_RETRANS_RECV , AST_RTP_PROPERTY_RETRANS_SEND ,
  AST_RTP_PROPERTY_REMB , AST_RTP_PROPERTY_MAX
}
 

Functions

uintmax_t ast_debug_category_dtls_id (void)
 
uintmax_t ast_debug_category_dtls_packet_id (void)
 
uintmax_t ast_debug_category_ice_id (void)
 
uintmax_t ast_debug_category_rtcp_id (void)
 
uintmax_t ast_debug_category_rtcp_packet_id (void)
 
uintmax_t ast_debug_category_rtp_id (void)
 
uintmax_t ast_debug_category_rtp_packet_id (void)
 
int ast_rtp_codecs_find_payload_code (struct ast_rtp_codecs *codecs, int payload)
 Search for the tx payload type in the ast_rtp_codecs structure. More...
 
unsigned int ast_rtp_codecs_get_framing (struct ast_rtp_codecs *codecs)
 Get the framing used for a set of codecs. More...
 
struct ast_rtp_payload_typeast_rtp_codecs_get_payload (struct ast_rtp_codecs *codecs, int payload)
 Retrieve rx payload mapped information by payload type. More...
 
struct ast_formatast_rtp_codecs_get_payload_format (struct ast_rtp_codecs *codecs, int payload)
 Retrieve the actual ast_format stored on the codecs structure for a specific tx payload type. More...
 
int ast_rtp_codecs_get_preferred_dtmf_format_pt (struct ast_rtp_codecs *codecs)
 Retrieve rx preferred dtmf format payload type. More...
 
int ast_rtp_codecs_get_preferred_dtmf_format_rate (struct ast_rtp_codecs *codecs)
 Retrieve rx preferred dtmf format sample rate. More...
 
struct ast_formatast_rtp_codecs_get_preferred_format (struct ast_rtp_codecs *codecs)
 Retrieve rx preferred format. More...
 
enum ast_media_type ast_rtp_codecs_get_stream_type (struct ast_rtp_codecs *codecs)
 Determine the type of RTP stream media from the codecs mapped. More...
 
int ast_rtp_codecs_payload_code (struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code)
 Retrieve a rx mapped payload type based on whether it is an Asterisk format and the code. More...
 
int ast_rtp_codecs_payload_code_sample_rate (struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code, unsigned int sample_rate)
 Retrieve a rx mapped payload type based on whether it is an Asterisk format, the code and the sample rate. More...
 
int ast_rtp_codecs_payload_code_tx (struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code)
 Retrieve a tx mapped payload type based on whether it is an Asterisk format and the code. More...
 
int ast_rtp_codecs_payload_code_tx_sample_rate (struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code, unsigned int sample_rate)
 Retrieve a tx mapped payload type based on whether it is an Asterisk format and the code. More...
 
void ast_rtp_codecs_payload_formats (struct ast_rtp_codecs *codecs, struct ast_format_cap *astformats, int *nonastformats)
 Retrieve all formats that were found. More...
 
int ast_rtp_codecs_payload_replace_format (struct ast_rtp_codecs *codecs, int payload, struct ast_format *format)
 Update the format associated with a tx payload type in a codecs structure. More...
 
int ast_rtp_codecs_payload_set_rx (struct ast_rtp_codecs *codecs, int code, struct ast_format *format)
 Set a payload code for use with a specific Asterisk format. More...
 
int ast_rtp_codecs_payload_set_rx_sample_rate (struct ast_rtp_codecs *codecs, int code, struct ast_format *format, unsigned int sample_rate)
 Set a payload code with sample rate for use with a specific Asterisk format. More...
 
void ast_rtp_codecs_payloads_clear (struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance)
 Clear rx and tx payload mapping information from an RTP instance. More...
 
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. More...
 
void ast_rtp_codecs_payloads_destroy (struct ast_rtp_codecs *codecs)
 Destroy the contents of an RTP codecs structure (but not the structure itself) More...
 
int ast_rtp_codecs_payloads_initialize (struct ast_rtp_codecs *codecs)
 Initialize an RTP codecs structure. More...
 
void ast_rtp_codecs_payloads_set_m_type (struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
 Record tx payload type information that was seen in an m= SDP line. More...
 
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 tx payload type information that was seen in an a=rtpmap: SDP line. More...
 
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 tx payload type to a known MIME media type for a codec with a specific sample rate. More...
 
void ast_rtp_codecs_payloads_unset (struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
 Remove tx payload type mapped information. More...
 
void ast_rtp_codecs_payloads_xover (struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
 Crossover copy the tx payload mapping of src to the rx payload mapping of dest. More...
 
void ast_rtp_codecs_set_framing (struct ast_rtp_codecs *codecs, unsigned int framing)
 Set the framing used for a set of codecs. More...
 
int ast_rtp_codecs_set_preferred_dtmf_format (struct ast_rtp_codecs *codecs, int pt, int rate)
 Set the preferred dtmf format pt and sample rate. More...
 
int ast_rtp_codecs_set_preferred_format (struct ast_rtp_codecs *codecs, struct ast_format *format)
 Set the preferred format. More...
 
struct ast_jsonast_rtp_convert_stats_json (const struct ast_rtp_instance_stats *stats)
 Convert given stat instance into json format. More...
 
void ast_rtp_dtls_cfg_copy (const struct ast_rtp_dtls_cfg *src_cfg, struct ast_rtp_dtls_cfg *dst_cfg)
 Copy contents of a DTLS configuration structure. More...
 
void ast_rtp_dtls_cfg_free (struct ast_rtp_dtls_cfg *dtls_cfg)
 Free contents of a DTLS configuration structure. More...
 
int ast_rtp_dtls_cfg_parse (struct ast_rtp_dtls_cfg *dtls_cfg, const char *name, const char *value)
 Parse DTLS related configuration options. More...
 
int ast_rtp_dtls_cfg_validate (struct ast_rtp_dtls_cfg *dtls_cfg)
 Validates DTLS related configuration options. More...
 
struct ast_rtp_payload_typeast_rtp_engine_alloc_payload_type (void)
 Allocation routine for ast_rtp_payload_type. More...
 
int ast_rtp_engine_load_format (struct ast_format *format)
 Custom formats declared in codecs.conf at startup must be communicated to the rtp_engine so their mime type can payload number can be initialized. More...
 
int ast_rtp_engine_register2 (struct ast_rtp_engine *engine, struct ast_module *module)
 Register an RTP engine. More...
 
int ast_rtp_engine_register_srtp (struct ast_srtp_res *srtp_res, struct ast_srtp_policy_res *policy_res)
 
int ast_rtp_engine_srtp_is_registered (void)
 
int ast_rtp_engine_unload_format (struct ast_format *format)
 Formats requiring the use of a format attribute interface must have that interface registered in order for the rtp engine to handle it correctly. If an attribute interface is unloaded, this function must be called to notify the rtp_engine. More...
 
int ast_rtp_engine_unregister (struct ast_rtp_engine *engine)
 Unregister an RTP engine. More...
 
void ast_rtp_engine_unregister_srtp (void)
 
int ast_rtp_get_rate (const struct ast_format *format)
 Retrieve the sample rate of a format according to RTP specifications. More...
 
int ast_rtp_glue_register2 (struct ast_rtp_glue *glue, struct ast_module *module)
 Register RTP glue. More...
 
int ast_rtp_glue_unregister (struct ast_rtp_glue *glue)
 Unregister RTP glue. More...
 
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. More...
 
int ast_rtp_instance_add_srtp_policy (struct ast_rtp_instance *instance, struct ast_srtp_policy *remote_policy, struct ast_srtp_policy *local_policy, int rtcp)
 Add or replace the SRTP policies for the given RTP instance. More...
 
void ast_rtp_instance_available_formats (struct ast_rtp_instance *instance, struct ast_format_cap *to_endpoint, struct ast_format_cap *to_asterisk, struct ast_format_cap *result)
 Request the formats that can be transcoded. More...
 
int ast_rtp_instance_bundle (struct ast_rtp_instance *child, struct ast_rtp_instance *parent)
 Request that an RTP instance be bundled with another. More...
 
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. More...
 
int ast_rtp_instance_destroy (struct ast_rtp_instance *instance)
 Destroy an RTP instance. More...
 
int ast_rtp_instance_dtmf_begin (struct ast_rtp_instance *instance, char digit)
 Begin sending a DTMF digit. More...
 
int ast_rtp_instance_dtmf_end (struct ast_rtp_instance *instance, char digit)
 Stop sending a DTMF digit. More...
 
int ast_rtp_instance_dtmf_end_with_duration (struct ast_rtp_instance *instance, char digit, unsigned int duration)
 
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get (struct ast_rtp_instance *instance)
 Get the DTMF mode of an RTP instance. More...
 
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. More...
 
int ast_rtp_instance_early_bridge (struct ast_channel *c0, struct ast_channel *c1)
 Early bridge two channels that use RTP instances. More...
 
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. More...
 
void ast_rtp_instance_extmap_clear (struct ast_rtp_instance *instance)
 Clear negotiated RTP extension information. More...
 
size_t ast_rtp_instance_extmap_count (struct ast_rtp_instance *instance)
 Get the number of known unique identifiers. More...
 
int ast_rtp_instance_extmap_enable (struct ast_rtp_instance *instance, int id, enum ast_rtp_extension extension, enum ast_rtp_extension_direction direction)
 Enable support for an RTP extension on an instance. More...
 
enum ast_rtp_extension_direction ast_rtp_instance_extmap_get_direction (struct ast_rtp_instance *instance, int id)
 Retrieve the negotiated direction for an RTP extension id. More...
 
enum ast_rtp_extension ast_rtp_instance_extmap_get_extension (struct ast_rtp_instance *instance, int id)
 Retrieve the extension for an RTP extension id. More...
 
int ast_rtp_instance_extmap_get_id (struct ast_rtp_instance *instance, enum ast_rtp_extension extension)
 Retrieve the id for an RTP extension. More...
 
const char * ast_rtp_instance_extmap_get_uri (struct ast_rtp_instance *instance, int id)
 Retrieve the URI for an RTP extension id. More...
 
int ast_rtp_instance_extmap_negotiate (struct ast_rtp_instance *instance, int id, enum ast_rtp_extension_direction direction, const char *uri, const char *attributes)
 Negotiate received RTP extension information. More...
 
int ast_rtp_instance_fd (struct ast_rtp_instance *instance, int rtcp)
 Get the file descriptor for an RTP session (or RTCP) More...
 
struct ast_rtp_glueast_rtp_instance_get_active_glue (struct ast_rtp_instance *instance)
 Get the RTP glue in use on an RTP instance. More...
 
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. More...
 
int ast_rtp_instance_get_and_cmp_requested_target_address (struct ast_rtp_instance *instance, struct ast_sockaddr *address)
 Get the requested target address of the remote endpoint and compare it to the given address. More...
 
struct ast_rtp_instanceast_rtp_instance_get_bridged (struct ast_rtp_instance *instance)
 Get the other RTP instance that an instance is bridged to. More...
 
const char * ast_rtp_instance_get_channel_id (struct ast_rtp_instance *instance)
 Get the unique ID of the channel that owns this RTP instance. More...
 
const char * ast_rtp_instance_get_cname (struct ast_rtp_instance *rtp)
 Retrieve the CNAME used in RTCP SDES items. More...
 
struct ast_rtp_codecsast_rtp_instance_get_codecs (struct ast_rtp_instance *instance)
 Get the codecs structure of an RTP instance. More...
 
void * ast_rtp_instance_get_data (struct ast_rtp_instance *instance)
 Get the data portion of an RTP instance. More...
 
struct ast_rtp_engine_dtlsast_rtp_instance_get_dtls (struct ast_rtp_instance *instance)
 Obtain a pointer to the DTLS support present on an RTP instance. More...
 
struct ast_rtp_engineast_rtp_instance_get_engine (struct ast_rtp_instance *instance)
 Get the RTP engine in use on an RTP instance. More...
 
void * ast_rtp_instance_get_extended_prop (struct ast_rtp_instance *instance, int property)
 Get the value of an RTP instance extended property. More...
 
struct ast_rtp_glueast_rtp_instance_get_glue (const char *type)
 Get the RTP glue that binds a channel to the RTP engine. More...
 
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. More...
 
struct ast_rtp_engine_iceast_rtp_instance_get_ice (struct ast_rtp_instance *instance)
 Obtain a pointer to the ICE support present on an RTP instance. More...
 
void ast_rtp_instance_get_incoming_source_address (struct ast_rtp_instance *instance, struct ast_sockaddr *address)
 Get the incoming source address of the remote endpoint. More...
 
int ast_rtp_instance_get_keepalive (struct ast_rtp_instance *instance)
 Get the RTP keepalive interval. More...
 
time_t ast_rtp_instance_get_last_rx (const struct ast_rtp_instance *rtp)
 Get the last RTP reception time. More...
 
time_t ast_rtp_instance_get_last_tx (const struct ast_rtp_instance *rtp)
 Get the last RTP transmission time. More...
 
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. More...
 
int ast_rtp_instance_get_prop (struct ast_rtp_instance *instance, enum ast_rtp_property property)
 Get the value of an RTP instance property. More...
 
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. More...
 
void ast_rtp_instance_get_requested_target_address (struct ast_rtp_instance *instance, struct ast_sockaddr *address)
 Get the requested target address of the remote endpoint. More...
 
struct ast_srtpast_rtp_instance_get_srtp (struct ast_rtp_instance *instance, int rtcp)
 Obtain the SRTP instance associated with an RTP instance. More...
 
unsigned int ast_rtp_instance_get_ssrc (struct ast_rtp_instance *rtp)
 Retrieve the local SSRC value that we will be using. More...
 
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. More...
 
struct ast_jsonast_rtp_instance_get_stats_all_json (struct ast_rtp_instance *instance)
 Retrieve statistics about an RTP instance in json format. More...
 
int ast_rtp_instance_get_timeout (struct ast_rtp_instance *instance)
 Get the RTP timeout value. More...
 
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. More...
 
struct ast_rtp_instanceast_rtp_instance_new (const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data)
 Create a new RTP instance. More...
 
struct ast_frameast_rtp_instance_read (struct ast_rtp_instance *instance, int rtcp)
 Receive a frame over RTP. More...
 
int ast_rtp_instance_sendcng (struct ast_rtp_instance *instance, int level)
 Send a comfort noise packet to the RTP instance. More...
 
void ast_rtp_instance_set_bridged (struct ast_rtp_instance *instance, struct ast_rtp_instance *bridged)
 Set the other RTP instance that an instance is bridged to. More...
 
void ast_rtp_instance_set_channel_id (struct ast_rtp_instance *instance, const char *uniqueid)
 Set the channel that owns this RTP instance. More...
 
void ast_rtp_instance_set_data (struct ast_rtp_instance *instance, void *data)
 Set the data portion of an RTP instance. More...
 
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. More...
 
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. More...
 
int ast_rtp_instance_set_incoming_source_address (struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
 Set the incoming source address of the remote endpoint that we are sending RTP to. More...
 
void ast_rtp_instance_set_keepalive (struct ast_rtp_instance *instance, int timeout)
 Set the RTP keepalive interval. More...
 
void ast_rtp_instance_set_last_rx (struct ast_rtp_instance *rtp, time_t time)
 Set the last RTP reception time. More...
 
void ast_rtp_instance_set_last_tx (struct ast_rtp_instance *rtp, time_t time)
 Set the last RTP transmission time. More...
 
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. More...
 
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. More...
 
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. More...
 
int ast_rtp_instance_set_read_format (struct ast_rtp_instance *instance, struct ast_format *format)
 Request that the underlying RTP engine provide audio frames in a specific format. More...
 
void ast_rtp_instance_set_remote_ssrc (struct ast_rtp_instance *rtp, unsigned int ssrc)
 Set the remote SSRC for an RTP instance. More...
 
int ast_rtp_instance_set_requested_target_address (struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
 Set the requested target address of the remote endpoint. More...
 
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. More...
 
void ast_rtp_instance_set_stream_num (struct ast_rtp_instance *instance, int stream_num)
 Set the stream number for an RTP instance. More...
 
void ast_rtp_instance_set_timeout (struct ast_rtp_instance *instance, int timeout)
 Set the RTP timeout value. More...
 
int ast_rtp_instance_set_write_format (struct ast_rtp_instance *instance, struct ast_format *format)
 Tell underlying RTP engine that audio frames will be provided in a specific format. More...
 
void ast_rtp_instance_stop (struct ast_rtp_instance *instance)
 Stop an RTP instance. More...
 
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. More...
 
void ast_rtp_instance_update_source (struct ast_rtp_instance *instance)
 Indicate that the RTP marker bit should be set on an RTP stream. More...
 
int ast_rtp_instance_write (struct ast_rtp_instance *instance, struct ast_frame *frame)
 Send a frame out over RTP. More...
 
char * ast_rtp_lookup_mime_multiple2 (struct ast_str *buf, struct ast_format_cap *ast_format_capability, int rtp_capability, const int asterisk_format, enum ast_rtp_options options)
 Convert formats into a string and put them into a buffer. More...
 
const char * ast_rtp_lookup_mime_subtype2 (const int asterisk_format, const struct ast_format *format, int code, enum ast_rtp_options options)
 Retrieve mime subtype information on a payload. More...
 
unsigned int ast_rtp_lookup_sample_rate2 (int asterisk_format, const struct ast_format *format, int code)
 Get the sample rate associated with known RTP payload types. More...
 
int ast_rtp_payload_mapping_tx_is_present (struct ast_rtp_codecs *codecs, const struct ast_rtp_payload_type *to_match)
 Determine if a type of payload is already present in mappings. More...
 
void ast_rtp_publish_rtcp_message (struct ast_rtp_instance *rtp, struct stasis_message_type *message_type, struct ast_rtp_rtcp_report *report, struct ast_json *blob)
 Publish an RTCP message to Stasis Message Bus API. More...
 
int ast_rtp_red_buffer (struct ast_rtp_instance *instance, struct ast_frame *frame)
 Buffer a frame in an RTP instance for RED. More...
 
int ast_rtp_red_init (struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations)
 Initialize RED support on an RTP instance. More...
 
struct stasis_message_typeast_rtp_rtcp_received_type (void)
 Message type for an RTCP message received from some external source. More...
 
struct ast_rtp_rtcp_reportast_rtp_rtcp_report_alloc (unsigned int report_blocks)
 Allocate an ao2 ref counted instance of ast_rtp_rtcp_report. More...
 
struct stasis_message_typeast_rtp_rtcp_sent_type (void)
 Message type for an RTCP message sent from this Asterisk instance. More...
 
struct stasis_topicast_rtp_topic (void)
 Stasis Message Bus API topic for RTP and RTCP related messages More...
 

Detailed Description

Pluggable RTP Architecture.

Author
Joshua Colp jcolp.nosp@m.@dig.nosp@m.ium.c.nosp@m.om Asterisk RTP Engine API

Definition in file rtp_engine.h.

Macro Definition Documentation

◆ AST_DEBUG_CATEGORY_DTLS

#define AST_DEBUG_CATEGORY_DTLS   ast_debug_category_dtls_id() /* DTLS debug logging category id */

Definition at line 3089 of file rtp_engine.h.

◆ AST_DEBUG_CATEGORY_DTLS_PACKET

#define AST_DEBUG_CATEGORY_DTLS_PACKET   ast_debug_category_dtls_packet_id() /* DTLS packet debug logging category id */

Definition at line 3090 of file rtp_engine.h.

◆ AST_DEBUG_CATEGORY_ICE

#define AST_DEBUG_CATEGORY_ICE   ast_debug_category_ice_id() /* ICE debug logging category id */

Definition at line 3091 of file rtp_engine.h.

◆ AST_DEBUG_CATEGORY_RTCP

#define AST_DEBUG_CATEGORY_RTCP   ast_debug_category_rtcp_id() /* RTCP debug logging category id */

Definition at line 3087 of file rtp_engine.h.

◆ AST_DEBUG_CATEGORY_RTCP_PACKET

#define AST_DEBUG_CATEGORY_RTCP_PACKET   ast_debug_category_rtcp_packet_id() /* RTCP packet debug logging category id */

Definition at line 3088 of file rtp_engine.h.

◆ AST_DEBUG_CATEGORY_RTP

#define AST_DEBUG_CATEGORY_RTP   ast_debug_category_rtp_id() /* RTP debug logging category id */

Definition at line 3085 of file rtp_engine.h.

◆ AST_DEBUG_CATEGORY_RTP_PACKET

#define AST_DEBUG_CATEGORY_RTP_PACKET   ast_debug_category_rtp_packet_id() /* RTP packet debug logging category id */

Definition at line 3086 of file rtp_engine.h.

◆ ast_debug_dtls

#define ast_debug_dtls (   sublevel,
  ... 
)     ast_debug_category(sublevel, AST_DEBUG_CATEGORY_DTLS, __VA_ARGS__)

Log debug level DTLS information.

Parameters
sublevelDebug output sublevel (>= 0)
...String format and any associated arguments

Definition at line 3133 of file rtp_engine.h.

◆ ast_debug_dtls_packet_is_allowed

Definition at line 3137 of file rtp_engine.h.

◆ ast_debug_ice

#define ast_debug_ice (   sublevel,
  ... 
)     ast_debug_category(sublevel, AST_DEBUG_CATEGORY_ICE, __VA_ARGS__)

Log debug level ICE information.

Parameters
sublevelDebug output sublevel (>= 0)
...String format and any associated arguments

Definition at line 3145 of file rtp_engine.h.

◆ ast_debug_rtcp

#define ast_debug_rtcp (   sublevel,
  ... 
)     ast_debug_category(sublevel, AST_DEBUG_CATEGORY_RTCP, __VA_ARGS__)

Log debug level RTCP information.

Parameters
sublevelDebug output sublevel (>= 0)
...String format and any associated arguments

Definition at line 3116 of file rtp_engine.h.

◆ ast_debug_rtcp_is_allowed

Definition at line 3120 of file rtp_engine.h.

◆ ast_debug_rtcp_packet_is_allowed

Definition at line 3124 of file rtp_engine.h.

◆ ast_debug_rtp

#define ast_debug_rtp (   sublevel,
  ... 
)     ast_debug_category(sublevel, AST_DEBUG_CATEGORY_RTP, __VA_ARGS__)

Log debug level RTP information.

Parameters
sublevelDebug output sublevel (>= 0)
...String format and any associated arguments

Definition at line 3099 of file rtp_engine.h.

◆ ast_debug_rtp_is_allowed

Definition at line 3103 of file rtp_engine.h.

◆ ast_debug_rtp_packet_is_allowed

Definition at line 3107 of file rtp_engine.h.

◆ AST_LOG_CATEGORY_DTLS

#define AST_LOG_CATEGORY_DTLS   "dtls"

Definition at line 3071 of file rtp_engine.h.

◆ AST_LOG_CATEGORY_DTLS_PACKET

#define AST_LOG_CATEGORY_DTLS_PACKET   "dtls_packet"

Definition at line 3073 of file rtp_engine.h.

◆ AST_LOG_CATEGORY_ICE

#define AST_LOG_CATEGORY_ICE   "ice"

Definition at line 3075 of file rtp_engine.h.

◆ AST_LOG_CATEGORY_RTCP

#define AST_LOG_CATEGORY_RTCP   "rtcp"

Definition at line 3067 of file rtp_engine.h.

◆ AST_LOG_CATEGORY_RTCP_PACKET

#define AST_LOG_CATEGORY_RTCP_PACKET   "rtcp_packet"

Definition at line 3069 of file rtp_engine.h.

◆ AST_LOG_CATEGORY_RTP

#define AST_LOG_CATEGORY_RTP   "rtp"

Definition at line 3063 of file rtp_engine.h.

◆ AST_LOG_CATEGORY_RTP_PACKET

#define AST_LOG_CATEGORY_RTP_PACKET   "rtp_packet"

Definition at line 3065 of file rtp_engine.h.

◆ AST_RED_MAX_GENERATION

#define AST_RED_MAX_GENERATION   5

Maximum number of generations

Definition at line 98 of file rtp_engine.h.

◆ AST_RTP_CISCO_DTMF

#define AST_RTP_CISCO_DTMF   (1 << 2)

DTMF (Cisco Proprietary)

Definition at line 298 of file rtp_engine.h.

◆ AST_RTP_CN

#define AST_RTP_CN   (1 << 1)

'Comfort Noise' (RFC3389)

Definition at line 296 of file rtp_engine.h.

◆ AST_RTP_CODECS_NULL_INIT

#define AST_RTP_CODECS_NULL_INIT
Value:
{ .codecs_lock = AST_RWLOCK_INIT_VALUE, .payload_mapping_rx = { 0, }, .payload_mapping_tx = { 0, }, .framing = 0, .preferred_format = NULL, \
.preferred_dtmf_rate = -1, .preferred_dtmf_pt = -1}
#define AST_RWLOCK_INIT_VALUE
Definition: lock.h:105
#define NULL
Definition: resample.c:96

Definition at line 773 of file rtp_engine.h.

◆ AST_RTP_DTMF

#define AST_RTP_DTMF   (1 << 0)

DTMF (RFC2833)

Definition at line 294 of file rtp_engine.h.

◆ ast_rtp_engine_register

#define ast_rtp_engine_register (   engine)    ast_rtp_engine_register2(engine, AST_MODULE_SELF)

Definition at line 852 of file rtp_engine.h.

◆ ast_rtp_glue_register

#define ast_rtp_glue_register (   glue)    ast_rtp_glue_register2(glue, AST_MODULE_SELF)

Definition at line 905 of file rtp_engine.h.

◆ ast_rtp_instance_get_and_cmp_remote_address

#define ast_rtp_instance_get_and_cmp_remote_address (   instance,
  address 
)     ast_rtp_instance_get_and_cmp_requested_target_address((instance), (address))

Get the address of the remote endpoint that we are sending RTP to, comparing its address to another.

Parameters
instanceThe instance that we want to get the remote address for
addressAn initialized address that may be overwritten if the remote address is different
Return values
0address was not changed
1address was changed Example usage:
int ret;
char * address
Definition: f2c.h:59
#define ast_rtp_instance_get_and_cmp_remote_address(instance, address)
Get the address of the remote endpoint that we are sending RTP to, comparing its address to another.
Definition: rtp_engine.h:1286
Socket address structure.
Definition: netsock2.h:97

This retrieves the current remote address set on the instance pointed to by instance and puts the value into the address structure.

Since
1.8

Definition at line 1286 of file rtp_engine.h.

◆ ast_rtp_instance_get_remote_address

#define ast_rtp_instance_get_remote_address (   instance,
  address 
)     ast_rtp_instance_get_incoming_source_address((instance), (address))

Get the address of the remote endpoint that we are sending RTP to.

Parameters
instanceThe instance that we want to get the remote address for
addressA structure to put the address into

Example usage:

#define ast_rtp_instance_get_remote_address(instance, address)
Get the address of the remote endpoint that we are sending RTP to.
Definition: rtp_engine.h:1250

This retrieves the current remote address set on the instance pointed to by instance and puts the value into the address structure.

Since
1.8

Definition at line 1250 of file rtp_engine.h.

◆ ast_rtp_instance_set_remote_address

#define ast_rtp_instance_set_remote_address (   instance,
  address 
)     ast_rtp_instance_set_requested_target_address((instance), (address))

Set the address of the remote endpoint that we are sending RTP to.

Parameters
instanceThe RTP instance to change the address on
addressAddress to set it to
Return values
0success
-1failure

Example usage:

#define ast_rtp_instance_set_remote_address(instance, address)
Set the address of the remote endpoint that we are sending RTP to.
Definition: rtp_engine.h:1138

This changes the remote address that RTP will be sent to on instance to the address given in the sin structure.

Since
1.8

Definition at line 1138 of file rtp_engine.h.

◆ AST_RTP_MAX

#define AST_RTP_MAX   AST_RTP_CISCO_DTMF

Maximum RTP-specific code

Definition at line 300 of file rtp_engine.h.

◆ AST_RTP_MAX_PT

#define AST_RTP_MAX_PT   128

Maximum number of payload types RTP can support.

Definition at line 83 of file rtp_engine.h.

◆ AST_RTP_PT_FIRST_DYNAMIC

#define AST_RTP_PT_FIRST_DYNAMIC   96

First dynamic RTP payload type

Definition at line 92 of file rtp_engine.h.

◆ AST_RTP_PT_LAST_REASSIGN

#define AST_RTP_PT_LAST_REASSIGN   63

Last reassignable RTP payload type

Definition at line 95 of file rtp_engine.h.

◆ AST_RTP_PT_LAST_STATIC

#define AST_RTP_PT_LAST_STATIC   34

Last RTP payload type statically assigned, see http://www.iana.org/assignments/rtp-parameters

Definition at line 89 of file rtp_engine.h.

◆ AST_RTP_RTCP_FMT_FIR

#define AST_RTP_RTCP_FMT_FIR   4

Full INTRA-frame Request (From RFC5104)

Definition at line 337 of file rtp_engine.h.

◆ AST_RTP_RTCP_FMT_NACK

#define AST_RTP_RTCP_FMT_NACK   1

Generic NACK (From RFC4585 also RFC5104)

Definition at line 333 of file rtp_engine.h.

◆ AST_RTP_RTCP_FMT_PLI

#define AST_RTP_RTCP_FMT_PLI   1

Picture loss indication (From RFC4585)

Definition at line 335 of file rtp_engine.h.

◆ AST_RTP_RTCP_FMT_REMB

#define AST_RTP_RTCP_FMT_REMB   15

REMB Information (From draft-alvestrand-rmcat-remb-03)

Definition at line 339 of file rtp_engine.h.

◆ AST_RTP_RTCP_FMT_TRANSPORT_WIDE_CC

#define AST_RTP_RTCP_FMT_TRANSPORT_WIDE_CC   15

Transport-wide congestion control feedback (From draft-holmer-rmcat-transport-wide-cc-extensions-01)

Definition at line 341 of file rtp_engine.h.

◆ AST_RTP_RTCP_PSFB

#define AST_RTP_RTCP_PSFB   206

Payload Specific Feed Back (From RFC4585 also RFC5104)

Definition at line 329 of file rtp_engine.h.

◆ AST_RTP_RTCP_RR

#define AST_RTP_RTCP_RR   201

Receiver Report

Definition at line 325 of file rtp_engine.h.

◆ AST_RTP_RTCP_RTPFB

#define AST_RTP_RTCP_RTPFB   205

Transport Layer Feed Back (From RFC4585 also RFC5104)

Definition at line 327 of file rtp_engine.h.

◆ AST_RTP_RTCP_SR

#define AST_RTP_RTCP_SR   200

Sender Report

Definition at line 323 of file rtp_engine.h.

◆ AST_RTP_STAT_SET

#define AST_RTP_STAT_SET (   current_stat,
  combined,
  placement,
  value 
)

Definition at line 484 of file rtp_engine.h.

◆ AST_RTP_STAT_STRCPY

#define AST_RTP_STAT_STRCPY (   current_stat,
  combined,
  placement,
  value 
)

Definition at line 492 of file rtp_engine.h.

◆ AST_RTP_STAT_TERMINATOR

#define AST_RTP_STAT_TERMINATOR (   combined)
Value:
if (stat == combined) { \
return 0; \
}

Definition at line 500 of file rtp_engine.h.

◆ DEFAULT_DTMF_SAMPLE_RATE_MS

#define DEFAULT_DTMF_SAMPLE_RATE_MS   8000

Definition at line 110 of file rtp_engine.h.

◆ MAX_CHANNEL_ID

#define MAX_CHANNEL_ID   152

Maximum size of an internal Asterisk channel unique ID.

Note
Must match the AST_MAX_UNIQUEID(AST_MAX_PUBLIC_UNIQUEID) value. We don't use that defined value directly here to avoid a hard dependency on channel.h. DTMF samples per second

Definition at line 109 of file rtp_engine.h.

Enumeration Type Documentation

◆ ast_rtp_dtls_connection

DTLS connection states.

Enumerator
AST_RTP_DTLS_CONNECTION_NEW 

Endpoint wants to use a new connection

AST_RTP_DTLS_CONNECTION_EXISTING 

Endpoint wishes to use existing connection

Definition at line 572 of file rtp_engine.h.

572 {
573 AST_RTP_DTLS_CONNECTION_NEW, /*!< Endpoint wants to use a new connection */
574 AST_RTP_DTLS_CONNECTION_EXISTING, /*!< Endpoint wishes to use existing connection */
575};
@ AST_RTP_DTLS_CONNECTION_NEW
Definition: rtp_engine.h:573
@ AST_RTP_DTLS_CONNECTION_EXISTING
Definition: rtp_engine.h:574

◆ ast_rtp_dtls_hash

DTLS fingerprint hashes.

Enumerator
AST_RTP_DTLS_HASH_SHA256 

SHA-256 fingerprint hash

AST_RTP_DTLS_HASH_SHA1 

SHA-1 fingerprint hash

Definition at line 578 of file rtp_engine.h.

578 {
579 AST_RTP_DTLS_HASH_SHA256, /*!< SHA-256 fingerprint hash */
580 AST_RTP_DTLS_HASH_SHA1, /*!< SHA-1 fingerprint hash */
581};
@ AST_RTP_DTLS_HASH_SHA1
Definition: rtp_engine.h:580
@ AST_RTP_DTLS_HASH_SHA256
Definition: rtp_engine.h:579

◆ ast_rtp_dtls_setup

DTLS setup types.

Enumerator
AST_RTP_DTLS_SETUP_ACTIVE 

Endpoint is willing to inititate connections

AST_RTP_DTLS_SETUP_PASSIVE 

Endpoint is willing to accept connections

AST_RTP_DTLS_SETUP_ACTPASS 

Endpoint is willing to both accept and initiate connections

AST_RTP_DTLS_SETUP_HOLDCONN 

Endpoint does not want the connection to be established right now

Definition at line 564 of file rtp_engine.h.

564 {
565 AST_RTP_DTLS_SETUP_ACTIVE, /*!< Endpoint is willing to inititate connections */
566 AST_RTP_DTLS_SETUP_PASSIVE, /*!< Endpoint is willing to accept connections */
567 AST_RTP_DTLS_SETUP_ACTPASS, /*!< Endpoint is willing to both accept and initiate connections */
568 AST_RTP_DTLS_SETUP_HOLDCONN, /*!< Endpoint does not want the connection to be established right now */
569};
@ AST_RTP_DTLS_SETUP_PASSIVE
Definition: rtp_engine.h:566
@ AST_RTP_DTLS_SETUP_HOLDCONN
Definition: rtp_engine.h:568
@ AST_RTP_DTLS_SETUP_ACTPASS
Definition: rtp_engine.h:567
@ AST_RTP_DTLS_SETUP_ACTIVE
Definition: rtp_engine.h:565

◆ ast_rtp_dtls_verify

DTLS verification settings.

Enumerator
AST_RTP_DTLS_VERIFY_NONE 

Don't verify anything

AST_RTP_DTLS_VERIFY_FINGERPRINT 

Verify the fingerprint

AST_RTP_DTLS_VERIFY_CERTIFICATE 

Verify the certificate

Definition at line 584 of file rtp_engine.h.

584 {
585 AST_RTP_DTLS_VERIFY_NONE = 0, /*!< Don't verify anything */
586 AST_RTP_DTLS_VERIFY_FINGERPRINT = (1 << 0), /*!< Verify the fingerprint */
587 AST_RTP_DTLS_VERIFY_CERTIFICATE = (1 << 1), /*!< Verify the certificate */
588};
@ AST_RTP_DTLS_VERIFY_NONE
Definition: rtp_engine.h:585
@ AST_RTP_DTLS_VERIFY_FINGERPRINT
Definition: rtp_engine.h:586
@ AST_RTP_DTLS_VERIFY_CERTIFICATE
Definition: rtp_engine.h:587

◆ ast_rtp_dtmf_mode

RTP DTMF Modes

Enumerator
AST_RTP_DTMF_MODE_NONE 

No DTMF is being carried over the RTP stream

AST_RTP_DTMF_MODE_RFC2833 

DTMF is being carried out of band using RFC2833

AST_RTP_DTMF_MODE_INBAND 

DTMF is being carried inband over the RTP stream

Definition at line 151 of file rtp_engine.h.

151 {
152 /*! No DTMF is being carried over the RTP stream */
154 /*! DTMF is being carried out of band using RFC2833 */
156 /*! DTMF is being carried inband over the RTP stream */
158};
@ AST_RTP_DTMF_MODE_RFC2833
Definition: rtp_engine.h:155
@ AST_RTP_DTMF_MODE_INBAND
Definition: rtp_engine.h:157
@ AST_RTP_DTMF_MODE_NONE
Definition: rtp_engine.h:153

◆ ast_rtp_extension

Known RTP extensions.

Enumerator
AST_RTP_EXTENSION_UNSUPPORTED 

Per the RFC 0 should not be used, so we treat it as an unsupported extension placeholder

AST_RTP_EXTENSION_ABS_SEND_TIME 

abs-send-time from https://tools.ietf.org/html/draft-alvestrand-rmcat-remb-03

AST_RTP_EXTENSION_TRANSPORT_WIDE_CC 

transport-cc from https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01

AST_RTP_EXTENSION_MAX 

The maximum number of known RTP extensions

Definition at line 593 of file rtp_engine.h.

593 {
594 /*! Per the RFC 0 should not be used, so we treat it as an unsupported extension placeholder */
596 /*! abs-send-time from https://tools.ietf.org/html/draft-alvestrand-rmcat-remb-03 */
598 /*! transport-cc from https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01 */
600 /*! The maximum number of known RTP extensions */
602};
@ AST_RTP_EXTENSION_MAX
Definition: rtp_engine.h:601
@ AST_RTP_EXTENSION_TRANSPORT_WIDE_CC
Definition: rtp_engine.h:599
@ AST_RTP_EXTENSION_ABS_SEND_TIME
Definition: rtp_engine.h:597
@ AST_RTP_EXTENSION_UNSUPPORTED
Definition: rtp_engine.h:595

◆ ast_rtp_extension_direction

Directions for RTP extensions.

Enumerator
AST_RTP_EXTENSION_DIRECTION_NONE 

The extension is not negotiated and is not flowing

AST_RTP_EXTENSION_DIRECTION_SENDRECV 

Send and receive

AST_RTP_EXTENSION_DIRECTION_SENDONLY 

Send only

AST_RTP_EXTENSION_DIRECTION_RECVONLY 

Receive only

AST_RTP_EXTENSION_DIRECTION_INACTIVE 

Negotiated but not sending or receiving

Definition at line 827 of file rtp_engine.h.

827 {
828 /*! The extension is not negotiated and is not flowing */
830 /*! Send and receive */
832 /*! Send only */
834 /*! Receive only */
836 /*! Negotiated but not sending or receiving */
838};
@ AST_RTP_EXTENSION_DIRECTION_SENDRECV
Definition: rtp_engine.h:831
@ AST_RTP_EXTENSION_DIRECTION_NONE
Definition: rtp_engine.h:829
@ AST_RTP_EXTENSION_DIRECTION_INACTIVE
Definition: rtp_engine.h:837
@ AST_RTP_EXTENSION_DIRECTION_RECVONLY
Definition: rtp_engine.h:835
@ AST_RTP_EXTENSION_DIRECTION_SENDONLY
Definition: rtp_engine.h:833

◆ ast_rtp_glue_result

Result codes when RTP glue is queried for information

Enumerator
AST_RTP_GLUE_RESULT_FORBID 

No remote or local bridging is permitted

AST_RTP_GLUE_RESULT_REMOTE 

Move RTP stream to be remote between devices directly

AST_RTP_GLUE_RESULT_LOCAL 

Perform RTP engine level bridging if possible

Definition at line 161 of file rtp_engine.h.

161 {
162 /*! No remote or local bridging is permitted */
164 /*! Move RTP stream to be remote between devices directly */
166 /*! Perform RTP engine level bridging if possible */
168};
@ AST_RTP_GLUE_RESULT_LOCAL
Definition: rtp_engine.h:167
@ AST_RTP_GLUE_RESULT_REMOTE
Definition: rtp_engine.h:165
@ AST_RTP_GLUE_RESULT_FORBID
Definition: rtp_engine.h:163

◆ ast_rtp_ice_candidate_type

ICE candidate types.

Enumerator
AST_RTP_ICE_CANDIDATE_TYPE_HOST 

ICE host candidate. A host candidate represents the actual local transport address in the host.

AST_RTP_ICE_CANDIDATE_TYPE_SRFLX 

ICE server reflexive candidate, which represents the public mapped address of the local address.

AST_RTP_ICE_CANDIDATE_TYPE_RELAYED 

ICE relayed candidate, which represents the address allocated in TURN server.

Definition at line 506 of file rtp_engine.h.

506 {
507 AST_RTP_ICE_CANDIDATE_TYPE_HOST, /*!< ICE host candidate. A host candidate represents the actual local transport address in the host. */
508 AST_RTP_ICE_CANDIDATE_TYPE_SRFLX, /*!< ICE server reflexive candidate, which represents the public mapped address of the local address. */
509 AST_RTP_ICE_CANDIDATE_TYPE_RELAYED, /*!< ICE relayed candidate, which represents the address allocated in TURN server. */
510};
@ AST_RTP_ICE_CANDIDATE_TYPE_RELAYED
Definition: rtp_engine.h:509
@ AST_RTP_ICE_CANDIDATE_TYPE_SRFLX
Definition: rtp_engine.h:508
@ AST_RTP_ICE_CANDIDATE_TYPE_HOST
Definition: rtp_engine.h:507

◆ ast_rtp_ice_component_type

ICE component types.

Enumerator
AST_RTP_ICE_COMPONENT_RTP 
AST_RTP_ICE_COMPONENT_RTCP 

Definition at line 513 of file rtp_engine.h.

513 {
516};
@ AST_RTP_ICE_COMPONENT_RTCP
Definition: rtp_engine.h:515
@ AST_RTP_ICE_COMPONENT_RTP
Definition: rtp_engine.h:514

◆ ast_rtp_ice_role

ICE role during negotiation.

Enumerator
AST_RTP_ICE_ROLE_CONTROLLED 
AST_RTP_ICE_ROLE_CONTROLLING 

Definition at line 519 of file rtp_engine.h.

519 {
522};
@ AST_RTP_ICE_ROLE_CONTROLLING
Definition: rtp_engine.h:521
@ AST_RTP_ICE_ROLE_CONTROLLED
Definition: rtp_engine.h:520

◆ ast_rtp_instance_rtcp

Enumerator
AST_RTP_INSTANCE_RTCP_DISABLED 

RTCP should not be sent/received

AST_RTP_INSTANCE_RTCP_STANDARD 

RTCP should be sent/received based on standard port rules

AST_RTP_INSTANCE_RTCP_MUX 

RTCP should be sent/received on the same port as RTP

Definition at line 283 of file rtp_engine.h.

283 {
284 /*! RTCP should not be sent/received */
286 /*! RTCP should be sent/received based on standard port rules */
288 /*! RTCP should be sent/received on the same port as RTP */
290};
@ AST_RTP_INSTANCE_RTCP_MUX
Definition: rtp_engine.h:289
@ AST_RTP_INSTANCE_RTCP_STANDARD
Definition: rtp_engine.h:287
@ AST_RTP_INSTANCE_RTCP_DISABLED
Definition: rtp_engine.h:285

◆ ast_rtp_instance_stat

Statistics that can be retrieved from an RTP instance

Enumerator
AST_RTP_INSTANCE_STAT_ALL 

Retrieve all statistics

AST_RTP_INSTANCE_STAT_TXCOUNT 

Retrieve number of packets transmitted

AST_RTP_INSTANCE_STAT_RXCOUNT 

Retrieve number of packets received

AST_RTP_INSTANCE_STAT_COMBINED_LOSS 

Retrieve ALL statistics relating to packet loss

AST_RTP_INSTANCE_STAT_TXPLOSS 

Retrieve number of packets lost for transmitting

AST_RTP_INSTANCE_STAT_RXPLOSS 

Retrieve number of packets lost for receiving

AST_RTP_INSTANCE_STAT_REMOTE_MAXRXPLOSS 

Retrieve maximum number of packets lost on remote side

AST_RTP_INSTANCE_STAT_REMOTE_MINRXPLOSS 

Retrieve minimum number of packets lost on remote side

AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVRXPLOSS 

Retrieve average number of packets lost on remote side

AST_RTP_INSTANCE_STAT_REMOTE_STDEVRXPLOSS 

Retrieve standard deviation of packets lost on remote side

AST_RTP_INSTANCE_STAT_LOCAL_MAXRXPLOSS 

Retrieve maximum number of packets lost on local side

AST_RTP_INSTANCE_STAT_LOCAL_MINRXPLOSS 

Retrieve minimum number of packets lost on local side

AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVRXPLOSS 

Retrieve average number of packets lost on local side

AST_RTP_INSTANCE_STAT_LOCAL_STDEVRXPLOSS 

Retrieve standard deviation of packets lost on local side

AST_RTP_INSTANCE_STAT_COMBINED_JITTER 

Retrieve ALL statistics relating to jitter

AST_RTP_INSTANCE_STAT_TXJITTER 

Retrieve jitter on transmitted packets

AST_RTP_INSTANCE_STAT_RXJITTER 

Retrieve jitter on received packets

AST_RTP_INSTANCE_STAT_REMOTE_MAXJITTER 

Retrieve maximum jitter on remote side

AST_RTP_INSTANCE_STAT_REMOTE_MINJITTER 

Retrieve minimum jitter on remote side

AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVJITTER 

Retrieve average jitter on remote side

AST_RTP_INSTANCE_STAT_REMOTE_STDEVJITTER 

Retrieve standard deviation jitter on remote side

AST_RTP_INSTANCE_STAT_LOCAL_MAXJITTER 

Retrieve maximum jitter on local side

AST_RTP_INSTANCE_STAT_LOCAL_MINJITTER 

Retrieve minimum jitter on local side

AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVJITTER 

Retrieve average jitter on local side

AST_RTP_INSTANCE_STAT_LOCAL_STDEVJITTER 

Retrieve standard deviation jitter on local side

AST_RTP_INSTANCE_STAT_COMBINED_RTT 

Retrieve ALL statistics relating to round trip time

AST_RTP_INSTANCE_STAT_RTT 

Retrieve round trip time

AST_RTP_INSTANCE_STAT_MAX_RTT 

Retrieve maximum round trip time

AST_RTP_INSTANCE_STAT_MIN_RTT 

Retrieve minimum round trip time

AST_RTP_INSTANCE_STAT_NORMDEVRTT 

Retrieve average round trip time

AST_RTP_INSTANCE_STAT_STDEVRTT 

Retrieve standard deviation round trip time

AST_RTP_INSTANCE_STAT_LOCAL_SSRC 

Retrieve local SSRC

AST_RTP_INSTANCE_STAT_REMOTE_SSRC 

Retrieve remote SSRC

AST_RTP_INSTANCE_STAT_CHANNEL_UNIQUEID 

Retrieve channel unique ID

AST_RTP_INSTANCE_STAT_TXOCTETCOUNT 

Retrieve number of octets transmitted

AST_RTP_INSTANCE_STAT_RXOCTETCOUNT 

Retrieve number of octets received

AST_RTP_INSTANCE_STAT_COMBINED_MES 

Retrieve ALL statistics relating to Media Experience Score

AST_RTP_INSTANCE_STAT_TXMES 

Retrieve MES on transmitted packets

AST_RTP_INSTANCE_STAT_RXMES 

Retrieve MES on received packets

AST_RTP_INSTANCE_STAT_REMOTE_MAXMES 

Retrieve maximum MES on remote side

AST_RTP_INSTANCE_STAT_REMOTE_MINMES 

Retrieve minimum MES on remote side

AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVMES 

Retrieve average MES on remote side

AST_RTP_INSTANCE_STAT_REMOTE_STDEVMES 

Retrieve standard deviation MES on remote side

AST_RTP_INSTANCE_STAT_LOCAL_MAXMES 

Retrieve maximum MES on local side

AST_RTP_INSTANCE_STAT_LOCAL_MINMES 

Retrieve minimum MES on local side

AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVMES 

Retrieve average MES on local side

AST_RTP_INSTANCE_STAT_LOCAL_STDEVMES 

Retrieve standard deviation MES on local side

Definition at line 185 of file rtp_engine.h.

185 {
186 /*! Retrieve all statistics */
188 /*! Retrieve number of packets transmitted */
190 /*! Retrieve number of packets received */
192 /*! Retrieve ALL statistics relating to packet loss */
194 /*! Retrieve number of packets lost for transmitting */
196 /*! Retrieve number of packets lost for receiving */
198 /*! Retrieve maximum number of packets lost on remote side */
200 /*! Retrieve minimum number of packets lost on remote side */
202 /*! Retrieve average number of packets lost on remote side */
204 /*! Retrieve standard deviation of packets lost on remote side */
206 /*! Retrieve maximum number of packets lost on local side */
208 /*! Retrieve minimum number of packets lost on local side */
210 /*! Retrieve average number of packets lost on local side */
212 /*! Retrieve standard deviation of packets lost on local side */
214 /*! Retrieve ALL statistics relating to jitter */
216 /*! Retrieve jitter on transmitted packets */
218 /*! Retrieve jitter on received packets */
220 /*! Retrieve maximum jitter on remote side */
222 /*! Retrieve minimum jitter on remote side */
224 /*! Retrieve average jitter on remote side */
226 /*! Retrieve standard deviation jitter on remote side */
228 /*! Retrieve maximum jitter on local side */
230 /*! Retrieve minimum jitter on local side */
232 /*! Retrieve average jitter on local side */
234 /*! Retrieve standard deviation jitter on local side */
236 /*! Retrieve ALL statistics relating to round trip time */
238 /*! Retrieve round trip time */
240 /*! Retrieve maximum round trip time */
242 /*! Retrieve minimum round trip time */
244 /*! Retrieve average round trip time */
246 /*! Retrieve standard deviation round trip time */
248 /*! Retrieve local SSRC */
250 /*! Retrieve remote SSRC */
252 /*! Retrieve channel unique ID */
254 /*! Retrieve number of octets transmitted */
256 /*! Retrieve number of octets received */
258
259 /*! Retrieve ALL statistics relating to Media Experience Score */
261 /*! Retrieve MES on transmitted packets */
263 /*! Retrieve MES on received packets */
265 /*! Retrieve maximum MES on remote side */
267 /*! Retrieve minimum MES on remote side */
269 /*! Retrieve average MES on remote side */
271 /*! Retrieve standard deviation MES on remote side */
273 /*! Retrieve maximum MES on local side */
275 /*! Retrieve minimum MES on local side */
277 /*! Retrieve average MES on local side */
279 /*! Retrieve standard deviation MES on local side */
281};
@ AST_RTP_INSTANCE_STAT_LOCAL_MAXRXPLOSS
Definition: rtp_engine.h:207
@ AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVRXPLOSS
Definition: rtp_engine.h:203
@ AST_RTP_INSTANCE_STAT_REMOTE_MAXRXPLOSS
Definition: rtp_engine.h:199
@ AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVMES
Definition: rtp_engine.h:270
@ AST_RTP_INSTANCE_STAT_REMOTE_MINJITTER
Definition: rtp_engine.h:223
@ AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVMES
Definition: rtp_engine.h:278
@ AST_RTP_INSTANCE_STAT_MIN_RTT
Definition: rtp_engine.h:243
@ AST_RTP_INSTANCE_STAT_TXMES
Definition: rtp_engine.h:262
@ AST_RTP_INSTANCE_STAT_CHANNEL_UNIQUEID
Definition: rtp_engine.h:253
@ AST_RTP_INSTANCE_STAT_TXPLOSS
Definition: rtp_engine.h:195
@ AST_RTP_INSTANCE_STAT_MAX_RTT
Definition: rtp_engine.h:241
@ AST_RTP_INSTANCE_STAT_RXPLOSS
Definition: rtp_engine.h:197
@ AST_RTP_INSTANCE_STAT_REMOTE_MAXJITTER
Definition: rtp_engine.h:221
@ AST_RTP_INSTANCE_STAT_LOCAL_MAXJITTER
Definition: rtp_engine.h:229
@ AST_RTP_INSTANCE_STAT_REMOTE_MINMES
Definition: rtp_engine.h:268
@ AST_RTP_INSTANCE_STAT_REMOTE_STDEVJITTER
Definition: rtp_engine.h:227
@ AST_RTP_INSTANCE_STAT_REMOTE_MINRXPLOSS
Definition: rtp_engine.h:201
@ AST_RTP_INSTANCE_STAT_LOCAL_MINMES
Definition: rtp_engine.h:276
@ AST_RTP_INSTANCE_STAT_TXOCTETCOUNT
Definition: rtp_engine.h:255
@ AST_RTP_INSTANCE_STAT_RXMES
Definition: rtp_engine.h:264
@ AST_RTP_INSTANCE_STAT_REMOTE_STDEVMES
Definition: rtp_engine.h:272
@ AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVRXPLOSS
Definition: rtp_engine.h:211
@ AST_RTP_INSTANCE_STAT_REMOTE_STDEVRXPLOSS
Definition: rtp_engine.h:205
@ AST_RTP_INSTANCE_STAT_LOCAL_STDEVRXPLOSS
Definition: rtp_engine.h:213
@ AST_RTP_INSTANCE_STAT_REMOTE_MAXMES
Definition: rtp_engine.h:266
@ AST_RTP_INSTANCE_STAT_TXCOUNT
Definition: rtp_engine.h:189
@ AST_RTP_INSTANCE_STAT_STDEVRTT
Definition: rtp_engine.h:247
@ AST_RTP_INSTANCE_STAT_COMBINED_MES
Definition: rtp_engine.h:260
@ AST_RTP_INSTANCE_STAT_LOCAL_MAXMES
Definition: rtp_engine.h:274
@ AST_RTP_INSTANCE_STAT_RXJITTER
Definition: rtp_engine.h:219
@ AST_RTP_INSTANCE_STAT_LOCAL_MINRXPLOSS
Definition: rtp_engine.h:209
@ AST_RTP_INSTANCE_STAT_LOCAL_SSRC
Definition: rtp_engine.h:249
@ AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVJITTER
Definition: rtp_engine.h:225
@ AST_RTP_INSTANCE_STAT_COMBINED_JITTER
Definition: rtp_engine.h:215
@ AST_RTP_INSTANCE_STAT_TXJITTER
Definition: rtp_engine.h:217
@ AST_RTP_INSTANCE_STAT_LOCAL_MINJITTER
Definition: rtp_engine.h:231
@ AST_RTP_INSTANCE_STAT_COMBINED_LOSS
Definition: rtp_engine.h:193
@ AST_RTP_INSTANCE_STAT_LOCAL_STDEVJITTER
Definition: rtp_engine.h:235
@ AST_RTP_INSTANCE_STAT_COMBINED_RTT
Definition: rtp_engine.h:237
@ AST_RTP_INSTANCE_STAT_NORMDEVRTT
Definition: rtp_engine.h:245
@ AST_RTP_INSTANCE_STAT_RTT
Definition: rtp_engine.h:239
@ AST_RTP_INSTANCE_STAT_RXOCTETCOUNT
Definition: rtp_engine.h:257
@ AST_RTP_INSTANCE_STAT_LOCAL_STDEVMES
Definition: rtp_engine.h:280
@ AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVJITTER
Definition: rtp_engine.h:233
@ AST_RTP_INSTANCE_STAT_ALL
Definition: rtp_engine.h:187
@ AST_RTP_INSTANCE_STAT_RXCOUNT
Definition: rtp_engine.h:191
@ AST_RTP_INSTANCE_STAT_REMOTE_SSRC
Definition: rtp_engine.h:251

◆ ast_rtp_instance_stat_field

Field statistics that can be retrieved from an RTP instance

Enumerator
AST_RTP_INSTANCE_STAT_FIELD_QUALITY 

Retrieve quality information

AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER 

Retrieve quality information about jitter

AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS 

Retrieve quality information about packet loss

AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT 

Retrieve quality information about round trip time

AST_RTP_INSTANCE_STAT_FIELD_QUALITY_MES 

Retrieve quality information about Media Experience Score

Definition at line 171 of file rtp_engine.h.

171 {
172 /*! Retrieve quality information */
174 /*! Retrieve quality information about jitter */
176 /*! Retrieve quality information about packet loss */
178 /*! Retrieve quality information about round trip time */
180 /*! Retrieve quality information about Media Experience Score */
182};
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS
Definition: rtp_engine.h:177
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT
Definition: rtp_engine.h:179
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY
Definition: rtp_engine.h:173
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER
Definition: rtp_engine.h:175
@ AST_RTP_INSTANCE_STAT_FIELD_QUALITY_MES
Definition: rtp_engine.h:181

◆ ast_rtp_options

Additional RTP options

Enumerator
AST_RTP_OPT_G726_NONSTANDARD 

Remote side is using non-standard G.726

Definition at line 145 of file rtp_engine.h.

145 {
146 /*! Remote side is using non-standard G.726 */
148};
@ AST_RTP_OPT_G726_NONSTANDARD
Definition: rtp_engine.h:147

◆ ast_rtp_property

RTP Properties that can be set on an RTP instance

Enumerator
AST_RTP_PROPERTY_NAT 

Enable symmetric RTP support

AST_RTP_PROPERTY_DTMF 

RTP instance will be carrying DTMF (using RFC2833)

AST_RTP_PROPERTY_DTMF_COMPENSATE 

Expect unreliable DTMF from remote party

AST_RTP_PROPERTY_STUN 

Enable STUN support

AST_RTP_PROPERTY_RTCP 

Enable RTCP support

AST_RTP_PROPERTY_ASYMMETRIC_CODEC 

Enable Asymmetric RTP Codecs

AST_RTP_PROPERTY_RETRANS_RECV 

Enable packet retransmission for received packets

AST_RTP_PROPERTY_RETRANS_SEND 

Enable packet retransmission for sent packets

AST_RTP_PROPERTY_REMB 

Enable REMB sending and receiving passthrough support

AST_RTP_PROPERTY_MAX 

Maximum number of RTP properties supported.

Note
THIS MUST BE THE LAST ENTRY IN THIS ENUM.

Definition at line 116 of file rtp_engine.h.

116 {
117 /*! Enable symmetric RTP support */
119 /*! RTP instance will be carrying DTMF (using RFC2833) */
121 /*! Expect unreliable DTMF from remote party */
123 /*! Enable STUN support */
125 /*! Enable RTCP support */
127 /*! Enable Asymmetric RTP Codecs */
129 /*! Enable packet retransmission for received packets */
131 /*! Enable packet retransmission for sent packets */
133 /*! Enable REMB sending and receiving passthrough support */
135
136 /*!
137 * \brief Maximum number of RTP properties supported
138 *
139 * \note THIS MUST BE THE LAST ENTRY IN THIS ENUM.
140 */
142};
@ AST_RTP_PROPERTY_NAT
Definition: rtp_engine.h:118
@ AST_RTP_PROPERTY_MAX
Maximum number of RTP properties supported.
Definition: rtp_engine.h:141
@ AST_RTP_PROPERTY_RETRANS_RECV
Definition: rtp_engine.h:130
@ AST_RTP_PROPERTY_RETRANS_SEND
Definition: rtp_engine.h:132
@ AST_RTP_PROPERTY_RTCP
Definition: rtp_engine.h:126
@ AST_RTP_PROPERTY_ASYMMETRIC_CODEC
Definition: rtp_engine.h:128
@ AST_RTP_PROPERTY_STUN
Definition: rtp_engine.h:124
@ AST_RTP_PROPERTY_DTMF
Definition: rtp_engine.h:120
@ AST_RTP_PROPERTY_DTMF_COMPENSATE
Definition: rtp_engine.h:122
@ AST_RTP_PROPERTY_REMB
Definition: rtp_engine.h:134

Function Documentation

◆ ast_debug_category_dtls_id()

uintmax_t ast_debug_category_dtls_id ( void  )

Definition at line 3787 of file rtp_engine.c.

3788{
3790}
static uintmax_t debug_category_dtls_id
Definition: rtp_engine.c:3785

References debug_category_dtls_id.

◆ ast_debug_category_dtls_packet_id()

uintmax_t ast_debug_category_dtls_packet_id ( void  )

Definition at line 3794 of file rtp_engine.c.

3795{
3797}
static uintmax_t debug_category_dtls_packet_id
Definition: rtp_engine.c:3792

References debug_category_dtls_packet_id.

◆ ast_debug_category_ice_id()

uintmax_t ast_debug_category_ice_id ( void  )

Definition at line 3801 of file rtp_engine.c.

3802{
3803 return debug_category_ice_id;
3804}
static uintmax_t debug_category_ice_id
Definition: rtp_engine.c:3799

References debug_category_ice_id.

◆ ast_debug_category_rtcp_id()

uintmax_t ast_debug_category_rtcp_id ( void  )

Definition at line 3773 of file rtp_engine.c.

3774{
3776}
static uintmax_t debug_category_rtcp_id
Definition: rtp_engine.c:3771

References debug_category_rtcp_id.

◆ ast_debug_category_rtcp_packet_id()

uintmax_t ast_debug_category_rtcp_packet_id ( void  )

Definition at line 3780 of file rtp_engine.c.

3781{
3783}
static uintmax_t debug_category_rtcp_packet_id
Definition: rtp_engine.c:3778

References debug_category_rtcp_packet_id.

◆ ast_debug_category_rtp_id()

uintmax_t ast_debug_category_rtp_id ( void  )

Definition at line 3759 of file rtp_engine.c.

3760{
3761 return debug_category_rtp_id;
3762}
static uintmax_t debug_category_rtp_id
Definition: rtp_engine.c:3757

References debug_category_rtp_id.

◆ ast_debug_category_rtp_packet_id()

uintmax_t ast_debug_category_rtp_packet_id ( void  )

Definition at line 3766 of file rtp_engine.c.

3767{
3769}
static uintmax_t debug_category_rtp_packet_id
Definition: rtp_engine.c:3764

References debug_category_rtp_packet_id.

◆ ast_rtp_codecs_find_payload_code()

int ast_rtp_codecs_find_payload_code ( struct ast_rtp_codecs codecs,
int  payload 
)

Search for the tx payload type in the ast_rtp_codecs structure.

Parameters
codecsCodecs structure to look in
payloadThe payload type format to look for
Returns
Numerical payload type or -1 if unable to find payload in codecs

Example usage:

static struct ao2_container * codecs
Registered codecs.
Definition: codec.c:48
int ast_rtp_codecs_find_payload_code(struct ast_rtp_codecs *codecs, int payload)
Search for the tx payload type in the ast_rtp_codecs structure.
Definition: rtp_engine.c:2167

This looks for the numerical payload for ULAW in the codecs structure.

Definition at line 2167 of file rtp_engine.c.

2168{
2169 struct ast_rtp_payload_type *type;
2170 int res = -1;
2171
2172 ast_rwlock_rdlock(&codecs->codecs_lock);
2173 if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
2174 type = AST_VECTOR_GET(&codecs->payload_mapping_tx, payload);
2175 if (type) {
2176 res = payload;
2177 }
2178 }
2179 ast_rwlock_unlock(&codecs->codecs_lock);
2180
2181 return res;
2182}
static const char type[]
Definition: chan_ooh323.c:109
#define ast_rwlock_rdlock(a)
Definition: lock.h:242
#define ast_rwlock_unlock(a)
Definition: lock.h:241
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:620
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:691

References ast_rwlock_rdlock, ast_rwlock_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, codecs, ast_rtp_payload_type::payload, and type.

Referenced by bridge_p2p_rtp_write().

◆ ast_rtp_codecs_get_framing()

unsigned int ast_rtp_codecs_get_framing ( struct ast_rtp_codecs codecs)

Get the framing used for a set of codecs.

Parameters
codecsCodecs structure to get the framing from
Returns
The framing to be used for the media stream associated with these codecs
Since
13.0.0

Definition at line 1688 of file rtp_engine.c.

1689{
1690 unsigned int framing;
1691
1692 ast_rwlock_rdlock(&codecs->codecs_lock);
1693 framing = codecs->framing;
1694 ast_rwlock_unlock(&codecs->codecs_lock);
1695
1696 return framing;
1697}

References ast_rwlock_rdlock, ast_rwlock_unlock, and codecs.

Referenced by ast_rtp_write(), create_outgoing_sdp_stream(), multicast_rtp_write(), and native_rtp_bridge_compatible_check().

◆ ast_rtp_codecs_get_payload()

struct ast_rtp_payload_type * ast_rtp_codecs_get_payload ( struct ast_rtp_codecs codecs,
int  payload 
)

Retrieve rx payload mapped information by payload type.

Parameters
codecsCodecs structure to look in
payloadNumerical payload to look up
Returns
Payload information.
Return values
NULLif payload does not exist.
Note
The payload returned by this function has its reference count increased. Callers are responsible for decrementing the reference count.

Example usage:

struct ast_rtp_payload_type *payload_type;
payload_type = ast_rtp_codecs_get_payload(&codecs, 0);
struct ast_rtp_payload_type * ast_rtp_codecs_get_payload(struct ast_rtp_codecs *codecs, int payload)
Retrieve rx payload mapped information by payload type.
Definition: rtp_engine.c:1554

This looks up the information for payload '0' from the codecs structure.

Definition at line 1554 of file rtp_engine.c.

1555{
1556 struct ast_rtp_payload_type *type = NULL;
1557
1558 if (payload < 0 || payload >= AST_RTP_MAX_PT) {
1559 return NULL;
1560 }
1561
1562 ast_rwlock_rdlock(&codecs->codecs_lock);
1563 if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_rx)) {
1564 type = AST_VECTOR_GET(&codecs->payload_mapping_rx, payload);
1565 ao2_bump(type);
1566 }
1567 ast_rwlock_unlock(&codecs->codecs_lock);
1568
1569 if (!type && payload <= AST_RTP_PT_LAST_STATIC) {
1573 }
1574
1575 return type;
1576}
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
static struct ast_rtp_payload_type * static_RTP_PT[AST_RTP_MAX_PT]
Mapping between Asterisk codecs and rtp payload types.
Definition: rtp_engine.c:279
static ast_rwlock_t static_RTP_PT_lock
Definition: rtp_engine.c:280
#define AST_RTP_MAX_PT
Definition: rtp_engine.h:83
#define AST_RTP_PT_LAST_STATIC
Definition: rtp_engine.h:89

References ao2_bump, AST_RTP_MAX_PT, AST_RTP_PT_LAST_STATIC, ast_rwlock_rdlock, ast_rwlock_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, codecs, NULL, ast_rtp_payload_type::payload, static_RTP_PT, static_RTP_PT_lock, and type.

Referenced by ast_rtp_dtmf_begin(), ast_rtp_interpret(), and bridge_p2p_rtp_write().

◆ ast_rtp_codecs_get_payload_format()

struct ast_format * ast_rtp_codecs_get_payload_format ( struct ast_rtp_codecs codecs,
int  payload 
)

Retrieve the actual ast_format stored on the codecs structure for a specific tx payload type.

Parameters
codecsCodecs structure to look in
payloadNumerical payload type to look up
Returns
pointer to format structure on success
Return values
NULLon failure
Note
The format returned by this function has its reference count increased. Callers are responsible for decrementing the reference count.
Since
10.0

Definition at line 1656 of file rtp_engine.c.

1657{
1658 struct ast_rtp_payload_type *type;
1659 struct ast_format *format = NULL;
1660
1661 if (payload < 0 || payload >= AST_RTP_MAX_PT) {
1662 return NULL;
1663 }
1664
1665 ast_rwlock_rdlock(&codecs->codecs_lock);
1666 if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
1667 type = AST_VECTOR_GET(&codecs->payload_mapping_tx, payload);
1668 if (type && type->asterisk_format) {
1669 format = ao2_bump(type->format);
1670 }
1671 }
1672 ast_rwlock_unlock(&codecs->codecs_lock);
1673
1674 return format;
1675}
Definition of a media format.
Definition: format.c:43

References ao2_bump, AST_RTP_MAX_PT, ast_rwlock_rdlock, ast_rwlock_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, codecs, NULL, and type.

Referenced by get_codecs().

◆ ast_rtp_codecs_get_preferred_dtmf_format_pt()

int ast_rtp_codecs_get_preferred_dtmf_format_pt ( struct ast_rtp_codecs codecs)

Retrieve rx preferred dtmf format payload type.

Parameters
codecsCodecs structure to look in
Returns
Payload type of preferred dtmf format.
Return values
-1if not set.

Example usage:

int payload;
int ast_rtp_codecs_get_preferred_dtmf_format_pt(struct ast_rtp_codecs *codecs)
Retrieve rx preferred dtmf format payload type.
Definition: rtp_engine.c:1595

This looks up the preferred dtmf format pt on the codec

Definition at line 1595 of file rtp_engine.c.

1596{
1597 int pt = -1;
1598 ast_rwlock_rdlock(&codecs->codecs_lock);
1599 pt = codecs->preferred_dtmf_pt;
1600 ast_rwlock_unlock(&codecs->codecs_lock);
1601 return pt;
1602}

References ast_rwlock_rdlock, ast_rwlock_unlock, and codecs.

Referenced by ast_rtp_dtmf_begin().

◆ ast_rtp_codecs_get_preferred_dtmf_format_rate()

int ast_rtp_codecs_get_preferred_dtmf_format_rate ( struct ast_rtp_codecs codecs)

Retrieve rx preferred dtmf format sample rate.

Parameters
codecsCodecs structure to look in
Returns
Sample rate of preferred dtmf format.
Return values
-1if not set.

Example usage:

int sample_rate;
int ast_rtp_codecs_get_preferred_dtmf_format_rate(struct ast_rtp_codecs *codecs)
Retrieve rx preferred dtmf format sample rate.
Definition: rtp_engine.c:1604

This looks up the preferred dtmf format sample rate on the codec

Definition at line 1604 of file rtp_engine.c.

1605{
1606 int rate = -1;
1607 ast_rwlock_rdlock(&codecs->codecs_lock);
1608 rate = codecs->preferred_dtmf_rate;
1609 ast_rwlock_unlock(&codecs->codecs_lock);
1610 return rate;
1611}

References ast_rwlock_rdlock, ast_rwlock_unlock, and codecs.

Referenced by ast_rtp_dtmf_begin().

◆ ast_rtp_codecs_get_preferred_format()

struct ast_format * ast_rtp_codecs_get_preferred_format ( struct ast_rtp_codecs codecs)

Retrieve rx preferred format.

Parameters
codecsCodecs structure to look in
Returns
format information.
Return values
NULLif format does not exist.
Note
The format returned by this function has its reference count increased. Callers are responsible for decrementing the reference count.

Example usage:

struct ast_format *payload_format;
struct ast_format * ast_rtp_codecs_get_preferred_format(struct ast_rtp_codecs *codecs)
Retrieve rx preferred format.
Definition: rtp_engine.c:1578

This looks up the preferred format on the codec

Definition at line 1578 of file rtp_engine.c.

1579{
1580 struct ast_format *format;
1581 ast_rwlock_rdlock(&codecs->codecs_lock);
1582 format = ao2_bump(codecs->preferred_format);
1583 ast_rwlock_unlock(&codecs->codecs_lock);
1584 return format;
1585}

References ao2_bump, ast_rwlock_rdlock, ast_rwlock_unlock, and codecs.

Referenced by ast_rtp_dtmf_begin().

◆ ast_rtp_codecs_get_stream_type()

enum ast_media_type ast_rtp_codecs_get_stream_type ( struct ast_rtp_codecs codecs)

Determine the type of RTP stream media from the codecs mapped.

Since
13.19.0
Parameters
codecsCodecs structure to look in
Returns
Media type or AST_MEDIA_TYPE_UNKNOWN if no codecs mapped.

Definition at line 1535 of file rtp_engine.c.

1536{
1537 enum ast_media_type stream_type = AST_MEDIA_TYPE_UNKNOWN;
1538 int payload;
1539 struct ast_rtp_payload_type *type;
1540
1541 ast_rwlock_rdlock(&codecs->codecs_lock);
1542 for (payload = 0; payload < AST_VECTOR_SIZE(&codecs->payload_mapping_rx); ++payload) {
1543 type = AST_VECTOR_GET(&codecs->payload_mapping_rx, payload);
1544 if (type && type->asterisk_format) {
1545 stream_type = ast_format_get_type(type->format);
1546 break;
1547 }
1548 }
1549 ast_rwlock_unlock(&codecs->codecs_lock);
1550
1551 return stream_type;
1552}
ast_media_type
Types of media.
Definition: codec.h:30
@ AST_MEDIA_TYPE_UNKNOWN
Definition: codec.h:31
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354

References ast_format_get_type(), AST_MEDIA_TYPE_UNKNOWN, ast_rwlock_rdlock, ast_rwlock_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, codecs, ast_rtp_payload_type::payload, and type.

Referenced by ast_rtp_read().

◆ ast_rtp_codecs_payload_code()

int ast_rtp_codecs_payload_code ( struct ast_rtp_codecs codecs,
int  asterisk_format,
struct ast_format format,
int  code 
)

Retrieve a rx mapped payload type based on whether it is an Asterisk format and the code.

Parameters
codecsCodecs structure to look in
asterisk_formatNon-zero if the given Asterisk format is present
formatAsterisk format to look for
codeThe format to look for

Find the currently assigned rx mapped payload type based on whether it is an Asterisk format or non-format code. If one is currently not assigned then create a rx payload type mapping.

Returns
Numerical payload type
Return values
-1if could not assign.

Example usage:

struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
Definition: format_cache.c:86
int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code)
Retrieve a rx mapped payload type based on whether it is an Asterisk format and the code.
Definition: rtp_engine.c:2025

This looks for the numerical payload for ULAW in the codecs structure.

Since
1.8

Definition at line 2025 of file rtp_engine.c.

2026{
2027 return ast_rtp_codecs_payload_code_sample_rate(codecs, asterisk_format, format, code, 0);
2028}
int ast_rtp_codecs_payload_code_sample_rate(struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code, unsigned int sample_rate)
Retrieve a rx mapped payload type based on whether it is an Asterisk format, the code and the sample ...
Definition: rtp_engine.c:2030

References ast_rtp_codecs_payload_code_sample_rate(), ast_rtp_payload_type::asterisk_format, codecs, and ast_rtp_payload_type::format.

Referenced by apply_cap_to_bundled(), create_outgoing_sdp_stream(), and jingle_add_payloads_to_description().

◆ ast_rtp_codecs_payload_code_sample_rate()

int ast_rtp_codecs_payload_code_sample_rate ( struct ast_rtp_codecs codecs,
int  asterisk_format,
struct ast_format format,
int  code,
unsigned int  sample_rate 
)

Retrieve a rx mapped payload type based on whether it is an Asterisk format, the code and the sample rate.

Parameters
codecsCodecs structure to look in
asterisk_formatNon-zero if the given Asterisk format is present
formatAsterisk format to look for
codeThe format to look for
sample_rateNon-zero if we want to also match on sample rate.

Find the currently assigned rx mapped payload type based on whether it is an Asterisk format or non-format code. If one is currently not assigned then create a rx payload type mapping.

Returns
Numerical payload type
Return values
-1if could not assign.

Example usage:

#define AST_RTP_DTMF
Definition: rtp_engine.h:294
int ast_rtp_codecs_payload_code_sample_rate(struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code, unsigned int sample_rate)
Retrieve a rx mapped payload type based on whether it is an Asterisk format, the code and the sample ...
Definition: rtp_engine.c:2030

This looks for the numerical payload for a DTMF type with a sample rate of 8kHz in the codecs structure.

Since
22.0.0

Definition at line 2030 of file rtp_engine.c.

2031{
2032 struct ast_rtp_payload_type *type;
2033 int idx;
2034 int payload = -1;
2035
2037 if (!asterisk_format) {
2038 ast_rwlock_rdlock(&codecs->codecs_lock);
2039 for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_rx); ++idx) {
2040 type = AST_VECTOR_GET(&codecs->payload_mapping_rx, idx);
2041 if (!type) {
2042 continue;
2043 }
2044
2045 if (!type->asterisk_format
2046 && type->primary_mapping
2047 && type->rtp_code == code
2048 && (sample_rate == 0 || type->sample_rate == sample_rate)) {
2049 payload = idx;
2050 break;
2051 }
2052 }
2053 ast_rwlock_unlock(&codecs->codecs_lock);
2054 } else if (format) {
2055 ast_rwlock_rdlock(&codecs->codecs_lock);
2056 for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_rx); ++idx) {
2057 type = AST_VECTOR_GET(&codecs->payload_mapping_rx, idx);
2058 if (!type) {
2059 continue;
2060 }
2061
2062 if (type->asterisk_format
2063 && type->primary_mapping
2065 payload = idx;
2066 break;
2067 }
2068 }
2069 ast_rwlock_unlock(&codecs->codecs_lock);
2070 }
2071
2072 if (payload < 0) {
2074 code, 0, sample_rate);
2075 }
2077
2078 return payload;
2079}
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
@ AST_FORMAT_CMP_EQUAL
Definition: format.h:36
static int rtp_codecs_assign_payload_code_rx(struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code, int explicit, unsigned int sample_rate)
Definition: rtp_engine.c:1934
unsigned int sample_rate
Definition: rtp_engine.h:318
struct ast_format * format
Definition: rtp_engine.h:306

References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_rwlock_rdlock, ast_rwlock_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_rtp_payload_type::asterisk_format, codecs, ast_rtp_payload_type::format, ast_rtp_payload_type::payload, rtp_codecs_assign_payload_code_rx(), ast_rtp_payload_type::sample_rate, static_RTP_PT_lock, and type.

Referenced by ast_rtp_codecs_payload_code(), and create_outgoing_sdp_stream().

◆ ast_rtp_codecs_payload_code_tx()

int ast_rtp_codecs_payload_code_tx ( struct ast_rtp_codecs codecs,
int  asterisk_format,
const struct ast_format format,
int  code 
)

Retrieve a tx mapped payload type based on whether it is an Asterisk format and the code.

Since
14.0.0
Parameters
codecsCodecs structure to look in
asterisk_formatNon-zero if the given Asterisk format is present
formatAsterisk format to look for
codeThe format to look for
Returns
Numerical payload type
Return values
-1if not found.

Definition at line 2162 of file rtp_engine.c.

2163{
2164 return ast_rtp_codecs_payload_code_tx_sample_rate(codecs, asterisk_format, format, code, 0);
2165}
int ast_rtp_codecs_payload_code_tx_sample_rate(struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code, unsigned int sample_rate)
Retrieve a tx mapped payload type based on whether it is an Asterisk format and the code.
Definition: rtp_engine.c:2091

References ast_rtp_codecs_payload_code_tx_sample_rate(), ast_rtp_payload_type::asterisk_format, codecs, and ast_rtp_payload_type::format.

Referenced by ast_rtp_dtmf_begin(), ast_rtp_sendcng(), ast_rtp_write(), multicast_rtp_write(), and send_start_rtp().

◆ ast_rtp_codecs_payload_code_tx_sample_rate()

int ast_rtp_codecs_payload_code_tx_sample_rate ( struct ast_rtp_codecs codecs,
int  asterisk_format,
const struct ast_format format,
int  code,
unsigned int  sample_rate 
)

Retrieve a tx mapped payload type based on whether it is an Asterisk format and the code.

Since
22.0.0
Parameters
codecsCodecs structure to look in
asterisk_formatNon-zero if the given Asterisk format is present
formatAsterisk format to look for
codeThe format to look for
sample_rateThe sample rate to look for, zero if we don't care
Returns
Numerical payload type
Return values
-1if not found.

Definition at line 2091 of file rtp_engine.c.

2092{
2093 struct ast_rtp_payload_type *type;
2094 int idx;
2095 int payload = -1;
2096
2097 if (!asterisk_format) {
2098 ast_rwlock_rdlock(&codecs->codecs_lock);
2099 for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_tx); ++idx) {
2100 type = AST_VECTOR_GET(&codecs->payload_mapping_tx, idx);
2101 if (!type) {
2102 continue;
2103 }
2104
2105 if (!type->asterisk_format
2106 && type->rtp_code == code
2107 /* Multiple DTMF types share an rtp code but have different sample rates. To ensure we have the right
2108 type we therefore need the sample rate as well as the format and code. Other types have a fixed
2109 sample rate so this is not needed. For those pass in a sample rate of 0 or use ast_rtp_codecs_payload_code_tx. */
2110 && (sample_rate == 0 || type->sample_rate == sample_rate)) {
2111 payload = idx;
2112 break;
2113 }
2114 }
2115 ast_rwlock_unlock(&codecs->codecs_lock);
2116 } else if (format) {
2117 ast_rwlock_rdlock(&codecs->codecs_lock);
2118 for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_tx); ++idx) {
2119 type = AST_VECTOR_GET(&codecs->payload_mapping_tx, idx);
2120 if (!type) {
2121 continue;
2122 }
2123
2124 if (type->asterisk_format
2126 payload = idx;
2127 break;
2128 }
2129 }
2130 ast_rwlock_unlock(&codecs->codecs_lock);
2131 }
2132
2133 if (payload < 0) {
2137
2138 /*
2139 * Comfort noise is NOT used as an SDP negotiated format within Asterisk;
2140 * instead, it is used when it is not negotiated. This special case allows
2141 * its payload to be returned when not negotiated, allowing keep alive to
2142 * function as expected.
2143 */
2144 if (payload == 13 && code == AST_RTP_CN) {
2145 return payload;
2146 }
2147
2148 ast_rwlock_rdlock(&codecs->codecs_lock);
2149 if (payload >= 0 && payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)){
2150 type = AST_VECTOR_GET(&codecs->payload_mapping_tx, payload);
2151 if (!type || (sample_rate != 0 && type->sample_rate != sample_rate)) {
2152 /* Don't use the type if we can't find it or it doesn't match the supplied sample_rate */
2153 payload = -1;
2154 }
2155 }
2156 ast_rwlock_unlock(&codecs->codecs_lock);
2157 }
2158
2159 return payload;
2160}
static int find_static_payload_type(int asterisk_format, const struct ast_format *format, int code)
Definition: rtp_engine.c:1743
#define AST_RTP_CN
Definition: rtp_engine.h:296

References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_RTP_CN, ast_rwlock_rdlock, ast_rwlock_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_rtp_payload_type::asterisk_format, codecs, find_static_payload_type(), ast_rtp_payload_type::format, ast_rtp_payload_type::payload, ast_rtp_payload_type::sample_rate, static_RTP_PT_lock, and type.

Referenced by ast_rtp_codecs_payload_code_tx(), ast_rtp_dtmf_begin(), and bridge_p2p_rtp_write().

◆ ast_rtp_codecs_payload_formats()

void ast_rtp_codecs_payload_formats ( struct ast_rtp_codecs codecs,
struct ast_format_cap astformats,
int *  nonastformats 
)

Retrieve all formats that were found.

Parameters
codecsCodecs structure to look in
astformatsA capabilities structure to put the Asterisk formats in.
nonastformatsAn integer to put the non-Asterisk formats in

Example usage:

struct ast_format_cap *astformats = ast_format_cap_alloc_nolock()
int nonastformats;
ast_rtp_codecs_payload_formats(&codecs, astformats, &nonastformats);
void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, struct ast_format_cap *astformats, int *nonastformats)
Retrieve all formats that were found.
Definition: rtp_engine.c:1699
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54

This retrieves all the formats known about in the codecs structure and puts the Asterisk ones in the integer pointed to by astformats and the non-Asterisk ones in the integer pointed to by nonastformats.

Since
1.8

Definition at line 1699 of file rtp_engine.c.

1700{
1701 int idx;
1702
1704 *nonastformats = 0;
1705
1706 ast_rwlock_rdlock(&codecs->codecs_lock);
1707
1708 for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_tx); ++idx) {
1709 struct ast_rtp_payload_type *type;
1710
1711 type = AST_VECTOR_GET(&codecs->payload_mapping_tx, idx);
1712 if (!type) {
1713 continue;
1714 }
1715
1716 if (type->asterisk_format) {
1717 ast_format_cap_append(astformats, type->format, 0);
1718 } else {
1719 *nonastformats |= type->rtp_code;
1720 }
1721 }
1722 if (codecs->framing) {
1723 ast_format_cap_set_framing(astformats, codecs->framing);
1724 }
1725
1726 ast_rwlock_unlock(&codecs->codecs_lock);
1727}
void ast_format_cap_remove_by_type(struct ast_format_cap *cap, enum ast_media_type type)
Remove all formats matching a specific format type.
Definition: format_cap.c:523
#define ast_format_cap_append(cap, format, framing)
Add format capability to capabilities structure.
Definition: format_cap.h:99
void ast_format_cap_set_framing(struct ast_format_cap *cap, unsigned int framing)
Set the global framing.
Definition: format_cap.c:136

References ast_format_cap_append, ast_format_cap_remove_by_type(), ast_format_cap_set_framing(), AST_MEDIA_TYPE_UNKNOWN, ast_rwlock_rdlock, ast_rwlock_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, codecs, and type.

Referenced by jingle_interpret_description().

◆ ast_rtp_codecs_payload_replace_format()

int ast_rtp_codecs_payload_replace_format ( struct ast_rtp_codecs codecs,
int  payload,
struct ast_format format 
)

Update the format associated with a tx payload type in a codecs structure.

Parameters
codecsCodecs structure to operate on
payloadNumerical payload type to look up
formatThe format to replace the existing one
Return values
0success
-1failure
Since
13

Definition at line 1622 of file rtp_engine.c.

1623{
1624 struct ast_rtp_payload_type *type;
1625
1626 if (payload < 0 || payload >= AST_RTP_MAX_PT || !format) {
1627 return -1;
1628 }
1629
1631 if (!type) {
1632 return -1;
1633 }
1634 ao2_ref(format, +1);
1635 type->format = format;
1636 type->asterisk_format = 1;
1637 type->payload = payload;
1638 type->primary_mapping = 1;
1639
1640 ast_rwlock_wrlock(&codecs->codecs_lock);
1642 if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
1643 ao2_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, payload));
1644 }
1645 if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, type)) {
1646 ao2_ref(type, -1);
1647 }
1648 } else {
1649 ao2_ref(type, -1);
1650 }
1651 ast_rwlock_unlock(&codecs->codecs_lock);
1652
1653 return 0;
1654}
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define ast_rwlock_wrlock(a)
Definition: lock.h:243
struct ast_rtp_payload_type * ast_rtp_engine_alloc_payload_type(void)
Allocation routine for ast_rtp_payload_type.
Definition: rtp_engine.c:331
static int payload_mapping_tx_is_present(const struct ast_rtp_codecs *codecs, const struct ast_rtp_payload_type *to_match)
Definition: rtp_engine.c:1188
#define AST_VECTOR_REPLACE(vec, idx, elem)
Replace an element at a specific position in a vector, growing the vector if needed.
Definition: vector.h:295

References ao2_cleanup, ao2_ref, ast_rtp_engine_alloc_payload_type(), AST_RTP_MAX_PT, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_GET, AST_VECTOR_REPLACE, AST_VECTOR_SIZE, codecs, ast_rtp_payload_type::format, ast_rtp_payload_type::payload, payload_mapping_tx_is_present(), and type.

Referenced by get_codecs().

◆ ast_rtp_codecs_payload_set_rx()

int ast_rtp_codecs_payload_set_rx ( struct ast_rtp_codecs codecs,
int  code,
struct ast_format format 
)

Set a payload code for use with a specific Asterisk format.

Parameters
codecsCodecs structure to manipulate
codeThe payload code
formatAsterisk format
Return values
0Payload was set to the given format
-1Payload was in use or could not be set
Since
15.0.0

Definition at line 2081 of file rtp_engine.c.

2082{
2083 return rtp_codecs_assign_payload_code_rx(codecs, 1, format, code, 1, 0);
2084}

References codecs, ast_rtp_payload_type::format, and rtp_codecs_assign_payload_code_rx().

Referenced by apply_cap_to_bundled(), and create_outgoing_sdp_stream().

◆ ast_rtp_codecs_payload_set_rx_sample_rate()

int ast_rtp_codecs_payload_set_rx_sample_rate ( struct ast_rtp_codecs codecs,
int  code,
struct ast_format format,
unsigned int  sample_rate 
)

Set a payload code with sample rate for use with a specific Asterisk format.

Parameters
codecsCodecs structure to manipulate
codeThe payload code
formatAsterisk format
sample_rateSample rate of the format, 0 to use the format's default
Return values
0Payload was set to the given format
-1Payload was in use or could not be set
Since
22.0.0

Definition at line 2086 of file rtp_engine.c.

2087{
2088 return rtp_codecs_assign_payload_code_rx(codecs, 1, format, code, 0, sample_rate);
2089}

References codecs, ast_rtp_payload_type::format, rtp_codecs_assign_payload_code_rx(), and ast_rtp_payload_type::sample_rate.

◆ ast_rtp_codecs_payloads_clear()

void ast_rtp_codecs_payloads_clear ( struct ast_rtp_codecs codecs,
struct ast_rtp_instance instance 
)

Clear rx and tx payload mapping information from an RTP instance.

Parameters
codecsThe codecs structure that payloads will be cleared from
instanceOptionally the instance that the codecs structure belongs to

Example usage:

void ast_rtp_codecs_payloads_clear(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance)
Clear rx and tx payload mapping information from an RTP instance.
Definition: rtp_engine.c:1025

This clears the codecs structure and puts it into a pristine state.

Since
1.8

Definition at line 1025 of file rtp_engine.c.

1026{
1029
1030 if (instance && instance->engine && instance->engine->payload_set) {
1031 int i;
1032
1033 ao2_lock(instance);
1034 for (i = 0; i < AST_RTP_MAX_PT; i++) {
1035 instance->engine->payload_set(instance, i, 0, NULL, 0);
1036 }
1037 ao2_unlock(instance);
1038 }
1039}
#define ao2_unlock(a)
Definition: astobj2.h:729
#define ao2_lock(a)
Definition: astobj2.h:717
void ast_rtp_codecs_payloads_destroy(struct ast_rtp_codecs *codecs)
Destroy the contents of an RTP codecs structure (but not the structure itself)
Definition: rtp_engine.c:1002
int ast_rtp_codecs_payloads_initialize(struct ast_rtp_codecs *codecs)
Initialize an RTP codecs structure.
Definition: rtp_engine.c:986
void(* payload_set)(struct ast_rtp_instance *instance, int payload, int asterisk_format, struct ast_format *format, int code)
Definition: rtp_engine.h:694
struct ast_rtp_engine * engine
Definition: rtp_engine.c:196

References ao2_lock, ao2_unlock, ast_rtp_codecs_payloads_destroy(), ast_rtp_codecs_payloads_initialize(), AST_RTP_MAX_PT, codecs, ast_rtp_instance::engine, NULL, and ast_rtp_engine::payload_set.

◆ ast_rtp_codecs_payloads_copy()

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.

Parameters
srcThe source codecs structure
destThe destination codecs structure that the values from src will be copied to
instanceOptionally the instance that the dst codecs structure belongs to

Example usage:

ast_rtp_codecs_payloads_copy(&codecs0, &codecs1, NULL);
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:1279

This copies the payloads from the codecs0 structure to the codecs1 structure, overwriting any current values.

Since
1.8

Definition at line 1279 of file rtp_engine.c.

1280{
1281 int idx;
1282 struct ast_rtp_payload_type *type;
1283
1285
1286 /* Deadlock avoidance because of held write lock. */
1287 while (ast_rwlock_tryrdlock(&src->codecs_lock)) {
1289 sched_yield();
1291 }
1292
1293 /*
1294 * This represents a completely new mapping of what the remote party is
1295 * expecting for payloads, so we clear out the entire tx payload mapping
1296 * vector and replace it.
1297 */
1298 for (idx = 0; idx < AST_VECTOR_SIZE(&dest->payload_mapping_tx); ++idx) {
1299 type = AST_VECTOR_GET(&dest->payload_mapping_tx, idx);
1300 ao2_t_cleanup(type, "destroying ast_rtp_codec tx mapping");
1302 }
1303
1304 rtp_codecs_payloads_copy_rx(src, dest, instance);
1305 rtp_codecs_payloads_copy_tx(src, dest, instance);
1306 dest->framing = src->framing;
1310
1313}
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
Definition: astobj2.h:501
#define ao2_t_cleanup(obj, tag)
Definition: astobj2.h:1935
#define ast_rwlock_tryrdlock(a)
Definition: lock.h:244
static void rtp_codecs_payloads_copy_tx(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
Definition: rtp_engine.c:1248
static void rtp_codecs_payloads_copy_rx(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
Definition: rtp_engine.c:1152
int preferred_dtmf_pt
Definition: rtp_engine.h:770
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:758
int preferred_dtmf_rate
Definition: rtp_engine.h:768
struct ast_format * preferred_format
Definition: rtp_engine.h:766
unsigned int framing
Definition: rtp_engine.h:764
struct ast_rtp_codecs::@282 payload_mapping_tx

References ao2_replace, ao2_t_cleanup, ast_rwlock_tryrdlock, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_GET, AST_VECTOR_REPLACE, AST_VECTOR_SIZE, ast_rtp_codecs::codecs_lock, ast_rtp_codecs::framing, NULL, ast_rtp_codecs::payload_mapping_tx, ast_rtp_codecs::preferred_dtmf_pt, ast_rtp_codecs::preferred_dtmf_rate, ast_rtp_codecs::preferred_format, rtp_codecs_payloads_copy_rx(), rtp_codecs_payloads_copy_tx(), and type.

Referenced by jingle_interpret_description(), set_caps(), and set_incoming_call_offer_cap().

◆ ast_rtp_codecs_payloads_destroy()

void ast_rtp_codecs_payloads_destroy ( struct ast_rtp_codecs codecs)

Destroy the contents of an RTP codecs structure (but not the structure itself)

Parameters
codecsThe codecs structure to destroy the contents of

Example usage:

void ast_rtp_codecs_payloads_destroy(struct ast_rtp_codecs *codecs)
Destroy the contents of an RTP codecs structure (but not the structure itself)
Definition: rtp_engine.c:1002
Since
11

Definition at line 1002 of file rtp_engine.c.

1003{
1004 int idx;
1005 struct ast_rtp_payload_type *type;
1006
1007 for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_rx); ++idx) {
1008 type = AST_VECTOR_GET(&codecs->payload_mapping_rx, idx);
1009 ao2_t_cleanup(type, "destroying ast_rtp_codec rx mapping");
1010 }
1011 AST_VECTOR_FREE(&codecs->payload_mapping_rx);
1012
1013 for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_tx); ++idx) {
1014 type = AST_VECTOR_GET(&codecs->payload_mapping_tx, idx);
1015 ao2_t_cleanup(type, "destroying ast_rtp_codec tx mapping");
1016 }
1017 AST_VECTOR_FREE(&codecs->payload_mapping_tx);
1018
1019 ao2_t_cleanup(codecs->preferred_format, "destroying ast_rtp_codec preferred format");
1020 codecs->preferred_format = NULL;
1021
1022 ast_rwlock_destroy(&codecs->codecs_lock);
1023}
#define ast_rwlock_destroy(rwlock)
Definition: lock.h:240
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:185

References ao2_t_cleanup, ast_rwlock_destroy, AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_SIZE, codecs, NULL, and type.

Referenced by ast_rtp_codecs_payloads_clear(), ast_stream_free(), ast_stream_set_rtp_codecs(), instance_destructor(), jingle_interpret_description(), set_caps(), and set_incoming_call_offer_cap().

◆ ast_rtp_codecs_payloads_initialize()

int ast_rtp_codecs_payloads_initialize ( struct ast_rtp_codecs codecs)

Initialize an RTP codecs structure.

Parameters
codecsThe codecs structure to initialize
Return values
0success
-1failure

Example usage:

int ast_rtp_codecs_payloads_initialize(struct ast_rtp_codecs *codecs)
Initialize an RTP codecs structure.
Definition: rtp_engine.c:986
Since
11

Definition at line 986 of file rtp_engine.c.

987{
988 int res;
989
990 codecs->framing = 0;
991 ast_rwlock_init(&codecs->codecs_lock);
992 res = AST_VECTOR_INIT(&codecs->payload_mapping_rx, AST_RTP_MAX_PT);
993 res |= AST_VECTOR_INIT(&codecs->payload_mapping_tx, AST_RTP_MAX_PT);
994 if (res) {
995 AST_VECTOR_FREE(&codecs->payload_mapping_rx);
996 AST_VECTOR_FREE(&codecs->payload_mapping_tx);
997 }
998
999 return res;
1000}
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
Definition: lock.h:231
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:124

References AST_RTP_MAX_PT, ast_rwlock_init, AST_VECTOR_FREE, AST_VECTOR_INIT, and codecs.

Referenced by ast_rtp_codecs_payloads_clear(), ast_rtp_instance_new(), get_codecs(), and jingle_interpret_description().

◆ ast_rtp_codecs_payloads_set_m_type()

void ast_rtp_codecs_payloads_set_m_type ( struct ast_rtp_codecs codecs,
struct ast_rtp_instance instance,
int  payload 
)

Record tx payload type information that was seen in an m= SDP line.

Parameters
codecsThe codecs structure to muck with
instanceOptionally the instance that the codecs structure belongs to
payloadNumerical payload that was seen in the m= SDP line

Example usage:

void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
Record tx payload type information that was seen in an m= SDP line.
Definition: rtp_engine.c:1362

This records that the numerical payload '0' was seen in the codecs structure.

Since
1.8

Definition at line 1362 of file rtp_engine.c.

1363{
1365
1366 if (payload < 0 || payload >= AST_RTP_MAX_PT || payload > AST_RTP_PT_LAST_STATIC) {
1367 return;
1368 }
1369
1373 if (!new_type) {
1374 ast_debug(1, "Don't have a default tx payload type %d format for m type on %p\n",
1375 payload, codecs);
1376 return;
1377 }
1378
1379 ast_debug(1, "Setting tx payload type %d based on m type on %p\n",
1380 payload, codecs);
1381
1382 ast_rwlock_wrlock(&codecs->codecs_lock);
1383
1385 if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
1386 ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, payload),
1387 "cleaning up replaced tx payload type");
1388 }
1389
1390 if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, new_type)) {
1391 ao2_ref(new_type, -1);
1392 } else if (instance && instance->engine && instance->engine->payload_set) {
1393 ao2_lock(instance);
1394 instance->engine->payload_set(instance, payload, new_type->asterisk_format, new_type->format, new_type->rtp_code);
1395 ao2_unlock(instance);
1396 }
1397 } else {
1398 ao2_ref(new_type, -1);
1399 }
1400
1401 ast_rwlock_unlock(&codecs->codecs_lock);
1402}
#define ast_debug(level,...)
Log a DEBUG message.

References ao2_bump, ao2_lock, ao2_ref, ao2_t_cleanup, ao2_unlock, ast_debug, AST_RTP_MAX_PT, AST_RTP_PT_LAST_STATIC, ast_rwlock_rdlock, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_GET, AST_VECTOR_REPLACE, AST_VECTOR_SIZE, codecs, ast_rtp_instance::engine, 10aedae86a32_add_outgoing_enum_va::new_type, ast_rtp_payload_type::payload, payload_mapping_tx_is_present(), ast_rtp_engine::payload_set, static_RTP_PT, and static_RTP_PT_lock.

Referenced by get_codecs().

◆ ast_rtp_codecs_payloads_set_rtpmap_type()

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 tx payload type information that was seen in an a=rtpmap: SDP line.

Parameters
codecsThe codecs structure to muck with
instanceOptionally the instance that the codecs structure belongs to
payloadNumerical payload that was seen in the a=rtpmap: SDP line
mimetypeThe string mime type that was seen
mimesubtypeThe string mime sub type that was seen
optionsOptional options that may change the behavior of this specific payload
Return values
0success
-1failure, invalid payload numbe
-2failure, unknown mimetype

Example usage:

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 tx payload type information that was seen in an a=rtpmap: SDP line.
Definition: rtp_engine.c:1490

This records that the numerical payload '0' was seen with mime type 'audio' and sub mime type 'PCMU' in the codecs structure.

Since
1.8

Definition at line 1490 of file rtp_engine.c.

1491{
1492 return ast_rtp_codecs_payloads_set_rtpmap_type_rate(codecs, instance, payload, mimetype, mimesubtype, options, 0);
1493}
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 tx payload type to a known MIME media type for a codec with a specific sample rate.
Definition: rtp_engine.c:1404
static struct test_options options

References ast_rtp_codecs_payloads_set_rtpmap_type_rate(), codecs, options, and ast_rtp_payload_type::payload.

Referenced by configure_local_rtp(), jingle_interpret_description(), ooh323_set_write_format(), and setup_rtp_connection().

◆ ast_rtp_codecs_payloads_set_rtpmap_type_rate()

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 tx payload type to a known MIME media type for a codec with a specific sample rate.

Parameters
codecsRTP structure to modify
instanceOptionally the instance that the codecs structure belongs to
ptPayload type entry to modify
mimetypetop-level MIME type of media stream (typically "audio", "video", "text", etc.)
mimesubtypeMIME subtype of media stream (typically a codec name)
optionsZero or more flags from the ast_rtp_options enum
sample_rateThe sample rate of the media stream

This function 'fills in' an entry in the list of possible formats for a media stream associated with an RTP structure.

Return values
0on success
-1if the payload type is out of range
-2if the mimeType/mimeSubtype combination was not found
Since
1.8

Definition at line 1404 of file rtp_engine.c.

1408{
1409 unsigned int idx;
1410 int found = 0;
1411
1412 if (pt < 0 || pt >= AST_RTP_MAX_PT) {
1413 return -1; /* bogus payload type */
1414 }
1415
1417 ast_rwlock_wrlock(&codecs->codecs_lock);
1418
1419 for (idx = 0; idx < mime_types_len; ++idx) {
1420 const struct ast_rtp_mime_type *t = &ast_rtp_mime_types[idx];
1422
1423 if (strcasecmp(mimesubtype, t->subtype)) {
1424 continue;
1425 }
1426
1427 if (strcasecmp(mimetype, t->type)) {
1428 continue;
1429 }
1430
1431 /* if both sample rates have been supplied, and they don't match,
1432 * then this not a match; if one has not been supplied, then the
1433 * rates are not compared */
1434 if (sample_rate && t->sample_rate &&
1435 (sample_rate != t->sample_rate)) {
1436 continue;
1437 }
1438
1439 found = 1;
1440
1442 if (!new_type) {
1443 continue;
1444 }
1445
1446 new_type->asterisk_format = t->payload_type.asterisk_format;
1447 new_type->rtp_code = t->payload_type.rtp_code;
1448 new_type->payload = pt;
1449 new_type->primary_mapping = 1;
1450 new_type->sample_rate = sample_rate;
1455 } else {
1456 new_type->format = t->payload_type.format;
1457 }
1458
1459 if (new_type->format) {
1460 /* SDP parsing automatically increases the reference count */
1461 new_type->format = ast_format_parse_sdp_fmtp(new_type->format, "");
1462 }
1463
1465 if (pt < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
1466 ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, pt),
1467 "cleaning up replaced tx payload type");
1468 }
1469
1470 if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, pt, new_type)) {
1471 ao2_ref(new_type, -1);
1472 } else if (instance && instance->engine && instance->engine->payload_set) {
1473 ao2_lock(instance);
1474 instance->engine->payload_set(instance, pt, new_type->asterisk_format, new_type->format, new_type->rtp_code);
1475 ao2_unlock(instance);
1476 }
1477 } else {
1478 ao2_ref(new_type, -1);
1479 }
1480
1481 break;
1482 }
1483
1484 ast_rwlock_unlock(&codecs->codecs_lock);
1486
1487 return (found ? 0 : -2);
1488}
struct ast_format * ast_format_parse_sdp_fmtp(const struct ast_format *format, const char *attributes)
This function is used to have a media format aware module parse and interpret SDP attribute informati...
Definition: format.c:286
struct ast_format * ast_format_g726
Built-in cached g726 format.
Definition: format_cache.c:111
struct ast_format * ast_format_g726_aal2
Built-in cached g726 aal2 format.
Definition: format_cache.c:116
static struct ast_rtp_mime_type ast_rtp_mime_types[128]
static int mime_types_len
Definition: rtp_engine.c:267
static ast_rwlock_t mime_types_lock
Definition: rtp_engine.c:266
unsigned int sample_rate
Expected sample rate of the /c subtype.
Definition: rtp_engine.c:264
char subtype[64]
The format type.
Definition: rtp_engine.c:262
char type[16]
The media type.
Definition: rtp_engine.c:260
struct ast_rtp_payload_type payload_type
A mapping object between the Asterisk codec and this RTP payload.
Definition: rtp_engine.c:258

References ao2_lock, ao2_ref, ao2_t_cleanup, ao2_unlock, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_g726, ast_format_g726_aal2, ast_format_parse_sdp_fmtp(), ast_rtp_engine_alloc_payload_type(), AST_RTP_MAX_PT, ast_rtp_mime_types, AST_RTP_OPT_G726_NONSTANDARD, ast_rwlock_rdlock, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_GET, AST_VECTOR_REPLACE, AST_VECTOR_SIZE, ast_rtp_payload_type::asterisk_format, codecs, ast_rtp_instance::engine, ast_rtp_payload_type::format, mime_types_len, mime_types_lock, 10aedae86a32_add_outgoing_enum_va::new_type, options, payload_mapping_tx_is_present(), ast_rtp_engine::payload_set, ast_rtp_mime_type::payload_type, ast_rtp_payload_type::rtp_code, ast_rtp_payload_type::sample_rate, ast_rtp_mime_type::sample_rate, ast_rtp_mime_type::subtype, and ast_rtp_mime_type::type.

Referenced by ast_rtp_codecs_payloads_set_rtpmap_type(), get_codecs(), and jingle_interpret_description().

◆ ast_rtp_codecs_payloads_unset()

void ast_rtp_codecs_payloads_unset ( struct ast_rtp_codecs codecs,
struct ast_rtp_instance instance,
int  payload 
)

Remove tx payload type mapped information.

Parameters
codecsThe codecs structure to muck with
instanceOptionally the instance that the codecs structure belongs to
payloadNumerical payload to unset

Example usage:

void ast_rtp_codecs_payloads_unset(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
Remove tx payload type mapped information.
Definition: rtp_engine.c:1495

This clears the payload '0' from the codecs structure. It will be as if it was never set.

Since
1.8

Definition at line 1495 of file rtp_engine.c.

1496{
1497 struct ast_rtp_payload_type *type;
1498
1499 if (payload < 0 || payload >= AST_RTP_MAX_PT) {
1500 return;
1501 }
1502
1503 ast_debug(2, "Unsetting payload %d on %p\n", payload, codecs);
1504
1505 ast_rwlock_wrlock(&codecs->codecs_lock);
1506
1507 if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
1508 type = AST_VECTOR_GET(&codecs->payload_mapping_tx, payload);
1509 /*
1510 * Remove the preferred format if we are unsetting its container.
1511 *
1512 * There can be empty slots in payload_mapping_tx corresponding to
1513 * dynamic payload types that haven't been seen before so we need
1514 * to check for NULL before attempting to use 'type' in the call to
1515 * ast_format_cmp.
1516 */
1517 if (type) {
1518 if (ast_format_cmp(type->format, codecs->preferred_format) == AST_FORMAT_CMP_EQUAL) {
1519 ao2_replace(codecs->preferred_format, NULL);
1520 }
1521 ao2_ref(type, -1);
1522 AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, NULL);
1523 }
1524 }
1525
1526 if (instance && instance->engine && instance->engine->payload_set) {
1527 ao2_lock(instance);
1528 instance->engine->payload_set(instance, payload, 0, NULL, 0);
1529 ao2_unlock(instance);
1530 }
1531
1532 ast_rwlock_unlock(&codecs->codecs_lock);
1533}

References ao2_lock, ao2_ref, ao2_replace, ao2_unlock, ast_debug, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_RTP_MAX_PT, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_GET, AST_VECTOR_REPLACE, AST_VECTOR_SIZE, codecs, ast_rtp_instance::engine, NULL, ast_rtp_payload_type::payload, ast_rtp_engine::payload_set, and type.

◆ ast_rtp_codecs_payloads_xover()

void ast_rtp_codecs_payloads_xover ( struct ast_rtp_codecs src,
struct ast_rtp_codecs dest,
struct ast_rtp_instance instance 
)

Crossover copy the tx payload mapping of src to the rx payload mapping of dest.

Since
14.0.0
Parameters
srcThe source codecs structure
destThe destination codecs structure that the values from src will be copied to
instanceOptionally the instance that the dst codecs structure belongs to

Definition at line 1315 of file rtp_engine.c.

1316{
1317 int idx;
1318 struct ast_rtp_payload_type *type;
1319
1321 if (src != dest) {
1322 /* Deadlock avoidance because of held write lock. */
1323 while (ast_rwlock_tryrdlock(&src->codecs_lock)) {
1325 sched_yield();
1327 }
1328 }
1329
1330 /* Crossover copy payload type tx mapping to rx mapping. */
1331 for (idx = 0; idx < AST_VECTOR_SIZE(&src->payload_mapping_tx); ++idx) {
1333 if (!type) {
1334 continue;
1335 }
1336
1337 /* All tx mapping elements should have the primary flag set. */
1338 ast_assert(type->primary_mapping);
1339
1340 ast_debug(2, "Crossover copying tx to rx payload mapping %d (%p) from %p to %p\n",
1341 idx, type, src, dest);
1343
1344 if (instance && instance->engine && instance->engine->payload_set) {
1345 ao2_lock(instance);
1346 instance->engine->payload_set(instance, idx, type->asterisk_format, type->format, type->rtp_code);
1347 ao2_unlock(instance);
1348 }
1349 }
1350
1351 dest->framing = src->framing;
1355
1356 if (src != dest) {
1358 }
1360}
static void rtp_codecs_payload_replace_rx(struct ast_rtp_codecs *codecs, int payload, struct ast_rtp_payload_type *new_type)
Definition: rtp_engine.c:1135
#define ast_assert(a)
Definition: utils.h:776

References ao2_lock, ao2_replace, ao2_unlock, ast_assert, ast_debug, ast_rwlock_tryrdlock, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_rtp_codecs::codecs_lock, ast_rtp_instance::engine, ast_rtp_codecs::framing, ast_rtp_codecs::payload_mapping_tx, ast_rtp_engine::payload_set, ast_rtp_codecs::preferred_dtmf_pt, ast_rtp_codecs::preferred_dtmf_rate, ast_rtp_codecs::preferred_format, rtp_codecs_payload_replace_rx(), and type.

Referenced by ast_rtp_instance_early_bridge_make_compatible(), set_caps(), and set_incoming_call_offer_cap().

◆ ast_rtp_codecs_set_framing()

void ast_rtp_codecs_set_framing ( struct ast_rtp_codecs codecs,
unsigned int  framing 
)

Set the framing used for a set of codecs.

Parameters
codecsCodecs structure to set framing on
framingThe framing value to set on the codecs
Since
13.0.0

Definition at line 1677 of file rtp_engine.c.

1678{
1679 if (!framing) {
1680 return;
1681 }
1682
1683 ast_rwlock_wrlock(&codecs->codecs_lock);
1684 codecs->framing = framing;
1685 ast_rwlock_unlock(&codecs->codecs_lock);
1686}

References ast_rwlock_unlock, ast_rwlock_wrlock, and codecs.

Referenced by configure_local_rtp(), get_codecs(), jingle_enable_video(), and jingle_new().

◆ ast_rtp_codecs_set_preferred_dtmf_format()

int ast_rtp_codecs_set_preferred_dtmf_format ( struct ast_rtp_codecs codecs,
int  pt,
int  rate 
)

Set the preferred dtmf format pt and sample rate.

Parameters
codecsCodecs structure to set the preferred format in
ptPreferred dtmf payload type to set.
ratePreferred dtmf payload rate to set.
Returns
0
Note
The format passed this function has its reference count increased. If an existing format is set, that format is replaced.

Example usage:

int dtmf_code = atoi(dtmf_pt);
int dtmf_rate = clock_rate;
int ast_rtp_codecs_set_preferred_dtmf_format(struct ast_rtp_codecs *codecs, int pt, int rate)
Set the preferred dtmf format pt and sample rate.
Definition: rtp_engine.c:1613

This sets the preferred dtmf_code and dtmf_rate on the codec.

Definition at line 1613 of file rtp_engine.c.

1614{
1615 ast_rwlock_wrlock(&codecs->codecs_lock);
1616 codecs->preferred_dtmf_pt = pt;
1617 codecs->preferred_dtmf_rate = rate;
1618 ast_rwlock_unlock(&codecs->codecs_lock);
1619 return 0;
1620}

References ast_rwlock_unlock, ast_rwlock_wrlock, and codecs.

Referenced by get_codecs().

◆ ast_rtp_codecs_set_preferred_format()

int ast_rtp_codecs_set_preferred_format ( struct ast_rtp_codecs codecs,
struct ast_format format 
)

Set the preferred format.

Parameters
codecsCodecs structure to set the preferred format in
formatPreferred format to set.
Returns
0
Note
The format passed this function has its reference count increased. If an existing format is set, that format is replaced.

Example usage:

struct ast_format *preferred_format = ast_format_cap_get_format(joint, 0);
struct ast_format * ast_format_cap_get_format(const struct ast_format_cap *cap, int position)
Get the format at a specific index.
Definition: format_cap.c:400
int ast_rtp_codecs_set_preferred_format(struct ast_rtp_codecs *codecs, struct ast_format *format)
Set the preferred format.
Definition: rtp_engine.c:1587

This sets the first joint format as the preferred format.

Definition at line 1587 of file rtp_engine.c.

1588{
1589 ast_rwlock_wrlock(&codecs->codecs_lock);
1590 ao2_replace(codecs->preferred_format, format);
1591 ast_rwlock_unlock(&codecs->codecs_lock);
1592 return 0;
1593}

References ao2_replace, ast_rwlock_unlock, ast_rwlock_wrlock, and codecs.

Referenced by set_caps().

◆ ast_rtp_convert_stats_json()

struct ast_json * ast_rtp_convert_stats_json ( const struct ast_rtp_instance_stats stats)

Convert given stat instance into json format.

Parameters
stats
Returns
A json format stat

Definition at line 4205 of file rtp_engine.c.

4206{
4207 struct ast_json *j_res;
4208 int ret;
4209
4210 j_res = ast_json_object_create();
4211 if (!j_res) {
4212 return NULL;
4213 }
4214
4215 /* set mandatory items */
4216 ret = ast_json_object_set(j_res, "txcount", ast_json_integer_create(stats->txcount));
4217 ret |= ast_json_object_set(j_res, "rxcount", ast_json_integer_create(stats->rxcount));
4218
4219 ret |= ast_json_object_set(j_res, "txploss", ast_json_integer_create(stats->txploss));
4220 ret |= ast_json_object_set(j_res, "rxploss", ast_json_integer_create(stats->rxploss));
4221
4222 ret |= ast_json_object_set(j_res, "local_ssrc", ast_json_integer_create(stats->local_ssrc));
4223 ret |= ast_json_object_set(j_res, "remote_ssrc", ast_json_integer_create(stats->remote_ssrc));
4224
4225 ret |= ast_json_object_set(j_res, "txoctetcount", ast_json_integer_create(stats->txoctetcount));
4226 ret |= ast_json_object_set(j_res, "rxoctetcount", ast_json_integer_create(stats->rxoctetcount));
4227
4228 ret |= ast_json_object_set(j_res, "channel_uniqueid", ast_json_string_create(stats->channel_uniqueid));
4229 if (ret) {
4230 ast_log(LOG_WARNING, "Could not create rtp statistics info. channel: %s\n", stats->channel_uniqueid);
4231 ast_json_unref(j_res);
4232 return NULL;
4233 }
4234
4235 /* set other items */
4236 SET_AST_JSON_OBJ(j_res, "txjitter", ast_json_real_create(stats->txjitter));
4237 SET_AST_JSON_OBJ(j_res, "rxjitter", ast_json_real_create(stats->rxjitter));
4238
4239 SET_AST_JSON_OBJ(j_res, "remote_maxjitter", ast_json_real_create(stats->remote_maxjitter));
4240 SET_AST_JSON_OBJ(j_res, "remote_minjitter", ast_json_real_create(stats->remote_minjitter));
4241 SET_AST_JSON_OBJ(j_res, "remote_normdevjitter", ast_json_real_create(stats->remote_normdevjitter));
4242 SET_AST_JSON_OBJ(j_res, "remote_stdevjitter", ast_json_real_create(stats->remote_stdevjitter));
4243
4244 SET_AST_JSON_OBJ(j_res, "local_maxjitter", ast_json_real_create(stats->local_maxjitter));
4245 SET_AST_JSON_OBJ(j_res, "local_minjitter", ast_json_real_create(stats->local_minjitter));
4246 SET_AST_JSON_OBJ(j_res, "local_normdevjitter", ast_json_real_create(stats->local_normdevjitter));
4247 SET_AST_JSON_OBJ(j_res, "local_stdevjitter", ast_json_real_create(stats->local_stdevjitter));
4248
4249 SET_AST_JSON_OBJ(j_res, "remote_maxrxploss", ast_json_real_create(stats->remote_maxrxploss));
4250 SET_AST_JSON_OBJ(j_res, "remote_minrxploss", ast_json_real_create(stats->remote_minrxploss));
4251 SET_AST_JSON_OBJ(j_res, "remote_normdevrxploss", ast_json_real_create(stats->remote_normdevrxploss));
4252 SET_AST_JSON_OBJ(j_res, "remote_stdevrxploss", ast_json_real_create(stats->remote_stdevrxploss));
4253
4254 SET_AST_JSON_OBJ(j_res, "local_maxrxploss", ast_json_real_create(stats->local_maxrxploss));
4255 SET_AST_JSON_OBJ(j_res, "local_minrxploss", ast_json_real_create(stats->local_minrxploss));
4256 SET_AST_JSON_OBJ(j_res, "local_normdevrxploss", ast_json_real_create(stats->local_normdevrxploss));
4257 SET_AST_JSON_OBJ(j_res, "local_stdevrxploss", ast_json_real_create(stats->local_stdevrxploss));
4258
4259 SET_AST_JSON_OBJ(j_res, "rtt", ast_json_real_create(stats->rtt));
4260 SET_AST_JSON_OBJ(j_res, "maxrtt", ast_json_real_create(stats->maxrtt));
4261 SET_AST_JSON_OBJ(j_res, "minrtt", ast_json_real_create(stats->minrtt));
4262 SET_AST_JSON_OBJ(j_res, "normdevrtt", ast_json_real_create(stats->normdevrtt));
4263 SET_AST_JSON_OBJ(j_res, "stdevrtt", ast_json_real_create(stats->stdevrtt));
4264
4265 SET_AST_JSON_OBJ(j_res, "txmes", ast_json_integer_create(stats->txmes));
4266 SET_AST_JSON_OBJ(j_res, "rxmes", ast_json_integer_create(stats->rxmes));
4267
4268 SET_AST_JSON_OBJ(j_res, "remote_maxmes", ast_json_real_create(stats->remote_maxmes));
4269 SET_AST_JSON_OBJ(j_res, "remote_minmes", ast_json_real_create(stats->remote_minmes));
4270 SET_AST_JSON_OBJ(j_res, "remote_normdevmes", ast_json_real_create(stats->remote_normdevmes));
4271 SET_AST_JSON_OBJ(j_res, "remote_stdevmes", ast_json_real_create(stats->remote_stdevmes));
4272
4273 SET_AST_JSON_OBJ(j_res, "local_maxmes", ast_json_real_create(stats->local_maxmes));
4274 SET_AST_JSON_OBJ(j_res, "local_minmes", ast_json_real_create(stats->local_minmes));
4275 SET_AST_JSON_OBJ(j_res, "local_normdevmes", ast_json_real_create(stats->local_normdevmes));
4276 SET_AST_JSON_OBJ(j_res, "local_stdevmes", ast_json_real_create(stats->local_stdevmes));
4277
4278 return j_res;
4279}
#define ast_log
Definition: astobj2.c:42
#define LOG_WARNING
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
Definition: json.c:278
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
Definition: json.c:399
struct ast_json * ast_json_integer_create(intmax_t value)
Create a JSON integer.
Definition: json.c:327
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
Definition: json.c:414
struct ast_json * ast_json_real_create(double value)
Create a JSON real number.
Definition: json.c:342
#define SET_AST_JSON_OBJ(target, name, obj)
Set given json object into target with name.
Definition: rtp_engine.c:293
Abstract JSON element (object, array, string, int, ...).
unsigned int remote_ssrc
Definition: rtp_engine.h:454
unsigned int rxcount
Definition: rtp_engine.h:400
unsigned int local_ssrc
Definition: rtp_engine.h:452
unsigned int rxoctetcount
Definition: rtp_engine.h:460
unsigned int rxploss
Definition: rtp_engine.h:424
unsigned int txcount
Definition: rtp_engine.h:398
unsigned int txploss
Definition: rtp_engine.h:422
unsigned int txoctetcount
Definition: rtp_engine.h:458
char channel_uniqueid[MAX_CHANNEL_ID]
Definition: rtp_engine.h:456

References ast_json_integer_create(), ast_json_object_create(), ast_json_object_set(), ast_json_real_create(), ast_json_string_create(), ast_json_unref(), ast_log, ast_rtp_instance_stats::channel_uniqueid, ast_rtp_instance_stats::local_maxjitter, ast_rtp_instance_stats::local_maxmes, ast_rtp_instance_stats::local_maxrxploss, ast_rtp_instance_stats::local_minjitter, ast_rtp_instance_stats::local_minmes, ast_rtp_instance_stats::local_minrxploss, ast_rtp_instance_stats::local_normdevjitter, ast_rtp_instance_stats::local_normdevmes, ast_rtp_instance_stats::local_normdevrxploss, ast_rtp_instance_stats::local_ssrc, ast_rtp_instance_stats::local_stdevjitter, ast_rtp_instance_stats::local_stdevmes, ast_rtp_instance_stats::local_stdevrxploss, LOG_WARNING, ast_rtp_instance_stats::maxrtt, ast_rtp_instance_stats::minrtt, ast_rtp_instance_stats::normdevrtt, NULL, ast_rtp_instance_stats::remote_maxjitter, ast_rtp_instance_stats::remote_maxmes, ast_rtp_instance_stats::remote_maxrxploss, ast_rtp_instance_stats::remote_minjitter, ast_rtp_instance_stats::remote_minmes, ast_rtp_instance_stats::remote_minrxploss, ast_rtp_instance_stats::remote_normdevjitter, ast_rtp_instance_stats::remote_normdevmes, ast_rtp_instance_stats::remote_normdevrxploss, ast_rtp_instance_stats::remote_ssrc, ast_rtp_instance_stats::remote_stdevjitter, ast_rtp_instance_stats::remote_stdevmes, ast_rtp_instance_stats::remote_stdevrxploss, ast_rtp_instance_stats::rtt, ast_rtp_instance_stats::rxcount, ast_rtp_instance_stats::rxjitter, ast_rtp_instance_stats::rxmes, ast_rtp_instance_stats::rxoctetcount, ast_rtp_instance_stats::rxploss, SET_AST_JSON_OBJ, ast_rtp_instance_stats::stdevrtt, ast_rtp_instance_stats::txcount, ast_rtp_instance_stats::txjitter, ast_rtp_instance_stats::txmes, ast_rtp_instance_stats::txoctetcount, and ast_rtp_instance_stats::txploss.

Referenced by ast_rtp_instance_get_stats_all_json().

◆ ast_rtp_dtls_cfg_copy()

void ast_rtp_dtls_cfg_copy ( const struct ast_rtp_dtls_cfg src_cfg,
struct ast_rtp_dtls_cfg dst_cfg 
)

Copy contents of a DTLS configuration structure.

Parameters
src_cfgsource DTLS configuration structure
dst_cfgdestination DTLS configuration structure

Definition at line 3329 of file rtp_engine.c.

3330{
3331 ast_rtp_dtls_cfg_free(dst_cfg); /* Prevent a double-call leaking memory via ast_strdup */
3332
3333 dst_cfg->enabled = src_cfg->enabled;
3334 dst_cfg->verify = src_cfg->verify;
3335 dst_cfg->rekey = src_cfg->rekey;
3336 dst_cfg->suite = src_cfg->suite;
3337 dst_cfg->hash = src_cfg->hash;
3338 dst_cfg->ephemeral_cert = src_cfg->ephemeral_cert;
3339 dst_cfg->certfile = ast_strdup(src_cfg->certfile);
3340 dst_cfg->pvtfile = ast_strdup(src_cfg->pvtfile);
3341 dst_cfg->cipher = ast_strdup(src_cfg->cipher);
3342 dst_cfg->cafile = ast_strdup(src_cfg->cafile);
3343 dst_cfg->capath = ast_strdup(src_cfg->capath);
3344 dst_cfg->default_setup = src_cfg->default_setup;
3345}
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
void ast_rtp_dtls_cfg_free(struct ast_rtp_dtls_cfg *dtls_cfg)
Free contents of a DTLS configuration structure.
Definition: rtp_engine.c:3347
enum ast_rtp_dtls_setup default_setup
Definition: rtp_engine.h:608
enum ast_rtp_dtls_verify verify
Definition: rtp_engine.h:611
unsigned int rekey
Definition: rtp_engine.h:607
enum ast_rtp_dtls_hash hash
Definition: rtp_engine.h:610
unsigned int enabled
Definition: rtp_engine.h:606
unsigned int ephemeral_cert
Definition: rtp_engine.h:617
enum ast_srtp_suite suite
Definition: rtp_engine.h:609

References ast_rtp_dtls_cfg_free(), ast_strdup, ast_rtp_dtls_cfg::cafile, ast_rtp_dtls_cfg::capath, ast_rtp_dtls_cfg::certfile, ast_rtp_dtls_cfg::cipher, ast_rtp_dtls_cfg::default_setup, ast_rtp_dtls_cfg::enabled, ast_rtp_dtls_cfg::ephemeral_cert, ast_rtp_dtls_cfg::hash, ast_rtp_dtls_cfg::pvtfile, ast_rtp_dtls_cfg::rekey, ast_rtp_dtls_cfg::suite, and ast_rtp_dtls_cfg::verify.

◆ ast_rtp_dtls_cfg_free()

void ast_rtp_dtls_cfg_free ( struct ast_rtp_dtls_cfg dtls_cfg)

Free contents of a DTLS configuration structure.

Parameters
dtls_cfga DTLS configuration structure

Definition at line 3347 of file rtp_engine.c.

3348{
3349 ast_free(dtls_cfg->certfile);
3350 dtls_cfg->certfile = NULL;
3351 ast_free(dtls_cfg->pvtfile);
3352 dtls_cfg->pvtfile = NULL;
3353 ast_free(dtls_cfg->cipher);
3354 dtls_cfg->cipher = NULL;
3355 ast_free(dtls_cfg->cafile);
3356 dtls_cfg->cafile = NULL;
3357 ast_free(dtls_cfg->capath);
3358 dtls_cfg->capath = NULL;
3359}
#define ast_free(a)
Definition: astmm.h:180

References ast_free, ast_rtp_dtls_cfg::cafile, ast_rtp_dtls_cfg::capath, ast_rtp_dtls_cfg::certfile, ast_rtp_dtls_cfg::cipher, NULL, and ast_rtp_dtls_cfg::pvtfile.

Referenced by ast_rtp_dtls_cfg_copy(), and media_configuration_destroy().

◆ ast_rtp_dtls_cfg_parse()

int ast_rtp_dtls_cfg_parse ( struct ast_rtp_dtls_cfg dtls_cfg,
const char *  name,
const char *  value 
)

Parse DTLS related configuration options.

Parameters
dtls_cfga DTLS configuration structure
namename of the configuration option
valuevalue of the configuration option
Return values
0if handled
-1if not handled

Definition at line 3236 of file rtp_engine.c.

3237{
3238 if (!strcasecmp(name, "dtlsenable")) {
3239 dtls_cfg->enabled = ast_true(value) ? 1 : 0;
3240 } else if (!strcasecmp(name, "dtlsverify")) {
3241 if (!strcasecmp(value, "yes")) {
3243 } else if (!strcasecmp(value, "fingerprint")) {
3245 } else if (!strcasecmp(value, "certificate")) {
3247 } else if (!strcasecmp(value, "no")) {
3248 dtls_cfg->verify = AST_RTP_DTLS_VERIFY_NONE;
3249 } else {
3250 return -1;
3251 }
3252 } else if (!strcasecmp(name, "dtlsrekey")) {
3253 if (sscanf(value, "%30u", &dtls_cfg->rekey) != 1) {
3254 return -1;
3255 }
3256 } else if (!strcasecmp(name, "dtlsautogeneratecert")) {
3257 dtls_cfg->ephemeral_cert = ast_true(value) ? 1 : 0;
3258 } else if (!strcasecmp(name, "dtlscertfile")) {
3260 ast_log(LOG_ERROR, "%s file %s does not exist or is not readable\n", name, value);
3261 return -1;
3262 }
3263 ast_free(dtls_cfg->certfile);
3264 dtls_cfg->certfile = ast_strdup(value);
3265 } else if (!strcasecmp(name, "dtlsprivatekey")) {
3267 ast_log(LOG_ERROR, "%s file %s does not exist or is not readable\n", name, value);
3268 return -1;
3269 }
3270 ast_free(dtls_cfg->pvtfile);
3271 dtls_cfg->pvtfile = ast_strdup(value);
3272 } else if (!strcasecmp(name, "dtlscipher")) {
3273 ast_free(dtls_cfg->cipher);
3274 dtls_cfg->cipher = ast_strdup(value);
3275 } else if (!strcasecmp(name, "dtlscafile")) {
3277 ast_log(LOG_ERROR, "%s file %s does not exist or is not readable\n", name, value);
3278 return -1;
3279 }
3280 ast_free(dtls_cfg->cafile);
3281 dtls_cfg->cafile = ast_strdup(value);
3282 } else if (!strcasecmp(name, "dtlscapath") || !strcasecmp(name, "dtlscadir")) {
3284 ast_log(LOG_ERROR, "%s file %s does not exist or is not readable\n", name, value);
3285 return -1;
3286 }
3287 ast_free(dtls_cfg->capath);
3288 dtls_cfg->capath = ast_strdup(value);
3289 } else if (!strcasecmp(name, "dtlssetup")) {
3290 if (!strcasecmp(value, "active")) {
3292 } else if (!strcasecmp(value, "passive")) {
3294 } else if (!strcasecmp(value, "actpass")) {
3296 }
3297 } else if (!strcasecmp(name, "dtlsfingerprint")) {
3298 if (!strcasecmp(value, "sha-256")) {
3299 dtls_cfg->hash = AST_RTP_DTLS_HASH_SHA256;
3300 } else if (!strcasecmp(value, "sha-1")) {
3301 dtls_cfg->hash = AST_RTP_DTLS_HASH_SHA1;
3302 }
3303 } else {
3304 return -1;
3305 }
3306
3307 return 0;
3308}
static const char name[]
Definition: format_mp3.c:68
#define LOG_ERROR
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: utils.c:2235
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
int value
Definition: syslog.c:37
int ast_file_is_readable(const char *filename)
Test that a file exists and is readable by the effective user.
Definition: utils.c:3143

References ast_file_is_readable(), ast_free, ast_log, AST_RTP_DTLS_HASH_SHA1, AST_RTP_DTLS_HASH_SHA256, AST_RTP_DTLS_SETUP_ACTIVE, AST_RTP_DTLS_SETUP_ACTPASS, AST_RTP_DTLS_SETUP_PASSIVE, AST_RTP_DTLS_VERIFY_CERTIFICATE, AST_RTP_DTLS_VERIFY_FINGERPRINT, AST_RTP_DTLS_VERIFY_NONE, ast_strdup, ast_strlen_zero(), ast_true(), ast_rtp_dtls_cfg::cafile, ast_rtp_dtls_cfg::capath, ast_rtp_dtls_cfg::certfile, ast_rtp_dtls_cfg::cipher, ast_rtp_dtls_cfg::default_setup, ast_rtp_dtls_cfg::enabled, ast_rtp_dtls_cfg::ephemeral_cert, ast_rtp_dtls_cfg::hash, LOG_ERROR, name, ast_rtp_dtls_cfg::pvtfile, ast_rtp_dtls_cfg::rekey, value, and ast_rtp_dtls_cfg::verify.

Referenced by dtls_handler(), and media_encryption_handler().

◆ ast_rtp_dtls_cfg_validate()

int ast_rtp_dtls_cfg_validate ( struct ast_rtp_dtls_cfg dtls_cfg)

Validates DTLS related configuration options.

Parameters
dtls_cfga DTLS configuration structure
Return values
0if valid
-1if invalid

Definition at line 3310 of file rtp_engine.c.

3311{
3312 if (dtls_cfg->ephemeral_cert) {
3313 if (!ast_strlen_zero(dtls_cfg->certfile)) {
3314 ast_log(LOG_ERROR, "You cannot request automatically generated certificates"
3315 " (dtls_auto_generate_cert) and also specify a certificate file"
3316 " (dtls_cert_file) at the same time\n");
3317 return -1;
3318 } else if (!ast_strlen_zero(dtls_cfg->pvtfile)
3319 || !ast_strlen_zero(dtls_cfg->cafile)
3320 || !ast_strlen_zero(dtls_cfg->capath)) {
3321 ast_log(LOG_NOTICE, "dtls_pvt_file, dtls_cafile, and dtls_ca_path are"
3322 " ignored when dtls_auto_generate_cert is enabled\n");
3323 }
3324 }
3325
3326 return 0;
3327}
#define LOG_NOTICE

References ast_log, ast_strlen_zero(), ast_rtp_dtls_cfg::cafile, ast_rtp_dtls_cfg::capath, ast_rtp_dtls_cfg::certfile, ast_rtp_dtls_cfg::ephemeral_cert, LOG_ERROR, LOG_NOTICE, and ast_rtp_dtls_cfg::pvtfile.

Referenced by sip_endpoint_apply_handler().

◆ ast_rtp_engine_alloc_payload_type()

struct ast_rtp_payload_type * ast_rtp_engine_alloc_payload_type ( void  )

Allocation routine for ast_rtp_payload_type.

Return values
NULLon error
Returns
An ao2 ref counted ast_rtp_payload_type on success.
Note
The ast_rtp_payload_type returned by this function is an ao2 ref counted object.

Definition at line 331 of file rtp_engine.c.

332{
333 return rtp_payload_type_alloc(NULL, 0, 0, 0, 0);
334}
static struct ast_rtp_payload_type * rtp_payload_type_alloc(struct ast_format *format, int payload, int rtp_code, int primary_mapping, unsigned int sample_rate)
Definition: rtp_engine.c:311

References NULL, and rtp_payload_type_alloc().

Referenced by ast_rtp_codecs_payload_replace_format(), ast_rtp_codecs_payloads_set_rtpmap_type_rate(), and payload_mapping_rx_clear_primary().

◆ ast_rtp_engine_load_format()

int ast_rtp_engine_load_format ( struct ast_format format)

Custom formats declared in codecs.conf at startup must be communicated to the rtp_engine so their mime type can payload number can be initialized.

Definition at line 3445 of file rtp_engine.c.

3446{
3447 char *codec_name = ast_strdupa(ast_format_get_codec_name(format));
3448
3449 codec_name = ast_str_to_upper(codec_name);
3450
3451 set_next_mime_type(format,
3452 0,
3454 codec_name,
3456 add_static_payload(-1, format, 0);
3457
3458 return 0;
3459}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
const char * ast_codec_media_type2str(enum ast_media_type type)
Conversion function to take a media type and turn it into a string.
Definition: codec.c:348
unsigned int ast_format_get_sample_rate(const struct ast_format *format)
Get the sample rate of a media format.
Definition: format.c:379
const char * ast_format_get_codec_name(const struct ast_format *format)
Get the codec name associated with a format.
Definition: format.c:339
static void add_static_payload(int payload, struct ast_format *format, int rtp_code)
Definition: rtp_engine.c:3399
static void set_next_mime_type(struct ast_format *format, int rtp_code, const char *type, const char *subtype, unsigned int sample_rate)
Definition: rtp_engine.c:3371
static force_inline char * ast_str_to_upper(char *str)
Convert a string to all upper-case.
Definition: strings.h:1342

References add_static_payload(), ast_codec_media_type2str(), ast_format_get_codec_name(), ast_format_get_sample_rate(), ast_format_get_type(), ast_str_to_upper(), ast_strdupa, ast_rtp_payload_type::format, and set_next_mime_type().

Referenced by load_module().

◆ ast_rtp_engine_register2()

int ast_rtp_engine_register2 ( struct ast_rtp_engine engine,
struct ast_module module 
)

Register an RTP engine.

Parameters
engineStructure of the RTP engine to register
moduleModule that the RTP engine is part of
Return values
0success
-1failure

Example usage:

ast_rtp_engine_register2(&example_rtp_engine, NULL);
int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module)
Register an RTP engine.
Definition: rtp_engine.c:336

This registers the RTP engine declared as example_rtp_engine with the RTP engine core, but does not associate a module with it.

Note
It is recommended that you use the ast_rtp_engine_register macro so that the module is associated with the RTP engine and use counting is performed.
Since
1.8

Definition at line 336 of file rtp_engine.c.

337{
338 struct ast_rtp_engine *current_engine;
339
340 /* Perform a sanity check on the engine structure to make sure it has the basics */
341 if (ast_strlen_zero(engine->name) || !engine->new || !engine->destroy || !engine->write || !engine->read) {
342 ast_log(LOG_WARNING, "RTP Engine '%s' failed sanity check so it was not registered.\n", !ast_strlen_zero(engine->name) ? engine->name : "Unknown");
343 return -1;
344 }
345
346 /* Link owner module to the RTP engine for reference counting purposes */
347 engine->mod = module;
348
350
351 /* Ensure that no two modules with the same name are registered at the same time */
352 AST_RWLIST_TRAVERSE(&engines, current_engine, entry) {
353 if (!strcmp(current_engine->name, engine->name)) {
354 ast_log(LOG_WARNING, "An RTP engine with the name '%s' has already been registered.\n", engine->name);
356 return -1;
357 }
358 }
359
360 /* The engine survived our critique. Off to the list it goes to be used */
361 AST_RWLIST_INSERT_TAIL(&engines, engine, entry);
362
364
365 ast_verb(5, "Registered RTP engine '%s'\n", engine->name);
366
367 return 0;
368}
#define ast_verb(level,...)
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:494
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:741
int(* write)(struct ast_rtp_instance *instance, struct ast_frame *frame)
Definition: rtp_engine.h:675
int(* destroy)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:673
struct ast_module * mod
Definition: rtp_engine.h:669
int(* new)(struct ast_rtp_instance *instance, struct ast_sched_context *sched, struct ast_sockaddr *sa, void *data)
Definition: rtp_engine.h:671
const char * name
Definition: rtp_engine.h:667
struct ast_frame *(* read)(struct ast_rtp_instance *instance, int rtcp)
Definition: rtp_engine.h:712

References ast_log, AST_RWLIST_INSERT_TAIL, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strlen_zero(), ast_verb, ast_rtp_engine::destroy, LOG_WARNING, ast_rtp_engine::mod, ast_rtp_engine::name, ast_rtp_engine::new, ast_rtp_engine::read, and ast_rtp_engine::write.

◆ ast_rtp_engine_register_srtp()

int ast_rtp_engine_register_srtp ( struct ast_srtp_res srtp_res,
struct ast_srtp_policy_res policy_res 
)

Definition at line 2926 of file rtp_engine.c.

2927{
2928 if (res_srtp || res_srtp_policy) {
2929 return -1;
2930 }
2931 if (!srtp_res || !policy_res) {
2932 return -1;
2933 }
2934
2937
2938 return 0;
2939}
static struct ast_srtp_res srtp_res
Definition: res_srtp.c:129
static struct ast_srtp_policy_res policy_res
Definition: res_srtp.c:141
struct ast_srtp_res * res_srtp
Definition: rtp_engine.c:182
struct ast_srtp_policy_res * res_srtp_policy
Definition: rtp_engine.c:183

References policy_res, res_srtp, res_srtp_policy, and srtp_res.

Referenced by res_srtp_init().

◆ ast_rtp_engine_srtp_is_registered()

int ast_rtp_engine_srtp_is_registered ( void  )

Definition at line 2947 of file rtp_engine.c.

2948{
2949 return res_srtp && res_srtp_policy;
2950}

References res_srtp, and res_srtp_policy.

Referenced by ast_sdp_srtp_alloc().

◆ ast_rtp_engine_unload_format()

int ast_rtp_engine_unload_format ( struct ast_format format)

Formats requiring the use of a format attribute interface must have that interface registered in order for the rtp engine to handle it correctly. If an attribute interface is unloaded, this function must be called to notify the rtp_engine.

Definition at line 3461 of file rtp_engine.c.

3462{
3463 int x;
3464 int y = 0;
3465
3467 /* remove everything pertaining to this format id from the lists */
3468 for (x = 0; x < AST_RTP_MAX_PT; x++) {
3469 if (static_RTP_PT[x]
3470 && ast_format_cmp(static_RTP_PT[x]->format, format) == AST_FORMAT_CMP_EQUAL) {
3471 ao2_ref(static_RTP_PT[x], -1);
3472 static_RTP_PT[x] = NULL;
3473 }
3474 }
3476
3478 /* rebuild the list skipping the items matching this id */
3479 for (x = 0; x < mime_types_len; x++) {
3480 if (ast_format_cmp(ast_rtp_mime_types[x].payload_type.format, format) == AST_FORMAT_CMP_EQUAL) {
3482 continue;
3483 }
3484 if (x != y) {
3486 }
3487 y++;
3488 }
3489 mime_types_len = y;
3491 return 0;
3492}
static void rtp_engine_mime_type_cleanup(int i)
Definition: rtp_engine.c:3365

References ao2_ref, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_RTP_MAX_PT, ast_rtp_mime_types, ast_rwlock_unlock, ast_rwlock_wrlock, ast_rtp_payload_type::format, mime_types_len, mime_types_lock, NULL, rtp_engine_mime_type_cleanup(), static_RTP_PT, and static_RTP_PT_lock.

Referenced by unload_module().

◆ ast_rtp_engine_unregister()

int ast_rtp_engine_unregister ( struct ast_rtp_engine engine)

Unregister an RTP engine.

Parameters
engineStructure of the RTP engine to unregister
Return values
0success
-1failure

Example usage:

ast_rtp_engine_unregister(&example_rtp_engine);
int ast_rtp_engine_unregister(struct ast_rtp_engine *engine)
Unregister an RTP engine.
Definition: rtp_engine.c:370

This unregisters the RTP engine declared as example_rtp_engine from the RTP engine core. If a module reference was provided when it was registered then this will only be called once the RTP engine is no longer in use.

Since
1.8

Definition at line 370 of file rtp_engine.c.

371{
372 struct ast_rtp_engine *current_engine = NULL;
373
375
376 if ((current_engine = AST_RWLIST_REMOVE(&engines, engine, entry))) {
377 ast_verb(5, "Unregistered RTP engine '%s'\n", engine->name);
378 }
379
381
382 return current_engine ? 0 : -1;
383}
#define AST_RWLIST_REMOVE
Definition: linkedlists.h:885

References AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_rtp_engine::name, and NULL.

Referenced by load_module(), and unload_module().

◆ ast_rtp_engine_unregister_srtp()

void ast_rtp_engine_unregister_srtp ( void  )

Definition at line 2941 of file rtp_engine.c.

2942{
2943 res_srtp = NULL;
2945}

References NULL, res_srtp, and res_srtp_policy.

Referenced by res_srtp_shutdown().

◆ ast_rtp_get_rate()

int ast_rtp_get_rate ( const struct ast_format format)

Retrieve the sample rate of a format according to RTP specifications.

Since
16.7.0
17.1.0
Parameters
formatThe media format
Returns
The sample rate

Definition at line 4292 of file rtp_engine.c.

4293{
4294 /* For those wondering: due to a fluke in RFC publication, G.722 is advertised
4295 * as having a sample rate of 8kHz, while implementations must know that its
4296 * real rate is 16kHz. Seriously.
4297 */
4298 return (ast_format_cmp(format, ast_format_g722) == AST_FORMAT_CMP_EQUAL) ? 8000 : (int)ast_format_get_sample_rate(format);
4299}
struct ast_format * ast_format_g722
Built-in cached g722 format.
Definition: format_cache.c:106

References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_g722, and ast_format_get_sample_rate().

Referenced by ast_rtcp_calculate_sr_rr_statistics(), ast_rtcp_interpret(), ast_rtp_dtmf_end_with_duration(), ast_rtp_interpret(), calc_rxstamp_and_jitter(), jitterbuffer_frame_get_ntp_timestamp(), process_dtmf_cisco(), process_dtmf_rfc2833(), rtp_raw_write(), and update_jitter_stats().

◆ ast_rtp_glue_register2()

int ast_rtp_glue_register2 ( struct ast_rtp_glue glue,
struct ast_module module 
)

Register RTP glue.

Parameters
glueThe glue to register
moduleModule that the RTP glue is part of
Return values
0success
-1failure

Example usage:

ast_rtp_glue_register2(&example_rtp_glue, NULL);
int ast_rtp_glue_register2(struct ast_rtp_glue *glue, struct ast_module *module)
Register RTP glue.
Definition: rtp_engine.c:385

This registers the RTP glue declared as example_rtp_glue with the RTP engine core, but does not associate a module with it.

Note
It is recommended that you use the ast_rtp_glue_register macro so that the module is associated with the RTP glue and use counting is performed.
Since
1.8

Definition at line 385 of file rtp_engine.c.

386{
387 struct ast_rtp_glue *current_glue = NULL;
388
389 if (ast_strlen_zero(glue->type)) {
390 return -1;
391 }
392
393 glue->mod = module;
394
396
397 AST_RWLIST_TRAVERSE(&glues, current_glue, entry) {
398 if (!strcasecmp(current_glue->type, glue->type)) {
399 ast_log(LOG_WARNING, "RTP glue with the name '%s' has already been registered.\n", glue->type);
401 return -1;
402 }
403 }
404
405 AST_RWLIST_INSERT_TAIL(&glues, glue, entry);
406
408
409 ast_verb(5, "Registered RTP glue '%s'\n", glue->type);
410
411 return 0;
412}
const char * type
Definition: rtp_engine.h:780
struct ast_module * mod
Definition: rtp_engine.h:782

References ast_log, AST_RWLIST_INSERT_TAIL, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strlen_zero(), ast_verb, LOG_WARNING, ast_rtp_glue::mod, NULL, and ast_rtp_glue::type.

◆ ast_rtp_glue_unregister()

int ast_rtp_glue_unregister ( struct ast_rtp_glue glue)

Unregister RTP glue.

Parameters
glueThe glue to unregister
Return values
0success
-1failure

Example usage:

ast_rtp_glue_unregister(&example_rtp_glue);
int ast_rtp_glue_unregister(struct ast_rtp_glue *glue)
Unregister RTP glue.
Definition: rtp_engine.c:414

This unregisters the RTP glue declared as example_rtp_gkue from the RTP engine core. If a module reference was provided when it was registered then this will only be called once the RTP engine is no longer in use.

Since
1.8

Definition at line 414 of file rtp_engine.c.

415{
416 struct ast_rtp_glue *current_glue = NULL;
417
419
420 if ((current_glue = AST_RWLIST_REMOVE(&glues, glue, entry))) {
421 ast_verb(5, "Unregistered RTP glue '%s'\n", glue->type);
422 }
423
425
426 return current_glue ? 0 : -1;
427}

References AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, NULL, and ast_rtp_glue::type.

Referenced by load_module(), and unload_module().

◆ ast_rtp_instance_activate()

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.

Parameters
instanceThe RTP instance
Return values
0success
-1failure

Example usage:

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:2863

This tells the underlying RTP engine of instance that packets will now flow.

Since
1.8

Definition at line 2863 of file rtp_engine.c.

2864{
2865 int res;
2866
2867 if (instance->engine->activate) {
2868 ao2_lock(instance);
2869 res = instance->engine->activate(instance);
2870 ao2_unlock(instance);
2871 } else {
2872 res = 0;
2873 }
2874 return res;
2875}
int(* activate)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:724

References ast_rtp_engine::activate, ao2_lock, ao2_unlock, and ast_rtp_instance::engine.

Referenced by apply_negotiated_sdp_stream(), rtp_call(), and test_init_rtp_instances().

◆ ast_rtp_instance_add_srtp_policy()

int ast_rtp_instance_add_srtp_policy ( struct ast_rtp_instance instance,
struct ast_srtp_policy remote_policy,
struct ast_srtp_policy local_policy,
int  rtcp 
)

Add or replace the SRTP policies for the given RTP instance.

Parameters
instancethe RTP instance
remote_policythe remote endpoint's policy
local_policyour policy for this RTP instance's remote endpoint
rtcp1 for dedicated RTCP policies
Return values
0Success
non-zeroFailure
Note
If no remote policy is provided any existing SRTP policies are left and the new local policy is added

Definition at line 2952 of file rtp_engine.c.

2953{
2954 int res = 0;
2955 struct ast_srtp **srtp;
2956
2957 if (!res_srtp) {
2958 return -1;
2959 }
2960
2961 ao2_lock(instance);
2962
2963 srtp = rtcp ? &instance->rtcp_srtp : &instance->srtp;
2964
2965 if (!*srtp) {
2966 res = res_srtp->create(srtp, instance, remote_policy);
2967 } else if (remote_policy) {
2968 res = res_srtp->replace(srtp, instance, remote_policy);
2969 }
2970 if (!res) {
2971 res = res_srtp->add_stream(*srtp, local_policy);
2972 }
2973
2974 ao2_unlock(instance);
2975
2976 return res;
2977}
struct ast_srtp * rtcp_srtp
Definition: rtp_engine.c:222
struct ast_srtp * srtp
Definition: rtp_engine.c:220
int(* replace)(struct ast_srtp **srtp, struct ast_rtp_instance *rtp, struct ast_srtp_policy *policy)
Definition: res_srtp.h:38
int(* add_stream)(struct ast_srtp *srtp, struct ast_srtp_policy *policy)
Definition: res_srtp.h:42
int(* create)(struct ast_srtp **srtp, struct ast_rtp_instance *rtp, struct ast_srtp_policy *policy)
Definition: res_srtp.h:36

References ast_srtp_res::add_stream, ao2_lock, ao2_unlock, ast_srtp_res::create, ast_srtp_res::replace, res_srtp, ast_rtp_instance::rtcp_srtp, and ast_rtp_instance::srtp.

Referenced by crypto_activate().

◆ ast_rtp_instance_available_formats()

void ast_rtp_instance_available_formats ( struct ast_rtp_instance instance,
struct ast_format_cap to_endpoint,
struct ast_format_cap to_asterisk,
struct ast_format_cap result 
)

Request the formats that can be transcoded.

Parameters
instanceThe RTP instance
to_endpointFormats being sent/received towards the endpoint
to_asteriskFormats being sent/received towards Asterisk
resultcapabilities structure to store and return supported formats in.

Example usage:

ast_rtp_instance_available_formats(instance, to_capabilities, from_capabilities, result_capabilities);
void ast_rtp_instance_available_formats(struct ast_rtp_instance *instance, struct ast_format_cap *to_endpoint, struct ast_format_cap *to_asterisk, struct ast_format_cap *result)
Request the formats that can be transcoded.
Definition: rtp_engine.c:2849

This sees if it is possible to have ulaw communicated to the endpoint but signed linear received into Asterisk.

Since
1.8

Definition at line 2849 of file rtp_engine.c.

2850{
2851 if (instance->engine->available_formats) {
2852 ao2_lock(instance);
2853 instance->engine->available_formats(instance, to_endpoint, to_asterisk, result);
2854 ao2_unlock(instance);
2856 return;
2857 }
2858 }
2859
2860 ast_translate_available_formats(to_endpoint, to_asterisk, result);
2861}
static PGresult * result
Definition: cel_pgsql.c:84
size_t ast_format_cap_count(const struct ast_format_cap *cap)
Get the number of formats present within the capabilities structure.
Definition: format_cap.c:395
void(* available_formats)(struct ast_rtp_instance *instance, struct ast_format_cap *to_endpoint, struct ast_format_cap *to_asterisk, struct ast_format_cap *result)
Definition: rtp_engine.h:728
void ast_translate_available_formats(struct ast_format_cap *dest, struct ast_format_cap *src, struct ast_format_cap *result)
Find available formats.
Definition: translate.c:1616

References ao2_lock, ao2_unlock, ast_format_cap_count(), ast_translate_available_formats(), ast_rtp_engine::available_formats, ast_rtp_instance::engine, and result.

◆ ast_rtp_instance_bundle()

int ast_rtp_instance_bundle ( struct ast_rtp_instance child,
struct ast_rtp_instance parent 
)

Request that an RTP instance be bundled with another.

Since
15.0.0
Parameters
childThe child RTP instance
parentThe parent RTP instance the child should be bundled with
Return values
0success
-1failure

Definition at line 4053 of file rtp_engine.c.

4054{
4055 int res = -1;
4056
4057 if (parent && (child->engine != parent->engine)) {
4058 return -1;
4059 }
4060
4061 ao2_lock(child);
4062 if (child->engine->bundle) {
4063 res = child->engine->bundle(child, parent);
4064 }
4065 ao2_unlock(child);
4066
4067 return res;
4068}
int(* bundle)(struct ast_rtp_instance *child, struct ast_rtp_instance *parent)
Definition: rtp_engine.h:736

References ao2_lock, ao2_unlock, ast_rtp_engine::bundle, and ast_rtp_instance::engine.

Referenced by apply_negotiated_sdp_stream(), and negotiate_incoming_sdp_stream().

◆ ast_rtp_instance_change_source()

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.

Parameters
instanceInstance that the new media source is feeding into

Example usage:

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:2352

This indicates that the source of media that is feeding the instance pointed to by instance has changed and that the marker bit should be set and the SSRC updated.

Since
1.8

Definition at line 2352 of file rtp_engine.c.

2353{
2354 if (instance->engine->change_source) {
2355 ao2_lock(instance);
2356 instance->engine->change_source(instance);
2357 ao2_unlock(instance);
2358 }
2359}
void(* change_source)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:686

References ao2_lock, ao2_unlock, ast_rtp_engine::change_source, and ast_rtp_instance::engine.

Referenced by chan_pjsip_indicate(), create_outgoing_sdp_stream(), jingle_indicate(), ooh323_indicate(), and unistim_indicate().

◆ ast_rtp_instance_destroy()

int ast_rtp_instance_destroy ( struct ast_rtp_instance instance)

Destroy an RTP instance.

Parameters
instanceThe RTP instance to destroy
Return values
0success
-1failure

Example usage:

int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
Definition: rtp_engine.c:464

This destroys the RTP instance pointed to by instance. Once this function returns instance no longer points to valid memory and may not be used again.

Since
1.8

Definition at line 464 of file rtp_engine.c.

465{
466 if (!instance) {
467 return 0;
468 }
470 char buffer[4][512];
471 ast_debug_rtp(1, "%s:\n"
472 " RTT: %s\n"
473 " Loss: %s\n"
474 " Jitter: %s\n"
475 " MES: %s\n",
476 instance->channel_uniqueid,
478 buffer[0], sizeof(buffer[0])),
480 buffer[1], sizeof(buffer[1])),
482 buffer[2], sizeof(buffer[2])),
484 buffer[3], sizeof(buffer[3]))
485 );
486 }
487
488 ao2_cleanup(instance);
489
490 return 0;
491}
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:2656
#define ast_debug_rtp(sublevel,...)
Log debug level RTP information.
Definition: rtp_engine.h:3099
#define ast_debug_rtp_is_allowed
Definition: rtp_engine.h:3103
char channel_uniqueid[AST_MAX_UNIQUEID]
Definition: rtp_engine.c:224

References ao2_cleanup, ast_debug_rtp, ast_debug_rtp_is_allowed, ast_rtp_instance_get_quality(), AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_MES, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT, and ast_rtp_instance::channel_uniqueid.

Referenced by AST_TEST_DEFINE(), jingle_session_destructor(), multicast_rtp_request(), ooh323_destroy(), rtp_hangup(), stream_destroy(), unicast_rtp_request(), and unistim_hangup_clean().

◆ ast_rtp_instance_dtmf_begin()

int ast_rtp_instance_dtmf_begin ( struct ast_rtp_instance instance,
char  digit 
)

Begin sending a DTMF digit.

Parameters
instanceThe RTP instance to send the DTMF on
digitWhat DTMF digit to send
Return values
0success
-1failure

Example usage:

int ast_rtp_instance_dtmf_begin(struct ast_rtp_instance *instance, char digit)
Begin sending a DTMF digit.
Definition: rtp_engine.c:2273

This starts sending the DTMF '1' on the RTP instance pointed to by instance. It will continue being sent until it is ended.

Since
1.8

Definition at line 2273 of file rtp_engine.c.

2274{
2275 int res;
2276
2277 if (instance->engine->dtmf_begin) {
2278 ao2_lock(instance);
2279 res = instance->engine->dtmf_begin(instance, digit);
2280 ao2_unlock(instance);
2281 } else {
2282 res = -1;
2283 }
2284 return res;
2285}
char digit
int(* dtmf_begin)(struct ast_rtp_instance *instance, char digit)
Definition: rtp_engine.h:679

References ao2_lock, ao2_unlock, digit, ast_rtp_engine::dtmf_begin, and ast_rtp_instance::engine.

Referenced by chan_pjsip_digit_begin(), jingle_digit_begin(), and ooh323_digit_begin().

◆ ast_rtp_instance_dtmf_end()

int ast_rtp_instance_dtmf_end ( struct ast_rtp_instance instance,
char  digit 
)

Stop sending a DTMF digit.

Parameters
instanceThe RTP instance to stop the DTMF on
digitWhat DTMF digit to stop
Return values
0success
-1failure

Example usage:

int ast_rtp_instance_dtmf_end(struct ast_rtp_instance *instance, char digit)
Stop sending a DTMF digit.
Definition: rtp_engine.c:2287

This stops sending the DTMF '1' on the RTP instance pointed to by instance.

Since
1.8

Definition at line 2287 of file rtp_engine.c.

2288{
2289 int res;
2290
2291 if (instance->engine->dtmf_end) {
2292 ao2_lock(instance);
2293 res = instance->engine->dtmf_end(instance, digit);
2294 ao2_unlock(instance);
2295 } else {
2296 res = -1;
2297 }
2298 return res;
2299}
int(* dtmf_end)(struct ast_rtp_instance *instance, char digit)
Definition: rtp_engine.h:681

References ao2_lock, ao2_unlock, digit, ast_rtp_engine::dtmf_end, and ast_rtp_instance::engine.

Referenced by ooh323_digit_end().

◆ ast_rtp_instance_dtmf_end_with_duration()

int ast_rtp_instance_dtmf_end_with_duration ( struct ast_rtp_instance instance,
char  digit,
unsigned int  duration 
)

Definition at line 2301 of file rtp_engine.c.

2302{
2303 int res;
2304
2305 if (instance->engine->dtmf_end_with_duration) {
2306 ao2_lock(instance);
2307 res = instance->engine->dtmf_end_with_duration(instance, digit, duration);
2308 ao2_unlock(instance);
2309 } else {
2310 res = -1;
2311 }
2312 return res;
2313}
int(* dtmf_end_with_duration)(struct ast_rtp_instance *instance, char digit, unsigned int duration)
Definition: rtp_engine.h:682

References ao2_lock, ao2_unlock, digit, ast_rtp_engine::dtmf_end_with_duration, and ast_rtp_instance::engine.

Referenced by chan_pjsip_digit_end(), and jingle_digit_end().

◆ ast_rtp_instance_dtmf_mode_get()

enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get ( struct ast_rtp_instance instance)

Get the DTMF mode of an RTP instance.

Parameters
instanceThe RTP instance to get the DTMF mode of
Returns
DTMF mode

Example usage:

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:2329
ast_rtp_dtmf_mode
Definition: rtp_engine.h:151

This gets the DTMF mode set on the RTP instance pointed to by 'instance'.

Since
1.8

Definition at line 2329 of file rtp_engine.c.

2330{
2331 int res;
2332
2333 if (instance->engine->dtmf_mode_get) {
2334 ao2_lock(instance);
2335 res = instance->engine->dtmf_mode_get(instance);
2336 ao2_unlock(instance);
2337 } else {
2338 res = 0;
2339 }
2340 return res;
2341}
enum ast_rtp_dtmf_mode(* dtmf_mode_get)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:700

References ao2_lock, ao2_unlock, ast_rtp_engine::dtmf_mode_get, and ast_rtp_instance::engine.

Referenced by chan_pjsip_digit_begin(), chan_pjsip_digit_end(), native_rtp_bridge_compatible_check(), pjsip_acf_dtmf_mode_write(), and set_caps().

◆ ast_rtp_instance_dtmf_mode_set()

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.

Parameters
instancethe RTP instance to set DTMF mode on
dtmf_modeThe DTMF mode that is in use
Return values
0success
-1failure

Example usage:

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:2315

This sets the RTP instance to use RFC2833 for DTMF transmission and receiving.

Since
1.8

Definition at line 2315 of file rtp_engine.c.

2316{
2317 int res;
2318
2319 if (instance->engine->dtmf_mode_set) {
2320 ao2_lock(instance);
2321 res = instance->engine->dtmf_mode_set(instance, dtmf_mode);
2322 ao2_unlock(instance);
2323 } else {
2324 res = -1;
2325 }
2326 return res;
2327}
int(* dtmf_mode_set)(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
Definition: rtp_engine.h:698

References ao2_lock, ao2_unlock, ast_rtp_engine::dtmf_mode_set, and ast_rtp_instance::engine.

Referenced by create_rtp(), get_codecs(), and pjsip_acf_dtmf_mode_write().

◆ ast_rtp_instance_early_bridge()

int ast_rtp_instance_early_bridge ( struct ast_channel c0,
struct ast_channel c1 
)

Early bridge two channels that use RTP instances.

Parameters
c0First channel part of the bridge
c1Second channel part of the bridge
Return values
0success
-1failure
Note
This should only be used by channel drivers in their technology declaration.
Since
1.8

Definition at line 2529 of file rtp_engine.c.

2530{
2531 struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL,
2532 *vinstance0 = NULL, *vinstance1 = NULL,
2533 *tinstance0 = NULL, *tinstance1 = NULL;
2534 struct ast_rtp_glue *glue0, *glue1;
2535 enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
2536 enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
2539
2540 /* If there is no second channel just immediately bail out, we are of no use in that scenario */
2541 if (!c1 || !cap1 || !cap0) {
2542 ao2_cleanup(cap0);
2543 ao2_cleanup(cap1);
2544 return -1;
2545 }
2546
2547 /* Lock both channels so we can look for the glue that binds them together */
2548 ast_channel_lock_both(c0, c1);
2549
2550 /* Grab glue that binds each channel to something using the RTP engine */
2552 ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
2553 goto done;
2554 }
2555
2556 audio_glue0_res = glue0->get_rtp_info(c0, &instance0);
2557 video_glue0_res = glue0->get_vrtp_info ? glue0->get_vrtp_info(c0, &vinstance0) : AST_RTP_GLUE_RESULT_FORBID;
2558
2559 audio_glue1_res = glue1->get_rtp_info(c1, &instance1);
2560 video_glue1_res = glue1->get_vrtp_info ? glue1->get_vrtp_info(c1, &vinstance1) : AST_RTP_GLUE_RESULT_FORBID;
2561
2562 /* If we are carrying video, and both sides are not going to remotely bridge... fail the native bridge */
2563 if (video_glue0_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue0_res != AST_RTP_GLUE_RESULT_REMOTE)) {
2564 audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
2565 }
2566 if (video_glue1_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue1_res != AST_RTP_GLUE_RESULT_REMOTE)) {
2567 audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
2568 }
2569 if (audio_glue0_res == AST_RTP_GLUE_RESULT_REMOTE && (video_glue0_res == AST_RTP_GLUE_RESULT_FORBID || video_glue0_res == AST_RTP_GLUE_RESULT_REMOTE) && glue0->get_codec) {
2570 glue0->get_codec(c0, cap0);
2571 }
2572 if (audio_glue1_res == AST_RTP_GLUE_RESULT_REMOTE && (video_glue1_res == AST_RTP_GLUE_RESULT_FORBID || video_glue1_res == AST_RTP_GLUE_RESULT_REMOTE) && glue1->get_codec) {
2573 glue1->get_codec(c1, cap1);
2574 }
2575
2576 /* If any sort of bridge is forbidden just completely bail out and go back to generic bridging */
2577 if (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE) {
2578 goto done;
2579 }
2580
2581 /* Make sure we have matching codecs */
2582 if (!ast_format_cap_iscompatible(cap0, cap1)) {
2583 goto done;
2584 }
2585
2586 /* Bridge media early */
2587 if (glue0->update_peer(c0, instance1, vinstance1, tinstance1, cap1, 0)) {
2588 ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n", ast_channel_name(c0), c1 ? ast_channel_name(c1) : "<unspecified>");
2589 }
2590
2591done:
2594
2595 ao2_cleanup(cap0);
2596 ao2_cleanup(cap1);
2597
2598 unref_instance_cond(&instance0);
2599 unref_instance_cond(&instance1);
2600 unref_instance_cond(&vinstance0);
2601 unref_instance_cond(&vinstance1);
2602 unref_instance_cond(&tinstance0);
2603 unref_instance_cond(&tinstance1);
2604
2605 ast_debug(1, "Setting early bridge SDP of '%s' with that of '%s'\n", ast_channel_name(c0), c1 ? ast_channel_name(c1) : "<unspecified>");
2606
2607 return 0;
2608}
const char * ast_channel_name(const struct ast_channel *chan)
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2979
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
Definition: channel.h:2973
@ AST_FORMAT_CAP_FLAG_DEFAULT
Definition: format_cap.h:38
int ast_format_cap_iscompatible(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2)
Determine if any joint capabilities exist between two capabilities structures.
Definition: format_cap.c:653
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition: format_cap.h:49
static void unref_instance_cond(struct ast_rtp_instance **instance)
Conditionally unref an rtp instance.
Definition: rtp_engine.c:2418
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:2398
ast_rtp_glue_result
Definition: rtp_engine.h:161
enum ast_rtp_glue_result(* get_rtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance)
Callback for retrieving the RTP instance carrying audio.
Definition: rtp_engine.h:787
void(* get_codec)(struct ast_channel *chan, struct ast_format_cap *result_cap)
Callback for retrieving codecs that the channel can do. Result returned in result_cap.
Definition: rtp_engine.h:819
int(* update_peer)(struct ast_channel *chan, struct ast_rtp_instance *instance, struct ast_rtp_instance *vinstance, struct ast_rtp_instance *tinstance, const struct ast_format_cap *cap, int nat_active)
Definition: rtp_engine.h:814
enum ast_rtp_glue_result(* get_vrtp_info)(struct ast_channel *chan, struct ast_rtp_instance **instance)
Callback for retrieving the RTP instance carrying video.
Definition: rtp_engine.h:799
int done
Definition: test_amihooks.c:48

References ao2_cleanup, ast_channel_lock_both, ast_channel_name(), ast_channel_tech(), ast_channel_unlock, ast_debug, ast_format_cap_alloc, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_iscompatible(), ast_log, AST_RTP_GLUE_RESULT_FORBID, AST_RTP_GLUE_RESULT_REMOTE, ast_rtp_instance_get_glue(), done, ast_rtp_glue::get_codec, ast_rtp_glue::get_rtp_info, ast_rtp_glue::get_vrtp_info, LOG_WARNING, NULL, type, unref_instance_cond(), and ast_rtp_glue::update_peer.

◆ ast_rtp_instance_early_bridge_make_compatible()

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.

Parameters
c_dstDestination channel to copy to
c_srcSource channel to copy from
Since
1.8

Definition at line 2443 of file rtp_engine.c.

2444{
2445 struct ast_rtp_instance *instance_dst = NULL, *instance_src = NULL,
2446 *vinstance_dst = NULL, *vinstance_src = NULL,
2447 *tinstance_dst = NULL, *tinstance_src = NULL;
2448 struct ast_rtp_glue *glue_dst, *glue_src;
2449 enum ast_rtp_glue_result audio_glue_dst_res = AST_RTP_GLUE_RESULT_FORBID, video_glue_dst_res = AST_RTP_GLUE_RESULT_FORBID;
2450 enum ast_rtp_glue_result audio_glue_src_res = AST_RTP_GLUE_RESULT_FORBID, video_glue_src_res = AST_RTP_GLUE_RESULT_FORBID;
2453
2454 /* Lock both channels so we can look for the glue that binds them together */
2455 ast_channel_lock_both(c_dst, c_src);
2456
2457 if (!cap_src || !cap_dst) {
2458 goto done;
2459 }
2460
2461 /* Grab glue that binds each channel to something using the RTP engine */
2462 if (!(glue_dst = ast_rtp_instance_get_glue(ast_channel_tech(c_dst)->type)) || !(glue_src = ast_rtp_instance_get_glue(ast_channel_tech(c_src)->type))) {
2463 ast_debug(1, "Can't find native functions for channel '%s'\n", glue_dst ? ast_channel_name(c_src) : ast_channel_name(c_dst));
2464 goto done;
2465 }
2466
2467 audio_glue_dst_res = glue_dst->get_rtp_info(c_dst, &instance_dst);
2468 video_glue_dst_res = glue_dst->get_vrtp_info ? glue_dst->get_vrtp_info(c_dst, &vinstance_dst) : AST_RTP_GLUE_RESULT_FORBID;
2469
2470 audio_glue_src_res = glue_src->get_rtp_info(c_src, &instance_src);
2471 video_glue_src_res = glue_src->get_vrtp_info ? glue_src->get_vrtp_info(c_src, &vinstance_src) : AST_RTP_GLUE_RESULT_FORBID;
2472
2473 /* If we are carrying video, and both sides are not going to remotely bridge... fail the native bridge */
2474 if (video_glue_dst_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue_dst_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue_dst_res != AST_RTP_GLUE_RESULT_REMOTE)) {
2475 audio_glue_dst_res = AST_RTP_GLUE_RESULT_FORBID;
2476 }
2477 if (video_glue_src_res != AST_RTP_GLUE_RESULT_FORBID && (audio_glue_src_res != AST_RTP_GLUE_RESULT_REMOTE || video_glue_src_res != AST_RTP_GLUE_RESULT_REMOTE)) {
2478 audio_glue_src_res = AST_RTP_GLUE_RESULT_FORBID;
2479 }
2480 if (audio_glue_dst_res == AST_RTP_GLUE_RESULT_REMOTE && (video_glue_dst_res == AST_RTP_GLUE_RESULT_FORBID || video_glue_dst_res == AST_RTP_GLUE_RESULT_REMOTE) && glue_dst->get_codec) {
2481 glue_dst->get_codec(c_dst, cap_dst);
2482 }
2483 if (audio_glue_src_res == AST_RTP_GLUE_RESULT_REMOTE && (video_glue_src_res == AST_RTP_GLUE_RESULT_FORBID || video_glue_src_res == AST_RTP_GLUE_RESULT_REMOTE) && glue_src->get_codec) {
2484 glue_src->get_codec(c_src, cap_src);
2485 }
2486
2487 /* If any sort of bridge is forbidden just completely bail out and go back to generic bridging */
2488 if (audio_glue_dst_res != AST_RTP_GLUE_RESULT_REMOTE || audio_glue_src_res != AST_RTP_GLUE_RESULT_REMOTE) {
2489 goto done;
2490 }
2491
2492 /* Make sure we have matching codecs */
2493 if (!ast_format_cap_iscompatible(cap_dst, cap_src)) {
2494 goto done;
2495 }
2496
2497 ast_rtp_codecs_payloads_xover(&instance_src->codecs, &instance_dst->codecs, instance_dst);
2498
2499 if (vinstance_dst && vinstance_src) {
2500 ast_rtp_codecs_payloads_xover(&vinstance_src->codecs, &vinstance_dst->codecs, vinstance_dst);
2501 }
2502 if (tinstance_dst && tinstance_src) {
2503 ast_rtp_codecs_payloads_xover(&tinstance_src->codecs, &tinstance_dst->codecs, tinstance_dst);
2504 }
2505
2506 if (glue_dst->update_peer(c_dst, instance_src, vinstance_src, tinstance_src, cap_src, 0)) {
2507 ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n",
2508 ast_channel_name(c_dst), ast_channel_name(c_src));
2509 } else {
2510 ast_debug(1, "Seeded SDP of '%s' with that of '%s'\n",
2511 ast_channel_name(c_dst), ast_channel_name(c_src));
2512 }
2513
2514done:
2515 ast_channel_unlock(c_dst);
2516 ast_channel_unlock(c_src);
2517
2518 ao2_cleanup(cap_dst);
2519 ao2_cleanup(cap_src);
2520
2521 unref_instance_cond(&instance_dst);
2522 unref_instance_cond(&instance_src);
2523 unref_instance_cond(&vinstance_dst);
2524 unref_instance_cond(&vinstance_src);
2525 unref_instance_cond(&tinstance_dst);
2526 unref_instance_cond(&tinstance_src);
2527}
void ast_rtp_codecs_payloads_xover(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
Crossover copy the tx payload mapping of src to the rx payload mapping of dest.
Definition: rtp_engine.c:1315
struct ast_rtp_codecs codecs
Definition: rtp_engine.c:210

References ao2_cleanup, ast_channel_lock_both, ast_channel_name(), ast_channel_tech(), ast_channel_unlock, ast_debug, ast_format_cap_alloc, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_iscompatible(), ast_log, ast_rtp_codecs_payloads_xover(), AST_RTP_GLUE_RESULT_FORBID, AST_RTP_GLUE_RESULT_REMOTE, ast_rtp_instance_get_glue(), ast_rtp_instance::codecs, done, ast_rtp_glue::get_codec, ast_rtp_glue::get_rtp_info, ast_rtp_glue::get_vrtp_info, LOG_WARNING, NULL, type, unref_instance_cond(), and ast_rtp_glue::update_peer.

Referenced by dial_exec_full(), and do_forward().

◆ ast_rtp_instance_extmap_clear()

void ast_rtp_instance_extmap_clear ( struct ast_rtp_instance instance)

Clear negotiated RTP extension information.

Parameters
instanceThe RTP instance to clear negotiated extension information on

Definition at line 890 of file rtp_engine.c.

891{
892 static const struct rtp_extmap extmap_none = {
895 };
896 int idx;
897
898 ao2_lock(instance);
899
900 /* Clear both the known unique ids and the negotiated extensions as we are about to have
901 * new results set on us.
902 */
903 for (idx = 0; idx < AST_VECTOR_SIZE(&instance->extmap_unique_ids); ++idx) {
904 AST_VECTOR_REPLACE(&instance->extmap_unique_ids, idx, extmap_none);
905 }
906
907 for (idx = 0; idx < AST_VECTOR_SIZE(&instance->extmap_negotiated); ++idx) {
908 AST_VECTOR_REPLACE(&instance->extmap_negotiated, idx, -1);
909 }
910
911 ao2_unlock(instance);
912}
struct ast_rtp_instance::@391 extmap_unique_ids
struct ast_rtp_instance::@390 extmap_negotiated
enum ast_rtp_extension extension
Definition: rtp_engine.c:188

References ao2_lock, ao2_unlock, AST_RTP_EXTENSION_DIRECTION_NONE, AST_RTP_EXTENSION_UNSUPPORTED, AST_VECTOR_REPLACE, AST_VECTOR_SIZE, rtp_extmap::extension, ast_rtp_instance::extmap_negotiated, and ast_rtp_instance::extmap_unique_ids.

Referenced by process_extmap_attributes().

◆ ast_rtp_instance_extmap_count()

size_t ast_rtp_instance_extmap_count ( struct ast_rtp_instance instance)

Get the number of known unique identifiers.

Parameters
instanceThe RTP instance to retrieve the count from
Returns
the number of known unique identifiers
Since
15.5.0

Definition at line 927 of file rtp_engine.c.

928{
929 size_t count;
930
931 ao2_lock(instance);
932 count = AST_VECTOR_SIZE(&instance->extmap_unique_ids);
933 ao2_unlock(instance);
934
935 return count;
936}

References ao2_lock, ao2_unlock, AST_VECTOR_SIZE, and ast_rtp_instance::extmap_unique_ids.

Referenced by add_extmap_to_stream(), and enable_rtp_extension().

◆ ast_rtp_instance_extmap_enable()

int ast_rtp_instance_extmap_enable ( struct ast_rtp_instance instance,
int  id,
enum ast_rtp_extension  extension,
enum ast_rtp_extension_direction  direction 
)

Enable support for an RTP extension on an instance.

Parameters
instanceThe RTP instance to enable the extension on
idThe unique local identifier to use for this extension (-1 to have one auto selected)
extensionThe RTP extension
directionThe initial direction that the RTP extension should be used in
Return values
0success
-1failure
Since
15.5.0

Definition at line 760 of file rtp_engine.c.

762{
763 struct rtp_extmap extmap = {
765 .direction = direction,
766 };
767
768 ao2_lock(instance);
769
770 if (!instance->engine->extension_enable || !instance->engine->extension_enable(instance, extension)) {
771 ao2_unlock(instance);
772 return 0;
773 }
774
775 /* We store enabled extensions separately so we can easily do negotiation */
777 ao2_unlock(instance);
778 return -1;
779 }
780
781 if (id <= 0) {
782 /* We find a free unique identifier for this extension by just appending it to the
783 * vector of unique ids. The size of the vector will become its unique identifier.
784 * As well when we are asking for information on the extensions it will be returned,
785 * allowing it to be added to the SDP offer.
786 */
787 if (AST_VECTOR_APPEND(&instance->extmap_unique_ids, extmap)) {
789 ao2_unlock(instance);
790 return -1;
791 }
792 id = AST_VECTOR_SIZE(&instance->extmap_unique_ids);
793 } else {
794 /* Otherwise we put it precisely where they want it */
795 if (AST_VECTOR_REPLACE(&instance->extmap_unique_ids, id - 1, extmap)) {
797 ao2_unlock(instance);
798 return -1;
799 }
800 }
801
802 /* Now that we have an id add the extension to here */
803 if (AST_VECTOR_REPLACE(&instance->extmap_negotiated, extension, id)) {
807 AST_VECTOR_REPLACE(&instance->extmap_unique_ids, id - 1, extmap);
808 ao2_unlock(instance);
809 return -1;
810 }
811
812 ao2_unlock(instance);
813
814 return 0;
815}
direction
int(* extension_enable)(struct ast_rtp_instance *instance, enum ast_rtp_extension extension)
Definition: rtp_engine.h:750
struct ast_rtp_instance::@389 extmap_enabled
structure to hold extensions
enum ast_rtp_extension_direction direction
Definition: rtp_engine.c:190
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Definition: vector.h:267

References ao2_lock, ao2_unlock, AST_RTP_EXTENSION_DIRECTION_NONE, AST_RTP_EXTENSION_UNSUPPORTED, AST_VECTOR_APPEND, AST_VECTOR_REPLACE, AST_VECTOR_SIZE, rtp_extmap::direction, ast_rtp_instance::engine, rtp_extmap::extension, ast_rtp_engine::extension_enable, ast_rtp_instance::extmap_enabled, ast_rtp_instance::extmap_negotiated, and ast_rtp_instance::extmap_unique_ids.

Referenced by enable_rtp_extension().

◆ ast_rtp_instance_extmap_get_direction()

enum ast_rtp_extension_direction ast_rtp_instance_extmap_get_direction ( struct ast_rtp_instance instance,
int  id 
)

Retrieve the negotiated direction for an RTP extension id.

Parameters
instanceThe RTP instance to retrieve the direction from
idThe negotiated RTP extension id
Returns
direction the direction that has been negotiated
Since
15.5.0

Definition at line 958 of file rtp_engine.c.

959{
961
962 ao2_lock(instance);
963
964 if (0 < id && id <= AST_VECTOR_SIZE(&instance->extmap_unique_ids)) {
965 struct rtp_extmap *extmap = AST_VECTOR_GET_ADDR(&instance->extmap_unique_ids, id - 1);
966
967 direction = extmap->direction;
968 }
969 ao2_unlock(instance);
970
971 return direction;
972}
ast_rtp_extension_direction
Directions for RTP extensions.
Definition: rtp_engine.h:827
#define AST_VECTOR_GET_ADDR(vec, idx)
Get an address of element in a vector.
Definition: vector.h:679

References ao2_lock, ao2_unlock, AST_RTP_EXTENSION_DIRECTION_NONE, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, rtp_extmap::direction, and ast_rtp_instance::extmap_unique_ids.

Referenced by add_extmap_to_stream().

◆ ast_rtp_instance_extmap_get_extension()

enum ast_rtp_extension ast_rtp_instance_extmap_get_extension ( struct ast_rtp_instance instance,
int  id 
)

Retrieve the extension for an RTP extension id.

Parameters
instanceThe RTP instance to retrieve the extension from
idThe negotiated RTP extension id
Returns
extension the extension that maps to the id
Since
15.5.0
Note
This will return AST_RTP_EXTENSION_UNSUPPORTED if an extension was proposed for this unique identifier but it is not supported or if the unique identifier is unused.

Definition at line 938 of file rtp_engine.c.

939{
941
942 ao2_lock(instance);
943
944 /* The local unique identifier starts at '1' so the highest unique identifier
945 * can be the actual size of the vector. We compensate (as it is 0 index based)
946 * by dropping it down to 1 to get the correct information.
947 */
948 if (0 < id && id <= AST_VECTOR_SIZE(&instance->extmap_unique_ids)) {
949 struct rtp_extmap *extmap = AST_VECTOR_GET_ADDR(&instance->extmap_unique_ids, id - 1);
950
951 extension = extmap->extension;
952 }
953 ao2_unlock(instance);
954
955 return extension;
956}
ast_rtp_extension
Known RTP extensions.
Definition: rtp_engine.h:593

References ao2_lock, ao2_unlock, AST_RTP_EXTENSION_UNSUPPORTED, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, rtp_extmap::extension, and ast_rtp_instance::extmap_unique_ids.

Referenced by add_extmap_to_stream(), and ast_rtp_instance_extmap_get_uri().

◆ ast_rtp_instance_extmap_get_id()

int ast_rtp_instance_extmap_get_id ( struct ast_rtp_instance instance,
enum ast_rtp_extension  extension 
)

Retrieve the id for an RTP extension.

Parameters
instanceThe RTP instance to retrieve the id from
extensionThe RTP extension
Return values
-1not negotiated
idif negotiated
Since
15.5.0

Definition at line 914 of file rtp_engine.c.

915{
916 int id = -1;
917
918 ao2_lock(instance);
919 if (extension < AST_VECTOR_SIZE(&instance->extmap_negotiated)) {
921 }
922 ao2_unlock(instance);
923
924 return id;
925}
enum queue_result id
Definition: app_queue.c:1767

References ao2_lock, ao2_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_rtp_instance::extmap_negotiated, and id.

Referenced by ast_rtp_rtcp_handle_nack(), enable_rtp_extension(), rtp_instance_parse_extmap_extensions(), and rtp_raw_write().

◆ ast_rtp_instance_extmap_get_uri()

const char * ast_rtp_instance_extmap_get_uri ( struct ast_rtp_instance instance,
int  id 
)

Retrieve the URI for an RTP extension id.

Parameters
instanceThe RTP instance to retrieve the direction from
idThe negotiated RTP extension id
Returns
The URI for the RTP extension
Since
15.5.0

Definition at line 974 of file rtp_engine.c.

975{
977
979 (unsigned int)extension >= ARRAY_LEN(rtp_extension_uris)) {
980 return NULL;
981 }
982
984}
enum ast_rtp_extension ast_rtp_instance_extmap_get_extension(struct ast_rtp_instance *instance, int id)
Retrieve the extension for an RTP extension id.
Definition: rtp_engine.c:938
static const char *const rtp_extension_uris[AST_RTP_EXTENSION_MAX]
URIs for known RTP extensions.
Definition: rtp_engine.c:240
#define ARRAY_LEN(a)
Definition: utils.h:703

References ARRAY_LEN, AST_RTP_EXTENSION_UNSUPPORTED, ast_rtp_instance_extmap_get_extension(), rtp_extmap::extension, NULL, and rtp_extension_uris.

Referenced by add_extmap_to_stream().

◆ ast_rtp_instance_extmap_negotiate()

int ast_rtp_instance_extmap_negotiate ( struct ast_rtp_instance instance,
int  id,
enum ast_rtp_extension_direction  direction,
const char *  uri,
const char *  attributes 
)

Negotiate received RTP extension information.

Parameters
instanceThe RTP instance to set the extension on
idThe local identifier for the extension
directionThe direction that the extension should be used in
uriThe unique URI for the extension
attributesAttributes specific to this extension (if NULL or empty then no attributes)
Return values
0success
-1failure
Since
15.5.0

Definition at line 846 of file rtp_engine.c.

848{
849 /* 'attributes' is currently unused but exists in the API to ensure it does not need to be altered
850 * in the future in case we need to use it.
851 */
852 int idx;
854
855 /* Per the RFC the identifier has to be 1 or above */
856 if (id < 1) {
857 return -1;
858 }
859
860 /* Convert the provided URI to the internal representation */
861 for (idx = 0; idx < ARRAY_LEN(rtp_extension_uris); ++idx) {
862 if (!strcasecmp(rtp_extension_uris[idx], uri)) {
863 extension = idx;
864 break;
865 }
866 }
867
868 ao2_lock(instance);
869 /* We only accept the extension if it is enabled */
870 if (extension < AST_VECTOR_SIZE(&instance->extmap_enabled) &&
872 struct rtp_extmap extmap = {
875 };
876
877 /* If the direction negotiation failed then don't accept or use this extension */
881 }
882 AST_VECTOR_REPLACE(&instance->extmap_unique_ids, id - 1, extmap);
883 }
884 }
885 ao2_unlock(instance);
886
887 return 0;
888}
static enum ast_rtp_extension_direction rtp_extmap_negotiate_direction(enum ast_rtp_extension_direction ours, enum ast_rtp_extension_direction theirs)
Helper function which negotiates two RTP extension directions to get our current direction.
Definition: rtp_engine.c:818

References ao2_lock, ao2_unlock, ARRAY_LEN, AST_RTP_EXTENSION_DIRECTION_NONE, AST_RTP_EXTENSION_UNSUPPORTED, AST_VECTOR_GET, AST_VECTOR_REPLACE, AST_VECTOR_SIZE, rtp_extmap::direction, rtp_extmap::extension, ast_rtp_instance::extmap_enabled, ast_rtp_instance::extmap_negotiated, ast_rtp_instance::extmap_unique_ids, rtp_extension_uris, and rtp_extmap_negotiate_direction().

Referenced by process_extmap_attributes().

◆ ast_rtp_instance_fd()

int ast_rtp_instance_fd ( struct ast_rtp_instance instance,
int  rtcp 
)

Get the file descriptor for an RTP session (or RTCP)

Parameters
instanceInstance to get the file descriptor for
rtcpWhether to retrieve the file descriptor for RTCP or not
Return values
fdsuccess
-1failure

Example usage:

int rtp_fd = ast_rtp_instance_fd(instance, 0);
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:2384

This retrieves the file descriptor for the socket carrying media on the instance pointed to by instance.

Since
1.8

Definition at line 2384 of file rtp_engine.c.

2385{
2386 int res;
2387
2388 if (instance->engine->fd) {
2389 ao2_lock(instance);
2390 res = instance->engine->fd(instance, rtcp);
2391 ao2_unlock(instance);
2392 } else {
2393 res = -1;
2394 }
2395 return res;
2396}
int(* fd)(struct ast_rtp_instance *instance, int rtcp)
Definition: rtp_engine.h:706

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, and ast_rtp_engine::fd.

Referenced by apply_negotiated_sdp_stream(), check_for_rtp_changes(), configure_local_rtp(), jingle_enable_video(), jingle_new(), rtp_find_rtcp_fd_position(), start_rtp(), unicast_rtp_request(), and unistim_new().

◆ ast_rtp_instance_get_active_glue()

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.

Parameters
instanceThe RTP instance
Returns
pointer to the glue

Example:

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:2921

This gets the RTP glue currently in use on the RTP instance pointed to by 'instance'.

Since
1.8

Definition at line 2921 of file rtp_engine.c.

2922{
2923 return instance->glue;
2924}
struct ast_rtp_glue * glue
Definition: rtp_engine.c:218

References ast_rtp_instance::glue.

◆ ast_rtp_instance_get_and_cmp_local_address()

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.

Parameters
instanceThe instance that we want to get the local address for
addressAn initialized address that may be overwritten if the local address is different
Return values
0address was not changed
1address was changed Example usage:
int ret;
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:657

This retrieves the current local address set on the instance pointed to by instance and puts the value into the address structure.

Since
1.8

Definition at line 657 of file rtp_engine.c.

659{
660 ao2_lock(instance);
661 if (ast_sockaddr_cmp(address, &instance->local_address) != 0) {
663 ao2_unlock(instance);
664 return 1;
665 }
666 ao2_unlock(instance);
667
668 return 0;
669}
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
Definition: netsock2.h:167
int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares two ast_sockaddr structures.
Definition: netsock2.c:388
struct ast_sockaddr local_address
Definition: rtp_engine.c:202

References ao2_lock, ao2_unlock, ast_sockaddr_cmp(), ast_sockaddr_copy(), and ast_rtp_instance::local_address.

◆ ast_rtp_instance_get_and_cmp_requested_target_address()

int ast_rtp_instance_get_and_cmp_requested_target_address ( struct ast_rtp_instance instance,
struct ast_sockaddr address 
)

Get the requested target address of the remote endpoint and compare it to the given address.

Parameters
instanceThe instance that we want to get the remote address for
addressAn initialized address that may be overwritten addresses differ
Return values
0address was not changed
1address was changed

Definition at line 679 of file rtp_engine.c.

681{
682 ao2_lock(instance);
683 if (ast_sockaddr_cmp(address, &instance->requested_target_address) != 0) {
685 ao2_unlock(instance);
686 return 1;
687 }
688 ao2_unlock(instance);
689
690 return 0;
691}
struct ast_sockaddr requested_target_address
Definition: rtp_engine.c:204

References ao2_lock, ao2_unlock, ast_sockaddr_cmp(), ast_sockaddr_copy(), and ast_rtp_instance::requested_target_address.

◆ ast_rtp_instance_get_bridged()

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.

Parameters
instanceThe RTP instance that we want
Return values
non-NULLsuccess
NULLfailure

Example usage:

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:2426
struct ast_rtp_instance * bridged
Definition: rtp_engine.c:208

This gets the RTP instance that instance0 is bridged to.

Since
1.8

Definition at line 2426 of file rtp_engine.c.

2427{
2428 struct ast_rtp_instance *bridged;
2429
2430 ao2_lock(instance);
2431 bridged = instance->bridged;
2432 ao2_unlock(instance);
2433 return bridged;
2434}

References ao2_lock, ao2_unlock, and ast_rtp_instance::bridged.

Referenced by ast_rtp_interpret().

◆ ast_rtp_instance_get_channel_id()

const char * ast_rtp_instance_get_channel_id ( struct ast_rtp_instance instance)

Get the unique ID of the channel that owns this RTP instance.

Note that this should remain valid for the lifetime of the RTP instance.

Parameters
instanceThe RTP instance
Returns
The unique ID of the channel
Return values
Emptystring if no channel owns this RTP instance
Since
12

Definition at line 576 of file rtp_engine.c.

577{
578 return instance->channel_uniqueid;
579}

References ast_rtp_instance::channel_uniqueid.

Referenced by __rtp_recvfrom(), ast_rtcp_interpret(), ast_rtp_get_stat(), ast_rtp_prop_set(), ast_rtp_stop(), ast_rtp_write(), calc_rxstamp_and_jitter(), rtp_check_timeout(), rtp_raw_write(), rtp_transport_wide_cc_feedback_produce(), update_local_mes_stats(), and update_reported_mes_stats().

◆ ast_rtp_instance_get_cname()

const char * ast_rtp_instance_get_cname ( struct ast_rtp_instance rtp)

Retrieve the CNAME used in RTCP SDES items.

This is a pointer directly into the RTP struct, not a copy.

Parameters
rtpThe RTP instance
Returns
the CNAME

Definition at line 4040 of file rtp_engine.c.

4041{
4042 const char *cname = "";
4043
4044 ao2_lock(rtp);
4045 if (rtp->engine->cname_get) {
4046 cname = rtp->engine->cname_get(rtp);
4047 }
4048 ao2_unlock(rtp);
4049
4050 return cname;
4051}
const char *(* cname_get)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:734

References ao2_lock, ao2_unlock, ast_rtp_engine::cname_get, and ast_rtp_instance::engine.

Referenced by add_ssrc_to_stream().

◆ ast_rtp_instance_get_codecs()

struct ast_rtp_codecs * ast_rtp_instance_get_codecs ( struct ast_rtp_instance instance)

Get the codecs structure of an RTP instance.

Parameters
instanceThe RTP instance to get the codecs structure from

Example usage:

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:755

This gets the codecs structure on the RTP instance pointed to by 'instance'.

Since
1.8

Definition at line 755 of file rtp_engine.c.

756{
757 return &instance->codecs;
758}

References ast_rtp_instance::codecs.

Referenced by apply_cap_to_bundled(), ast_rtp_dtmf_begin(), ast_rtp_interpret(), ast_rtp_read(), ast_rtp_sendcng(), ast_rtp_write(), bridge_p2p_rtp_write(), configure_local_rtp(), create_outgoing_sdp_stream(), jingle_add_payloads_to_description(), jingle_enable_video(), jingle_interpret_description(), jingle_new(), multicast_rtp_write(), native_rtp_bridge_compatible_check(), ooh323_set_write_format(), send_start_rtp(), set_caps(), set_incoming_call_offer_cap(), and setup_rtp_connection().

◆ ast_rtp_instance_get_data()

void * ast_rtp_instance_get_data ( struct ast_rtp_instance instance)

Get the data portion of an RTP instance.

Parameters
instanceThe RTP instance we want the data portion from

Example usage:

struct *blob = ast_rtp_instance_get_data(instance);
(
void * ast_rtp_instance_get_data(struct ast_rtp_instance *instance)
Get the data portion of an RTP instance.
Definition: rtp_engine.c:591

This gets the data pointer on the RTP instance pointed to by 'instance'.

Since
1.8

Definition at line 591 of file rtp_engine.c.

592{
593 return instance->data;
594}

References ast_rtp_instance::data.

Referenced by __rtp_recvfrom(), __rtp_sendto(), ast_rtcp_calculate_sr_rr_statistics(), ast_rtcp_generate_nack(), ast_rtcp_generate_report(), ast_rtcp_generate_sdes(), ast_rtcp_interpret(), ast_rtcp_read(), ast_rtcp_write(), ast_rtp_bundle(), ast_rtp_change_source(), ast_rtp_destroy(), ast_rtp_dtmf_begin(), ast_rtp_dtmf_continuation(), ast_rtp_dtmf_end_with_duration(), ast_rtp_dtmf_mode_get(), ast_rtp_dtmf_mode_set(), ast_rtp_fd(), ast_rtp_get_cname(), ast_rtp_get_ssrc(), ast_rtp_get_stat(), ast_rtp_interpret(), ast_rtp_local_bridge(), ast_rtp_prop_set(), ast_rtp_qos_set(), ast_rtp_read(), ast_rtp_remote_address_set(), ast_rtp_rtcp_handle_nack(), ast_rtp_sendcng(), ast_rtp_set_remote_ssrc(), ast_rtp_set_stream_num(), ast_rtp_stop(), ast_rtp_stun_request(), ast_rtp_update_source(), ast_rtp_write(), bridge_p2p_rtp_write(), create_dtmf_frame(), multicast_rtp_activate(), multicast_rtp_destroy(), multicast_rtp_write(), process_cn_rfc3389(), process_dtmf_cisco(), process_dtmf_rfc2833(), red_write(), rtp_instance_parse_transport_wide_cc(), rtp_raw_write(), rtp_red_buffer(), rtp_red_init(), rtp_sendto(), and rtp_transport_wide_cc_feedback_produce().

◆ ast_rtp_instance_get_dtls()

struct ast_rtp_engine_dtls * ast_rtp_instance_get_dtls ( struct ast_rtp_instance instance)

Obtain a pointer to the DTLS support present on an RTP instance.

Parameters
instancethe RTP instance
Returns
DTLS support if present
Return values
NULLif no DTLS support available

Definition at line 3227 of file rtp_engine.c.

3228{
3229 if (instance->engine->dtls) {
3230 return &rtp_dtls_wrappers;
3231 }
3232 /* DTLS not available */
3233 return NULL;
3234}
static struct ast_rtp_engine_dtls rtp_dtls_wrappers
Definition: rtp_engine.c:3214
struct ast_rtp_engine_dtls * dtls
Definition: rtp_engine.h:744

References ast_rtp_engine::dtls, ast_rtp_instance::engine, NULL, and rtp_dtls_wrappers.

Referenced by add_crypto_to_stream(), add_fingerprints_if_present(), apply_dtls_attrib(), ast_sdp_get_rtp_profile(), and setup_dtls_srtp().

◆ ast_rtp_instance_get_engine()

struct ast_rtp_engine * ast_rtp_instance_get_engine ( struct ast_rtp_instance instance)

Get the RTP engine in use on an RTP instance.

Parameters
instanceThe RTP instance
Returns
pointer to the engine

Example usage:

struct ast_rtp_engine *engine = ast_rtp_instance_get_engine(instance);
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:2916

This gets the RTP engine currently in use on the RTP instance pointed to by 'instance'.

Since
1.8

Definition at line 2916 of file rtp_engine.c.

2917{
2918 return instance->engine;
2919}

References ast_rtp_instance::engine.

Referenced by native_rtp_bridge_compatible_check(), native_rtp_bridge_start(), and native_rtp_bridge_stop().

◆ ast_rtp_instance_get_extended_prop()

void * ast_rtp_instance_get_extended_prop ( struct ast_rtp_instance instance,
int  property 
)

Get the value of an RTP instance extended property.

Parameters
instanceThe RTP instance to get the extended property on
propertyThe extended property to get
Since
1.8

Definition at line 718 of file rtp_engine.c.

719{
720 void *prop;
721
722 if (instance->engine->extended_prop_get) {
723 ao2_lock(instance);
724 prop = instance->engine->extended_prop_get(instance, property);
725 ao2_unlock(instance);
726 } else {
727 prop = NULL;
728 }
729
730 return prop;
731}
void *(* extended_prop_get)(struct ast_rtp_instance *instance, int property)
Definition: rtp_engine.h:690

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, ast_rtp_engine::extended_prop_get, and NULL.

◆ ast_rtp_instance_get_glue()

struct ast_rtp_glue * ast_rtp_instance_get_glue ( const char *  type)

Get the RTP glue that binds a channel to the RTP engine.

Parameters
typeName of the glue we want
Return values
non-NULLsuccess
NULLfailure

Example usage:

struct ast_rtp_glue *glue = ast_rtp_instance_get_glue("Example");
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:2398

This retrieves the RTP glue that has the name 'Example'.

Since
1.8

Definition at line 2398 of file rtp_engine.c.

2399{
2400 struct ast_rtp_glue *glue = NULL;
2401
2403
2404 AST_RWLIST_TRAVERSE(&glues, glue, entry) {
2405 if (!strcasecmp(glue->type, type)) {
2406 break;
2407 }
2408 }
2409
2411
2412 return glue;
2413}
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, NULL, type, and ast_rtp_glue::type.

Referenced by ast_ari_channels_rtpstatistics(), ast_rtp_instance_early_bridge(), ast_rtp_instance_early_bridge_make_compatible(), ast_rtp_instance_make_compatible(), and rtp_glue_data_get().

◆ ast_rtp_instance_get_hold_timeout()

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.

Parameters
instanceThe RTP instance
Returns
timeout value

Example usage:

int timeout = ast_rtp_instance_get_hold_timeout(instance);
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:2906

This gets the RTP hold timeout value for the RTP instance pointed to by 'instance'.

Since
1.8

Definition at line 2906 of file rtp_engine.c.

2907{
2908 return instance->holdtimeout;
2909}

References ast_rtp_instance::holdtimeout.

◆ ast_rtp_instance_get_ice()

struct ast_rtp_engine_ice * ast_rtp_instance_get_ice ( struct ast_rtp_instance instance)

Obtain a pointer to the ICE support present on an RTP instance.

Parameters
instancethe RTP instance
Returns
ICE support if present
Return values
NULLif no ICE support available

Definition at line 3107 of file rtp_engine.c.

3108{
3109 if (instance->engine->ice) {
3110 return &rtp_ice_wrappers;
3111 }
3112 /* ICE not available */
3113 return NULL;
3114}
static struct ast_rtp_engine_ice rtp_ice_wrappers
Definition: rtp_engine.c:3093
struct ast_rtp_engine_ice * ice
Definition: rtp_engine.h:742

References ast_rtp_instance::engine, ast_rtp_engine::ice, NULL, and rtp_ice_wrappers.

Referenced by add_ice_to_stream(), check_ice_support(), create_rtp(), jingle_add_google_candidates_to_transport(), jingle_add_ice_udp_candidates_to_transport(), jingle_enable_video(), jingle_interpret_google_transport(), jingle_interpret_ice_udp_transport(), jingle_new(), jingle_outgoing_hook(), jingle_request(), process_ice_attributes(), process_ice_auth_attrb(), and set_ice_components().

◆ ast_rtp_instance_get_incoming_source_address()

void ast_rtp_instance_get_incoming_source_address ( struct ast_rtp_instance instance,
struct ast_sockaddr address 
)

Get the incoming source address of the remote endpoint.

This returns the remote address the engine is sending RTP to. Usually this will be the same as the requested target address, however in the case where the engine "learns" the address (for instance, symmetric RTP enabled) this will then contain the learned address.

Parameters
instanceThe instance that we want to get the incoming source address for
addressA structure to put the address into

Definition at line 693 of file rtp_engine.c.

695{
696 ao2_lock(instance);
698 ao2_unlock(instance);
699}
struct ast_sockaddr incoming_source_address
Definition: rtp_engine.c:206

References ao2_lock, ao2_unlock, ast_sockaddr_copy(), and ast_rtp_instance::incoming_source_address.

◆ ast_rtp_instance_get_keepalive()

int ast_rtp_instance_get_keepalive ( struct ast_rtp_instance instance)

Get the RTP keepalive interval.

Parameters
instanceThe RTP instance
Returns
period Keepalive interval value

Example usage:

int interval = ast_rtp_instance_get_keepalive(instance);
int ast_rtp_instance_get_keepalive(struct ast_rtp_instance *instance)
Get the RTP keepalive interval.
Definition: rtp_engine.c:2911

This gets the RTP keepalive interval value for the RTP instance pointed to by 'instance'.

Since
1.8

Definition at line 2911 of file rtp_engine.c.

2912{
2913 return instance->keepalive;
2914}

References ast_rtp_instance::keepalive.

Referenced by send_keepalive().

◆ ast_rtp_instance_get_last_rx()

time_t ast_rtp_instance_get_last_rx ( const struct ast_rtp_instance rtp)

Get the last RTP reception time.

Parameters
rtpThe instance from which to get the last reception time
Returns
The last RTP reception time

Definition at line 4017 of file rtp_engine.c.

4018{
4019 return rtp->last_rx;
4020}

References ast_rtp_instance::last_rx.

Referenced by rtp_check_timeout().

◆ ast_rtp_instance_get_last_tx()

time_t ast_rtp_instance_get_last_tx ( const struct ast_rtp_instance rtp)

Get the last RTP transmission time.

Parameters
rtpThe instance from which to get the last transmission time
Returns
The last RTP transmission time

Definition at line 4007 of file rtp_engine.c.

4008{
4009 return rtp->last_tx;
4010}

References ast_rtp_instance::last_tx.

Referenced by send_keepalive().

◆ ast_rtp_instance_get_local_address()

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.

Parameters
instanceThe RTP instance to get the address from
addressThe variable to store the address in

Example usage:

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:671

This gets the local address that we are expecting RTP on and stores it in the 'address' structure.

Since
1.8

Definition at line 671 of file rtp_engine.c.

673{
674 ao2_lock(instance);
676 ao2_unlock(instance);
677}

References ao2_lock, ao2_unlock, ast_sockaddr_copy(), and ast_rtp_instance::local_address.

Referenced by ast_rtp_prop_set(), ast_rtp_remote_address_set(), channel_read_rtp(), configure_local_rtp(), create_outgoing_sdp_stream(), multicast_send_control_packet(), send_start_rtp(), test_init_rtp_instances(), unicast_rtp_request(), and unistim_set_rtp_peer().

◆ ast_rtp_instance_get_prop()

int ast_rtp_instance_get_prop ( struct ast_rtp_instance instance,
enum ast_rtp_property  property 
)

Get the value of an RTP instance property.

Parameters
instanceThe RTP instance to get the property from
propertyThe property to get
Returns
Current value of the property

Example usage:

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:744

This returns the current value of the NAT property on the instance pointed to by instance.

Since
1.8

Definition at line 744 of file rtp_engine.c.

745{
746 int prop;
747
748 ao2_lock(instance);
749 prop = instance->properties[property];
750 ao2_unlock(instance);
751
752 return prop;
753}
int properties[AST_RTP_PROPERTY_MAX]
Definition: rtp_engine.c:200

References ao2_lock, ao2_unlock, and ast_rtp_instance::properties.

Referenced by ast_rtcp_interpret(), ast_rtp_dtmf_compatible(), ast_rtp_read(), bridge_p2p_rtp_write(), process_dtmf_cisco(), process_dtmf_rfc2833(), rtp_raw_write(), and rtp_write_rtcp_psfb().

◆ ast_rtp_instance_get_quality()

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.

Parameters
instanceInstance to get statistics on
fieldWhat quality statistic to retrieve
bufWhat buffer to put the result into
sizeSize of the above buffer
Return values
non-NULLsuccess
NULLfailure

Example usage:

#define AST_MAX_USER_FIELD
Definition: channel.h:176
static int quality
Definition: codec_speex.c:62
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
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:2656

This retrieves general quality statistics and places a text representation into the buf pointed to by buf.

Since
1.8

Definition at line 2656 of file rtp_engine.c.

2657{
2658 struct ast_rtp_instance_stats stats = { 0, };
2659 enum ast_rtp_instance_stat stat;
2660
2661 /* Determine what statistics we will need to retrieve based on field passed in */
2664 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER) {
2666 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS) {
2668 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT) {
2670 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_MES) {
2672 } else {
2673 return NULL;
2674 }
2675
2676 /* Attempt to actually retrieve the statistics we need to generate the quality string */
2677 if (ast_rtp_instance_get_stats(instance, &stats, stat)) {
2678 return NULL;
2679 }
2680
2681 /* Now actually fill the buffer with the good information */
2683 snprintf(buf, size, "ssrc=%u;themssrc=%u;lp=%u;rxjitter=%f;rxcount=%u;"
2684 "txjitter=%f;txcount=%u;rlp=%u;rtt=%f;rxmes=%f;txmes=%f",
2685 stats.local_ssrc, stats.remote_ssrc, stats.rxploss, stats.rxjitter,
2686 stats.rxcount, stats.txjitter, stats.txcount, stats.txploss, stats.rtt,
2687 stats.rxmes, stats.txmes);
2688 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER) {
2689 snprintf(buf, size, "minrxjitter=%010.6f;maxrxjitter=%010.6f;avgrxjitter=%010.6f;stdevrxjitter=%010.6f;mintxjitter=%010.6f;maxtxjitter=%010.6f;avgtxjitter=%010.6f;stdevtxjitter=%010.6f;",
2691 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS) {
2692 snprintf(buf, size, " minrxlost=%010.6f; maxrxlost=%010.6f; avgrxlost=%010.6f; stdevrxlost=%010.6f; mintxlost=%010.6f; maxtxlost=%010.6f; avgtxlost=%010.6f; stdevtxlost=%010.6f;",
2694 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT) {
2695 snprintf(buf, size, " minrtt=%010.6f; maxrtt=%010.6f; avgrtt=%010.6f; stdevrtt=%010.6f;", stats.minrtt, stats.maxrtt, stats.normdevrtt, stats.stdevrtt);
2696 } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_MES) {
2697 snprintf(buf, size, " minrxmes=%010.6f; maxrxmes=%010.6f; avgrxmes=%010.6f; stdevrxmes=%010.6f; mintxmes=%010.6f; maxtxmes=%010.6f; avgtxmes=%010.6f; stdevtxmes=%010.6f;",
2698 stats.local_minmes, stats.local_maxmes,
2699 stats.local_normdevmes, stats.local_stdevmes,
2700 stats.remote_minmes, stats.remote_maxmes,
2701 stats.remote_normdevmes, stats.remote_stdevmes);
2702 }
2703
2704 return buf;
2705}
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:2638
ast_rtp_instance_stat
Definition: rtp_engine.h:185

References ast_rtp_instance_get_stats(), AST_RTP_INSTANCE_STAT_ALL, AST_RTP_INSTANCE_STAT_COMBINED_JITTER, AST_RTP_INSTANCE_STAT_COMBINED_LOSS, AST_RTP_INSTANCE_STAT_COMBINED_MES, AST_RTP_INSTANCE_STAT_COMBINED_RTT, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_MES, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT, buf, ast_rtp_instance_stats::local_maxjitter, ast_rtp_instance_stats::local_maxmes, ast_rtp_instance_stats::local_maxrxploss, ast_rtp_instance_stats::local_minjitter, ast_rtp_instance_stats::local_minmes, ast_rtp_instance_stats::local_minrxploss, ast_rtp_instance_stats::local_normdevjitter, ast_rtp_instance_stats::local_normdevmes, ast_rtp_instance_stats::local_normdevrxploss, ast_rtp_instance_stats::local_ssrc, ast_rtp_instance_stats::local_stdevjitter, ast_rtp_instance_stats::local_stdevmes, ast_rtp_instance_stats::local_stdevrxploss, ast_rtp_instance_stats::maxrtt, ast_rtp_instance_stats::minrtt, ast_rtp_instance_stats::normdevrtt, NULL, ast_rtp_instance_stats::remote_maxjitter, ast_rtp_instance_stats::remote_maxmes, ast_rtp_instance_stats::remote_maxrxploss, ast_rtp_instance_stats::remote_minjitter, ast_rtp_instance_stats::remote_minmes, ast_rtp_instance_stats::remote_minrxploss, ast_rtp_instance_stats::remote_normdevjitter, ast_rtp_instance_stats::remote_normdevmes, ast_rtp_instance_stats::remote_normdevrxploss, ast_rtp_instance_stats::remote_ssrc, ast_rtp_instance_stats::remote_stdevjitter, ast_rtp_instance_stats::remote_stdevmes, ast_rtp_instance_stats::remote_stdevrxploss, ast_rtp_instance_stats::rtt, ast_rtp_instance_stats::rxcount, ast_rtp_instance_stats::rxjitter, ast_rtp_instance_stats::rxmes, ast_rtp_instance_stats::rxploss, ast_rtp_instance_stats::stdevrtt, ast_rtp_instance_stats::txcount, ast_rtp_instance_stats::txjitter, ast_rtp_instance_stats::txmes, and ast_rtp_instance_stats::txploss.

Referenced by ast_rtp_instance_destroy(), ast_rtp_instance_set_stats_vars(), and channel_read_rtcp().

◆ ast_rtp_instance_get_requested_target_address()

void ast_rtp_instance_get_requested_target_address ( struct ast_rtp_instance instance,
struct ast_sockaddr address 
)

Get the requested target address of the remote endpoint.

This returns the explicitly set address of a remote endpoint. Meaning this won't change unless specifically told to change. In most cases this should be the same as the incoming source address, except in cases where the engine "learns" the address in which case this and the incoming source address might differ.

Parameters
instanceThe instance that we want to get the requested target address for
addressA structure to put the address into

Definition at line 701 of file rtp_engine.c.

703{
704 ao2_lock(instance);
706 ao2_unlock(instance);
707}

References ao2_lock, ao2_unlock, ast_sockaddr_copy(), and ast_rtp_instance::requested_target_address.

Referenced by ast_rtp_read().

◆ ast_rtp_instance_get_srtp()

struct ast_srtp * ast_rtp_instance_get_srtp ( struct ast_rtp_instance instance,
int  rtcp 
)

Obtain the SRTP instance associated with an RTP instance.

Parameters
instancethe RTP instance
rtcp1 to request instance for RTCP
Returns
the SRTP instance on success
Return values
NULLif no SRTP instance exists

Definition at line 2979 of file rtp_engine.c.

2980{
2981 if (rtcp && instance->rtcp_srtp) {
2982 return instance->rtcp_srtp;
2983 } else {
2984 return instance->srtp;
2985 }
2986}

References ast_rtp_instance::rtcp_srtp, and ast_rtp_instance::srtp.

Referenced by __rtp_sendto(), ast_rtcp_read(), ast_rtp_change_source(), and ast_rtp_read().

◆ ast_rtp_instance_get_ssrc()

unsigned int ast_rtp_instance_get_ssrc ( struct ast_rtp_instance rtp)

Retrieve the local SSRC value that we will be using.

Parameters
rtpThe RTP instance
Returns
The SSRC value

Definition at line 4027 of file rtp_engine.c.

4028{
4029 unsigned int ssrc = 0;
4030
4031 ao2_lock(rtp);
4032 if (rtp->engine->ssrc_get) {
4033 ssrc = rtp->engine->ssrc_get(rtp);
4034 }
4035 ao2_unlock(rtp);
4036
4037 return ssrc;
4038}
unsigned int(* ssrc_get)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:732

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, and ast_rtp_engine::ssrc_get.

Referenced by add_ssrc_to_stream(), ast_srtp_unprotect(), and create_outgoing_sdp_stream().

◆ ast_rtp_instance_get_stats()

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.

Parameters
instanceInstance to get statistics on
statsStructure to put results into
statWhat statistic(s) to retrieve
Return values
0success
-1failure

Example usage:

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:2638

This retrieves all statistics the underlying RTP engine supports and puts the values into the stats structure.

Since
1.8

Definition at line 2638 of file rtp_engine.c.

2639{
2640 int res;
2641
2642 if (!instance || !instance->engine || !stats) {
2643 return -1;
2644 }
2645
2646 if (instance->engine->get_stat) {
2647 ao2_lock(instance);
2648 res = instance->engine->get_stat(instance, stats, stat);
2649 ao2_unlock(instance);
2650 } else {
2651 res = -1;
2652 }
2653 return res;
2654}
int(* get_stat)(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
Definition: rtp_engine.h:702

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, and ast_rtp_engine::get_stat.

Referenced by ast_rtp_instance_get_quality(), ast_rtp_instance_get_stats_all_json(), ast_sip_session_media_stats_save(), ast_srtp_unprotect(), AST_TEST_DEFINE(), channel_read_rtcp(), cli_channelstats_print_body(), crypto_activate(), and process_ssrc_attributes().

◆ ast_rtp_instance_get_stats_all_json()

struct ast_json * ast_rtp_instance_get_stats_all_json ( struct ast_rtp_instance instance)

Retrieve statistics about an RTP instance in json format.

Parameters
instance
Returns
json object of stats

Definition at line 4281 of file rtp_engine.c.

4282{
4283 struct ast_rtp_instance_stats stats = {0,};
4284
4286 return NULL;
4287 }
4288
4289 return ast_rtp_convert_stats_json(&stats);
4290}
struct ast_json * ast_rtp_convert_stats_json(const struct ast_rtp_instance_stats *stats)
Convert given stat instance into json format.
Definition: rtp_engine.c:4205

References ast_rtp_convert_stats_json(), ast_rtp_instance_get_stats(), AST_RTP_INSTANCE_STAT_ALL, and NULL.

Referenced by ast_ari_channels_rtpstatistics().

◆ ast_rtp_instance_get_timeout()

int ast_rtp_instance_get_timeout ( struct ast_rtp_instance instance)

Get the RTP timeout value.

Parameters
instanceThe RTP instance
Returns
timeout value

Example usage:

int timeout = ast_rtp_instance_get_timeout(instance);
int ast_rtp_instance_get_timeout(struct ast_rtp_instance *instance)
Get the RTP timeout value.
Definition: rtp_engine.c:2901

This gets the RTP timeout value for the RTP instance pointed to by 'instance'.

Since
1.8

Definition at line 2901 of file rtp_engine.c.

2902{
2903 return instance->timeout;
2904}

References ast_rtp_instance::timeout.

Referenced by apply_negotiated_sdp_stream(), and rtp_check_timeout().

◆ ast_rtp_instance_make_compatible()

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.

Parameters
chanOur own Asterisk channel
instanceThe first RTP instance
peerThe peer Asterisk channel
Return values
0success
-1failure

Example usage:

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:2805

This makes the RTP instance for 'peer' compatible with 'instance' and vice versa.

Since
1.8

Definition at line 2805 of file rtp_engine.c.

2806{
2807 struct ast_rtp_glue *glue;
2808 struct ast_rtp_instance *peer_instance = NULL;
2809 int res = -1;
2810
2811 if (!instance->engine->make_compatible) {
2812 return -1;
2813 }
2814
2815 ast_channel_lock(peer);
2816
2818 ast_channel_unlock(peer);
2819 return -1;
2820 }
2821
2822 glue->get_rtp_info(peer, &peer_instance);
2823 if (!peer_instance) {
2824 ast_log(LOG_ERROR, "Unable to get_rtp_info for peer type %s\n", glue->type);
2825 ast_channel_unlock(peer);
2826 return -1;
2827 }
2828 if (peer_instance->engine != instance->engine) {
2829 ast_log(LOG_ERROR, "Peer engine mismatch for type %s\n", glue->type);
2830 ast_channel_unlock(peer);
2831 ao2_ref(peer_instance, -1);
2832 return -1;
2833 }
2834
2835 /*
2836 * XXX Good thing nothing calls this function because we would need
2837 * deadlock avoidance to get the two instance locks.
2838 */
2839 res = instance->engine->make_compatible(chan, instance, peer, peer_instance);
2840
2841 ast_channel_unlock(peer);
2842
2843 ao2_ref(peer_instance, -1);
2844 peer_instance = NULL;
2845
2846 return res;
2847}
#define ast_channel_lock(chan)
Definition: channel.h:2972
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:720

References ao2_ref, ast_channel_lock, ast_channel_tech(), ast_channel_unlock, ast_log, ast_rtp_instance_get_glue(), ast_rtp_instance::engine, ast_rtp_glue::get_rtp_info, ast_rtp_instance::glue, LOG_ERROR, ast_rtp_engine::make_compatible, NULL, type, and ast_rtp_glue::type.

◆ ast_rtp_instance_new()

struct ast_rtp_instance * ast_rtp_instance_new ( const char *  engine_name,
struct ast_sched_context sched,
const struct ast_sockaddr sa,
void *  data 
)

Create a new RTP instance.

Parameters
engine_nameName of the engine to use for the RTP instance
schedScheduler context that the RTP engine may want to use
saAddress we want to bind to
dataUnique data for the engine
Return values
non-NULLsuccess
NULLfailure

Example usage:

struct ast_rtp_instance *instance = NULL;
instance = ast_rtp_instance_new(NULL, sched, &sin, NULL);
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
Definition: rtp_engine.c:493
Definition: sched.c:76

This creates a new RTP instance using the default engine and asks the RTP engine to bind to the address given in the address structure.

Note
The RTP engine does not have to use the address provided when creating an RTP instance. It may choose to use another depending on it's own configuration.
Since
1.8

Definition at line 493 of file rtp_engine.c.

496{
497 struct ast_sockaddr address = {{0,}};
498 struct ast_rtp_instance *instance = NULL;
499 struct ast_rtp_engine *engine = NULL;
500 struct ast_module *mod_ref;
501
503
504 /* If an engine name was specified try to use it or otherwise use the first one registered */
505 if (!ast_strlen_zero(engine_name)) {
507 if (!strcmp(engine->name, engine_name)) {
508 break;
509 }
510 }
511 } else {
512 engine = AST_RWLIST_FIRST(&engines);
513 }
514
515 /* If no engine was actually found bail out now */
516 if (!engine) {
517 ast_log(LOG_ERROR, "No RTP engine was found. Do you have one loaded?\n");
519 return NULL;
520 }
521
522 /* Bump up the reference count before we return so the module can not be unloaded */
523 mod_ref = ast_module_running_ref(engine->mod);
524
526
527 if (!mod_ref) {
528 /* BUGBUG: improve handling of this situation. */
529 return NULL;
530 }
531
532 /* Allocate a new RTP instance */
533 if (!(instance = ao2_alloc(sizeof(*instance), instance_destructor))) {
534 ast_module_unref(engine->mod);
535 return NULL;
536 }
537 instance->engine = engine;
538 ast_sockaddr_copy(&instance->local_address, sa);
540
542 ao2_ref(instance, -1);
543 return NULL;
544 }
545
546 /* Initialize RTP extension support */
547 if (AST_VECTOR_INIT(&instance->extmap_enabled, 0) ||
548 AST_VECTOR_INIT(&instance->extmap_negotiated, 0) ||
549 AST_VECTOR_INIT(&instance->extmap_unique_ids, 0)) {
550 ao2_ref(instance, -1);
551 return NULL;
552 }
553
554 ast_debug(1, "Using engine '%s' for RTP instance '%p'\n", engine->name, instance);
555
556 /*
557 * And pass it off to the engine to setup
558 *
559 * Lock in case the RTP engine has other threads that
560 * need synchronization with the construction.
561 */
562 ao2_lock(instance);
563 if (instance->engine->new(instance, sched, &address, data)) {
564 ast_debug(1, "Engine '%s' failed to setup RTP instance '%p'\n", engine->name, instance);
565 ao2_unlock(instance);
566 ao2_ref(instance, -1);
567 return NULL;
568 }
569 ao2_unlock(instance);
570
571 ast_debug(1, "RTP instance '%p' is setup and ready to go\n", instance);
572
573 return instance;
574}
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:409
#define AST_RWLIST_FIRST
Definition: linkedlists.h:423
#define ast_module_unref(mod)
Release a reference to the module.
Definition: module.h:483
#define ast_module_running_ref(mod)
Hold a reference to the module if it is running.
Definition: module.h:469
static void instance_destructor(void *obj)
Definition: rtp_engine.c:429
struct ast_module::@369 entry

References ao2_alloc, ao2_lock, ao2_ref, ao2_unlock, ast_debug, ast_log, ast_module_running_ref, ast_module_unref, ast_rtp_codecs_payloads_initialize(), AST_RWLIST_FIRST, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_sockaddr_copy(), ast_strlen_zero(), AST_VECTOR_INIT, ast_rtp_instance::codecs, ast_rtp_instance::engine, ast_module::entry, ast_rtp_instance::extmap_enabled, ast_rtp_instance::extmap_negotiated, ast_rtp_instance::extmap_unique_ids, instance_destructor(), ast_rtp_instance::local_address, LOG_ERROR, ast_rtp_engine::mod, ast_rtp_engine::name, ast_rtp_engine::new, and NULL.

Referenced by configure_local_rtp(), create_rtp(), jingle_alloc(), jingle_enable_video(), multicast_rtp_request(), start_rtp(), test_init_rtp_instances(), and unicast_rtp_request().

◆ ast_rtp_instance_read()

struct ast_frame * ast_rtp_instance_read ( struct ast_rtp_instance instance,
int  rtcp 
)

Receive a frame over RTP.

Parameters
instanceThe RTP instance to receive frame on
rtcpWhether to read in RTCP or not
Return values
non-NULLsuccess
NULLfailure

Example usage:

struct ast_frame *frame;
frame = ast_rtp_instance_read(instance, 0);
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
Definition: rtp_engine.c:606
Data structure associated with a single frame of data.

This asks the RTP engine to read in RTP from the instance and return it as an Asterisk frame.

Since
1.8

Definition at line 606 of file rtp_engine.c.

607{
608 struct ast_frame *frame;
609
610 ao2_lock(instance);
611 frame = instance->engine->read(instance, rtcp);
612 ao2_unlock(instance);
613 return frame;
614}

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, and ast_rtp_engine::read.

Referenced by AST_TEST_DEFINE(), jingle_read(), media_session_rtcp_read_callback(), media_session_rtp_read_callback(), ooh323_rtp_read(), rtp_read(), test_read_frames(), test_write_and_read_interleaved_frames(), and unistim_rtp_read().

◆ ast_rtp_instance_sendcng()

int ast_rtp_instance_sendcng ( struct ast_rtp_instance instance,
int  level 
)

Send a comfort noise packet to the RTP instance.

Parameters
instanceThe RTP instance
levelMagnitude of the noise level
Return values
0Success
non-zeroFailure

Definition at line 2988 of file rtp_engine.c.

2989{
2990 int res;
2991
2992 if (instance->engine->sendcng) {
2993 ao2_lock(instance);
2994 res = instance->engine->sendcng(instance, level);
2995 ao2_unlock(instance);
2996 } else {
2997 res = -1;
2998 }
2999 return res;
3000}
int(* sendcng)(struct ast_rtp_instance *instance, int level)
Definition: rtp_engine.h:730

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, and ast_rtp_engine::sendcng.

Referenced by do_monitor(), and send_keepalive().

◆ ast_rtp_instance_set_bridged()

void ast_rtp_instance_set_bridged ( struct ast_rtp_instance instance,
struct ast_rtp_instance bridged 
)

Set the other RTP instance that an instance is bridged to.

Parameters
instanceThe RTP instance that we want to set the bridged value on
bridgedThe RTP instance they are bridged to
Since
12

Definition at line 2436 of file rtp_engine.c.

2437{
2438 ao2_lock(instance);
2439 instance->bridged = bridged;
2440 ao2_unlock(instance);
2441}

References ao2_lock, ao2_unlock, and ast_rtp_instance::bridged.

Referenced by native_rtp_bridge_start(), and native_rtp_bridge_stop().

◆ ast_rtp_instance_set_channel_id()

void ast_rtp_instance_set_channel_id ( struct ast_rtp_instance instance,
const char *  uniqueid 
)

Set the channel that owns this RTP instance.

Parameters
instanceThe RTP instance
uniqueidThe uniqueid of the channel
Since
12

Definition at line 581 of file rtp_engine.c.

582{
583 ast_copy_string(instance->channel_uniqueid, uniqueid, sizeof(instance->channel_uniqueid));
584}
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425

References ast_copy_string(), and ast_rtp_instance::channel_uniqueid.

Referenced by apply_negotiated_sdp_stream(), jingle_enable_video(), jingle_set_owner(), multicast_rtp_request(), set_channel_on_rtp_instance(), start_rtp(), test_init_rtp_instances(), unicast_rtp_request(), and unistim_set_owner().

◆ ast_rtp_instance_set_data()

void ast_rtp_instance_set_data ( struct ast_rtp_instance instance,
void *  data 
)

Set the data portion of an RTP instance.

Parameters
instanceThe RTP instance to manipulate
dataPointer to data

Example usage:

ast_rtp_instance_set_data(instance, blob);
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:586

This sets the data pointer on the RTP instance pointed to by 'instance' to blob.

Since
1.8

Definition at line 586 of file rtp_engine.c.

587{
588 instance->data = data;
589}

References ast_rtp_instance::data.

Referenced by ast_rtp_new(), and multicast_rtp_new().

◆ ast_rtp_instance_set_extended_prop()

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.

Parameters
instanceThe RTP instance to set the extended property on
propertyThe extended property to set
valueThe value to set the extended property to
Since
1.8

Definition at line 709 of file rtp_engine.c.

710{
711 if (instance->engine->extended_prop_set) {
712 ao2_lock(instance);
713 instance->engine->extended_prop_set(instance, property, value);
714 ao2_unlock(instance);
715 }
716}
int(* extended_prop_set)(struct ast_rtp_instance *instance, int property, void *value)
Definition: rtp_engine.h:688

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, ast_rtp_engine::extended_prop_set, and value.

◆ ast_rtp_instance_set_hold_timeout()

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.

Parameters
instanceThe RTP instance
timeoutValue to set the timeout to

Example usage:

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:2891

This sets the RTP hold timeout value on 'instance' to be 5000.

Since
1.8

Definition at line 2891 of file rtp_engine.c.

2892{
2893 instance->holdtimeout = timeout;
2894}

References ast_rtp_instance::holdtimeout, and ast_rtp_instance::timeout.

◆ ast_rtp_instance_set_incoming_source_address()

int ast_rtp_instance_set_incoming_source_address ( struct ast_rtp_instance instance,
const struct ast_sockaddr address 
)

Set the incoming source address of the remote endpoint that we are sending RTP to.

This sets the incoming source address the engine is sending RTP to. Usually this will be the same as the requested target address, however in the case where the engine "learns" the address (for instance, symmetric RTP enabled) this will then contain the learned address.

Parameters
instanceThe RTP instance to change the address on
addressAddress to set it to
Return values
0success
-1failure

Definition at line 634 of file rtp_engine.c.

636{
637 ao2_lock(instance);
639 ao2_unlock(instance);
640
641 return 0;
642}
static void rtp_instance_set_incoming_source_address_nolock(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Definition: rtp_engine.c:625

References ao2_lock, ao2_unlock, and rtp_instance_set_incoming_source_address_nolock().

Referenced by ast_rtp_read().

◆ ast_rtp_instance_set_keepalive()

void ast_rtp_instance_set_keepalive ( struct ast_rtp_instance instance,
int  timeout 
)

Set the RTP keepalive interval.

Parameters
instanceThe RTP instance
timeoutValue to set the keepalive interval to

Example usage:

void ast_rtp_instance_set_keepalive(struct ast_rtp_instance *instance, int timeout)
Set the RTP keepalive interval.
Definition: rtp_engine.c:2896

This sets the RTP keepalive interval on 'instance' to be 5000.

Since
1.8

Definition at line 2896 of file rtp_engine.c.

2897{
2898 instance->keepalive = interval;
2899}

References ast_rtp_instance::keepalive.

Referenced by apply_negotiated_sdp_stream().

◆ ast_rtp_instance_set_last_rx()

void ast_rtp_instance_set_last_rx ( struct ast_rtp_instance rtp,
time_t  time 
)

Set the last RTP reception time.

Parameters
rtpThe instance on which to set the last reception time
timeThe last reception time

Definition at line 4022 of file rtp_engine.c.

4023{
4024 rtp->last_rx = time;
4025}

References ast_rtp_instance::last_rx.

Referenced by create_rtp(), media_session_rtcp_read_callback(), media_session_rtp_read_callback(), and rtp_check_timeout().

◆ ast_rtp_instance_set_last_tx()

void ast_rtp_instance_set_last_tx ( struct ast_rtp_instance rtp,
time_t  time 
)

Set the last RTP transmission time.

Parameters
rtpThe instance on which to set the last transmission time
timeThe last transmission time

Definition at line 4012 of file rtp_engine.c.

4013{
4014 rtp->last_tx = time;
4015}

References ast_rtp_instance::last_tx.

Referenced by __rtp_sendto().

◆ ast_rtp_instance_set_local_address()

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.

Parameters
instanceThe RTP instance to change the address on
addressAddress to set it to
Return values
0success
-1failure

Example usage:

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:616

This changes the local address that RTP is expected on to the address given in the sin structure.

Since
1.8

Definition at line 616 of file rtp_engine.c.

618{
619 ao2_lock(instance);
621 ao2_unlock(instance);
622 return 0;
623}

References ao2_lock, ao2_unlock, ast_sockaddr_copy(), and ast_rtp_instance::local_address.

Referenced by ast_rtp_remote_address_set(), and rtp_allocate_transport().

◆ ast_rtp_instance_set_prop()

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.

Parameters
instanceThe RTP instance to set the property on
propertyThe property to modify
valueThe value to set the property to

Example usage:

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:733

This enables the AST_RTP_PROPERTY_NAT property on the instance pointed to by instance.

Since
1.8

Definition at line 733 of file rtp_engine.c.

734{
735 ao2_lock(instance);
736 instance->properties[property] = value;
737
738 if (instance->engine->prop_set) {
739 instance->engine->prop_set(instance, property, value);
740 }
741 ao2_unlock(instance);
742}
void(* prop_set)(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Definition: rtp_engine.h:692

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, ast_rtp_engine::prop_set, ast_rtp_instance::properties, and value.

Referenced by check_for_rtp_changes(), configure_local_rtp(), create_rtp(), enable_rtcp(), get_codecs(), jingle_alloc(), jingle_enable_video(), pjsip_acf_dtmf_mode_write(), start_rtp(), and test_init_rtp_instances().

◆ ast_rtp_instance_set_qos()

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.

Parameters
instanceInstance to set the QoS parameters on
tosTerms of service value
cosClass of service value
descWhat is setting the QoS values
Return values
0success
-1failure

Example usage:

ast_rtp_instance_set_qos(instance, 0, 0, "Example");
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:2361

This sets the TOS and COS values to 0 on the instance pointed to by instance.

Since
1.8

Definition at line 2361 of file rtp_engine.c.

2362{
2363 int res;
2364
2365 if (instance->engine->qos) {
2366 ao2_lock(instance);
2367 res = instance->engine->qos(instance, tos, cos, desc);
2368 ao2_unlock(instance);
2369 } else {
2370 res = -1;
2371 }
2372 return res;
2373}
static const char desc[]
Definition: cdr_radius.c:84
unsigned int tos
Definition: chan_iax2.c:379
unsigned int cos
Definition: chan_iax2.c:380
int(* qos)(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
Definition: rtp_engine.h:704

References ao2_lock, ao2_unlock, cos, desc, ast_rtp_instance::engine, ast_rtp_engine::qos, and tos.

Referenced by configure_local_rtp(), create_rtp(), and start_rtp().

◆ ast_rtp_instance_set_read_format()

int ast_rtp_instance_set_read_format ( struct ast_rtp_instance instance,
struct ast_format format 
)

Request that the underlying RTP engine provide audio frames in a specific format.

Parameters
instanceThe RTP instance to change read format on
formatFormat that frames are wanted in
Return values
0success
-1failure

Example usage:

struct ast_format tmp_fmt;
int ast_rtp_instance_set_read_format(struct ast_rtp_instance *instance, struct ast_format *format)
Request that the underlying RTP engine provide audio frames in a specific format.
Definition: rtp_engine.c:2776

This requests that the RTP engine provide audio frames in the ULAW format.

Since
1.8

Definition at line 2776 of file rtp_engine.c.

2777{
2778 int res;
2779
2780 if (instance->engine->set_read_format) {
2781 ao2_lock(instance);
2782 res = instance->engine->set_read_format(instance, format);
2783 ao2_unlock(instance);
2784 } else {
2785 res = -1;
2786 }
2787 return res;
2788}
int(* set_read_format)(struct ast_rtp_instance *instance, struct ast_format *format)
Definition: rtp_engine.h:716

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, and ast_rtp_engine::set_read_format.

◆ ast_rtp_instance_set_remote_ssrc()

void ast_rtp_instance_set_remote_ssrc ( struct ast_rtp_instance rtp,
unsigned int  ssrc 
)

Set the remote SSRC for an RTP instance.

Since
15.0.0
Parameters
rtpThe RTP instance
ssrcThe remote SSRC

Definition at line 4070 of file rtp_engine.c.

4071{
4072 ao2_lock(rtp);
4073 if (rtp->engine->set_remote_ssrc) {
4074 rtp->engine->set_remote_ssrc(rtp, ssrc);
4075 }
4076 ao2_unlock(rtp);
4077}
void(* set_remote_ssrc)(struct ast_rtp_instance *instance, unsigned int ssrc)
Definition: rtp_engine.h:738

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, and ast_rtp_engine::set_remote_ssrc.

Referenced by process_ssrc_attributes().

◆ ast_rtp_instance_set_requested_target_address()

int ast_rtp_instance_set_requested_target_address ( struct ast_rtp_instance instance,
const struct ast_sockaddr address 
)

Set the requested target address of the remote endpoint.

This should always be the address of the remote endpoint. Consequently, this can differ from the address the engine is sending RTP to. However, usually they will be the same except in some circumstances (for instance when the engine "learns" the address if symmetric RTP is enabled).

Parameters
instanceThe RTP instance to change the address on
addressAddress to set it to
Return values
0success
-1failure

Definition at line 644 of file rtp_engine.c.

646{
647 ao2_lock(instance);
648
651
652 ao2_unlock(instance);
653
654 return 0;
655}

References ao2_lock, ao2_unlock, ast_sockaddr_copy(), ast_rtp_instance::requested_target_address, and rtp_instance_set_incoming_source_address_nolock().

◆ ast_rtp_instance_set_stats_vars()

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.

Parameters
chanChannel to set the statistics on
instanceThe RTP instance that statistics will be retrieved from
Note
Absolutely NO channel locks should be held before calling this function.

Example usage:

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:2707

This retrieves standard statistics from the RTP instance rtp and sets it on the channel pointed to by chan.

Since
1.8

Definition at line 2707 of file rtp_engine.c.

2708{
2709 char quality_buf[AST_MAX_USER_FIELD];
2710 char *quality;
2711 struct ast_channel *bridge;
2712
2714 if (bridge) {
2717 } else {
2718 ast_channel_lock(chan);
2719 }
2721
2723 quality_buf, sizeof(quality_buf));
2724 if (quality) {
2725 pbx_builtin_setvar_helper(chan, "RTPAUDIOQOS", quality);
2726 if (bridge) {
2727 pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSBRIDGED", quality);
2728 }
2729 }
2730
2732 AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, quality_buf, sizeof(quality_buf));
2733 if (quality) {
2734 pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSJITTER", quality);
2735 if (bridge) {
2736 pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSJITTERBRIDGED", quality);
2737 }
2738 }
2739
2741 AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, quality_buf, sizeof(quality_buf));
2742 if (quality) {
2743 pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSLOSS", quality);
2744 if (bridge) {
2745 pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSLOSSBRIDGED", quality);
2746 }
2747 }
2748
2750 AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT, quality_buf, sizeof(quality_buf));
2751 if (quality) {
2752 pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSRTT", quality);
2753 if (bridge) {
2754 pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSRTTBRIDGED", quality);
2755 }
2756 }
2757
2759 AST_RTP_INSTANCE_STAT_FIELD_QUALITY_MES, quality_buf, sizeof(quality_buf));
2760 if (quality) {
2761 pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSMES", quality);
2762 if (bridge) {
2763 pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSMESBRIDGED", quality);
2764 }
2765 }
2766
2768 ast_channel_unlock(chan);
2769 if (bridge) {
2773 }
2774}
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
Definition: channel.c:10578
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:3008
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
Main Channel structure associated with a channel.
struct ast_bridge * bridge

References ast_channel_bridge_peer(), ast_channel_lock, ast_channel_lock_both, ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), ast_channel_unlock, ast_channel_unref, AST_MAX_USER_FIELD, ast_rtp_instance_get_quality(), AST_RTP_INSTANCE_STAT_FIELD_QUALITY, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_MES, AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT, ast_channel::bridge, pbx_builtin_setvar_helper(), and quality.

Referenced by chan_pjsip_session_end(), and hangup().

◆ ast_rtp_instance_set_stream_num()

void ast_rtp_instance_set_stream_num ( struct ast_rtp_instance instance,
int  stream_num 
)

Set the stream number for an RTP instance.

Since
15.0.0
Parameters
instanceThe RTP instance
stream_numThe stream identifier number

Definition at line 4079 of file rtp_engine.c.

4080{
4081 ao2_lock(rtp);
4082 if (rtp->engine->set_stream_num) {
4083 rtp->engine->set_stream_num(rtp, stream_num);
4084 }
4085 ao2_unlock(rtp);
4086}

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, and ast_rtp_engine::set_stream_num.

Referenced by apply_negotiated_sdp_stream().

◆ ast_rtp_instance_set_timeout()

void ast_rtp_instance_set_timeout ( struct ast_rtp_instance instance,
int  timeout 
)

Set the RTP timeout value.

Parameters
instanceThe RTP instance
timeoutValue to set the timeout to

Example usage:

void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout)
Set the RTP timeout value.
Definition: rtp_engine.c:2886

This sets the RTP timeout value on 'instance' to be 5000.

Since
1.8

Definition at line 2886 of file rtp_engine.c.

2887{
2888 instance->timeout = timeout;
2889}

References ast_rtp_instance::timeout.

Referenced by apply_negotiated_sdp_stream(), and configure_local_rtp().

◆ ast_rtp_instance_set_write_format()

int ast_rtp_instance_set_write_format ( struct ast_rtp_instance instance,
struct ast_format format 
)

Tell underlying RTP engine that audio frames will be provided in a specific format.

Parameters
instanceThe RTP instance to change write format on
formatFormat that frames will be provided in
Return values
0success
-1failure

Example usage:

struct ast_format tmp_fmt;
int ast_rtp_instance_set_write_format(struct ast_rtp_instance *instance, struct ast_format *format)
Tell underlying RTP engine that audio frames will be provided in a specific format.
Definition: rtp_engine.c:2790

This tells the underlying RTP engine that audio frames will be provided to it in ULAW format.

Since
1.8

Definition at line 2790 of file rtp_engine.c.

2791{
2792 int res;
2793
2794 if (instance->engine->set_read_format) {
2795 ao2_lock(instance);
2796 res = instance->engine->set_write_format(instance, format);
2797 ao2_unlock(instance);
2798 } else {
2799 res = -1;
2800 }
2801 return res;
2802}
int(* set_write_format)(struct ast_rtp_instance *instance, struct ast_format *format)
Definition: rtp_engine.h:718

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, ast_rtp_engine::set_read_format, and ast_rtp_engine::set_write_format.

◆ ast_rtp_instance_stop()

void ast_rtp_instance_stop ( struct ast_rtp_instance instance)

Stop an RTP instance.

Parameters
instanceInstance that media is no longer going to at this time

Example usage:

void ast_rtp_instance_stop(struct ast_rtp_instance *instance)
Stop an RTP instance.
Definition: rtp_engine.c:2375

This tells the RTP engine being used for the instance pointed to by instance that media is no longer going to it at this time, but may in the future.

Since
1.8

Definition at line 2375 of file rtp_engine.c.

2376{
2377 if (instance->engine->stop) {
2378 ao2_lock(instance);
2379 instance->engine->stop(instance);
2380 ao2_unlock(instance);
2381 }
2382}
void(* stop)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:677

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, and ast_rtp_engine::stop.

Referenced by apply_negotiated_sdp_stream(), close_rtp_connection(), jingle_session_destructor(), ooh323_destroy(), stream_stop(), and unistim_hangup_clean().

◆ ast_rtp_instance_stun_request()

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.

Parameters
instanceThe RTP instance
suggestionThe suggested destination
usernameOptionally a username for the request

Example usage:

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:2877

This requests that the RTP engine send a STUN BIND request on the session pointed to by 'instance'.

Since
1.8

Definition at line 2877 of file rtp_engine.c.

2880{
2881 if (instance->engine->stun_request) {
2882 instance->engine->stun_request(instance, suggestion, username);
2883 }
2884}
void(* stun_request)(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username)
Definition: rtp_engine.h:726

References ast_rtp_instance::engine, and ast_rtp_engine::stun_request.

Referenced by jingle_interpret_google_transport().

◆ ast_rtp_instance_update_source()

void ast_rtp_instance_update_source ( struct ast_rtp_instance instance)

Indicate that the RTP marker bit should be set on an RTP stream.

Parameters
instanceInstance that the new media source is feeding into

Example usage:

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:2343

This indicates that the source of media that is feeding the instance pointed to by instance has been updated and that the marker bit should be set.

Since
1.8

Definition at line 2343 of file rtp_engine.c.

2344{
2345 if (instance->engine->update_source) {
2346 ao2_lock(instance);
2347 instance->engine->update_source(instance);
2348 ao2_unlock(instance);
2349 }
2350}
void(* update_source)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:684

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, and ast_rtp_engine::update_source.

Referenced by jingle_indicate(), and ooh323_indicate().

◆ ast_rtp_instance_write()

int ast_rtp_instance_write ( struct ast_rtp_instance instance,
struct ast_frame frame 
)

Send a frame out over RTP.

Parameters
instanceThe RTP instance to send frame out on
framethe frame to send out
Return values
0success
-1failure

Example usage:

ast_rtp_instance_write(instance, frame);
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
Definition: rtp_engine.c:596

This gives the frame pointed to by frame to the RTP engine being used for the instance and asks that it be transmitted to the current remote address set on the RTP instance.

Since
1.8

Definition at line 596 of file rtp_engine.c.

597{
598 int res;
599
600 ao2_lock(instance);
601 res = instance->engine->write(instance, frame);
602 ao2_unlock(instance);
603 return res;
604}

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, and ast_rtp_engine::write.

Referenced by AST_TEST_DEFINE(), chan_pjsip_indicate(), jingle_write(), media_session_rtp_write_callback(), ooh323_write(), rtp_write(), test_write_and_read_interleaved_frames(), test_write_frames(), and unistim_write().

◆ ast_rtp_lookup_mime_multiple2()

char * ast_rtp_lookup_mime_multiple2 ( struct ast_str buf,
struct ast_format_cap ast_format_capability,
int  rtp_capability,
const int  asterisk_format,
enum ast_rtp_options  options 
)

Convert formats into a string and put them into a buffer.

Parameters
bufBuffer to put the mime output into
ast_format_capabilityAsterisk Formats we are looking up.
rtp_capabilityRTP codes that we are looking up
asterisk_formatNon-zero if the ast_format_capability structure is to be used, 0 if rtp_capability is to be used
optionsAdditional options that may change the result
Return values
non-NULLsuccess
NULLfailure

Example usage:

char buf[256] = "";
struct ast_format tmp_fmt;
struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
char *mime = ast_rtp_lookup_mime_multiple2(&buf, sizeof(buf), cap, 0, 1, 0);
ast_format_cap_destroy(cap);
char * ast_rtp_lookup_mime_multiple2(struct ast_str *buf, struct ast_format_cap *ast_format_capability, int rtp_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:2237

This returns the mime values for ULAW and ALAW in the buffer pointed to by buf.

Since
1.8

Definition at line 2237 of file rtp_engine.c.

2238{
2239 int found = 0;
2240 const char *name;
2241 if (!buf) {
2242 return NULL;
2243 }
2244
2245
2246 if (asterisk_format) {
2247 int x;
2248 struct ast_format *tmp_fmt;
2249 for (x = 0; x < ast_format_cap_count(ast_format_capability); x++) {
2250 tmp_fmt = ast_format_cap_get_format(ast_format_capability, x);
2251 name = ast_rtp_lookup_mime_subtype2(asterisk_format, tmp_fmt, 0, options);
2252 ao2_ref(tmp_fmt, -1);
2253 ast_str_append(&buf, 0, "%s|", name);
2254 found = 1;
2255 }
2256 } else {
2257 int x;
2258 ast_str_append(&buf, 0, "0x%x (", (unsigned int) rtp_capability);
2259 for (x = 1; x <= AST_RTP_MAX; x <<= 1) {
2260 if (rtp_capability & x) {
2261 name = ast_rtp_lookup_mime_subtype2(asterisk_format, NULL, x, options);
2262 ast_str_append(&buf, 0, "%s|", name);
2263 found = 1;
2264 }
2265 }
2266 }
2267
2268 ast_str_append(&buf, 0, "%s", found ? ")" : "nothing)");
2269
2270 return ast_str_buffer(buf);
2271}
const char * ast_rtp_lookup_mime_subtype2(const int asterisk_format, const struct ast_format *format, int code, enum ast_rtp_options options)
Retrieve mime subtype information on a payload.
Definition: rtp_engine.c:2184
#define AST_RTP_MAX
Definition: rtp_engine.h:300
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1139
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761

References ao2_ref, ast_format_cap_count(), ast_format_cap_get_format(), ast_rtp_lookup_mime_subtype2(), AST_RTP_MAX, ast_str_append(), ast_str_buffer(), ast_rtp_payload_type::asterisk_format, buf, name, NULL, and options.

◆ ast_rtp_lookup_mime_subtype2()

const char * ast_rtp_lookup_mime_subtype2 ( const int  asterisk_format,
const struct ast_format format,
int  code,
enum ast_rtp_options  options 
)

Retrieve mime subtype information on a payload.

Parameters
asterisk_formatNon-zero to look up using Asterisk format
formatAsterisk format to look up
codeRTP code to look up
optionsAdditional options that may change the result
Returns
Mime subtype success
Return values
NULLfailure

Example usage:

const char *subtype = ast_rtp_lookup_mime_subtype2(1, ast_format_ulaw, 0, 0);
const char * ast_rtp_lookup_mime_subtype2(const int asterisk_format, const struct ast_format *format, int code, enum ast_rtp_options options)
Retrieve mime subtype information on a payload.
Definition: rtp_engine.c:2184

This looks up the mime subtype for the ULAW format.

Since
1.8

Definition at line 2184 of file rtp_engine.c.

2186{
2187 int i;
2188 const char *res = "";
2189
2191 for (i = 0; i < mime_types_len; i++) {
2192 if (ast_rtp_mime_types[i].payload_type.asterisk_format && asterisk_format && format &&
2193 (ast_format_cmp(format, ast_rtp_mime_types[i].payload_type.format) != AST_FORMAT_CMP_NOT_EQUAL)) {
2196 res = "G726-32";
2197 break;
2198 } else {
2199 res = ast_rtp_mime_types[i].subtype;
2200 break;
2201 }
2202 } else if (!ast_rtp_mime_types[i].payload_type.asterisk_format && !asterisk_format &&
2204
2205 res = ast_rtp_mime_types[i].subtype;
2206 break;
2207 }
2208 }
2210
2211 return res;
2212}
@ AST_FORMAT_CMP_NOT_EQUAL
Definition: format.h:38

References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_FORMAT_CMP_NOT_EQUAL, ast_format_g726_aal2, ast_rtp_mime_types, AST_RTP_OPT_G726_NONSTANDARD, ast_rwlock_rdlock, ast_rwlock_unlock, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::format, mime_types_len, mime_types_lock, options, ast_rtp_mime_type::payload_type, ast_rtp_payload_type::rtp_code, and ast_rtp_mime_type::subtype.

Referenced by ast_rtp_lookup_mime_multiple2(), generate_rtpmap_attr(), generate_rtpmap_attr2(), and jingle_add_payloads_to_description().

◆ ast_rtp_lookup_sample_rate2()

unsigned int ast_rtp_lookup_sample_rate2 ( int  asterisk_format,
const struct ast_format format,
int  code 
)

Get the sample rate associated with known RTP payload types.

Parameters
asterisk_formatTrue if the value in format is to be used.
formatAn asterisk format
codefrom AST_RTP list
Returns
the sample rate if the format was found, zero if it was not found
Since
1.8

Definition at line 2214 of file rtp_engine.c.

2216{
2217 unsigned int i;
2218 unsigned int res = 0;
2219
2221 for (i = 0; i < mime_types_len; ++i) {
2222 if (ast_rtp_mime_types[i].payload_type.asterisk_format && asterisk_format && format &&
2223 (ast_format_cmp(format, ast_rtp_mime_types[i].payload_type.format) != AST_FORMAT_CMP_NOT_EQUAL)) {
2225 break;
2226 } else if (!ast_rtp_mime_types[i].payload_type.asterisk_format && !asterisk_format &&
2229 break;
2230 }
2231 }
2233
2234 return res;
2235}

References ast_format_cmp(), AST_FORMAT_CMP_NOT_EQUAL, ast_rtp_mime_types, ast_rwlock_rdlock, ast_rwlock_unlock, ast_rtp_payload_type::asterisk_format, ast_rtp_payload_type::format, mime_types_len, mime_types_lock, ast_rtp_mime_type::payload_type, ast_rtp_payload_type::rtp_code, and ast_rtp_mime_type::sample_rate.

Referenced by create_outgoing_sdp_stream(), generate_rtpmap_attr(), and jingle_add_payloads_to_description().

◆ ast_rtp_payload_mapping_tx_is_present()

int ast_rtp_payload_mapping_tx_is_present ( struct ast_rtp_codecs codecs,
const struct ast_rtp_payload_type to_match 
)

Determine if a type of payload is already present in mappings.

Since
18
Parameters
codecsCodecs to be checked for mappings.
to_matchPayload type object to compare against.
Note
It is assumed that codecs is not locked before calling.
Return values
0not found
1found

Definition at line 1226 of file rtp_engine.c.

1226 {
1227 int ret = 0;
1228 if (codecs && to_match) {
1229 ast_rwlock_rdlock(&codecs->codecs_lock);
1230 ret = payload_mapping_tx_is_present(codecs, to_match);
1231 ast_rwlock_unlock(&codecs->codecs_lock);
1232 }
1233 return ret;
1234}

References ast_rwlock_rdlock, ast_rwlock_unlock, codecs, and payload_mapping_tx_is_present().

Referenced by ast_rtp_dtmf_begin().

◆ ast_rtp_publish_rtcp_message()

void ast_rtp_publish_rtcp_message ( struct ast_rtp_instance rtp,
struct stasis_message_type message_type,
struct ast_rtp_rtcp_report report,
struct ast_json blob 
)

Publish an RTCP message to Stasis Message Bus API.

Since
12
Parameters
rtpThe rtp instance object
message_typeThe RTP message type to publish
reportThe RTCP report object to publish. This should be an ao2 ref counted object. This routine will increase the reference count of the object.
blobAdditional JSON objects to publish along with the RTCP information

Definition at line 3706 of file rtp_engine.c.

3710{
3711 RAII_VAR(struct rtcp_message_payload *, payload, NULL, ao2_cleanup);
3713
3714 if (!message_type) {
3715 return;
3716 }
3717
3718 payload = ao2_alloc(sizeof(*payload), rtcp_message_payload_dtor);
3719 if (!payload || !report) {
3720 return;
3721 }
3722
3723 if (!ast_strlen_zero(rtp->channel_uniqueid)) {
3724 payload->snapshot = ast_channel_snapshot_get_latest(rtp->channel_uniqueid);
3725 }
3726 if (blob) {
3727 payload->blob = blob;
3728 ast_json_ref(blob);
3729 }
3730 ao2_ref(report, +1);
3731 payload->report = report;
3732
3733 message = stasis_message_create(message_type, payload);
3734 if (!message) {
3735 return;
3736 }
3737
3739}
struct ast_channel_snapshot * ast_channel_snapshot_get_latest(const char *uniqueid)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object,...
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Definition: json.c:67
struct stasis_topic * ast_rtp_topic(void)
Stasis Message Bus API topic for RTP and RTCP related messages
Definition: rtp_engine.c:3752
static void rtcp_message_payload_dtor(void *obj)
Definition: rtp_engine.c:3504
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1578
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:978

References ao2_alloc, ao2_cleanup, ao2_ref, ast_channel_snapshot_get_latest(), ast_json_ref(), ast_rtp_topic(), ast_strlen_zero(), ast_rtp_instance::channel_uniqueid, NULL, RAII_VAR, rtcp_message_payload_dtor(), stasis_message_create(), and stasis_publish().

Referenced by ast_rtcp_calculate_sr_rr_statistics(), and ast_rtcp_interpret().

◆ ast_rtp_red_buffer()

int ast_rtp_red_buffer ( struct ast_rtp_instance instance,
struct ast_frame frame 
)

Buffer a frame in an RTP instance for RED.

Parameters
instanceThe instance to buffer the frame on
frameFrame that we want to buffer
Return values
0success
-1failure
Since
1.8

Definition at line 2624 of file rtp_engine.c.

2625{
2626 int res;
2627
2628 if (instance->engine->red_buffer) {
2629 ao2_lock(instance);
2630 res = instance->engine->red_buffer(instance, frame);
2631 ao2_unlock(instance);
2632 } else {
2633 res = -1;
2634 }
2635 return res;
2636}
int(* red_buffer)(struct ast_rtp_instance *instance, struct ast_frame *frame)
Definition: rtp_engine.h:710

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, and ast_rtp_engine::red_buffer.

◆ ast_rtp_red_init()

int ast_rtp_red_init ( struct ast_rtp_instance instance,
int  buffer_time,
int *  payloads,
int  generations 
)

Initialize RED support on an RTP instance.

Parameters
instanceThe instance to initialize RED support on
buffer_timeHow long to buffer before sending
payloadsPayload values
generationsNumber of generations
Return values
0success
-1failure
Since
1.8

Definition at line 2610 of file rtp_engine.c.

2611{
2612 int res;
2613
2614 if (instance->engine->red_init) {
2615 ao2_lock(instance);
2616 res = instance->engine->red_init(instance, buffer_time, payloads, generations);
2617 ao2_unlock(instance);
2618 } else {
2619 res = -1;
2620 }
2621 return res;
2622}
int(* red_init)(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations)
Definition: rtp_engine.h:708

References ao2_lock, ao2_unlock, ast_rtp_instance::engine, and ast_rtp_engine::red_init.

◆ ast_rtp_rtcp_report_alloc()

struct ast_rtp_rtcp_report * ast_rtp_rtcp_report_alloc ( unsigned int  report_blocks)

Allocate an ao2 ref counted instance of ast_rtp_rtcp_report.

Parameters
report_blocksThe number of report blocks to allocate
Returns
An ao2 ref counted ast_rtp_rtcp_report object on success
Return values
NULLon error

Definition at line 3695 of file rtp_engine.c.

3696{
3697 struct ast_rtp_rtcp_report *rtcp_report;
3698
3699 /* Size of object is sizeof the report + the number of report_blocks * sizeof pointer */
3700 rtcp_report = ao2_alloc((sizeof(*rtcp_report) + report_blocks * sizeof(struct ast_rtp_rtcp_report_block *)),
3702
3703 return rtcp_report;
3704}
static void rtp_rtcp_report_dtor(void *obj)
Definition: rtp_engine.c:3685
A report block within a SR/RR report.
Definition: rtp_engine.h:346
An object that represents data sent during a SR/RR RTCP report.
Definition: rtp_engine.h:361

References ao2_alloc, and rtp_rtcp_report_dtor().

Referenced by ast_rtcp_interpret(), ast_rtcp_write(), ast_rtp_read(), rtp_write_rtcp_fir(), and rtp_write_rtcp_psfb().

◆ ast_rtp_topic()

struct stasis_topic * ast_rtp_topic ( void  )

Stasis Message Bus API topic for RTP and RTCP related messages

Since
12
Returns
A Stasis Message Bus API topic

Definition at line 3752 of file rtp_engine.c.

3753{
3754 return rtp_topic;
3755}
static struct stasis_topic * rtp_topic
Stasis Message Bus API topic for RTP related messages
Definition: rtp_engine.c:283

References rtp_topic.

Referenced by ast_rtp_publish_rtcp_message(), load_module(), and manager_subscriptions_init().