Yate
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
ClientChannel Class Reference

Channel used by client programs. More...

#include <yatecbase.h>

Inheritance diagram for ClientChannel:
Channel CallEndpoint DebugEnabler MessageNotifier RefObject GenObject

Public Types

enum  Notification {
  Startup, Destroyed, Active, OnHold,
  Mute, Noticed, AddrChanged, Routed,
  Accepted, Rejected, Progressing, Ringing,
  Answered, Transfer, Conference, AudioSet,
  Unknown
}
 
enum  SlaveType { SlaveNone = 0, SlaveTransfer, SlaveConference }
 

Public Member Functions

 ClientChannel (const Message &msg, const String &peerid)
 
 ClientChannel (const String &target, const NamedList &params, int st=SlaveNone, const String &masterChan=String::empty())
 
 ClientChannel (const String &soundId)
 
bool start (const String &target, const NamedList &params)
 
virtual bool msgProgress (Message &msg)
 
virtual bool msgRinging (Message &msg)
 
virtual bool msgAnswered (Message &msg)
 
virtual bool msgDrop (Message &msg, const char *reason)
 
virtual bool callRouted (Message &msg)
 
virtual void callAccept (Message &msg)
 
virtual void callRejected (const char *error, const char *reason, const Message *msg)
 
void callAnswer (bool setActive=true)
 
int slave () const
 
ObjListslaves ()
 
unsigned int slavesCount () const
 
void addSlave (const String &sid)
 
void removeSlave (const String &sid)
 
const Stringmaster () const
 
const NamedListclientParams () const
 
const Stringparty () const
 
const StringpartyName () const
 
bool conference () const
 
const StringtransferId () const
 
RefObjectclientData () const
 
void setClientData (RefObject *obj=0)
 
bool setMedia (bool open=false, bool replace=false)
 
bool setActive (bool active, bool update=true)
 
bool setMuted (bool on, bool update=true)
 
void setTransfer (const String &target=String::empty())
 
void setConference (const String &target=String::empty())
 
const StringpeerOutFormat () const
 
const StringpeerInFormat () const
 
bool active () const
 
bool muted () const
 
bool isNoticed () const
 
void noticed ()
 
int line () const
 
void line (int newLine)
 
void update (int notif, bool chan=true, bool updatePeer=true, const char *engineMsg=0, bool minimal=false, bool data=false)
 
void getReconnPeer (String &buf)
 
bool hasReconnPeer ()
 
CallEndpointgetReconnPeer (bool ref=true)
 
void dropReconnPeer (const char *reason=0)
 
- Public Member Functions inherited from Channel
virtual ~Channel ()
 
virtual void * getObject (const String &name) const
 
virtual void complete (Message &msg, bool minimal=false) const
 
Messagemessage (const char *name, bool minimal=false, bool data=false)
 
Messagemessage (const char *name, const NamedList *original, const char *params=0, bool minimal=false, bool data=false)
 
Messagemessage (const char *name, const NamedList &original, const char *params=0, bool minimal=false, bool data=false)
 
virtual bool msgTone (Message &msg, const char *tone)
 
virtual bool msgText (Message &msg, const char *text)
 
virtual bool msgTransfer (Message &msg)
 
virtual bool msgUpdate (Message &msg)
 
virtual bool msgMasquerade (Message &msg)
 
virtual void msgStatus (Message &msg)
 
virtual bool msgControl (Message &msg)
 
virtual void checkTimers (Message &msg, const Time &tmr)
 
virtual bool callPrerouted (Message &msg, bool handled)
 
virtual void callConnect (Message &msg)
 
virtual bool setDebug (Message &msg)
 
const Stringstatus () const
 
const Stringaddress () const
 
bool isOutgoing () const
 
bool isIncoming () const
 
bool isAnswered () const
 
const char * direction () const
 
Driverdriver () const
 
u_int64_t timeout () const
 
void timeout (u_int64_t tout)
 
u_int64_t maxcall () const
 
void maxcall (u_int64_t tout)
 
void setMaxcall (const Message &msg, int defTout=-1)
 
void setMaxcall (const Message *msg, int defTout=-1)
 
u_int64_t maxPDD () const
 
void maxPDD (u_int64_t tout)
 
void setMaxPDD (const Message &msg)
 
const Stringtargetid () const
 
const Stringbillid () const
 
void initChan ()
 
bool startRouter (Message *msg)
 
void filterDebug (const String &item)
 
const NamedListparameters () const
 
virtual void dispatched (const Message &msg, bool handled)
 
- Public Member Functions inherited from CallEndpoint
virtual const StringtoString () const
 
const Stringid () const
 
CallEndpointgetPeer () const
 
bool getPeerId (String &id) const
 
String getPeerId () const
 
bool getLastPeerId (String &id) const
 
void setLastPeerId ()
 
Mutexmutex () const
 
bool connect (CallEndpoint *peer, const char *reason=0, bool notify=true)
 
bool disconnect (const char *reason=0, bool notify=true, const NamedList *params=0)
 
bool disconnect (const char *reason, const NamedList &params)
 
DataEndpointgetEndpoint (const String &type=CallEndpoint::audioType()) const
 
DataEndpointsetEndpoint (const String &type=CallEndpoint::audioType())
 
void clearEndpoint (const String &type=String::empty())
 
void setSource (DataSource *source=0, const String &type=CallEndpoint::audioType())
 
DataSourcegetSource (const String &type=CallEndpoint::audioType()) const
 
void setConsumer (DataConsumer *consumer=0, const String &type=CallEndpoint::audioType())
 
DataConsumergetConsumer (const String &type=CallEndpoint::audioType()) const
 
bool clearData (DataNode *node, const String &type=CallEndpoint::audioType())
 
- Public Member Functions inherited from RefObject
 RefObject ()
 
virtual ~RefObject ()
 
virtual bool alive () const
 
bool ref ()
 
bool deref ()
 
int refcount () const
 
virtual void destruct ()
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 
- 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 MessageNotifier
virtual ~MessageNotifier ()
 

Static Public Member Functions

static int lookup (const char *notif, int def=Unknown)
 
static const char * lookup (int notif, const char *def=0)
 
static int lookupSlaveType (const char *notif, int def=SlaveNone)
 
- Static Public Member Functions inherited from Channel
static MutexparamMutex ()
 
static unsigned int allocId ()
 
- Static Public Member Functions inherited from CallEndpoint
static MutexcommonMutex ()
 
static const StringaudioType ()
 
- Static Public Member Functions inherited from RefObject
static bool alive (const RefObject *obj)
 
static bool efficientIncDec ()
 
- Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
 
static bool getObjCounting ()
 
static void setObjCounting (bool enable)
 
static NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 

Static Public Attributes

static const TokenDict s_notification []
 
static const TokenDict s_slaveTypes []
 

Protected Member Functions

virtual void destroyed ()
 
virtual void connected (const char *reason)
 
virtual void disconnected (bool final, const char *reason)
 
bool peerHasSource (Message &msg)
 
void checkSilence ()
 
- Protected Member Functions inherited from Channel
 Channel (Driver *driver, const char *id=0, bool outgoing=false)
 
 Channel (Driver &driver, const char *id=0, bool outgoing=false)
 
void cleanup ()
 
void dropChan ()
 
virtual void zeroRefs ()
 
virtual void setDisconnect (const NamedList *params)
 
virtual void endDisconnect (const Message &msg, bool handled)
 
virtual void setId (const char *newId)
 
virtual MessagegetDisconnect (const char *reason)
 
void status (const char *newstat)
 
virtual void statusParams (String &str)
 
void setOutgoing (bool outgoing=true)
 
bool dtmfSequence (Message &msg)
 
bool dtmfEnqueue (Message *msg)
 
bool dtmfInband (const char *tone)
 
bool toneDetect (const char *sniffer=0)
 
NamedListparameters ()
 
- Protected Member Functions inherited from CallEndpoint
 CallEndpoint (const char *id=0)
 
void setPeer (CallEndpoint *peer, const char *reason=0, bool notify=true, const NamedList *params=0)
 
void setEndpoint (DataEndpoint *endPoint)
 
- Protected Member Functions inherited from RefObject
bool resurrect ()
 
- Protected Member Functions inherited from DebugEnabler
void debugName (const char *name)
 

Protected Attributes

int m_slave
 
String m_master
 
String m_party
 
String m_partyName
 
String m_peerOutFormat
 
String m_peerInFormat
 
String m_reason
 
String m_peerId
 
bool m_noticed
 
int m_line
 
bool m_active
 
bool m_silence
 
bool m_conference
 
bool m_muted
 
String m_transferId
 
RefObjectm_clientData
 
bool m_utility
 
String m_soundId
 
ObjList m_slaves
 
NamedList m_clientParams
 
- Protected Attributes inherited from Channel
String m_status
 
String m_address
 
String m_targetid
 
String m_billid
 
bool m_answered
 
- Protected Attributes inherited from CallEndpoint
ObjList m_data
 
Mutexm_mutex
 

Friends

class ClientDriver
 

Detailed Description

Channel used by client programs.

This class implements a Channel used by client programs

Member Enumeration Documentation

Channel notifications

enum SlaveType

Channel slave type

Constructor & Destructor Documentation

ClientChannel ( const Message msg,
const String peerid 
)

Incoming (from engine) constructor

Parameters
msgThe call.execute message
peeridThe peer's id
ClientChannel ( const String target,
const NamedList params,
int  st = SlaveNone,
const String masterChan = String::empty() 
)

Outgoing (to engine) constructor

Parameters
targetThe target to call
paramsCall parameters
stOptional slave
masterChanMaster channel id if slave, ignored otherwise
ClientChannel ( const String soundId)
explicit

Constructor for utility channels used to play notifications

Parameters
soundIdThe id of the sound to play

Member Function Documentation

bool active ( ) const
inline

Check if this channel is the active one

Returns
True if this channel is the active one
void addSlave ( const String sid)
inline

Add a slave id. This method is thread safe

Parameters
sidSlave id to add

References ObjList::append(), and ObjList::find().

virtual void callAccept ( Message msg)
virtual

Notification on success of incoming call

Parameters
msgNotification call.execute message just after being dispatched

Reimplemented from Channel.

void callAnswer ( bool  setActive = true)

Answer an incoming call. Set media channels. Enqueue a clientchan.update message

Parameters
setActiveTrue to activate the channel
virtual void callRejected ( const char *  error,
const char *  reason,
const Message msg 
)
virtual

Notification on failure of incoming call

Parameters
errorStandard error keyword
reasonTextual failure reason
msgPointer to message causing the rejection, if any

Reimplemented from Channel.

virtual bool callRouted ( Message msg)
virtual

Notification on progress of routing incoming call

Parameters
msgNotification call.route message just after being dispatched
Returns
True to continue with the call, false to abort the route

Reimplemented from Channel.

RefObject* clientData ( ) const
inline

Get the client data

Returns
RefObject pointer or 0
const NamedList& clientParams ( ) const
inline

Retrieve channel client parameters

Returns
Channel client parameters list
bool conference ( ) const
inline

Check if this channel is in conference

Returns
True if this channel is in conference
virtual void connected ( const char *  reason)
protectedvirtual

Connect notification method.

Parameters
reasonText that describes connect reason.

Reimplemented from Channel.

virtual void destroyed ( )
protectedvirtual

Destruct notification, performs cleanups

Reimplemented from CallEndpoint.

virtual void disconnected ( bool  final,
const char *  reason 
)
protectedvirtual

Disconnect notification method.

Parameters
finalTrue if this disconnect was called from the destructor.
reasonText that describes disconnect reason.

Reimplemented from Channel.

void dropReconnPeer ( const char *  reason = 0)

Drop peer used to reconnect

void getReconnPeer ( String buf)
inline

Retrieve peer used to reconnect. This method is thread safe

Parameters
bufDestination buffer

Referenced by ClientChannel::hasReconnPeer().

CallEndpoint* getReconnPeer ( bool  ref = true)

Get peer used to reconnect

Parameters
refTrue to return a referenced pointer
Returns
CallEndpoint pointer or 0 if not found
bool hasReconnPeer ( )
inline

Check if the peer used to reconnect is alive

Returns
True if the peer used to reconnect is alive

References ClientChannel::getReconnPeer().

bool isNoticed ( ) const
inline

Check if this channel was noticed

Returns
True if this channel was noticed
int line ( ) const
inline

Get this channel's line

Returns
This channel's line
void line ( int  newLine)

Set this channel's line

Parameters
newLineThis channel's line
static int lookup ( const char *  notif,
int  def = Unknown 
)
inlinestatic

Lookup for a notification id

Parameters
notifThe notification's name
defDefault value to return if not found
Returns
The result

References TelEngine::lookup(), and ClientChannel::s_notification.

static const char* lookup ( int  notif,
const char *  def = 0 
)
inlinestatic

Lookup for a notification name

Parameters
notifThe notification's id
defDefault value to return if not found
Returns
The result

References TelEngine::lookup(), and ClientChannel::s_notification.

static int lookupSlaveType ( const char *  notif,
int  def = SlaveNone 
)
inlinestatic

Lookup for a slave type

Parameters
notifThe slave type name
defDefault value to return if not found
Returns
The result

References TelEngine::lookup(), and ClientChannel::s_slaveTypes.

const String& master ( ) const
inline

Get the master channel id if any

Returns
The master channel id of this channel
virtual bool msgAnswered ( Message msg)
virtual

Notification on remote answered. Note that the answered flag will be set

Parameters
msgNotification message
Returns
True to stop processing the message, false to let it flow

Reimplemented from Channel.

virtual bool msgDrop ( Message msg,
const char *  reason 
)
virtual

Notification on current call drop request

Parameters
msgNotification message
reasonPointer to drop reason text or NULL if none provided
Returns
True if initiated call drop, false if failed

Reimplemented from Channel.

virtual bool msgProgress ( Message msg)
virtual

Notification on remote call making some progress, not enabled by default

Parameters
msgNotification message
Returns
True to stop processing the message, false to let it flow

Reimplemented from Channel.

virtual bool msgRinging ( Message msg)
virtual

Notification on remote ringing

Parameters
msgNotification message
Returns
True to stop processing the message, false to let it flow

Reimplemented from Channel.

bool muted ( ) const
inline

Check if this channel is muted

Returns
True if this channel is muted
void noticed ( )

Notice this channel. Enqueue a clientchan.update message

const String& party ( ) const
inline

Get the remote party of this channel

Returns
The remote party of this channel
const String& partyName ( ) const
inline

Get the remote party name of this channel

Returns
The remote party name of this channel
const String& peerInFormat ( ) const
inline

Get the peer source's data format

Returns
The peer source's data format
const String& peerOutFormat ( ) const
inline

Get the peer consumer's data format

Returns
The peer consumer's data format
void removeSlave ( const String sid)
inline

Remove a slave id. This method is thread safe

Parameters
sidSlave id to remove

References ObjList::remove().

bool setActive ( bool  active,
bool  update = true 
)

Set/reset this channel's data source/consumer

Parameters
activeTrue to set active, false to set inactive (mute)
updateTrue to enqueue an update message
Returns
True on success
void setClientData ( RefObject obj = 0)
inline

Set/reset the client data. If a new client data is set its reference counter is increased

Parameters
objThe new client data

References TelEngine::destruct().

void setConference ( const String target = String::empty())

Set/reset the conference data. Enqueue clientchan.update if changed. Open media when reset if the channel is active and answered

Parameters
targetThe confeernce room's name. Leave it blank to reset
bool setMedia ( bool  open = false,
bool  replace = false 
)

Attach/detach media channels

Parameters
openTrue to open, false to close
replaceTrue to replace media if already open. Ignored if open is false
Returns
True on success
bool setMuted ( bool  on,
bool  update = true 
)

Set/reset this channel's muted flag. Set media if 'on' is false and the channel is active

Parameters
onTrue to reset outgoing media, false to set outgoing media
updateTrue to enqueue an update message
Returns
True on success
void setTransfer ( const String target = String::empty())

Set/reset the transferred peer's id. Enqueue clientchan.update if changed. Open media when reset if the channel is active and answered

Parameters
targetThe transferred peer's id. Leave it blank to reset
int slave ( ) const
inline

Get the slave type of this channel

Returns
The slave type of this channel
ObjList& slaves ( )
inline

Retrieve channel slaves. This method is not thread safe

Returns
Channel slaves list
unsigned int slavesCount ( ) const
inline

Retrieve channel slaves number. This method is thread safe

Returns
Channel slaves list

References ObjList::count().

bool start ( const String target,
const NamedList params 
)

Init and start router for an outgoing (to engine), not utility, channel

Parameters
targetThe target to call
paramsCall parameters
Returns
True on success
const String& transferId ( ) const
inline

Get the transferred peer's id

Returns
The transferred peer's id
void update ( int  notif,
bool  chan = true,
bool  updatePeer = true,
const char *  engineMsg = 0,
bool  minimal = false,
bool  data = false 
)

Update channel. Enqueue a clientchan.update message with the given operation. Enqueue other channel status messages if required

Parameters
notifThe value of the notify parameter
chanSet the channel as message's user data
updatePeerTrue to update peer's data formats
engineMsgOptional message to enqueue in the engine
minimalSet to true to fill in only a minimum of engine message's parameters
dataSet the channel as engine message's user data

Member Data Documentation

const TokenDict s_notification[]
static

Channel notifications dictionary

Referenced by ClientChannel::lookup().

const TokenDict s_slaveTypes[]
static

Channel notifications dictionary

Referenced by ClientChannel::lookupSlaveType().


The documentation for this class was generated from the following file: