Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Functions | Variables
ooh323cDriver.c File Reference
#include "ooh323cDriver.h"
#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/pbx.h"
#include "asterisk/logger.h"
Include dependency graph for ooh323cDriver.c:

Go to the source code of this file.

Data Structures

struct  callthread
 

Macros

#define AST_BACKGROUND_STACKSIZE   768 * 1024
 
#define SEC_TO_HOLD_THREAD   24
 

Functions

struct ast_formatconvertH323CapToAsteriskCap (int cap)
 
void * ooh323c_call_thread (void *dummy)
 
void * ooh323c_cmd_thread (void *dummy)
 
int ooh323c_set_aliases (ooAliases *aliases)
 
int ooh323c_set_capability (struct ast_format_cap *cap, int dtmf, int dtmfcodec)
 
int ooh323c_set_capability_for_call (ooCallData *call, struct ast_format_cap *cap, int dtmf, int dtmfcodec, int t38support, int g729onlyA)
 
void * ooh323c_stack_thread (void *dummy)
 
int ooh323c_start_call_thread (ooCallData *call)
 
int ooh323c_start_receive_channel (ooCallData *call, ooLogicalChannel *pChannel)
 
int ooh323c_start_receive_datachannel (ooCallData *call, ooLogicalChannel *pChannel)
 
int ooh323c_start_stack_thread ()
 
int ooh323c_start_transmit_channel (ooCallData *call, ooLogicalChannel *pChannel)
 
int ooh323c_start_transmit_datachannel (ooCallData *call, ooLogicalChannel *pChannel)
 
int ooh323c_stop_call_thread (ooCallData *call)
 
int ooh323c_stop_receive_channel (ooCallData *call, ooLogicalChannel *pChannel)
 
int ooh323c_stop_receive_datachannel (ooCallData *call, ooLogicalChannel *pChannel)
 
int ooh323c_stop_stack_thread (void)
 
int ooh323c_stop_transmit_channel (ooCallData *call, ooLogicalChannel *pChannel)
 
int ooh323c_stop_transmit_datachannel (ooCallData *call, ooLogicalChannel *pChannel)
 

Variables

static struct callthreadcallThreads = NULL
 
static ast_mutex_t callThreadsLock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
OOBOOL gH323Debug
 
OOH323EndPoint gH323ep
 
static int grxframes = 240
 
static int gtxframes = 20
 
struct ast_modulemyself
 
static pthread_t ooh323c_thread = AST_PTHREADT_NULL
 
static pthread_t ooh323cmd_thread = AST_PTHREADT_NULL
 

Macro Definition Documentation

◆ AST_BACKGROUND_STACKSIZE

#define AST_BACKGROUND_STACKSIZE   768 * 1024

Definition at line 26 of file ooh323cDriver.c.

◆ SEC_TO_HOLD_THREAD

#define SEC_TO_HOLD_THREAD   24

Definition at line 28 of file ooh323cDriver.c.

Referenced by ooh323c_call_thread().

Function Documentation

◆ convertH323CapToAsteriskCap()

struct ast_format* convertH323CapToAsteriskCap ( int  cap)

Definition at line 664 of file ooh323cDriver.c.

References ast_debug, ast_format_alaw, ast_format_g723, ast_format_g726, ast_format_g726_aal2, ast_format_g729, ast_format_gsm, ast_format_h263, ast_format_speex, ast_format_ulaw, and NULL.

Referenced by ooh323c_start_receive_channel(), and ooh323c_start_transmit_channel().

665 {
666  switch(cap)
667  {
668  case OO_G711ULAW64K:
669  return ast_format_ulaw;
670  case OO_G711ALAW64K:
671  return ast_format_alaw;
672  case OO_GSMFULLRATE:
673  return ast_format_gsm;
674  case OO_SPEEX:
675  return ast_format_speex;
676  case OO_G729:
677  return ast_format_g729;
678  case OO_G729A:
679  return ast_format_g729;
680  case OO_G729B:
681  return ast_format_g729;
682  case OO_G7231:
683  return ast_format_g723;
684  case OO_G726:
685  return ast_format_g726;
686  case OO_G726AAL2:
687  return ast_format_g726_aal2;
688  case OO_H263VIDEO:
689  return ast_format_h263;
690  default:
691  ast_debug(1, "Cap %d is not supported by driver yet\n", cap);
692  return NULL;
693  }
694 
695  return NULL;
696 }
struct ast_format * ast_format_g726
Built-in cached g726 format.
Definition: format_cache.c:116
struct ast_format * ast_format_g723
Built-in cached g723.1 format.
Definition: format_cache.c:151
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
Definition: format_cache.c:86
struct ast_format * ast_format_g726_aal2
Built-in cached g726 aal2 format.
Definition: format_cache.c:121
#define NULL
Definition: resample.c:96
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
struct ast_format * ast_format_gsm
Built-in cached gsm format.
Definition: format_cache.c:101
struct ast_format * ast_format_speex
Built-in cached speex format.
Definition: format_cache.c:136
struct ast_format * ast_format_alaw
Built-in cached alaw format.
Definition: format_cache.c:91
struct ast_format * ast_format_g729
Built-in cached g729 format.
Definition: format_cache.c:156
struct ast_format * ast_format_h263
Built-in cached h263 format.
Definition: format_cache.c:171

◆ ooh323c_call_thread()

void * ooh323c_call_thread ( void *  dummy)

Definition at line 80 of file ooh323cDriver.c.

References ast_free, ast_module_unref, ast_mutex_destroy, ast_mutex_lock, ast_mutex_unlock, ast_update_use_count(), c, callthread::call, callThreads, callThreadsLock, FALSE, callthread::inUse, callthread::lock, callthread::next, NULL, callthread::prev, SEC_TO_HOLD_THREAD, and callthread::thePipe.

Referenced by ooh323c_start_call_thread().

81 {
82  struct callthread* mycthread = (struct callthread *)dummy;
83  struct pollfd pfds[1];
84  char c;
85  int res = 0;
86 
87  do {
88 
89  ooMonitorCallChannels((ooCallData*)mycthread->call);
90  mycthread->call = NULL;
91  mycthread->prev = NULL;
92  mycthread->inUse = FALSE;
93 
95  mycthread->next = callThreads;
96  callThreads = mycthread;
97  if (mycthread->next) mycthread->next->prev = mycthread;
99 
100  pfds[0].fd = mycthread->thePipe[0];
101  pfds[0].events = POLLIN;
102  ooSocketPoll(pfds, 1, SEC_TO_HOLD_THREAD * 1000);
103  if (ooPDRead(pfds, 1, mycthread->thePipe[0]))
104  res = read(mycthread->thePipe[0], &c, 1);
105 
107  ast_mutex_lock(&mycthread->lock);
108  if (mycthread->prev)
109  mycthread->prev->next = mycthread->next;
110  else
111  callThreads = mycthread->next;
112  if (mycthread->next)
113  mycthread->next->prev = mycthread->prev;
114  ast_mutex_unlock(&mycthread->lock);
116 
117  } while (mycthread->call != NULL && res >= 0);
118 
119 
120  ast_mutex_destroy(&mycthread->lock);
121 
122  close(mycthread->thePipe[0]);
123  close(mycthread->thePipe[1]);
124  ast_free(mycthread);
127  return NULL;
128 }
#define FALSE
Definition: app_minivm.c:521
ooCallData * call
Definition: ooh323cDriver.c:44
int thePipe[2]
Definition: ooh323cDriver.c:42
static void dummy(char *unused,...)
Definition: chan_unistim.c:220
static struct callthread * callThreads
#define ast_mutex_lock(a)
Definition: lock.h:187
static struct test_val c
#define SEC_TO_HOLD_THREAD
Definition: ooh323cDriver.c:28
#define NULL
Definition: resample.c:96
void ast_update_use_count(void)
Notify when usecount has been changed.
Definition: loader.c:2528
#define ast_module_unref(mod)
Release a reference to the module.
Definition: module.h:469
static ast_mutex_t callThreadsLock
Definition: ooh323cDriver.c:48
struct callthread * prev
Definition: ooh323cDriver.c:45
#define ast_free(a)
Definition: astmm.h:182
ast_mutex_t lock
Definition: ooh323cDriver.c:41
#define ast_mutex_destroy(a)
Definition: lock.h:186
OOBOOL inUse
Definition: ooh323cDriver.c:43
struct callthread * next
Definition: ooh323cDriver.c:45
struct ast_module * myself
Definition: chan_ooh323.c:113
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ ooh323c_cmd_thread()

void * ooh323c_cmd_thread ( void *  dummy)

Definition at line 73 of file ooh323cDriver.c.

References dummy().

Referenced by ooh323c_start_stack_thread().

74 {
75 
76  ooMonitorCmdChannels();
77  return dummy;
78 }
static void dummy(char *unused,...)
Definition: chan_unistim.c:220

◆ ooh323c_set_aliases()

int ooh323c_set_aliases ( ooAliases *  aliases)

Definition at line 566 of file ooh323cDriver.c.

References aliases, and ast_debug.

567 {
568  ooAliases *cur = aliases;
569  while(cur)
570  {
571  switch(cur->type)
572  {
573  case T_H225AliasAddress_dialedDigits:
574  ooH323EpAddAliasDialedDigits(cur->value);
575  break;
576  case T_H225AliasAddress_h323_ID:
577  ooH323EpAddAliasH323ID(cur->value);
578  break;
579  case T_H225AliasAddress_url_ID:
580  ooH323EpAddAliasURLID(cur->value);
581  break;
582  case T_H225AliasAddress_email_ID:
583  ooH323EpAddAliasEmailID(cur->value);
584  break;
585  default:
586  ast_debug(1, "Ignoring unknown alias type\n");
587  }
588  cur = cur->next;
589  }
590  return 1;
591 }
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
static const struct cfalias aliases[]
Definition: chan_sip.c:8510

◆ ooh323c_set_capability()

int ooh323c_set_capability ( struct ast_format_cap cap,
int  dtmf,
int  dtmfcodec 
)

Definition at line 228 of file ooh323cDriver.c.

References ao2_ref, ast_format_alaw, ast_format_cap_count(), ast_format_cap_get_format(), ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_g723, ast_format_g726, ast_format_g726_aal2, ast_format_g729, ast_format_gsm, ast_format_h263, ast_format_speex, ast_format_ulaw, ast_verb, FALSE, format, gH323Debug, grxframes, gtxframes, H323_DTMF_CISCO, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_RFC2833, ooh323c_set_capability_for_call(), ooh323c_start_receive_channel(), ooh323c_start_transmit_channel(), ooh323c_stop_receive_channel(), and ooh323c_stop_transmit_channel().

Referenced by load_module(), and ooh323c_stop_stack_thread().

229 {
230  int ret = 0, x;
231  if (gH323Debug) {
232  ast_verb(0, "\tAdding capabilities to H323 endpoint\n");
233  }
234 
235  for(x=0; x<ast_format_cap_count(cap); x++)
236  {
237  struct ast_format *format = ast_format_cap_get_format(cap, x);
239  {
240  if (gH323Debug) {
241  ast_verb(0, "\tAdding g711 ulaw capability to H323 endpoint\n");
242  }
243  ret= ooH323EpAddG711Capability(OO_G711ULAW64K, gtxframes, grxframes,
244  OORXANDTX, &ooh323c_start_receive_channel,
248  }
250  {
251  if (gH323Debug) {
252  ast_verb(0, "\tAdding g711 alaw capability to H323 endpoint\n");
253  }
254  ret= ooH323EpAddG711Capability(OO_G711ALAW64K, gtxframes, grxframes,
255  OORXANDTX, &ooh323c_start_receive_channel,
259  }
260 
262  {
263  if (gH323Debug) {
264  ast_verb(0, "\tAdding g729A capability to H323 endpoint\n");
265  }
266  ret = ooH323EpAddG729Capability(OO_G729A, 2, 24,
267  OORXANDTX, &ooh323c_start_receive_channel,
271 
272  if (gH323Debug) {
273  ast_verb(0, "\tAdding g729 capability to H323 endpoint\n");
274  }
275  ret |= ooH323EpAddG729Capability(OO_G729, 2, 24,
276  OORXANDTX, &ooh323c_start_receive_channel,
280  if (gH323Debug) {
281  ast_verb(0, "\tAdding g729b capability to H323 endpoint\n");
282  }
283  ret |= ooH323EpAddG729Capability(OO_G729B, 2, 24,
284  OORXANDTX, &ooh323c_start_receive_channel,
288  }
289 
291  {
292  if (gH323Debug) {
293  ast_verb(0, "\tAdding g7231 capability to H323 endpoint\n");
294  }
295  ret = ooH323EpAddG7231Capability(OO_G7231, 1, 1, FALSE,
296  OORXANDTX, &ooh323c_start_receive_channel,
300 
301  }
302 
304  {
305  if (gH323Debug) {
306  ast_verb(0, "\tAdding g726 capability to H323 endpoint\n");
307  }
308  ret = ooH323EpAddG726Capability(OO_G726, gtxframes, grxframes, FALSE,
309  OORXANDTX, &ooh323c_start_receive_channel,
313 
314  }
315 
317  {
318  if (gH323Debug) {
319  ast_verb(0, "\tAdding g726aal2 capability to H323 endpoint\n");
320  }
321  ret = ooH323EpAddG726Capability(OO_G726AAL2, gtxframes, grxframes, FALSE,
322  OORXANDTX, &ooh323c_start_receive_channel,
326 
327  }
328 
330  {
331  if (gH323Debug) {
332  ast_verb(0, "\tAdding h263 capability to H323 endpoint\n");
333  }
334  ret = ooH323EpAddH263VideoCapability(OO_H263VIDEO, 1, 0, 0, 0, 0, 320*1024,
335  OORXANDTX, &ooh323c_start_receive_channel,
339 
340  }
341 
343  {
344  if (gH323Debug) {
345  ast_verb(0, "\tAdding gsm capability to H323 endpoint\n");
346  }
347  ret = ooH323EpAddGSMCapability(OO_GSMFULLRATE, 4, FALSE, FALSE,
348  OORXANDTX, &ooh323c_start_receive_channel,
352 
353  }
354 
356  {
357  if (gH323Debug) {
358  ast_verb(0, "\tAdding speex capability to H323 endpoint\n");
359  }
360  ret = ooH323EpAddSpeexCapability(OO_SPEEX, 4, 4, FALSE,
361  OORXANDTX, &ooh323c_start_receive_channel,
365 
366  }
367 
368  ao2_ref(format, -1);
369  }
370 
371  if(dtmf & H323_DTMF_CISCO)
372  ret |= ooH323EpEnableDTMFCISCO(0);
373  if(dtmf & H323_DTMF_RFC2833)
374  ret |= ooH323EpEnableDTMFRFC2833(0);
375  else if(dtmf & H323_DTMF_H245ALPHANUMERIC)
376  ret |= ooH323EpEnableDTMFH245Alphanumeric();
377  else if(dtmf & H323_DTMF_H245SIGNAL)
378  ret |= ooH323EpEnableDTMFH245Signal();
379 
380  return ret;
381 }
struct ast_format * ast_format_g726
Built-in cached g726 format.
Definition: format_cache.c:116
struct ast_format * ast_format_g723
Built-in cached g723.1 format.
Definition: format_cache.c:151
#define FALSE
Definition: app_minivm.c:521
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
Definition: format_cache.c:86
struct ast_format * ast_format_g726_aal2
Built-in cached g726 aal2 format.
Definition: format_cache.c:121
Definition of a media format.
Definition: format.c:43
size_t ast_format_cap_count(const struct ast_format_cap *cap)
Get the number of formats present within the capabilities structure.
Definition: format_cap.c:395
static int grxframes
Definition: ooh323cDriver.c:36
#define ast_verb(level,...)
Definition: logger.h:463
#define H323_DTMF_CISCO
Definition: ooh323cDriver.h:31
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
struct ast_format * ast_format_gsm
Built-in cached gsm format.
Definition: format_cache.c:101
#define ao2_ref(o, delta)
Definition: astobj2.h:464
int ooh323c_start_receive_channel(ooCallData *call, ooLogicalChannel *pChannel)
#define H323_DTMF_H245ALPHANUMERIC
Definition: ooh323cDriver.h:28
struct ast_format * ast_format_speex
Built-in cached speex format.
Definition: format_cache.c:136
static int gtxframes
Definition: ooh323cDriver.c:38
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
int ooh323c_stop_transmit_channel(ooCallData *call, ooLogicalChannel *pChannel)
#define H323_DTMF_H245SIGNAL
Definition: ooh323cDriver.h:29
int ooh323c_start_transmit_channel(ooCallData *call, ooLogicalChannel *pChannel)
struct ast_format * ast_format_alaw
Built-in cached alaw format.
Definition: format_cache.c:91
struct ast_format * ast_format_g729
Built-in cached g729 format.
Definition: format_cache.c:156
struct ast_format * ast_format_cap_get_format(const struct ast_format_cap *cap, int position)
Get the format at a specific index.
Definition: format_cap.c:400
int ooh323c_stop_receive_channel(ooCallData *call, ooLogicalChannel *pChannel)
static snd_pcm_format_t format
Definition: chan_alsa.c:102
struct ast_format * ast_format_h263
Built-in cached h263 format.
Definition: format_cache.c:171
#define H323_DTMF_RFC2833
Definition: ooh323cDriver.h:26

◆ ooh323c_set_capability_for_call()

int ooh323c_set_capability_for_call ( ooCallData *  call,
struct ast_format_cap cap,
int  dtmf,
int  dtmfcodec,
int  t38support,
int  g729onlyA 
)

Definition at line 384 of file ooh323cDriver.c.

References ao2_ref, ast_format_alaw, ast_format_cap_count(), ast_format_cap_get_format(), ast_format_cap_get_format_framing(), ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_g723, ast_format_g726, ast_format_g726_aal2, ast_format_g729, ast_format_gsm, ast_format_h263, ast_format_speex, ast_format_ulaw, ast_verb, FALSE, format, gH323Debug, grxframes, H323_DTMF_CISCO, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_RFC2833, ooh323c_start_receive_channel(), ooh323c_start_receive_datachannel(), ooh323c_start_transmit_channel(), ooh323c_start_transmit_datachannel(), ooh323c_stop_receive_channel(), ooh323c_stop_receive_datachannel(), ooh323c_stop_transmit_channel(), and ooh323c_stop_transmit_datachannel().

Referenced by onNewCallCreated(), ooh323_onReceivedSetup(), and ooh323c_set_capability().

386 {
387  int ret = 0, x, txframes;
388  if (gH323Debug) {
389  ast_verb(0, "\tAdding capabilities to call(%s, %s)\n", call->callType,
390  call->callToken);
391  }
392  if(dtmf & H323_DTMF_CISCO || 1)
393  ret |= ooCallEnableDTMFCISCO(call,dtmfcodec);
394  if(dtmf & H323_DTMF_RFC2833 || 1)
395  ret |= ooCallEnableDTMFRFC2833(call,dtmfcodec);
396  if(dtmf & H323_DTMF_H245ALPHANUMERIC || 1)
397  ret |= ooCallEnableDTMFH245Alphanumeric(call);
398  if(dtmf & H323_DTMF_H245SIGNAL || 1)
399  ret |= ooCallEnableDTMFH245Signal(call);
400 
401  if (t38support)
402  ooCapabilityAddT38Capability(call, OO_T38, OORXANDTX,
407  0);
408 
409  for(x=0; x<ast_format_cap_count(cap); x++)
410  {
411  struct ast_format *format = ast_format_cap_get_format(cap, x);
413  {
414  if (gH323Debug) {
415  ast_verb(0, "\tAdding g711 ulaw capability to call(%s, %s)\n",
416  call->callType, call->callToken);
417  }
418  txframes = ast_format_cap_get_format_framing(cap, format);
419  ret= ooCallAddG711Capability(call, OO_G711ULAW64K, txframes,
420  txframes, OORXANDTX,
425  }
427  {
428  if (gH323Debug) {
429  ast_verb(0, "\tAdding g711 alaw capability to call(%s, %s)\n",
430  call->callType, call->callToken);
431  }
432  txframes = ast_format_cap_get_format_framing(cap, format);
433  ret= ooCallAddG711Capability(call, OO_G711ALAW64K, txframes,
434  txframes, OORXANDTX,
439  }
440 
442  {
443  if (gH323Debug) {
444  ast_verb(0, "\tAdding g726 capability to call (%s, %s)\n",
445  call->callType, call->callToken);
446  }
447  txframes = ast_format_cap_get_format_framing(cap, format);
448  ret = ooCallAddG726Capability(call, OO_G726, txframes, grxframes, FALSE,
449  OORXANDTX, &ooh323c_start_receive_channel,
453 
454  }
455 
457  {
458  if (gH323Debug) {
459  ast_verb(0, "\tAdding g726aal2 capability to call (%s, %s)\n",
460  call->callType, call->callToken);
461  }
462  txframes = ast_format_cap_get_format_framing(cap, format);
463  ret = ooCallAddG726Capability(call, OO_G726AAL2, txframes, grxframes, FALSE,
464  OORXANDTX, &ooh323c_start_receive_channel,
468 
469  }
470 
472  {
473 
474  txframes = (ast_format_cap_get_format_framing(cap, format))/10;
475  if (gH323Debug) {
476  ast_verb(0, "\tAdding g729A capability to call(%s, %s)\n",
477  call->callType, call->callToken);
478  }
479  ret= ooCallAddG729Capability(call, OO_G729A, txframes, txframes,
480  OORXANDTX, &ooh323c_start_receive_channel,
484  if (g729onlyA)
485  continue;
486  if (gH323Debug) {
487  ast_verb(0, "\tAdding g729 capability to call(%s, %s)\n",
488  call->callType, call->callToken);
489  }
490  ret|= ooCallAddG729Capability(call, OO_G729, txframes, txframes,
491  OORXANDTX, &ooh323c_start_receive_channel,
495  if (gH323Debug) {
496  ast_verb(0, "\tAdding g729B capability to call(%s, %s)\n",
497  call->callType, call->callToken);
498  }
499  ret|= ooCallAddG729Capability(call, OO_G729B, txframes, txframes,
500  OORXANDTX, &ooh323c_start_receive_channel,
504 
505  }
506 
508  {
509  if (gH323Debug) {
510  ast_verb(0, "\tAdding g7231 capability to call (%s, %s)\n",
511  call->callType, call->callToken);
512  }
513  ret = ooCallAddG7231Capability(call, OO_G7231, 1, 1, FALSE,
514  OORXANDTX, &ooh323c_start_receive_channel,
518 
519  }
520 
522  {
523  if (gH323Debug) {
524  ast_verb(0, "\tAdding h263 capability to call (%s, %s)\n",
525  call->callType, call->callToken);
526  }
527  ret = ooCallAddH263VideoCapability(call, OO_H263VIDEO, 1, 0, 0, 0, 0, 320*1024,
528  OORXANDTX, &ooh323c_start_receive_channel,
532 
533  }
534 
536  {
537  if (gH323Debug) {
538  ast_verb(0, "\tAdding gsm capability to call(%s, %s)\n",
539  call->callType, call->callToken);
540  }
541  ret = ooCallAddGSMCapability(call, OO_GSMFULLRATE, 4, FALSE, FALSE,
542  OORXANDTX, &ooh323c_start_receive_channel,
546  }
547 
549  {
550  if (gH323Debug) {
551  ast_verb(0, "\tAdding Speex capability to call(%s, %s)\n",
552  call->callType, call->callToken);
553  }
554  ret = ooCallAddSpeexCapability(call, OO_SPEEX, 4, 4, FALSE,
555  OORXANDTX, &ooh323c_start_receive_channel,
559  }
560 
561  ao2_ref(format, -1);
562  }
563  return ret;
564 }
struct ast_format * ast_format_g726
Built-in cached g726 format.
Definition: format_cache.c:116
struct ast_format * ast_format_g723
Built-in cached g723.1 format.
Definition: format_cache.c:151
#define FALSE
Definition: app_minivm.c:521
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
Definition: format_cache.c:86
struct ast_format * ast_format_g726_aal2
Built-in cached g726 aal2 format.
Definition: format_cache.c:121
int ooh323c_start_transmit_datachannel(ooCallData *call, ooLogicalChannel *pChannel)
Definition of a media format.
Definition: format.c:43
int ooh323c_start_receive_datachannel(ooCallData *call, ooLogicalChannel *pChannel)
size_t ast_format_cap_count(const struct ast_format_cap *cap)
Get the number of formats present within the capabilities structure.
Definition: format_cap.c:395
static int call(void *data)
Definition: chan_pjsip.c:2358
static int grxframes
Definition: ooh323cDriver.c:36
#define ast_verb(level,...)
Definition: logger.h:463
#define H323_DTMF_CISCO
Definition: ooh323cDriver.h:31
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
struct ast_format * ast_format_gsm
Built-in cached gsm format.
Definition: format_cache.c:101
#define ao2_ref(o, delta)
Definition: astobj2.h:464
int ooh323c_start_receive_channel(ooCallData *call, ooLogicalChannel *pChannel)
#define H323_DTMF_H245ALPHANUMERIC
Definition: ooh323cDriver.h:28
struct ast_format * ast_format_speex
Built-in cached speex format.
Definition: format_cache.c:136
unsigned int ast_format_cap_get_format_framing(const struct ast_format_cap *cap, const struct ast_format *format)
Get the framing for a format.
Definition: format_cap.c:443
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
int ooh323c_stop_transmit_channel(ooCallData *call, ooLogicalChannel *pChannel)
int ooh323c_stop_receive_datachannel(ooCallData *call, ooLogicalChannel *pChannel)
#define H323_DTMF_H245SIGNAL
Definition: ooh323cDriver.h:29
int ooh323c_start_transmit_channel(ooCallData *call, ooLogicalChannel *pChannel)
struct ast_format * ast_format_alaw
Built-in cached alaw format.
Definition: format_cache.c:91
int ooh323c_stop_transmit_datachannel(ooCallData *call, ooLogicalChannel *pChannel)
struct ast_format * ast_format_g729
Built-in cached g729 format.
Definition: format_cache.c:156
struct ast_format * ast_format_cap_get_format(const struct ast_format_cap *cap, int position)
Get the format at a specific index.
Definition: format_cap.c:400
int ooh323c_stop_receive_channel(ooCallData *call, ooLogicalChannel *pChannel)
static int g729onlyA
Definition: chan_ooh323.c:375
static snd_pcm_format_t format
Definition: chan_alsa.c:102
struct ast_format * ast_format_h263
Built-in cached h263 format.
Definition: format_cache.c:171
#define H323_DTMF_RFC2833
Definition: ooh323cDriver.h:26

◆ ooh323c_stack_thread()

void * ooh323c_stack_thread ( void *  dummy)

Definition at line 66 of file ooh323cDriver.c.

References dummy().

Referenced by ooh323c_start_stack_thread().

67 {
68 
69  ooMonitorChannels();
70  return dummy;
71 }
static void dummy(char *unused,...)
Definition: chan_unistim.c:220

◆ ooh323c_start_call_thread()

int ooh323c_start_call_thread ( ooCallData *  call)

Definition at line 130 of file ooh323cDriver.c.

References ast_calloc, ast_debug, ast_free, ast_log, ast_module_ref, ast_mutex_destroy, ast_mutex_init, ast_mutex_lock, ast_mutex_trylock, ast_mutex_unlock, ast_pthread_create_detached_background, c, callthread::call, callThreads, callThreadsLock, gH323Debug, callthread::inUse, callthread::lock, LOG_ERROR, callthread::next, NULL, ooh323c_call_thread(), PF_LOCAL, callthread::thePipe, and TRUE.

Referenced by onNewCallCreated().

130  {
131  char c = 'c';
132  struct callthread *cur = callThreads;
133 
135  while (cur != NULL && (cur->inUse || ast_mutex_trylock(&cur->lock))) {
136  cur = cur->next;
137  }
139 
140  if (cur != NULL) {
141  if (cur->inUse || write(cur->thePipe[1], &c, 1) < 0) {
142  ast_mutex_unlock(&cur->lock);
143  cur = NULL;
144  }
145  }
146 
147 /* make new thread */
148  if (cur == NULL) {
149  if (!(cur = ast_calloc(1, sizeof(struct callthread)))) {
150  ast_log(LOG_ERROR, "Unable to allocate thread structure for call %s\n",
151  call->callToken);
152  return -1;
153  }
154 
156  if ((socketpair(PF_LOCAL, SOCK_STREAM, 0, cur->thePipe)) == -1) {
157  ast_log(LOG_ERROR, "Can't create thread pipe for call %s\n", call->callToken);
158  ast_free(cur);
159  return -1;
160  }
161  cur->inUse = TRUE;
162  cur->call = call;
163 
164  ast_mutex_init(&cur->lock);
165 
166  if (gH323Debug)
167  ast_debug(1,"new call thread created for call %s\n", call->callToken);
168 
170  {
171  ast_log(LOG_ERROR, "Unable to start ooh323c call thread for call %s\n",
172  call->callToken);
173  ast_mutex_destroy(&cur->lock);
174  close(cur->thePipe[0]);
175  close(cur->thePipe[1]);
176  ast_free(cur);
177  return -1;
178  }
179 
180  } else {
181  if (gH323Debug)
182  ast_debug(1,"using existing call thread for call %s\n", call->callToken);
183  cur->inUse = TRUE;
184  cur->call = call;
185  ast_mutex_unlock(&cur->lock);
186 
187  }
188  return 0;
189 }
void * ooh323c_call_thread(void *dummy)
Definition: ooh323cDriver.c:80
ooCallData * call
Definition: ooh323cDriver.c:44
int thePipe[2]
Definition: ooh323cDriver.c:42
static struct callthread * callThreads
#define ast_mutex_lock(a)
Definition: lock.h:187
static struct test_val c
static int call(void *data)
Definition: chan_pjsip.c:2358
#define NULL
Definition: resample.c:96
#define ast_pthread_create_detached_background(a, b, c, d)
Definition: utils.h:572
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
static ast_mutex_t callThreadsLock
Definition: ooh323cDriver.c:48
#define ast_mutex_trylock(a)
Definition: lock.h:189
#define LOG_ERROR
Definition: logger.h:285
#define PF_LOCAL
Definition: asterisk.c:293
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
OOBOOL gH323Debug
Definition: chan_ooh323.c:381
ast_mutex_t lock
Definition: ooh323cDriver.c:41
#define TRUE
Definition: app_minivm.c:518
#define ast_mutex_init(pmutex)
Definition: lock.h:184
#define ast_mutex_destroy(a)
Definition: lock.h:186
OOBOOL inUse
Definition: ooh323cDriver.c:43
struct callthread * next
Definition: ooh323cDriver.c:45
struct ast_module * myself
Definition: chan_ooh323.c:113
#define ast_mutex_unlock(a)
Definition: lock.h:188
#define ast_module_ref(mod)
Hold a reference to the module.
Definition: module.h:443

◆ ooh323c_start_receive_channel()

int ooh323c_start_receive_channel ( ooCallData *  call,
ooLogicalChannel *  pChannel 
)

Definition at line 593 of file ooh323cDriver.c.

References ast_log, convertH323CapToAsteriskCap(), LOG_ERROR, and NULL.

Referenced by ooh323c_set_capability(), and ooh323c_set_capability_for_call().

594 {
595  struct ast_format *tmpfmt = NULL;
596  tmpfmt = convertH323CapToAsteriskCap(pChannel->chanCap->cap);
597  if(tmpfmt) {
598  /* ooh323_set_read_format(call, fmt); */
599  }else{
600  ast_log(LOG_ERROR, "Invalid capability type for receive channel %s\n",
601  call->callToken);
602  return -1;
603  }
604  return 1;
605 }
Definition of a media format.
Definition: format.c:43
static int call(void *data)
Definition: chan_pjsip.c:2358
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
Definition: logger.h:285
struct ast_format * convertH323CapToAsteriskCap(int cap)

◆ ooh323c_start_receive_datachannel()

int ooh323c_start_receive_datachannel ( ooCallData *  call,
ooLogicalChannel *  pChannel 
)

Definition at line 642 of file ooh323cDriver.c.

Referenced by ooh323c_set_capability_for_call().

643 {
644  return 1;
645 }

◆ ooh323c_start_stack_thread()

int ooh323c_start_stack_thread ( void  )

Definition at line 199 of file ooh323cDriver.c.

References ast_log, ast_pthread_create_background, LOG_ERROR, NULL, ooh323c_cmd_thread(), ooh323c_stack_thread(), ooh323c_thread, and ooh323cmd_thread.

Referenced by load_module().

200 {
202  {
203  ast_log(LOG_ERROR, "Unable to start ooh323c thread.\n");
204  return -1;
205  }
207  {
208  ast_log(LOG_ERROR, "Unable to start ooh323cmd thread.\n");
209  return -1;
210  }
211  return 0;
212 }
#define NULL
Definition: resample.c:96
static pthread_t ooh323c_thread
Definition: ooh323cDriver.c:34
#define ast_pthread_create_background(a, b, c, d)
Definition: utils.h:567
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
Definition: logger.h:285
static pthread_t ooh323cmd_thread
Definition: ooh323cDriver.c:35
void * ooh323c_cmd_thread(void *dummy)
Definition: ooh323cDriver.c:73
void * ooh323c_stack_thread(void *dummy)
Definition: ooh323cDriver.c:66

◆ ooh323c_start_transmit_channel()

int ooh323c_start_transmit_channel ( ooCallData *  call,
ooLogicalChannel *  pChannel 
)

Definition at line 607 of file ooh323cDriver.c.

References ast_format_alaw, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_g729, ast_format_ulaw, ast_log, convertH323CapToAsteriskCap(), LOG_ERROR, NULL, ooh323_set_write_format(), and setup_rtp_connection().

Referenced by ooh323c_set_capability(), and ooh323c_set_capability_for_call().

608 {
609  struct ast_format *tmpfmt = NULL;
610  tmpfmt = convertH323CapToAsteriskCap(pChannel->chanCap->cap);
611 
612  if (tmpfmt) {
615  ooh323_set_write_format(call, tmpfmt, ((OOCapParams *)(pChannel->chanCap->params))->txframes);
616  } else if (ast_format_cmp(tmpfmt, ast_format_g729) == AST_FORMAT_CMP_EQUAL) {
617  ooh323_set_write_format(call, tmpfmt, ((OOCapParams *)(pChannel->chanCap->params))->txframes*10);
618  } else {
619  ooh323_set_write_format(call, tmpfmt, 0);
620  }
621  }else{
622  ast_log(LOG_ERROR, "Invalid capability type for receive channel %s\n",
623  call->callToken);
624  return -1;
625  }
626  setup_rtp_connection(call, pChannel->remoteIP, pChannel->remoteMediaPort);
627  return 1;
628 }
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
Definition: format_cache.c:86
Definition of a media format.
Definition: format.c:43
static int call(void *data)
Definition: chan_pjsip.c:2358
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
#define LOG_ERROR
Definition: logger.h:285
struct ast_format * convertH323CapToAsteriskCap(int cap)
void setup_rtp_connection(ooCallData *call, const char *remoteIp, int remotePort)
Definition: chan_ooh323.c:4775
struct ast_format * ast_format_alaw
Built-in cached alaw format.
Definition: format_cache.c:91
struct ast_format * ast_format_g729
Built-in cached g729 format.
Definition: format_cache.c:156
void ooh323_set_write_format(ooCallData *call, struct ast_format *fmt, int txframes)
Definition: chan_ooh323.c:1553

◆ ooh323c_start_transmit_datachannel()

int ooh323c_start_transmit_datachannel ( ooCallData *  call,
ooLogicalChannel *  pChannel 
)

Definition at line 647 of file ooh323cDriver.c.

References setup_udptl_connection().

Referenced by ooh323c_set_capability_for_call().

648 {
649  setup_udptl_connection(call, pChannel->remoteIP, pChannel->remoteMediaPort);
650  return 1;
651 }
static int call(void *data)
Definition: chan_pjsip.c:2358
void setup_udptl_connection(ooCallData *call, const char *remoteIp, int remotePort)
Definition: chan_ooh323.c:4839

◆ ooh323c_stop_call_thread()

int ooh323c_stop_call_thread ( ooCallData *  call)

Definition at line 192 of file ooh323cDriver.c.

References AST_PTHREADT_NULL.

Referenced by onCallCleared().

192  {
193  if (call->callThread != AST_PTHREADT_NULL) {
194  ooStopMonitorCallChannels(call);
195  }
196  return 0;
197 }
static int call(void *data)
Definition: chan_pjsip.c:2358
#define AST_PTHREADT_NULL
Definition: lock.h:66

◆ ooh323c_stop_receive_channel()

int ooh323c_stop_receive_channel ( ooCallData *  call,
ooLogicalChannel *  pChannel 
)

Definition at line 630 of file ooh323cDriver.c.

Referenced by ooh323c_set_capability(), and ooh323c_set_capability_for_call().

631 {
632  return 1;
633 }

◆ ooh323c_stop_receive_datachannel()

int ooh323c_stop_receive_datachannel ( ooCallData *  call,
ooLogicalChannel *  pChannel 
)

Definition at line 653 of file ooh323cDriver.c.

Referenced by ooh323c_set_capability_for_call().

654 {
655  return 1;
656 }

◆ ooh323c_stop_stack_thread()

int ooh323c_stop_stack_thread ( void  )

Definition at line 214 of file ooh323cDriver.c.

References AST_PTHREADT_NULL, NULL, ooh323c_set_capability(), ooh323c_thread, and ooh323cmd_thread.

Referenced by unload_module().

215 {
217  {
218  ooStopMonitor();
219  pthread_join(ooh323c_thread, NULL);
221  pthread_join(ooh323cmd_thread, NULL);
223  }
224  return 0;
225 }
#define NULL
Definition: resample.c:96
static pthread_t ooh323c_thread
Definition: ooh323cDriver.c:34
#define AST_PTHREADT_NULL
Definition: lock.h:66
static pthread_t ooh323cmd_thread
Definition: ooh323cDriver.c:35

◆ ooh323c_stop_transmit_channel()

int ooh323c_stop_transmit_channel ( ooCallData *  call,
ooLogicalChannel *  pChannel 
)

Definition at line 635 of file ooh323cDriver.c.

References close_rtp_connection().

Referenced by ooh323c_set_capability(), and ooh323c_set_capability_for_call().

636 {
638  return 1;
639 }
static int call(void *data)
Definition: chan_pjsip.c:2358
void close_rtp_connection(ooCallData *call)
Definition: chan_ooh323.c:4810

◆ ooh323c_stop_transmit_datachannel()

int ooh323c_stop_transmit_datachannel ( ooCallData *  call,
ooLogicalChannel *  pChannel 
)

Definition at line 658 of file ooh323cDriver.c.

References close_udptl_connection().

Referenced by ooh323c_set_capability_for_call().

659 {
661  return 1;
662 }
void close_udptl_connection(ooCallData *call)
Definition: chan_ooh323.c:4901
static int call(void *data)
Definition: chan_pjsip.c:2358

Variable Documentation

◆ callThreads

struct callthread * callThreads = NULL
static

◆ callThreadsLock

ast_mutex_t callThreadsLock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
static

Definition at line 48 of file ooh323cDriver.c.

Referenced by ooh323c_call_thread(), and ooh323c_start_call_thread().

◆ gH323Debug

OOBOOL gH323Debug

◆ gH323ep

OOH323EndPoint gH323ep

◆ grxframes

int grxframes = 240
static

Definition at line 36 of file ooh323cDriver.c.

Referenced by ooh323c_set_capability(), and ooh323c_set_capability_for_call().

◆ gtxframes

int gtxframes = 20
static

Definition at line 38 of file ooh323cDriver.c.

Referenced by ooh323c_set_capability().

◆ myself

struct ast_module* myself

Definition at line 113 of file chan_ooh323.c.

◆ ooh323c_thread

pthread_t ooh323c_thread = AST_PTHREADT_NULL
static

Definition at line 34 of file ooh323cDriver.c.

Referenced by ooh323c_start_stack_thread(), and ooh323c_stop_stack_thread().

◆ ooh323cmd_thread

pthread_t ooh323cmd_thread = AST_PTHREADT_NULL
static

Definition at line 35 of file ooh323cDriver.c.

Referenced by ooh323c_start_stack_thread(), and ooh323c_stop_stack_thread().