Asterisk - The Open Source Telephony Project
18.5.0
|
Jack Application. More...
#include "asterisk.h"
#include <limits.h>
#include <jack/jack.h>
#include <jack/ringbuffer.h>
#include <libresample.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/strings.h"
#include "asterisk/lock.h"
#include "asterisk/app.h"
#include "asterisk/pbx.h"
#include "asterisk/audiohook.h"
#include "asterisk/format_cache.h"
Go to the source code of this file.
Data Structures | |
struct | jack_data |
Macros | |
#define | COMMON_OPTIONS |
Common options between the Jack() app and JACK_HOOK() function. More... | |
#define | RESAMPLE_QUALITY 1 |
#define | RINGBUFFER_FRAME_CAPACITY 100 |
Enumerations | |
enum | { OPT_SERVER_NAME = (1 << 0), OPT_INPUT_PORT = (1 << 1), OPT_OUTPUT_PORT = (1 << 2), OPT_NOSTART_SERVER = (1 << 3), OPT_CLIENT_NAME = (1 << 4) } |
enum | { OPT_ARG_SERVER_NAME, OPT_ARG_INPUT_PORT, OPT_ARG_OUTPUT_PORT, OPT_ARG_CLIENT_NAME, OPT_ARG_ARRAY_SIZE } |
Functions | |
static int | alloc_resampler (struct jack_data *jack_data, int input) |
AST_MODULE_INFO_STANDARD_EXTENDED (ASTERISK_GPL_KEY, "JACK Interface") | |
static struct jack_data * | destroy_jack_data (struct jack_data *jack_data) |
static int | disable_jack_hook (struct ast_channel *chan) |
static int | enable_jack_hook (struct ast_channel *chan, char *data) |
static void | handle_input (void *buf, jack_nframes_t nframes, struct jack_data *jack_data) |
Handle jack input port. More... | |
static void | handle_jack_audio (struct ast_channel *chan, struct jack_data *jack_data, struct ast_frame *out_frame) |
handle jack audio More... | |
static int | handle_options (struct jack_data *jack_data, const char *__options_str) |
static void | handle_output (void *buf, jack_nframes_t nframes, struct jack_data *jack_data) |
Handle jack output port. More... | |
static int | init_jack_data (struct ast_channel *chan, struct jack_data *jack_data) |
static struct jack_data * | jack_data_alloc (void) |
static int | jack_exec (struct ast_channel *chan, const char *data) |
static int | jack_hook_callback (struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction) |
static void | jack_hook_ds_destroy (void *data) |
static int | jack_hook_write (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
static int | jack_process (jack_nframes_t nframes, void *arg) |
static void | jack_shutdown (void *arg) |
static const char * | jack_status_to_str (jack_status_t status) |
static int | load_module (void) |
static void | log_jack_status (const char *prefix, jack_status_t status) |
static int | queue_voice_frame (struct jack_data *jack_data, struct ast_frame *f) |
static int | unload_module (void) |
Variables | |
static const char | jack_app [] = "JACK" |
static const struct ast_app_option | jack_exec_options [128] = { [ 's' ] = { .flag = OPT_SERVER_NAME , .arg_index = OPT_ARG_SERVER_NAME + 1 }, [ 'i' ] = { .flag = OPT_INPUT_PORT , .arg_index = OPT_ARG_INPUT_PORT + 1 }, [ 'o' ] = { .flag = OPT_OUTPUT_PORT , .arg_index = OPT_ARG_OUTPUT_PORT + 1 }, [ 'n' ] = { .flag = OPT_NOSTART_SERVER }, [ 'c' ] = { .flag = OPT_CLIENT_NAME , .arg_index = OPT_ARG_CLIENT_NAME + 1 }, } |
static const struct ast_datastore_info | jack_hook_ds_info |
static struct ast_custom_function | jack_hook_function |
struct { | |
jack_status_t status | |
const char * str | |
} | jack_status_table [] |
Jack Application.
This is an application to connect an Asterisk channel to an input and output jack port so that the audio can be processed through another application, or to play audio from another application.
$ svn co http://svn.digium.com/svn/thirdparty/libresample/trunk
Definition in file app_jack.c.
#define COMMON_OPTIONS |
Common options between the Jack() app and JACK_HOOK() function.
Definition at line 67 of file app_jack.c.
#define RESAMPLE_QUALITY 1 |
Definition at line 61 of file app_jack.c.
Referenced by alloc_resampler().
#define RINGBUFFER_FRAME_CAPACITY 100 |
Definition at line 64 of file app_jack.c.
Referenced by init_jack_data().
anonymous enum |
Enumerator | |
---|---|
OPT_SERVER_NAME | |
OPT_INPUT_PORT | |
OPT_OUTPUT_PORT | |
OPT_NOSTART_SERVER | |
OPT_CLIENT_NAME |
Definition at line 669 of file app_jack.c.
anonymous enum |
Enumerator | |
---|---|
OPT_ARG_SERVER_NAME | |
OPT_ARG_INPUT_PORT | |
OPT_ARG_OUTPUT_PORT | |
OPT_ARG_CLIENT_NAME | |
OPT_ARG_ARRAY_SIZE |
Definition at line 677 of file app_jack.c.
|
static |
Definition at line 193 of file app_jack.c.
References ast_log, jack_data::audiohook_rate, jack_data::client, jack_data::input_resample_factor, jack_data::input_resampler, LOG_ERROR, jack_data::output_resample_factor, jack_data::output_resampler, and RESAMPLE_QUALITY.
Referenced by jack_process(), and queue_voice_frame().
AST_MODULE_INFO_STANDARD_EXTENDED | ( | ASTERISK_GPL_KEY | , |
"JACK Interface" | |||
) |
Referenced by load_module().
Definition at line 343 of file app_jack.c.
References ast_audiohook_destroy(), ast_free, ast_string_field_free_memory, jack_data::audiohook, jack_data::client, jack_data::has_audiohook, jack_data::input_port, jack_data::input_rb, jack_data::input_resampler, NULL, jack_data::output_port, jack_data::output_rb, and jack_data::output_resampler.
Referenced by enable_jack_hook(), jack_exec(), and jack_hook_ds_destroy().
|
static |
Definition at line 942 of file app_jack.c.
References ast_audiohook_detach(), ast_channel_datastore_find(), ast_channel_datastore_remove(), ast_channel_lock, ast_channel_unlock, ast_datastore_free(), ast_log, jack_data::audiohook, ast_datastore::data, LOG_WARNING, and NULL.
Referenced by jack_hook_write().
|
static |
Definition at line 875 of file app_jack.c.
References args, AST_APP_ARG, ast_audiohook_attach(), ast_audiohook_init(), AST_AUDIOHOOK_MANIPULATE_ALL_RATES, AST_AUDIOHOOK_TYPE_MANIPULATE, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_datastore_alloc, ast_datastore_free(), AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strlen_zero, jack_data::audiohook, ast_datastore::data, destroy_jack_data(), handle_options(), jack_data::has_audiohook, init_jack_data(), jack_data_alloc(), jack_hook_callback(), LOG_ERROR, ast_audiohook::manipulate_callback, NULL, options, and S_OR.
Referenced by jack_hook_write().
|
static |
Handle jack input port.
Read nframes number of samples from the input buffer, resample it if necessary, and write it into the appropriate ringbuffer.
Definition at line 241 of file app_jack.c.
References ARRAY_LEN, ast_log, buf, jack_data::input_rb, jack_data::input_resample_factor, jack_data::input_resampler, LOG_ERROR, and LOG_WARNING.
Referenced by jack_process().
|
static |
handle jack audio
[in] | chan | The Asterisk channel to write the frames to if no output frame is provided. |
[in] | jack_data | This is the jack_data struct that contains the input ringbuffer that audio will be read from. |
[out] | out_frame | If this argument is non-NULL, then assuming there is enough data avilable in the ringbuffer, the audio in this frame will get replaced with audio from the input buffer. If there is not enough data available to read at this time, then the frame data gets zeroed out. |
Read data from the input ringbuffer, which is the properly resampled audio that was read from the jack input port. Write it to the channel in 20 ms frames, or fill up an output frame instead if one is provided.
Definition at line 621 of file app_jack.c.
References ARRAY_LEN, ast_debug, AST_FRAME_VOICE, ast_log, ast_write(), jack_data::audiohook_format, buf, ast_frame::data, ast_frame::datalen, jack_data::frame_datalen, ast_frame::frametype, jack_data::input_rb, LOG_ERROR, ast_frame::ptr, and ast_frame::samples.
Referenced by jack_exec(), and jack_hook_callback().
|
static |
Definition at line 709 of file app_jack.c.
References ast_app_parse_options(), ast_log, ast_strdupa, ast_string_field_set, ast_strlen_zero, ast_test_flag, jack_data::client_name, jack_data::connect_input_port, jack_data::connect_output_port, jack_exec_options, LOG_ERROR, jack_data::no_start_server, OPT_ARG_ARRAY_SIZE, OPT_ARG_CLIENT_NAME, OPT_ARG_INPUT_PORT, OPT_ARG_OUTPUT_PORT, OPT_ARG_SERVER_NAME, OPT_CLIENT_NAME, OPT_INPUT_PORT, OPT_NOSTART_SERVER, OPT_OUTPUT_PORT, OPT_SERVER_NAME, and jack_data::server_name.
Referenced by enable_jack_hook(), and jack_exec().
|
static |
Handle jack output port.
Read nframes number of samples from the ringbuffer and write it out to the output port buffer.
Definition at line 304 of file app_jack.c.
References ast_debug, len(), and jack_data::output_rb.
Referenced by jack_process().
|
static |
Definition at line 390 of file app_jack.c.
References ast_channel_lock, ast_channel_name(), ast_channel_readformat(), ast_channel_unlock, ast_debug, ast_format_cache_get_slin_by_rate(), ast_format_get_name(), ast_format_get_sample_rate(), ast_log, ast_strdupa, ast_strlen_zero, jack_data::audiohook_format, jack_data::audiohook_rate, jack_data::client, jack_data::client_name, jack_data::connect_input_port, jack_data::connect_output_port, jack_data::frame_datalen, jack_data::input_port, jack_data::input_rb, jack_process(), jack_shutdown(), LOG_ERROR, log_jack_status(), jack_data::no_start_server, NULL, jack_data::output_port, jack_data::output_rb, RINGBUFFER_FRAME_CAPACITY, jack_data::server_name, and status.
Referenced by enable_jack_hook(), and jack_exec().
|
static |
Definition at line 695 of file app_jack.c.
References ast_calloc_with_stringfields, and NULL.
Referenced by enable_jack_hook(), and jack_exec().
|
static |
Definition at line 760 of file app_jack.c.
References AST_CONTROL_HANGUP, AST_FRAME_CONTROL, AST_FRAME_VOICE, ast_frfree, ast_read(), ast_set_read_format(), ast_set_write_format(), ast_strlen_zero, ast_waitfor(), jack_data::audiohook_format, destroy_jack_data(), ast_frame::frametype, handle_jack_audio(), handle_options(), init_jack_data(), ast_frame_subclass::integer, jack_data_alloc(), NULL, queue_voice_frame(), jack_data::stop, and ast_frame::subclass.
Referenced by load_module().
|
static |
Definition at line 833 of file app_jack.c.
References AST_AUDIOHOOK_DIRECTION_READ, AST_AUDIOHOOK_STATUS_DONE, ast_channel_datastore_find(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_format_cmp(), AST_FORMAT_CMP_NOT_EQUAL, ast_format_get_name(), AST_FRAME_VOICE, ast_log, jack_data::audiohook_format, ast_datastore::data, ast_frame_subclass::format, ast_frame::frametype, handle_jack_audio(), LOG_ERROR, LOG_WARNING, NULL, queue_voice_frame(), ast_audiohook::status, and ast_frame::subclass.
Referenced by enable_jack_hook().
|
static |
Definition at line 821 of file app_jack.c.
References destroy_jack_data().
|
static |
Definition at line 970 of file app_jack.c.
References ast_log, disable_jack_hook(), enable_jack_hook(), LOG_ERROR, and LOG_WARNING.
|
static |
Definition at line 319 of file app_jack.c.
References alloc_resampler(), handle_input(), handle_output(), jack_data::input_port, jack_data::input_resample_factor, and jack_data::output_port.
Referenced by init_jack_data().
|
static |
Definition at line 336 of file app_jack.c.
References jack_data::stop.
Referenced by init_jack_data().
|
static |
Definition at line 162 of file app_jack.c.
References ARRAY_LEN, and jack_status_table.
Referenced by log_jack_status().
|
static |
Definition at line 1038 of file app_jack.c.
References ast_custom_function_register, AST_MODULE_INFO_STANDARD_EXTENDED(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, ast_unregister_application(), ASTERISK_GPL_KEY, jack_app, and jack_exec().
|
static |
Definition at line 174 of file app_jack.c.
References ast_log, ast_str_alloca, ast_str_append(), ast_str_buffer(), ast_str_set(), first, jack_status_to_str(), LOG_NOTICE, status, and str.
Referenced by init_jack_data().
Definition at line 537 of file app_jack.c.
References alloc_resampler(), ARRAY_LEN, ast_log, ast_frame::data, LOG_ERROR, LOG_WARNING, jack_data::output_rb, jack_data::output_resample_factor, jack_data::output_resampler, ast_frame::ptr, and ast_frame::samples.
Referenced by jack_exec(), and jack_hook_callback().
|
static |
Definition at line 1028 of file app_jack.c.
References ast_custom_function_unregister(), ast_unregister_application(), and jack_app.
|
static |
Definition at line 117 of file app_jack.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 693 of file app_jack.c.
Referenced by handle_options().
|
static |
Definition at line 828 of file app_jack.c.
|
static |
Definition at line 992 of file app_jack.c.
const { ... } jack_status_table[] |
Referenced by jack_status_to_str().
jack_status_t status |
Definition at line 146 of file app_jack.c.
Referenced by __ast_pbx_run(), __bt_curdel(), __bt_delete(), __bt_get(), __bt_put(), __bt_seq(), __bt_sync(), __rec_close(), __rec_delete(), __rec_get(), __rec_iput(), __rec_put(), __rec_seq(), __rec_sync(), __rtp_recvfrom(), __rtp_sendto(), _child_handler(), _iax2_show_peers_one(), _sip_show_peer(), _sip_show_peers_one(), _stun_show_status(), acf_odbc_read(), acf_odbc_write(), action_extensionstate(), agent_function_read(), agi_exec_full(), answer(), ast_audiohook_update_status(), ast_rtp_ice_add_cand(), ast_rtp_ice_turn_request(), ast_rtp_on_ice_tx_pkt(), ast_rtp_on_turn_rx_rtcp_data(), ast_rtp_on_turn_rx_rtp_data(), ast_safe_system(), ast_sip_format_contact_ami(), ast_sip_get_contact_short_status_label(), ast_sip_get_contact_status_label(), ast_sip_send_response(), ast_sip_session_terminate(), ast_srtp_change_source(), ast_srtp_create(), ast_unreal_hangup(), callerid_read(), callerid_write(), canary_exit(), chanavail_exec(), change_favorite_icon(), channel_fax_cb(), channel_set_intercept_mode(), cli_contact_print_body(), complete_dpreply(), connectedline_read(), connectedline_write(), contact_apply_handler(), contact_remove_unreachable(), dbm_delete(), dbm_fetch(), dbm_firstkey(), dbm_nextkey(), digest_create_request_with_auth(), diversion_incoming_response(), dundi_show_peers(), filestream_destructor(), format_ami_contactlist_handler(), get_buddy_status(), handle_cc_notify(), handle_cdr_pgsql_status(), handle_cli_cdr_mysql_status(), handle_cli_iax2_show_peer(), handle_cli_realtime_mysql_status(), handle_open_receive_channel_ack_message(), handle_outgoing_response(), hsearch(), ice_create(), init_jack_data(), join_queue(), load_pjsip(), log_jack_status(), mbl_status_exec(), meetme_stasis_cb(), options_incoming_request(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), parse_status(), party_id_read(), party_id_write(), party_name_read(), party_name_write(), party_number_read(), party_number_write(), party_subaddress_read(), party_subaddress_write(), permanent_uri_handler(), publish_load_message(), qualify_contact_cb(), queue_exec(), qupd_exec(), read_exec(), readexten_exec(), rec_rdelete(), redirecting_read(), redirecting_write(), refresh_all_favorite(), registration_client_send(), reload_module(), ring_entry(), rtp_transport_wide_cc_feedback_status_append(), run_ras(), safe_exec_wait(), sdp_search(), send_expansion_icon(), send_favorite(), send_icon(), send_manager_peer_status(), send_options_response(), send_response(), sendtext_exec(), sendurl_exec(), setup_outbound_invite_auth(), shaun_of_the_dead(), show_entry_history(), sip_options_set_contact_status(), sip_publisher_service_queue(), system_create_resolver_and_set_nameservers(), system_registry_to_ami(), transfer_exec(), transport_create(), update_client_state_status(), update_status(), vm_allocate_dh(), wait_for_answer(), wait_our_turn(), xfer_client_on_evsub_state(), xmpp_pak_presence(), xmpp_pak_s10n(), and xpidf_generate_body_content().
const char* str |
Definition at line 147 of file app_jack.c.
Referenced by _free_port_cfg(), acf_cut_exec(), add_hintdevice(), add_required_respheader(), anti_injection(), aoc_charge_type_str(), aoc_charged_item_str(), aoc_rate_type_str(), aoc_scale_str(), aoc_type_of_totaling_str(), aoc_volume_unit_str(), aocmessage_get_unit_entry(), ast_ari_callback(), ast_ari_validate_date(), ast_ari_websocket_session_write(), ast_begins_with(), ast_category_get_templates(), ast_cc_agent_set_interfaces_chanvar(), ast_dump_locks(), ast_func_read(), ast_hashtab_hash_string(), ast_hashtab_hash_string_nocase(), ast_hashtab_hash_string_sax(), ast_include_rename(), ast_json_vstringf(), ast_log_show_lock(), ast_parse_digest(), ast_set_cc_interfaces_chanvar(), ast_sip_global_default_outbound_endpoint(), ast_skip_blanks(), ast_sockaddr_split_hostport(), ast_sockaddr_stringify_fmt(), ast_sockaddr_stringify_port(), ast_str_to_lower(), ast_str_to_upper(), ast_tcptls_server_start(), AST_TEST_DEFINE(), ast_trim_blanks(), build_nonce(), build_user_routes(), candidate_exten_advance(), cc_extension_monitor_init(), cc_generic_agent_start_monitoring(), check_mime(), check_tcptls_cert_name(), cli_print_body(), collect_names_cb(), contacts_to_str(), custom_log(), dbl_list_expect_reverse(), delayed_method2str(), dial_handle_playtones(), do_magic_pickup(), ext_cmp_exten_strlen(), filter_leading_space_from_exprs(), filter_newlines(), find_realtime(), format_log_json(), format_str_append_auth(), function_fieldnum_helper(), function_fieldqty_helper(), sip_to_pjsip::get_bind(), get_content(), handle_getvariablefull(), handle_playtones(), handle_show_locks(), handle_show_translation_path(), handle_tcptls_connection(), hash_string(), iax_parse_ies(), init_appendbuf(), jack_str(), jingle_new(), list_item_to_str(), load_modules(), localnet_to_str(), localnet_to_vl_append(), log_jack_status(), mansession_cmp_fn(), match_to_str(), match_to_var_list_append(), misdn_cfg_get(), misdn_cfg_get_config_string(), misdn_cfg_get_next_port(), misdn_cfg_get_ports_string(), misdn_cfg_is_group_method(), misdn_cfg_is_port_valid(), misdn_to_str_plan(), misdn_to_str_pres(), misdn_to_str_screen(), misdn_to_str_ton(), named_callgroups_to_str(), named_pickupgroups_to_str(), new_find_extension(), ParsingContext::next_stack(), parse_cdata(), pbx_retrieve_variable(), pp_each_extension_helper(), process_text_line(), pvalWordSetString(), pvt_cause_cmp_fn(), SqlConfigParser::read(), read_mf_digits(), read_sf_digits(), readwavheader(), regex(), remove_spaces_before_equals(), replace(), res_sdp_crypto_parse_offer(), rtcp_payload_type2str(), security_event_stasis_cb(), sendtext_exec(), set_var_to_str(), sip_endpoint_identifier_type2str(), sip_outbound_registration_status_str(), sip_subscription_to_ami(), smdi_ifaces_cmp_fn(), smdi_mwi_q_cmp_fn(), stasis_app_message_handler(), str_is_negative(), strreplace(), substitute_escapes(), syslog_log(), test_2way_function(), test_chan_function(), test_chan_integer(), test_chan_integer_accessor(), test_chan_string(), test_chan_variable(), test_expected_result(), tls_method_to_str(), transmit_info_with_aoc(), transform::unicode(), ustmtext(), variable_count_cmp_fn(), vm_allocate_dh(), astconfigparser::write_dicts(), and write_html_escaped().