|
Yate
|
IAX engine class. More...
#include <yateiax.h>
Public Member Functions | |
| IAXEngine (const char *iface, int port, u_int32_t format, u_int32_t capab, const NamedList *params=0, const char *name="iaxengine") | |
| virtual | ~IAXEngine () |
| const String & | name () const |
| u_int8_t | callerNumType () const |
| u_int8_t | callingPres () const |
| IAXTransaction * | addFrame (const SocketAddr &addr, IAXFrame *frame) |
| IAXTransaction * | addFrame (const SocketAddr &addr, const unsigned char *buf, unsigned int len) |
| IAXTransaction * | findTransaction (const SocketAddr &addr, u_int16_t rCallNo) |
| virtual void | processMedia (IAXTransaction *transaction, DataBlock &data, u_int32_t tStamp, int type, bool mark) |
| bool | process () |
| unsigned int | challengeTout () const |
| u_int16_t | maxFullFrameDataLen () const |
| u_int32_t | format (bool audio=true) const |
| u_int32_t | capability () const |
| void | getOutDataAdjust (unsigned int &thres, unsigned int &over, unsigned int &under) const |
| void | initOutDataAdjust (const NamedList ¶ms, IAXTransaction *tr=0) |
| void | initialize (const NamedList ¶ms) |
| void | readSocket (SocketAddr &addr) |
| bool | writeSocket (const void *buf, int len, const SocketAddr &addr, IAXFullFrame *frame=0, unsigned int *sent=0) |
| bool | writeSocket (const SocketAddr &addr, IAXFullFrame *frame) |
| void | runGetEvents () |
| void | removeTransaction (IAXTransaction *transaction) |
| bool | haveTransactions () |
| u_int32_t | transactionCount () |
| void | keepAlive (const SocketAddr &addr) |
| virtual bool | mediaFormatChanged (IAXTransaction *trans, int type, u_int32_t format) |
| virtual bool | checkCallToken (const SocketAddr &addr, IAXFullFrame &frame) |
| bool | acceptFormatAndCapability (IAXTransaction *trans, unsigned int *caps=0, int type=IAXFormat::Audio) |
| virtual void | defaultEventHandler (IAXEvent *event) |
| bool | exiting () const |
| virtual void | setExiting () |
| void | enableTrunking (IAXTransaction *trans, const NamedList *params, const String &prefix=String::empty()) |
| void | enableTrunking (IAXTransaction *trans, IAXTrunkInfo &data) |
| void | initTrunkIn (IAXTransaction *trans, const NamedList *params, const String &prefix=String::empty()) |
| void | initTrunkIn (IAXTransaction *trans, IAXTrunkInfo &data) |
| bool | trunkInfo (RefPointer< IAXTrunkInfo > &info) |
| void | sendInval (IAXFullFrame *frame, const SocketAddr &addr) |
| void | runProcessTrunkFrames () |
| Socket & | socket () |
| const SocketAddr & | addr () const |
| void | setFormats (u_int32_t caps, u_int32_t fmtAudio, u_int32_t fmtVideo) |
Public Member Functions inherited from DebugEnabler | |
| DebugEnabler (int level=TelEngine::debugLevel(), bool enabled=true) | |
| int | debugLevel () const |
| int | debugLevel (int level) |
| bool | debugEnabled () const |
| void | debugEnabled (bool enable) |
| const char * | debugName () const |
| bool | debugAt (int level) const |
| bool | debugChained () const |
| void | debugChain (const DebugEnabler *chain=0) |
| void | debugCopy (const DebugEnabler *original=0) |
Public Member Functions inherited from Mutex | |
| Mutex (bool recursive=false, const char *name=0) | |
| Mutex (const Mutex &original) | |
| ~Mutex () | |
| Mutex & | operator= (const Mutex &original) |
| virtual bool | lock (long maxwait=-1) |
| virtual bool | unlock () |
| virtual bool | locked () const |
| const char * | owner () const |
| bool | recursive () const |
Public Member Functions inherited from Lockable | |
| virtual | ~Lockable () |
| virtual bool | check (long maxwait=-1) |
| virtual bool | unlockAll () |
Static Public Member Functions | |
| static int | getPort (const NamedList ¶ms, const String ¶m="port") |
| static void | getMD5FromChallenge (String &md5data, const String &challenge, const String &password) |
| static bool | isMD5ChallengeCorrect (const String &md5data, const String &challenge, const String &password) |
| static void | buildAddrSecret (String &buf, const String &secret, const SocketAddr &addr) |
| static int | addrSecretAge (const String &buf, const String &secret, const SocketAddr &addr) |
| static void | addKeyword (NamedList &list, const char *param, const TokenDict *tokens, unsigned int val) |
| static void | decodeDateTime (u_int32_t dt, unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &sec) |
| static unsigned int | overallTout (unsigned int interval=IAX2_RETRANS_INTERVAL_DEF, unsigned int nRetrans=IAX2_RETRANS_COUNT_DEF) |
Static Public Member Functions inherited from Mutex | |
| static int | count () |
| static int | locks () |
| static bool | efficientTimedLock () |
Static Public Member Functions inherited from Lockable | |
| static void | wait (unsigned long maxwait) |
| static unsigned long | wait () |
| static void | startUsingNow () |
| static void | enableSafety (bool safe=true) |
| static bool | safety () |
Protected Member Functions | |
| bool | processTrunkFrames (const Time &time=Time()) |
| virtual void | processEvent (IAXEvent *event) |
| IAXEvent * | getEvent (const Time &now=Time()) |
| u_int16_t | generateCallNo () |
| void | releaseCallNo (u_int16_t lcallno) |
| IAXTransaction * | startLocalTransaction (IAXTransaction::Type type, const SocketAddr &addr, IAXIEList &ieList, bool refTrans=false, bool startTrans=true) |
| bool | bind (const char *iface, int port, bool force) |
Protected Member Functions inherited from DebugEnabler | |
| void | debugName (const char *name) |
Protected Attributes | |
| int | m_trunking |
IAX engine class.
This class holds all information needded to manipulate all IAX transactions and events
|
virtual |
Destructor Closes all transactions belonging to this engine and flush all queues
| bool acceptFormatAndCapability | ( | IAXTransaction * | trans, |
| unsigned int * | caps = 0, | ||
| int | type = IAXFormat::Audio ) |
Process the initial received format and capability. If accepted on exit will set the transaction format and capability
| trans | Transaction that received the new format |
| caps | Optional codecs to set in transaction before processing |
| type | Media type |
| IAXTransaction * addFrame | ( | const SocketAddr & | addr, |
| const unsigned char * | buf, | ||
| unsigned int | len ) |
Add a raw frame to the transaction list
| addr | Address from which the message was received |
| buf | Pointer to the start of the buffer holding the IAX frame |
| len | Length of the message buffer |
References addr().
| IAXTransaction * addFrame | ( | const SocketAddr & | addr, |
| IAXFrame * | frame ) |
Add a parsed frame to the transaction list
| addr | Address from which the frame was received |
| frame | A parsed IAX frame |
References addr().
|
inlinestatic |
Add string (keyword) if found in a dictionary or integer parameter to a named list
| list | Destination list |
| param | Parameter to add to the list |
| tokens | The dictionary used to find the given value |
| val | The value to find/add to the list |
References NamedList::addParam().
|
inline |
Retrieve the socket address on wgich we are bound
Referenced by addFrame(), addFrame(), addrSecretAge(), buildAddrSecret(), checkCallToken(), findTransaction(), keepAlive(), readSocket(), sendInval(), startLocalTransaction(), writeSocket(), and writeSocket().
|
static |
Decode a secret built using buildAddrSecret()
| buf | Input buffer |
| secret | Extra secret to check |
| addr | Socket address |
References addr().
|
protected |
Bind the socket. Terminate it before trying
| iface | Address of the interface to use, default all (0.0.0.0) |
| port | UDP port to run the protocol on |
| force | Force binding if failed on required port |
References Mutex::Mutex().
|
static |
|
inline |
Retrieve the default caller number type
|
inline |
Retrieve the default caller number presentation and screening concatenated value
|
inline |
Get the media capability of this engine
|
inline |
Get the timeout interval sent challenge
|
virtual |
Check call token on incoming call requests. This method is called by the engine when processing an incoming call request
| addr | The address from where the call request was received |
| frame | Received frame |
References addr().
|
static |
Decode a DATETIME value
| dt | Value to decode |
| year | The year component of the date |
| month | The month component of the date |
| day | The day component of the date |
| hour | The hour component of the time |
| minute | The minute component of the time |
| sec | The seconds component of the time |
|
virtual |
Default event handler. event MUST NOT be deleted
| event | The event to handle |
| void enableTrunking | ( | IAXTransaction * | trans, |
| const NamedList * | params, | ||
| const String & | prefix = String::empty() ) |
Enable trunking for the given transaction. Allocate a trunk meta frame if needed. Trunk data is ignored if a trunk object for transaction remote address already exists
| trans | Transaction to enable trunking for |
| params | Trunk parameters list, may be 0 |
| prefix | Trunk parameters name prefix |
References String::empty().
| void enableTrunking | ( | IAXTransaction * | trans, |
| IAXTrunkInfo & | data ) |
Enable trunking for the given transaction. Allocate a trunk meta frame if needed. Trunk data is ignored if a trunk object for transaction remote address already exists
| trans | Transaction to enable trunking for |
| data | Trunk info to use |
|
inline |
Check if the engine is exiting
| IAXTransaction * findTransaction | ( | const SocketAddr & | addr, |
| u_int16_t | rCallNo ) |
Find a complete transaction. This method is thread safe
| addr | Remote address |
| rCallNo | Remote transaction call number |
References addr().
|
inline |
Get the default media format
| audio | True to retrieve default audio format, false for video format |
Referenced by IAXEngine(), and mediaFormatChanged().
|
protected |
Generate call number. Update used call numbers list
Get an IAX event from the queue. This method is thread safe.
| now | Current time |
|
inline |
Retrieve outgoing data timestamp adjust values
| thres | Adjust outgoing data timestamp threshold |
| over | Value used to adjust outgoing data timestamp on data overrun |
| under | Value used to adjust outgoing data timestamp on data underrun |
Retrieve a port parameter
| params | Parameters list |
| param | Parameter to retrieve |
References NamedList::getIntValue().
| bool haveTransactions | ( | ) |
Check if there are any transactions in the engine This method is thread safe
| void initialize | ( | const NamedList & | params | ) |
(Re)Initialize the engine
| params | Parameter list |
| void initOutDataAdjust | ( | const NamedList & | params, |
| IAXTransaction * | tr = 0 ) |
Initialize outgoing data timestamp adjust values. This method is thread safe
| params | Parameters list |
| tr | Optional transaction to init, initialize the engine's data if 0 |
| void initTrunkIn | ( | IAXTransaction * | trans, |
| const NamedList * | params, | ||
| const String & | prefix = String::empty() ) |
Init incoming trunking data for a given transaction
| trans | Transaction to init |
| params | Trunk parameters list, may be 0 |
| prefix | Trunk parameters name prefix |
References String::empty().
| void initTrunkIn | ( | IAXTransaction * | trans, |
| IAXTrunkInfo & | data ) |
Init incoming trunking data for a given transaction
| trans | Transaction to init |
| data | Trunk info to use |
|
static |
Test if a received response to an authentication request is correct
| md5data | Data to compare with |
| challenge | Received challenge |
| password | Password source |
| void keepAlive | ( | const SocketAddr & | addr | ) |
Send an INVAL with call numbers set to 0 to a remote peer to keep it alive
| addr | Address to send to |
References addr().
|
inline |
Get the maximum allowed frame length
|
inlinevirtual |
Process a new format received with a full frame
| trans | Transaction that received the new format |
| type | Media type |
| format | The received format |
References format().
|
inline |
|
static |
Calculate overall timeout from interval and retransmission counter
| interval | The first retransmisssion interval |
| nRetrans | The number of retransmissions |
| bool process | ( | ) |
Event processor method. Keeps calling getEvent() and passing any events to processEvent() until there are no more events
|
protectedvirtual |
Default event for connection transactions handler. This method may be overriden to perform custom processing This method is thread safe
| event | Event to process |
|
inlinevirtual |
Process media from remote peer. Descendents must override this method
| transaction | IAXTransaction that owns the call leg |
| data | Media data |
| tStamp | Media timestamp |
| type | Media type |
| mark | Mark flag |
Process all trunk meta frames in the queue
| time | Time of the call |
| void readSocket | ( | SocketAddr & | addr | ) |
|
protected |
Release a call number
| lcallno | Call number to release |
| void removeTransaction | ( | IAXTransaction * | transaction | ) |
Removes a transaction from queue. Free the allocated local call number Does not delete it
| transaction | Transaction to remove |
| void runGetEvents | ( | ) |
Read events
| void runProcessTrunkFrames | ( | ) |
Keep calling processTrunkFrames to send trunked media data
| void sendInval | ( | IAXFullFrame * | frame, |
| const SocketAddr & | addr ) |
Send an INVAL frame
| frame | Frame for which to send an INVAL frame |
| addr | The address from where the call request was received |
References addr().
|
virtual |
Set the exiting flag
|
inline |
Send engine formats
| caps | Capabilities |
| fmtAudio | Default audio format |
| fmtVideo | Default video format |
|
inline |
Get the socket used for engine operation
|
protected |
Start a transaction based on a local request
| type | Transaction type |
| addr | Remote address to send the request |
| ieList | First frame IE list |
| refTrans | Return a refferenced transaction pointer |
| startTrans | Start transaction |
References addr().
| u_int32_t transactionCount | ( | ) |
Return the transactions count This method is thread safe
|
inline |
Retrieve the default trunk info data
| info | Destination to be set with trunk info pointer |
|
inline |
Write a full frame to socket
| addr | Socket to write to |
| frame | Frame to write |
References addr(), DataBlock::data(), IAXFrame::data(), DataBlock::length(), and writeSocket().
| bool writeSocket | ( | const void * | buf, |
| int | len, | ||
| const SocketAddr & | addr, | ||
| IAXFullFrame * | frame = 0, | ||
| unsigned int * | sent = 0 ) |
Write data to socket.
| buf | Data to write |
| len | Data length |
| addr | Socket to write to |
| frame | Optional frame to be printed |
| sent | Pointer to variable to be filled with the number of bytes sent |
References addr().
Referenced by writeSocket().