# Defining an audio transcoding configuration

In the audio transcoding configuration, instead of playing and recording audio data as is (pass-through configuration), the application can use another audio codec on the IP side or another media format on the host. The following illustration shows an audio transcoding configuration:

In this configuration, the application creates a standard Fusion path and switches the PCM audio stream to a standard ADI play/record resource (a DSP resource) allocated to support ADI service operations. For more information, see the ADI Service Developer's Reference Manual and the Fusion Developer's Manual.

The application uses the same ADI multimedia functions to perform play and record as in the pass-through configuration. By using these functions, the application can enable audio silence detection and synchronize the audio and video streams on video I-frame detection. It can also stop the recording of audio and video streams simultaneously.

Audio streams recorded in the audio transcoding configuration cannot be played back in a pass-through configuration, and vice-versa, without a conversion between NMS-packetized format and a raw audio bit stream. The one exception is when using the NMS Multimedia File Interface library functions for playing and recording 3GP files. In this case, the application can use these functions to convert AMR audio streams stored in or retrieved from 3GP format to NMS-packetized format or raw format. Once converted, the data can then be used in the pass-through configuration or the audio transcoding configuration, as shown in the following table:

Data format | Configuration
NMS-packetized | Pass-through
Raw | Audio transcoding

For more information on the Multimedia File Interface library functions, see Multimedia File Interface Library overview.

With an audio transcoding configuration, audio data is transcoded from and to whatever IP format is desired in a regular Fusion channel. The data can be recorded and played back in any format supported by the ADI service, but must be in AMR format, if using 3GP files. As in all configurations, video data is passed-through.

## Function sequence

The following tables present a typical function sequence for an audio transcoding configuration. This sequence shows

- Initialization

- Play operation

- Record operation

This function sequence contains both video-specific and non-video-specific calls.

### Initialization

Step | Call | Description
1 | ctaCreateQueue ( &queuehd) | Creates a CTA queue.
2 | ctaCreateContext ( &video_ctahd, queuehd) | Creates a CTA context for the video channel.
3 | ctaCreateContext ( &audio_ctahd, queuehd) | Creates a CTA context for the audio ADI port and the Fusion channel. A single context can be used for the audio ADI port and the Fusion channel or two contexts can be created.
4 | ctaOpenServices ( video_ctahd, svclist, nsvcs) | Creates an ADI port for the pass-through video. The pass-through video channel consumes no DSP resources on the CG board. Therefore, the svclist parameter of ctaOpenServices must contain the following settings: Set the svclist.mvipaddr.mode parameter to 0 to prevent allocation of DSP resources for this channel on the CG board. The svclist.mvipaddr.stream and svclist.mvipaddr.timeslot parameters are not applicable when the mvipaddr.mode parameter is set to 0. Set these parameters to 0 for the pass-through video channel. The ADI service and the MSPP service are in the list of services.
5 | ctaOpenServices ( audio_ctahd, svclist, nsvcs) | Creates an ADI port and opens the MSPP service for audio. The audio channel requires an ADI DSP port for silence detection. Therefore, the svclist parameter for the ADI service in ctaOpenServices must contain the following settings: Set the svclist.mvipaddr.mode parameter to ADI_VOICE_DUPLEX to allocate DSP resources for this channel on the CG board. Set the svclist.mvipaddr.stream parameter to 16 or 0. (NMS recommends 0). Set the svclist.mvipaddr.timeslot parameter to the desired DSP port. Valid range is 0 - 127. See the ADI Service Developers Reference Manual. To open the MSPP service, and support a DS0 endpoint in the Fusion channel, the svclist parameter for the MSPP service in ctaOpenServices must contain the following settings: Set the svclist.mvipaddr.mode parameter to ADI_VOICE_DUPLEX to allocate DSP resources for this channel on the CG board. Set the svclist.mvipaddr.stream parameter to 16 or 0. (NMS recommends 0.) Set the svclist.mvipaddr.timeslot parameter to the desired DSP port. Valid range is 0 - 127. See the MSPP Service Developers Reference Manual. Both the ADI service and the MSPP service must be in the list of services.
6 | nccStartProtocol ( audio_ctahd, nocc) | Starts the NOCC protocol on the audio ADI port channel to enable silence detection, transcoding, and play/record operation on the audio channel.
7 | mspCreateEndpoint ( video_ctahd, &video_ephd) | Creates a video RTP endpoint.
8 | mspCreateEndpoint ( audio_ctahd, &audio_ephd) | Creates an audio MSPP RTP endpoint.
9 | mspGetFilterHandle ( video_ctahd, video_ephd, &cg_video_ephd) | Translates the video MSPP ephd to a CG board ephd. Note: In this configuration, only the video_ephd is translated.
10 | mspCreateEndpoint ( audio_ctahd, &txc_ephd) | Creates an MSPP DS0 endpoint for the audio transcoding path. The timeslot number provided must equal the one specified in ctaOpenServices for the MSPP service.
11 | mspCreateChannel ( audio_ctahd, &txc_chhd) | Creates an AMR MSPP channel for the transcoding path.
12 | mspConnect ( audio_ephd, txc_chhd, txc_ephd) | Connects the audio RTP endpoint, the AMR channel, and the MSPP DS0 endpoint together.
13 | swiMakeConnection ( &inp, &out) | Connects the MSPP DS0 endpoint and the ADI DSP port. Timeslot numbers are those specified in respective svclist.mvipaddr of ctaOpenServices. Note: The connection must be duplex to support play and record.

### Play operation

Step | Call | Description
1 | adiPlayMMFromMemory ( video_ctahd, cg_video_ephd,,,,) or adiPlayMMAsync ( video_ctahd, cg_video_ephd,,,,) | Begins playing video portion of message.
2 | adiPlayMMFromMemory ( audio_ctahd, cg_audio_ephd,,,,) or adiPlayMMAsync ( audio_ctahd, cg_audio_ephd,,,,) | Begins playing audio portion of message.
3 | adiStopPlaying ( video_ctahd) | Stops playing video portion of message.
4 | adiStopPlaying ( audio_ctahd) | Stops playing audio portion of message.

### Record operation

Step | Call | Description
1 | adiRecordMMToMemory ( video_ctahd, cg_video_ephd, cg_audio_ephd) or adiRecordMMAsync ( video_ctahd, cg_video_ephd, cg_audio_ephd) | Begins recording video portion of message. The application passes both the audio board handle and the video board handle to the video record function, allowing the inter-dependence between the audio and video streams (for example, for I-frame detection).
2 | adiRecordMMToMemory ( audio_ctahd, cg_video_ephd, cg_audio_ephd) or adiRecordMMAsnyc (audio_ctahd, cg_video_ephd, cg_audio_ephd) | Begins recording audio portion of message. Initial silence can be skipped and audio record can be aborted if a long silence is detected during the record operation. The application passes both the audio board handle and the video board handle to the audio record function, allowing the inter-dependence between the audio and video streams (for example, for I-frame detection).
3 | adiStopRecording ( video_ctahd) | Stops recording video portion of message.
4 | adiStopRecording ( audio_ctahd) | Stops recording audio portion of message.