channel/chan_pjsip: add dialplan function for music on hold

Add a new dialplan function PJSIP_MOH_PASSTHROUGH that allows
the on-hold behavior to be controlled on a per-call basis

ASTERISK-28542 #close

Change-Id: Iebe905b2ad6dbaa87ab330267147180b05a3c3a8
This commit is contained in:
Torrey Searle
2019-09-19 10:56:26 +02:00
committed by Torrey Searle
parent 1b6513c5dd
commit b43cdc7f1e
6 changed files with 113 additions and 2 deletions

View File

@@ -1738,7 +1738,7 @@ static int chan_pjsip_indicate(struct ast_channel *ast, int condition, const voi
device_buf = alloca(device_buf_size);
ast_channel_get_device_name(ast, device_buf, device_buf_size);
ast_devstate_changed_literal(AST_DEVICE_ONHOLD, 1, device_buf);
if (!channel->session->endpoint->moh_passthrough) {
if (!channel->session->moh_passthrough) {
ast_moh_start(ast, data, NULL);
} else {
if (ast_sip_push_task(channel->session->serializer, remote_send_hold, ao2_bump(channel->session))) {
@@ -1754,7 +1754,7 @@ static int chan_pjsip_indicate(struct ast_channel *ast, int condition, const voi
device_buf = alloca(device_buf_size);
ast_channel_get_device_name(ast, device_buf, device_buf_size);
ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, 1, device_buf);
if (!channel->session->endpoint->moh_passthrough) {
if (!channel->session->moh_passthrough) {
ast_moh_stop(ast);
} else {
if (ast_sip_push_task(channel->session->serializer, remote_send_unhold, ao2_bump(channel->session))) {
@@ -3222,6 +3222,12 @@ static struct ast_custom_function dtmf_mode_function = {
.write = pjsip_acf_dtmf_mode_write
};
static struct ast_custom_function moh_passthrough_function = {
.name = "PJSIP_MOH_PASSTHROUGH",
.read = pjsip_acf_moh_passthrough_read,
.write = pjsip_acf_moh_passthrough_write
};
static struct ast_custom_function session_refresh_function = {
.name = "PJSIP_SEND_SESSION_REFRESH",
.write = pjsip_acf_session_refresh_write,
@@ -3274,6 +3280,11 @@ static int load_module(void)
goto end;
}
if (ast_custom_function_register(&moh_passthrough_function)) {
ast_log(LOG_WARNING, "Unable to register PJSIP_MOH_PASSTHROUGH dialplan function\n");
goto end;
}
if (ast_custom_function_register(&session_refresh_function)) {
ast_log(LOG_WARNING, "Unable to register PJSIP_SEND_SESSION_REFRESH dialplan function\n");
goto end;
@@ -3319,6 +3330,7 @@ end:
ast_sip_session_unregister_supplement(&call_pickup_supplement);
ast_sip_unregister_service(&refer_callback_module);
ast_custom_function_unregister(&dtmf_mode_function);
ast_custom_function_unregister(&moh_passthrough_function);
ast_custom_function_unregister(&media_offer_function);
ast_custom_function_unregister(&chan_pjsip_dial_contacts_function);
ast_custom_function_unregister(&chan_pjsip_parse_uri_function);
@@ -3346,6 +3358,7 @@ static int unload_module(void)
ast_sip_unregister_service(&refer_callback_module);
ast_custom_function_unregister(&dtmf_mode_function);
ast_custom_function_unregister(&moh_passthrough_function);
ast_custom_function_unregister(&media_offer_function);
ast_custom_function_unregister(&chan_pjsip_dial_contacts_function);
ast_custom_function_unregister(&chan_pjsip_parse_uri_function);