Skip to content

Commit

Permalink
siprec: add start&stop events
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Aug 9, 2024
1 parent 3b65c35 commit 99429ab
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
46 changes: 46 additions & 0 deletions modules/siprec/doc/siprec_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,52 @@ modparam("siprec", "skip_failover_codes", "[34][0-9][0-9]")
</section>
</section>

<section id="exported_events" xreflabel="Exported Events">
<title>Exported Events</title>
<section id="event_E_SIPREC_START" xreflabel="E_SIPREC_START">
<title>
<function moreinfo="none">E_SIPREC_START</function>
</title>
<para>
This event is raised when a SIPREC call is established and a call
starts to be recorded.
</para>
<para>Parameters:</para>
<itemizedlist>
<listitem><para>
<emphasis>dlg_id</emphasis> - dialog id (<quote>did</quote>)
of the call being recorded;
</para></listitem>
<listitem><para>
<emphasis>dlg_callid</emphasis> - Call-Id of the call being
recorded;
</para></listitem>
<listitem><para>
<emphasis>callid</emphasis> - Call-Id (B2B id) of the
SIPREC call;
</para></listitem>
<listitem><para>
<emphasis>session_id</emphasis> - SIPREC UUID of the recording call;
</para></listitem>
<listitem><para>
<emphasis>server</emphasis> - the SIPREC server handing this call;
</para></listitem>
</itemizedlist>
</section>

<section id="event_E_SIPREC_STOP" xreflabel="E_SIPREC_STOP">
<title>
<function moreinfo="none">E_SIPREC_STOP</function>
</title>
<para>
This event is raised when a SIPREC call is terminated.
</para>
<para>This event exposes the same parameters as the
<xref linkend="event_E_SIPREC_START"/> event.
</para>
</section>
</section>

<section id="exported_functions" xreflabel="exported_functions">
<title>Exported Functions</title>
<section id="func_siprec_start_recording" xreflabel="siprec_start_recording()">
Expand Down
10 changes: 10 additions & 0 deletions modules/siprec/siprec_logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "siprec_logic.h"
#include "siprec_body.h"
#include "siprec_events.h"
#include "../../mod_fix.h"
#include "../../error.h"

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 99429ab

Please sign in to comment.