# Setting up the NaturalAccess environment

Before calling functions from the MSPP API, an application initializes NaturalAccess and opens the NaturalAccess services it will use (including MSPP). Applications can use only services initialized with ctaInitialize. To set up NaturalAccess:

Step | Action
1 | Initialize NaturalAccess and its services.
2 | Create event queues and contexts (associated with existing event queues).
3 | Opening MSPP API instances on contexts.

To initialize NaturalAccess and its services, invoke ctaInitialize and specify the names of the services and service managers the application will use.

The following table lists some of the services and service managers that Fusion applications can use:

This service... | With this service manager... | Provides...
MSP | MSPMGR | Media channel processing and control
ADI | ADIMGR | DTMF detection, tone generation, etc.
NCC | ADIMGR | PSTN call control
SWI | SWIMGR | CT bus switching functions
VCE | VCEMGR | Voice message play and record

For a list of standard NaturalAccess services, refer to the Dialogic® NaturalAccess™ Software Developer's Manual.

## Creating event queues and contexts

After initializing NaturalAccess and its services, the application does the following:

Step | Action
1 | Creates one or more event queues by invoking ctaCreateQueue. Specify which service managers to attach to each queue. The MSPP API uses the MSPMGR service manager.
2 | Creates contexts by invoking ctaCreateContext and providing a queue handle (ctaqueuehd) returned from a previous call to ctaCreateQueue. Events for any services opened on the context are later routed to the associated event queue.

ctaCreateContext returns a context handle (ctahd). The application must specify a valid ctahd when invoking MSPP functions. Events communicated back to the application are associated with the specified context handle. For more information about NaturalAccess programming models and managing contexts and queues, refer to the Dialogic® NaturalAccess™ Software Developer's Manual.

## Opening MSPP API instances

ctaOpenServices opens one or more service instances on a particular context. To open an MSPP API instance on a context, invoke ctaOpenServices with the following:

- A ctahd.

- Service name (MSP) and associated service manager (MSPMGR).

- The board number, stream and timeslot, and mode to associate with the service instance.

For more information about arguments, errors, and events, refer to the Dialogic® NaturalAccess™ Software Developer's Manual.

### Example: Opening the ADI API and MSPP APIs on a context

In some cases, the application must open multiple services on the contexts associated with MSPP API instances. For example, when an application wants to perform silence detection with the voice data that passes through MSPP connections, it must open an ADI API instance with each context it uses to create DS0 endpoints. To do this, the application must open the MSPP and ADI APIs on the context and specify (in the CTA_MVIP_ADDR structure) the following address and mode information for the ADI API:

CTA_MVIP_ADDR parameter | Value | Description
services[0].mvipaddr.board | NA | Name of the CG board on which to open the service.
svclist.mvipaddr.stream | 0 | Stream associated with the DSP port. Dialogic recommends using stream 0.
svclist.mvipaddr.timeslot | 0 - 1500 | Timeslot associated with the DSP port.
svclist.mvipaddr.mode | ADI_VOICE_DUPLEX | Mode of operation for DSP resources allocated to the service instance. For more information about ADI API instances, refer to the Dialogic® NaturalAccess™ Alliance Device Interface API Developer’s Manual.

Note: When the application uses mspCreateEndpoint to create a DS0 endpoint, it must specify the same timeslot (in the DS0_ENDPOINT_ADDR structure) that it specified (in the CTA_MVIP_ADDR substructure) when it opened the ADI API on the context.