Browse code

sbc: make rtprelay_enabled controllable via msg/hdrs/replacement

Stefan Sayer authored on 17/04/2014 00:14:02
Showing 4 changed files
... ...
@@ -227,7 +227,7 @@ void SBCCallLeg::applyAProfile()
227 227
   // apply A leg configuration (but most of the configuration is applied in
228 228
   // SBCFactory::onInvite)
229 229
 
230
-  if (call_profile.rtprelay_enabled || call_profile.transcoder.isActive()) {
230
+  if (call_profile.rtprelay_enabled_value || call_profile.transcoder.isActive()) {
231 231
     DBG("Enabling RTP relay mode for SBC call\n");
232 232
 
233 233
     setRtpRelayForceSymmetricRtp(call_profile.aleg_force_symmetric_rtp_value);
... ...
@@ -371,7 +371,7 @@ void SBCCallLeg::applyBProfile()
371 371
     dlg->setOutboundInterface(call_profile.outbound_interface_value);
372 372
 
373 373
   // was read from caller but reading directly from profile now
374
-  if (call_profile.rtprelay_enabled || call_profile.transcoder.isActive()) {
374
+  if (call_profile.rtprelay_enabled_value || call_profile.transcoder.isActive()) {
375 375
 
376 376
     if (call_profile.rtprelay_interface_value >= 0)
377 377
       setRtpInterface(call_profile.rtprelay_interface_value);
... ...
@@ -354,7 +354,7 @@ bool SBCCallProfile::readFromConfiguration(const string& name,
354 354
 
355 355
   refuse_with = cfg.getParameter("refuse_with");
356 356
 
357
-  rtprelay_enabled = cfg.getParameter("enable_rtprelay") == "yes";
357
+  rtprelay_enabled = cfg.getParameter("enable_rtprelay");
358 358
   aleg_force_symmetric_rtp = cfg.getParameter("rtprelay_force_symmetric_rtp");
359 359
   force_symmetric_rtp = aleg_force_symmetric_rtp;
360 360
   msgflags_symmetric_rtp = cfg.getParameter("rtprelay_msgflags_symmetric_rtp") == "yes";
... ...
@@ -476,8 +476,9 @@ bool SBCCallProfile::readFromConfiguration(const string& name,
476 476
     INFO("SBC:      fixing Replaces in INVITE: '%s'\n", fix_replaces_inv.c_str());
477 477
     INFO("SBC:      fixing Replaces in REFER: '%s'\n", fix_replaces_ref.c_str());
478 478
 
479
-    INFO("SBC:      RTP relay %sabled\n", rtprelay_enabled?"en":"dis");
480
-    if (rtprelay_enabled) {
479
+
480
+    INFO("SBC:      RTP relay enabled: '%s'\n", rtprelay_enabled.c_str());
481
+    if (!rtprelay_enabled.empty() && rtprelay_enabled != "no") {
481 482
       if (!force_symmetric_rtp.empty()) {
482 483
 	INFO("SBC:      RTP force symmetric RTP: %s\n",
483 484
 	     force_symmetric_rtp.c_str());
... ...
@@ -674,7 +675,7 @@ string SBCCallProfile::print() const {
674 675
   res += "auth_aleg_enabled:    " + string(auth_aleg_enabled?"true":"false") + "\n";
675 676
   res += "auth_aleg_user:       " + auth_aleg_credentials.user+"\n";
676 677
   res += "auth_aleg_pwd:        " + auth_aleg_credentials.pwd+"\n";
677
-  res += "rtprelay_enabled:     " + string(rtprelay_enabled?"true":"false") + "\n";
678
+  res += "rtprelay_enabled:     " + rtprelay_enabled + "\n";
678 679
   res += "force_symmetric_rtp:  " + force_symmetric_rtp;
679 680
   res += "msgflags_symmetric_rtp: " + string(msgflags_symmetric_rtp?"true":"false") + "\n";
680 681
   
... ...
@@ -771,9 +772,10 @@ bool SBCCallProfile::evaluate(ParamReplacerCtx& ctx,
771 772
 
772 773
   if (!transcoder.evaluate(ctx,req)) return false;
773 774
 
774
-  if (rtprelay_enabled || transcoder.isActive()) {
775
+  REPLACE_BOOL(rtprelay_enabled, rtprelay_enabled_value);
776
+
777
+  if (rtprelay_enabled_value || transcoder.isActive()) {
775 778
     // evaluate other RTP relay related params only if enabled
776
-    // FIXME: really not evaluate rtprelay_enabled itself?
777 779
     REPLACE_BOOL(force_symmetric_rtp, force_symmetric_rtp_value);
778 780
     REPLACE_BOOL(aleg_force_symmetric_rtp, aleg_force_symmetric_rtp_value);
779 781
 
... ...
@@ -187,7 +187,8 @@ struct SBCCallProfile
187 187
 
188 188
   string refuse_with;
189 189
 
190
-  bool rtprelay_enabled;
190
+  string rtprelay_enabled;
191
+  bool rtprelay_enabled_value;
191 192
   string force_symmetric_rtp;
192 193
   string aleg_force_symmetric_rtp;
193 194
   bool force_symmetric_rtp_value;
... ...
@@ -344,7 +345,7 @@ struct SBCCallProfile
344 345
     dlg_nat_handling(false),
345 346
     keep_vias(false),bleg_keep_vias(false),
346 347
     sst_enabled_value(false),
347
-    rtprelay_enabled(false),
348
+    rtprelay_enabled_value(false),
348 349
     force_symmetric_rtp_value(false),
349 350
     aleg_force_symmetric_rtp_value(false),
350 351
     rtprelay_transparent_seqno(true),
... ...
@@ -164,7 +164,7 @@ void CCCtl::start(const string& cc_name, const string& ltag,
164 164
   if (call_profile->append_headers.size() > 2)
165 165
       assertEndCRLF(call_profile->append_headers);
166 166
 
167
-  ENABLE_IN_CALL_PROFILE("rtprelay_enabled", rtprelay_enabled);
167
+  SET_TO_CALL_PROFILE("rtprelay_enabled", rtprelay_enabled);
168 168
   SET_TO_CALL_PROFILE("rtprelay_interface", rtprelay_interface);
169 169
   SET_TO_CALL_PROFILE("aleg_rtprelay_interface", aleg_rtprelay_interface);
170 170