Realtime multimedia and communication in packet networks - PowerPoint PPT Presentation

About This Presentation
Title:

Realtime multimedia and communication in packet networks

Description:

Remember to check out http://www.voip-info.org/ - Check out the Cut function! ... located in /var/lib/asterisk/agi-bin in source versions of asterisk ... – PowerPoint PPT presentation

Number of Views:60
Avg rating:3.0/5.0
Slides: 15
Provided by: csR3
Category:

less

Transcript and Presenter's Notes

Title: Realtime multimedia and communication in packet networks


1
Real-time multimedia and communication in packet
networks
  • Asterisk AGI and Manager Interface

2
Last Practical
  • Create a calculator application using the
    Asterisk dialplan
  • E.g. phone an extension
  • answers and provide an IVR menu saying press 1
    to go to the calculator, 2 to go somewhere else,
    and 3 to go somewhere further
  • If I press 1 must be routed to calculator where
    I am prompted to choose to go to multiplication
    menu, division menu, add menu or subtraction menu
  • 1,2,3,4
  • Within each menu prompt user for expression
    separated by star ()?
  • So in addition menu, pressing 10020 should
    return 120
  • While in multiplication menu pressing 10020 will
    return 2000
  • Results can be played using Festival
  • After each result should have option of another
    operation or going to one of the other menus
    (-/)?
  • Remember to check out http//www.voip-info.org/ -
    Check out the Cut function!

3
Controlling Asterisk
  • Number of ways Asterisk can be controlled
  • Dialplan
  • Asterisk scheduling (call me)?
  • Asterisk Gateway Interface (AGI)?
  • Manager Interface

4
AGI
  • AGI allows us to add functionality to Asterisk
    with many different programming languages
  • Java, Perl, PHP, C, Pascal Anything!
  • Provides a standard interface through which
    programs may control asterisk
  • Used for advanced logic or to communicate with
    resources such as relational databases and
    external devices
  • Allows asterisk to perform tasks that would be
    otherwise difficult or impossible

5
AGI How it works
  • The AGI script is called from the dialplan?
  • Asterisk and your program communicate via the
    STDIN, STDOUT and STDERR communications channels
    (file handles in programming)?
  • Your AGI scripts reads input via its STDIN file
    handle
  • Your AGI script writes back to asterisk via its
    STDOUT file handle
  • Your AGI program writes error message back to
    asterisk via its STDERR file handle

6
Starting your AGI program
  • Syntax
  • exten gt extennumber,priority,application,argument
    s
  • The application is AGI
  • The argument is the filename of your program
  • The script must be
  • executable (chmod x filename)?
  • located in /var/lib/asterisk/agi-bin in source
    versions of asterisk
  • Located in /usr/share/asterisk/agi-bin in binary
    vesions of asterisk
  • Example Run a perl script agi-test.agi
  • exten gt 1,2,AGI, agi-test.agi

7
Passing args
  • exten 1,2,AGI,agi-test.agiARG1ARG2
  • AGI programs always receive two args
  • 1 path to the AGI script
  • 2 Arguments passed from the dialplan
  • Notes about arguments
  • If no arg is given the arg is empty.
  • Consists of everything on the line following the
    verticle bar after the file name, up until the
    final vertical bar?
  • Quotes are taken as being part of the argument

8
Communicating with
  • Use 'show agi' at the CLI will give you a list of
    commands
  • At script startup time, sends a group of
    variables to your script which you have to read
    in
  • Each item is sent on a line terminated with a
    newline. The last item is followed by an empty
    line
  • agi_request agi-test.agi
  • agi_channel SIP/1000-bcgd162
  • agi_language en
  • agi_context mtsietsi
  • agi_extention 105
  • agi_priority 2
  • Commands sent to must be terminated with newline

9
AGI examples?
  • Perl - /usr/share/asterisk/agi-bin/agi-test.agi
  • Java - /usr/share/asterisk/agi-bin/mosJava.java
  • /usr/share/asterisk/agi-bin/mosJava.agi

10
Manager API
  • A client/server module that allows us to interact
    with via TCP/IP
  • Similar to SMTP and HTTP
  • Communicates using tags
  • headervalue terminated with a newline
  • First tag must be one of the following
  • Action an action requested by the client.
  • Response A response to an action from Asterisk
  • Event An event reported by Asterisk to the client

11
Manager interface (login)?
  • telnet into 146.231.121.88 on port 5038
  • Login
  • Action Login
  • Username voipuser
  • Secret voipuser
  • Events off
  • /r/n

12
Manager interface (Originate)?
  • Action Originate
  • Channel SIP/1000
  • Exten s
  • Context mtsietsi
  • Priority 1
  • Timeout 10000

13
Manager interface (Monitor)?
  • Action Monitor
  • Channel SIP/ab5s51182s
  • File monitor
  • Mix 1

14
Today's Practical
  • 1) Extend your calculator to incorporate an AGI
    program
  • Do the calculation
  • Parse the numbers
  • Take a number to a power
  • Solve complex problems i.e. y ax4 ax3 ax2
    ax a
Write a Comment
User Comments (0)
About PowerShow.com