From 99429abaef3081cb2359f0aff163582dc38581fd Mon Sep 17 00:00:00 2001 From: Razvan Crainea Date: Fri, 9 Aug 2024 17:42:41 +0300 Subject: [PATCH] siprec: add start&stop events --- modules/siprec/doc/siprec_admin.xml | 46 +++++++++++++++++++++++++++++ modules/siprec/siprec_logic.c | 10 +++++++ 2 files changed, 56 insertions(+) diff --git a/modules/siprec/doc/siprec_admin.xml b/modules/siprec/doc/siprec_admin.xml index a672fe1cbaf..054092da9ba 100644 --- a/modules/siprec/doc/siprec_admin.xml +++ b/modules/siprec/doc/siprec_admin.xml @@ -231,6 +231,52 @@ modparam("siprec", "skip_failover_codes", "[34][0-9][0-9]") +
+ Exported Events +
+ + <function moreinfo="none">E_SIPREC_START</function> + + + This event is raised when a SIPREC call is established and a call + starts to be recorded. + + Parameters: + + + dlg_id - dialog id (did) + of the call being recorded; + + + dlg_callid - Call-Id of the call being + recorded; + + + callid - Call-Id (B2B id) of the + SIPREC call; + + + session_id - SIPREC UUID of the recording call; + + + server - the SIPREC server handing this call; + + +
+ +
+ + <function moreinfo="none">E_SIPREC_STOP</function> + + + This event is raised when a SIPREC call is terminated. + + This event exposes the same parameters as the + event. + +
+
+
Exported Functions
diff --git a/modules/siprec/siprec_logic.c b/modules/siprec/siprec_logic.c index b050a9ae62b..122f3047ee9 100644 --- a/modules/siprec/siprec_logic.c +++ b/modules/siprec/siprec_logic.c @@ -25,6 +25,7 @@ #include "siprec_logic.h" #include "siprec_body.h" +#include "siprec_events.h" #include "../../mod_fix.h" #include "../../error.h" @@ -75,6 +76,11 @@ int src_init(void) return -1; } + if (src_init_events() < 0) { + LM_ERR("could not initialize siprec events\n"); + return -1; + } + return 0; } @@ -151,6 +157,7 @@ int srec_stop_recording(struct src_sess *ss) LM_ERR("Cannot end recording session for key %.*s\n", req.b2b_key->len, req.b2b_key->s); srec_rtp.copy_delete(ss->rtp, &mod_name, &ss->media); + raise_siprec_stop_event(ss); src_clean_session(ss); return 0; } @@ -231,6 +238,7 @@ int srec_register_callbacks(struct src_sess *sess) "Will not be able to handle in-dialog for replicated sessions!\n"); LM_DBG("registered dialog callbacks for %p\n", sess); sess->flags |= SIPREC_DLG_CBS; + raise_siprec_start_event(sess); return 0; } @@ -288,6 +296,8 @@ static int srec_b2b_req(struct sip_msg *msg, struct src_sess *ss) if (get_body(msg, &body) != 0 || body.len==0) { if (msg->REQ_METHOD != METHOD_UPDATE) goto reply; + if (msg->REQ_METHOD == METHOD_BYE) + raise_siprec_stop_event(ss); code = 200; } else { if (srec_rtp.copy_answer(ss->rtp, &mod_name,