Asterisk/Camp

From My Notepad
Jump to: navigation, search

Camp

These are my notes while I try and develop Camp functionality for Asterisk.

Method

Camping can be achieved in asterisk by adding the functionality to the parking code. A camped user could be added to the parkinglot with a flag set to denote it is camped instead of parked, and we could pick the parking slot from the opposite end that they are being picked for parking, or we could get fancy and impliment another range of slots for camped calls. For initial development I'm just going to let the existing parking code pick the next available slot, or the last available slot.

Add the following to the parkeduser struct:

unsigned int camped = 0;        /*!< Whether or not the pu is camped */
unsigned int camptype = 0;        /*!< Where do we go when a device becomes available */
char campedondevices[AST_MAX_EXTENSION];        /*!< List of devices we are camped on */

We also have the following defines:

/*! Once device is available, do we jump to the available device or an extension? */
#define CAMP_ON_DEVICE              (1 << 0)        /*!<  */
#define CAMP_ON_EXTEN               (1 << 1)        /*!<  */

We camp a call on devices by calling the CampOn dialplan application:

[Syntax]
CampOn(Technology/Resource[&Technology2/Resource2[&...]][,timeout[,context[,exten[,priority]]])

The call is inserted into a parkinglot as a parked user with pu->camped=1.

pu->campedondevices is set to the list of devices we are camping the call on. Status of the devices will be checked in the manage_parkinglot function that already services unparking timed out calls.

The call is added to the parking lot as usual pu->camped set to 1, and pu->parkingtime is set to timeout if it is passed to the application.

If c,e,p is passed to the application, we set pu->camptype=CAMP_ON_EXTEN and pu->context, pu->exten, pu->priority to the passed c,e,p. If a device becomes available, we send the call to c,e,p.

If no c,e,p is passed, we set pu->camptype=CAMP_ON_DEVICE. If a device becomes available, we dial the available device. We can do this in one of two ways. The first would be using a method similar to the peername_flat extension when a parked call times out. The second would be similar to when comebacktoorigin=no, we go to [comebackcontext],s,1 and set CAMPONDEVICE= to the available device.

If no device becomes available during pu->parkingtime, the manage_parkinglot function will handle uncamping a timed out call exactly the same way a timed out parked call would be handled with the addition of CAMP_STATUS=TIMEOUT or something similar so the dialplan can know the call timed out.

main/features.c line 3852:

/* Are we a camped user? */
if (pu->camped) {
        /* Check the list of devices to see if anyone is no longer on the phone */
        while ((tech = strsep(&pu->campedondevices, "&"))) {
                state = ast_device_state(tech);
                if (state = AST_DEVICE_NOT_INUSE) {
                        /* send the camped user to the device/extension */
                }
        }
} /* End pu->camped */

Notes on how parking works

Notes on how one touch parking works

builtin_parkcall is called
which calls parkcall_helper(chan, peer, config, code, sense, NULL);
which calls masq_park_call_announce(parkee, parker, args); after logic
which calls masq_park_call(rchan, peer, 0, NULL, 1, args);
which calls park_call_full(chan, peer, args); after logic

park_call_full

Does the actual work for parking a channel.

ParkedCall() - unparking a call

park_exec calls park_exec_full