root/contributed_modules/modules/extaudio/functions.inc.php

Revision 6042, 3.1 kB (checked in by Nick_Lewis, 5 years ago)

New External Audio Module for paging to Public Address Systems

Line 
1 <?php
2
3 // The destinations this module provides
4 // returns a associative arrays with keys 'destination' and 'description'
5 function extaudio_destinations() {
6     //static destinations
7     $extens = array();
8     $extens[] = array('destination' => 'app-extaudio,audioout,1', 'description' => 'Ext Audio Out');
9
10     if (isset($extens))
11         return $extens;
12     else
13         return null;
14
15 }
16
17 /*     Generates dialplan for "extaudio" components
18     We call this with retrieve_conf
19 */
20 function extaudio_get_config($engine) {
21
22     global $ext;
23     switch($engine) {
24         case "asterisk":
25
26 // Volume settings
27
28             $sql = "SELECT value FROM extaudio WHERE variable = 'lineoutvol'";
29             $result = sql($sql,"getRow",DB_FETCHMODE_ASSOC);
30             $lineoutvol = $result['value'];
31             if (!isset($lineoutvol)) {
32                             echo("Warning - No lineoutvol setting\n");
33                             $lineoutvol = 50;
34                             }
35             $command = "amixer set Master " . $lineoutvol . "% unmute";
36             exec($command,$output,$status);
37             if ($status) {echo($output);}
38
39
40             $sql = "SELECT value FROM extaudio WHERE variable = 'capturevol'";
41             $result = sql($sql,"getRow",DB_FETCHMODE_ASSOC);
42             $capturevol = $result['value'];
43             if (!isset($capturevol)) {
44                             echo("Warning - No capturevol setting\n");
45                             $capturevol = 50;
46                             }
47
48             //capture volume seems to cause distortion above 25%
49             $reducedcapturevol = $capturevol / 4;
50
51             $command = "amixer set Capture " . $reducedcapturevol . "% unmute";
52             exec($command,$output,$status);
53             if ($status) {echo($output);}
54
55
56             $sql = "SELECT value FROM extaudio WHERE variable = 'pagingvol'";
57             $result = sql($sql,"getRow",DB_FETCHMODE_ASSOC);
58             $pagingvol = $result['value'];
59             if (!isset($pagingvol)) {
60                             echo("Warning - No pagingvol setting\n");
61                             $pagingvol = 100;
62                             }
63             $command = "amixer set PCM " . $pagingvol . "% unmute";
64             exec($command,$output,$status);
65             if ($status) {echo($output);}
66
67
68             $sql = "SELECT value FROM extaudio WHERE variable = 'muzakvol'";
69             $result = sql($sql,"getRow",DB_FETCHMODE_ASSOC);
70             $muzakvol = $result['value'];
71             if (!isset($muzakvol)) {
72                             echo("Warning - No muzakvol setting\n");
73                             $muzakvol = 100;
74                             }
75             $command = "amixer set Line " . $muzakvol . "% unmute cap";
76             exec($command,$output,$status);
77             if ($status) {echo($output);}
78
79             $pagingmuzak = "/usr/bin/amixer set Line 0% unmute cap";
80             $nopagingmuzak = "/usr/bin/amixer set Line " . $muzakvol . "% unmute cap";
81
82
83 // "extaudio" destinations
84             $ext->add('app-extaudio', 'audioout', '', new ext_noop('External Audio Out'));
85             $ext->add('app-extaudio', 'audioout', '', new ext_ringing());
86             $ext->add('app-extaudio', 'audioout', '', new ext_wait(1));
87             $ext->add('app-extaudio', 'audioout', '', new ext_playback(public_address_system));
88             $ext->add('app-extaudio', 'audioout', '', new ext_playback(beep));
89             $ext->add('app-extaudio', 'audioout', '', new ext_system($pagingmuzak));
90             $ext->add('app-extaudio', 'audioout', '', new ext_dial("console/dsp,20,A(beep)"));
91             $ext->add('app-extaudio', 'h', '', new ext_noop('Hungup so returning to normal extaudio settings'));
92             $ext->add('app-extaudio', 'h', '', new ext_system($nopagingmuzak));
93             $ext->add('app-extaudio', 'h', '', new ext_hangup());
94
95     break;
96     }
97 }
98
99
100
101 ?>
Note: See TracBrowser for help on using the browser.