Bläddra i källkod

rtpengine: make start_recording and stop_recording accept flags

Claudiu Boriga 8 år sedan
förälder
incheckning
45b4d35f72
2 ändrade filer med 46 tillägg och 11 borttagningar
  1. 16 5
      src/modules/rtpengine/doc/rtpengine_admin.xml
  2. 30 6
      src/modules/rtpengine/rtpengine.c

+ 16 - 5
src/modules/rtpengine/doc/rtpengine_admin.xml

@@ -2472,7 +2472,7 @@ rtpengine_manage();
 
 
 	<section id="rtpengine.f.start_recording">
 	<section id="rtpengine.f.start_recording">
 		<title>
 		<title>
-		<function moreinfo="none">start_recording()</function>
+		<function moreinfo="none">start_recording([flags])</function>
 		</title>
 		</title>
 		<para>
 		<para>
 		This function will send a signal to the &rtp; relay to record
 		This function will send a signal to the &rtp; relay to record
@@ -2482,6 +2482,12 @@ rtpengine_manage();
 		metadata from SDP.
 		metadata from SDP.
 		</para>
 		</para>
 		<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.
 		This function can be used from REQUEST_ROUTE and ONREPLY_ROUTE.
 		</para>
 		</para>
 		<example>
 		<example>
@@ -2496,14 +2502,19 @@ start_recording();
 
 
 	<section id="rtpengine.f.stop_recording">
 	<section id="rtpengine.f.stop_recording">
 		<title>
 		<title>
-		<function moreinfo="none">stop_recording()</function>
+		<function moreinfo="none">stop_recording([flags])</function>
 		</title>
 		</title>
 		<para>
 		<para>
-		This function will send a signal to the &rtp; relay to record
+		This function will send a signal to the &rtp; relay to stop recording
 		the &rtp; stream flowing through it. See also the option
 		the &rtp; stream flowing through it. See also the option
 		<quote>record-call=off</quote> for rtpengine_manage()/rtpengine_offer(),
 		<quote>record-call=off</quote> for rtpengine_manage()/rtpengine_offer(),
-		which offers an alternative for call recording, saving also call
-		metadata from SDP.
+		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>
 		<para>
 		<para>
 		This function can be used from REQUEST_ROUTE and ONREPLY_ROUTE.
 		This function can be used from REQUEST_ROUTE and ONREPLY_ROUTE.

+ 30 - 6
src/modules/rtpengine/rtpengine.c

@@ -284,9 +284,15 @@ static cmd_export_t cmds[] = {
 	{"start_recording",	(cmd_function)start_recording_f,	0,
 	{"start_recording",	(cmd_function)start_recording_f,	0,
 		0, 0,
 		0, 0,
 		ANY_ROUTE },
 		ANY_ROUTE },
+	{"start_recording",	(cmd_function)start_recording_f,	1,
+		fixup_spve_null, 0,
+		ANY_ROUTE},
 	{"stop_recording",	(cmd_function)stop_recording_f, 	0,
 	{"stop_recording",	(cmd_function)stop_recording_f, 	0,
 		0, 0,
 		0, 0,
 		ANY_ROUTE },
 		ANY_ROUTE },
+	{"stop_recording",	(cmd_function)stop_recording_f, 	1,
+		fixup_spve_null, 0,
+		ANY_ROUTE},
 	{"rtpengine_offer",	(cmd_function)rtpengine_offer1_f,	0,
 	{"rtpengine_offer",	(cmd_function)rtpengine_offer1_f,	0,
 		0, 0,
 		0, 0,
 		ANY_ROUTE},
 		ANY_ROUTE},
@@ -3375,23 +3381,41 @@ error:
 
 
 
 
 static int rtpengine_start_recording_wrap(struct sip_msg *msg, void *d, int more) {
 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) {
 static int rtpengine_stop_recording_wrap(struct sip_msg *msg, void *d, int more) {
-	return rtpp_function_call_simple(msg, OP_STOP_RECORDING, NULL);
+	return rtpp_function_call_simple(msg, OP_STOP_RECORDING, d);
 }
 }
 
 
 static int
 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
 static int
-stop_recording_f(struct sip_msg* msg, char *foo, char *bar)
+stop_recording_f(struct sip_msg* msg, char *str1, char *str2)
 {
 {
-	return rtpengine_rtpp_set_wrap(msg, rtpengine_stop_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_stop_recording_wrap, flags.s, 1);
 }
 }
 
 
 static int rtpengine_rtpstat_wrap(struct sip_msg *msg, void *d, int more) {
 static int rtpengine_rtpstat_wrap(struct sip_msg *msg, void *d, int more) {