Browse code

dsm:sbc: sample application

Stefan Sayer authored on 11/03/2014 18:30:22
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,18 @@
1
+ simple DSM SBC test app  -  disconnect B leg after a timer, play a file in the A leg after that
2
+
3
+ how to use (running from within source dir, in core/):
4
+  cd core/etc
5
+  ln -s ../../doc/dsm/examples/sbc/sbc_test_app/profile/sbc_test_app_profile.sbcprofile.conf .
6
+  mkdir sbc ; cd sbc
7
+  ln -s ../../doc/dsm/examples/sbc/sbc_test_app/sbc_test_app.conf .
8
+  
9
+ corresponding sbc.conf section - load cc_dsm cc plugin:
10
+   load_cc_plugins=cc_dsm
11
+   profiles=sbc_test_app_profile
12
+   active_profile=sbc_test_app_profile
13
+
14
+ corresponding dsm.conf :
15
+   conf_dir=etc/sbc
16
+
17
+
18
+
0 19
new file mode 100644
... ...
@@ -0,0 +1,27 @@
1
+#
2
+# DSM SBC test app profile
3
+#
4
+#
5
+# how to use (from source dir):
6
+#  cd core/etc
7
+#  ln -s ../../doc/dsm/examples/sbc/sbc_test_app/profile/sbc_test_app_profile.sbcprofile.conf .
8
+#  mkdir sbc ; cd sbc
9
+#  ln -s ../../doc/dsm/examples/sbc/sbc_test_app/sbc_test_app.conf .
10
+#  
11
+# corresponding sbc.conf section - load cc_dsm cc plugin:
12
+#   load_cc_plugins=cc_dsm
13
+#   profiles=sbc_test_app_profile
14
+#   active_profile=sbc_test_app_profile
15
+#
16
+# corresponding dsm.conf :
17
+#   conf_dir=etc/sbc
18
+
19
+
20
+RURI=sip:echo@192.168.5.110:5088
21
+
22
+call_control=cc_dsm
23
+cc_dsm_module=cc_dsm
24
+cc_dsm_app_bundle=sbc_test_app
25
+cc_dsm_start_diag=test_sbc
26
+
27
+enable_rtprelay=yes
0 28
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+
2
+# configuration for SBC DSM app
3
+
4
+# DSM configuration
5
+diag_path=../doc/dsm/examples/sbc/sbc_test_app
6
+load_diags=test_sbc
7
+register_apps=test_sbc
8
+
9
+mod_path=../apps/dsm/mods/lib/
10
+run_invite_event=yes
11
+set_param_variables=yes
12
+
13
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- --- ----
14
+# application configuration:
15
+
16
+my_config_var=val
0 17
new file mode 100644
... ...
@@ -0,0 +1,63 @@
1
+--
2
+-- simple DSM/SBC example: disconnect B leg after a timer, play a file in the A leg after that
3
+--
4
+
5
+import(mod_dlg);
6
+import(mod_sbc);
7
+import(mod_utils);
8
+
9
+initial state START enter {
10
+  log(3, "entering START state");
11
+};
12
+
13
+transition "init event" START - start / {
14
+  log(3, "initializing");
15
+  logAll(3);
16
+
17
+  if sbc.isALeg() {
18
+    log(3, "this is an A leg");
19
+    setTimer(1, 10);
20
+  } else {
21
+    log(3, "this is a B leg");
22
+  }
23
+} -> RUN;
24
+
25
+state RUN;
26
+
27
+transition "state changed" RUN - legStateChange / logParams(3) -> RUN;
28
+
29
+transition "timer hit" RUN - timer(#id == 1) / {
30
+  -- save other leg's ltag
31
+  dlg.getOtherId($b_ltag);
32
+
33
+  -- don't send hold, keep media session
34
+  sbc.disconnect(false, true);
35
+  
36
+  -- instruct other leg to hang up
37
+  set($cmd="hangup");
38
+  set($call_id=@local_tag);
39
+  postEvent($b_ltag, cmd;call_id);
40
+
41
+  setInputPlaylist();
42
+  connectMedia();
43
+  playFile("wav/default_en.wav");
44
+  sbc.streamsSetReceiving(false, false);
45
+
46
+} -> PLAYING_FILE;
47
+
48
+state PLAYING_FILE;
49
+
50
+transition "file ended" PLAYING_FILE - noAudio / {
51
+  -- use sbc.stopCall, otherwise RTP relay may still be active
52
+  sbc.stopCall("normal-call-clearance");
53
+} -> END;
54
+
55
+-- B leg side 
56
+transition "got disconnect cmd" RUN - event(#cmd=="hangup") / {
57
+  -- disconnect our leg from the other, too
58
+  sbc.disconnect(false, true);
59
+  -- stop our call leg
60
+  sbc.stopCall("normal-call-clearance");
61
+} -> END;
62
+
63
+state END;
0 64
\ No newline at end of file