26 #error C++ is required
29 #include <yatengine.h>
100 int guessSamples(
int len)
const;
106 int dataRate()
const;
112 : name(0), type(
"audio"),
113 frameSize(0), frameTime(0),
114 sampleRate(8000), numChannels(1),
121 inline explicit FormatInfo(
const char* _name,
int fsize = 0,
int ftime = 10000,
122 const char* _type =
"audio",
int srate = 8000,
int nchan = 1,
bool convert =
false)
123 : name(_name), type(_type),
124 frameSize(fsize), frameTime(ftime),
125 sampleRate(srate), numChannels(nchan),
175 static const FormatInfo* addFormat(
const String& name,
int fsize,
int ftime,
const String& type =
"audio",
int srate = 8000,
int nchan = 1);
205 :
NamedList(value), m_parsed(value.getInfo())
237 :
NamedList(format ? format->name : (const char*)0), m_parsed(format)
258 {
return getInfo() ? getInfo()->frameSize : defValue; }
266 {
return getInfo() ? getInfo()->frameTime : defValue; }
275 {
return getInfo() ? getInfo()->sampleRate : defValue; }
283 {
return getInfo() ? getInfo()->numChannels : defValue; }
289 virtual void changed();
321 : m_format(format), m_timestamp(0)
352 {
return m_timestamp; }
374 {
return (
unsigned long)-1; }
386 unsigned long m_timestamp;
390 class DataTranslator;
391 class TranslatorFactory;
392 class ThreadedSourcePrivate;
408 m_source(0), m_override(0),
409 m_regularTsDelta(0), m_overrideTsDelta(0), m_lastTsTime(0)
415 virtual void destroyed();
422 virtual void* getObject(
const String& name)
const;
433 virtual unsigned long Consume(
const DataBlock& data,
unsigned long tStamp,
unsigned long flags) = 0;
447 {
return m_override; }
465 unsigned long Consume(
const DataBlock& data,
unsigned long tStamp,
469 long m_regularTsDelta;
470 long m_overrideTsDelta;
471 u_int64_t m_lastTsTime;
488 m_nextStamp(invalidStamp()), m_translator(0) { }
493 virtual void destroyed();
500 virtual void* getObject(
const String& name)
const;
506 virtual bool valid()
const;
522 unsigned long Forward(
const DataBlock& data,
unsigned long tStamp = invalidStamp(),
523 unsigned long flags = 0);
531 bool attach(
DataConsumer* consumer,
bool override =
false);
550 {
return m_translator; }
556 void synchronize(
unsigned long tStamp);
563 {
return m_nextStamp; }
566 unsigned long m_nextStamp;
571 m_translator = translator;
573 bool detachInternal(DataConsumer* consumer);
574 DataTranslator* m_translator;
583 friend class ThreadedSourcePrivate;
588 virtual void destroyed();
596 bool start(
const char* name =
"ThreadedSource",
Thread::Priority prio = Thread::Normal);
613 bool running()
const;
627 virtual void run() = 0;
633 virtual void cleanup();
640 bool looping(
bool runConsumers =
false)
const;
643 ThreadedSourcePrivate* m_thread;
680 virtual void* getObject(
const String& name)
const;
687 {
return m_tsource && m_tsource->valid(); }
694 {
return m_tsource; }
716 static ObjList* srcFormats(
const DataFormat& dFormat =
"slin",
int maxCost = -1,
unsigned int maxLen = 0,
ObjList* lst = 0);
726 static ObjList* destFormats(
const DataFormat& sFormat =
"slin",
int maxCost = -1,
unsigned int maxLen = 0,
ObjList* lst = 0);
736 static ObjList* allFormats(
const ObjList* formats,
bool existing =
true,
bool sameRate =
true,
bool sameChans =
true);
746 static ObjList* allFormats(
const String& formats,
bool existing =
true,
bool sameRate =
true,
bool sameChans =
true);
793 static void setMaxChain(
unsigned int maxChain);
801 {
return m_tsource ? m_tsource->m_consumers.
skipNull() : 0; }
824 static void compose();
828 static Mutex s_mutex;
830 static unsigned int s_maxChain;
847 : m_name(name ? name :
"?")
888 virtual unsigned int length()
const;
895 virtual bool intermediate(
const FormatInfo* info)
const;
901 virtual const FormatInfo* intermediate()
const;
907 virtual const char*
name()
const
915 {
return m_counter; }
939 virtual void destroyed();
946 virtual void* getObject(
const String& name)
const;
952 virtual const String& toString()
const;
958 Mutex* mutex()
const;
964 static Mutex& commonMutex();
1003 {
return m_consumer; }
1017 {
return m_peerRecord; }
1031 {
return m_callRecord; }
1065 void clearSniffers();
1094 {
if (call == m_call) m_call = 0; }
1101 virtual bool control(
NamedList& params);
1133 const void* m_lastPeer;
1145 virtual void destroyed();
1152 virtual void* getObject(
const String& name)
const;
1180 bool getPeerId(
String&
id)
const;
1186 String getPeerId()
const;
1193 bool getLastPeerId(
String&
id)
const;
1198 void setLastPeerId();
1211 static Mutex& commonMutex();
1220 bool connect(
CallEndpoint* peer,
const char* reason = 0,
bool notify =
true);
1230 {
return disconnect(
false,reason,notify,params); }
1239 {
return disconnect(
false,reason,
true,¶ms); }
1301 static const String& audioType();
1335 void setPeer(
CallEndpoint* peer,
const char* reason = 0,
bool notify =
true,
const NamedList* params = 0);
1347 virtual void setId(
const char* newId);
1350 bool disconnect(
bool final,
const char* reason,
bool notify,
const NamedList* params);
1365 u_int64_t m_changed;
1366 static unsigned int s_delay;
1374 virtual void* getObject(
const String& name)
const;
1401 { s_delay = delay; }
1408 {
return !m_filter.
null(); }
1415 bool filterDebug(
const String& item)
const;
1424 static bool itemComplete(
String& itemList,
const String& item,
const String& partWord);
1432 Status = 0x00000001,
1435 Command = 0x00000008,
1441 Execute = 0x00000100,
1444 Locate = 0x00000400,
1445 Masquerade = 0x00000800,
1446 Ringing = 0x00001000,
1447 Answered = 0x00002000,
1450 Progress = 0x00010000,
1451 Update = 0x00020000,
1452 Transfer = 0x00040000,
1453 Control = 0x00080000,
1455 MsgExecute = 0x00100000,
1457 PubLast = 0x0fffffff,
1459 Private = 0x10000000
1467 static const char* messageName(
int id);
1475 {
return lookup(name,s_messages); }
1483 Module(
const char* name,
const char* type = 0,
bool earlyInit =
false);
1493 virtual void initialize();
1506 {
return (
id & m_relays) != 0; }
1514 bool installRelay(
int id,
unsigned priority = 100);
1522 bool installRelay(
const char* name,
unsigned priority = 100);
1531 bool installRelay(
int id,
const char* name,
unsigned priority = 100);
1546 bool uninstallRelay(
MessageRelay* relay,
bool delRelay =
true);
1554 bool uninstallRelay(
int id,
bool delRelay =
true);
1560 bool uninstallRelays();
1568 virtual bool received(
Message &msg,
int id);
1574 virtual void genUpdate(
Message& msg);
1580 virtual void msgTimer(
Message& msg);
1586 virtual void msgStatus(
Message& msg);
1593 virtual bool msgRoute(
Message& msg);
1601 virtual bool msgCommand(
Message& msg);
1607 virtual void statusModule(
String& str);
1613 virtual void statusParams(
String& str);
1619 virtual void statusDetail(
String& str);
1627 virtual bool commandExecute(
String& retVal,
const String& line);
1636 virtual bool commandComplete(
Message& msg,
const String& partLine,
const String& partWord);
1664 u_int64_t m_timeout;
1665 u_int64_t m_maxcall;
1667 u_int64_t m_dtmfTime;
1668 unsigned int m_toutAns;
1669 unsigned int m_dtmfSeq;
1691 virtual void* getObject(
const String& name)
const;
1697 static Mutex& paramMutex();
1704 virtual void complete(
Message& msg,
bool minimal =
false)
const;
1713 Message* message(
const char* name,
bool minimal =
false,
bool data =
false);
1725 Message* message(
const char* name,
const NamedList* original,
const char* params = 0,
bool minimal =
false,
bool data =
false);
1737 inline Message*
message(
const char* name,
const NamedList& original,
const char* params = 0,
bool minimal =
false,
bool data =
false)
1738 {
return message(name,&original,params,minimal,data); }
1745 virtual bool msgProgress(
Message& msg);
1752 virtual bool msgRinging(
Message& msg);
1759 virtual bool msgAnswered(
Message& msg);
1767 virtual bool msgTone(
Message& msg,
const char* tone);
1775 virtual bool msgText(
Message& msg,
const char* text);
1783 virtual bool msgDrop(
Message& msg,
const char* reason);
1790 virtual bool msgTransfer(
Message& msg);
1797 virtual bool msgUpdate(
Message& msg);
1804 virtual bool msgMasquerade(
Message& msg);
1810 virtual void msgStatus(
Message& msg);
1817 virtual bool msgControl(
Message& msg);
1824 virtual void checkTimers(
Message& msg,
const Time& tmr);
1832 virtual bool callPrerouted(
Message& msg,
bool handled);
1839 virtual bool callRouted(
Message& msg);
1845 virtual void callAccept(
Message& msg);
1853 virtual void callRejected(
const char* error,
const char* reason = 0,
const Message* msg = 0);
1860 virtual void callConnect(
Message& msg);
1866 virtual bool setDebug(
Message& msg);
1873 {
return m_status; }
1880 {
return m_address; }
1887 {
return m_outgoing; }
1894 {
return !m_outgoing; }
1901 {
return m_answered; }
1907 const char* direction()
const;
1914 {
return m_driver; }
1921 {
return m_timeout; }
1928 { m_timeout = tout; }
1935 {
return m_maxcall; }
1942 { m_maxcall = tout; }
1950 { setMaxcall(&msg,defTout); }
1957 void setMaxcall(
const Message* msg,
int defTout = -1);
1965 {
return m_maxPDD; }
1973 { m_maxPDD = tout; }
1980 void setMaxPDD(
const Message& msg);
1988 {
return m_targetid; }
1996 {
return m_billid; }
2010 bool startRouter(
Message* msg);
2016 static unsigned int allocId();
2022 void filterDebug(
const String& item);
2029 {
return m_parameters; }
2036 virtual void dispatched(
const Message& msg,
bool handled);
2042 Channel(
Driver* driver,
const char*
id = 0,
bool outgoing =
false);
2047 Channel(
Driver& driver,
const char*
id = 0,
bool outgoing =
false);
2064 virtual void zeroRefs();
2070 virtual void connected(
const char* reason);
2077 virtual void disconnected(
bool final,
const char* reason);
2083 virtual void setDisconnect(
const NamedList* params);
2090 virtual void endDisconnect(
const Message& msg,
bool handled);
2096 virtual void setId(
const char* newId);
2103 virtual Message* getDisconnect(
const char* reason);
2110 void status(
const char* newstat);
2116 virtual void statusParams(
String& str);
2123 { m_outgoing = outgoing; }
2130 bool dtmfSequence(
Message& msg);
2137 bool dtmfEnqueue(
Message* msg);
2145 bool dtmfInband(
const char* tone);
2153 bool toneDetect(
const char* sniffer = 0);
2160 {
return m_parameters; }
2184 unsigned int m_nextid;
2190 volatile bool m_doExpire;
2198 virtual void* getObject(
const String& name)
const;
2205 {
return m_prefix; }
2212 {
return m_varchan; }
2232 virtual bool isBusy()
const;
2238 virtual void dropAll(
Message &msg);
2245 virtual bool canAccept(
bool routers =
true);
2251 virtual bool canRoute();
2257 unsigned int nextid();
2264 {
return m_nextid; }
2271 {
return m_timeout; }
2278 {
return m_routing; }
2285 {
return m_routed; }
2299 {
return m_chanCount; }
2306 {
return m_maxchans; }
2314 Driver(
const char* name,
const char* type = 0);
2319 virtual void initialize();
2326 void setup(
const char* prefix = 0,
bool minimal =
false);
2334 virtual bool received(
Message &msg,
int id);
2340 virtual void genUpdate(
Message& msg);
2348 virtual bool hasLine(
const String& line)
const;
2356 virtual bool msgRoute(
Message& msg);
2373 virtual bool commandComplete(
Message& msg,
const String& partLine,
const String& partWord);
2379 virtual void statusModule(
String& str);
2385 virtual void statusParams(
String& str);
2391 virtual void statusDetail(
String& str);
2403 virtual void loadLimits();
2410 { m_varchan = variable; }
2417 { m_timeout = tout; }
2424 { m_maxroute = ncalls; }
2431 { m_maxchans = ncalls; }
2438 { m_dtmfDups = duplicates; }
2474 virtual bool route();
2479 virtual void cleanup();
2508 void pickAccountParams(
const NamedList& params);
2515 void setInboundParams(
NamedList& params);
2521 void setOutboundParams(
NamedList& params);
2527 void setRegisterParams(
NamedList& params);
2534 {
return m_inbParams; }
2541 {
return m_outParams; }
2548 {
return m_regParams; }
2556 : m_mutex(mutex), m_inbParams(
""), m_outParams(
""), m_regParams(
"")
2565 YATE_API
bool isE164(
const char* str);
CallEndpoint * getPeer() const
Definition: yatephone.h:1172
bool varchan() const
Definition: yatephone.h:2211
bool null() const
Definition: yateclass.h:1967
virtual void setDisconnect(const NamedList *params)
Definition: yatephone.h:1326
static NamedCounter * getCurrentObjCounter(bool always=false)
bool isAnswered() const
Definition: yatephone.h:1900
const FormatInfo * src
Definition: yatephone.h:140
void dtmfDups(bool duplicates)
Definition: yatephone.h:2437
const DataFormat & getFormat() const
Definition: yatephone.h:344
A class that holds just a block of raw data.
Definition: yateclass.h:3774
static int relayId(const char *name)
Definition: yatephone.h:1474
virtual bool valid() const
Definition: yatephone.h:358
Definition: yateclass.h:949
A regexp matching class.
Definition: yateclass.h:2902
An unidirectional data translator (codec)
Definition: yatephone.h:838
const String & targetid() const
Definition: yatephone.h:1987
void setMaxcall(const Message &msg, int defTout=-1)
Definition: yatephone.h:1949
ObjList * skipNull() const
virtual void attached(bool added)
Definition: yatephone.h:381
CallEndpoint * getCall() const
Definition: yatephone.h:1078
DataEndpoint * getPeer() const
Definition: yatephone.h:1071
DataConsumer(const char *format="slin")
Definition: yatephone.h:406
static void install(TranslatorFactory *factory)
const FormatInfo * dest
Definition: yatephone.h:142
Post-dispatching message hook.
Definition: yatengine.h:676
unsigned long timeStamp() const
Definition: yatephone.h:351
virtual const String & toString() const
Definition: yatephone.h:1158
Definition: yatephone.h:138
void timeout(u_int64_t tout)
Definition: yatephone.h:1927
Thread support class.
Definition: yateclass.h:5529
const String & billid() const
Definition: yatephone.h:1995
void setOutgoing(bool outgoing=true)
Definition: yatephone.h:2122
Mutex * mutex() const
Definition: yatephone.h:1204
Data source with own thread.
Definition: yatephone.h:581
const String & id() const
Definition: yatephone.h:2486
const String & type() const
Definition: yatephone.h:1380
static unsigned int updateDelay()
Definition: yatephone.h:1393
int depth
Definition: yatephone.h:53
int height
Definition: yatephone.h:48
TranslatorFactory(const char *name=0)
Definition: yatephone.h:846
bool isIncoming() const
Definition: yatephone.h:1893
Call routing thread.
Definition: yatephone.h:2448
bool disconnect(const char *reason=0, bool notify=true, const NamedList *params=0)
Definition: yatephone.h:1229
int timeout() const
Definition: yatephone.h:2270
bool filterInstalled() const
Definition: yatephone.h:1407
virtual bool valid() const
Definition: yatephone.h:686
A multiple message receiver.
Definition: yatengine.h:607
CallAccount(Mutex *mutex)
Definition: yatephone.h:2555
Definition: yatephone.h:397
const NamedList & registerParams() const
Definition: yatephone.h:2547
An abstract communication channel.
Definition: yatephone.h:1655
A message handler relay.
Definition: yatengine.h:623
bool isOutgoing() const
Definition: yatephone.h:1886
DataSource * getConnSource() const
Definition: yatephone.h:439
virtual bool setFormat(const DataFormat &format)
Definition: yatephone.h:337
DataFlags
Definition: yatephone.h:306
static unsigned long invalidStamp()
Definition: yatephone.h:373
int lookup(const char *str, const TokenDict *tokens, int defvalue=0, int base=0)
int width
Definition: yatephone.h:43
u_int64_t timeout() const
Definition: yatephone.h:1920
const String & status() const
Definition: yatephone.h:1872
const NamedList & inboundParams() const
Definition: yatephone.h:2533
ObjList & channels()
Definition: yatephone.h:2218
int routing() const
Definition: yatephone.h:2277
const String & id() const
Definition: yatephone.h:1165
An abstract call endpoint.
Definition: yatephone.h:1127
DataSource * getSource() const
Definition: yatephone.h:989
An unidirectional data translator (codec)
Definition: yatephone.h:651
void varchan(bool variable)
Definition: yatephone.h:2409
ObjList * getConsumers() const
Definition: yatephone.h:800
A time holding class.
Definition: yateclass.h:3536
virtual void connected(const char *reason)
Definition: yatephone.h:1313
DataNode(const char *format=0)
Definition: yatephone.h:320
void maxChans(int ncalls)
Definition: yatephone.h:2430
A holder for a debug level.
Definition: yateclass.h:309
Definition: yatephone.h:477
A message container class.
Definition: yatengine.h:312
unsigned long nextStamp() const
Definition: yatephone.h:562
ThreadedSource(const char *format="slin")
Definition: yatephone.h:620
const String & prefix() const
Definition: yatephone.h:2204
u_int64_t maxPDD() const
Definition: yatephone.h:1964
A Channel driver module.
Definition: yatephone.h:2171
DataConsumer * getPeerRecord() const
Definition: yatephone.h:1016
static const String & audioType()
const NamedList & outboundParams() const
Definition: yatephone.h:2540
const String & name() const
Definition: yatephone.h:1085
void timeout(int tout)
Definition: yatephone.h:2416
int chanCount() const
Definition: yatephone.h:2298
const char * c_str(const String *str)
Definition: yateclass.h:2805
NamedList & operator=(const NamedList &value)
DataTranslator * getTranslator() const
Definition: yatephone.h:549
A data transfer endpoint capable of sending and/or receiving data.
Definition: yatephone.h:927
bool relayInstalled(int id) const
Definition: yatephone.h:1505
A named string container class.
Definition: yateclass.h:4553
static void updateDelay(unsigned int delay)
Definition: yatephone.h:1400
void maxcall(u_int64_t tout)
Definition: yatephone.h:1941
Ephemeral mutex or semaphore locking object.
Definition: yateclass.h:5357
DataSource * getOverSource() const
Definition: yatephone.h:446
DataConsumer * getConsumer() const
Definition: yatephone.h:1002
void clearCall(const CallEndpoint *call)
Definition: yatephone.h:1093
int cost
Definition: yatephone.h:144
unsigned int lastid() const
Definition: yatephone.h:2263
virtual void disconnected(bool final, const char *reason)
Definition: yatephone.h:1320
int total() const
Definition: yatephone.h:2291
virtual DataSource * getTransSource() const
Definition: yatephone.h:693
virtual DataSource * getTransSource() const
Definition: yatephone.h:453
DataConsumer * getCallRecord() const
Definition: yatephone.h:1030
const NamedList & parameters() const
Definition: yatephone.h:2028
DataSource(const char *format="slin")
Definition: yatephone.h:486
Definition: yateclass.h:217
virtual bool nativeConnect(DataEndpoint *peer)
Definition: yatephone.h:1109
NamedCounter * objectsCounter() const
Definition: yatephone.h:914
A C-style string handling class.
Definition: yateclass.h:1832
void maxRoute(int ncalls)
Definition: yatephone.h:2423
Driver * driver() const
Definition: yatephone.h:1913
const String & address() const
Definition: yatephone.h:1879
Definition: yateclass.h:683
Priority
Definition: yateclass.h:5539
virtual const char * name() const
Definition: yatephone.h:907
u_int64_t maxcall() const
Definition: yatephone.h:1934
An object list class.
Definition: yateclass.h:1229
Definition: yatephone.h:298
NamedList & parameters()
Definition: yatephone.h:2159
A Plugin that implements a module.
Definition: yatephone.h:1357
void maxPDD(u_int64_t tout)
Definition: yatephone.h:1972
static const String & empty()
bool disconnect(const char *reason, const NamedList ¶ms)
Definition: yatephone.h:1238
virtual int costFormat(const DataFormat &format)
Definition: yatephone.h:329
Settings for an account handling calls.
Definition: yatephone.h:2494
int routed() const
Definition: yatephone.h:2284
Plugin support.
Definition: yatengine.h:1023
Mutex support.
Definition: yateclass.h:5131
virtual bool control(NamedList ¶ms)
Definition: yatephone.h:366
Definition: yateclass.h:830
int maxChans() const
Definition: yatephone.h:2305
Definition: yatephone.h:39
Message * message(const char *name, const NamedList &original, const char *params=0, bool minimal=false, bool data=false)
Definition: yatephone.h:1737
Atomic counter with name.
Definition: yateclass.h:3232
bool isE164(const char *str)