Added option music-on-hold for first chat member.
This commit is contained in:
parent
1f87f1d416
commit
a8c926e858
1
CHANGES
1
CHANGES
|
@ -8,6 +8,7 @@ HEAD
|
||||||
- send Sending-Complete if overlap dialing is not used.
|
- send Sending-Complete if overlap dialing is not used.
|
||||||
- fixed numberingplan for 'connected number'.
|
- fixed numberingplan for 'connected number'.
|
||||||
- added devicestate option.
|
- added devicestate option.
|
||||||
|
- capi-chat can play music-on-hold for first caller.
|
||||||
|
|
||||||
chan_capi-1.0.2
|
chan_capi-1.0.2
|
||||||
------------------
|
------------------
|
||||||
|
|
4
README
4
README
|
@ -283,7 +283,9 @@ Chat (MeetMe/Conference):
|
||||||
(This uses the DSPs onboard a Dialogic DIVA Server Rev.2 card.)
|
(This uses the DSPs onboard a Dialogic DIVA Server Rev.2 card.)
|
||||||
exten => s,1,capicommand(chat|<roomname>|<options>|controller)
|
exten => s,1,capicommand(chat|<roomname>|<options>|controller)
|
||||||
Example:
|
Example:
|
||||||
exten => s,1,capicommand(chat|salesmeeting||1,3-6)
|
exten => s,1,capicommand(chat|salesmeeting|m|1,3-6)
|
||||||
|
Possible options:
|
||||||
|
'm' = The first caller will get music-on-hold until second caller arrives.
|
||||||
|
|
||||||
|
|
||||||
Using CLIR
|
Using CLIR
|
||||||
|
|
|
@ -22,10 +22,12 @@
|
||||||
#include "chan_capi_chat.h"
|
#include "chan_capi_chat.h"
|
||||||
#include "chan_capi_utils.h"
|
#include "chan_capi_utils.h"
|
||||||
|
|
||||||
|
#define CHAT_FLAG_MOH 0x0001
|
||||||
|
|
||||||
struct capichat_s {
|
struct capichat_s {
|
||||||
char name[16];
|
char name[16];
|
||||||
unsigned int number;
|
unsigned int number;
|
||||||
|
int active;
|
||||||
struct capi_pvt *i;
|
struct capi_pvt *i;
|
||||||
struct capichat_s *next;
|
struct capichat_s *next;
|
||||||
};
|
};
|
||||||
|
@ -82,6 +84,13 @@ static void update_capi_mixer(int remove, unsigned int roomnumber, struct capi_p
|
||||||
}
|
}
|
||||||
room = room->next;
|
room = room->next;
|
||||||
}
|
}
|
||||||
|
room = chat_list;
|
||||||
|
while (room) {
|
||||||
|
if (room->number == roomnumber) {
|
||||||
|
room->active = found + ((remove) ? 0 : 1);
|
||||||
|
}
|
||||||
|
room = room->next;
|
||||||
|
}
|
||||||
cc_mutex_unlock(&chat_lock);
|
cc_mutex_unlock(&chat_lock);
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
|
@ -201,7 +210,8 @@ static struct capichat_s *add_chat_member(char *roomname, struct capi_pvt *i)
|
||||||
/*
|
/*
|
||||||
* loop during chat
|
* loop during chat
|
||||||
*/
|
*/
|
||||||
static void chat_handle_events(struct ast_channel *c, struct capi_pvt *i)
|
static void chat_handle_events(struct ast_channel *c, struct capi_pvt *i,
|
||||||
|
struct capichat_s *room, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct ast_frame *f;
|
struct ast_frame *f;
|
||||||
int ms;
|
int ms;
|
||||||
|
@ -211,15 +221,22 @@ static void chat_handle_events(struct ast_channel *c, struct capi_pvt *i)
|
||||||
int nfds = 0;
|
int nfds = 0;
|
||||||
struct ast_channel *rchan;
|
struct ast_channel *rchan;
|
||||||
struct ast_channel *chan = c;
|
struct ast_channel *chan = c;
|
||||||
|
int moh_active = 0;
|
||||||
|
|
||||||
|
ast_indicate(chan, -1);
|
||||||
|
|
||||||
waitfd = i->readerfd;
|
waitfd = i->readerfd;
|
||||||
if (i->channeltype == CAPI_CHANNELTYPE_NULL) {
|
if (i->channeltype == CAPI_CHANNELTYPE_NULL) {
|
||||||
nfds = 1;
|
nfds = 1;
|
||||||
ast_indicate(chan, -1);
|
|
||||||
ast_set_read_format(chan, capi_capability);
|
ast_set_read_format(chan, capi_capability);
|
||||||
ast_set_write_format(chan, capi_capability);
|
ast_set_write_format(chan, capi_capability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((flags & CHAT_FLAG_MOH) && (room->active < 2)) {
|
||||||
|
ast_moh_start(chan, NULL, NULL);
|
||||||
|
moh_active = 1;
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
ready_fd = 0;
|
ready_fd = 0;
|
||||||
ms = 100;
|
ms = 100;
|
||||||
|
@ -275,6 +292,10 @@ static void chat_handle_events(struct ast_channel *c, struct capi_pvt *i)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((moh_active) && (room->active > 1)) {
|
||||||
|
ast_moh_stop(chan);
|
||||||
|
moh_active = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,6 +310,7 @@ int pbx_capi_chat(struct ast_channel *c, char *param)
|
||||||
struct capichat_s *room;
|
struct capichat_s *room;
|
||||||
ast_group_t tmpcntr;
|
ast_group_t tmpcntr;
|
||||||
unsigned long contr = 0;
|
unsigned long contr = 0;
|
||||||
|
unsigned int flags = 0;
|
||||||
|
|
||||||
roomname = strsep(¶m, "|");
|
roomname = strsep(¶m, "|");
|
||||||
options = strsep(¶m, "|");
|
options = strsep(¶m, "|");
|
||||||
|
@ -307,6 +329,19 @@ int pbx_capi_chat(struct ast_channel *c, char *param)
|
||||||
contr = (unsigned long)(tmpcntr >> 1);
|
contr = (unsigned long)(tmpcntr >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while ((options) && (*options)) {
|
||||||
|
switch (*options) {
|
||||||
|
case 'm':
|
||||||
|
flags |= CHAT_FLAG_MOH;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cc_log(LOG_WARNING, "Unknown chat option '%c'.\n",
|
||||||
|
*options);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
options++;
|
||||||
|
}
|
||||||
|
|
||||||
cc_verbose(3, 1, VERBOSE_PREFIX_3 "capi chat: %s: roomname=%s "
|
cc_verbose(3, 1, VERBOSE_PREFIX_3 "capi chat: %s: roomname=%s "
|
||||||
"options=%s controller=%s (0x%x)\n",
|
"options=%s controller=%s (0x%x)\n",
|
||||||
c->name, roomname, options, controller, contr);
|
c->name, roomname, options, controller, contr);
|
||||||
|
@ -321,8 +356,9 @@ int pbx_capi_chat(struct ast_channel *c, char *param)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->_state != AST_STATE_UP)
|
if (c->_state != AST_STATE_UP) {
|
||||||
ast_answer(c);
|
ast_answer(c);
|
||||||
|
}
|
||||||
|
|
||||||
capi_wait_for_answered(i);
|
capi_wait_for_answered(i);
|
||||||
if (!(capi_wait_for_b3_up(i))) {
|
if (!(capi_wait_for_b3_up(i))) {
|
||||||
|
@ -336,7 +372,7 @@ int pbx_capi_chat(struct ast_channel *c, char *param)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* main loop */
|
/* main loop */
|
||||||
chat_handle_events(c, i);
|
chat_handle_events(c, i, room, flags);
|
||||||
|
|
||||||
del_chat_member(room);
|
del_chat_member(room);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue