Table of Contents Index NMS Glossary Previous Page Next Page Version


Chapter 10

Demonstration Programs


10.1 Introduction
10.1.1 ctademo.c
10.2 Host Port to Port Connection Program: hostp2p
OAM Users
agmon Users
Running hostp2p (agmon and OAM Users)
10.3 Play and Record: playrec
10.4 Multi-Threaded Application: threads

10.1 IntroductionTop of Page

This chapter presents the demonstration programs shipped with the ADI service.

CT Access is shipped with source code for all demonstration programs. Each demonstration program is shipped as an executable program and with its source and makefiles.

Note: The demonstration programs incta and outcta demonstrate placing inbound and outbound calls. Refer to the CT Access Developer's Reference Manual for more information about these demonstration programs.

The following demonstration programs are provided with CT Access and the ADI service:
Program

Description

hostp2p

Demonstrates a live voice connection between two ports using play and record functions.

playrec

Demonstrates playing and recording using asynchronous and callback methods.

threads

A simple, multi-threaded answering machine demonstration.

xferpbx

Demonstrates transfer of a call to another extension on a PBX, Centrex, or Centrex-like switch.

Before you start the demonstration programs, ensure that:

Refer to the appropriate installation and developer's manual for details on installing the board.

10.1.1 ctademo.cTop of Page

All of the demonstration programs use a common set of high-level functions contained in ctademo.c and ctademo.h. This demonstration code provides functions for initializing CT Access, opening and closing ports, waiting for calls, placing calls, answering calls, performing record and playback operations, and collecting digits. You can use these functions as base code for developing your applications with CT Access. Note that this library of functions is for demonstration only, and is subject to change without notice.

10.2 Host Port to Port Connection Program: hostp2pTop of Page

Name

hostp2p

Purpose

Demonstrates live voice connection between two ports using play and record functions.

Usage

hostp2p options

where options are:

Option

Description

-b n

Board number. Default = 0

-B n

Second AG board number (if different).

-s [n:]m

First port DSP address. Default = 0:0

Specify only the timeslot, except for AG-24/30/48/60 boards, you must specify the MVIP stream and timeslot.

-S [n:]m

Second port DSP address. Default = 0:1

Specify only the timeslot, except for AG-24/30/48/60 boards, you must specify the MVIP stream and timeslot.

-p protocol

Protocol to run. Default = LPS0

-P protocol

Second port's protocol (if different).

-e n

Encoding type. Refer to adidef.h. Default = 10 (mu-law)

-f n

Buffer size (msec). Default = 60

-d digits

Digits to dial on port 2 (if not NOCC).

-E len:tim

Echo cancellation length:adaptime. Default = 4:100

Description

hostp2p uses simultaneous play and record of small buffers to simulate a real-time voice connection between two voice calls. It uses the asynchronous play and record functions of the ADI service.

Procedure

This procedure assumes that you are testing on an AG 2000 board with loop start line interfaces connected to phone lines. hostp2p requires rvoice.dsp and echo.dsp for an AG-8 board. hostp2p requires rvoice.m54 and echo.m54 for an AG 2000 board .

OAM UsersTop of Page

Ensure that the configuration file has SwitchConnections=Yes or Clocking.HBus.ClockMode = STANDALONE for the board you are using. This ensures that the default DSP-to-line interface connections are set up by OAM.

agmon UsersTop of Page

Ensure that the ag.cfg file has ENABLEMVIP=NO for the board you are using. This ensures that the default DSP-to-line interface connections are set up by agmon.

Running hostp2p (agmon and OAM Users)Top of Page

To run hostp2p:

  1. Start hostp2p by entering the following at the prompt:

    
    hostp2p -p lps0  -d phone_number
    hostp2p starts and the following information is displayed:
    CTA host port to port voice Demo V 1.0 (Dec 8 1997)
    Port #1: Board 0 Stream 0 Slot 0 Protocol = lps0
    Port #2: Board 0 Stream 0 Slot 1 Protocol = lps0
    Encoding = 10
    Buffer time = 60 msec
    Echocanceling length = 4 msec, adapt time= 100 msec

    Initializing and opening the CTA context...
    Daemon not running. Using process global default parms.
    Trace disabled.
    --------
    Waiting for incoming call...
    hostp2p waits for an incoming call.
  2. Place a call to the telephone line connected to port 0.

    
    The following information is displayed:
    Incoming Call...
    Answering call...
    Call connected.
    -------
    Placing a call to '5551212'...
    hostp2p places a call to the number you specified. When the called party answers, you will have a connection.

10.3 Play and Record: playrecTop of Page

Name

playrec

Purpose

Demonstrates voice play and record using asynchronous buffer submission and play and record callback routines.

Usage

playrec [options]

where options are:
Option

Description

-?

Displays command line options.

-h

Displays command line options.

-b n

Specifies the board n. Default is 0.

-s n:m

Specifies MVIP stream and timeslot. Default is 0:0.

-r

Specifies the maximum recording duration (in seconds).

-z

Specifies the application buffer size. Must be a multiple of NMS_24 frame size (62).

Featured Functions

adiPlayAsync, adiSubmitPlayBuffer, adiStartPlaying, adiRecordAsync, adiSubmitRecordBuffer, adiStartRecording, adiGetEncodingInfo

Description

This demonstration operates in two phases-asynchronous voice play and record operations and callback voice play and record operations.

If you do not specify a buffer size on the command line (-z), playrec retrieves the AG physical buffer using adiGetEncodingInfo.

The demonstration is constructed so that the play and record functions are synchronous within the application. This is a single-port, single-threaded demonstration.

Note: adiStartPlaying and adiStartRecording (and consequently, this demonstration program) are not supported while CT Access is running in Client/Server mode.

Procedure

The following procedure assumes that you are using an AG 2000 DID board with a 2500-type telephone connected to one of the lines.

To run playrec:

  1. Change to the \nms\ctaccess\demos\playrec directory.

    
    
  2. Start playrec by entering the following at the prompt:

    
    playrec [-b n -s n:m -r -z ]
    Make sure that you specify the proper board and timeslot. The default value for both arguments is 0.
    You will be prompted to record a brief message. The prompt is played using asynchronous buffer submission and you will see ADIEVN_PLAY_BUFFER_REQ displayed on your screen (assuming you haven't specified an application buffer large enough to fit the whole prompt file).
    You can terminate the prompt prematurely by entering a touchtone.
  3. At the record beep prompt, begin speaking.

    
    You should see ADIEVN_RECORD_BUFFER_FULL displayed on your screen each buffer_size time period. 
  4. You can terminate the recording prematurely by entering a touchtone, or by ceasing to speak.

    
    The recording you just made is played back. Again, the message ADIEVN_PLAY_BUFFER_REQ is displayed on your screen.
  5. Repeat steps 2 and 3. The sequence of the above procedure is repeated using callback mode. Since CT Access automatically invokes the callback routine, the displayed event messages are replaced with the corresponding callback events.

Note

This demonstration allows you to experiment with buffer sizes. The encoding format for the files is ADI_ENCODE_NMS_24, which has a 62-byte frame size. Buffer sizes you specify with the -z option must therefore be multiples of 62.

10.4 Multi-Threaded Application: threadsTop of Page

Name

threads

Purpose

Demonstrates handling multiple ports using one thread per port.

Usage

threads [options]

where options are:
Option

Description

-b n

Specifies the board number n. Default is 0.

-s n:m

Specifies the MVIP stream and timeslot for the first channel. Default is 0:0.

-n nports

The number of ports (and threads) to use. Default is 1.

-p protocol

Specifies the protocol to run. Default is lps0.

-f filename

Voice file to use for answering message. Default is answer.vce. (Encoding is assumed to be ADI_ENCODE_NMS_24.)

Featured Functions

adiAnswerCall (in DemoWaitForCall), adiReleaseCall (in DemoHangUp), adiStartPlaying (in DemoPlayFile)

Description

This demonstration application is a multi-threaded answering machine using ctademo. Each thread opens a port and repeatedly waits for calls on the port. Each time a call is received, it answers, plays the answering message, and hangs up.

adiStartPlaying (and consequently, this demonstration program) is not supported while CT Access is running in Server mode.

Procedure

Before running threads, verify that your system has the proper configuration. It should have the desired number of lines connected to loop start hybrids having the same MVIP stream and successive MVIP timeslots.

To run threads, type the following command at the prompt:

threads [-b n -s n:m -n nports -p protocol -f filename ]


Specify the MVIP stream, the lowest-numbered MVIP timeslot, and the number of timeslots to use.

The demonstration should continue to answer all of the lines until it is stopped by pressing Ctrl+C.

Note

Much of the code in threads parses and documents the command-line arguments and creates threads under various operating systems. All of the call handling is performed by RunDemo.



Table of Contents Index NMS Glossary Previous Page Next Page Version


Want to send us feedback on our documentation? Email: Tech_Pubs@nmss.com
Copyright © 2000, Natural MicroSystems, Inc. All rights reserved.