--- apps/app_meetme.c.ORIG 2005-11-12 09:03:40.000000000 -1000 +++ apps/app_meetme.c 2005-11-21 15:23:08.000000000 -1000 @@ -143,6 +143,7 @@ int locked; /* Is the conference locked? */ pthread_t recordthread; /* thread for recording */ pthread_attr_t attr; /* thread attribute */ + pthread_t sendtextthread; /* thread for sending text */ char *recordingfilename; /* Filename to record the Conference into */ char *recordingformat; /* Format to record the Conference in */ char pin[AST_MAX_EXTENSION]; /* If protected by a PIN */ @@ -171,6 +172,12 @@ struct volume listen; }; +struct ast_conf_text { + struct ast_conference *conf; + char text[1024]; + struct ast_conf_user *sender; +}; + static int audio_buffers; /* The number of audio buffers to be allocated on pseudo channels when in a conference */ @@ -192,6 +199,7 @@ static int admin_exec(struct ast_channel *chan, void *data); static void *recordthread(void *args); +static void *sendtextthread(void *args); #include "enter.h" #include "leave.h" @@ -1309,6 +1317,17 @@ */ write(fd, f->data, f->datalen); } + } else if (f->frametype == AST_FRAME_TEXT) { + /* Text conference support */ + struct ast_conf_text *t = calloc(1, sizeof(*t)); + if( t ) { + t->conf = conf; + t->sender = user; + ast_copy_string(t->text, f->data, sizeof(t->text)); + pthread_attr_init(&conf->attr); + pthread_attr_setdetachstate(&conf->attr, PTHREAD_CREATE_DETACHED); + ast_pthread_create(&conf->sendtextthread, &conf->attr, sendtextthread, t); + } } else if ((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_EXIT_CONTEXT)) { char tmp[2]; @@ -2148,6 +2167,28 @@ pthread_exit(0); } +static void *sendtextthread(void *args) +{ + struct ast_conf_text *t = args; + + ast_log(LOG_DEBUG, "Text thread for '%s' from %s\n", t->text, t->sender->chan->name); + struct ast_conf_user *u = calloc(1, sizeof(*u)); + if( u ) { + for (u = t->conf->firstuser; u; u = u->nextuser) { + if (u==t->sender) + continue; + if ( u->chan->tech->send_text) { + /* We should use: ast_sendtext(u->chan, t->text) + * but it generates a blocking warning */ + u->chan->tech->send_text(u->chan, t->text); + } + } + free(u); + } + free(t); + pthread_exit(0); +} + static void load_config(void) { struct ast_config *cfg;