浏览代码

Merge pull request #1253 from claudiupb/implement-stop-recording

Add stop_recording function, and make start/stop_recording functions accept flags
Richard Fuchs 8 年之前
父节点
当前提交
67f2e8d93b
共有 3 个文件被更改,包括 89 次插入4 次删除
  1. 36 1
      src/modules/rtpengine/doc/rtpengine_admin.xml
  2. 52 3
      src/modules/rtpengine/rtpengine.c
  3. 1 0
      src/modules/rtpengine/rtpengine.h

+ 36 - 1
src/modules/rtpengine/doc/rtpengine_admin.xml

@@ -2472,7 +2472,7 @@ rtpengine_manage();
 
 	<section id="rtpengine.f.start_recording">
 		<title>
-		<function moreinfo="none">start_recording()</function>
+		<function moreinfo="none">start_recording([flags])</function>
 		</title>
 		<para>
 		This function will send a signal to the &rtp; relay to record
@@ -2482,6 +2482,12 @@ rtpengine_manage();
 		metadata from SDP.
 		</para>
 		<para>
+		It can take the same parameters as <function>rtpengine_manage().</function>
+		The flags parameter to start_recording can be a configuration variable
+		containing the flags as a string.
+		The call-id flag can be used to start recording for a different call.
+		</para>
+		<para>
 		This function can be used from REQUEST_ROUTE and ONREPLY_ROUTE.
 		</para>
 		<example>
@@ -2494,6 +2500,35 @@ start_recording();
 		</example>
 	</section>
 
+	<section id="rtpengine.f.stop_recording">
+		<title>
+		<function moreinfo="none">stop_recording([flags])</function>
+		</title>
+		<para>
+		This function will send a signal to the &rtp; relay to stop recording
+		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.
+		</para>
+		<para>
+		It can take the same parameters as <function>rtpengine_manage().</function>
+		The flags parameter to start_recording can be a configuration variable
+		containing the flags as a string.
+		The call-id flag can be used to stop recording for a different call.
+		</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>
 

+ 52 - 3
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,15 @@ static cmd_export_t cmds[] = {
 	{"start_recording",	(cmd_function)start_recording_f,	0,
 		0, 0,
 		ANY_ROUTE },
+	{"start_recording",	(cmd_function)start_recording_f,	1,
+		fixup_spve_null, 0,
+		ANY_ROUTE},
+	{"stop_recording",	(cmd_function)stop_recording_f, 	0,
+		0, 0,
+		ANY_ROUTE },
+	{"stop_recording",	(cmd_function)stop_recording_f, 	1,
+		fixup_spve_null, 0,
+		ANY_ROUTE},
 	{"rtpengine_offer",	(cmd_function)rtpengine_offer1_f,	0,
 		0, 0,
 		ANY_ROUTE},
@@ -3370,13 +3381,41 @@ error:
 
 
 static int rtpengine_start_recording_wrap(struct sip_msg *msg, void *d, int more) {
-	return rtpp_function_call_simple(msg, OP_START_RECORDING, NULL);
+	return rtpp_function_call_simple(msg, OP_START_RECORDING, d);
+}
+
+static int rtpengine_stop_recording_wrap(struct sip_msg *msg, void *d, int more) {
+	return rtpp_function_call_simple(msg, OP_STOP_RECORDING, d);
 }
 
 static int
-start_recording_f(struct sip_msg* msg, char *foo, char *bar)
+start_recording_f(struct sip_msg* msg, char *str1, char *str2)
 {
-	return rtpengine_rtpp_set_wrap(msg, rtpengine_start_recording_wrap, NULL, 1);
+	str flags;
+	flags.s = NULL;
+	if (str1) {
+		if (get_str_fparam(&flags, msg, (fparam_t *) str1)) {
+			LM_ERR("Error getting string parameter\n");
+			return -1;
+		}
+	}
+
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_start_recording_wrap, flags.s, 1);
+}
+
+static int
+stop_recording_f(struct sip_msg* msg, char *str1, char *str2)
+{
+	str flags;
+	flags.s = NULL;
+	if (str1) {
+		if (get_str_fparam(&flags, msg, (fparam_t *) str1)) {
+			LM_ERR("Error getting string parameter\n");
+			return -1;
+		}
+	}
+
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_stop_recording_wrap, flags.s, 1);
 }
 
 static int rtpengine_rtpstat_wrap(struct sip_msg *msg, void *d, int more) {
@@ -3503,6 +3542,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 +3656,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,
 };