138 ast_debug(2,
"Destroying channel tech_pvt data %p\n", data);
239 glue0->
result = combined_result;
240 glue1->
result = combined_result;
274 combined_result = glue0->
result;
277 return combined_result;
306 if (!data0 || !data1) {
310 glue0 = &data0->
glue;
311 glue1 = &data1->
glue;
315 if (!glue0->
cb || !glue1->
cb) {
333 ast_debug(2,
"Bridge '%s'. Tech starting '%s' and '%s' with target '%s'\n",
337 native_type = glue0->
result;
339 switch (native_type) {
349 ast_verb(4,
"Locally RTP bridged '%s' and '%s' in stack\n",
355 if (!cap0 || !cap1) {
378 ast_verb(4,
"Remotely bridged '%s' and '%s' - media will flow directly between them\n",
387 ast_debug(2,
"Bridge '%s'. Sending '%s' back to remote\n",
389 if (bc0->
chan == target) {
408 ast_debug(2,
"Bridge '%s'. Bringing back '%s' to us\n",
414 ast_debug(2,
"Bridge '%s'. Bringing back '%s' to us\n",
449 if (!data0 || !data1) {
453 glue0 = &data0->
glue;
454 glue1 = &data1->
glue;
456 ast_debug(2,
"Bridge '%s'. Tech stopping '%s' and '%s' with target '%s'\n",
460 if (!glue0->
cb || !glue1->
cb) {
473 ast_debug(2,
"Bridge '%s'. Bringing back '%s' to us\n",
481 ast_debug(2,
"Bridge '%s'. Bringing back '%s' to us\n",
509 ast_debug(2,
"Bridge '%s'. Bringing back '%s' to us\n",
511 if (bc0->
chan == target) {
532 ast_debug(2,
"Bridge '%s'. Bringing back '%s' and '%s' to us\n",
538 ast_debug(2,
"Bridge '%s'. Skip bringing back '%s' and '%s' to us\n",
551 ast_debug(2,
"Discontinued RTP bridging of '%s' and '%s' - media will flow through Asterisk core\n",
646 ast_debug(1,
"Bridge '%s'. Checking compatability for channels '%s' and '%s'\n",
650 ast_debug(1,
"Bridge '%s' can not use native RTP bridge as channel '%s' has features which prevent it\n",
656 ast_debug(1,
"Bridge '%s' can not use native RTP bridge as channel '%s' has features which prevent it\n",
666 ast_debug(1,
"Bridge '%s' can not use native RTP bridge as could not get details\n",
670 native_type = glue0->result;
673 ast_debug(1,
"Bridge '%s' can not use native RTP bridge as it was forbidden while getting details\n",
680 ast_debug(1,
"Bridge '%s' can not use native RTP bridge as channel '%s' has DTMF hooks\n",
687 ast_debug(1,
"Bridge '%s' can not use native RTP bridge as channel '%s' has DTMF hooks\n",
697 glue0->audio.instance, bc1->
chan, glue1->audio.instance)))) {
698 ast_debug(1,
"Bridge '%s' can not use local native RTP bridge as local bridge or DTMF is not compatible\n",
705 if (!cap0 || !cap1) {
710 if (glue0->cb->get_codec) {
711 glue0->cb->get_codec(bc0->
chan, cap0);
713 if (glue1->cb->get_codec) {
714 glue1->cb->get_codec(bc1->
chan, cap1);
722 ast_debug(1,
"Bridge '%s': Channel codec0 = %s is not codec1 = %s, cannot native bridge in RTP.\n",
729 if (glue0->audio.instance && glue1->audio.instance) {
730 unsigned int framing_inst0, framing_inst1;
733 if (framing_inst0 != framing_inst1) {
735 ast_debug(1,
"Asymmetric ptimes on the two call legs (%u != %u). Cannot native bridge in RTP\n",
736 framing_inst0, framing_inst1);
739 ast_debug(3,
"Symmetric ptimes on the two call legs (%u). May be able to native bridge in RTP\n",
748 if (read_ptime0 != write_ptime1 || read_ptime1 != write_ptime0) {
749 ast_debug(1,
"Bridge '%s': Packetization differs between RTP streams (%d != %d or %d != %d). Cannot native bridge in RTP\n",
751 read_ptime0, write_ptime1, read_ptime1, write_ptime0);
754 ast_debug(3,
"Bridge '%s': Packetization comparison success between RTP streams (read_ptime0:%d == write_ptime1:%d and read_ptime1:%d == write_ptime0:%d).\n",
756 read_ptime0, write_ptime1, read_ptime1, write_ptime0);
773 ast_debug(1,
"Bridge '%s' can not use native RTP bridge as two channels are required\n",
786 return is_compatible;
801 .disable_inheritance = 1,
807 if (!
data->hook_data) {
811 ast_debug(2,
"Bridge '%s'. Attaching hook data %p to '%s'\n",
820 if (
data->hook_data->id < 0) {
846 ast_debug(2,
"Bridge '%s'. Detaching hook data %p from '%s'\n",
975 ast_debug(2,
"Bridge '%s'. Channel '%s' is joining bridge tech\n",
1004 SWAP(req_top, existing_top);
1027 ast_debug(2,
"Bridge '%s'. Channel '%s' is unsuspended back to bridge tech\n",
1038 ast_debug(2,
"Bridge '%s'. Channel '%s' is leaving bridge tech\n",
1058 ast_debug(2,
"Bridge '%s'. Channel '%s' is suspending from bridge tech\n",
1078 t38_parameters = frame->
data.
ptr;
Asterisk main include file. File version handling, generic pbx functions.
#define ast_calloc(num, len)
A wrapper for calloc()
@ AO2_ALLOC_OPT_LOCK_NOLOCK
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc_options(data_size, destructor_fn, options)
void __ao2_cleanup(void *obj)
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
#define ast_bridge_unlock(bridge)
Unlock the bridge.
@ AST_BRIDGE_CAPABILITY_NATIVE
#define ast_bridge_lock(bridge)
Lock the bridge.
int ast_bridge_queue_everyone_else(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
Queue the given frame to everyone else.
void ast_bridge_channel_stream_map(struct ast_bridge_channel *bridge_channel)
Maps a channel's stream topology to and from the bridge.
static void native_rtp_stream_topology_changed(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
static int native_rtp_bridge_capable(struct ast_channel *chan)
static int native_rtp_bridge_compatible_check(struct ast_bridge *bridge, struct ast_bridge_channel *bc0, struct ast_bridge_channel *bc1)
static void native_rtp_bridge_framehook_detach(struct ast_bridge_channel *bridge_channel)
static int native_rtp_bridge_join(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
Forward declarations.
static struct ast_frame * native_rtp_framehook(struct ast_channel *chan, struct ast_frame *f, enum ast_framehook_event event, void *data)
static struct ast_stream_topology * native_rtp_request_stream_topology_update(struct ast_stream_topology *existing_topology, struct ast_stream_topology *requested_topology)
static int native_rtp_framehook_consume(void *data, enum ast_frame_type type)
static struct native_rtp_bridge_channel_data * native_rtp_bridge_channel_data_alloc(void)
static void native_rtp_bridge_unsuspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
static void native_rtp_bridge_suspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
static void native_rtp_bridge_stop(struct ast_bridge *bridge, struct ast_channel *target)
static enum ast_rtp_glue_result rtp_glue_get_current_combined_result(struct ast_channel *c0, struct ast_channel *c1)
static struct ast_bridge_technology native_rtp_bridge
static int native_rtp_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
static void native_rtp_bridge_channel_data_free(struct native_rtp_bridge_channel_data *data)
static int rtp_glue_data_get(struct ast_channel *c0, struct rtp_glue_data *glue0, struct ast_channel *c1, struct rtp_glue_data *glue1)
static void native_rtp_bridge_leave(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
static void rtp_glue_data_reset(struct rtp_glue_data *glue)
static int load_module(void)
static int unload_module(void)
static int native_rtp_bridge_compatible(struct ast_bridge *bridge)
static int native_rtp_bridge_framehook_attach(struct ast_bridge_channel *bridge_channel)
static void rtp_glue_data_destroy(struct rtp_glue_data *glue)
static void rtp_glue_data_init(struct rtp_glue_data *glue)
static void native_rtp_bridge_start(struct ast_bridge *bridge, struct ast_channel *target)
@ AST_BRIDGE_PREFERENCE_BASE_NATIVE
#define ast_bridge_technology_register(technology)
See __ast_bridge_technology_register()
int ast_bridge_technology_unregister(struct ast_bridge_technology *technology)
Unregister a bridge technology from use.
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
void * ast_channel_get_stream_topology_change_source(struct ast_channel *chan)
Retrieve the source that initiated the last stream topology change.
int ast_channel_request_stream_topology_change(struct ast_channel *chan, struct ast_stream_topology *topology, void *change_source)
Request that the stream topology of a channel change.
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
int ast_channel_has_hook_requiring_audio(struct ast_channel *chan)
Check if the channel has any active hooks that require audio.
#define ast_channel_lock(chan)
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
struct ast_format * ast_channel_rawwriteformat(struct ast_channel *chan)
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
#define ast_channel_unlock(chan)
ast_channel_state
ast_channel states
int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interface *i)
Attach an framehook onto a channel for frame interception.
ast_framehook_event
These are the types of events that the framehook's event callback can receive.
@ AST_FRAMEHOOK_EVENT_WRITE
int ast_framehook_detach(struct ast_channel *chan, int framehook_id)
Detach an framehook from a channel.
#define AST_FRAMEHOOK_INTERFACE_VERSION
Asterisk internal frame definitions.
@ AST_T38_REQUEST_NEGOTIATE
ast_frame_type
Frame types.
@ AST_CONTROL_T38_PARAMETERS
@ AST_CONTROL_UPDATE_RTP_PEER
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Pluggable RTP Architecture.
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance)
Get the DTMF mode of an RTP instance.
@ AST_RTP_GLUE_RESULT_LOCAL
@ AST_RTP_GLUE_RESULT_REMOTE
@ AST_RTP_GLUE_RESULT_FORBID
struct ast_rtp_engine * ast_rtp_instance_get_engine(struct ast_rtp_instance *instance)
Get the RTP engine in use on an RTP instance.
struct ast_rtp_glue * ast_rtp_instance_get_glue(const char *type)
Get the RTP glue that binds a channel to the RTP engine.
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
unsigned int ast_rtp_codecs_get_framing(struct ast_rtp_codecs *codecs)
Get the framing used for a set of codecs.
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.
@ AST_STREAM_STATE_RECVONLY
Set when the stream is receiving media only.
@ AST_STREAM_STATE_REMOVED
Set when the stream has been removed/declined.
@ AST_STREAM_STATE_SENDONLY
Set when the stream is sending media only.
void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state)
Set the state of a stream.
struct ast_stream * ast_stream_topology_get_stream(const struct ast_stream_topology *topology, unsigned int position)
Get a specific stream from the topology.
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
void ast_stream_set_formats(struct ast_stream *stream, struct ast_format_cap *caps)
Set the current negotiated formats of a stream.
const struct ast_format_cap * ast_stream_get_formats(const struct ast_stream *stream)
Get the current negotiated formats of a stream.
struct ast_stream_topology * ast_stream_topology_clone(const struct ast_stream_topology *topology)
Create a deep clone of an existing stream topology.
#define ast_str_alloca(init_len)
Structure that contains information regarding a channel in a bridge.
void * tech_pvt
Private information unique to the bridge technology.
struct ast_bridge * bridge
Bridge this channel is participating in.
struct ast_bridge_features * features
struct ast_channel * chan
struct ao2_container * dtmf_hooks
Structure that is the essence of a bridge technology.
Structure that contains information about a bridge.
const ast_string_field uniqueid
struct ast_bridge_channels_list channels
unsigned int num_channels
Main Channel structure associated with a channel.
struct ast_bridge_channel * bridge_channel
struct ast_bridge * bridge
enum ast_control_t38 request_response
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@226 data
enum ast_frame_type frametype
int(* local_bridge)(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1)
int(* dtmf_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1)
int(* allow_vrtp_remote)(struct ast_channel *chan1, struct ast_rtp_instance *instance)
Used to prevent two channels from remotely bridging video rtp if the channel tech has a reason for pr...
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.
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.
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)
int(* allow_rtp_remote)(struct ast_channel *chan1, struct ast_rtp_instance *instance)
Used to prevent two channels from remotely bridging audio rtp if the channel tech has a reason for pr...
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.
Support for dynamic strings.
Internal structure which contains instance information about bridged RTP channels.
struct native_rtp_framehook_data * hook_data
Channel's hook data.
struct rtp_glue_data glue
Channel's cached RTP glue information.
struct ast_rtp_glue * remote_cb
Glue callbacks to bring remote channel streams back to Asterisk.
Internal structure which contains bridged RTP channel hook data.
unsigned int detached
Set when this framehook has been detached.
int id
Framehook used to intercept certain control frames.
struct rtp_glue_stream audio
struct rtp_glue_stream video
enum ast_rtp_glue_result result
struct ast_rtp_glue * cb
glue callbacks
enum ast_rtp_glue_result result
glue result
struct ast_rtp_instance * instance
RTP instance.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.