Asterisk - The Open Source Telephony Project  18.5.0
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_engine_test
 Structure that represents the test functionality for res_rtp_asterisk unit tests. 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_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_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   { .codecs_lock = AST_RWLOCK_INIT_VALUE, .payload_mapping_rx = { 0, }, .payload_mapping_tx = { 0, }, .framing = 0, }
 
#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 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
}
 
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 }
 
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...
 
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_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...
 
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...
 
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...
 
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...
 
void ast_rtp_instance_drop_packets (struct ast_rtp_instance *instance, int num)
 Set the number of packets to drop on RTP read. 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)
 
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...
 
size_t ast_rtp_instance_get_recv_buffer_count (struct ast_rtp_instance *instance)
 Get the current size of the receive buffer. More...
 
size_t ast_rtp_instance_get_recv_buffer_max (struct ast_rtp_instance *instance)
 Get the maximum size of the receive buffer. 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...
 
int ast_rtp_instance_get_sdes_received (struct ast_rtp_instance *instance)
 Get the value of sdes_received on the test engine. More...
 
size_t ast_rtp_instance_get_send_buffer_count (struct ast_rtp_instance *instance)
 Get the current size of the send buffer. 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...
 
struct ast_rtp_engine_testast_rtp_instance_get_test (struct ast_rtp_instance *instance)
 Obtain a pointer to the test callbacks on an RTP instance. 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...
 
void ast_rtp_instance_queue_report (struct ast_rtp_instance *instance)
 Sends a SR/RR report the next time RTP would be sent. More...
 
struct ast_frameast_rtp_instance_read (struct ast_rtp_instance *instance, int rtcp)
 Receive a frame over RTP. More...
 
void ast_rtp_instance_reset_test_engine (struct ast_rtp_instance *instance)
 Resets all the fields to default values for the test engine. 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_schedid (struct ast_rtp_instance *instance, int id)
 Set the schedid for RTCP. 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...
 
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_RED_MAX_GENERATION

#define AST_RED_MAX_GENERATION   5

Maximum number of generations

Definition at line 98 of file rtp_engine.h.

Referenced by process_sdp_a_text().

◆ AST_RTP_CISCO_DTMF

#define AST_RTP_CISCO_DTMF   (1 << 2)

DTMF (Cisco Proprietary)

Definition at line 270 of file rtp_engine.h.

Referenced by ast_rtp_engine_init(), and ast_rtp_interpret().

◆ AST_RTP_CN

#define AST_RTP_CN   (1 << 1)

'Comfort Noise' (RFC3389)

Definition at line 268 of file rtp_engine.h.

Referenced by ast_rtp_engine_init(), ast_rtp_interpret(), and ast_rtp_sendcng().

◆ AST_RTP_CODECS_NULL_INIT

#define AST_RTP_CODECS_NULL_INIT   { .codecs_lock = AST_RWLOCK_INIT_VALUE, .payload_mapping_rx = { 0, }, .payload_mapping_tx = { 0, }, .framing = 0, }

Definition at line 716 of file rtp_engine.h.

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

◆ AST_RTP_DTMF

#define AST_RTP_DTMF   (1 << 0)

◆ ast_rtp_engine_register

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

Definition at line 794 of file rtp_engine.h.

Referenced by AST_TEST_DEFINE(), and load_module().

◆ ast_rtp_glue_register

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

Definition at line 847 of file rtp_engine.h.

Referenced by load_module().

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

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 1228 of file rtp_engine.h.

Referenced by check_for_rtp_changes(), ooh323_set_rtp_peer(), and sip_set_rtp_peer().

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

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 1192 of file rtp_engine.h.

Referenced by __rtp_recvfrom(), add_sdp(), ast_rtcp_write(), ast_rtp_bundle(), ast_rtp_dtmf_begin(), ast_rtp_dtmf_continuation(), ast_rtp_dtmf_end_with_duration(), ast_rtp_prop_set(), ast_rtp_read(), ast_rtp_rtcp_handle_nack(), ast_rtp_sendcng(), ast_rtp_write(), bridge_p2p_rtp_write(), channel_read_rtp(), create_dtmf_frame(), find_rtp_port(), jingle_interpret_ice_udp_transport(), multicast_send_control_packet(), ooh323_get_rtp_peer(), process_cn_rfc3389(), process_dtmf_rfc2833(), process_sdp(), rtp_raw_write(), send_start_rtp(), sip_acf_channel_read(), skinny_set_rtp_peer(), transmit_modify_with_sdp(), and unistim_set_rtp_peer().

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

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 1080 of file rtp_engine.h.

Referenced by __rtp_recvfrom(), apply_negotiated_sdp_stream(), ast_rtp_bundle(), ast_rtp_ice_start_media(), ast_rtp_read(), ast_rtp_remote_address_set(), ast_rtp_stop(), AST_TEST_DEFINE(), handle_open_receive_channel_ack_message(), jingle_interpret_ice_udp_transport(), multicast_rtp_request(), process_sdp(), setup_rtp_connection(), setup_rtp_remote(), start_rtp(), test_init_rtp_instances(), and unicast_rtp_request().

◆ AST_RTP_MAX

#define AST_RTP_MAX   AST_RTP_CISCO_DTMF

Maximum RTP-specific code

Definition at line 272 of file rtp_engine.h.

Referenced by add_sdp(), ast_rtp_lookup_mime_multiple2(), and create_outgoing_sdp_stream().

◆ AST_RTP_MAX_PT

#define AST_RTP_MAX_PT   128

◆ AST_RTP_PT_FIRST_DYNAMIC

#define AST_RTP_PT_FIRST_DYNAMIC   96

◆ 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.

Referenced by find_unused_payload(), and handle_show_settings().

◆ AST_RTP_PT_LAST_STATIC

#define AST_RTP_PT_LAST_STATIC   34

◆ AST_RTP_RTCP_FMT_FIR

#define AST_RTP_RTCP_FMT_FIR   4

Full INTRA-frame Request (From RFC5104)

Definition at line 307 of file rtp_engine.h.

Referenced by ast_rtcp_interpret().

◆ AST_RTP_RTCP_FMT_NACK

#define AST_RTP_RTCP_FMT_NACK   1

Generic NACK (From RFC4585 also RFC5104)

Definition at line 303 of file rtp_engine.h.

Referenced by ast_rtcp_generate_nack(), ast_rtcp_interpret(), and rtcp_payload_subtype2str().

◆ AST_RTP_RTCP_FMT_PLI

#define AST_RTP_RTCP_FMT_PLI   1

Picture loss indication (From RFC4585)

Definition at line 305 of file rtp_engine.h.

Referenced by ast_rtcp_interpret().

◆ AST_RTP_RTCP_FMT_REMB

#define AST_RTP_RTCP_FMT_REMB   15

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

Definition at line 309 of file rtp_engine.h.

Referenced by ast_rtcp_interpret(), AST_TEST_DEFINE(), remb_collector_alloc(), remb_hook_event_cb(), rtcp_payload_subtype2str(), rtp_write_rtcp_psfb(), and softmix_bridge_write_rtcp().

◆ 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 311 of file rtp_engine.h.

Referenced by rtp_transport_wide_cc_feedback_produce().

◆ AST_RTP_RTCP_PSFB

#define AST_RTP_RTCP_PSFB   206

Payload Specific Feed Back (From RFC4585 also RFC5104)

Definition at line 299 of file rtp_engine.h.

Referenced by ast_rtp_write(), AST_TEST_DEFINE(), chan_pjsip_write_stream(), remb_collector_alloc(), remb_hook_event_cb(), and softmix_bridge_write_rtcp().

◆ AST_RTP_RTCP_RR

#define AST_RTP_RTCP_RR   201

Receiver Report

Definition at line 295 of file rtp_engine.h.

Referenced by AST_TEST_DEFINE(), and lintospeex_feedback().

◆ AST_RTP_RTCP_RTPFB

#define AST_RTP_RTCP_RTPFB   205

Transport Layer Feed Back (From RFC4585 also RFC5104)

Definition at line 297 of file rtp_engine.h.

Referenced by ast_rtcp_generate_nack(), ast_rtcp_interpret(), rtcp_payload_subtype2str(), and rtp_transport_wide_cc_feedback_produce().

◆ AST_RTP_RTCP_SR

#define AST_RTP_RTCP_SR   200

Sender Report

Definition at line 293 of file rtp_engine.h.

Referenced by AST_TEST_DEFINE(), hook_event_cb(), lintospeex_feedback(), rtcp_report_to_ami(), and rtcp_report_to_json().

◆ AST_RTP_STAT_SET

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

Definition at line 433 of file rtp_engine.h.

Referenced by ast_rtp_get_stat().

◆ AST_RTP_STAT_STRCPY

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

Definition at line 441 of file rtp_engine.h.

Referenced by ast_rtp_get_stat().

◆ AST_RTP_STAT_TERMINATOR

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

Definition at line 449 of file rtp_engine.h.

Referenced by ast_rtp_get_stat().

◆ 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.

Definition at line 107 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 521 of file rtp_engine.h.

521  {
522  AST_RTP_DTLS_CONNECTION_NEW, /*!< Endpoint wants to use a new connection */
523  AST_RTP_DTLS_CONNECTION_EXISTING, /*!< Endpoint wishes to use existing connection */
524 };

◆ 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 527 of file rtp_engine.h.

527  {
528  AST_RTP_DTLS_HASH_SHA256, /*!< SHA-256 fingerprint hash */
529  AST_RTP_DTLS_HASH_SHA1, /*!< SHA-1 fingerprint hash */
530 };

◆ 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 513 of file rtp_engine.h.

513  {
514  AST_RTP_DTLS_SETUP_ACTIVE, /*!< Endpoint is willing to inititate connections */
515  AST_RTP_DTLS_SETUP_PASSIVE, /*!< Endpoint is willing to accept connections */
516  AST_RTP_DTLS_SETUP_ACTPASS, /*!< Endpoint is willing to both accept and initiate connections */
517  AST_RTP_DTLS_SETUP_HOLDCONN, /*!< Endpoint does not want the connection to be established right now */
518 };

◆ 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 533 of file rtp_engine.h.

533  {
534  AST_RTP_DTLS_VERIFY_NONE = 0, /*!< Don't verify anything */
535  AST_RTP_DTLS_VERIFY_FINGERPRINT = (1 << 0), /*!< Verify the fingerprint */
536  AST_RTP_DTLS_VERIFY_CERTIFICATE = (1 << 1), /*!< Verify the certificate */
537 };

◆ 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 148 of file rtp_engine.h.

148  {
149  /*! No DTMF is being carried over the RTP stream */
151  /*! DTMF is being carried out of band using RFC2833 */
153  /*! DTMF is being carried inband over the RTP stream */
155 };

◆ 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 542 of file rtp_engine.h.

542  {
543  /*! Per the RFC 0 should not be used, so we treat it as an unsupported extension placeholder */
545  /*! abs-send-time from https://tools.ietf.org/html/draft-alvestrand-rmcat-remb-03 */
547  /*! transport-cc from https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01 */
549  /*! The maximum number of known RTP extensions */
551 };

◆ 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 769 of file rtp_engine.h.

769  {
770  /*! The extension is not negotiated and is not flowing */
772  /*! Send and receive */
774  /*! Send only */
776  /*! Receive only */
778  /*! Negotiated but not sending or receiving */
780 };

◆ 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 158 of file rtp_engine.h.

158  {
159  /*! No remote or local bridging is permitted */
161  /*! Move RTP stream to be remote between devices directly */
163  /*! Perform RTP engine level bridging if possible */
165 };

◆ 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 455 of file rtp_engine.h.

455  {
456  AST_RTP_ICE_CANDIDATE_TYPE_HOST, /*!< ICE host candidate. A host candidate represents the actual local transport address in the host. */
457  AST_RTP_ICE_CANDIDATE_TYPE_SRFLX, /*!< ICE server reflexive candidate, which represents the public mapped address of the local address. */
458  AST_RTP_ICE_CANDIDATE_TYPE_RELAYED, /*!< ICE relayed candidate, which represents the address allocated in TURN server. */
459 };

◆ ast_rtp_ice_component_type

ICE component types.

Enumerator
AST_RTP_ICE_COMPONENT_RTP 
AST_RTP_ICE_COMPONENT_RTCP 

Definition at line 462 of file rtp_engine.h.

◆ ast_rtp_ice_role

ICE role during negotiation.

Enumerator
AST_RTP_ICE_ROLE_CONTROLLED 
AST_RTP_ICE_ROLE_CONTROLLING 

Definition at line 468 of file rtp_engine.h.

◆ 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 255 of file rtp_engine.h.

255  {
256  /*! RTCP should not be sent/received */
258  /*! RTCP should be sent/received based on standard port rules */
260  /*! RTCP should be sent/received on the same port as RTP */
262 };

◆ 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

Definition at line 180 of file rtp_engine.h.

180  {
181  /*! Retrieve all statistics */
183  /*! Retrieve number of packets transmitted */
185  /*! Retrieve number of packets received */
187  /*! Retrieve ALL statistics relating to packet loss */
189  /*! Retrieve number of packets lost for transmitting */
191  /*! Retrieve number of packets lost for receiving */
193  /*! Retrieve maximum number of packets lost on remote side */
195  /*! Retrieve minimum number of packets lost on remote side */
197  /*! Retrieve average number of packets lost on remote side */
199  /*! Retrieve standard deviation of packets lost on remote side */
201  /*! Retrieve maximum number of packets lost on local side */
203  /*! Retrieve minimum number of packets lost on local side */
205  /*! Retrieve average number of packets lost on local side */
207  /*! Retrieve standard deviation of packets lost on local side */
209  /*! Retrieve ALL statistics relating to jitter */
211  /*! Retrieve jitter on transmitted packets */
213  /*! Retrieve jitter on received packets */
215  /*! Retrieve maximum jitter on remote side */
217  /*! Retrieve minimum jitter on remote side */
219  /*! Retrieve average jitter on remote side */
221  /*! Retrieve standard deviation jitter on remote side */
223  /*! Retrieve maximum jitter on local side */
225  /*! Retrieve minimum jitter on local side */
227  /*! Retrieve average jitter on local side */
229  /*! Retrieve standard deviation jitter on local side */
231  /*! Retrieve ALL statistics relating to round trip time */
233  /*! Retrieve round trip time */
235  /*! Retrieve maximum round trip time */
237  /*! Retrieve minimum round trip time */
239  /*! Retrieve average round trip time */
241  /*! Retrieve standard deviation round trip time */
243  /*! Retrieve local SSRC */
245  /*! Retrieve remote SSRC */
247  /*! Retrieve channel unique ID */
249  /*! Retrieve number of octets transmitted */
251  /*! Retrieve number of octets received */
253 };

◆ 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

Definition at line 168 of file rtp_engine.h.

168  {
169  /*! Retrieve quality information */
171  /*! Retrieve quality information about jitter */
173  /*! Retrieve quality information about packet loss */
175  /*! Retrieve quality information about round trip time */
177 };

◆ ast_rtp_options

Additional RTP options

Enumerator
AST_RTP_OPT_G726_NONSTANDARD 

Remote side is using non-standard G.726

Definition at line 142 of file rtp_engine.h.

142  {
143  /*! Remote side is using non-standard G.726 */
144  AST_RTP_OPT_G726_NONSTANDARD = (1 << 0),
145 };

◆ 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 113 of file rtp_engine.h.

113  {
114  /*! Enable symmetric RTP support */
116  /*! RTP instance will be carrying DTMF (using RFC2833) */
118  /*! Expect unreliable DTMF from remote party */
120  /*! Enable STUN support */
122  /*! Enable RTCP support */
124  /*! Enable Asymmetric RTP Codecs */
126  /*! Enable packet retransmission for received packets */
128  /*! Enable packet retransmission for sent packets */
130  /*! Enable REMB sending and receiving passthrough support */
132 
133  /*!
134  * \brief Maximum number of RTP properties supported
135  *
136  * \note THIS MUST BE THE LAST ENTRY IN THIS ENUM.
137  */
139 };
Maximum number of RTP properties supported.
Definition: rtp_engine.h:138

Function Documentation

◆ 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
Return values
Numericalpayload type or -1 if unable to find payload in codecs

Example usage:

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

Definition at line 1975 of file rtp_engine.c.

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

Referenced by bridge_p2p_rtp_write().

1976 {
1977  struct ast_rtp_payload_type *type;
1978  int res = -1;
1979 
1980  ast_rwlock_rdlock(&codecs->codecs_lock);
1981  if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
1982  type = AST_VECTOR_GET(&codecs->payload_mapping_tx, payload);
1983  if (type) {
1984  res = payload;
1985  }
1986  }
1987  ast_rwlock_unlock(&codecs->codecs_lock);
1988 
1989  return res;
1990 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_rwlock_rdlock(a)
Definition: lock.h:233
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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
Return values
Theframing to be used for the media stream associated with these codecs
Since
13.0.0

Definition at line 1569 of file rtp_engine.c.

References ast_rwlock_rdlock, ast_rwlock_unlock, ast_rtp_codecs::codecs_lock, and ast_rtp_codecs::framing.

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

1570 {
1571  unsigned int framing;
1572 
1573  ast_rwlock_rdlock(&codecs->codecs_lock);
1574  framing = codecs->framing;
1575  ast_rwlock_unlock(&codecs->codecs_lock);
1576 
1577  return framing;
1578 }
#define ast_rwlock_rdlock(a)
Definition: lock.h:233
unsigned int framing
Definition: rtp_engine.h:713
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232

◆ 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
Return values
Payloadinformation.
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);

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

Definition at line 1479 of file rtp_engine.c.

References ao2_bump, AST_RTP_MAX_PT, AST_RTP_PT_LAST_STATIC, ast_rwlock_rdlock, ast_rwlock_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_rtp_codecs::codecs_lock, NULL, and type.

Referenced by ast_rtp_interpret(), and bridge_p2p_rtp_write().

1480 {
1481  struct ast_rtp_payload_type *type = NULL;
1482 
1483  if (payload < 0 || payload >= AST_RTP_MAX_PT) {
1484  return NULL;
1485  }
1486 
1487  ast_rwlock_rdlock(&codecs->codecs_lock);
1488  if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_rx)) {
1489  type = AST_VECTOR_GET(&codecs->payload_mapping_rx, payload);
1490  ao2_bump(type);
1491  }
1492  ast_rwlock_unlock(&codecs->codecs_lock);
1493 
1494  if (!type && payload <= AST_RTP_PT_LAST_STATIC) {
1496  type = ao2_bump(static_RTP_PT[payload]);
1498  }
1499 
1500  return type;
1501 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_rwlock_rdlock(a)
Definition: lock.h:233
#define AST_RTP_PT_LAST_STATIC
Definition: rtp_engine.h:89
#define NULL
Definition: resample.c:96
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
#define ao2_bump(obj)
Definition: astobj2.h:491
#define AST_RTP_MAX_PT
Definition: rtp_engine.h:83
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:274
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
static ast_rwlock_t static_RTP_PT_lock
Definition: rtp_engine.c:275
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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
Return values
pointerto format structure on success
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 1537 of file rtp_engine.c.

References ao2_bump, AST_RTP_MAX_PT, ast_rwlock_rdlock, ast_rwlock_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_rtp_payload_type::asterisk_format, ast_rtp_codecs::codecs_lock, format, ast_rtp_payload_type::format, NULL, and type.

Referenced by get_codecs(), process_sdp_a_audio(), and process_sdp_a_video().

1538 {
1539  struct ast_rtp_payload_type *type;
1540  struct ast_format *format = NULL;
1541 
1542  if (payload < 0 || payload >= AST_RTP_MAX_PT) {
1543  return NULL;
1544  }
1545 
1546  ast_rwlock_rdlock(&codecs->codecs_lock);
1547  if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
1548  type = AST_VECTOR_GET(&codecs->payload_mapping_tx, payload);
1549  if (type && type->asterisk_format) {
1550  format = ao2_bump(type->format);
1551  }
1552  }
1553  ast_rwlock_unlock(&codecs->codecs_lock);
1554 
1555  return format;
1556 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_rwlock_rdlock(a)
Definition: lock.h:233
Definition of a media format.
Definition: format.c:43
#define NULL
Definition: resample.c:96
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
#define ao2_bump(obj)
Definition: astobj2.h:491
#define AST_RTP_MAX_PT
Definition: rtp_engine.h:83
struct ast_format * format
Definition: rtp_engine.h:278
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
static snd_pcm_format_t format
Definition: chan_alsa.c:102
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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 1460 of file rtp_engine.c.

References ast_format_get_type(), AST_MEDIA_TYPE_UNKNOWN, ast_rwlock_rdlock, ast_rwlock_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_rtp_payload_type::asterisk_format, ast_rtp_codecs::codecs_lock, ast_rtp_payload_type::format, ast_rtp_payload_type::payload, and type.

Referenced by ast_rtp_read().

1461 {
1462  enum ast_media_type stream_type = AST_MEDIA_TYPE_UNKNOWN;
1463  int payload;
1464  struct ast_rtp_payload_type *type;
1465 
1466  ast_rwlock_rdlock(&codecs->codecs_lock);
1467  for (payload = 0; payload < AST_VECTOR_SIZE(&codecs->payload_mapping_rx); ++payload) {
1468  type = AST_VECTOR_GET(&codecs->payload_mapping_rx, payload);
1469  if (type && type->asterisk_format) {
1470  stream_type = ast_format_get_type(type->format);
1471  break;
1472  }
1473  }
1474  ast_rwlock_unlock(&codecs->codecs_lock);
1475 
1476  return stream_type;
1477 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_rwlock_rdlock(a)
Definition: lock.h:233
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
struct ast_format * format
Definition: rtp_engine.h:278
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
ast_media_type
Types of media.
Definition: codec.h:30
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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.

Return values
Numericalpayload type
-1if could not assign.

Example usage:

int payload = ast_rtp_codecs_payload_code(&codecs, 1, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0), 0);

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

Since
1.8

Definition at line 1873 of file rtp_engine.c.

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, ast_rtp_codecs::codecs_lock, ast_rtp_payload_type::format, ast_rtp_payload_type::payload, ast_rtp_payload_type::primary_mapping, ast_rtp_payload_type::rtp_code, rtp_codecs_assign_payload_code_rx(), and type.

Referenced by add_codec_to_sdp(), add_noncodec_to_sdp(), add_sdp(), add_tcodec_to_sdp(), add_vcodec_to_sdp(), apply_cap_to_bundled(), create_outgoing_sdp_stream(), and jingle_add_payloads_to_description().

1874 {
1875  struct ast_rtp_payload_type *type;
1876  int idx;
1877  int payload = -1;
1878 
1880  if (!asterisk_format) {
1881  ast_rwlock_rdlock(&codecs->codecs_lock);
1882  for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_rx); ++idx) {
1883  type = AST_VECTOR_GET(&codecs->payload_mapping_rx, idx);
1884  if (!type) {
1885  continue;
1886  }
1887 
1888  if (!type->asterisk_format
1889  && type->primary_mapping
1890  && type->rtp_code == code) {
1891  payload = idx;
1892  break;
1893  }
1894  }
1895  ast_rwlock_unlock(&codecs->codecs_lock);
1896  } else if (format) {
1897  ast_rwlock_rdlock(&codecs->codecs_lock);
1898  for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_rx); ++idx) {
1899  type = AST_VECTOR_GET(&codecs->payload_mapping_rx, idx);
1900  if (!type) {
1901  continue;
1902  }
1903 
1904  if (type->asterisk_format
1905  && type->primary_mapping
1906  && ast_format_cmp(format, type->format) == AST_FORMAT_CMP_EQUAL) {
1907  payload = idx;
1908  break;
1909  }
1910  }
1911  ast_rwlock_unlock(&codecs->codecs_lock);
1912  }
1913 
1914  if (payload < 0) {
1915  payload = rtp_codecs_assign_payload_code_rx(codecs, asterisk_format, format,
1916  code, 0);
1917  }
1919 
1920  return payload;
1921 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_rwlock_rdlock(a)
Definition: lock.h:233
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
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
struct ast_format * format
Definition: rtp_engine.h:278
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
static int rtp_codecs_assign_payload_code_rx(struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code, int explicit)
Definition: rtp_engine.c:1815
unsigned int primary_mapping
Definition: rtp_engine.h:286
static ast_rwlock_t static_RTP_PT_lock
Definition: rtp_engine.c:275
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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
Return values
Numericalpayload type
-1if not found.

Definition at line 1928 of file rtp_engine.c.

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, ast_rtp_codecs::codecs_lock, find_static_payload_type(), ast_rtp_payload_type::format, ast_rtp_payload_type::payload, ast_rtp_payload_type::rtp_code, and type.

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

1929 {
1930  struct ast_rtp_payload_type *type;
1931  int idx;
1932  int payload = -1;
1933 
1934  if (!asterisk_format) {
1935  ast_rwlock_rdlock(&codecs->codecs_lock);
1936  for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_tx); ++idx) {
1937  type = AST_VECTOR_GET(&codecs->payload_mapping_tx, idx);
1938  if (!type) {
1939  continue;
1940  }
1941 
1942  if (!type->asterisk_format
1943  && type->rtp_code == code) {
1944  payload = idx;
1945  break;
1946  }
1947  }
1948  ast_rwlock_unlock(&codecs->codecs_lock);
1949  } else if (format) {
1950  ast_rwlock_rdlock(&codecs->codecs_lock);
1951  for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_tx); ++idx) {
1952  type = AST_VECTOR_GET(&codecs->payload_mapping_tx, idx);
1953  if (!type) {
1954  continue;
1955  }
1956 
1957  if (type->asterisk_format
1958  && ast_format_cmp(format, type->format) == AST_FORMAT_CMP_EQUAL) {
1959  payload = idx;
1960  break;
1961  }
1962  }
1963  ast_rwlock_unlock(&codecs->codecs_lock);
1964  }
1965 
1966  if (payload < 0) {
1968  payload = find_static_payload_type(asterisk_format, format, code);
1970  }
1971 
1972  return payload;
1973 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_rwlock_rdlock(a)
Definition: lock.h:233
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
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
static int find_static_payload_type(int asterisk_format, const struct ast_format *format, int code)
Definition: rtp_engine.c:1624
struct ast_format * format
Definition: rtp_engine.h:278
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
static ast_rwlock_t static_RTP_PT_lock
Definition: rtp_engine.c:275
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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);

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 1580 of file rtp_engine.c.

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, ast_rtp_payload_type::asterisk_format, ast_rtp_codecs::codecs_lock, ast_rtp_payload_type::format, ast_rtp_codecs::framing, ast_rtp_payload_type::rtp_code, and type.

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

1581 {
1582  int idx;
1583 
1585  *nonastformats = 0;
1586 
1587  ast_rwlock_rdlock(&codecs->codecs_lock);
1588 
1589  for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_tx); ++idx) {
1590  struct ast_rtp_payload_type *type;
1591 
1592  type = AST_VECTOR_GET(&codecs->payload_mapping_tx, idx);
1593  if (!type) {
1594  continue;
1595  }
1596 
1597  if (type->asterisk_format) {
1598  ast_format_cap_append(astformats, type->format, 0);
1599  } else {
1600  *nonastformats |= type->rtp_code;
1601  }
1602  }
1603  if (codecs->framing) {
1604  ast_format_cap_set_framing(astformats, codecs->framing);
1605  }
1606 
1607  ast_rwlock_unlock(&codecs->codecs_lock);
1608 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_rwlock_rdlock(a)
Definition: lock.h:233
unsigned int framing
Definition: rtp_engine.h:713
void ast_format_cap_set_framing(struct ast_format_cap *cap, unsigned int framing)
Set the global framing.
Definition: format_cap.c:136
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
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:525
struct ast_format * format
Definition: rtp_engine.h:278
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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 1503 of file rtp_engine.c.

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, ast_rtp_payload_type::asterisk_format, ast_rtp_codecs::codecs_lock, format, ast_rtp_payload_type::format, ast_rtp_payload_type::payload, payload_mapping_tx_is_present(), ast_rtp_payload_type::primary_mapping, and type.

Referenced by get_codecs(), process_sdp_a_audio(), and process_sdp_a_video().

1504 {
1505  struct ast_rtp_payload_type *type;
1506 
1507  if (payload < 0 || payload >= AST_RTP_MAX_PT || !format) {
1508  return -1;
1509  }
1510 
1512  if (!type) {
1513  return -1;
1514  }
1515  ao2_ref(format, +1);
1516  type->format = format;
1517  type->asterisk_format = 1;
1518  type->payload = payload;
1519  type->primary_mapping = 1;
1520 
1521  ast_rwlock_wrlock(&codecs->codecs_lock);
1522  if (!payload_mapping_tx_is_present(codecs, type)) {
1523  if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
1524  ao2_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, payload));
1525  }
1526  if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, type)) {
1527  ao2_ref(type, -1);
1528  }
1529  } else {
1530  ao2_ref(type, -1);
1531  }
1532  ast_rwlock_unlock(&codecs->codecs_lock);
1533 
1534  return 0;
1535 }
static const char type[]
Definition: chan_ooh323.c:109
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
#define AST_RTP_MAX_PT
Definition: rtp_engine.h:83
struct ast_rtp_payload_type * ast_rtp_engine_alloc_payload_type(void)
Allocation routine for ast_rtp_payload_type.
Definition: rtp_engine.c:325
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_format * format
Definition: rtp_engine.h:278
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:1144
#define ast_rwlock_wrlock(a)
Definition: lock.h:234
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#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:284
unsigned int primary_mapping
Definition: rtp_engine.h:286
static snd_pcm_format_t format
Definition: chan_alsa.c:102
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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 1923 of file rtp_engine.c.

References rtp_codecs_assign_payload_code_rx().

Referenced by apply_cap_to_bundled(), and create_outgoing_sdp_stream().

1924 {
1925  return rtp_codecs_assign_payload_code_rx(codecs, 1, format, code, 1);
1926 }
static int rtp_codecs_assign_payload_code_rx(struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code, int explicit)
Definition: rtp_engine.c:1815

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

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

Since
1.8

Definition at line 994 of file rtp_engine.c.

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

995 {
998 
999  if (instance && instance->engine && instance->engine->payload_set) {
1000  int i;
1001 
1002  ao2_lock(instance);
1003  for (i = 0; i < AST_RTP_MAX_PT; i++) {
1004  instance->engine->payload_set(instance, i, 0, NULL, 0);
1005  }
1006  ao2_unlock(instance);
1007  }
1008 }
int ast_rtp_codecs_payloads_initialize(struct ast_rtp_codecs *codecs)
Initialize an RTP codecs structure.
Definition: rtp_engine.c:958
void(* payload_set)(struct ast_rtp_instance *instance, int payload, int asterisk_format, struct ast_format *format, int code)
Definition: rtp_engine.h:643
#define ao2_unlock(a)
Definition: astobj2.h:730
#define NULL
Definition: resample.c:96
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:974
#define AST_RTP_MAX_PT
Definition: rtp_engine.h:83
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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);

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

Since
1.8

Definition at line 1224 of file rtp_engine.c.

References 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, rtp_codecs_payloads_copy_rx(), rtp_codecs_payloads_copy_tx(), and type.

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

1225 {
1226  int idx;
1227  struct ast_rtp_payload_type *type;
1228 
1230 
1231  /* Deadlock avoidance because of held write lock. */
1232  while (ast_rwlock_tryrdlock(&src->codecs_lock)) {
1234  sched_yield();
1236  }
1237 
1238  /*
1239  * This represents a completely new mapping of what the remote party is
1240  * expecting for payloads, so we clear out the entire tx payload mapping
1241  * vector and replace it.
1242  */
1243  for (idx = 0; idx < AST_VECTOR_SIZE(&dest->payload_mapping_tx); ++idx) {
1244  type = AST_VECTOR_GET(&dest->payload_mapping_tx, idx);
1245  ao2_t_cleanup(type, "destroying ast_rtp_codec tx mapping");
1246  AST_VECTOR_REPLACE(&dest->payload_mapping_tx, idx, NULL);
1247  }
1248 
1249  rtp_codecs_payloads_copy_rx(src, dest, instance);
1250  rtp_codecs_payloads_copy_tx(src, dest, instance);
1251  dest->framing = src->framing;
1252 
1255 }
static const char type[]
Definition: chan_ooh323.c:109
#define ao2_t_cleanup(obj, tag)
Definition: astobj2.h:1959
unsigned int framing
Definition: rtp_engine.h:713
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:1108
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:1193
#define NULL
Definition: resample.c:96
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
#define ast_rwlock_tryrdlock(a)
Definition: lock.h:235
#define ast_rwlock_wrlock(a)
Definition: lock.h:234
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#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:284
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

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

Since
11

Definition at line 974 of file rtp_engine.c.

References ao2_t_cleanup, ast_rwlock_destroy, AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_rtp_codecs::codecs_lock, and type.

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

975 {
976  int idx;
977  struct ast_rtp_payload_type *type;
978 
979  for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_rx); ++idx) {
980  type = AST_VECTOR_GET(&codecs->payload_mapping_rx, idx);
981  ao2_t_cleanup(type, "destroying ast_rtp_codec rx mapping");
982  }
983  AST_VECTOR_FREE(&codecs->payload_mapping_rx);
984 
985  for (idx = 0; idx < AST_VECTOR_SIZE(&codecs->payload_mapping_tx); ++idx) {
986  type = AST_VECTOR_GET(&codecs->payload_mapping_tx, idx);
987  ao2_t_cleanup(type, "destroying ast_rtp_codec tx mapping");
988  }
989  AST_VECTOR_FREE(&codecs->payload_mapping_tx);
990 
992 }
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:174
static const char type[]
Definition: chan_ooh323.c:109
#define ao2_t_cleanup(obj, tag)
Definition: astobj2.h:1959
#define ast_rwlock_destroy(rwlock)
Definition: lock.h:231
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

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

Since
11

Definition at line 958 of file rtp_engine.c.

References AST_RTP_MAX_PT, ast_rwlock_init, AST_VECTOR_FREE, AST_VECTOR_INIT, ast_rtp_codecs::codecs_lock, and ast_rtp_codecs::framing.

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

959 {
960  int res;
961 
962  codecs->framing = 0;
963  ast_rwlock_init(&codecs->codecs_lock);
964  res = AST_VECTOR_INIT(&codecs->payload_mapping_rx, AST_RTP_MAX_PT);
965  res |= AST_VECTOR_INIT(&codecs->payload_mapping_tx, AST_RTP_MAX_PT);
966  if (res) {
967  AST_VECTOR_FREE(&codecs->payload_mapping_rx);
968  AST_VECTOR_FREE(&codecs->payload_mapping_tx);
969  }
970 
971  return res;
972 }
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:174
unsigned int framing
Definition: rtp_engine.h:713
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define AST_RTP_MAX_PT
Definition: rtp_engine.h:83
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
Definition: lock.h:222

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

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

Since
1.8

Definition at line 1301 of file rtp_engine.c.

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, ast_rtp_payload_type::asterisk_format, ast_rtp_codecs::codecs_lock, ast_rtp_instance::engine, ast_rtp_payload_type::format, 10aedae86a32_add_outgoing_enum_va::new_type, payload_mapping_tx_is_present(), ast_rtp_engine::payload_set, and ast_rtp_payload_type::rtp_code.

Referenced by get_codecs(), and process_sdp().

1302 {
1304 
1305  if (payload < 0 || payload >= AST_RTP_MAX_PT || payload > AST_RTP_PT_LAST_STATIC) {
1306  return;
1307  }
1308 
1310  new_type = ao2_bump(static_RTP_PT[payload]);
1312  if (!new_type) {
1313  ast_debug(1, "Don't have a default tx payload type %d format for m type on %p\n",
1314  payload, codecs);
1315  return;
1316  }
1317 
1318  ast_debug(1, "Setting tx payload type %d based on m type on %p\n",
1319  payload, codecs);
1320 
1321  ast_rwlock_wrlock(&codecs->codecs_lock);
1322 
1323  if (!payload_mapping_tx_is_present(codecs, new_type)) {
1324  if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
1325  ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, payload),
1326  "cleaning up replaced tx payload type");
1327  }
1328 
1329  if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, new_type)) {
1330  ao2_ref(new_type, -1);
1331  } else if (instance && instance->engine && instance->engine->payload_set) {
1332  ao2_lock(instance);
1333  instance->engine->payload_set(instance, payload, new_type->asterisk_format, new_type->format, new_type->rtp_code);
1334  ao2_unlock(instance);
1335  }
1336  } else {
1337  ao2_ref(new_type, -1);
1338  }
1339 
1340  ast_rwlock_unlock(&codecs->codecs_lock);
1341 }
#define ast_rwlock_rdlock(a)
Definition: lock.h:233
void(* payload_set)(struct ast_rtp_instance *instance, int payload, int asterisk_format, struct ast_format *format, int code)
Definition: rtp_engine.h:643
#define ao2_t_cleanup(obj, tag)
Definition: astobj2.h:1959
#define AST_RTP_PT_LAST_STATIC
Definition: rtp_engine.h:89
#define ao2_unlock(a)
Definition: astobj2.h:730
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
#define ao2_bump(obj)
Definition: astobj2.h:491
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define AST_RTP_MAX_PT
Definition: rtp_engine.h:83
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_format * format
Definition: rtp_engine.h:278
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:274
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:1144
#define ast_rwlock_wrlock(a)
Definition: lock.h:234
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#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:284
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191
static ast_rwlock_t static_RTP_PT_lock
Definition: rtp_engine.c:275
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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 strin 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:

ast_rtp_codecs_payloads_set_rtpmap_type(&codecs, NULL, 0, "audio", "PCMU", 0);

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 1428 of file rtp_engine.c.

References ast_rtp_codecs_payloads_set_rtpmap_type_rate().

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

1429 {
1430  return ast_rtp_codecs_payloads_set_rtpmap_type_rate(codecs, instance, payload, mimetype, mimesubtype, options, 0);
1431 }
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:1343
static struct test_options options

◆ 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 1343 of file rtp_engine.c.

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, ast_rtp_codecs::codecs_lock, ast_rtp_instance::engine, ast_rtp_payload_type::format, mime_types_len, 10aedae86a32_add_outgoing_enum_va::new_type, ast_rtp_payload_type::payload, payload_mapping_tx_is_present(), ast_rtp_engine::payload_set, ast_rtp_mime_type::payload_type, ast_rtp_payload_type::primary_mapping, ast_rtp_payload_type::rtp_code, 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(), jingle_interpret_description(), process_sdp_a_audio(), process_sdp_a_text(), and process_sdp_a_video().

1347 {
1348  unsigned int idx;
1349  int found = 0;
1350 
1351  if (pt < 0 || pt >= AST_RTP_MAX_PT) {
1352  return -1; /* bogus payload type */
1353  }
1354 
1356  ast_rwlock_wrlock(&codecs->codecs_lock);
1357 
1358  for (idx = 0; idx < mime_types_len; ++idx) {
1359  const struct ast_rtp_mime_type *t = &ast_rtp_mime_types[idx];
1361 
1362  if (strcasecmp(mimesubtype, t->subtype)) {
1363  continue;
1364  }
1365 
1366  if (strcasecmp(mimetype, t->type)) {
1367  continue;
1368  }
1369 
1370  /* if both sample rates have been supplied, and they don't match,
1371  * then this not a match; if one has not been supplied, then the
1372  * rates are not compared */
1373  if (sample_rate && t->sample_rate &&
1374  (sample_rate != t->sample_rate)) {
1375  continue;
1376  }
1377 
1378  found = 1;
1379 
1380  new_type = ast_rtp_engine_alloc_payload_type();
1381  if (!new_type) {
1382  continue;
1383  }
1384 
1386  new_type->rtp_code = t->payload_type.rtp_code;
1387  new_type->payload = pt;
1388  new_type->primary_mapping = 1;
1392  new_type->format = ast_format_g726_aal2;
1393  } else {
1394  new_type->format = t->payload_type.format;
1395  }
1396 
1397  if (new_type->format) {
1398  /* SDP parsing automatically increases the reference count */
1399  new_type->format = ast_format_parse_sdp_fmtp(new_type->format, "");
1400  }
1401 
1402  if (!payload_mapping_tx_is_present(codecs, new_type)) {
1403  if (pt < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
1404  ao2_t_cleanup(AST_VECTOR_GET(&codecs->payload_mapping_tx, pt),
1405  "cleaning up replaced tx payload type");
1406  }
1407 
1408  if (AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, pt, new_type)) {
1409  ao2_ref(new_type, -1);
1410  } else if (instance && instance->engine && instance->engine->payload_set) {
1411  ao2_lock(instance);
1412  instance->engine->payload_set(instance, pt, new_type->asterisk_format, new_type->format, new_type->rtp_code);
1413  ao2_unlock(instance);
1414  }
1415  } else {
1416  ao2_ref(new_type, -1);
1417  }
1418 
1419  break;
1420  }
1421 
1422  ast_rwlock_unlock(&codecs->codecs_lock);
1424 
1425  return (found ? 0 : -2);
1426 }
struct ast_format * ast_format_g726
Built-in cached g726 format.
Definition: format_cache.c:116
#define ast_rwlock_rdlock(a)
Definition: lock.h:233
char type[16]
The media type.
Definition: rtp_engine.c:255
static int mime_types_len
Definition: rtp_engine.c:262
void(* payload_set)(struct ast_rtp_instance *instance, int payload, int asterisk_format, struct ast_format *format, int code)
Definition: rtp_engine.h:643
#define ao2_t_cleanup(obj, tag)
Definition: astobj2.h:1959
char subtype[64]
The format type.
Definition: rtp_engine.c:257
static ast_rwlock_t mime_types_lock
Definition: rtp_engine.c:261
static struct ast_rtp_mime_type ast_rtp_mime_types[128]
struct ast_format * ast_format_g726_aal2
Built-in cached g726 aal2 format.
Definition: format_cache.c:121
#define ao2_unlock(a)
Definition: astobj2.h:730
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
unsigned int sample_rate
Expected sample rate of the /c subtype.
Definition: rtp_engine.c:259
struct ast_rtp_payload_type payload_type
A mapping object between the Asterisk codec and this RTP payload.
Definition: rtp_engine.c:253
#define AST_RTP_MAX_PT
Definition: rtp_engine.h:83
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
struct ast_rtp_payload_type * ast_rtp_engine_alloc_payload_type(void)
Allocation routine for ast_rtp_payload_type.
Definition: rtp_engine.c:325
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_format * format
Definition: rtp_engine.h:278
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:1144
#define ast_rwlock_wrlock(a)
Definition: lock.h:234
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#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:284
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191
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
static struct test_options options
unsigned int primary_mapping
Definition: rtp_engine.h:286
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

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

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

Since
1.8

Definition at line 1433 of file rtp_engine.c.

References ao2_cleanup, ao2_lock, ao2_unlock, ast_debug, AST_RTP_MAX_PT, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_GET, AST_VECTOR_REPLACE, AST_VECTOR_SIZE, ast_rtp_codecs::codecs_lock, ast_rtp_instance::engine, NULL, ast_rtp_engine::payload_set, and type.

Referenced by process_sdp_a_audio(), and process_sdp_a_video().

1434 {
1435  struct ast_rtp_payload_type *type;
1436 
1437  if (payload < 0 || payload >= AST_RTP_MAX_PT) {
1438  return;
1439  }
1440 
1441  ast_debug(2, "Unsetting payload %d on %p\n", payload, codecs);
1442 
1443  ast_rwlock_wrlock(&codecs->codecs_lock);
1444 
1445  if (payload < AST_VECTOR_SIZE(&codecs->payload_mapping_tx)) {
1446  type = AST_VECTOR_GET(&codecs->payload_mapping_tx, payload);
1447  ao2_cleanup(type);
1448  AST_VECTOR_REPLACE(&codecs->payload_mapping_tx, payload, NULL);
1449  }
1450 
1451  if (instance && instance->engine && instance->engine->payload_set) {
1452  ao2_lock(instance);
1453  instance->engine->payload_set(instance, payload, 0, NULL, 0);
1454  ao2_unlock(instance);
1455  }
1456 
1457  ast_rwlock_unlock(&codecs->codecs_lock);
1458 }
static const char type[]
Definition: chan_ooh323.c:109
void(* payload_set)(struct ast_rtp_instance *instance, int payload, int asterisk_format, struct ast_format *format, int code)
Definition: rtp_engine.h:643
#define ao2_unlock(a)
Definition: astobj2.h:730
#define NULL
Definition: resample.c:96
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define AST_RTP_MAX_PT
Definition: rtp_engine.h:83
#define ao2_lock(a)
Definition: astobj2.h:718
#define ast_rwlock_wrlock(a)
Definition: lock.h:234
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#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:284
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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
Returns
Nothing

Definition at line 1257 of file rtp_engine.c.

References ao2_lock, ao2_unlock, ast_assert, ast_debug, ast_rwlock_tryrdlock, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_GET, AST_VECTOR_SIZE, ast_rtp_payload_type::asterisk_format, ast_rtp_codecs::codecs_lock, ast_rtp_instance::engine, ast_rtp_payload_type::format, ast_rtp_codecs::framing, ast_rtp_engine::payload_set, ast_rtp_payload_type::primary_mapping, ast_rtp_payload_type::rtp_code, rtp_codecs_payload_replace_rx(), and type.

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

1258 {
1259  int idx;
1260  struct ast_rtp_payload_type *type;
1261 
1263  if (src != dest) {
1264  /* Deadlock avoidance because of held write lock. */
1265  while (ast_rwlock_tryrdlock(&src->codecs_lock)) {
1267  sched_yield();
1269  }
1270  }
1271 
1272  /* Crossover copy payload type tx mapping to rx mapping. */
1273  for (idx = 0; idx < AST_VECTOR_SIZE(&src->payload_mapping_tx); ++idx) {
1274  type = AST_VECTOR_GET(&src->payload_mapping_tx, idx);
1275  if (!type) {
1276  continue;
1277  }
1278 
1279  /* All tx mapping elements should have the primary flag set. */
1280  ast_assert(type->primary_mapping);
1281 
1282  ast_debug(2, "Crossover copying tx to rx payload mapping %d (%p) from %p to %p\n",
1283  idx, type, src, dest);
1284  rtp_codecs_payload_replace_rx(dest, idx, type);
1285 
1286  if (instance && instance->engine && instance->engine->payload_set) {
1287  ao2_lock(instance);
1288  instance->engine->payload_set(instance, idx, type->asterisk_format, type->format, type->rtp_code);
1289  ao2_unlock(instance);
1290  }
1291  }
1292 
1293  dest->framing = src->framing;
1294 
1295  if (src != dest) {
1297  }
1299 }
static const char type[]
Definition: chan_ooh323.c:109
void(* payload_set)(struct ast_rtp_instance *instance, int payload, int asterisk_format, struct ast_format *format, int code)
Definition: rtp_engine.h:643
unsigned int framing
Definition: rtp_engine.h:713
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:1079
#define ast_assert(a)
Definition: utils.h:695
#define ao2_unlock(a)
Definition: astobj2.h:730
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
#define ast_rwlock_tryrdlock(a)
Definition: lock.h:235
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_format * format
Definition: rtp_engine.h:278
#define ast_rwlock_wrlock(a)
Definition: lock.h:234
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191
unsigned int primary_mapping
Definition: rtp_engine.h:286
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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 1558 of file rtp_engine.c.

References ast_rwlock_unlock, ast_rwlock_wrlock, ast_rtp_codecs::codecs_lock, and ast_rtp_codecs::framing.

Referenced by add_sdp(), check_peer_ok(), configure_local_rtp(), create_addr_from_peer(), get_codecs(), jingle_enable_video(), jingle_new(), process_sdp(), process_sdp_a_audio(), and start_rtp().

1559 {
1560  if (!framing) {
1561  return;
1562  }
1563 
1564  ast_rwlock_wrlock(&codecs->codecs_lock);
1565  codecs->framing = framing;
1566  ast_rwlock_unlock(&codecs->codecs_lock);
1567 }
unsigned int framing
Definition: rtp_engine.h:713
ast_rwlock_t codecs_lock
Definition: rtp_engine.h:707
#define ast_rwlock_unlock(a)
Definition: lock.h:232
#define ast_rwlock_wrlock(a)
Definition: lock.h:234

◆ 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 3113 of file rtp_engine.c.

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.

Referenced by build_peer(), check_peer_ok(), and create_addr_from_peer().

3114 {
3115  ast_rtp_dtls_cfg_free(dst_cfg); /* Prevent a double-call leaking memory via ast_strdup */
3116 
3117  dst_cfg->enabled = src_cfg->enabled;
3118  dst_cfg->verify = src_cfg->verify;
3119  dst_cfg->rekey = src_cfg->rekey;
3120  dst_cfg->suite = src_cfg->suite;
3121  dst_cfg->hash = src_cfg->hash;
3122  dst_cfg->ephemeral_cert = src_cfg->ephemeral_cert;
3123  dst_cfg->certfile = ast_strdup(src_cfg->certfile);
3124  dst_cfg->pvtfile = ast_strdup(src_cfg->pvtfile);
3125  dst_cfg->cipher = ast_strdup(src_cfg->cipher);
3126  dst_cfg->cafile = ast_strdup(src_cfg->cafile);
3127  dst_cfg->capath = ast_strdup(src_cfg->capath);
3128  dst_cfg->default_setup = src_cfg->default_setup;
3129 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
void ast_rtp_dtls_cfg_free(struct ast_rtp_dtls_cfg *dtls_cfg)
Free contents of a DTLS configuration structure.
Definition: rtp_engine.c:3131
enum ast_rtp_dtls_hash hash
Definition: rtp_engine.h:559
unsigned int enabled
Definition: rtp_engine.h:555
enum ast_rtp_dtls_setup default_setup
Definition: rtp_engine.h:557
enum ast_rtp_dtls_verify verify
Definition: rtp_engine.h:560
unsigned int ephemeral_cert
Definition: rtp_engine.h:566
enum ast_srtp_suite suite
Definition: rtp_engine.h:558
unsigned int rekey
Definition: rtp_engine.h:556

◆ 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 3131 of file rtp_engine.c.

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(), build_peer(), media_configuration_destroy(), reload_config(), sip_destroy_peer(), sip_pvt_dtor(), and unload_module().

3132 {
3133  ast_free(dtls_cfg->certfile);
3134  dtls_cfg->certfile = NULL;
3135  ast_free(dtls_cfg->pvtfile);
3136  dtls_cfg->pvtfile = NULL;
3137  ast_free(dtls_cfg->cipher);
3138  dtls_cfg->cipher = NULL;
3139  ast_free(dtls_cfg->cafile);
3140  dtls_cfg->cafile = NULL;
3141  ast_free(dtls_cfg->capath);
3142  dtls_cfg->capath = NULL;
3143 }
#define NULL
Definition: resample.c:96
#define ast_free(a)
Definition: astmm.h:182

◆ 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 3020 of file rtp_engine.c.

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, ast_rtp_dtls_cfg::pvtfile, ast_rtp_dtls_cfg::rekey, and ast_rtp_dtls_cfg::verify.

Referenced by build_peer(), dtls_handler(), media_encryption_handler(), and reload_config().

3021 {
3022  if (!strcasecmp(name, "dtlsenable")) {
3023  dtls_cfg->enabled = ast_true(value) ? 1 : 0;
3024  } else if (!strcasecmp(name, "dtlsverify")) {
3025  if (!strcasecmp(value, "yes")) {
3027  } else if (!strcasecmp(value, "fingerprint")) {
3029  } else if (!strcasecmp(value, "certificate")) {
3031  } else if (!strcasecmp(value, "no")) {
3032  dtls_cfg->verify = AST_RTP_DTLS_VERIFY_NONE;
3033  } else {
3034  return -1;
3035  }
3036  } else if (!strcasecmp(name, "dtlsrekey")) {
3037  if (sscanf(value, "%30u", &dtls_cfg->rekey) != 1) {
3038  return -1;
3039  }
3040  } else if (!strcasecmp(name, "dtlsautogeneratecert")) {
3041  dtls_cfg->ephemeral_cert = ast_true(value) ? 1 : 0;
3042  } else if (!strcasecmp(name, "dtlscertfile")) {
3044  ast_log(LOG_ERROR, "%s file %s does not exist or is not readable\n", name, value);
3045  return -1;
3046  }
3047  ast_free(dtls_cfg->certfile);
3048  dtls_cfg->certfile = ast_strdup(value);
3049  } else if (!strcasecmp(name, "dtlsprivatekey")) {
3051  ast_log(LOG_ERROR, "%s file %s does not exist or is not readable\n", name, value);
3052  return -1;
3053  }
3054  ast_free(dtls_cfg->pvtfile);
3055  dtls_cfg->pvtfile = ast_strdup(value);
3056  } else if (!strcasecmp(name, "dtlscipher")) {
3057  ast_free(dtls_cfg->cipher);
3058  dtls_cfg->cipher = ast_strdup(value);
3059  } else if (!strcasecmp(name, "dtlscafile")) {
3061  ast_log(LOG_ERROR, "%s file %s does not exist or is not readable\n", name, value);
3062  return -1;
3063  }
3064  ast_free(dtls_cfg->cafile);
3065  dtls_cfg->cafile = ast_strdup(value);
3066  } else if (!strcasecmp(name, "dtlscapath") || !strcasecmp(name, "dtlscadir")) {
3068  ast_log(LOG_ERROR, "%s file %s does not exist or is not readable\n", name, value);
3069  return -1;
3070  }
3071  ast_free(dtls_cfg->capath);
3072  dtls_cfg->capath = ast_strdup(value);
3073  } else if (!strcasecmp(name, "dtlssetup")) {
3074  if (!strcasecmp(value, "active")) {
3076  } else if (!strcasecmp(value, "passive")) {
3078  } else if (!strcasecmp(value, "actpass")) {
3080  }
3081  } else if (!strcasecmp(name, "dtlsfingerprint")) {
3082  if (!strcasecmp(value, "sha-256")) {
3083  dtls_cfg->hash = AST_RTP_DTLS_HASH_SHA256;
3084  } else if (!strcasecmp(value, "sha-1")) {
3085  dtls_cfg->hash = AST_RTP_DTLS_HASH_SHA1;
3086  }
3087  } else {
3088  return -1;
3089  }
3090 
3091  return 0;
3092 }
int ast_file_is_readable(const char *filename)
Test that a file exists and is readable by the effective user.
Definition: main/utils.c:2855
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
int value
Definition: syslog.c:37
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
enum ast_rtp_dtls_hash hash
Definition: rtp_engine.h:559
unsigned int enabled
Definition: rtp_engine.h:555
enum ast_rtp_dtls_setup default_setup
Definition: rtp_engine.h:557
#define LOG_ERROR
Definition: logger.h:285
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1951
enum ast_rtp_dtls_verify verify
Definition: rtp_engine.h:560
static const char name[]
Definition: cdr_mysql.c:74
#define ast_free(a)
Definition: astmm.h:182
unsigned int ephemeral_cert
Definition: rtp_engine.h:566
unsigned int rekey
Definition: rtp_engine.h:556

◆ 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 3094 of file rtp_engine.c.

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 build_peer(), reload_config(), and sip_endpoint_apply_handler().

3095 {
3096  if (dtls_cfg->ephemeral_cert) {
3097  if (!ast_strlen_zero(dtls_cfg->certfile)) {
3098  ast_log(LOG_ERROR, "You cannot request automatically generated certificates"
3099  " (dtls_auto_generate_cert) and also specify a certificate file"
3100  " (dtls_cert_file) at the same time\n");
3101  return -1;
3102  } else if (!ast_strlen_zero(dtls_cfg->pvtfile)
3103  || !ast_strlen_zero(dtls_cfg->cafile)
3104  || !ast_strlen_zero(dtls_cfg->capath)) {
3105  ast_log(LOG_NOTICE, "dtls_pvt_file, dtls_cafile, and dtls_ca_path are"
3106  " ignored when dtls_auto_generate_cert is enabled\n");
3107  }
3108  }
3109 
3110  return 0;
3111 }
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
Definition: logger.h:285
#define LOG_NOTICE
Definition: logger.h:263
unsigned int ephemeral_cert
Definition: rtp_engine.h:566

◆ 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
Anao2 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 325 of file rtp_engine.c.

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().

326 {
327  return rtp_payload_type_alloc(NULL, 0, 0, 0);
328 }
#define NULL
Definition: resample.c:96
static struct ast_rtp_payload_type * rtp_payload_type_alloc(struct ast_format *format, int payload, int rtp_code, int primary_mapping)
Definition: rtp_engine.c:306

◆ 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 3229 of file rtp_engine.c.

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, and set_next_mime_type().

Referenced by load_module().

3230 {
3231  char *codec_name = ast_strdupa(ast_format_get_codec_name(format));
3232 
3233  codec_name = ast_str_to_upper(codec_name);
3234 
3235  set_next_mime_type(format,
3236  0,
3238  codec_name,
3239  ast_format_get_sample_rate(format));
3240  add_static_payload(-1, format, 0);
3241 
3242  return 0;
3243 }
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354
const char * ast_format_get_codec_name(const struct ast_format *format)
Get the codec name associated with a format.
Definition: format.c:339
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:347
static void add_static_payload(int payload, struct ast_format *format, int rtp_code)
Definition: rtp_engine.c:3183
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static force_inline char * ast_str_to_upper(char *str)
Convert a string to all upper-case.
Definition: strings.h:1289
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:3155
unsigned int ast_format_get_sample_rate(const struct ast_format *format)
Get the sample rate of a media format.
Definition: format.c:379

◆ 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);

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 330 of file rtp_engine.c.

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.

331 {
332  struct ast_rtp_engine *current_engine;
333 
334  /* Perform a sanity check on the engine structure to make sure it has the basics */
335  if (ast_strlen_zero(engine->name) || !engine->new || !engine->destroy || !engine->write || !engine->read) {
336  ast_log(LOG_WARNING, "RTP Engine '%s' failed sanity check so it was not registered.\n", !ast_strlen_zero(engine->name) ? engine->name : "Unknown");
337  return -1;
338  }
339 
340  /* Link owner module to the RTP engine for reference counting purposes */
341  engine->mod = module;
342 
344 
345  /* Ensure that no two modules with the same name are registered at the same time */
346  AST_RWLIST_TRAVERSE(&engines, current_engine, entry) {
347  if (!strcmp(current_engine->name, engine->name)) {
348  ast_log(LOG_WARNING, "An RTP engine with the name '%s' has already been registered.\n", engine->name);
350  return -1;
351  }
352  }
353 
354  /* The engine survived our critique. Off to the list it goes to be used */
356 
358 
359  ast_verb(2, "Registered RTP engine '%s'\n", engine->name);
360 
361  return 0;
362 }
int(* write)(struct ast_rtp_instance *instance, struct ast_frame *frame)
Definition: rtp_engine.h:624
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
struct ast_frame *(* read)(struct ast_rtp_instance *instance, int rtcp)
Definition: rtp_engine.h:661
#define LOG_WARNING
Definition: logger.h:274
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define ast_verb(level,...)
Definition: logger.h:463
#define ast_strlen_zero(foo)
Definition: strings.h:52
int(* destroy)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:622
#define ast_log
Definition: astobj2.c:42
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
int(* new)(struct ast_rtp_instance *instance, struct ast_sched_context *sched, struct ast_sockaddr *sa, void *data)
Definition: rtp_engine.h:620
struct ast_module * mod
Definition: rtp_engine.h:618
const char * name
Definition: rtp_engine.h:616
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:740
Definition: search.h:40

◆ 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 2710 of file rtp_engine.c.

References policy_res, and srtp_res.

Referenced by res_srtp_init().

2711 {
2712  if (res_srtp || res_srtp_policy) {
2713  return -1;
2714  }
2715  if (!srtp_res || !policy_res) {
2716  return -1;
2717  }
2718 
2719  res_srtp = srtp_res;
2721 
2722  return 0;
2723 }
static struct ast_srtp_res srtp_res
Definition: res_srtp.c:102
struct ast_srtp_res * res_srtp
Definition: rtp_engine.c:177
static struct ast_srtp_policy_res policy_res
Definition: res_srtp.c:114
struct ast_srtp_policy_res * res_srtp_policy
Definition: rtp_engine.c:178

◆ ast_rtp_engine_srtp_is_registered()

int ast_rtp_engine_srtp_is_registered ( void  )

Definition at line 2731 of file rtp_engine.c.

References res_srtp_policy.

Referenced by ast_sdp_srtp_alloc(), and dialog_initialize_dtls_srtp().

2732 {
2733  return res_srtp && res_srtp_policy;
2734 }
struct ast_srtp_res * res_srtp
Definition: rtp_engine.c:177
struct ast_srtp_policy_res * res_srtp_policy
Definition: rtp_engine.c:178

◆ 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 3245 of file rtp_engine.c.

References ao2_ref, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_RTP_MAX_PT, ast_rtp_mime_types, ast_rwlock_unlock, ast_rwlock_wrlock, mime_types_len, NULL, and rtp_engine_mime_type_cleanup().

Referenced by unload_module().

3246 {
3247  int x;
3248  int y = 0;
3249 
3251  /* remove everything pertaining to this format id from the lists */
3252  for (x = 0; x < AST_RTP_MAX_PT; x++) {
3253  if (static_RTP_PT[x]
3254  && ast_format_cmp(static_RTP_PT[x]->format, format) == AST_FORMAT_CMP_EQUAL) {
3255  ao2_ref(static_RTP_PT[x], -1);
3256  static_RTP_PT[x] = NULL;
3257  }
3258  }
3260 
3262  /* rebuild the list skipping the items matching this id */
3263  for (x = 0; x < mime_types_len; x++) {
3264  if (ast_format_cmp(ast_rtp_mime_types[x].payload_type.format, format) == AST_FORMAT_CMP_EQUAL) {
3266  continue;
3267  }
3268  if (x != y) {
3270  }
3271  y++;
3272  }
3273  mime_types_len = y;
3275  return 0;
3276 }
static int mime_types_len
Definition: rtp_engine.c:262
static ast_rwlock_t mime_types_lock
Definition: rtp_engine.c:261
static struct ast_rtp_mime_type ast_rtp_mime_types[128]
#define NULL
Definition: resample.c:96
#define ast_rwlock_unlock(a)
Definition: lock.h:232
#define AST_RTP_MAX_PT
Definition: rtp_engine.h:83
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
#define ao2_ref(o, delta)
Definition: astobj2.h:464
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:274
#define ast_rwlock_wrlock(a)
Definition: lock.h:234
static void rtp_engine_mime_type_cleanup(int i)
Definition: rtp_engine.c:3149
static ast_rwlock_t static_RTP_PT_lock
Definition: rtp_engine.c:275

◆ 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);

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 364 of file rtp_engine.c.

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

Referenced by AST_TEST_DEFINE(), load_module(), and unload_module().

365 {
366  struct ast_rtp_engine *current_engine = NULL;
367 
369 
370  if ((current_engine = AST_RWLIST_REMOVE(&engines, engine, entry))) {
371  ast_verb(2, "Unregistered RTP engine '%s'\n", engine->name);
372  }
373 
375 
376  return current_engine ? 0 : -1;
377 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:463
const char * name
Definition: rtp_engine.h:616
#define AST_RWLIST_REMOVE
Definition: linkedlists.h:884
Definition: search.h:40

◆ ast_rtp_engine_unregister_srtp()

void ast_rtp_engine_unregister_srtp ( void  )

Definition at line 2725 of file rtp_engine.c.

References NULL.

Referenced by res_srtp_shutdown().

2726 {
2727  res_srtp = NULL;
2729 }
#define NULL
Definition: resample.c:96
struct ast_srtp_res * res_srtp
Definition: rtp_engine.c:177
struct ast_srtp_policy_res * res_srtp_policy
Definition: rtp_engine.c:178

◆ 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);

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 379 of file rtp_engine.c.

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.

380 {
381  struct ast_rtp_glue *current_glue = NULL;
382 
383  if (ast_strlen_zero(glue->type)) {
384  return -1;
385  }
386 
387  glue->mod = module;
388 
390 
391  AST_RWLIST_TRAVERSE(&glues, current_glue, entry) {
392  if (!strcasecmp(current_glue->type, glue->type)) {
393  ast_log(LOG_WARNING, "RTP glue with the name '%s' has already been registered.\n", glue->type);
395  return -1;
396  }
397  }
398 
400 
402 
403  ast_verb(2, "Registered RTP glue '%s'\n", glue->type);
404 
405  return 0;
406 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define LOG_WARNING
Definition: logger.h:274
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:463
const char * type
Definition: rtp_engine.h:722
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
struct ast_module * mod
Definition: rtp_engine.h:724
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:740
Definition: search.h:40

◆ 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);

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 408 of file rtp_engine.c.

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().

409 {
410  struct ast_rtp_glue *current_glue = NULL;
411 
413 
414  if ((current_glue = AST_RWLIST_REMOVE(&glues, glue, entry))) {
415  ast_verb(2, "Unregistered RTP glue '%s'\n", glue->type);
416  }
417 
419 
420  return current_glue ? 0 : -1;
421 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:463
const char * type
Definition: rtp_engine.h:722
#define AST_RWLIST_REMOVE
Definition: linkedlists.h:884
Definition: search.h:40

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

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

Since
1.8

Definition at line 2647 of file rtp_engine.c.

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

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

2648 {
2649  int res;
2650 
2651  if (instance->engine->activate) {
2652  ao2_lock(instance);
2653  res = instance->engine->activate(instance);
2654  ao2_unlock(instance);
2655  } else {
2656  res = 0;
2657  }
2658  return res;
2659 }
int(* activate)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:673
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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 2736 of file rtp_engine.c.

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

Referenced by crypto_activate(), and rtcp_debug_test_addr().

2737 {
2738  int res = 0;
2739  struct ast_srtp **srtp;
2740 
2741  if (!res_srtp) {
2742  return -1;
2743  }
2744 
2745  ao2_lock(instance);
2746 
2747  srtp = rtcp ? &instance->rtcp_srtp : &instance->srtp;
2748 
2749  if (!*srtp) {
2750  res = res_srtp->create(srtp, instance, remote_policy);
2751  } else if (remote_policy) {
2752  res = res_srtp->replace(srtp, instance, remote_policy);
2753  }
2754  if (!res) {
2755  res = res_srtp->add_stream(*srtp, local_policy);
2756  }
2757 
2758  ao2_unlock(instance);
2759 
2760  return res;
2761 }
#define ao2_unlock(a)
Definition: astobj2.h:730
int(* add_stream)(struct ast_srtp *srtp, struct ast_srtp_policy *policy)
Definition: res_srtp.h:42
struct ast_srtp_res * res_srtp
Definition: rtp_engine.c:177
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_srtp * srtp
Definition: rtp_engine.c:215
struct ast_srtp * rtcp_srtp
Definition: rtp_engine.c:217
int(* replace)(struct ast_srtp **srtp, struct ast_rtp_instance *rtp, struct ast_srtp_policy *policy)
Definition: res_srtp.h:38
int(* create)(struct ast_srtp **srtp, struct ast_rtp_instance *rtp, struct ast_srtp_policy *policy)
Definition: res_srtp.h:36

◆ 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);

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 2633 of file rtp_engine.c.

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

Referenced by sip_call().

2634 {
2635  if (instance->engine->available_formats) {
2636  ao2_lock(instance);
2637  instance->engine->available_formats(instance, to_endpoint, to_asterisk, result);
2638  ao2_unlock(instance);
2639  if (ast_format_cap_count(result)) {
2640  return;
2641  }
2642  }
2643 
2644  ast_translate_available_formats(to_endpoint, to_asterisk, result);
2645 }
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
#define ao2_unlock(a)
Definition: astobj2.h:730
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:1571
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:677
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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 3804 of file rtp_engine.c.

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().

3805 {
3806  int res = -1;
3807 
3808  if (parent && (child->engine != parent->engine)) {
3809  return -1;
3810  }
3811 
3812  ao2_lock(child);
3813  if (child->engine->bundle) {
3814  res = child->engine->bundle(child, parent);
3815  }
3816  ao2_unlock(child);
3817 
3818  return res;
3819 }
int(* bundle)(struct ast_rtp_instance *child, struct ast_rtp_instance *parent)
Definition: rtp_engine.h:685
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

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

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 2160 of file rtp_engine.c.

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

Referenced by create_outgoing_sdp_stream(), jingle_indicate(), mgcp_indicate(), ooh323_indicate(), sip_indicate(), skinny_indicate(), and unistim_indicate().

2161 {
2162  if (instance->engine->change_source) {
2163  ao2_lock(instance);
2164  instance->engine->change_source(instance);
2165  ao2_unlock(instance);
2166  }
2167 }
void(* change_source)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:635
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

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

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 458 of file rtp_engine.c.

References ao2_cleanup.

Referenced by AST_TEST_DEFINE(), destroy_endpoint(), destroy_rtp(), dialog_clean_rtp(), jingle_session_destructor(), mgcp_hangup(), multicast_rtp_request(), ooh323_destroy(), rtp_hangup(), sip_new(), start_rtp(), stream_destroy(), unalloc_sub(), unicast_rtp_request(), and unistim_hangup_clean().

459 {
460  ao2_cleanup(instance);
461 
462  return 0;
463 }
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

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

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 2081 of file rtp_engine.c.

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

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

2082 {
2083  int res;
2084 
2085  if (instance->engine->dtmf_begin) {
2086  ao2_lock(instance);
2087  res = instance->engine->dtmf_begin(instance, digit);
2088  ao2_unlock(instance);
2089  } else {
2090  res = -1;
2091  }
2092  return res;
2093 }
char digit
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
int(* dtmf_begin)(struct ast_rtp_instance *instance, char digit)
Definition: rtp_engine.h:628
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

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

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

Since
1.8

Definition at line 2095 of file rtp_engine.c.

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

Referenced by mgcp_senddigit_end(), and ooh323_digit_end().

2096 {
2097  int res;
2098 
2099  if (instance->engine->dtmf_end) {
2100  ao2_lock(instance);
2101  res = instance->engine->dtmf_end(instance, digit);
2102  ao2_unlock(instance);
2103  } else {
2104  res = -1;
2105  }
2106  return res;
2107 }
char digit
int(* dtmf_end)(struct ast_rtp_instance *instance, char digit)
Definition: rtp_engine.h:630
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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 2109 of file rtp_engine.c.

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

Referenced by chan_pjsip_digit_end(), jingle_digit_end(), and sip_senddigit_end().

2110 {
2111  int res;
2112 
2113  if (instance->engine->dtmf_end_with_duration) {
2114  ao2_lock(instance);
2115  res = instance->engine->dtmf_end_with_duration(instance, digit, duration);
2116  ao2_unlock(instance);
2117  } else {
2118  res = -1;
2119  }
2120  return res;
2121 }
char digit
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191
int(* dtmf_end_with_duration)(struct ast_rtp_instance *instance, char digit, unsigned int duration)
Definition: rtp_engine.h:631

◆ 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
Return values
DTMFmode

Example usage:

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

Since
1.8

Definition at line 2137 of file rtp_engine.c.

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().

2138 {
2139  int res;
2140 
2141  if (instance->engine->dtmf_mode_get) {
2142  ao2_lock(instance);
2143  res = instance->engine->dtmf_mode_get(instance);
2144  ao2_unlock(instance);
2145  } else {
2146  res = 0;
2147  }
2148  return res;
2149 }
enum ast_rtp_dtmf_mode(* dtmf_mode_get)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:649
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

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

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

Since
1.8

Definition at line 2123 of file rtp_engine.c.

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

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

2124 {
2125  int res;
2126 
2127  if (instance->engine->dtmf_mode_set) {
2128  ao2_lock(instance);
2129  res = instance->engine->dtmf_mode_set(instance, dtmf_mode);
2130  ao2_unlock(instance);
2131  } else {
2132  res = -1;
2133  }
2134  return res;
2135 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
int(* dtmf_mode_set)(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
Definition: rtp_engine.h:647
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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 2337 of file rtp_engine.c.

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.

2338 {
2339  struct ast_rtp_instance *instance0 = NULL, *instance1 = NULL,
2340  *vinstance0 = NULL, *vinstance1 = NULL,
2341  *tinstance0 = NULL, *tinstance1 = NULL;
2342  struct ast_rtp_glue *glue0, *glue1;
2343  enum ast_rtp_glue_result audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID, video_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
2344  enum ast_rtp_glue_result audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID, video_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
2347 
2348  /* If there is no second channel just immediately bail out, we are of no use in that scenario */
2349  if (!c1 || !cap1 || !cap0) {
2350  ao2_cleanup(cap0);
2351  ao2_cleanup(cap1);
2352  return -1;
2353  }
2354 
2355  /* Lock both channels so we can look for the glue that binds them together */
2356  ast_channel_lock_both(c0, c1);
2357 
2358  /* Grab glue that binds each channel to something using the RTP engine */
2360  ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", glue0 ? ast_channel_name(c1) : ast_channel_name(c0));
2361  goto done;
2362  }
2363 
2364  audio_glue0_res = glue0->get_rtp_info(c0, &instance0);
2365  video_glue0_res = glue0->get_vrtp_info ? glue0->get_vrtp_info(c0, &vinstance0) : AST_RTP_GLUE_RESULT_FORBID;
2366 
2367  audio_glue1_res = glue1->get_rtp_info(c1, &instance1);
2368  video_glue1_res = glue1->get_vrtp_info ? glue1->get_vrtp_info(c1, &vinstance1) : AST_RTP_GLUE_RESULT_FORBID;
2369 
2370  /* If we are carrying video, and both sides are not going to remotely bridge... fail the native bridge */
2371  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)) {
2372  audio_glue0_res = AST_RTP_GLUE_RESULT_FORBID;
2373  }
2374  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)) {
2375  audio_glue1_res = AST_RTP_GLUE_RESULT_FORBID;
2376  }
2377  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) {
2378  glue0->get_codec(c0, cap0);
2379  }
2380  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) {
2381  glue1->get_codec(c1, cap1);
2382  }
2383 
2384  /* If any sort of bridge is forbidden just completely bail out and go back to generic bridging */
2385  if (audio_glue0_res != AST_RTP_GLUE_RESULT_REMOTE || audio_glue1_res != AST_RTP_GLUE_RESULT_REMOTE) {
2386  goto done;
2387  }
2388 
2389  /* Make sure we have matching codecs */
2390  if (!ast_format_cap_iscompatible(cap0, cap1)) {
2391  goto done;
2392  }
2393 
2394  /* Bridge media early */
2395  if (glue0->update_peer(c0, instance1, vinstance1, tinstance1, cap1, 0)) {
2396  ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n", ast_channel_name(c0), c1 ? ast_channel_name(c1) : "<unspecified>");
2397  }
2398 
2399 done:
2400  ast_channel_unlock(c0);
2401  ast_channel_unlock(c1);
2402 
2403  ao2_cleanup(cap0);
2404  ao2_cleanup(cap1);
2405 
2406  unref_instance_cond(&instance0);
2407  unref_instance_cond(&instance1);
2408  unref_instance_cond(&vinstance0);
2409  unref_instance_cond(&vinstance1);
2410  unref_instance_cond(&tinstance0);
2411  unref_instance_cond(&tinstance1);
2412 
2413  ast_debug(1, "Setting early bridge SDP of '%s' with that of '%s'\n", ast_channel_name(c0), c1 ? ast_channel_name(c1) : "<unspecified>");
2414 
2415  return 0;
2416 }
static const char type[]
Definition: chan_ooh323.c:109
static void unref_instance_cond(struct ast_rtp_instance **instance)
Conditionally unref an rtp instance.
Definition: rtp_engine.c:2226
#define LOG_WARNING
Definition: logger.h:274
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:756
#define NULL
Definition: resample.c:96
int done
Definition: test_amihooks.c:48
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
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:729
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:2206
ast_rtp_glue_result
Definition: rtp_engine.h:158
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:761
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2952
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
const char * ast_channel_name(const struct ast_channel *chan)
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:741
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
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:655

◆ 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 2251 of file rtp_engine.c.

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().

2252 {
2253  struct ast_rtp_instance *instance_dst = NULL, *instance_src = NULL,
2254  *vinstance_dst = NULL, *vinstance_src = NULL,
2255  *tinstance_dst = NULL, *tinstance_src = NULL;
2256  struct ast_rtp_glue *glue_dst, *glue_src;
2257  enum ast_rtp_glue_result audio_glue_dst_res = AST_RTP_GLUE_RESULT_FORBID, video_glue_dst_res = AST_RTP_GLUE_RESULT_FORBID;
2258  enum ast_rtp_glue_result audio_glue_src_res = AST_RTP_GLUE_RESULT_FORBID, video_glue_src_res = AST_RTP_GLUE_RESULT_FORBID;
2261 
2262  /* Lock both channels so we can look for the glue that binds them together */
2263  ast_channel_lock_both(c_dst, c_src);
2264 
2265  if (!cap_src || !cap_dst) {
2266  goto done;
2267  }
2268 
2269  /* Grab glue that binds each channel to something using the RTP engine */
2270  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))) {
2271  ast_debug(1, "Can't find native functions for channel '%s'\n", glue_dst ? ast_channel_name(c_src) : ast_channel_name(c_dst));
2272  goto done;
2273  }
2274 
2275  audio_glue_dst_res = glue_dst->get_rtp_info(c_dst, &instance_dst);
2276  video_glue_dst_res = glue_dst->get_vrtp_info ? glue_dst->get_vrtp_info(c_dst, &vinstance_dst) : AST_RTP_GLUE_RESULT_FORBID;
2277 
2278  audio_glue_src_res = glue_src->get_rtp_info(c_src, &instance_src);
2279  video_glue_src_res = glue_src->get_vrtp_info ? glue_src->get_vrtp_info(c_src, &vinstance_src) : AST_RTP_GLUE_RESULT_FORBID;
2280 
2281  /* If we are carrying video, and both sides are not going to remotely bridge... fail the native bridge */
2282  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)) {
2283  audio_glue_dst_res = AST_RTP_GLUE_RESULT_FORBID;
2284  }
2285  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)) {
2286  audio_glue_src_res = AST_RTP_GLUE_RESULT_FORBID;
2287  }
2288  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) {
2289  glue_dst->get_codec(c_dst, cap_dst);
2290  }
2291  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) {
2292  glue_src->get_codec(c_src, cap_src);
2293  }
2294 
2295  /* If any sort of bridge is forbidden just completely bail out and go back to generic bridging */
2296  if (audio_glue_dst_res != AST_RTP_GLUE_RESULT_REMOTE || audio_glue_src_res != AST_RTP_GLUE_RESULT_REMOTE) {
2297  goto done;
2298  }
2299 
2300  /* Make sure we have matching codecs */
2301  if (!ast_format_cap_iscompatible(cap_dst, cap_src)) {
2302  goto done;
2303  }
2304 
2305  ast_rtp_codecs_payloads_xover(&instance_src->codecs, &instance_dst->codecs, instance_dst);
2306 
2307  if (vinstance_dst && vinstance_src) {
2308  ast_rtp_codecs_payloads_xover(&vinstance_src->codecs, &vinstance_dst->codecs, vinstance_dst);
2309  }
2310  if (tinstance_dst && tinstance_src) {
2311  ast_rtp_codecs_payloads_xover(&tinstance_src->codecs, &tinstance_dst->codecs, tinstance_dst);
2312  }
2313 
2314  if (glue_dst->update_peer(c_dst, instance_src, vinstance_src, tinstance_src, cap_src, 0)) {
2315  ast_log(LOG_WARNING, "Channel '%s' failed to setup early bridge to '%s'\n",
2316  ast_channel_name(c_dst), ast_channel_name(c_src));
2317  } else {
2318  ast_debug(1, "Seeded SDP of '%s' with that of '%s'\n",
2319  ast_channel_name(c_dst), ast_channel_name(c_src));
2320  }
2321 
2322 done:
2323  ast_channel_unlock(c_dst);
2324  ast_channel_unlock(c_src);
2325 
2326  ao2_cleanup(cap_dst);
2327  ao2_cleanup(cap_src);
2328 
2329  unref_instance_cond(&instance_dst);
2330  unref_instance_cond(&instance_src);
2331  unref_instance_cond(&vinstance_dst);
2332  unref_instance_cond(&vinstance_src);
2333  unref_instance_cond(&tinstance_dst);
2334  unref_instance_cond(&tinstance_src);
2335 }
static const char type[]
Definition: chan_ooh323.c:109
static void unref_instance_cond(struct ast_rtp_instance **instance)
Conditionally unref an rtp instance.
Definition: rtp_engine.c:2226
#define LOG_WARNING
Definition: logger.h:274
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:756
#define NULL
Definition: resample.c:96
int done
Definition: test_amihooks.c:48
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
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:729
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:2206
ast_rtp_glue_result
Definition: rtp_engine.h:158
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:761
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
#define ast_channel_unlock(chan)
Definition: channel.h:2946
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2952
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
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:1257
const char * ast_channel_name(const struct ast_channel *chan)
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:741
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
struct ast_rtp_codecs codecs
Definition: rtp_engine.c:205
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:655

◆ 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 862 of file rtp_engine.c.

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

Referenced by process_extmap_attributes().

863 {
864  static const struct rtp_extmap extmap_none = {
867  };
868  int idx;
869 
870  ao2_lock(instance);
871 
872  /* Clear both the known unique ids and the negotiated extensions as we are about to have
873  * new results set on us.
874  */
875  for (idx = 0; idx < AST_VECTOR_SIZE(&instance->extmap_unique_ids); ++idx) {
876  AST_VECTOR_REPLACE(&instance->extmap_unique_ids, idx, extmap_none);
877  }
878 
879  for (idx = 0; idx < AST_VECTOR_SIZE(&instance->extmap_negotiated); ++idx) {
880  AST_VECTOR_REPLACE(&instance->extmap_negotiated, idx, -1);
881  }
882 
883  ao2_unlock(instance);
884 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
enum ast_rtp_extension extension
Definition: rtp_engine.c:183
#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:284
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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 899 of file rtp_engine.c.

References ao2_lock, ao2_unlock, and AST_VECTOR_SIZE.

Referenced by add_extmap_to_stream(), and enable_rtp_extension().

900 {
901  size_t count;
902 
903  ao2_lock(instance);
904  count = AST_VECTOR_SIZE(&instance->extmap_unique_ids);
905  ao2_unlock(instance);
906 
907  return count;
908 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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 732 of file rtp_engine.c.

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, and ast_rtp_engine::extension_enable.

Referenced by enable_rtp_extension().

734 {
735  struct rtp_extmap extmap = {
736  .extension = extension,
737  .direction = direction,
738  };
739 
740  ao2_lock(instance);
741 
742  if (!instance->engine->extension_enable || !instance->engine->extension_enable(instance, extension)) {
743  ao2_unlock(instance);
744  return 0;
745  }
746 
747  /* We store enabled extensions separately so we can easily do negotiation */
748  if (AST_VECTOR_REPLACE(&instance->extmap_enabled, extension, direction)) {
749  ao2_unlock(instance);
750  return -1;
751  }
752 
753  if (id <= 0) {
754  /* We find a free unique identifier for this extension by just appending it to the
755  * vector of unique ids. The size of the vector will become its unique identifier.
756  * As well when we are asking for information on the extensions it will be returned,
757  * allowing it to be added to the SDP offer.
758  */
759  if (AST_VECTOR_APPEND(&instance->extmap_unique_ids, extmap)) {
761  ao2_unlock(instance);
762  return -1;
763  }
764  id = AST_VECTOR_SIZE(&instance->extmap_unique_ids);
765  } else {
766  /* Otherwise we put it precisely where they want it */
767  if (AST_VECTOR_REPLACE(&instance->extmap_unique_ids, id - 1, extmap)) {
769  ao2_unlock(instance);
770  return -1;
771  }
772  }
773 
774  /* Now that we have an id add the extension to here */
775  if (AST_VECTOR_REPLACE(&instance->extmap_negotiated, extension, id)) {
779  AST_VECTOR_REPLACE(&instance->extmap_unique_ids, id - 1, extmap);
780  ao2_unlock(instance);
781  return -1;
782  }
783 
784  ao2_unlock(instance);
785 
786  return 0;
787 }
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Definition: vector.h:256
#define ao2_unlock(a)
Definition: astobj2.h:730
structure to hold extensions
#define ao2_lock(a)
Definition: astobj2.h:718
enum ast_rtp_extension_direction direction
Definition: rtp_engine.c:185
enum ast_rtp_extension extension
Definition: rtp_engine.c:183
#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:284
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191
direction
int(* extension_enable)(struct ast_rtp_instance *instance, enum ast_rtp_extension extension)
Definition: rtp_engine.h:699
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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
Return values
directionthe direction that has been negotiated
Since
15.5.0

Definition at line 930 of file rtp_engine.c.

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

Referenced by add_extmap_to_stream().

931 {
933 
934  ao2_lock(instance);
935 
936  if (0 < id && id <= AST_VECTOR_SIZE(&instance->extmap_unique_ids)) {
937  struct rtp_extmap *extmap = AST_VECTOR_GET_ADDR(&instance->extmap_unique_ids, id - 1);
938 
939  direction = extmap->direction;
940  }
941  ao2_unlock(instance);
942 
943  return direction;
944 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define AST_VECTOR_GET_ADDR(vec, idx)
Get an address of element in a vector.
Definition: vector.h:670
#define ao2_lock(a)
Definition: astobj2.h:718
enum ast_rtp_extension_direction direction
Definition: rtp_engine.c:185
ast_rtp_extension_direction
Directions for RTP extensions.
Definition: rtp_engine.h:769
direction
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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
Return values
extensionthe 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 910 of file rtp_engine.c.

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

Referenced by add_extmap_to_stream(), and ast_rtp_instance_extmap_get_uri().

911 {
913 
914  ao2_lock(instance);
915 
916  /* The local unique identifier starts at '1' so the highest unique identifier
917  * can be the actual size of the vector. We compensate (as it is 0 index based)
918  * by dropping it down to 1 to get the correct information.
919  */
920  if (0 < id && id <= AST_VECTOR_SIZE(&instance->extmap_unique_ids)) {
921  struct rtp_extmap *extmap = AST_VECTOR_GET_ADDR(&instance->extmap_unique_ids, id - 1);
922 
923  extension = extmap->extension;
924  }
925  ao2_unlock(instance);
926 
927  return extension;
928 }
ast_rtp_extension
Known RTP extensions.
Definition: rtp_engine.h:542
#define ao2_unlock(a)
Definition: astobj2.h:730
#define AST_VECTOR_GET_ADDR(vec, idx)
Get an address of element in a vector.
Definition: vector.h:670
structure to hold extensions
#define ao2_lock(a)
Definition: astobj2.h:718
enum ast_rtp_extension extension
Definition: rtp_engine.c:183
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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 886 of file rtp_engine.c.

References ao2_lock, ao2_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, and id.

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

887 {
888  int id = -1;
889 
890  ao2_lock(instance);
891  if (extension < AST_VECTOR_SIZE(&instance->extmap_negotiated)) {
892  id = AST_VECTOR_GET(&instance->extmap_negotiated, extension);
893  }
894  ao2_unlock(instance);
895 
896  return id;
897 }
#define ao2_unlock(a)
Definition: astobj2.h:730
structure to hold extensions
#define ao2_lock(a)
Definition: astobj2.h:718
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
enum queue_result id
Definition: app_queue.c:1507
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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
Return values
uriThe URI for the RTP extension
Since
15.5.0

Definition at line 946 of file rtp_engine.c.

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().

947 {
949 
950  if (extension == AST_RTP_EXTENSION_UNSUPPORTED ||
951  (unsigned int)extension >= ARRAY_LEN(rtp_extension_uris)) {
952  return NULL;
953  }
954 
956 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
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:910
ast_rtp_extension
Known RTP extensions.
Definition: rtp_engine.h:542
#define NULL
Definition: resample.c:96
structure to hold extensions
enum ast_rtp_extension extension
Definition: rtp_engine.c:183
static const char *const rtp_extension_uris[AST_RTP_EXTENSION_MAX]
URIs for known RTP extensions.
Definition: rtp_engine.c:235

◆ 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 818 of file rtp_engine.c.

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, rtp_extension_uris, and rtp_extmap_negotiate_direction().

Referenced by process_extmap_attributes().

820 {
821  /* 'attributes' is currently unused but exists in the API to ensure it does not need to be altered
822  * in the future in case we need to use it.
823  */
824  int idx;
826 
827  /* Per the RFC the identifier has to be 1 or above */
828  if (id < 1) {
829  return -1;
830  }
831 
832  /* Convert the provided URI to the internal representation */
833  for (idx = 0; idx < ARRAY_LEN(rtp_extension_uris); ++idx) {
834  if (!strcasecmp(rtp_extension_uris[idx], uri)) {
835  extension = idx;
836  break;
837  }
838  }
839 
840  ao2_lock(instance);
841  /* We only accept the extension if it is enabled */
842  if (extension < AST_VECTOR_SIZE(&instance->extmap_enabled) &&
843  AST_VECTOR_GET(&instance->extmap_enabled, extension) != AST_RTP_EXTENSION_DIRECTION_NONE) {
844  struct rtp_extmap extmap = {
845  .extension = extension,
846  .direction = rtp_extmap_negotiate_direction(AST_VECTOR_GET(&instance->extmap_enabled, extension), direction),
847  };
848 
849  /* If the direction negotiation failed then don't accept or use this extension */
851  if (extension != AST_RTP_EXTENSION_UNSUPPORTED) {
852  AST_VECTOR_REPLACE(&instance->extmap_negotiated, extension, id);
853  }
854  AST_VECTOR_REPLACE(&instance->extmap_unique_ids, id - 1, extmap);
855  }
856  }
857  ao2_unlock(instance);
858 
859  return 0;
860 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
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:790
ast_rtp_extension
Known RTP extensions.
Definition: rtp_engine.h:542
#define ao2_unlock(a)
Definition: astobj2.h:730
structure to hold extensions
#define ao2_lock(a)
Definition: astobj2.h:718
enum ast_rtp_extension_direction direction
Definition: rtp_engine.c:185
enum ast_rtp_extension extension
Definition: rtp_engine.c:183
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#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:284
direction
static const char *const rtp_extension_uris[AST_RTP_EXTENSION_MAX]
URIs for known RTP extensions.
Definition: rtp_engine.c:235
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ 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);

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

Since
1.8

Definition at line 2192 of file rtp_engine.c.

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(), configure_rtcp(), jingle_enable_video(), jingle_new(), mgcp_new(), rtp_find_rtcp_fd_position(), sip_new(), sip_set_rtp_peer(), skinny_new(), start_rtp(), transmit_reinvite_with_sdp(), unicast_rtp_request(), and unistim_new().

2193 {
2194  int res;
2195 
2196  if (instance->engine->fd) {
2197  ao2_lock(instance);
2198  res = instance->engine->fd(instance, rtcp);
2199  ao2_unlock(instance);
2200  } else {
2201  res = -1;
2202  }
2203  return res;
2204 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191
int(* fd)(struct ast_rtp_instance *instance, int rtcp)
Definition: rtp_engine.h:655

◆ 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
Return values
pointerto the glue

Example:

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

Since
1.8

Definition at line 2705 of file rtp_engine.c.

References ast_rtp_instance::glue.

2706 {
2707  return instance->glue;
2708 }
struct ast_rtp_glue * glue
Definition: rtp_engine.c:213

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

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 629 of file rtp_engine.c.

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

631 {
632  ao2_lock(instance);
633  if (ast_sockaddr_cmp(address, &instance->local_address) != 0) {
634  ast_sockaddr_copy(address, &instance->local_address);
635  ao2_unlock(instance);
636  return 1;
637  }
638  ao2_unlock(instance);
639 
640  return 0;
641 }
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:171
#define ao2_unlock(a)
Definition: astobj2.h:730
int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares two ast_sockaddr structures.
Definition: netsock2.c:388
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_sockaddr local_address
Definition: rtp_engine.c:197

◆ 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 651 of file rtp_engine.c.

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

653 {
654  ao2_lock(instance);
655  if (ast_sockaddr_cmp(address, &instance->requested_target_address) != 0) {
656  ast_sockaddr_copy(address, &instance->requested_target_address);
657  ao2_unlock(instance);
658  return 1;
659  }
660  ao2_unlock(instance);
661 
662  return 0;
663 }
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:171
#define ao2_unlock(a)
Definition: astobj2.h:730
int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares two ast_sockaddr structures.
Definition: netsock2.c:388
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_sockaddr requested_target_address
Definition: rtp_engine.c:199

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

This gets the RTP instance that instance0 is bridged to.

Since
1.8

Definition at line 2234 of file rtp_engine.c.

References ao2_lock, ao2_unlock, and ast_rtp_instance::bridged.

Referenced by ast_rtp_interpret(), and dialog_needdestroy().

2235 {
2236  struct ast_rtp_instance *bridged;
2237 
2238  ao2_lock(instance);
2239  bridged = instance->bridged;
2240  ao2_unlock(instance);
2241  return bridged;
2242 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_instance * bridged
Definition: rtp_engine.c:203

◆ 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
Return values
Theunique ID of the channel
Emptystring if no channel owns this RTP instance
Since
12

Definition at line 548 of file rtp_engine.c.

References ast_rtp_instance::channel_uniqueid.

Referenced by ast_rtp_get_stat(), rtp_check_timeout(), and rtp_transport_wide_cc_feedback_produce().

549 {
550  return instance->channel_uniqueid;
551 }
char channel_uniqueid[AST_MAX_UNIQUEID]
Definition: rtp_engine.c:219

◆ 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 3791 of file rtp_engine.c.

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

Referenced by add_ssrc_to_stream().

3792 {
3793  const char *cname = "";
3794 
3795  ao2_lock(rtp);
3796  if (rtp->engine->cname_get) {
3797  cname = rtp->engine->cname_get(rtp);
3798  }
3799  ao2_unlock(rtp);
3800 
3801  return cname;
3802 }
const char *(* cname_get)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:683
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ ast_rtp_instance_get_codecs()

struct ast_rtp_codecs* ast_rtp_instance_get_codecs ( struct ast_rtp_instance instance)

◆ 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);
(

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

Since
1.8

Definition at line 563 of file rtp_engine.c.

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_ice_add_remote_candidate(), ast_rtp_ice_change_components(), ast_rtp_ice_get_local_candidates(), ast_rtp_ice_get_password(), ast_rtp_ice_get_ufrag(), ast_rtp_ice_lite(), ast_rtp_ice_set_authentication(), ast_rtp_ice_set_role(), ast_rtp_ice_start(), ast_rtp_ice_start_media(), ast_rtp_ice_stop(), ast_rtp_ice_turn_request(), ast_rtp_interpret(), ast_rtp_local_bridge(), ast_rtp_on_ice_rx_data(), ast_rtp_on_ice_tx_pkt(), ast_rtp_on_turn_rtcp_state(), ast_rtp_on_turn_rtp_state(), ast_rtp_on_turn_rx_rtcp_data(), ast_rtp_on_turn_rx_rtp_data(), 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(), get_recv_buffer_count(), get_recv_buffer_max(), get_send_buffer_count(), ice_create(), ice_reset_session(), multicast_rtp_activate(), multicast_rtp_destroy(), multicast_rtp_write(), process_cn_rfc3389(), process_dtmf_cisco(), process_dtmf_rfc2833(), red_write(), rtcp_debug_test_addr(), rtp_instance_parse_transport_wide_cc(), rtp_raw_write(), rtp_red_buffer(), rtp_red_init(), rtp_sendto(), rtp_transport_wide_cc_feedback_produce(), set_rtp_rtcp_schedid(), and test_sip_rtpqos_1_get_stat().

564 {
565  return instance->data;
566 }

◆ 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
Return values
DTLSsupport if present
NULLif no DTLS support available

Definition at line 3011 of file rtp_engine.c.

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

Referenced by add_crypto_to_stream(), add_dtls_to_sdp(), apply_dtls_attrib(), ast_sdp_get_rtp_profile(), dialog_initialize_dtls_srtp(), process_crypto(), process_sdp(), process_sdp_a_dtls(), and setup_dtls_srtp().

3012 {
3013  if (instance->engine->dtls) {
3014  return &rtp_dtls_wrappers;
3015  }
3016  /* DTLS not available */
3017  return NULL;
3018 }
static struct ast_rtp_engine_dtls rtp_dtls_wrappers
Definition: rtp_engine.c:2998
#define NULL
Definition: resample.c:96
struct ast_rtp_engine_dtls * dtls
Definition: rtp_engine.h:693
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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
Return values
pointerto the engine

Example usage:

struct ast_rtp_engine *engine = ast_rtp_instance_get_engine(instance);

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

Since
1.8

Definition at line 2700 of file rtp_engine.c.

References ast_rtp_instance::engine.

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

2701 {
2702  return instance->engine;
2703 }
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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 690 of file rtp_engine.c.

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

691 {
692  void *prop;
693 
694  if (instance->engine->extended_prop_get) {
695  ao2_lock(instance);
696  prop = instance->engine->extended_prop_get(instance, property);
697  ao2_unlock(instance);
698  } else {
699  prop = NULL;
700  }
701 
702  return prop;
703 }
void *(* extended_prop_get)(struct ast_rtp_instance *instance, int property)
Definition: rtp_engine.h:639
#define ao2_unlock(a)
Definition: astobj2.h:730
#define NULL
Definition: resample.c:96
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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");

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

Since
1.8

Definition at line 2206 of file rtp_engine.c.

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, NULL, 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().

2207 {
2208  struct ast_rtp_glue *glue = NULL;
2209 
2211 
2212  AST_RWLIST_TRAVERSE(&glues, glue, entry) {
2213  if (!strcasecmp(glue->type, type)) {
2214  break;
2215  }
2216  }
2217 
2219 
2220  return glue;
2221 }
static const char type[]
Definition: chan_ooh323.c:109
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define NULL
Definition: resample.c:96
const char * type
Definition: rtp_engine.h:722
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
Definition: search.h:40

◆ 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
Return values
timeoutvalue

Example usage:

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

Since
1.8

Definition at line 2690 of file rtp_engine.c.

References ast_rtp_instance::holdtimeout.

Referenced by check_rtp_timeout().

2691 {
2692  return instance->holdtimeout;
2693 }

◆ 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
Return values
ICEsupport if present
NULLif no ICE support available

Definition at line 2891 of file rtp_engine.c.

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

Referenced by add_ice_to_sdp(), add_ice_to_stream(), check_ice_support(), create_rtp(), dialog_initialize_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(), process_sdp_a_ice(), set_ice_components(), and start_ice().

2892 {
2893  if (instance->engine->ice) {
2894  return &rtp_ice_wrappers;
2895  }
2896  /* ICE not available */
2897  return NULL;
2898 }
static struct ast_rtp_engine_ice rtp_ice_wrappers
Definition: rtp_engine.c:2877
#define NULL
Definition: resample.c:96
struct ast_rtp_engine_ice * ice
Definition: rtp_engine.h:691
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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 665 of file rtp_engine.c.

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

667 {
668  ao2_lock(instance);
669  ast_sockaddr_copy(address, &instance->incoming_source_address);
670  ao2_unlock(instance);
671 }
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:171
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_sockaddr incoming_source_address
Definition: rtp_engine.c:201

◆ 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
Return values
periodKeepalive interval value

Example usage:

int interval = ast_rtp_instance_get_keepalive(instance);

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

Since
1.8

Definition at line 2695 of file rtp_engine.c.

References ast_rtp_instance::keepalive.

Referenced by check_rtp_timeout(), and send_keepalive().

2696 {
2697  return instance->keepalive;
2698 }

◆ ast_rtp_instance_get_last_rx()

time_t ast_rtp_instance_get_last_rx ( const struct ast_rtp_instance rtp)

Definition at line 3768 of file rtp_engine.c.

References ast_rtp_instance::last_rx.

Referenced by rtp_check_timeout().

3769 {
3770  return rtp->last_rx;
3771 }

◆ 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 3758 of file rtp_engine.c.

References ast_rtp_instance::last_tx.

Referenced by send_keepalive().

3759 {
3760  return rtp->last_tx;
3761 }

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

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

Since
1.8

Definition at line 643 of file rtp_engine.c.

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

Referenced by add_sdp(), ast_rtp_ice_turn_request(), ast_rtp_prop_set(), ast_rtp_remote_address_set(), channel_read_rtp(), configure_local_rtp(), create_outgoing_sdp_stream(), get_our_media_address(), handle_open_receive_channel_ack_message(), multicast_send_control_packet(), send_start_rtp(), sip_acf_channel_read(), sip_allow_anyrtp_remote(), skinny_set_rtp_peer(), test_init_rtp_instances(), unicast_rtp_request(), and unistim_set_rtp_peer().

645 {
646  ao2_lock(instance);
647  ast_sockaddr_copy(address, &instance->local_address);
648  ao2_unlock(instance);
649 }
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:171
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_sockaddr local_address
Definition: rtp_engine.c:197

◆ 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
Return values
Currentvalue of the property

Example usage:

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

Since
1.8

Definition at line 716 of file rtp_engine.c.

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().

717 {
718  int prop;
719 
720  ao2_lock(instance);
721  prop = instance->properties[property];
722  ao2_unlock(instance);
723 
724  return prop;
725 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
int properties[AST_RTP_PROPERTY_MAX]
Definition: rtp_engine.c:195

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

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

Since
1.8

Definition at line 2460 of file rtp_engine.c.

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_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_RTT, buf, ast_rtp_instance_stats::local_maxjitter, ast_rtp_instance_stats::local_maxrxploss, ast_rtp_instance_stats::local_minjitter, ast_rtp_instance_stats::local_minrxploss, ast_rtp_instance_stats::local_normdevjitter, ast_rtp_instance_stats::local_normdevrxploss, ast_rtp_instance_stats::local_ssrc, ast_rtp_instance_stats::local_stdevjitter, 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_maxrxploss, ast_rtp_instance_stats::remote_minjitter, ast_rtp_instance_stats::remote_minrxploss, ast_rtp_instance_stats::remote_normdevjitter, ast_rtp_instance_stats::remote_normdevrxploss, ast_rtp_instance_stats::remote_ssrc, ast_rtp_instance_stats::remote_stdevjitter, 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::rxploss, ast_rtp_instance_stats::stdevrtt, ast_rtp_instance_stats::txcount, ast_rtp_instance_stats::txjitter, and ast_rtp_instance_stats::txploss.

Referenced by ast_rtp_instance_set_stats_vars(), channel_read_rtcp(), handle_request_bye(), sip_acf_channel_read(), and sip_hangup().

2461 {
2462  struct ast_rtp_instance_stats stats = { 0, };
2463  enum ast_rtp_instance_stat stat;
2464 
2465  /* Determine what statistics we will need to retrieve based on field passed in */
2466  if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY) {
2468  } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER) {
2470  } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS) {
2472  } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT) {
2474  } else {
2475  return NULL;
2476  }
2477 
2478  /* Attempt to actually retrieve the statistics we need to generate the quality string */
2479  if (ast_rtp_instance_get_stats(instance, &stats, stat)) {
2480  return NULL;
2481  }
2482 
2483  /* Now actually fill the buffer with the good information */
2484  if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY) {
2485  snprintf(buf, size, "ssrc=%u;themssrc=%u;lp=%u;rxjitter=%f;rxcount=%u;txjitter=%f;txcount=%u;rlp=%u;rtt=%f",
2486  stats.local_ssrc, stats.remote_ssrc, stats.rxploss, stats.rxjitter, stats.rxcount, stats.txjitter, stats.txcount, stats.txploss, stats.rtt);
2487  } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER) {
2488  snprintf(buf, size, "minrxjitter=%f;maxrxjitter=%f;avgrxjitter=%f;stdevrxjitter=%f;reported_minjitter=%f;reported_maxjitter=%f;reported_avgjitter=%f;reported_stdevjitter=%f;",
2490  } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS) {
2491  snprintf(buf, size, "minrxlost=%f;maxrxlost=%f;avgrxlost=%f;stdevrxlost=%f;reported_minlost=%f;reported_maxlost=%f;reported_avglost=%f;reported_stdevlost=%f;",
2493  } else if (field == AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT) {
2494  snprintf(buf, size, "minrtt=%f;maxrtt=%f;avgrtt=%f;stdevrtt=%f;", stats.minrtt, stats.maxrtt, stats.normdevrtt, stats.stdevrtt);
2495  }
2496 
2497  return buf;
2498 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
unsigned int txcount
Definition: rtp_engine.h:368
unsigned int rxploss
Definition: rtp_engine.h:394
#define NULL
Definition: resample.c:96
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:2446
ast_rtp_instance_stat
Definition: rtp_engine.h:180
unsigned int rxcount
Definition: rtp_engine.h:370
unsigned int local_ssrc
Definition: rtp_engine.h:422
unsigned int txploss
Definition: rtp_engine.h:392
unsigned int remote_ssrc
Definition: rtp_engine.h:424

◆ 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 673 of file rtp_engine.c.

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

Referenced by ast_rtp_read(), handle_response_invite(), and sip_allow_anyrtp_remote().

675 {
676  ao2_lock(instance);
677  ast_sockaddr_copy(address, &instance->requested_target_address);
678  ao2_unlock(instance);
679 }
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:171
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_sockaddr requested_target_address
Definition: rtp_engine.c:199

◆ 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
Return values
theSRTP instance on success
NULLif no SRTP instance exists

Definition at line 2763 of file rtp_engine.c.

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().

2764 {
2765  if (rtcp && instance->rtcp_srtp) {
2766  return instance->rtcp_srtp;
2767  } else {
2768  return instance->srtp;
2769  }
2770 }
struct ast_srtp * srtp
Definition: rtp_engine.c:215
struct ast_srtp * rtcp_srtp
Definition: rtp_engine.c:217

◆ 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 3778 of file rtp_engine.c.

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

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

3779 {
3780  unsigned int ssrc = 0;
3781 
3782  ao2_lock(rtp);
3783  if (rtp->engine->ssrc_get) {
3784  ssrc = rtp->engine->ssrc_get(rtp);
3785  }
3786  ao2_unlock(rtp);
3787 
3788  return ssrc;
3789 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
unsigned int(* ssrc_get)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:681
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

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

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

Since
1.8

Definition at line 2446 of file rtp_engine.c.

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(), process_ssrc_attributes(), show_chanstats_cb(), and sip_acf_channel_read().

2447 {
2448  int res;
2449 
2450  if (instance->engine->get_stat) {
2451  ao2_lock(instance);
2452  res = instance->engine->get_stat(instance, stats, stat);
2453  ao2_unlock(instance);
2454  } else {
2455  res = -1;
2456  }
2457  return res;
2458 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191
int(* get_stat)(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
Definition: rtp_engine.h:651

◆ ast_rtp_instance_get_test()

struct ast_rtp_engine_test* ast_rtp_instance_get_test ( struct ast_rtp_instance instance)

Obtain a pointer to the test callbacks on an RTP instance.

Parameters
instancethe RTP instance
Return values
testcallbacks if present
NULLif not present

Definition at line 2901 of file rtp_engine.c.

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

Referenced by __rtp_recvfrom(), ast_rtcp_interpret(), ast_rtp_instance_drop_packets(), ast_rtp_instance_get_recv_buffer_count(), ast_rtp_instance_get_recv_buffer_max(), ast_rtp_instance_get_sdes_received(), ast_rtp_instance_get_send_buffer_count(), ast_rtp_instance_queue_report(), ast_rtp_instance_reset_test_engine(), ast_rtp_instance_set_schedid(), and rtp_raw_write().

2902 {
2903  return instance->engine->test;
2904 }
struct ast_rtp_engine_test * test
Definition: rtp_engine.h:696
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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
Return values
timeoutvalue

Example usage:

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

Since
1.8

Definition at line 2685 of file rtp_engine.c.

References ast_rtp_instance::timeout.

Referenced by apply_negotiated_sdp_stream(), check_rtp_timeout(), and rtp_check_timeout().

2686 {
2687  return instance->timeout;
2688 }

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

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

Since
1.8

Definition at line 2589 of file rtp_engine.c.

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, LOG_ERROR, ast_rtp_engine::make_compatible, NULL, type, and ast_rtp_glue::type.

2590 {
2591  struct ast_rtp_glue *glue;
2592  struct ast_rtp_instance *peer_instance = NULL;
2593  int res = -1;
2594 
2595  if (!instance->engine->make_compatible) {
2596  return -1;
2597  }
2598 
2599  ast_channel_lock(peer);
2600 
2601  if (!(glue = ast_rtp_instance_get_glue(ast_channel_tech(peer)->type))) {
2602  ast_channel_unlock(peer);
2603  return -1;
2604  }
2605 
2606  glue->get_rtp_info(peer, &peer_instance);
2607  if (!peer_instance) {
2608  ast_log(LOG_ERROR, "Unable to get_rtp_info for peer type %s\n", glue->type);
2609  ast_channel_unlock(peer);
2610  return -1;
2611  }
2612  if (peer_instance->engine != instance->engine) {
2613  ast_log(LOG_ERROR, "Peer engine mismatch for type %s\n", glue->type);
2614  ast_channel_unlock(peer);
2615  ao2_ref(peer_instance, -1);
2616  return -1;
2617  }
2618 
2619  /*
2620  * XXX Good thing nothing calls this function because we would need
2621  * deadlock avoidance to get the two instance locks.
2622  */
2623  res = instance->engine->make_compatible(chan, instance, peer, peer_instance);
2624 
2625  ast_channel_unlock(peer);
2626 
2627  ao2_ref(peer_instance, -1);
2628  peer_instance = NULL;
2629 
2630  return res;
2631 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define NULL
Definition: resample.c:96
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:669
const char * type
Definition: rtp_engine.h:722
#define ast_log
Definition: astobj2.c:42
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:729
#define ao2_ref(o, delta)
Definition: astobj2.h:464
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:2206
#define LOG_ERROR
Definition: logger.h:285
#define ast_channel_unlock(chan)
Definition: channel.h:2946
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ 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);

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 465 of file rtp_engine.c.

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, 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 AST_TEST_DEFINE(), configure_local_rtp(), create_rtp(), dialog_initialize_rtp(), jingle_alloc(), jingle_enable_video(), multicast_rtp_request(), start_rtp(), test_init_rtp_instances(), and unicast_rtp_request().

468 {
469  struct ast_sockaddr address = {{0,}};
470  struct ast_rtp_instance *instance = NULL;
471  struct ast_rtp_engine *engine = NULL;
472  struct ast_module *mod_ref;
473 
475 
476  /* If an engine name was specified try to use it or otherwise use the first one registered */
477  if (!ast_strlen_zero(engine_name)) {
478  AST_RWLIST_TRAVERSE(&engines, engine, entry) {
479  if (!strcmp(engine->name, engine_name)) {
480  break;
481  }
482  }
483  } else {
484  engine = AST_RWLIST_FIRST(&engines);
485  }
486 
487  /* If no engine was actually found bail out now */
488  if (!engine) {
489  ast_log(LOG_ERROR, "No RTP engine was found. Do you have one loaded?\n");
491  return NULL;
492  }
493 
494  /* Bump up the reference count before we return so the module can not be unloaded */
495  mod_ref = ast_module_running_ref(engine->mod);
496 
498 
499  if (!mod_ref) {
500  /* BUGBUG: improve handling of this situation. */
501  return NULL;
502  }
503 
504  /* Allocate a new RTP instance */
505  if (!(instance = ao2_alloc(sizeof(*instance), instance_destructor))) {
506  ast_module_unref(engine->mod);
507  return NULL;
508  }
509  instance->engine = engine;
510  ast_sockaddr_copy(&instance->local_address, sa);
511  ast_sockaddr_copy(&address, sa);
512 
513  if (ast_rtp_codecs_payloads_initialize(&instance->codecs)) {
514  ao2_ref(instance, -1);
515  return NULL;
516  }
517 
518  /* Initialize RTP extension support */
519  if (AST_VECTOR_INIT(&instance->extmap_enabled, 0) ||
520  AST_VECTOR_INIT(&instance->extmap_negotiated, 0) ||
521  AST_VECTOR_INIT(&instance->extmap_unique_ids, 0)) {
522  ao2_ref(instance, -1);
523  return NULL;
524  }
525 
526  ast_debug(1, "Using engine '%s' for RTP instance '%p'\n", engine->name, instance);
527 
528  /*
529  * And pass it off to the engine to setup
530  *
531  * Lock in case the RTP engine has other threads that
532  * need synchronization with the construction.
533  */
534  ao2_lock(instance);
535  if (instance->engine->new(instance, sched, &address, data)) {
536  ast_debug(1, "Engine '%s' failed to setup RTP instance '%p'\n", engine->name, instance);
537  ao2_unlock(instance);
538  ao2_ref(instance, -1);
539  return NULL;
540  }
541  ao2_unlock(instance);
542 
543  ast_debug(1, "RTP instance '%p' is setup and ready to go\n", instance);
544 
545  return instance;
546 }
int ast_rtp_codecs_payloads_initialize(struct ast_rtp_codecs *codecs)
Initialize an RTP codecs structure.
Definition: rtp_engine.c:958
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:171
char * address
Definition: f2c.h:59
static void instance_destructor(void *obj)
Definition: rtp_engine.c:423
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define ao2_unlock(a)
Definition: astobj2.h:730
#define NULL
Definition: resample.c:96
Socket address structure.
Definition: netsock2.h:97
#define ast_module_unref(mod)
Release a reference to the module.
Definition: module.h:469
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
int(* new)(struct ast_rtp_instance *instance, struct ast_sched_context *sched, struct ast_sockaddr *sa, void *data)
Definition: rtp_engine.h:620
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_module * mod
Definition: rtp_engine.h:618
#define LOG_ERROR
Definition: logger.h:285
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
const char * name
Definition: rtp_engine.h:616
struct ast_sockaddr local_address
Definition: rtp_engine.c:197
#define ast_module_running_ref(mod)
Hold a reference to the module if it is running.
Definition: module.h:455
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191
Definition: search.h:40
#define AST_RWLIST_FIRST
Definition: linkedlists.h:422
struct ast_rtp_codecs codecs
Definition: rtp_engine.c:205

◆ 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);

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 578 of file rtp_engine.c.

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(), mgcp_rtp_read(), ooh323_rtp_read(), rtp_read(), sip_rtp_read(), skinny_rtp_read(), test_read_frames(), and unistim_rtp_read().

579 {
580  struct ast_frame *frame;
581 
582  ao2_lock(instance);
583  frame = instance->engine->read(instance, rtcp);
584  ao2_unlock(instance);
585  return frame;
586 }
struct ast_frame *(* read)(struct ast_rtp_instance *instance, int rtcp)
Definition: rtp_engine.h:661
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
Data structure associated with a single frame of data.
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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 2772 of file rtp_engine.c.

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

Referenced by check_rtp_timeout(), do_monitor(), and send_keepalive().

2773 {
2774  int res;
2775 
2776  if (instance->engine->sendcng) {
2777  ao2_lock(instance);
2778  res = instance->engine->sendcng(instance, level);
2779  ao2_unlock(instance);
2780  } else {
2781  res = -1;
2782  }
2783  return res;
2784 }
int(* sendcng)(struct ast_rtp_instance *instance, int level)
Definition: rtp_engine.h:679
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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 2244 of file rtp_engine.c.

References ao2_lock, ao2_unlock, and ast_rtp_instance::bridged.

Referenced by native_rtp_bridge_start(), and native_rtp_bridge_stop().

2245 {
2246  ao2_lock(instance);
2247  instance->bridged = bridged;
2248  ao2_unlock(instance);
2249 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_instance * bridged
Definition: rtp_engine.c:203

◆ 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 553 of file rtp_engine.c.

References ast_copy_string(), and ast_rtp_instance::channel_uniqueid.

Referenced by apply_negotiated_sdp_stream(), jingle_enable_video(), jingle_set_owner(), mgcp_set_owner(), multicast_rtp_request(), set_channel_on_rtp_instance(), sip_set_owner(), skinny_set_owner(), start_rtp(), unicast_rtp_request(), and unistim_set_owner().

554 {
555  ast_copy_string(instance->channel_uniqueid, uniqueid, sizeof(instance->channel_uniqueid));
556 }
char channel_uniqueid[AST_MAX_UNIQUEID]
Definition: rtp_engine.c:219
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

◆ 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);

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

Since
1.8

Definition at line 558 of file rtp_engine.c.

References ast_rtp_instance::data.

Referenced by ast_rtp_new(), multicast_rtp_new(), and test_sip_rtpqos_1_new().

559 {
560  instance->data = data;
561 }
union ast_frame::@263 data

◆ 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 681 of file rtp_engine.c.

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

682 {
683  if (instance->engine->extended_prop_set) {
684  ao2_lock(instance);
685  instance->engine->extended_prop_set(instance, property, value);
686  ao2_unlock(instance);
687  }
688 }
#define ao2_unlock(a)
Definition: astobj2.h:730
int value
Definition: syslog.c:37
#define ao2_lock(a)
Definition: astobj2.h:718
int(* extended_prop_set)(struct ast_rtp_instance *instance, int property, void *value)
Definition: rtp_engine.h:637
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

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

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

Since
1.8

Definition at line 2675 of file rtp_engine.c.

References ast_rtp_instance::holdtimeout, and timeout.

Referenced by check_rtp_timeout(), and dialog_initialize_rtp().

2676 {
2677  instance->holdtimeout = timeout;
2678 }
static int timeout
Definition: cdr_mysql.c:86

◆ 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 606 of file rtp_engine.c.

References ao2_lock, ao2_unlock, and rtp_instance_set_incoming_source_address_nolock().

Referenced by ast_rtp_read().

608 {
609  ao2_lock(instance);
611  ao2_unlock(instance);
612 
613  return 0;
614 }
static void rtp_instance_set_incoming_source_address_nolock(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Definition: rtp_engine.c:597
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718

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

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

Since
1.8

Definition at line 2680 of file rtp_engine.c.

References ast_rtp_instance::keepalive.

Referenced by apply_negotiated_sdp_stream(), and dialog_initialize_rtp().

2681 {
2682  instance->keepalive = interval;
2683 }

◆ 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 3773 of file rtp_engine.c.

References ast_rtp_instance::last_rx.

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

3774 {
3775  rtp->last_rx = time;
3776 }

◆ 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 3763 of file rtp_engine.c.

References ast_rtp_instance::last_tx.

Referenced by __rtp_sendto().

3764 {
3765  rtp->last_tx = time;
3766 }

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

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

Since
1.8

Definition at line 588 of file rtp_engine.c.

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().

590 {
591  ao2_lock(instance);
592  ast_sockaddr_copy(&instance->local_address, address);
593  ao2_unlock(instance);
594  return 0;
595 }
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:171
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_sockaddr local_address
Definition: rtp_engine.c:197

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

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

Since
1.8

Definition at line 705 of file rtp_engine.c.

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

Referenced by ast_rtp_ice_start_media(), check_for_rtp_changes(), configure_local_rtp(), configure_rtcp(), create_addr_from_peer(), create_rtp(), dialog_initialize_rtp(), do_setnat(), enable_rtcp(), get_codecs(), handle_request_invite(), jingle_alloc(), jingle_enable_video(), pjsip_acf_dtmf_mode_write(), process_sdp(), sip_dtmfmode(), sip_set_rtp_peer(), start_rtp(), test_init_rtp_instances(), and transmit_reinvite_with_sdp().

706 {
707  ao2_lock(instance);
708  instance->properties[property] = value;
709 
710  if (instance->engine->prop_set) {
711  instance->engine->prop_set(instance, property, value);
712  }
713  ao2_unlock(instance);
714 }
void(* prop_set)(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Definition: rtp_engine.h:641
#define ao2_unlock(a)
Definition: astobj2.h:730
int value
Definition: syslog.c:37
#define ao2_lock(a)
Definition: astobj2.h:718
int properties[AST_RTP_PROPERTY_MAX]
Definition: rtp_engine.c:195
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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");

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

Since
1.8

Definition at line 2169 of file rtp_engine.c.

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

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

2170 {
2171  int res;
2172 
2173  if (instance->engine->qos) {
2174  ao2_lock(instance);
2175  res = instance->engine->qos(instance, tos, cos, desc);
2176  ao2_unlock(instance);
2177  } else {
2178  res = -1;
2179  }
2180  return res;
2181 }
unsigned int cos
Definition: chan_iax2.c:352
static const char desc[]
Definition: cdr_mysql.c:73
#define ao2_unlock(a)
Definition: astobj2.h:730
unsigned int tos
Definition: chan_iax2.c:351
#define ao2_lock(a)
Definition: astobj2.h:718
int(* qos)(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
Definition: rtp_engine.h:653
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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;
ast_rtp_instance_set_read_format(instance, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));

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

Since
1.8

Definition at line 2560 of file rtp_engine.c.

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

Referenced by sip_new(), and sip_setoption().

2561 {
2562  int res;
2563 
2564  if (instance->engine->set_read_format) {
2565  ao2_lock(instance);
2566  res = instance->engine->set_read_format(instance, format);
2567  ao2_unlock(instance);
2568  } else {
2569  res = -1;
2570  }
2571  return res;
2572 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
int(* set_read_format)(struct ast_rtp_instance *instance, struct ast_format *format)
Definition: rtp_engine.h:665
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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 3821 of file rtp_engine.c.

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

Referenced by process_ssrc_attributes().

3822 {
3823  ao2_lock(rtp);
3824  if (rtp->engine->set_remote_ssrc) {
3825  rtp->engine->set_remote_ssrc(rtp, ssrc);
3826  }
3827  ao2_unlock(rtp);
3828 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
void(* set_remote_ssrc)(struct ast_rtp_instance *instance, unsigned int ssrc)
Definition: rtp_engine.h:687
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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 616 of file rtp_engine.c.

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

618 {
619  ao2_lock(instance);
620 
621  ast_sockaddr_copy(&instance->requested_target_address, address);
623 
624  ao2_unlock(instance);
625 
626  return 0;
627 }
static void rtp_instance_set_incoming_source_address_nolock(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Definition: rtp_engine.c:597
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:171
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_sockaddr requested_target_address
Definition: rtp_engine.c:199

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

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 2500 of file rtp_engine.c.

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_RTT, pbx_builtin_setvar_helper(), and quality.

Referenced by handle_request_bye(), and sip_hangup().

2501 {
2502  char quality_buf[AST_MAX_USER_FIELD];
2503  char *quality;
2504  struct ast_channel *bridge;
2505 
2506  bridge = ast_channel_bridge_peer(chan);
2507  if (bridge) {
2508  ast_channel_lock_both(chan, bridge);
2510  } else {
2511  ast_channel_lock(chan);
2512  }
2514 
2516  quality_buf, sizeof(quality_buf));
2517  if (quality) {
2518  pbx_builtin_setvar_helper(chan, "RTPAUDIOQOS", quality);
2519  if (bridge) {
2520  pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSBRIDGED", quality);
2521  }
2522  }
2523 
2524  quality = ast_rtp_instance_get_quality(instance,
2525  AST_RTP_INSTANCE_STAT_FIELD_QUALITY_JITTER, quality_buf, sizeof(quality_buf));
2526  if (quality) {
2527  pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSJITTER", quality);
2528  if (bridge) {
2529  pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSJITTERBRIDGED", quality);
2530  }
2531  }
2532 
2533  quality = ast_rtp_instance_get_quality(instance,
2534  AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS, quality_buf, sizeof(quality_buf));
2535  if (quality) {
2536  pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSLOSS", quality);
2537  if (bridge) {
2538  pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSLOSSBRIDGED", quality);
2539  }
2540  }
2541 
2542  quality = ast_rtp_instance_get_quality(instance,
2543  AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT, quality_buf, sizeof(quality_buf));
2544  if (quality) {
2545  pbx_builtin_setvar_helper(chan, "RTPAUDIOQOSRTT", quality);
2546  if (bridge) {
2547  pbx_builtin_setvar_helper(bridge, "RTPAUDIOQOSRTTBRIDGED", quality);
2548  }
2549  }
2550 
2552  ast_channel_unlock(chan);
2553  if (bridge) {
2555  ast_channel_unlock(bridge);
2556  ast_channel_unref(bridge);
2557  }
2558 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
static int quality
Definition: codec_speex.c:62
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:2460
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2981
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.
#define ast_channel_unlock(chan)
Definition: channel.h:2946
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...
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2952
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel&#39;s bridge peer only if the bridge is two-party.
Definition: channel.c:10765
#define AST_MAX_USER_FIELD
Definition: channel.h:175

◆ 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
rtpThe RTP instance
stream_numThe stream identifier number

Definition at line 3830 of file rtp_engine.c.

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

Referenced by apply_negotiated_sdp_stream().

3831 {
3832  ao2_lock(rtp);
3833  if (rtp->engine->set_stream_num) {
3834  rtp->engine->set_stream_num(rtp, stream_num);
3835  }
3836  ao2_unlock(rtp);
3837 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718

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

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

Since
1.8

Definition at line 2670 of file rtp_engine.c.

References timeout, and ast_rtp_instance::timeout.

Referenced by apply_negotiated_sdp_stream(), check_rtp_timeout(), configure_local_rtp(), and dialog_initialize_rtp().

2671 {
2672  instance->timeout = timeout;
2673 }
static int timeout
Definition: cdr_mysql.c:86

◆ 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;
ast_rtp_instance_set_write_format(instance, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));

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

Since
1.8

Definition at line 2574 of file rtp_engine.c.

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

Referenced by sip_new(), and sip_setoption().

2575 {
2576  int res;
2577 
2578  if (instance->engine->set_read_format) {
2579  ao2_lock(instance);
2580  res = instance->engine->set_write_format(instance, format);
2581  ao2_unlock(instance);
2582  } else {
2583  res = -1;
2584  }
2585  return res;
2586 }
int(* set_write_format)(struct ast_rtp_instance *instance, struct ast_format *format)
Definition: rtp_engine.h:667
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
int(* set_read_format)(struct ast_rtp_instance *instance, struct ast_format *format)
Definition: rtp_engine.h:665
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

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

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 2183 of file rtp_engine.c.

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

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

2184 {
2185  if (instance->engine->stop) {
2186  ao2_lock(instance);
2187  instance->engine->stop(instance);
2188  ao2_unlock(instance);
2189  }
2190 }
void(* stop)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:626
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

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

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

Since
1.8

Definition at line 2661 of file rtp_engine.c.

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

Referenced by jingle_interpret_google_transport().

2664 {
2665  if (instance->engine->stun_request) {
2666  instance->engine->stun_request(instance, suggestion, username);
2667  }
2668 }
void(* stun_request)(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username)
Definition: rtp_engine.h:675
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

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

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 2151 of file rtp_engine.c.

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

Referenced by jingle_indicate(), mgcp_indicate(), ooh323_indicate(), sip_answer(), sip_indicate(), sip_write(), and skinny_indicate().

2152 {
2153  if (instance->engine->update_source) {
2154  ao2_lock(instance);
2155  instance->engine->update_source(instance);
2156  ao2_unlock(instance);
2157  }
2158 }
#define ao2_unlock(a)
Definition: astobj2.h:730
void(* update_source)(struct ast_rtp_instance *instance)
Definition: rtp_engine.h:633
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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);

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 568 of file rtp_engine.c.

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(), mgcp_write(), ooh323_write(), rtp_write(), sip_indicate(), sip_write(), skinny_write(), test_write_frames(), and unistim_write().

569 {
570  int res;
571 
572  ao2_lock(instance);
573  res = instance->engine->write(instance, frame);
574  ao2_unlock(instance);
575  return res;
576 }
int(* write)(struct ast_rtp_instance *instance, struct ast_frame *frame)
Definition: rtp_engine.h:624
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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();
ast_format_cap_append(cap, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0));
ast_format_cap_append(cap, ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0));
char *mime = ast_rtp_lookup_mime_multiple2(&buf, sizeof(buf), cap, 0, 1, 0);
ast_format_cap_destroy(cap);

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

Since
1.8

Definition at line 2045 of file rtp_engine.c.

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(), name, and NULL.

Referenced by process_sdp().

2046 {
2047  int found = 0;
2048  const char *name;
2049  if (!buf) {
2050  return NULL;
2051  }
2052 
2053 
2054  if (asterisk_format) {
2055  int x;
2056  struct ast_format *tmp_fmt;
2057  for (x = 0; x < ast_format_cap_count(ast_format_capability); x++) {
2058  tmp_fmt = ast_format_cap_get_format(ast_format_capability, x);
2059  name = ast_rtp_lookup_mime_subtype2(asterisk_format, tmp_fmt, 0, options);
2060  ao2_ref(tmp_fmt, -1);
2061  ast_str_append(&buf, 0, "%s|", name);
2062  found = 1;
2063  }
2064  } else {
2065  int x;
2066  ast_str_append(&buf, 0, "0x%x (", (unsigned int) rtp_capability);
2067  for (x = 1; x <= AST_RTP_MAX; x <<= 1) {
2068  if (rtp_capability & x) {
2069  name = ast_rtp_lookup_mime_subtype2(asterisk_format, NULL, x, options);
2070  ast_str_append(&buf, 0, "%s|", name);
2071  found = 1;
2072  }
2073  }
2074  }
2075 
2076  ast_str_append(&buf, 0, "%s", found ? ")" : "nothing)");
2077 
2078  return ast_str_buffer(buf);
2079 }
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
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:1992
Definition of a media format.
Definition: format.c:43
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:1091
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
#define NULL
Definition: resample.c:96
#define AST_RTP_MAX
Definition: rtp_engine.h:272
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static const char name[]
Definition: cdr_mysql.c:74
static struct test_options options
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

◆ 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
Return values
Mimesubtype success
NULLfailure

Example usage:

const char *subtype = ast_rtp_lookup_mime_subtype2(1, ast_format_set(&tmp_fmt, AST_FORMAT_ULAW, 0), 0, 0);

This looks up the mime subtype for the ULAW format.

Since
1.8

Definition at line 1992 of file rtp_engine.c.

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, mime_types_len, ast_rtp_mime_type::payload_type, ast_rtp_payload_type::rtp_code, and ast_rtp_mime_type::subtype.

Referenced by add_codec_to_sdp(), add_noncodec_to_sdp(), add_sdp(), add_tcodec_to_sdp(), add_vcodec_to_sdp(), ast_rtp_lookup_mime_multiple2(), generate_rtpmap_attr(), jingle_add_payloads_to_description(), transmit_connect(), transmit_connect_with_sdp(), transmit_modify_request(), and transmit_modify_with_sdp().

1994 {
1995  int i;
1996  const char *res = "";
1997 
1999  for (i = 0; i < mime_types_len; i++) {
2000  if (ast_rtp_mime_types[i].payload_type.asterisk_format && asterisk_format && format &&
2001  (ast_format_cmp(format, ast_rtp_mime_types[i].payload_type.format) != AST_FORMAT_CMP_NOT_EQUAL)) {
2004  res = "G726-32";
2005  break;
2006  } else {
2007  res = ast_rtp_mime_types[i].subtype;
2008  break;
2009  }
2010  } else if (!ast_rtp_mime_types[i].payload_type.asterisk_format && !asterisk_format &&
2012 
2013  res = ast_rtp_mime_types[i].subtype;
2014  break;
2015  }
2016  }
2018 
2019  return res;
2020 }
#define ast_rwlock_rdlock(a)
Definition: lock.h:233
static int mime_types_len
Definition: rtp_engine.c:262
char subtype[64]
The format type.
Definition: rtp_engine.c:257
static ast_rwlock_t mime_types_lock
Definition: rtp_engine.c:261
static struct ast_rtp_mime_type ast_rtp_mime_types[128]
struct ast_format * ast_format_g726_aal2
Built-in cached g726 aal2 format.
Definition: format_cache.c:121
#define ast_rwlock_unlock(a)
Definition: lock.h:232
struct ast_rtp_payload_type payload_type
A mapping object between the Asterisk codec and this RTP payload.
Definition: rtp_engine.c:253
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
static struct test_options options

◆ 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 2022 of file rtp_engine.c.

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

Referenced by add_codec_to_sdp(), add_noncodec_to_sdp(), add_tcodec_to_sdp(), add_vcodec_to_sdp(), generate_rtpmap_attr(), and jingle_add_payloads_to_description().

2024 {
2025  unsigned int i;
2026  unsigned int res = 0;
2027 
2029  for (i = 0; i < mime_types_len; ++i) {
2030  if (ast_rtp_mime_types[i].payload_type.asterisk_format && asterisk_format && format &&
2031  (ast_format_cmp(format, ast_rtp_mime_types[i].payload_type.format) != AST_FORMAT_CMP_NOT_EQUAL)) {
2033  break;
2034  } else if (!ast_rtp_mime_types[i].payload_type.asterisk_format && !asterisk_format &&
2037  break;
2038  }
2039  }
2041 
2042  return res;
2043 }
#define ast_rwlock_rdlock(a)
Definition: lock.h:233
static int mime_types_len
Definition: rtp_engine.c:262
static ast_rwlock_t mime_types_lock
Definition: rtp_engine.c:261
static struct ast_rtp_mime_type ast_rtp_mime_types[128]
#define ast_rwlock_unlock(a)
Definition: lock.h:232
unsigned int sample_rate
Expected sample rate of the /c subtype.
Definition: rtp_engine.c:259
struct ast_rtp_payload_type payload_type
A mapping object between the Asterisk codec and this RTP payload.
Definition: rtp_engine.c:253
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_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 3485 of file rtp_engine.c.

References ao2_alloc, ao2_cleanup, ao2_ref, ast_channel_snapshot_get_latest(), ast_json_ref(), ast_rtp_rtcp_received_type(), ast_rtp_rtcp_sent_type(), ast_rtp_topic(), ast_strlen_zero, ast_rtp_instance::channel_uniqueid, NULL, RAII_VAR, rtcp_message_payload_dtor(), rtcp_report_to_ami(), rtcp_report_to_json(), stasis_message_create(), STASIS_MESSAGE_TYPE_DEFN(), stasis_publish(), and to_ami().

Referenced by ast_rtcp_calculate_sr_rr_statistics(), and ast_rtcp_interpret().

3489 {
3490  RAII_VAR(struct rtcp_message_payload *, payload, NULL, ao2_cleanup);
3492 
3493  if (!message_type) {
3494  return;
3495  }
3496 
3497  payload = ao2_alloc(sizeof(*payload), rtcp_message_payload_dtor);
3498  if (!payload || !report) {
3499  return;
3500  }
3501 
3502  if (!ast_strlen_zero(rtp->channel_uniqueid)) {
3503  payload->snapshot = ast_channel_snapshot_get_latest(rtp->channel_uniqueid);
3504  }
3505  if (blob) {
3506  payload->blob = blob;
3507  ast_json_ref(blob);
3508  }
3509  ao2_ref(report, +1);
3510  payload->report = report;
3511 
3512  message = stasis_message_create(message_type, payload);
3513  if (!message) {
3514  return;
3515  }
3516 
3518 }
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Definition: json.c:67
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
#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:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
static void rtcp_message_payload_dtor(void *obj)
Definition: rtp_engine.c:3288
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic&#39;s subscribers.
Definition: stasis.c:1511
char channel_uniqueid[AST_MAX_UNIQUEID]
Definition: rtp_engine.c:219
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...
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
struct stasis_topic * ast_rtp_topic(void)
Stasis Message Bus API topic for RTP and RTCP related messages
Definition: rtp_engine.c:3531

◆ 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 2432 of file rtp_engine.c.

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

Referenced by sip_write().

2433 {
2434  int res;
2435 
2436  if (instance->engine->red_buffer) {
2437  ao2_lock(instance);
2438  res = instance->engine->red_buffer(instance, frame);
2439  ao2_unlock(instance);
2440  } else {
2441  res = -1;
2442  }
2443  return res;
2444 }
#define ao2_unlock(a)
Definition: astobj2.h:730
int(* red_buffer)(struct ast_rtp_instance *instance, struct ast_frame *frame)
Definition: rtp_engine.h:659
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191

◆ 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 2418 of file rtp_engine.c.

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

Referenced by process_sdp().

2419 {
2420  int res;
2421 
2422  if (instance->engine->red_init) {
2423  ao2_lock(instance);
2424  res = instance->engine->red_init(instance, buffer_time, payloads, generations);
2425  ao2_unlock(instance);
2426  } else {
2427  res = -1;
2428  }
2429  return res;
2430 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_rtp_engine * engine
Definition: rtp_engine.c:191
int(* red_init)(struct ast_rtp_instance *instance, int buffer_time, int *payloads, int generations)
Definition: rtp_engine.h:657

◆ 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
Return values
Anao2 ref counted ast_rtp_rtcp_report object on success
NULLon error

Definition at line 3474 of file rtp_engine.c.

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().

3475 {
3476  struct ast_rtp_rtcp_report *rtcp_report;
3477 
3478  /* Size of object is sizeof the report + the number of report_blocks * sizeof pointer */
3479  rtcp_report = ao2_alloc((sizeof(*rtcp_report) + report_blocks * sizeof(struct ast_rtp_rtcp_report_block *)),
3481 
3482  return rtcp_report;
3483 }
An object that represents data sent during a SR/RR RTCP report.
Definition: rtp_engine.h:331
A report block within a SR/RR report.
Definition: rtp_engine.h:316
static void rtp_rtcp_report_dtor(void *obj)
Definition: rtp_engine.c:3464
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411