Browse code

rtpengine: add stop_recording function

Claudiu Boriga authored on 26/09/2017 12:49:59
Showing 3 changed files
... ...
@@ -2494,6 +2494,30 @@ start_recording();
2494 2494
 		</example>
2495 2495
 	</section>
2496 2496
 
2497
+	<section id="rtpengine.f.stop_recording">
2498
+		<title>
2499
+		<function moreinfo="none">stop_recording()</function>
2500
+		</title>
2501
+		<para>
2502
+		This function will send a signal to the &rtp; relay to record
2503
+		the &rtp; stream flowing through it. See also the option
2504
+		<quote>record-call=off</quote> for rtpengine_manage()/rtpengine_offer(),
2505
+		which offers an alternative for call recording, saving also call
2506
+		metadata from SDP.
2507
+		</para>
2508
+		<para>
2509
+		This function can be used from REQUEST_ROUTE and ONREPLY_ROUTE.
2510
+		</para>
2511
+		<example>
2512
+		<title><function>stop_recording</function> usage</title>
2513
+		<programlisting format="linespecific">
2514
+...
2515
+stop_recording();
2516
+...
2517
+		</programlisting>
2518
+		</example>
2519
+	</section>
2520
+
2497 2521
 
2498 2522
 	</section>
2499 2523
 
... ...
@@ -126,6 +126,7 @@ static const char *command_strings[] = {
126 126
 	[OP_START_RECORDING]	= "start recording",
127 127
 	[OP_QUERY]		= "query",
128 128
 	[OP_PING]		= "ping",
129
+	[OP_STOP_RECORDING]	= "stop recording",
129 130
 };
130 131
 
131 132
 struct minmax_mos_stats {
... ...
@@ -166,6 +167,7 @@ struct minmax_stats_vals {
166 167
 static char *gencookie();
167 168
 static int rtpp_test(struct rtpp_node*, int, int);
168 169
 static int start_recording_f(struct sip_msg *, char *, char *);
170
+static int stop_recording_f(struct sip_msg *, char *, char *);
169 171
 static int rtpengine_answer1_f(struct sip_msg *, char *, char *);
170 172
 static int rtpengine_offer1_f(struct sip_msg *, char *, char *);
171 173
 static int rtpengine_delete1_f(struct sip_msg *, char *, char *);
... ...
@@ -282,6 +284,9 @@ static cmd_export_t cmds[] = {
282 284
 	{"start_recording",	(cmd_function)start_recording_f,	0,
283 285
 		0, 0,
284 286
 		ANY_ROUTE },
287
+	{"stop_recording",	(cmd_function)stop_recording_f, 	0,
288
+		0, 0,
289
+		ANY_ROUTE },
285 290
 	{"rtpengine_offer",	(cmd_function)rtpengine_offer1_f,	0,
286 291
 		0, 0,
287 292
 		ANY_ROUTE},
... ...
@@ -3373,12 +3378,22 @@ static int rtpengine_start_recording_wrap(struct sip_msg *msg, void *d, int more
3373 3378
 	return rtpp_function_call_simple(msg, OP_START_RECORDING, NULL);
3374 3379
 }
3375 3380
 
3381
+static int rtpengine_stop_recording_wrap(struct sip_msg *msg, void *d, int more) {
3382
+	return rtpp_function_call_simple(msg, OP_STOP_RECORDING, NULL);
3383
+}
3384
+
3376 3385
 static int
3377 3386
 start_recording_f(struct sip_msg* msg, char *foo, char *bar)
3378 3387
 {
3379 3388
 	return rtpengine_rtpp_set_wrap(msg, rtpengine_start_recording_wrap, NULL, 1);
3380 3389
 }
3381 3390
 
3391
+static int
3392
+stop_recording_f(struct sip_msg* msg, char *foo, char *bar)
3393
+{
3394
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_stop_recording_wrap, NULL, 1);
3395
+}
3396
+
3382 3397
 static int rtpengine_rtpstat_wrap(struct sip_msg *msg, void *d, int more) {
3383 3398
 	void **parms;
3384 3399
 	pv_param_t *param;
... ...
@@ -3503,6 +3518,11 @@ static int ki_start_recording(sip_msg_t *msg)
3503 3518
 	return rtpengine_rtpp_set_wrap(msg, rtpengine_start_recording_wrap, NULL, 1);
3504 3519
 }
3505 3520
 
3521
+static int ki_stop_recording(sip_msg_t *msg)
3522
+{
3523
+	return rtpengine_rtpp_set_wrap(msg, rtpengine_stop_recording_wrap, NULL, 1);
3524
+}
3525
+
3506 3526
 static int ki_set_rtpengine_set(sip_msg_t *msg, int r1)
3507 3527
 {
3508 3528
 	rtpp_set_link_t rtpl1;
... ...
@@ -3612,6 +3632,11 @@ static sr_kemi_t sr_kemi_rtpengine_exports[] = {
3612 3632
         { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
3613 3633
             SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3614 3634
     },
3635
+    { str_init("rtpengine"), str_init("stop_recording"),
3636
+        SR_KEMIP_INT, ki_stop_recording,
3637
+        { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
3638
+            SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3639
+    },
3615 3640
     { str_init("rtpengine"), str_init("set_rtpengine_set"),
3616 3641
         SR_KEMIP_INT, ki_set_rtpengine_set,
3617 3642
         { SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE,
... ...
@@ -35,6 +35,7 @@ enum rtpe_operation {
35 35
         OP_ANSWER,
36 36
         OP_DELETE,
37 37
         OP_START_RECORDING,
38
+        OP_STOP_RECORDING,
38 39
         OP_QUERY,
39 40
         OP_PING,
40 41
 };