Fri Jul 3 20:38:46 2009

Asterisk developer's documentation


ooh323cDriver.c File Reference

#include "ooh323cDriver.h"
#include <asterisk/pbx.h>
#include <asterisk/logger.h>

Include dependency graph for ooh323cDriver.c:

Go to the source code of this file.

Functions

int convertH323CapToAsteriskCap (int cap)
int ooh323c_set_aliases (ooAliases *aliases)
int ooh323c_set_capability (struct ast_codec_pref *prefs, int capability, int dtmf)
int ooh323c_set_capability_for_call (ooCallData *call, struct ast_codec_pref *prefs, int capability, int dtmf)
void * ooh323c_stack_thread (void *dummy)
int ooh323c_start_receive_channel (ooCallData *call, ooLogicalChannel *pChannel)
int ooh323c_start_stack_thread ()
int ooh323c_start_transmit_channel (ooCallData *call, ooLogicalChannel *pChannel)
int ooh323c_stop_receive_channel (ooCallData *call, ooLogicalChannel *pChannel)
int ooh323c_stop_stack_thread (void)
int ooh323c_stop_transmit_channel (ooCallData *call, ooLogicalChannel *pChannel)

Variables

OOBOOL gH323Debug
static int grxframes = 240
static int gtxframes = 20
static pthread_t ooh323c_thread = AST_PTHREADT_NULL


Function Documentation

int convertH323CapToAsteriskCap ( int  cap  ) 

Definition at line 333 of file ooh323cDriver.c.

References AST_FORMAT_ALAW, AST_FORMAT_G723_1, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_H263, AST_FORMAT_ULAW, ast_log(), and LOG_DEBUG.

Referenced by ooh323c_start_receive_channel(), and ooh323c_start_transmit_channel().

00334 {
00335 
00336    switch(cap)
00337    {
00338       case OO_G711ULAW64K:
00339          return AST_FORMAT_ULAW;
00340       case OO_G711ALAW64K:
00341          return AST_FORMAT_ALAW;
00342       case OO_GSMFULLRATE:
00343          return AST_FORMAT_GSM;
00344       case OO_G729:
00345          return AST_FORMAT_G729A;
00346       case OO_G729A:
00347          return AST_FORMAT_G729A;
00348       case OO_G7231:
00349          return AST_FORMAT_G723_1;
00350       case OO_H263VIDEO:
00351          return AST_FORMAT_H263;
00352       default:
00353          ast_log(LOG_DEBUG, "Cap %d is not supported by driver yet\n");
00354          return -1;
00355    }
00356 
00357    return -1;
00358 }

int ooh323c_set_aliases ( ooAliases *  aliases  ) 

Definition at line 266 of file ooh323cDriver.c.

References ast_log(), and LOG_DEBUG.

00267 {
00268    ooAliases *cur = aliases;
00269    while(cur)
00270    {
00271       switch(cur->type)
00272       { 
00273       case T_H225AliasAddress_dialedDigits:
00274          ooH323EpAddAliasDialedDigits(cur->value);
00275          break;
00276       case T_H225AliasAddress_h323_ID:
00277          ooH323EpAddAliasH323ID(cur->value);
00278          break;
00279       case T_H225AliasAddress_url_ID:
00280          ooH323EpAddAliasURLID(cur->value);
00281          break;
00282       case T_H225AliasAddress_email_ID:
00283          ooH323EpAddAliasEmailID(cur->value);
00284          break;
00285       default:
00286          ast_log(LOG_DEBUG, "Ignoring unknown alias type\n");
00287       }
00288       cur = cur->next;
00289    }
00290    return 1;
00291 }

int ooh323c_set_capability ( struct ast_codec_pref *  prefs,
int  capability,
int  dtmf 
)

Definition at line 63 of file ooh323cDriver.c.

References ast_codec_pref_index(), AST_FORMAT_ALAW, AST_FORMAT_G723_1, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_H263, AST_FORMAT_ULAW, ast_verbose(), FALSE, format, gH323Debug, grxframes, gtxframes, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_RFC2833, ooh323c_start_receive_channel(), ooh323c_start_transmit_channel(), ooh323c_stop_receive_channel(), and ooh323c_stop_transmit_channel().

Referenced by load_module().

00064 {
00065    int ret, x, format=0;
00066    if(gH323Debug)
00067      ast_verbose("\tAdding capabilities to H323 endpoint\n");
00068    
00069    for(x=0; 0 != (format=ast_codec_pref_index(prefs, x)); x++)
00070    {
00071       if(format & AST_FORMAT_ULAW)
00072       {
00073          if(gH323Debug)
00074             ast_verbose("\tAdding g711 ulaw capability to H323 endpoint\n");
00075          ret= ooH323EpAddG711Capability(OO_G711ULAW64K, gtxframes, grxframes, 
00076                                      OORXANDTX, &ooh323c_start_receive_channel,
00077                                      &ooh323c_start_transmit_channel,
00078                                      &ooh323c_stop_receive_channel, 
00079                                      &ooh323c_stop_transmit_channel);
00080       }
00081       if(format & AST_FORMAT_ALAW)
00082       {
00083          if(gH323Debug)
00084             ast_verbose("\tAdding g711 alaw capability to H323 endpoint\n");
00085          ret= ooH323EpAddG711Capability(OO_G711ALAW64K, gtxframes, grxframes, 
00086                                      OORXANDTX, &ooh323c_start_receive_channel,
00087                                      &ooh323c_start_transmit_channel,
00088                                      &ooh323c_stop_receive_channel, 
00089                                      &ooh323c_stop_transmit_channel);
00090       }
00091 
00092       if(format & AST_FORMAT_G729A)
00093       {
00094          if(gH323Debug)
00095             ast_verbose("\tAdding g729A capability to H323 endpoint\n");
00096          ret = ooH323EpAddG729Capability(OO_G729A, 2, 24, 
00097                                      OORXANDTX, &ooh323c_start_receive_channel,
00098                                      &ooh323c_start_transmit_channel,
00099                                      &ooh323c_stop_receive_channel, 
00100                                      &ooh323c_stop_transmit_channel);
00101 
00102          if(gH323Debug)
00103             ast_verbose("\tAdding g729 capability to H323 endpoint\n");
00104          ret |= ooH323EpAddG729Capability(OO_G729, 2, 24, 
00105                                      OORXANDTX, &ooh323c_start_receive_channel,
00106                                      &ooh323c_start_transmit_channel,
00107                                      &ooh323c_stop_receive_channel, 
00108                                      &ooh323c_stop_transmit_channel);
00109       }
00110 
00111       if(format & AST_FORMAT_G723_1)
00112       {
00113          if(gH323Debug)
00114             ast_verbose("\tAdding g7231 capability to H323 endpoint\n");
00115          ret = ooH323EpAddG7231Capability(OO_G7231, 4, 7, FALSE, 
00116                                      OORXANDTX, &ooh323c_start_receive_channel,
00117                                      &ooh323c_start_transmit_channel,
00118                                      &ooh323c_stop_receive_channel, 
00119                                      &ooh323c_stop_transmit_channel);
00120 
00121       }
00122 
00123       if(format & AST_FORMAT_H263)
00124       {
00125          if(gH323Debug)
00126             ast_verbose("\tAdding h263 capability to H323 endpoint\n");
00127          ret = ooH323EpAddH263VideoCapability(OO_H263VIDEO, 1, 0, 0, 0, 0, 320*1024, 
00128                                      OORXANDTX, &ooh323c_start_receive_channel,
00129                                      &ooh323c_start_transmit_channel,
00130                                      &ooh323c_stop_receive_channel, 
00131                                      &ooh323c_stop_transmit_channel);
00132 
00133       }
00134 
00135       if(format & AST_FORMAT_GSM)
00136       {
00137          if(gH323Debug)
00138             ast_verbose("\tAdding gsm capability to H323 endpoint\n");
00139          ret = ooH323EpAddGSMCapability(OO_GSMFULLRATE, 4, FALSE, FALSE, 
00140                                      OORXANDTX, &ooh323c_start_receive_channel,
00141                                      &ooh323c_start_transmit_channel,
00142                                      &ooh323c_stop_receive_channel, 
00143                                      &ooh323c_stop_transmit_channel);
00144 
00145       }
00146       
00147    }
00148    
00149    if(dtmf & H323_DTMF_RFC2833)
00150       ret |= ooH323EpEnableDTMFRFC2833(0);
00151    else if(dtmf & H323_DTMF_H245ALPHANUMERIC)
00152       ret |= ooH323EpEnableDTMFH245Alphanumeric();
00153    else if(dtmf & H323_DTMF_H245SIGNAL)
00154       ret |= ooH323EpEnableDTMFH245Signal();
00155 
00156    return ret;
00157 }

int ooh323c_set_capability_for_call ( ooCallData *  call,
struct ast_codec_pref *  prefs,
int  capability,
int  dtmf 
)

Definition at line 160 of file ooh323cDriver.c.

References ast_codec_pref_index(), AST_FORMAT_ALAW, AST_FORMAT_G723_1, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_H263, AST_FORMAT_ULAW, ast_verbose(), FALSE, format, ast_codec_pref::framing, gH323Debug, grxframes, H323_DTMF_H245ALPHANUMERIC, H323_DTMF_H245SIGNAL, H323_DTMF_RFC2833, ooh323c_start_receive_channel(), ooh323c_start_transmit_channel(), ooh323c_stop_receive_channel(), and ooh323c_stop_transmit_channel().

Referenced by onNewCallCreated(), and ooh323_onReceivedSetup().

00161 {
00162    int ret, x, txframes, rxframes;
00163    int format=0;
00164    if(gH323Debug)
00165      ast_verbose("\tAdding capabilities to call(%s, %s)\n", call->callType, 
00166                                                             call->callToken);
00167    if(dtmf & H323_DTMF_RFC2833)
00168       ret |= ooCallEnableDTMFRFC2833(call,0);
00169    else if(dtmf & H323_DTMF_H245ALPHANUMERIC)
00170       ret |= ooCallEnableDTMFH245Alphanumeric(call);
00171    else if(dtmf & H323_DTMF_H245SIGNAL)
00172       ret |= ooCallEnableDTMFH245Signal(call);
00173 
00174 
00175    for(x=0; 0 !=(format=ast_codec_pref_index(prefs, x)); x++)
00176    {
00177       if(format & AST_FORMAT_ULAW)
00178       {
00179          if(gH323Debug)
00180             ast_verbose("\tAdding g711 ulaw capability to call(%s, %s)\n", 
00181                                               call->callType, call->callToken);
00182     txframes = prefs->framing[x];
00183          ret= ooCallAddG711Capability(call, OO_G711ULAW64K, txframes, 
00184                                       grxframes, OORXANDTX, 
00185                                       &ooh323c_start_receive_channel,
00186                                       &ooh323c_start_transmit_channel,
00187                                       &ooh323c_stop_receive_channel, 
00188                                       &ooh323c_stop_transmit_channel);
00189       }
00190       if(format & AST_FORMAT_ALAW)
00191       {
00192          if(gH323Debug)
00193             ast_verbose("\tAdding g711 alaw capability to call(%s, %s)\n",
00194                                             call->callType, call->callToken);
00195          txframes = prefs->framing[x];
00196          ret= ooCallAddG711Capability(call, OO_G711ALAW64K, txframes, 
00197                                      grxframes, OORXANDTX, 
00198                                      &ooh323c_start_receive_channel,
00199                                      &ooh323c_start_transmit_channel,
00200                                      &ooh323c_stop_receive_channel, 
00201                                      &ooh323c_stop_transmit_channel);
00202       }
00203 
00204       if(format & AST_FORMAT_G729A)
00205       {
00206          if(gH323Debug)
00207             ast_verbose("\tAdding g729A capability to call(%s, %s)\n",
00208                                             call->callType, call->callToken);
00209          txframes = (prefs->framing[x])/10;
00210          ret= ooCallAddG729Capability(call, OO_G729A, txframes, 24, 
00211                                      OORXANDTX, &ooh323c_start_receive_channel,
00212                                      &ooh323c_start_transmit_channel,
00213                                      &ooh323c_stop_receive_channel, 
00214                                      &ooh323c_stop_transmit_channel);
00215 
00216          if(gH323Debug)
00217             ast_verbose("\tAdding g729 capability to call(%s, %s)\n",
00218                                             call->callType, call->callToken);
00219          ret|= ooCallAddG729Capability(call, OO_G729, txframes, 24, 
00220                                      OORXANDTX, &ooh323c_start_receive_channel,
00221                                      &ooh323c_start_transmit_channel,
00222                                      &ooh323c_stop_receive_channel, 
00223                                      &ooh323c_stop_transmit_channel);
00224       }
00225 
00226       if(format & AST_FORMAT_G723_1)
00227       {
00228          if(gH323Debug)
00229             ast_verbose("\tAdding g7231 capability to call (%s, %s)\n",
00230                                            call->callType, call->callToken);
00231          ret = ooCallAddG7231Capability(call, OO_G7231, 4, 7, FALSE, 
00232                                      OORXANDTX, &ooh323c_start_receive_channel,
00233                                      &ooh323c_start_transmit_channel,
00234                                      &ooh323c_stop_receive_channel, 
00235                                      &ooh323c_stop_transmit_channel);
00236 
00237       }
00238 
00239       if(format & AST_FORMAT_H263)
00240       {
00241          if(gH323Debug)
00242             ast_verbose("\tAdding h263 capability to call (%s, %s)\n",
00243                                            call->callType, call->callToken);
00244          ret = ooCallAddH263VideoCapability(call, OO_H263VIDEO, 1, 0, 0, 0, 0, 320*1024, 
00245                                      OORXANDTX, &ooh323c_start_receive_channel,
00246                                      &ooh323c_start_transmit_channel,
00247                                      &ooh323c_stop_receive_channel, 
00248                                      &ooh323c_stop_transmit_channel);
00249 
00250       }
00251 
00252       if(format & AST_FORMAT_GSM)
00253       {
00254          if(gH323Debug)
00255             ast_verbose("\tAdding gsm capability to call(%s, %s)\n", 
00256                                              call->callType, call->callToken);
00257          ret = ooCallAddGSMCapability(call, OO_GSMFULLRATE, 4, FALSE, FALSE, 
00258                                      OORXANDTX, &ooh323c_start_receive_channel,
00259                                      &ooh323c_start_transmit_channel,
00260                                      &ooh323c_stop_receive_channel, 
00261                                      &ooh323c_stop_transmit_channel);
00262       }
00263    }
00264 }

void* ooh323c_stack_thread ( void *  dummy  ) 

Definition at line 34 of file ooh323cDriver.c.

Referenced by ooh323c_start_stack_thread().

00035 {
00036 
00037   ooMonitorChannels();
00038   return dummy;
00039 }

int ooh323c_start_receive_channel ( ooCallData *  call,
ooLogicalChannel *  pChannel 
)

Definition at line 293 of file ooh323cDriver.c.

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

Referenced by ooh323c_set_capability(), and ooh323c_set_capability_for_call().

00294 {
00295    int fmt=-1;
00296    fmt = convertH323CapToAsteriskCap(pChannel->chanCap->cap);
00297    if(fmt>0)
00298       ooh323_set_read_format(call, fmt);
00299    else{
00300      ast_log(LOG_ERROR, "Invalid capability type for receive channel %s\n",
00301                                                           call->callToken);
00302      return -1;
00303    }
00304    return 1;
00305 }

int ooh323c_start_stack_thread ( void   ) 

Definition at line 41 of file ooh323cDriver.c.

References ast_log(), ast_pthread_create, LOG_ERROR, ooh323c_stack_thread(), and ooh323c_thread.

Referenced by load_module().

00042 {
00043    if(ast_pthread_create(&ooh323c_thread, NULL, ooh323c_stack_thread, NULL) < 0)
00044    {
00045       ast_log(LOG_ERROR, "Unable to start ooh323c thread.\n");
00046       return -1;
00047    }
00048    return 0;
00049 }

int ooh323c_start_transmit_channel ( ooCallData *  call,
ooLogicalChannel *  pChannel 
)

Definition at line 307 of file ooh323cDriver.c.

References ast_log(), convertH323CapToAsteriskCap(), LOG_ERROR, ooh323_set_write_format(), and setup_rtp_connection().

Referenced by ooh323c_set_capability(), and ooh323c_set_capability_for_call().

00308 {
00309    int fmt=-1;
00310    fmt = convertH323CapToAsteriskCap(pChannel->chanCap->cap);
00311    if(fmt>0)
00312       ooh323_set_write_format(call, fmt);
00313    else{
00314       ast_log(LOG_ERROR, "Invalid capability type for receive channel %s\n",
00315                                                           call->callToken);
00316       return -1;
00317    }
00318    setup_rtp_connection(call, pChannel->remoteIP, pChannel->remoteMediaPort);
00319     return 1;
00320 }

int ooh323c_stop_receive_channel ( ooCallData *  call,
ooLogicalChannel *  pChannel 
)

Definition at line 322 of file ooh323cDriver.c.

Referenced by ooh323c_set_capability(), and ooh323c_set_capability_for_call().

00323 {
00324    return 1;
00325 }

int ooh323c_stop_stack_thread ( void   ) 

Definition at line 51 of file ooh323cDriver.c.

References AST_PTHREADT_NULL, and ooh323c_thread.

Referenced by unload_module().

00052 {
00053    if(ooh323c_thread !=  AST_PTHREADT_NULL)
00054    {
00055       ooStopMonitor();
00056       pthread_join(ooh323c_thread, NULL);
00057       ooh323c_thread =  AST_PTHREADT_NULL;
00058    }
00059    return 0;
00060 }

int ooh323c_stop_transmit_channel ( ooCallData *  call,
ooLogicalChannel *  pChannel 
)

Definition at line 327 of file ooh323cDriver.c.

References close_rtp_connection().

Referenced by ooh323c_set_capability(), and ooh323c_set_capability_for_call().

00328 {
00329    close_rtp_connection(call);
00330    return 1;
00331 }


Variable Documentation

OOBOOL gH323Debug

int grxframes = 240 [static]

Definition at line 25 of file ooh323cDriver.c.

Referenced by ooh323c_set_capability(), and ooh323c_set_capability_for_call().

int gtxframes = 20 [static]

Definition at line 27 of file ooh323cDriver.c.

Referenced by ooh323c_set_capability().

pthread_t ooh323c_thread = AST_PTHREADT_NULL [static]

Definition at line 24 of file ooh323cDriver.c.

Referenced by ooh323c_start_stack_thread(), and ooh323c_stop_stack_thread().


Generated on Fri Jul 3 20:38:47 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.9