فهرست منبع

rtpengine: add stop_recording function

Claudiu Boriga 8 سال پیش
والد
کامیت
ce5362dc46
3فایلهای تغییر یافته به همراه50 افزوده شده و 0 حذف شده
  1. 24 0
      src/modules/rtpengine/doc/rtpengine_admin.xml
  2. 25 0
      src/modules/rtpengine/rtpengine.c
  3. 1 0
      src/modules/rtpengine/rtpengine.h

+ 24 - 0
src/modules/rtpengine/doc/rtpengine_admin.xml

@@ -2494,6 +2494,30 @@ start_recording();
 		</example>
 	</section>
 
+	<section id="rtpengine.f.stop_recording">
+		<title>
+		<function moreinfo="none">stop_recording()</function>
+		</title>
+		<para>
+		This function will send a signal to the &rtp; relay to record
+		the &rtp; stream flowing through it. See also the option
+		<quote>record-call=off</quote> for rtpengine_manage()/rtpengine_offer(),
+		which offers an alternative for call recording, saving also call
+		metadata from SDP.
+		</para>
+		<para>
+		This function can be used from REQUEST_ROUTE and ONREPLY_ROUTE.
+		</para>
+		<example>
+		<title><function>stop_recording</function> usage</title>
+		<programlisting format="linespecific">
+...
+stop_recording();
+...
+		</programlisting>
+		</example>
+	</section>
+
 
 	</section>
 

+ 25 - 0
src/modules/rtpengine/rtpengine.c

@@ -126,6 +126,7 @@ static const char *command_strings[] = {
 	[OP_START_RECORDING]	= "start recording",
 	[OP_QUERY]		= "query",
 	[OP_PING]		= "ping",
+	[OP_STOP_RECORDING]	= "stop recording",
 };
 
 struct minmax_mos_stats {
@@ -166,6 +167,7 @@ struct minmax_stats_vals {
 static char *gencookie();
 static int rtpp_test(struct rtpp_node*, int, int);
 static int start_recording_f(struct sip_msg *, char *, char *);
+static int stop_recording_f(struct sip_msg *, char *, char *);
 static int rtpengine_answer1_f(struct sip_msg *, char *, char *);
 static int rtpengine_offer1_f(struct sip_msg *, char *, char *);
 static int rtpengine_delete1_f(struct sip_msg *, char *, char *);
@@ -282,6 +284,9 @@ static cmd_export_t cmds[] = {
 	{"start_recording",	(cmd_function)start_recording_f,	0,
 		0, 0,
 		ANY_ROUTE },
+	{"stop_recording",	(cmd_function)stop_recording_f, 	0,
+		0, 0,
+		ANY_ROUTE },
 	{"rtpengine_offer",	(cmd_function)rtpengine_offer1_f,	0,
 		0, 0,
 		ANY_ROUTE},
@@ -3373,12 +3378,22 @@ static int rtpengine_start_recording_wrap(struct sip_msg *msg, void *d, int more
 	return rtpp_function_call_simple(msg, OP_START_RECORDING, NULL);
 }
 
+static int rtpengine_stop_recording_wrap(struct sip_msg *msg, void *d, int more) {
+	return rtpp_function_call_simple(msg, OP_STOP_RECORDING, NULL);
+}
+
 static int
 start_recording_f(struct sip_msg* msg, char *foo, char *bar)
 {
 	return rtpengine_rtpp_set_wrap(msg, rtpengine_start_recording_wrap, NULL, 1);
 }
 
+static int
+stop_recording_f(struct sip_msg* msg, char *foo, char *bar)
+{
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_stop_recording_wrap, NULL, 1);
+}
+
 static int rtpengine_rtpstat_wrap(struct sip_msg *msg, void *d, int more) {
 	void **parms;
 	pv_param_t *param;
@@ -3503,6 +3518,11 @@ static int ki_start_recording(sip_msg_t *msg)
 	return rtpengine_rtpp_set_wrap(msg, rtpengine_start_recording_wrap, NULL, 1);
 }
 
+static int ki_stop_recording(sip_msg_t *msg)
+{
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_stop_recording_wrap, NULL, 1);
+}
+
 static int ki_set_rtpengine_set(sip_msg_t *msg, int r1)
 {
 	rtpp_set_link_t rtpl1;
@@ -3612,6 +3632,11 @@ static sr_kemi_t sr_kemi_rtpengine_exports[] = {
         { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
             SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
     },
+    { str_init("rtpengine"), str_init("stop_recording"),
+        SR_KEMIP_INT, ki_stop_recording,
+        { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+            SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+    },
     { str_init("rtpengine"), str_init("set_rtpengine_set"),
         SR_KEMIP_INT, ki_set_rtpengine_set,
         { SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,

+ 1 - 0
src/modules/rtpengine/rtpengine.h

@@ -35,6 +35,7 @@ enum rtpe_operation {
         OP_ANSWER,
         OP_DELETE,
         OP_START_RECORDING,
+        OP_STOP_RECORDING,
         OP_QUERY,
         OP_PING,
 };