130 likes | 400 Vues
Michael P. Plezbert Agilis Systems, Inc St. Louis Java Users Group April 13, 2006. VoIP, Asterisk, and Java. Overview. VoIP Basics Asterisk PBX Asterisk Gateway Interface Manager Interface Asterisk-Java Library Example Security Resources About Us. VoIP.
E N D
Michael P. Plezbert Agilis Systems, Inc St. Louis Java Users Group April 13, 2006 VoIP, Asterisk, and Java
Overview • VoIP Basics • Asterisk PBX • Asterisk Gateway Interface • Manager Interface • Asterisk-Java Library • Example • Security • Resources • About Us
VoIP • Two-way (pseudo-) real-time audio communication over IP network • Allows “free” computer-to-computer calls (disregarding broadband connection fees), e.g. Skype • Calls to “regular” phone network requires specialized hardware or service provider, e.g. Vonage
Cons Reliability of data network becomes paramount Latency and jitter are problems, requiring overallocation of bandwidth and/or QoS Requires VoIP phones or other specialized hardware to emulate traditional phone experience VoIP • Pros • Allows use of single network for voice and data • Cost savings over traditional PBX • Can leverage IT support staff • Easier interaction with computer/data systems
Asterisk PBX • Open source software PBX system • Runs on commodity computer hardware (x86) and software (linux/BSD) • Supports standard VoIP protocols • Hardware available for connection to POTS network • Many features built in, e.g. voicemail, call queues, conference calls
Asterisk Interaction • Asterisk can communicate with external programs in several ways • Call a local script • More suitable for scripting languages than Java • Connect via socket to an “AGI server” • Simple text messages back and forth • Server can be written in any language that supports socket comm • Cannot be used to originate calls • Accept socket (telnet) connections to a manager interface • Can be used to originate calls and receive other events • Read local “call files” • Simple way to originate calls
Asterisk Gateway Interface 1: a call comes into the asterisk server 2: the asterisk server makes a socket connection to an AGI server 3: the AGI server sends commands and receives results over the socket, controlling the flow of the call • Note that the AGI server cannot originate a call using this interface
AGI Commands • The AGI contains many commands for controlling a call, including • answer • hangup • stream file • Limited to streaming local sound files on the asterisk server, NOT over the socket interface • wait for digit • record file • Records to local file on the asterisk server
Manager Interface 1: client connects via socket to the asterisk manager interface and initiates a call 2: asterisk server places the call 3: when call connects, asterisk server connects via socket to the AGI server 4: the AGI server can send commands and receive results and events over both the AGI socket connection and the manager interface connection
The Asterisk-Java Library • Implements both the AGI server interface and the manager client interface • Contains classes and methods for sending commands and receiving events • Eliminates the need to manually build or parse command strings
An Example Simple example will Originate a call Play a sound file Wait up to 5 seconds for a response If 1, 2, or 3 is pressed then Play sound files indicating digit pressed Else Play sound file indicating invalid choice Hangup
Security • VPN or ssl-tunnel suggested • Socket comm is plain text (including authentication to manager interface) • AGI connection is not authenticated • Asterisk configuration • Limit accessibility of external calls
Resources • Asterisk: • http://www.asterisk.org • Asterisk@Home: • http://asteriskathome.sourceforge.net • Asterisk-Java Library: • http://www.asteriskjava.org • http://sourceforge.net/projects/asterisk-java