Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
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.
#define RINGBUFFER_FRAME_CAPACITY 100 |
Definition at line 64 of file app_jack.c.
anonymous enum |
Enumerator | |
---|---|
OPT_SERVER_NAME | |
OPT_INPUT_PORT | |
OPT_OUTPUT_PORT | |
OPT_NOSTART_SERVER | |
OPT_CLIENT_NAME |
Definition at line 667 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 675 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, input(), 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" | |||
) |
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 940 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, jack_hook_ds_info, LOG_WARNING, and NULL.
Referenced by jack_hook_write().
|
static |
Definition at line 873 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(), jack_hook_ds_info, 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 619 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 707 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_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 options.
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, buf, 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 693 of file app_jack.c.
References ast_calloc_with_stringfields, and NULL.
Referenced by enable_jack_hook(), and jack_exec().
|
static |
Definition at line 758 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 831 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, jack_data::audiohook_format, ast_datastore::data, ast_frame_subclass::format, ast_frame::frametype, handle_jack_audio(), jack_hook_ds_info, LOG_ERROR, LOG_WARNING, NULL, queue_voice_frame(), ast_audiohook::status, and ast_frame::subclass.
Referenced by enable_jack_hook().
|
static |
Definition at line 819 of file app_jack.c.
References destroy_jack_data().
|
static |
Definition at line 968 of file app_jack.c.
References ast_log, disable_jack_hook(), enable_jack_hook(), LOG_ERROR, LOG_WARNING, and value.
|
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, jack_status_table, and status.
Referenced by log_jack_status().
|
static |
Definition at line 1036 of file app_jack.c.
References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, ast_unregister_application(), jack_app, jack_exec(), and jack_hook_function.
|
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, prefix, 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 1026 of file app_jack.c.
References ast_custom_function_unregister(), ast_unregister_application(), jack_app, and jack_hook_function.
|
static |
Definition at line 117 of file app_jack.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 691 of file app_jack.c.
Referenced by handle_options().
|
static |
Definition at line 826 of file app_jack.c.
Referenced by disable_jack_hook(), enable_jack_hook(), and jack_hook_callback().
|
static |
Definition at line 990 of file app_jack.c.
Referenced by load_module(), and unload_module().
const struct { ... } 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(), _stun_show_status(), acf_odbc_read(), acf_odbc_write(), action_extensionstate(), agent_function_read(), agi_exec_full(), analog_publish_dnd_state(), answer(), ast_audiohook_update_status(), ast_privacy_set(), ast_safe_system(), ast_sip_create_dialog_uas(), ast_sip_create_dialog_uas_locked(), 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_system_publish_registry(), AST_TEST_DEFINE(), ast_unreal_hangup(), callerid_read(), callerid_write(), canary_exit(), chan_pjsip_incoming_response(), chan_pjsip_incoming_response_update_cause(), 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(), create_dialog_uas(), dbm_delete(), dbm_fetch(), dbm_firstkey(), dbm_nextkey(), digest_create_request_with_auth(), diversion_incoming_response(), diversion_outgoing_response(), dundi_show_peers(), filestream_destructor(), format_ami_contactlist_handler(), func_channel_read(), get_buddy_status(), handle_cdr_pgsql_status(), handle_cli_iax2_show_peer(), handle_cli_realtime_mysql_status(), handle_include_exec(), handle_incoming_response(), handle_outgoing_response(), hfp_send_clip(), hfp_send_cmer(), hsearch(), iax2_publish_registry(), identify_module(), incoming_response(), init_jack_data(), jack_status_to_str(), join_queue(), load_pjsip(), log_jack_status(), mbl_status_exec(), meetme_stasis_cb(), member_status_available(), modlist_modentry(), options_incoming_request(), party_id_read(), party_id_write(), party_name_read(), party_name_write(), party_number_read(), party_number_write(), party_subaddress_read(), party_subaddress_write(), path_outgoing_response(), peer_status(), permanent_uri_handler(), process_log_list(), process_module_list(), publish_dial_end_event(), publish_dnd_state(), publish_load_message(), publish_load_message_type(), publish_unload_message(), qualify_contact_cb(), queue_exec(), qupd_exec(), read_exec(), readexten_exec(), reason_header_outgoing_response(), rec_rdelete(), redirecting_read(), redirecting_write(), refer_client_on_evsub_state(), refresh_all_favorite(), registrar_add_unreachable(), registration_client_send(), reload_module(), remove_from_queue(), report_fax_status(), rfc3326_incoming_response(), rfc3326_outgoing_response(), ring_entry(), rtp_transport_wide_cc_feedback_status_append(), rtp_transport_wide_cc_feedback_status_vector_append(), run_agi(), safe_exec_wait(), sdp_search(), send_expansion_icon(), send_expansion_short(), send_favorite(), send_favorite_selected(), send_favorite_short(), send_icon(), send_options_response(), send_response(), sendtext_exec(), session_inv_on_media_update(), session_on_rx_response(), setup_outbound_invite_auth(), shaun_of_the_dead(), show_entry_history(), sip_options_notify_endpoint_state_compositors(), sip_options_set_contact_status(), sip_options_update_endpoint_state_compositor_aor(), sip_publisher_service_queue(), sms_log(), system_create_resolver_and_set_nameservers(), system_registry_to_ami(), t38_reinvite_response_cb(), transfer_exec(), transport_create(), update_client_state_status(), update_status(), verify_log_result(), 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 acf_cut_exec(), active_channels_to_str(), add_hintdevice(), add_user_extension(), analog_my_getsigstr(), anti_injection(), aoc_charge_type_str(), aoc_charged_item_str(), aoc_rate_type_str(), aoc_scale_str(), aoc_time_scale_str(), aoc_type_of_totaling_str(), aoc_volume_unit_str(), aocmessage_get_unit_entry(), append_event(), append_json(), append_json_single(), 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_copy_string(), ast_ends_with(), ast_event_append_ie_str(), ast_format_generate_sdp_fmtp(), ast_func_read(), ast_func_read2(), ast_get_character_str(), ast_get_digit_str(), ast_get_money_en_dollars_str(), ast_get_money_str(), ast_get_phonetic_str(), ast_hashtab_hash_string(), ast_hashtab_hash_string_nocase(), ast_hashtab_hash_string_sax(), ast_include_rename(), ast_json_utf8_check(), ast_json_utf8_check_len(), ast_json_vstringf(), ast_parse_digest(), ast_say_character_str(), ast_say_digit_str(), ast_say_money_str(), ast_say_phonetic_str(), ast_set_cc_interfaces_chanvar(), ast_sip_global_default_outbound_endpoint(), ast_sip_pubsub_generate_body_content(), ast_sip_rdata_get_header_value(), ast_sip_security_mechanisms_to_str(), ast_skip_blanks(), ast_sockaddr_parse(), ast_sockaddr_resolve(), ast_sockaddr_split_hostport(), ast_sockaddr_stringify_fmt(), ast_str_case_hash(), ast_str_expr(), ast_str_get_encoded_str(), ast_str_hash(), ast_str_hash_add(), ast_str_retrieve_variable(), ast_str_to_imax(), ast_str_to_int(), ast_str_to_long(), ast_str_to_lower(), ast_str_to_uint(), ast_str_to_ulong(), ast_str_to_umax(), ast_str_to_upper(), ast_str_to_uuid(), ast_stream_str2state(), ast_string_to_time_t(), ast_tcptls_server_start(), ast_term_color_code(), AST_TEST_DEFINE(), ast_translate_path_to_str(), ast_trim_blanks(), ast_variable_list_join(), astman_append_json(), base64_helper(), blacklist_read2(), build_cc_interfaces_chanvar(), build_nonce(), build_user_routes(), candidate_exten_advance(), CB_ADD(), CB_ADD_LEN(), cc_extension_monitor_init(), cc_generic_agent_start_monitoring(), cc_unique_append(), celt_generate_sdp_fmtp(), check_event(), check_expr2_input(), check_mime(), cli_print_body(), collect_names_cb(), contacts_to_str(), coreshowchannelmap_add_to_map(), count_linefeeds(), custom_log(), dbl_list_expect_reverse(), delayed_method2str(), dial_handle_playtones(), dialog_info_to_string(), do_print(), dundi_ie_append_str(), ext_cmp_exten_strlen(), file_extension_from_string(), filter_leading_space_from_exprs(), filter_newlines(), find_realtime(), format_log_json(), format_str_append_auth(), function_fieldnum_helper(), function_fieldqty_helper(), g729_generate_sdp_fmtp(), geoloc_config_list_locations(), sip_to_pjsip::get_bind(), get_ipaddress(), h263_generate_sdp_fmtp(), h264_generate_sdp_fmtp(), handle_getvariablefull(), handle_playtones(), handle_show_translation_path(), handle_tcptls_connection(), hash_string(), iax_frame_subclass2str(), iax_ie_append_str(), iax_parse_ies(), ilbc_generate_sdp_fmtp(), import_helper(), import_read2(), init_appendbuf(), internalerror(), internaloutput(), is_really_num(), jack_str(), jingle_new(), json_decode_read(), json_utf8_check_full(), list_item_to_str(), LLB_ADD(), load_modules(), localnet_to_str(), localnet_to_vl_append(), log_jack_status(), mansession_cmp_fn(), match_count(), match_to_str(), match_to_var_list_append(), mwi_subscription_mailboxes_str(), mwi_to_string(), my_getsigstr(), named_callgroups_to_str(), named_pickupgroups_to_str(), new_find_extension(), ParsingContext::next_stack(), opus_generate_sdp_fmtp(), parse_cdata(), pbx_retrieve_variable(), pidf_to_string(), pjsip_enable_logger_method(), pjstr_hash(), pjstr_hash_add(), pl_append(), pp_each_extension_helper(), pp_each_user_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(), say_character_str_full(), say_digit_str_full(), say_money_str_full(), say_phonetic_str_full(), security_event_stasis_cb(), security_mechanism_to_str(), sendtext_exec(), set2(), set_var_to_str(), silk_generate_sdp_fmtp(), sip_endpoint_identifier_str2type(), sip_endpoint_identifier_type2str(), sip_is_token(), sip_outbound_registration_status_str(), sip_subscription_to_ami(), siren14_generate_sdp_fmtp(), siren7_generate_sdp_fmtp(), smdi_ifaces_cmp_fn(), smdi_mwi_q_cmp_fn(), stackpeek_read(), stasis_app_message_handler(), stasis_app_recording_if_exists_parse(), stasis_app_recording_termination_parse(), str2tech(), str_is_negative(), strbetween(), strreplace(), substitute_escapes(), tdd_generate(), test_2way_function(), test_chan_function(), test_chan_integer(), test_chan_integer_accessor(), test_chan_string(), test_chan_variable(), test_core_format_generate_sdp_fmtp(), test_expected_result(), transform::unicode(), ustmtext(), validate_location_info(), variable_count_cmp_fn(), vp8_generate_sdp_fmtp(), astconfigparser::write_dicts(), write_html_escaped(), xpidf_to_string(), and yyparse().