45 #define SOFTMIX_MIN_SAMPLE_RATE 8000 48 #define DEFAULT_SOFTMIX_INTERVAL 20 51 #define SOFTMIX_DATALEN(rate, interval) ((rate/50) * (interval / 10)) 54 #define SOFTMIX_SAMPLES(rate, interval) (SOFTMIX_DATALEN(rate, interval) / 2) 57 #define SOFTMIX_STAT_INTERVAL 100 66 #define DEFAULT_SOFTMIX_SILENCE_THRESHOLD 2500 69 #define DEFAULT_SOFTMIX_TALKING_THRESHOLD 160 71 #define SOFTBRIDGE_VIDEO_DEST_PREFIX "softbridge_dest" 72 #define SOFTBRIDGE_VIDEO_DEST_LEN strlen(SOFTBRIDGE_VIDEO_DEST_PREFIX) 73 #define SOFTBRIDGE_VIDEO_DEST_SEPARATOR '_' 86 unsigned int sample_rates[16];
88 unsigned int num_channels[16];
120 if (!(entry =
ast_calloc(1,
sizeof(*entry)))) {
146 memset(trans_helper, 0,
sizeof(*trans_helper));
309 #ifdef BINAURAL_RENDERING 344 if (set_binaural == 1) {
346 }
else if (set_binaural == 0) {
352 if (binaural_pos_id != -1) {
355 if (is_announcement != -1) {
375 if (set_binaural == 1 || (set_binaural == -1 && sc->
binaural == 1)) {
377 }
else if (set_binaural == 0) {
383 if (setup_fail || !sc->
dsp) {
419 #ifdef BINAURAL_RENDERING 469 int source_channel_stream_position)
471 char *dest_video_name;
472 size_t dest_video_name_len;
481 dest_video_name_len += strlen(source_channel_name) + 1;
482 if (source_channel_stream_position != -1) {
483 dest_video_name_len += 11;
486 dest_video_name =
ast_alloca(dest_video_name_len);
487 if (source_channel_stream_position != -1) {
489 snprintf(dest_video_name, dest_video_name_len,
"%s%c%s%c%d",
492 source_channel_stream_position);
495 snprintf(dest_video_name, dest_video_name_len,
"%s%c%s",
497 source_channel_name);
506 const char *channel_name,
const char *sdp_label,
509 char *stream_clone_name =
NULL;
546 const char *channel_name,
const char *sdp_label,
650 if (participant == joiner) {
673 if (participant == joiner) {
688 ast_trace(-1,
"%s/%s: Couldn't request topology change\n",
701 int set_binaural = 0;
706 int skip_binaural_output = 1;
708 int is_announcement = 0;
709 int samplerate_change;
730 skip_binaural_output = 0;
737 if (!skip_binaural_output) {
741 "Could not allocate enough memory.\n", bridge->
uniqueid,
759 bridge_channel, 0, set_binaural, pos_id, is_announcement);
767 ast_debug(1,
"Channel %s simulating UNHOLD for bridge softmix join.\n",
777 const char *channel_name)
780 int stream_removed = 0;
792 return stream_removed;
892 int video_src_priority;
900 if (video_src_priority == 1) {
913 if (video_src_priority == 1) {
915 int echo = num_src > 1 ? 0 : 1;
918 }
else if (video_src_priority == 2) {
947 int totalsilence = 0;
956 char update_talking = -1;
973 ast_debug(1,
"Channel %s wrote unexpected format into bridge. Got %s, expected %s.\n",
1000 if (totalsilence < silence_threshold) {
1001 if (!sc->
talking && !silent) {
1028 if (update_talking != -1) {
1133 if (!source_video) {
1150 if (participant == source) {
1157 if (!original_topology) {
1363 ast_log(
LOG_ERROR,
"Synchronous bridge action written to a softmix bridge.\n");
1387 if (bitrate < softmix_data->bitrate) {
1392 if (bitrate > softmix_data->
bitrate) {
1458 if (bitrate < collector->bitrate) {
1463 if (bitrate > collector->
bitrate) {
1545 frexp(bitrate, &exp);
1546 exp = exp > 18 ? exp - 18 : 0;
1557 if (bridge_num == -1) {
1575 int channel_native_rate;
1588 }
else if (softmix_data->
internal_rate < channel_native_rate) {
1602 }
else if (softmix_data->
internal_rate == channel_native_rate) {
1620 if (binaural_active) {
1635 ast_debug(1,
"Locking at new rate. Bridge changed from %u to %u.\n",
1644 ast_debug(1,
"Locking at new maximum rate. Bridge changed from %u to %u.\n",
1652 int best_index = -1;
1660 if (best_index == -1
1676 }
else if (best_index == -1) {
1690 ast_debug(1,
"Multiple above internal rate. Bridge changed from %u to %u.\n",
1696 ast_debug(1,
"All below internal rate. Bridge changed from %u to %u.\n",
1705 unsigned int starting_num_entries,
unsigned int binaural_active)
1707 memset(mixing_array, 0,
sizeof(*mixing_array));
1713 if (binaural_active) {
1724 unsigned int binaural_active)
1727 if (binaural_active) {
1733 unsigned int num_entries,
unsigned int binaural_active)
1745 if (binaural_active) {
1771 #ifdef BINAURAL_RENDERING 1775 unsigned int stat_iteration_counter = 0;
1777 int update_all_rates = 0;
1782 timer = softmix_data->
timer;
1790 goto softmix_cleanup;
1803 int remb_update = 0;
1811 "Bridge %s: Conference mixing error, requested mixing length greater than mixing buffer.\n",
1813 goto softmix_cleanup;
1820 goto softmix_cleanup;
1828 if (!stat_iteration_counter) {
1829 memset(&stats, 0,
sizeof(stats));
1835 if (update_all_rates) {
1839 #ifdef BINAURAL_RENDERING 1861 if (update_all_rates) {
1867 if (!stat_iteration_counter) {
1879 #ifdef BINAURAL_RENDERING 1892 memset(buf, 0, softmix_datalen);
1893 for (idx = 0; idx < mixing_array.
used_entries; ++idx) {
1894 for (x = 0; x < softmix_samples; ++x) {
1899 #ifdef BINAURAL_RENDERING 1900 binaural_mixing(bridge, softmix_data, &mixing_array, bin_buf, ann_buf);
1916 "Replace softmix channel slin format");
1917 #ifdef BINAURAL_RENDERING 1921 softmix_samples, buf);
1927 memcpy(sc->
final_buf, buf, softmix_datalen);
1949 update_all_rates = 0;
1950 if (!stat_iteration_counter) {
1955 stat_iteration_counter--;
1966 goto softmix_cleanup;
1975 update_all_rates = 1;
2008 while (!softmix_data->
stop) {
2013 if (!softmix_data->
stop) {
2022 #ifndef BINAURAL_RENDERING 2040 "binaural processing, Will only process mono audio.\n",
2067 if (softmix_data->
timer) {
2083 softmix_data =
ast_calloc(1,
sizeof(*softmix_data));
2084 if (!softmix_data) {
2091 if (!softmix_data->
timer) {
2100 #ifdef BINAURAL_RENDERING 2135 if (!softmix_data) {
2140 softmix_data->
stop = 1;
2151 if (!softmix_data) {
2157 softmix_data->
stop = 1;
2159 thread = softmix_data->
thread;
2163 ast_debug(1,
"Bridge %s: Waiting for mixing thread to die.\n", bridge->
uniqueid);
2164 pthread_join(thread,
NULL);
2166 #ifdef BINAURAL_RENDERING 2202 if (
is_video_dest(stream, source_channel_name, source_channel_stream_position)) {
2247 size_t bridge_stream_position)
2276 size_t removed_streams_count = 0;
2285 if (!added_streams) {
2313 removed_streams[removed_streams_count++] = index;
2319 new_stream, index)) {
2329 removed_streams[removed_streams_count++] = index;
2337 new_stream, index)) {
2399 SCOPE_ENTER(4,
"%s/%s: Old participant topology %s\n",
2404 if (participant == bridge_channel) {
2427 for (removed_stream = 0; removed_stream < removed_streams_count; ++removed_stream) {
2429 removed_streams[removed_stream])) {
2430 ast_trace(-1,
"%s/%s: Removing stream %s\n",
2439 SCOPE_EXIT(
"%s/%s: New participant topology %s\n",
2468 struct ast_vector_int media_types;
2494 for (idx = 0; idx <
AST_VECTOR_SIZE(&softmix_data->remb_collectors); ++idx) {
2555 AST_VECTOR_SIZE(&media_types) - 1, &bridge->
channels, i);
2606 #ifdef TEST_FRAMEWORK 2623 for (i = 0; i < num_streams; ++i) {
2700 for (i = 0; i < num_streams; ++i) {
2731 info->name =
"sfu_append_source_streams";
2732 info->category =
"/bridges/bridge_softmix/";
2733 info->summary =
"Test appending of video streams";
2735 "This tests does stuff.";
2742 if (!topology_alice) {
2747 if (!topology_bob) {
2806 static const struct {
2807 const char *channel_name;
2809 int params_index[4];
2810 } removal_results[] = {
2811 {
"PJSIP/Bob-00000001", 4, { 0, 1, 2, 3 }, },
2812 {
"PJSIP/Edward-00000004", 4, { 0, 1, 2, 3 }, },
2813 {
"", 4, { 0, 1, 2, 3 }, },
2820 info->name =
"sfu_remove_destination_streams";
2821 info->category =
"/bridges/bridge_softmix/";
2822 info->summary =
"Test removal of destination video streams";
2824 "This tests does stuff.";
2836 for (i = 0; i <
ARRAY_LEN(removal_results); ++i) {
2847 for (j = 0; j < removal_results[i].num_streams; ++j) {
2854 orig_index = removal_results[i].params_index[j];
2871 if (
is_video_dest(actual, removal_results[i].channel_name, -1) &&
void check_binaural_position_change(struct ast_bridge *bridge, struct softmix_bridge_data *softmix_data)
Checks if a position change in the virual enviroment is requested by one of the participants.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
unsigned int num_above_maximum_rate
static void softmix_bridge_write_voice(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
#define SCOPE_EXIT_LOG(__log_level,...)
#define ast_channel_lock(chan)
Multi-party software based channel mixing (header)
const char * ast_stream_to_str(const struct ast_stream *stream, struct ast_str **buf)
Get a string representing the stream for debugging/display purposes.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
int ast_channel_hold_state(const struct ast_channel *chan)
static void * softmix_translate_helper_free_entry(struct softmix_translate_helper_entry *entry)
struct convolve_channel_pair ** chan_pairs
#define AST_VECTOR_GET_INDEX_NTH(vec, nth, value, cmp)
Get the nth index from a vector that matches the given comparison.
Asterisk main include file. File version handling, generic pbx functions.
const ast_string_field uniqueid
#define ast_realloc(p, len)
A wrapper for realloc()
struct ast_bridge_features * features
int ast_dsp_silence_with_energy(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence, int *frames_energy)
Process the audio frame for silence.
#define SOFTBRIDGE_VIDEO_DEST_PREFIX
static void softmix_bridge_stop(struct ast_bridge *bridge)
static int softmix_mixing_array_grow(struct softmix_mixing_array *mixing_array, unsigned int num_entries, unsigned int binaural_active)
int init_convolve_data(struct convolve_data *data, unsigned int default_sample_size)
Preinits a specific number of channels (CONVOVLE_CHANNEL_PREALLOC) at the beginning of a conference...
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_stream_topology * build_topology(const struct stream_parameters *params, size_t num_streams)
static int validate_original_streams(struct ast_test *test, struct ast_stream_topology *topology, const struct stream_parameters *params, size_t num_streams)
void ast_slinfactory_flush(struct ast_slinfactory *sf)
Flush the contents of a slinfactory.
static int softmix_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
unsigned int remb_send_interval
struct ast_stream_topology * topology
static void softmix_translate_helper_change_rate(struct softmix_translate_helper *trans_helper, unsigned int sample_rate)
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
static int softmix_bridge_create(struct ast_bridge *bridge)
Function called when a bridge is created.
void ast_dsp_free(struct ast_dsp *dsp)
unsigned int internal_mixing_interval
The mixing interval indicates how quickly softmix mixing should occur to mix audio.
unsigned int talking_threshold
unsigned int default_sample_size
#define AST_VECTOR_ELEM_DEFAULT_CMP(elem, value)
Default comparator for AST_VECTOR_REMOVE_ELEM_UNORDERED()
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
unsigned int binaural_init
unsigned int binaural_pos
static void sfu_topologies_on_join(struct ast_bridge *bridge, struct ast_bridge_channel *joiner)
Issue channel stream topology change requests.
struct ast_bridge_video_mode video_mode
const char * ast_codec_media_type2str(enum ast_media_type type)
Conversion function to take a media type and turn it into a string.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
static void softmix_translate_helper_destroy(struct softmix_translate_helper *trans_helper)
static int remove_destination_streams(struct ast_stream_topology *topology, const char *channel_name)
An object that represents data received in a feedback report.
Set when the stream has been removed/declined.
int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f)
Feed audio into a slinfactory.
#define SOFTBRIDGE_VIDEO_DEST_SEPARATOR
#define AST_TEST_REGISTER(cb)
void ast_timer_close(struct ast_timer *handle)
Close an opened timing handle.
#define ao2_t_replace(dst, src, tag)
Replace one object reference with another cleaning up the original.
Structure used to transport a message through the frame core.
#define ast_trace(level,...)
Print a basic trace message.
static void softmix_bridge_write_rtcp(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
short our_buf[MAX_DATALEN]
struct ast_timer * ast_timer_open(void)
Open a timer.
static struct softmix_remb_collector * remb_collector_alloc(void)
Allocate a REMB collector.
#define SOFTMIX_MIN_SAMPLE_RATE
#define ast_cond_wait(cond, mutex)
#define ast_cond_init(cond, attr)
struct timeval last_video_update
static void * softmix_mixing_thread(void *data)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
static void remb_collect_report_all(struct ast_bridge *bridge, struct softmix_bridge_data *softmix_data, float bitrate)
#define ao2_alloc_options(data_size, destructor_fn, options)
#define ast_mutex_lock(a)
struct ast_frame * ast_translate(struct ast_trans_pvt *tr, struct ast_frame *f, int consume)
translates one or more frames Apply an input frame into the translator and receive zero or one output...
Set when the stream is not sending OR receiving media.
#define ast_str_alloca(init_len)
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
static void softmix_bridge_write_text(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
void softmix_process_write_binaural_audio(struct softmix_channel *sc, unsigned int default_sample_size)
Writes the binaural audio to a channel.
struct ast_rtp_rtcp_feedback_remb remb
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_bridge_channel::@236 stream_map
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_append_stream(struct ast_stream_topology *topology, struct ast_stream *stream)
Append a stream to the topology.
static void map_source_to_destinations(const char *source_channel_name, size_t bridge_stream_position, struct ast_bridge_channels_list *participants, int source_channel_stream_position)
Map a source stream to all of its destination streams.
#define DEFAULT_SOFTMIX_SILENCE_THRESHOLD
Default time in ms of silence necessary to declare talking stopped by the bridge. ...
Out-of-call text message support.
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.
short final_buf[MAX_DATALEN]
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
static void softmix_mixing_array_destroy(struct softmix_mixing_array *mixing_array, unsigned int binaural_active)
#define ast_cond_signal(cond)
struct softmix_translate_helper::@96 entries
int ast_stream_topology_set_stream(struct ast_stream_topology *topology, unsigned int position, struct ast_stream *stream)
Set a specific position in a topology.
struct ast_format * dst_format
struct ast_bridge_softmix softmix
union ast_bridge_video_mode::@227 mode_data
static int softmix_bridge_write_control(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
unsigned int ast_slinfactory_available(const struct ast_slinfactory *sf)
Retrieve number of samples currently in a slinfactory.
enum ast_bridge_video_sfu_remb_behavior remb_behavior
static void softmix_bridge_destroy(struct ast_bridge *bridge)
Function called when a bridge is destroyed.
struct ast_vector_int to_bridge
struct ast_bridge * bridge
Bridge this channel is participating in.
struct ast_frame_subclass subclass
int ast_set_write_format_interleaved_stereo(struct ast_channel *chan, struct ast_format *format)
Sets write format for a channel. All internal data will than be handled in an interleaved format...
unsigned int silence_threshold
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
int ast_set_read_format_path(struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format)
Set specific read path on channel.
#define ast_strlen_zero(foo)
unsigned int sample_rates[16]
unsigned int max_num_entries
#define DEFAULT_SOFTMIX_INTERVAL
Interval at which mixing will take place. Valid options are 10, 20, and 40.
int ast_callid_threadassoc_add(ast_callid callid)
Adds a known callid to thread storage of the calling thread.
#define SOFTMIX_SAMPLES(rate, interval)
Number of samples we are dealing with.
#define SOFTMIX_BINAURAL_SAMPLE_RATE
static void softmix_bridge_write_video(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
void ast_bridge_update_talker_src_video_mode(struct ast_bridge *bridge, struct ast_channel *chan, int talker_energy, int is_keyfame)
Update information about talker energy for talker src video mode.
struct softmix_translate_helper_entry::@95 entry
#define ast_str_tmp(init_len, __expr)
#define ast_debug(level,...)
Log a DEBUG message.
const char * ast_stream_topology_to_str(const struct ast_stream_topology *topology, struct ast_str **buf)
Get a string representing the topology for debugging/display purposes.
#define ast_bridge_channel_lock(bridge_channel)
Lock the bridge_channel.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
struct ast_trans_pvt * ast_translator_build_path(struct ast_format *dest, struct ast_format *source)
Builds a translator path Build a path (possibly NULL) from source to dest.
int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception)
Waits for input on an fd.
#define BINAURAL_MIXING_INTERVAL
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
Vector element cleanup that does nothing.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_test_status_update(a, b, c...)
static void softmix_bridge_unsuspend(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
Function called when a channel is unsuspended from the bridge.
#define AST_PTHREADT_NULL
struct ast_format * read_slin_format
int ast_bridge_channel_notify_talking(struct ast_bridge_channel *bridge_channel, int started_talking)
Lets the bridging indicate when a bridge channel has stopped or started talking.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define ao2_ref(o, delta)
unsigned int maximum_rate
static force_inline void ast_slinear_saturated_add(short *input, short *value)
static void sfu_topologies_on_source_change(struct ast_bridge *bridge, struct ast_bridge_channel *source)
static void softmix_bridge_data_destroy(struct softmix_bridge_data *softmix_data)
AST_TEST_DEFINE(sfu_append_source_streams)
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
#define SCOPE_EXIT(...)
Scope Exit.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
unsigned int num_at_internal_rate
const struct ast_format_cap * ast_stream_get_formats(const struct ast_stream *stream)
Get the current negotiated formats of a stream.
void set_binaural_data_leave(struct convolve_data *data, unsigned int pos, unsigned int default_sample_size)
Removes a channel from the binaural conference bridge. Marks the position in the virtual room as unus...
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
static void softmix_bridge_check_voice(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
unsigned int internal_mixing_interval
#define SCOPE_EXIT_EXPR(__expr,...)
void ast_slinfactory_destroy(struct ast_slinfactory *sf)
Destroy the contents of a slinfactory.
struct ast_format * write_format
void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold)
Set the minimum average magnitude threshold to determine talking by the DSP.
#define ast_bridge_technology_register(technology)
See __ast_bridge_technology_register()
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
const char * ast_channel_uniqueid(const struct ast_channel *chan)
static int is_video_dest(const struct ast_stream *stream, const char *source_channel_name, int source_channel_stream_position)
Determine if a stream is a video destination stream.
#define ast_bridge_channel_unlock(bridge_channel)
Unlock the bridge_channel.
unsigned int internal_rate
struct ast_vector_int to_channel
int ast_slinfactory_init_with_format(struct ast_slinfactory *sf, struct ast_format *slin_out)
Initialize a slinfactory.
void free_convolve_data(struct convolve_data *data)
Frees all channels and data needed for binaural audio processing.
static int unload_module(void)
#define SCOPE_EXIT_LOG_RTN(__log_level,...)
Structure that contains information about a bridge.
int ast_timer_ack(const struct ast_timer *handle, unsigned int quantity)
Acknowledge a timer event.
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
static void remb_send_report(struct ast_bridge_channel *bridge_channel, struct softmix_bridge_data *softmix_data, struct softmix_channel *sc)
Set when the stream is sending and receiving media.
int ast_bridge_technology_unregister(struct ast_bridge_technology *technology)
Unregister a bridge technology from use.
static int append_source_stream(struct ast_stream_topology *dest, const char *channel_name, const char *sdp_label, struct ast_stream *stream, int index)
static struct softmix_translate_helper_entry * softmix_translate_helper_entry_alloc(struct ast_format *dst)
struct ast_frame write_frame
struct ast_format * slin_src
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
struct ast_bridge_video_sfu_data sfu_data
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
static int softmix_bridge_join(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
Function called when a channel is joined into the bridge.
Structure which contains per-channel mixing information.
static int16_t * softmix_process_read_audio(struct softmix_channel *sc, unsigned int num_samples)
#define AST_TEST_UNREGISTER(cb)
void create_binaural_frame(struct ast_bridge_channel *bridge_channel, struct softmix_channel *sc, int16_t *bin_buf, int16_t *ann_buf, unsigned int softmix_datalen, unsigned int softmix_samples, int16_t *buf)
Creates a frame out of binaural audio data.
static void softmix_translate_helper_init(struct softmix_translate_helper *trans_helper, unsigned int sample_rate)
struct ast_bridge_tech_optimizations tech_args
int ast_bridge_is_video_src(struct ast_bridge *bridge, struct ast_channel *chan)
Determine if a channel is a video src for the bridge.
static int append_all_streams(struct ast_stream_topology *dest, const struct ast_stream_topology *source)
const char * ast_msg_data_get_attribute(struct ast_msg_data *msg, enum ast_msg_data_attribute_type attribute_type)
Get attribute from ast_msg_data.
static void softmix_bridge_stream_sources_update(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct softmix_channel *sc)
#define ast_cond_destroy(cond)
void ast_bridge_channel_leave_bridge(struct ast_bridge_channel *bridge_channel, enum bridge_channel_state new_state, int cause)
Set bridge channel state to leave bridge (if not leaving already).
static void clear_talking(struct ast_bridge_channel *bridge_channel)
#define SCOPE_EXIT_RTN(...)
Scope Exit with return.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
struct ast_slinfactory factory
static void remb_collect_report(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct softmix_bridge_data *softmix_data, struct softmix_channel *sc)
#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()
#define ast_pthread_create(a, b, c, d)
struct ast_bridge * bridge
Bridge pointer passed to the softmix mixing thread.
int energy_history_cur_slot
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
struct ast_frame * out_frame
struct video_follow_talker_data video_talker
struct ast_rtp_rtcp_feedback_remb remb
unsigned int frame_ending
void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state)
Set the state of a stream.
static struct ast_bridge_technology softmix_bridge
#define SCOPE_ENTER(level,...)
Non RAII_VAR Scope Trace macros The advantage of these macros is that the EXITs will have the actual ...
static void gather_softmix_stats(struct softmix_stats *stats, const struct softmix_bridge_data *softmix_data, struct ast_bridge_channel *bridge_channel)
static int is_video_source(const struct ast_stream *stream)
Determine if a stream is a video source stream.
unsigned int video_update_discard
static void softmix_pass_video_top_priority(struct ast_bridge *bridge, struct ast_frame *frame)
Module has failed to load, may be in an inconsistent state.
struct ast_trans_pvt * trans_pvt
Vector container support.
unsigned int talking
TRUE if a channel is talking.
unsigned int num_channels[16]
static int validate_stream(struct ast_test *test, struct ast_stream *stream, const struct stream_parameters *params)
static void softmix_process_write_audio(struct softmix_translate_helper *trans_helper, struct ast_format *raw_write_fmt, struct softmix_channel *sc, unsigned int default_sample_size)
int set_binaural_data_join(struct convolve_data *data, unsigned int default_sample_size)
Joins a channel into a virtual enviroment build with the help of binaural sythesis.
void * tech_pvt
Private information unique to the bridge technology.
int ast_timer_fd(const struct ast_timer *handle)
Get a poll()-able file descriptor for a timer.
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
static void * cleanup(void *unused)
char * ast_frame_type2str(enum ast_frame_type frame_type, char *ftype, size_t len)
Copy the discription of a frame type into the provided string.
struct timeval last_remb_update
unsigned int send_sdp_label
static void remb_enable_collection(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, size_t bridge_stream_position)
Setup REMB collection for a particular bridge stream and channel.
static void softmix_translate_helper_cleanup(struct softmix_translate_helper *trans_helper)
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 SCOPE_EXIT_RTN_VALUE(__return_value,...)
Scope Exit with return value.
int ast_bridge_channel_queue_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *fr)
Write a frame to the specified bridge_channel.
void ast_stream_free(struct ast_stream *stream)
Destroy a media stream representation.
struct ast_bridge_channels_list channels
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
static void set_softmix_bridge_data(int rate, int interval, struct ast_bridge_channel *bridge_channel, int reset, int set_binaural, int binaural_pos_id, int is_announcement)
struct ast_stream * ast_stream_alloc(const char *name, enum ast_media_type type)
Create a new media stream representation.
#define ao2_replace(dst, src)
void add_binaural_mixing(struct ast_bridge *bridge, struct softmix_bridge_data *softmix_data, unsigned int softmix_samples, struct softmix_mixing_array *mixing_array, struct softmix_channel *sc, const char *channel_name)
Processes audio data with the binaural synthesis and adds the result to the mixing array...
struct ast_stream * ast_stream_clone(const struct ast_stream *stream, const char *name)
Create a deep clone of an existing stream.
struct convolve_data convolve
const char * ast_channel_name(const struct ast_channel *chan)
Structure that is the essence of a bridge technology.
unsigned int num_above_internal_rate
struct ast_rtp_rtcp_feedback feedback
static int remove_all_original_streams(struct ast_stream_topology *dest, const struct ast_stream_topology *source, const struct ast_stream_topology *original)
const char * ast_stream_state2str(enum ast_stream_state state)
Convert the state of a stream into a string.
int ast_stream_set_metadata(struct ast_stream *stream, const char *m_key, const char *value)
Set a stream metadata value.
#define AST_VECTOR_REPLACE(vec, idx, elem)
Replace an element at a specific position in a vector, growing the vector if needed.
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.
#define AST_RTP_RTCP_PSFB
static int sfu_topologies_on_leave(struct ast_bridge_channel *leaver, struct ast_bridge_channels_list *participants)
int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples)
Read samples from a slinfactory.
struct ast_dsp * ast_dsp_new_with_rate(unsigned int sample_rate)
Allocates a new dsp with a specific internal sample rate used during processing.
unsigned int is_announcement
static force_inline void ast_slinear_saturated_subtract(short *input, short *value)
unsigned int drop_silence
union ast_frame::@263 data
ast_media_type
Types of media.
int energy_history[DEFAULT_ENERGY_HISTORY_LEN]
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
enum ast_frame_type frametype
#define ast_mutex_init(pmutex)
#define ast_mutex_destroy(a)
static void softmix_bridge_leave(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
Function called when a channel leaves the bridge.
static unsigned int analyse_softmix_stats(struct softmix_stats *stats, struct softmix_bridge_data *softmix_data, int binaural_active)
struct ast_format * format
static void softmix_bridge_stream_topology_changed(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
stream_topology_changed callback
unsigned int used_entries
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
const char * ast_stream_get_name(const struct ast_stream *stream)
Get the name of a stream.
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define DEBUG_ATLEAST(level)
static struct ast_timer * timer
static int load_module(void)
unsigned int internal_sample_rate
The internal sample rate softmix uses to mix channels.
#define DEFAULT_SOFTMIX_TALKING_THRESHOLD
unsigned int highest_supported_rate
static int softmix_mixing_loop(struct ast_bridge *bridge)
Mixing loop.
struct ast_format * ast_channel_rawwriteformat(struct ast_channel *chan)
static int append_source_streams(struct ast_stream_topology *dest, const char *channel_name, const char *sdp_label, const struct ast_stream_topology *source)
unsigned int maximum_sample_rate
The maximum sample rate softmix uses to mix channels.
unsigned int num_channels
Set when the stream is receiving media only.
int ast_bridge_number_video_src(struct ast_bridge *bridge)
Returns the number of video sources currently active in the bridge.
enum ast_bridge_video_mode_type mode
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
struct softmix_remb_collector * remb_collector
#define DEFAULT_ENERGY_HISTORY_LEN
void ast_translator_free_path(struct ast_trans_pvt *tr)
Frees a translator path Frees the given translator path structure.
static int softmix_mixing_array_init(struct softmix_mixing_array *mixing_array, unsigned int starting_num_entries, unsigned int binaural_active)
void binaural_mixing(struct ast_bridge *bridge, struct softmix_bridge_data *softmix_data, struct softmix_mixing_array *mixing_array, int16_t *bin_buf, int16_t *ann_buf)
Mixes all binaural audio data contained in the mixing array.
#define ast_mutex_unlock(a)
#define SOFTBRIDGE_VIDEO_DEST_LEN
#define SOFTMIX_DATALEN(rate, interval)
Size of the buffer used for sample manipulation.
unsigned int binaural_active
#define SOFTMIX_STAT_INTERVAL
Number of mixing iterations to perform between gathering statistics.
#define AST_RTP_RTCP_FMT_REMB
static void softmix_poke_thread(struct softmix_bridge_data *softmix_data)