00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __YATEPHONE_H
00026 #define __YATEPHONE_H
00027
00028 #ifndef __cplusplus
00029 #error C++ is required
00030 #endif
00031
00032 #include <yatengine.h>
00033
00037 namespace TelEngine {
00038
00042 struct YATE_API ImageInfo {
00046 int width;
00047
00051 int height;
00052
00056 int depth;
00057 };
00058
00062 struct YATE_API FormatInfo {
00066 const char* name;
00067
00071 const char* type;
00072
00076 int frameSize;
00077
00081 int frameTime;
00082
00086 int sampleRate;
00087
00091 int numChannels;
00092
00096 bool converter;
00097
00103 int guessSamples(int len) const;
00104
00109 int dataRate() const;
00110
00114 inline FormatInfo()
00115 : name(0), type("audio"),
00116 frameSize(0), frameTime(0),
00117 sampleRate(8000), numChannels(1),
00118 converter(false)
00119 { }
00120
00124 inline FormatInfo(const char* _name, int fsize = 0, int ftime = 10000,
00125 const char* _type = "audio", int srate = 8000, int nchan = 1, bool convert = false)
00126 : name(_name), type(_type),
00127 frameSize(fsize), frameTime(ftime),
00128 sampleRate(srate), numChannels(nchan),
00129 converter(convert)
00130 { }
00131 };
00132
00133 class CallEndpoint;
00134 class Driver;
00135
00140 struct YATE_API TranslatorCaps {
00142 const FormatInfo* src;
00144 const FormatInfo* dest;
00146 int cost;
00147 };
00148
00153 class YATE_API FormatRepository
00154 {
00155 private:
00156 FormatRepository();
00157 FormatRepository& operator=(const FormatRepository&);
00158 public:
00164 static const FormatInfo* getFormat(const String& name);
00165
00177 static const FormatInfo* addFormat(const String& name, int fsize, int ftime, const String& type = "audio", int srate = 8000, int nchan = 1);
00178 };
00179
00184 class YATE_API DataFormat : public String
00185 {
00186 public:
00190 inline DataFormat()
00191 : m_parsed(0)
00192 { }
00193
00198 inline DataFormat(const char* value)
00199 : String(value), m_parsed(0)
00200 { }
00201
00206 inline DataFormat(const DataFormat& value)
00207 : String(value), m_parsed(value.getInfo())
00208 { }
00209
00214 inline DataFormat(const String& value)
00215 : String(value), m_parsed(0)
00216 { }
00217
00222 inline DataFormat(const String* value)
00223 : String(value), m_parsed(0)
00224 { }
00225
00230 inline DataFormat(const FormatInfo* format)
00231 : String(format ? format->name : (const char*)0), m_parsed(format)
00232 { }
00233
00237 inline DataFormat& operator=(const DataFormat& value)
00238 { String::operator=(value); return *this; }
00239
00244 const FormatInfo* getInfo() const;
00245
00251 inline int frameSize(int defValue = 0) const
00252 { return getInfo() ? getInfo()->frameSize : defValue; }
00253
00259 inline int frameTime(int defValue = 0) const
00260 { return getInfo() ? getInfo()->frameTime : defValue; }
00261
00268 inline int sampleRate(int defValue = 0) const
00269 { return getInfo() ? getInfo()->sampleRate : defValue; }
00270
00276 inline int numChannels(int defValue = 1) const
00277 { return getInfo() ? getInfo()->numChannels : defValue; }
00278
00279 protected:
00283 virtual void changed();
00284
00285 private:
00286 mutable const FormatInfo* m_parsed;
00287 };
00288
00292 class YATE_API DataNode : public RefObject
00293 {
00294 public:
00299 inline DataNode(const char* format = 0)
00300 : m_format(format), m_timestamp(0)
00301 { }
00302
00308 virtual int costFormat(const DataFormat& format)
00309 { return -1; }
00310
00316 virtual bool setFormat(const DataFormat& format)
00317 { return false; }
00318
00323 inline const DataFormat& getFormat() const
00324 { return m_format; }
00325
00330 inline unsigned long timeStamp() const
00331 { return m_timestamp; }
00332
00338 virtual bool control(NamedList& params)
00339 { return false; }
00340
00345 inline static unsigned long invalidStamp()
00346 { return (unsigned long)-1; }
00347
00348 protected:
00349 DataFormat m_format;
00350 unsigned long m_timestamp;
00351 };
00352
00353 class DataSource;
00354 class DataTranslator;
00355 class TranslatorFactory;
00356 class ThreadedSourcePrivate;
00357
00361 class YATE_API DataConsumer : public DataNode
00362 {
00363 friend class DataSource;
00364
00365 public:
00370 inline DataConsumer(const char* format = "slin")
00371 : DataNode(format),
00372 m_source(0), m_override(0),
00373 m_regularTsDelta(0), m_overrideTsDelta(0), m_lastTsTime(0)
00374 { }
00375
00379 virtual void destroyed();
00380
00386 virtual void* getObject(const String& name) const;
00387
00393 virtual void Consume(const DataBlock& data, unsigned long tStamp) = 0;
00394
00399 inline DataSource* getConnSource() const
00400 { return m_source; }
00401
00406 inline DataSource* getOverSource() const
00407 { return m_override; }
00408
00413 virtual DataSource* getTransSource() const
00414 { return 0; }
00415
00416 protected:
00422 virtual bool synchronize(DataSource* source);
00423
00424 private:
00425 void Consume(const DataBlock& data, unsigned long tStamp, DataSource* source);
00426 DataSource* m_source;
00427 DataSource* m_override;
00428 long m_regularTsDelta;
00429 long m_overrideTsDelta;
00430 u_int64_t m_lastTsTime;
00431 };
00432
00436 class YATE_API DataSource : public DataNode
00437 {
00438 friend class DataTranslator;
00439
00440 public:
00445 inline DataSource(const char* format = "slin")
00446 : DataNode(format), m_nextStamp(invalidStamp()), m_translator(0) { }
00447
00451 virtual void destroyed();
00452
00458 virtual void* getObject(const String& name) const;
00459
00465 void Forward(const DataBlock& data, unsigned long tStamp = invalidStamp());
00466
00473 bool attach(DataConsumer* consumer, bool override = false);
00474
00480 bool detach(DataConsumer* consumer);
00481
00485 void clear();
00486
00491 inline Mutex* mutex()
00492 { return &m_mutex; }
00493
00498 inline DataTranslator* getTranslator() const
00499 { return m_translator; }
00500
00505 void synchronize(unsigned long tStamp);
00506
00511 inline unsigned long nextStamp() const
00512 { return m_nextStamp; }
00513
00514 protected:
00515 unsigned long m_nextStamp;
00516 DataTranslator* m_translator;
00517 ObjList m_consumers;
00518 Mutex m_mutex;
00519 private:
00520 inline void setTranslator(DataTranslator* translator)
00521 { m_translator = translator; }
00522 bool detachInternal(DataConsumer* consumer);
00523 };
00524
00528 class YATE_API ThreadedSource : public DataSource
00529 {
00530 friend class ThreadedSourcePrivate;
00531 public:
00535 virtual void destroyed();
00536
00543 bool start(const char* name = "ThreadedSource", Thread::Priority prio = Thread::Normal);
00544
00548 void stop();
00549
00554 Thread* thread() const;
00555
00560 bool running() const;
00561
00565 inline bool asyncDelete() const
00566 { return m_asyncDelete; }
00567
00568 protected:
00573 inline ThreadedSource(const char* format = "slin")
00574 : DataSource(format), m_thread(0), m_asyncDelete(false)
00575 { }
00576
00581 inline void asyncDelete(bool async)
00582 { m_asyncDelete = async; }
00583
00587 inline void clearThread()
00588 { m_thread = 0; }
00589
00593 virtual void run() = 0;
00594
00599 virtual void cleanup();
00600
00606 virtual bool zeroRefsTest();
00607
00608 private:
00609 ThreadedSourcePrivate* m_thread;
00610 bool m_asyncDelete;
00611 };
00612
00618 class YATE_API DataTranslator : public DataConsumer
00619 {
00620 friend class TranslatorFactory;
00621 public:
00627 DataTranslator(const char* sFormat, const char* dFormat);
00628
00635 DataTranslator(const char* sFormat, DataSource* source = 0);
00636
00640 ~DataTranslator();
00641
00647 virtual void* getObject(const String& name) const;
00648
00653 virtual DataSource* getTransSource() const
00654 { return m_tsource; }
00655
00660 DataTranslator* getFirstTranslator();
00661
00666 const DataTranslator* getFirstTranslator() const;
00667
00676 static ObjList* srcFormats(const DataFormat& dFormat = "slin", int maxCost = -1, unsigned int maxLen = 0, ObjList* lst = 0);
00677
00686 static ObjList* destFormats(const DataFormat& sFormat = "slin", int maxCost = -1, unsigned int maxLen = 0, ObjList* lst = 0);
00687
00696 static ObjList* allFormats(const ObjList* formats, bool existing = true, bool sameRate = true, bool sameChans = true);
00697
00706 static ObjList* allFormats(const String& formats, bool existing = true, bool sameRate = true, bool sameChans = true);
00707
00714 static bool canConvert(const DataFormat& fmt1, const DataFormat& fmt2 = "slin");
00715
00722 static int cost(const DataFormat& sFormat, const DataFormat& dFormat);
00723
00730 static DataTranslator* create(const DataFormat& sFormat, const DataFormat& dFormat);
00731
00739 static bool attachChain(DataSource* source, DataConsumer* consumer, bool override = false);
00740
00747 static bool detachChain(DataSource* source, DataConsumer* consumer);
00748
00753 static void setMaxChain(unsigned int maxChain);
00754
00755 protected:
00761 virtual bool synchronize(DataSource* source);
00762
00767 static void install(TranslatorFactory* factory);
00768
00773 static void uninstall(TranslatorFactory* factory);
00774
00775 private:
00776 DataTranslator();
00777 static void compose();
00778 static void compose(TranslatorFactory* factory);
00779 static bool canConvert(const FormatInfo* fmt1, const FormatInfo* fmt2);
00780 DataSource* m_tsource;
00781 static Mutex s_mutex;
00782 static ObjList s_factories;
00783 static unsigned int s_maxChain;
00784 };
00785
00791 class YATE_API TranslatorFactory : public GenObject
00792 {
00793 protected:
00797 inline TranslatorFactory()
00798 { DataTranslator::install(this); }
00799
00800 public:
00804 virtual ~TranslatorFactory();
00805
00810 virtual void removed(const TranslatorFactory* factory);
00811
00818 virtual DataTranslator* create(const DataFormat& sFormat, const DataFormat& dFormat) = 0;
00819
00824 virtual const TranslatorCaps* getCapabilities() const = 0;
00825
00832 virtual bool converts(const DataFormat& sFormat, const DataFormat& dFormat) const;
00833
00838 virtual unsigned int length() const;
00839
00845 virtual bool intermediate(const FormatInfo* info) const;
00846
00851 virtual const FormatInfo* intermediate() const;
00852 };
00853
00859 class YATE_API DataEndpoint : public RefObject
00860 {
00861 public:
00862
00866 DataEndpoint(CallEndpoint* call = 0, const char* name = "audio");
00867
00871 virtual void destroyed();
00872
00878 virtual void* getObject(const String& name) const;
00879
00884 virtual const String& toString() const;
00885
00890 Mutex* mutex() const;
00891
00896 static Mutex& commonMutex();
00897
00903 bool connect(DataEndpoint* peer);
00904
00909 bool disconnect();
00910
00915 void setSource(DataSource* source = 0);
00916
00921 inline DataSource* getSource() const
00922 { return m_source; }
00923
00928 void setConsumer(DataConsumer* consumer = 0);
00929
00934 inline DataConsumer* getConsumer() const
00935 { return m_consumer; }
00936
00942 void setPeerRecord(DataConsumer* consumer = 0);
00943
00948 inline DataConsumer* getPeerRecord() const
00949 { return m_peerRecord; }
00950
00956 void setCallRecord(DataConsumer* consumer = 0);
00957
00962 inline DataConsumer* getCallRecord() const
00963 { return m_callRecord; }
00964
00970 bool addSniffer(DataConsumer* sniffer);
00971
00977 bool delSniffer(DataConsumer* sniffer);
00978
00984 inline DataConsumer* getSniffer(const String& name)
00985 { return static_cast<DataConsumer*>(m_sniffers[name]); }
00986
00990 void clearSniffers();
00991
00996 inline DataEndpoint* getPeer() const
00997 { return m_peer; }
00998
01003 inline CallEndpoint* getCall() const
01004 { return m_call; }
01005
01010 inline const String& name() const
01011 { return m_name; }
01012
01018 virtual bool control(NamedList& params);
01019
01020 protected:
01026 virtual bool nativeConnect(DataEndpoint* peer)
01027 { return false; }
01028
01029 private:
01030 String m_name;
01031 DataSource* m_source;
01032 DataConsumer* m_consumer;
01033 DataEndpoint* m_peer;
01034 CallEndpoint* m_call;
01035 DataConsumer* m_peerRecord;
01036 DataConsumer* m_callRecord;
01037 ObjList m_sniffers;
01038 };
01039
01044 class YATE_API CallEndpoint : public RefObject
01045 {
01046 friend class DataEndpoint;
01047
01048 private:
01049 CallEndpoint* m_peer;
01050 String m_id;
01051
01052 protected:
01053 ObjList m_data;
01054 Mutex* m_mutex;
01055
01056 public:
01060 virtual void destroyed();
01061
01067 virtual void* getObject(const String& name) const;
01068
01073 virtual const String& toString() const
01074 { return m_id; }
01075
01080 inline const String& id() const
01081 { return m_id; }
01082
01087 inline CallEndpoint* getPeer() const
01088 { return m_peer; }
01089
01094 inline const String& getPeerId() const
01095 { return m_peer ? m_peer->id() : String::empty(); }
01096
01101 inline Mutex* mutex() const
01102 { return m_mutex; }
01103
01108 static Mutex& commonMutex();
01109
01117 bool connect(CallEndpoint* peer, const char* reason = 0, bool notify = true);
01118
01125 inline bool disconnect(const char* reason = 0, bool notify = true)
01126 { return disconnect(false,reason,notify); }
01127
01133 DataEndpoint* getEndpoint(const char* type = "audio") const;
01134
01140 DataEndpoint* setEndpoint(const char* type = "audio");
01141
01146 void clearEndpoint(const char* type = 0);
01147
01153 void setSource(DataSource* source = 0, const char* type = "audio");
01154
01160 DataSource* getSource(const char* type = "audio") const;
01161
01167 void setConsumer(DataConsumer* consumer = 0, const char* type = "audio");
01168
01174 DataConsumer* getConsumer(const char* type = "audio") const;
01175
01176 protected:
01180 CallEndpoint(const char* id = 0);
01181
01186 virtual void connected(const char* reason) { }
01187
01193 virtual void disconnected(bool final, const char* reason) { }
01194
01201 void setPeer(CallEndpoint* peer, const char* reason = 0, bool notify = true);
01202
01207 void setEndpoint(DataEndpoint* endPoint);
01208
01213 virtual void setId(const char* newId);
01214
01215 private:
01216 bool disconnect(bool final, const char* reason, bool notify);
01217 };
01218
01223 class YATE_API Module : public Plugin, public Mutex, public MessageReceiver, public DebugEnabler
01224 {
01225 private:
01226 bool m_init;
01227 int m_relays;
01228 String m_name;
01229 String m_type;
01230 Regexp m_filter;
01231 u_int64_t m_changed;
01232 static unsigned int s_delay;
01233
01234 public:
01240 virtual void* getObject(const String& name) const;
01241
01246 inline const String& name() const
01247 { return m_name; }
01248
01253 inline const String& type() const
01254 { return m_type; }
01255
01260 void changed();
01261
01266 inline static unsigned int updateDelay()
01267 { return s_delay; }
01268
01273 inline static void updateDelay(unsigned int delay)
01274 { s_delay = delay; }
01275
01280 inline bool filterInstalled() const
01281 { return !m_filter.null(); }
01282
01288 bool filterDebug(const String& item) const;
01289
01290 protected:
01294 enum {
01295
01296 Status = 0x00000001,
01297 Timer = 0x00000002,
01298 Level = 0x00000004,
01299 Command = 0x00000008,
01300 Help = 0x00000010,
01301 Halt = 0x00000020,
01302 Route = 0x00000040,
01303
01304 Execute = 0x00000100,
01305 Drop = 0x00000200,
01306
01307 Locate = 0x00000400,
01308 Masquerade = 0x00000800,
01309 Ringing = 0x00001000,
01310 Answered = 0x00002000,
01311 Tone = 0x00004000,
01312 Text = 0x00008000,
01313 Progress = 0x00010000,
01314 Update = 0x00020000,
01315 Transfer = 0x00040000,
01316 Control = 0x00080000,
01317
01318 PubLast = 0x0fffffff,
01319
01320 Private = 0x10000000
01321 } RelayID;
01322
01328 static const char* messageName(int id);
01329
01336 Module(const char* name, const char* type = 0, bool earlyInit = false);
01337
01341 virtual ~Module();
01342
01346 virtual void initialize();
01347
01351 void setup();
01352
01359 bool installRelay(int id, unsigned priority = 100);
01360
01367 bool installRelay(const char* name, unsigned priority = 100);
01368
01376 bool installRelay(int id, const char* name, unsigned priority = 100);
01377
01383 bool installRelay(MessageRelay* relay);
01384
01391 bool uninstallRelay(MessageRelay* relay, bool delRelay = true);
01392
01399 bool uninstallRelay(int id, bool delRelay = true);
01400
01405 bool uninstallRelays();
01406
01413 virtual bool received(Message &msg, int id);
01414
01419 virtual void genUpdate(Message& msg);
01420
01425 virtual void msgTimer(Message& msg);
01426
01431 virtual void msgStatus(Message& msg);
01432
01438 virtual bool msgRoute(Message& msg);
01439
01446 virtual bool msgCommand(Message& msg);
01447
01452 virtual void statusModule(String& str);
01453
01458 virtual void statusParams(String& str);
01459
01464 virtual void statusDetail(String& str);
01465
01472 virtual bool commandExecute(String& retVal, const String& line);
01473
01481 virtual bool commandComplete(Message& msg, const String& partLine, const String& partWord);
01482
01488 virtual bool setDebug(Message& msg, const String& target);
01489
01490 private:
01491 Module();
01492 static TokenDict s_messages[];
01493 ObjList m_relayList;
01494 };
01495
01500 class YATE_API Channel : public CallEndpoint, public DebugEnabler
01501 {
01502 friend class Driver;
01503 friend class Router;
01504
01505 private:
01506 Driver* m_driver;
01507 bool m_outgoing;
01508 u_int64_t m_timeout;
01509 u_int64_t m_maxcall;
01510 u_int64_t m_dtmfTime;
01511 unsigned int m_dtmfSeq;
01512 String m_dtmfText;
01513 String m_dtmfDetected;
01514 String m_lastPeerId;
01515
01516 protected:
01517 String m_status;
01518 String m_address;
01519 String m_targetid;
01520 String m_billid;
01521 bool m_answered;
01522
01523 public:
01527 virtual ~Channel();
01528
01534 virtual void* getObject(const String& name) const;
01535
01541 virtual void complete(Message& msg, bool minimal = false) const;
01542
01550 Message* message(const char* name, bool minimal = false, bool data = false);
01551
01562 Message* message(const char* name, const NamedList* original, const char* params = 0, bool minimal = false, bool data = false);
01563
01574 inline Message* message(const char* name, const NamedList& original, const char* params = 0, bool minimal = false, bool data = false)
01575 { return message(name,&original,params,minimal,data); }
01576
01582 virtual bool msgProgress(Message& msg);
01583
01589 virtual bool msgRinging(Message& msg);
01590
01596 virtual bool msgAnswered(Message& msg);
01597
01604 virtual bool msgTone(Message& msg, const char* tone);
01605
01612 virtual bool msgText(Message& msg, const char* text);
01613
01620 virtual bool msgDrop(Message& msg, const char* reason);
01621
01627 virtual bool msgTransfer(Message& msg);
01628
01634 virtual bool msgUpdate(Message& msg);
01635
01641 virtual bool msgMasquerade(Message& msg);
01642
01647 virtual void msgStatus(Message& msg);
01648
01654 virtual bool msgControl(Message& msg);
01655
01661 virtual void checkTimers(Message& msg, const Time& tmr);
01662
01669 virtual bool callPrerouted(Message& msg, bool handled);
01670
01676 virtual bool callRouted(Message& msg);
01677
01682 virtual void callAccept(Message& msg);
01683
01690 virtual void callRejected(const char* error, const char* reason = 0, const Message* msg = 0);
01691
01697 virtual void callConnect(Message& msg);
01698
01703 virtual bool setDebug(Message& msg);
01704
01709 inline const String& status() const
01710 { return m_status; }
01711
01716 inline const String& address() const
01717 { return m_address; }
01718
01723 inline bool isOutgoing() const
01724 { return m_outgoing; }
01725
01730 inline bool isIncoming() const
01731 { return !m_outgoing; }
01732
01737 inline bool isAnswered() const
01738 { return m_answered; }
01739
01744 const char* direction() const;
01745
01750 inline Driver* driver() const
01751 { return m_driver; }
01752
01757 inline u_int64_t timeout() const
01758 { return m_timeout; }
01759
01764 inline void timeout(u_int64_t tout)
01765 { m_timeout = tout; }
01766
01771 inline u_int64_t maxcall() const
01772 { return m_maxcall; }
01773
01778 inline void maxcall(u_int64_t tout)
01779 { m_maxcall = tout; }
01780
01785 inline void setMaxcall(const Message& msg)
01786 { setMaxcall(&msg); }
01787
01792 void setMaxcall(const Message* msg);
01793
01799 inline const String& targetid() const
01800 { return m_targetid; }
01801
01807 inline const String& billid() const
01808 { return m_billid; }
01809
01814 const String& lastPeerId() const
01815 { return m_lastPeerId; }
01816
01823 bool startRouter(Message* msg);
01824
01829 static unsigned int allocId();
01830
01835 void filterDebug(const String& item);
01836
01837 protected:
01841 Channel(Driver* driver, const char* id = 0, bool outgoing = false);
01842
01846 Channel(Driver& driver, const char* id = 0, bool outgoing = false);
01847
01852 void cleanup();
01853
01857 void dropChan();
01858
01863 virtual void zeroRefs();
01864
01869 virtual void connected(const char* reason);
01870
01876 virtual void disconnected(bool final, const char* reason);
01877
01882 virtual void setId(const char* newId);
01883
01889 void status(const char* newstat);
01890
01895 virtual void statusParams(String& str);
01896
01901 inline void setOutgoing(bool outgoing = true)
01902 { m_outgoing = outgoing; }
01903
01909 bool dtmfSequence(Message& msg);
01910
01916 bool dtmfEnqueue(Message* msg);
01917
01924 bool dtmfInband(const char* tone);
01925
01932 bool toneDetect(const char* sniffer = 0);
01933
01934 private:
01935 void init();
01936 Channel();
01937 };
01938
01943 class YATE_API Driver : public Module
01944 {
01945 friend class Router;
01946 friend class Channel;
01947
01948 private:
01949 bool m_init;
01950 bool m_varchan;
01951 String m_prefix;
01952 ObjList m_chans;
01953 int m_routing;
01954 int m_routed;
01955 int m_total;
01956 unsigned int m_nextid;
01957 int m_timeout;
01958 int m_maxroute;
01959 int m_maxchans;
01960 bool m_dtmfDups;
01961
01962 public:
01968 virtual void* getObject(const String& name) const;
01969
01974 inline const String& prefix() const
01975 { return m_prefix; }
01976
01981 inline bool varchan() const
01982 { return m_varchan; }
01983
01988 inline ObjList& channels()
01989 { return m_chans; }
01990
01996 virtual Channel* find(const String& id) const;
01997
02002 virtual bool isBusy() const;
02003
02008 virtual void dropAll(Message &msg);
02009
02015 virtual bool canAccept(bool routers = true);
02016
02021 virtual bool canRoute();
02022
02027 unsigned int nextid();
02028
02033 inline unsigned int lastid() const
02034 { return m_nextid; }
02035
02040 inline int timeout() const
02041 { return m_timeout; }
02042
02047 inline int routing() const
02048 { return m_routing; }
02049
02054 inline int routed() const
02055 { return m_routed; }
02056
02061 inline int total() const
02062 { return m_total; }
02063
02064 protected:
02070 Driver(const char* name, const char* type = 0);
02071
02075 virtual void initialize();
02076
02082 void setup(const char* prefix = 0, bool minimal = false);
02083
02090 virtual bool received(Message &msg, int id);
02091
02096 virtual void genUpdate(Message& msg);
02097
02104 virtual bool hasLine(const String& line) const;
02105
02112 virtual bool msgRoute(Message& msg);
02113
02120 virtual bool msgExecute(Message& msg, String& dest) = 0;
02121
02129 virtual bool commandComplete(Message& msg, const String& partLine, const String& partWord);
02130
02135 virtual void statusModule(String& str);
02136
02141 virtual void statusParams(String& str);
02142
02147 virtual void statusDetail(String& str);
02148
02154 virtual bool setDebug(Message& msg, const String& target);
02155
02159 virtual void loadLimits();
02160
02165 inline void varchan(bool variable)
02166 { m_varchan = variable; }
02167
02172 inline void timeout(int tout)
02173 { m_timeout = tout; }
02174
02179 inline void maxRoute(int ncalls)
02180 { m_maxroute = ncalls; }
02181
02186 inline void maxChans(int ncalls)
02187 { m_maxchans = ncalls; }
02188
02193 inline void dtmfDups(bool duplicates)
02194 { m_dtmfDups = duplicates; }
02195
02196 private:
02197 Driver();
02198 };
02199
02204 class YATE_API Router : public Thread
02205 {
02206 private:
02207 Driver* m_driver;
02208 String m_id;
02209 Message* m_msg;
02210
02211 public:
02218 Router(Driver* driver, const char* id, Message* msg);
02219
02223 virtual void run();
02224
02229 virtual bool route();
02230
02234 virtual void cleanup();
02235
02236 protected:
02241 const String& id() const
02242 { return m_id; }
02243 };
02244
02250 YATE_API bool isE164(const char* str);
02251
02252 };
02253
02254 #endif
02255
02256