auto answer

This commit is contained in:
legop3 2026-06-14 02:36:51 -04:00
parent 46c6907f59
commit 14fecbb3e1
2 changed files with 21 additions and 7 deletions

View file

@ -88,9 +88,9 @@ means `DISCORD_OUTBOUND_SIP_HOST=192.168.0.25`.
Discord-originated calls dial the requested extension directly by default. The Discord-originated calls dial the requested extension directly by default. The
bridge also attaches common auto-answer headers (`Call-Info: bridge also attaches common auto-answer headers (`Call-Info:
<uri>;answer-after=0` and `Alert-Info: Ring Answer`) to Discord-originated <uri>;answer-after=0` and `Alert-Info: <http://127.0.0.1>;info=Ring Answer`)
outbound calls so auto-answer phones can behave more like FreePBX intercom to Discord-originated outbound calls, and appends `intercom=true` to the SIP
targets. URI, so auto-answer phones can behave more like FreePBX intercom targets.
Create a `docker-compose.yml`: Create a `docker-compose.yml`:
@ -215,8 +215,9 @@ Behavior:
- The bridge dials the requested extension through the configured PBX target. - The bridge dials the requested extension through the configured PBX target.
- It dials the requested extension directly, for example - It dials the requested extension directly, for example
`sip:1101@192.168.0.25:5060;transport=udp`. `sip:1101@192.168.0.25:5060;transport=udp`.
- Discord-originated outbound calls also include common auto-answer headers so - Discord-originated outbound calls also include auto-answer headers and append
phones configured for that behavior can answer immediately. `intercom=true` to the SIP URI so phones configured for that behavior can
answer immediately.
- When the SIP side answers, the phone call is connected to the Discord voice - When the SIP side answers, the phone call is connected to the Discord voice
channel where the command was run. channel where the command was run.

View file

@ -530,8 +530,20 @@ fn make_outbound_call(
) -> Result<CallId, SipCallError> { ) -> Result<CallId, SipCallError> {
unsafe { unsafe {
use self::ffi::pj_str::make_string_hdr; use self::ffi::pj_str::make_string_hdr;
let outbound_uri = if auto_answer {
if sip_uri.contains("intercom=true") {
sip_uri.to_string()
} else if let Some((base, params)) = sip_uri.split_once(';') {
format!("{base};intercom=true;{params}")
} else {
format!("{sip_uri};intercom=true")
}
} else {
sip_uri.to_string()
};
let uri = let uri =
std::ffi::CString::new(sip_uri).map_err(|source| SipCallError::InvalidString { std::ffi::CString::new(outbound_uri).map_err(|source| SipCallError::InvalidString {
field: "sip_uri", field: "sip_uri",
source, source,
})?; })?;
@ -565,7 +577,8 @@ fn make_outbound_call(
call_info as *mut ::pjsua::pj_list_type, call_info as *mut ::pjsua::pj_list_type,
); );
let alert_info = make_string_hdr(pool, c"Alert-Info", "Ring Answer") let alert_info =
make_string_hdr(pool, c"Alert-Info", "<http://127.0.0.1>;info=Ring Answer")
.map_err(|_| SipCallError::MakeCall(-1))?; .map_err(|_| SipCallError::MakeCall(-1))?;
::pjsua::pj_list_insert_before( ::pjsua::pj_list_insert_before(
&mut msg_data_ptr.hdr_list as *mut _ as *mut ::pjsua::pj_list_type, &mut msg_data_ptr.hdr_list as *mut _ as *mut ::pjsua::pj_list_type,