Contents:
Prosody version 1 performed various resource management functions which are not performed by version 2 (TiNG) itself. While new applications can be written to perform such resource management themselves (or, more commonly, designed such that the resource management is implicit in the design), for backward compatibility with existing applications, a resource manager is provided. Although applications written for version 1 may still require some modifications, these should be very minor.
Note that neither Prosody S nor Prosody X support the use of the resource manager.
The resource manager provides or modifies the following API functions. See following sections for full details, including any restrictions on their use.
Prosody version 1 supplied firmware in packages called builds. Each build had a predefined combination of Prosody functionality. A firmware build was downloaded as a unit using either a standalone application or the API call sm_download_fmw().
The resource manager provides this functionality by providing both a
facility to download firmware automatically and the
sm_download_fmw() API function as well as a selection of
predefined builds as described in
Prosody application note: the version 1
compatibility builds.
Prosody version 1 attempted to prevent resource exhaustion by
limiting the number of channels which could be allocated on each
Prosody processor. The caps_mask fields of
sm_channel_alloc_placed(),
and sm_channel_alloc()
were used to allow the application to describe its intended use for
each channel, so that Prosody could reserve the required resources.
The resource manager provides this functionality by implementing limits on channel allocation in the same manner as version 1. Note that, although many of the limits are the same, some are different when the application specifies an invalid combination of channels. The resource manager returns an error for many of these cases rather than allocating a channel.
When you use sm_channel_alloc_placed(), these errors may be returned:
The behaviour of sm_channel_alloc() is intended to be as intuitive as possible. It follows these steps:
group field refers to an existing group, perform
sm_channel_alloc_placed()
on the module hosting that group.
-1 nor 0,
return the error ERR_SM_NO_SUCH_GROUP.
firmware_id field, attempting to allocate the channel on
each module, trying modules in increasing order of module index. If the
channel is allocated, return it.
While this is not exactly the same behaviour as Prosody version 1, it is intended to give the same result when channel allocation succeeds, and a good error report when it fails.
Prosody version 1 normally allocated a timeslot to each channel as it was allocated, whereas version 2 (TiNG) requires the application to assign timeslots explictly with sm_switch_channel_input(), and sm_switch_channel_output().
The resource manager provides backward compatibility by performing the allocation and assignment on behalf of the application. The application can retrieve the timeslot assignment using sm_channel_info(), as with Prosody version 1. Note that, just like Prosody 1, all timeslots are forced to be either A-law or mu-law depending on the firmware build being used.
Prosody version 1 permitted independent processes to control a single
channel. Some API functions which used a tSMChannelID
(which is local to the process which allocates a channel) had an
equivalent which used a channel index instead. Prosody
version 2 (TiNG) itself does not provide an implementation for any of these
equivalents. However, the resource manager can provide implementations
for many of these functions. In particular, these are provided:
However, these functions are not provided:
Because of the extra performance overhead imposed by using channel
indexes, if you want to use them in an application, you must define the
additional C preprocessor symbol TiNG_USE_CHANNEL_IX.
In addition, the only channels which can use the
...conf_primix... API functions are "remote channels".
These are channels which were allocated with the bit
kSMChannelCapsRemoteAlloc set in the caps_mask
field of the
sm_channel_alloc() or
sm_channel_alloc_placed()
which allocated them. This causes the channel to be allocated inside the
resource manager, rather than locally in your application. If you
attempt to use an ordinary, local, channel with one of the
...conf_primix... API functions, it will normally return
the error ERR_SM_NO_SUCH_CHANNEL, as the channel is local
and the resource manager does not have a record of it.
A remote channel has limited functionality. The only API functions
which can use them are the ...conf_primix... and these:
The above API calls allow remote channels to use events of type
kSMEventTypeRecog to notify applications upon receipt of
digits. Remote channels do not support any other event type.
An application may allocate a mixture of remote and local channels. It is the responsibility of the developer to ensure that the correct API calls are used for the different channel types.
It is best to reserve this feature purely for maintaining applications which require it for backward compatibility.
When the resource manager is running, you can give it commands on its input. The commands available are:
The display of timelsots in use looks like this:
1 2 3
c m st 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
0 0 48 I O * * O * I I
0 0 49 *
0 1 50
0 1 51
0 2 52
0 2 53
0 3 54
0 3 55
1 4 48 * * * * * * * * * * * * * * * *
Each line shows the status of one stream. The labels on the left show
the card number, module number, and stream number for the stream. The
rest of the line shows each timeslot on that stream, with a star
(*) for a timeslot if both the input and output is in
use, "O" if only the output is in use, "I"
if only the input is in use, and blank if it is not in use at all.
So in the above example, the input timeslot 48:3 is in use, as is the
output timeslot 48:8, while both input and output timeslots 48:11 are
in use.
The display of channels in use consists of one line for each channel. The lines look like this:
23 f c0 m0 ->48:0 <-48:0 101 h c1 m5 100 i c1 m5 <-50:5 30 o c0 m0 ->48:1
This shows four channels allocated. The first column is the channel
index. The next column shows whether the channel is a full-duplex
channel (f), a half-duplex channel (h), an
input channel (i), or an output channel (o).
This is followed by the card number and module number. The rest of the
line shows information that may not apply to every channel. If the
channel has an output timeslot assigned, this is shown as
"->" and the stream and timeslot number. Similarly,
"<-" indicates an input timeslot.
Before running an application that requires the resource manager, you
must ensure that the resource manager is running. This may be done by
starting it when the system boots, or by running the application from
a script or batch file which starts the resource manager before the
application. The resource manager is supplied in the directory
$(TiNG)/ResourceManager. This directory contains firmware
configuration files for the
version 1 compatibility builds
while the resource manager itself is in an appropriate sub-directory
(gen-*) for each supported variant. When you start it,
you must pass it the name of the appropriate configuration file as a
parameter. For example:
gen-WINNT/ResourceManager.exe sp30x2.cfg
where sp30x2.cfg is the desired configuration file. The
format of this file is fully described in
Firmware Download and Configuration Files,
but for a quick and simple way to get started, take the sample
sp30x2.cfg file and modify it to describe your system.
The example file shows a configuration for a system with two DSPs
each running the sp30 firmware build for A-law timeslots. There are two
changes you might need to make: changing the number of DSPs (add or
remove a section starting with <DSPINDEX> and adjust the number
specified for <NUMDSPS>) and using different firmware builds
(change sp30a.sfw to sp60u.sfw or whatever you
want - the names are the same as the Prosody version 1 builds except
they end in .sfw instead of .smf).
Applications which use the resource manager must be built slightly differently to applications which use Prosody version 2 (TiNG) without the resource manager. The procedure described in Prosody Guide - how to build applications to use Prosody is extended as follows:
TiNG_USE_RESOURCE_MANAGER.
TiNG_USE_CHANNEL_IX.
ws2_32.lib (or your preferred alternative
socket library) as an extra library. For example in Visual Studio, in
the project settings, there is an item labelled "Object/library modules"
on the "Link" pane, and you add the socket library in there.
apilib/gen-LINUX/TiNGcore_rm.o
lib/gen-WINNT/TiNGcore_rm.obj or
lib/gen-WINNT/TiNGcore_rm.dll
apilib/gen-LINUX/TiNGcore_rm_ix.o
lib/gen-WINNT/TiNGcore_rm_ix.obj or
lib/gen-WINNT/TiNGcore_rm_ix.dll
On Microsoft Windows, there are project files for VisualStudio as
described in Prosody installation guide: Visual
Studio Project files which build the two variants of the Prosody
library which use the resource mananger. The project called
apilib_rm is the library for the resource manager and
apilib_rm_ix is the library with channel indexes as
well. Instead of explictly adding a Prosody library to your project,
you can tell VisualStudio that your project uses one of these, and it
will link with the correct library.
Document reference: AN 1387