# Making one-talker, one-listener connections

The PPX service provides convenience functions, ppxConnect and ppxDisconnect, to make connections between one talker and one listener.

ppxConnect uses internal connection handles that cannot be accessed by the application to make connections. Additional listeners cannot be these connections. These connections cannot be accessed across applications.

When a connection is made using ppxConnect, the connection is owned by the context
that created it. Only the owner context can disconnect the connection by calling ppxDisconnect.

These convenience functions include a mode argument that directs the PPX service to calculate endpoints for any additional connections based upon the single talker and listener that have been passed. The mode argument can have any of the following values:

Value | Description
--- | ---
PPX_SIMPLEX | Establishes a connection in one direction. This mode is typically used to broadcast or to monitor half a conversation.
PPX_DUPLEX | Establishes connections in two directions. This mode is typically used to connect a phone conversation.
PPX_QUAD | Establishes two duplex connections, one for voice and one for signaling. This mode is typically used to connect a network interface to its voice and signaling DSPs.

This topic provides information on:

- Making a simplex connection

- Making a duplex connection

- Making a quad connection

- Disconnecting a talker and a listener

## Making a simplex connection

To make a simplex connection, call ppxConnect, specify the address of the talker and the listener, and specify the mode PPX_SIMPLEX. The PPX service connects the talker to the listener by making the necessary switch connection. If the talker and the listener are on different boards, the connection can involve the allocation of telephony bus timeslots
.

The following illustration shows a simplex connection between local resources on a telephony board. The switch connection connects a network interface voice input on local stream 0 to the DSP voice output on local stream 5.

## Making a duplex connection

To make a duplex connection, call ppxConnect, specify the address of the talker and the listener, and specify the mode PPX_DUPLEX. For duplex connections, the PPX service makes two end-to-end connections. If the talker and the listener are on different boards, the connections involve the allocation of telephony bus timeslots.

A duplex connection is a bidirectional voice or a bidirectional signaling connection. Telephony bus streams are typically defined in pairs; an even-numbered stream n has a corresponding stream n+1. The even-numbered stream is in one direction and the odd-numbered stream is in the other direction. For example, if stream 0 is an input stream, stream 1 is an output stream.

For a duplex PPX connection, the talker and listener that are passed as arguments to the function specify the first connection. The second connection is determined by connecting the stream pair.

The following illustration shows a duplex connection between local resources on a telephony board. ppxConnect is called with the address of the talker (LOCAL:0:3) and the address of the listener (LOCAL:5:3). The first connection makes the connection between the talker and the listener. The PPX service automatically makes the second connection that is LOCAL:4:3 (stream 4 is the pair of stream 5) to LOCAL:1:3 (stream 1 is the pair of stream 0).

The PPX service uses the following algorithm to determine the streams that are used in a duplex connection. The application specifies one talker and one listener in the command:

ppxConnect( ctahd, &talker, &listener, PPX_DUPLEX)

The PPX service makes a series of connections. The first connection is:

talker -> listener

The second connection depends on whether the specified bus is local. Since inputs from local resources are always on even-numbered streams and outputs to local resources are always on odd-numbered streams, local stream endpoints are always as follows:

listener_2.stream = talker.stream + 1
talker_2.stream = listener.stream - 1

Then connect:

talker_2 -> listener_2

When the bus is not local, the second connection is determined as follows:

- If the talker is on an even-numbered stream:

listener_2.stream = talker.stream + 1

otherwise:

listener_2.stream = talker.stream - 1

- If the listener is on an even-numbered stream:

talker_2.stream = listener.stream + 1

otherwise:

talker_2.stream = listener.stream - 1

- Then connect:

talker_2 -> listener_2

## Making a quad connection

To make a quad connection, call ppxConnect, specify the addresses of the talker and the listener, and specify the mode PPX_QUAD. A quad connection is the same as making two duplex connections. The PPX service makes four end-to-end connections. The connections can involve the allocation of telephony bus timeslots if the talker and the listener are on different boards.

In a quad connection, the application specifies one connection, which connects a talker to a listener.

The PPX service does the following:

- Makes the duplex connection for the talker and the listener.

- Increments the streams by two, and connects a talker and listener.

- Makes the duplex connection for the new talker and listener.

The following illustration shows a quad connection between local resources on a telephony board. ppxConnect is called with the address of the talker (LOCAL:0:3) and the address of the listener (LOCAL:5:3). The first connection links the talker and the listener. The second connection links LOCAL:4:3 (stream 4 is the pair of stream 5) to LOCAL:1:3 (stream 1 is the pair of stream 0). The third connection links LOCAL:2:3 (stream 2 is stream 0 + 2) to LOCAL:7:3 (stream 7 is stream 5 + 2). The second connection links LOCAL:6:3 (stream 6 is the pair of stream 7) to LOCAL:3:3 (stream 3 is the pair of stream 2).

The PPX service makes the required connections by calling ppxConnect with two endpoints.

For example, connecting a network interface to the on-board DSP resources for one port of an AG 2000 consists of one PPX call. The PPX service makes four switch connections:

Application | Switch connections made by PPX service
talker.switch_number =0; talker.bus = MVIP95_LOCAL_BUS; talker.stream = 0; talker.timeslot = 4; listener.switch_number = 0; listener.bus = MVIP95_LOCAL_BUS; listener.stream = 5; listener.timeslot = 4; ppxConnect(ctahd, &talker, &listener, PPX_QUAD) | talker.bus = MVIP95_LOCAL_BUS; talker.stream = 0; talker.timeslot = 4; listener.bus = MVIP95_LOCAL_BUS; listener.stream = 5; listener.timeslot = 4; swiMakeConnection(swihd, talker,listener,1) talker.bus = MVIP95_LOCAL_BUS; talker.stream = 4; talker.timeslot = 4; listener.bus = MVIP95_LOCAL_BUS; listener.stream = 1; listener.timeslot = 4; swiMakeConnection(swihd, talker,listener,1) talker.bus = MVIP95_LOCAL_BUS; talker.stream = 2; talker.timeslot = 4; listener.bus = MVIP95_LOCAL_BUS; listener.stream = 7; listener.timeslot = 4; swiMakeConnection(swihd, talker,listener,1) talker.bus = MVIP95_LOCAL_BUS; talker.stream = 6; talker.timeslot = 4; listener.bus = MVIP95_LOCAL_BUS; listener.stream = 1; listener.timeslot = 4; swiMakeConnection(swihd, talker,listener,1)

Connecting the same port on the AG 2000 to DSP resources on an AG 4000 board consists of only one PPX call, but requires eight switch connections.

## Disconnecting a talker and a listener

Use ppxDisconnect to disconnect a previously connected simplex, duplex, or quad switch connection. Any intervening timeslots are freed. ppxDisconnect can breakdown only connections that are owned by the context that is associated with the connection.