37 #include <sys/types.h> 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,
811 ast_debug(2,
"Bridge '%s'. Attaching hook data %p to '%s'\n",
846 ast_debug(2,
"Bridge '%s'. Detaching hook data %p from '%s'\n",
932 == &native_rtp_bridge) {
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;
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
static enum ast_rtp_glue_result rtp_glue_get_current_combined_result(struct ast_channel *c0, struct ast_channel *c1)
Asterisk main include file. File version handling, generic pbx functions.
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
const ast_string_field uniqueid
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
struct ast_bridge_features * features
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
static struct ast_frame * native_rtp_framehook(struct ast_channel *chan, struct ast_frame *f, enum ast_framehook_event event, void *data)
static void native_rtp_bridge_unsuspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
static int unload_module(void)
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
ast_framehook_event
These are the types of events that the framehook's event callback can receive.
void __ao2_cleanup(void *obj)
int ast_framehook_detach(struct ast_channel *chan, int framehook_id)
Detach an framehook from a channel.
Set when the stream has been removed/declined.
enum ast_control_t38 request_response
int id
Framehook used to intercept certain control frames.
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)
ast_channel_state
ast_channel states
struct ao2_container * dtmf_hooks
#define ao2_alloc_options(data_size, destructor_fn, options)
#define ast_str_alloca(init_len)
struct ast_rtp_glue * cb
glue callbacks
static void native_rtp_bridge_leave(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
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_stream * ast_stream_topology_get_stream(const struct ast_stream_topology *topology, unsigned int position)
Get a specific stream from the topology.
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_stream_set_formats(struct ast_stream *stream, struct ast_format_cap *caps)
Set the current negotiated formats of a stream.
#define ast_verb(level,...)
unsigned int ast_rtp_codecs_get_framing(struct ast_rtp_codecs *codecs)
Get the framing used for a set of codecs.
static int native_rtp_bridge_compatible_check(struct ast_bridge *bridge, struct ast_bridge_channel *bc0, struct ast_bridge_channel *bc1)
struct ast_bridge * bridge
Bridge this channel is participating in.
struct ast_frame_subclass subclass
static void native_rtp_bridge_suspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
static void rtp_glue_data_destroy(struct rtp_glue_data *glue)
Internal structure which contains instance information about bridged RTP channels.
struct rtp_glue_stream video
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...
static struct ast_bridge_technology native_rtp_bridge
static int rtp_glue_data_get(struct ast_channel *c0, struct rtp_glue_data *glue0, struct ast_channel *c1, struct rtp_glue_data *glue1)
int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interface *i)
Attach an framehook onto a channel for frame interception.
static void rtp_glue_data_init(struct rtp_glue_data *glue)
static struct ast_stream_topology * native_rtp_request_stream_topology_update(struct ast_stream_topology *existing_topology, struct ast_stream_topology *requested_topology)
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.
#define ast_debug(level,...)
Log a DEBUG message.
Internal structure which contains bridged RTP channel hook data.
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
static int native_rtp_framehook_consume(void *data, enum ast_frame_type type)
General Asterisk PBX channel definitions.
int(* dtmf_compatible)(struct ast_channel *chan0, struct ast_rtp_instance *instance0, struct ast_channel *chan1, struct ast_rtp_instance *instance1)
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.
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.
static void rtp_glue_data_reset(struct rtp_glue_data *glue)
static void native_rtp_bridge_channel_data_free(struct native_rtp_bridge_channel_data *data)
Asterisk internal frame definitions.
#define ao2_ref(o, delta)
struct ast_rtp_glue * remote_cb
Glue callbacks to bring remote channel streams back to Asterisk.
static int native_rtp_bridge_capable(struct ast_channel *chan)
struct ast_rtp_engine * ast_rtp_instance_get_engine(struct ast_rtp_instance *instance)
Get the RTP engine in use on an RTP instance.
static int native_rtp_bridge_compatible(struct ast_bridge *bridge)
enum ast_rtp_glue_result result
const struct ast_format_cap * ast_stream_get_formats(const struct ast_stream *stream)
Get the current negotiated formats of a stream.
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.
static void native_rtp_bridge_stop(struct ast_bridge *bridge, struct ast_channel *target)
#define ast_bridge_technology_register(technology)
See __ast_bridge_technology_register()
ast_frame_type
Frame types.
Structure that contains information about a bridge.
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
int ast_bridge_technology_unregister(struct ast_bridge_technology *technology)
Unregister a bridge technology from use.
void * ast_channel_get_stream_topology_change_source(struct ast_channel *chan)
Retrieve the source that initiated the last stream topology change.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
struct native_rtp_framehook_data * hook_data
Channel's hook data.
#define AST_FRAMEHOOK_INTERFACE_VERSION
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
static int load_module(void)
#define ast_channel_unlock(chan)
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Set when the stream is sending media only.
#define ast_calloc(num, len)
A wrapper for calloc()
static void native_rtp_bridge_framehook_detach(struct ast_bridge_channel *bridge_channel)
void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state)
Set the state of a stream.
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...
Module has failed to load, may be in an inconsistent state.
void * tech_pvt
Private information unique to the bridge technology.
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
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_bridge_lock(bridge)
Lock the bridge.
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
struct ast_bridge_channels_list channels
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
int ast_channel_has_hook_requiring_audio(struct ast_channel *chan)
Check if the channel has any active hooks that require audio.
const char * ast_channel_name(const struct ast_channel *chan)
Structure that is the essence of a bridge technology.
struct rtp_glue_stream audio
int(* local_bridge)(struct ast_rtp_instance *instance0, struct ast_rtp_instance *instance1)
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance)
Get the DTMF mode of an RTP instance.
static int native_rtp_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
void ast_bridge_channel_stream_map(struct ast_bridge_channel *bridge_channel)
Maps a channel's stream topology to and from the bridge.
Data structure associated with a single frame of data.
static struct native_rtp_bridge_channel_data * native_rtp_bridge_channel_data_alloc(void)
enum ast_rtp_glue_result result
glue result
static int native_rtp_bridge_join(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
Forward declarations.
union ast_frame::@263 data
enum ast_frame_type frametype
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.
unsigned int detached
Set when this framehook has been detached.
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
static void native_rtp_bridge_start(struct ast_bridge *bridge, struct ast_channel *target)
#define ASTERISK_GPL_KEY
The text the key() function should return.
struct ast_rtp_glue * ast_rtp_instance_get_glue(const char *type)
Get the RTP glue that binds a channel to the RTP engine.
Pluggable RTP Architecture.
Asterisk module definitions.
struct ast_format * ast_channel_rawwriteformat(struct ast_channel *chan)
struct rtp_glue_data glue
Channel's cached RTP glue information.
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
unsigned int num_channels
Set when the stream is receiving media only.
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
static int native_rtp_bridge_framehook_attach(struct ast_bridge_channel *bridge_channel)
static void native_rtp_stream_topology_changed(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)