Browse code

sbc:dsm: pause/resume/mute/unmute rtp streams functions

Stefan Sayer authored on 10/11/2013 17:24:23
Showing 3 changed files
... ...
@@ -58,6 +58,13 @@ MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) {
58 58
   DEF_CMD("sbc.enableRelayDTMFReceiving", MODSBCEnableRelayDTMFReceiving);
59 59
   DEF_CMD("sbc.addToMediaProcessor", MODSBCAddToMediaProcessor);
60 60
   DEF_CMD("sbc.removeFromMediaProcessor", MODSBCRemoveFromMediaProcessor);
61
+
62
+  DEF_CMD("sbc.pauseRtpStreams", MODSBCPauseRtpStreams);
63
+  DEF_CMD("sbc.resumeRtpStreams", MODSBCResumeRtpStreams);
64
+
65
+  DEF_CMD("sbc.muteRtpStreams", MODSBCMuteRtpStreams);
66
+  DEF_CMD("sbc.unmuteRtpStreams", MODSBCUnmuteRtpStreams);
67
+
61 68
 } MOD_ACTIONEXPORT_END;
62 69
 
63 70
 MOD_CONDITIONEXPORT_BEGIN(MOD_CLS_NAME) {
... ...
@@ -295,6 +302,26 @@ EXEC_ACTION_START(MODSBCActionProfileSet) {
295 302
 		       " used without call leg");			\
296 303
   }
297 304
 
305
+#define GET_SBC_CALL_LEG(action)					\
306
+  SBCCallLeg* sbc_call_leg = dynamic_cast<SBCCallLeg*>(sess);		\
307
+  if (NULL == sbc_call_leg) {						\
308
+    DBG("script writer error: DSM action " #action			\
309
+	" used without sbc call leg\n");				\
310
+    throw DSMException("sbc", "type", "param", "cause",			\
311
+		       "script writer error: DSM action " #action	\
312
+		       " used without sbc call leg");			\
313
+  }
314
+
315
+#define GET_B2B_MEDIA							\
316
+  AmB2BMedia* b2b_media = sbc_call_leg->getMediaSession();		\
317
+  DBG("session: %p, media: %p\n", sbc_call_leg, b2b_media);		\
318
+  if (NULL == b2b_media) {						\
319
+    DBG("No B2BMedia in current SBC call leg, sorry\n");		\
320
+    sc_sess->SET_ERRNO(DSM_ERRNO_UNKNOWN_ARG);				\
321
+    sc_sess->SET_STRERROR("No B2BMedia in current SBC call leg, sorry"); \
322
+    EXEC_ACTION_STOP;							\
323
+  }
324
+
298 325
 EXEC_ACTION_START(MODSBCActionStopCall) {
299 326
   GET_CALL_LEG(StopCall);
300 327
   string cause = resolveVars(arg, sess, sc_sess, event_params);
... ...
@@ -388,17 +415,7 @@ EXEC_ACTION_START(MODSBCActionB2BRelayReliable) {
388 415
 
389 416
 CONST_ACTION_2P(MODSBCActionAddCallee, ',', false);
390 417
 EXEC_ACTION_START(MODSBCActionAddCallee) {
391
-  GET_CALL_LEG(AddCallee);
392
-
393
-  SBCCallLeg* sbc_call_leg = dynamic_cast<SBCCallLeg*>(call_leg);
394
-  if (NULL == sbc_call_leg) {
395
-    DBG("script writer error: DSM action sbc.addCallee "
396
-	" used without sbc call leg\n");
397
-    throw DSMException("sbc", "type", "param", "cause",
398
-		       "script writer error: DSM action sbc.addCallee "
399
-		       " used without call leg");
400
-    EXEC_ACTION_STOP;
401
-  }
418
+  GET_SBC_CALL_LEG(sbc.addCallee);
402 419
 
403 420
   string mode = resolveVars(par1, sess, sc_sess, event_params);
404 421
 
... ...
@@ -407,7 +424,7 @@ EXEC_ACTION_START(MODSBCActionAddCallee) {
407 424
     string hdrs;
408 425
     SBCCallLeg* peer = new SBCCallLeg(sbc_call_leg);
409 426
     SBCCallProfile &p = peer->getCallProfile();
410
-    AmB2BSession::RTPRelayMode rtp_mode = call_leg->getRtpRelayMode();
427
+    AmB2BSession::RTPRelayMode rtp_mode = sbc_call_leg->getRtpRelayMode();
411 428
 
412 429
     VarMapT::iterator it = sc_sess->var.find(varname+"." DSM_SBC_PARAM_ADDCALLEE_LOCAL_PARTY);
413 430
     if (it != sc_sess->var.end())
... ...
@@ -444,27 +461,12 @@ EXEC_ACTION_START(MODSBCActionAddCallee) {
444 461
 } EXEC_ACTION_END;
445 462
 
446 463
 EXEC_ACTION_START(MODSBCEnableRelayDTMFReceiving) {
447
-  GET_CALL_LEG(AddCallee);
448
-
449 464
   bool enable = (resolveVars(arg, sess, sc_sess, event_params)==DSM_TRUE);
450 465
 
451
-  SBCCallLeg* sbc_call_leg = dynamic_cast<SBCCallLeg*>(call_leg);
452
-  if (NULL == sbc_call_leg) {
453
-    DBG("script writer error: DSM action sbc.addCallee "
454
-	" used without sbc call leg\n");
455
-    throw DSMException("sbc", "type", "param", "cause",
456
-		       "script writer error: DSM action sbc.addCallee "
457
-		       " used without call leg");
458
-    EXEC_ACTION_STOP;
459
-  }
466
+  GET_SBC_CALL_LEG(AddCallee);
467
+  GET_B2B_MEDIA;
460 468
 
461
-  AmB2BMedia* b2b_media = sbc_call_leg->getMediaSession();
462
-  DBG("session: %p, media: %p\n", sbc_call_leg, b2b_media);
463
-  if (NULL != b2b_media) {
464
-    b2b_media->setRelayDTMFReceiving(enable);
465
-  } else {
466
-    DBG("No B2BMedia in current SBC call leg, sorry\n");
467
-  }
469
+  b2b_media->setRelayDTMFReceiving(enable);
468 470
 } EXEC_ACTION_END;
469 471
 
470 472
 EXEC_ACTION_START(MODSBCAddToMediaProcessor) {
... ...
@@ -477,4 +479,47 @@ EXEC_ACTION_START(MODSBCRemoveFromMediaProcessor) {
477 479
   GET_CALL_LEG(RemoveFromMediaProcessor);
478 480
   AmMediaProcessor::instance()->removeSession(call_leg);
479 481
 } EXEC_ACTION_END;
480
-  
482
+
483
+CONST_ACTION_2P(MODSBCPauseRtpStreams, ',', false);
484
+EXEC_ACTION_START(MODSBCPauseRtpStreams) {
485
+  bool p_a = (resolveVars(par1, sess, sc_sess, event_params)==DSM_TRUE);
486
+  bool p_b = (resolveVars(par2, sess, sc_sess, event_params)==DSM_TRUE);
487
+
488
+  GET_SBC_CALL_LEG(PauseRtpStream);
489
+  GET_B2B_MEDIA;
490
+
491
+  b2b_media->pauseStreams(p_a, p_b);
492
+} EXEC_ACTION_END;
493
+
494
+CONST_ACTION_2P(MODSBCResumeRtpStreams, ',', false);
495
+EXEC_ACTION_START(MODSBCResumeRtpStreams) {
496
+  bool p_a = (resolveVars(par1, sess, sc_sess, event_params)==DSM_TRUE);
497
+  bool p_b = (resolveVars(par2, sess, sc_sess, event_params)==DSM_TRUE);
498
+
499
+  GET_SBC_CALL_LEG(ResumeRtpStream);
500
+
501
+  GET_B2B_MEDIA;
502
+  b2b_media->resumeStreams(p_a, p_b);
503
+} EXEC_ACTION_END;
504
+
505
+CONST_ACTION_2P(MODSBCMuteRtpStreams, ',', false);
506
+EXEC_ACTION_START(MODSBCMuteRtpStreams) {
507
+  bool p_a = (resolveVars(par1, sess, sc_sess, event_params)==DSM_TRUE);
508
+  bool p_b = (resolveVars(par2, sess, sc_sess, event_params)==DSM_TRUE);
509
+
510
+  GET_SBC_CALL_LEG(muteRtpStreams);
511
+  GET_B2B_MEDIA;
512
+
513
+  b2b_media->muteStreams(p_a, p_b);
514
+} EXEC_ACTION_END;
515
+
516
+CONST_ACTION_2P(MODSBCUnmuteRtpStreams, ',', false);
517
+EXEC_ACTION_START(MODSBCUnmuteRtpStreams) {
518
+  bool p_a = (resolveVars(par1, sess, sc_sess, event_params)==DSM_TRUE);
519
+  bool p_b = (resolveVars(par2, sess, sc_sess, event_params)==DSM_TRUE);
520
+
521
+  GET_SBC_CALL_LEG(unmuteRtpStreams);
522
+  GET_B2B_MEDIA;
523
+
524
+  b2b_media->unmuteStreams(p_a, p_b);
525
+} EXEC_ACTION_END;
... ...
@@ -54,4 +54,9 @@ DEF_ACTION_1P(MODSBCEnableRelayDTMFReceiving);
54 54
 DEF_ACTION_1P(MODSBCAddToMediaProcessor);
55 55
 DEF_ACTION_1P(MODSBCRemoveFromMediaProcessor);
56 56
 
57
+DEF_ACTION_2P(MODSBCPauseRtpStreams);
58
+DEF_ACTION_2P(MODSBCResumeRtpStreams);
59
+
60
+DEF_ACTION_2P(MODSBCMuteRtpStreams);
61
+DEF_ACTION_2P(MODSBCUnmuteRtpStreams);
57 62
 #endif
... ...
@@ -209,6 +209,12 @@ sbc.enableRelayDTMFReceiving(bool rcv_dtmf)  - enable receiving of RTP DTMF in r
209 209
      note: session needs to be processed by media processor as well (sbc.addToMediaProcessor())
210 210
            so that DTMF is processed and passed up to the application (key event).
211 211
 
212
-sbc.addToMediaProcessor   - add sbc session to media processor (no playlist set etc)
212
+sbc.addToMediaProcessor      - add sbc session to media processor (no playlist set etc)
213 213
 
214 214
 sbc.removeFromMediaProcessor - remove sbc session from media processor
215
+
216
+sbc.pauseRtpStreams(bool pause_a, bool pause_b)     - pause A/B streams: drop received packets 
217
+sbc.resumeRtpStreams(bool resume_a, bool resume_b)  - resume A/B streams: process received packets 
218
+
219
+sbc.muteRtpStreams(bool mute_a, bool mute_b)        - mute A/B streams: don't send packets
220
+sbc.unmuteRtpStreams(bool unmute_a, bool unmute_b)  - unmute A/B streams: do send packets