⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 driver.h

📁 语音接口~语音识别 & 从声音识别到对各种情报的查找/提供 资料请求~住所.姓名.电话号码等的识别接待 受订货业务~被定型化的受订货业务 预约业务~预约情况的向导和预约接
💻 H
字号:
// Copyright (C) 2005 Open Source Telecom Corp.//  // This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.// // This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.#include "bayonne.h"#include <cc++/slog.h>#include <cc++/process.h>#include <ccrtp/rtp.h>#undef	HAVE_CONFIG_H#include <eXosip2/eXosip.h>#define BAD_REQ                 400#define UNAUTHORIZED    401#define FORBIDDEN               403#define NOT_FOUND               404#define NOT_ALLOWED             405#define NOT_ACCEPTABLE  406#define AUTH_REQUIRED   407#define REQ_TIMEOUT             408#define UNSUP_MEDIA_TYPE        415#define TEMP_UNAVAILABLE 480#define ADDR_INCOMPLETE 484#define BUSY_HERE               486#define REQ_TERMINATED  487#define NOT_ACCEPTABLE_HERE 488 // Not Acceptable Here// 5XX errors#define SERVICE_UNAVAILABLE     503// 6XX errors#define BUSY_EVERYWHERE 600#define DECLINE                 603namespace sipdriver {using namespace ost;using namespace std;struct dtmf2833{#if __BYTE_ORDER == __BIG_ENDIAN        unsigned event : 8;        unsigned char ebit : 1;        unsigned char rbit : 1;        unsigned vol : 6;        uint32 duration : 16;#else        unsigned event : 8;        unsigned vol : 6;        unsigned char rbit : 1;        unsigned char ebit : 1;        uint32 duration : 16;#endif};class Session;class Registry : public ScriptRegistry{public:	Registry *next;	const char *uri, *contact, *proxy;	const char *iface;//	const char *route;	const char *address;	const char *hostid;	const char *portid;	const char *userid, *localid;	const char *secret;	const char *type;	const char *realm;	const char *dtmf;	const char *encoding;	timeout_t framing;	int regid;	bool active;	bool isActive(void);	void add(ScriptImage *img);};	class Driver : public BayonneDriver, public Audio, public Thread{protected:	friend class Session;	friend class RTPStream;	InetAddress sip_addr, rtp_addr;	tpport_t rtp_port, sip_port;	uint8 dtmf_negotiate, data_negotiate;	bool info_negotiate;	Info info;	bool registry;	bool exiting;	bool dtmf_inband;	bool data_filler;	Level silence;	unsigned jitter;	timeout_t accept_timer;	timeout_t audio_timer;public:	static Driver sip;		// plugin activation	Driver();	inline tpport_t getPort(void)		{return sip_port;};	void startDriver(void);	void stopDriver(void);	const char *registerScript(ScriptImage *img, Line *line);	const char *assignScript(ScriptImage *img, Line *line);	Session *getCall(int callid);	void setAuthentication(Registry *reg);	bool getAuthentication(Session *s);	void run(void);	inline Level getSilence(void)		{return silence;};	unsigned getRegistration(regauth_t *data, unsigned count);};class RTPStream : public SymmetricRTPSession, public AudioBase, private TimerPort, private Mutex, public Bayonne{private:	friend class Session;protected:	Encoded pbuffer;	Encoded buffer;	Linear lbuffer;	Linear silent_frame;	Encoded silent_encoded;	DTMFDetect *dtmf;        Session *session;        size_t rtpBufferSize;        bool dropInbound;	bool ending;	unsigned long fcount, jitter, jsend, dtmfcount;	struct dtmf2833 dtmfpacket;		unsigned lastevt;	unsigned tonecount;	event_t stopid;        AudioBase *source, *sink;	AudioTone *tone;public:        uint32  iBytes;        uint32  oBytes;        uint32  oTimestamp;	RTPStream(Session *session);	~RTPStream();        void start(void);	void put2833(struct dtmf2833 *data);        ssize_t putBuffer(Encoded data, size_t len);        ssize_t getBuffer(Encoded data, size_t len);        void run(void);	void peerAudio(Encoded encoded, bool linear);	void postAudio(Encoded encoded);        void setSource(AudioBase *get, timeout_t max = 0);        void setSink(AudioBase *put, timeout_t max = 0);	void setTone(AudioTone *tone, timeout_t max = 0);	void set2833(struct dtmf2833 *data, timeout_t duration);	inline bool isEnding(void)		{return ending;};    	bool onRTPPacketRecv(IncomingRTPPkt &pkt);};// in this driver we really only have one instance of session since we// only use one timeslot, but the coding style is more reflective of// drivers with multiportclass Session : public BayonneSession, public TimerPort, public Audio{protected:	friend class Driver;	friend class RTPStream;	Info info;	AudioCodec *codec;	InetHostAddress local_address, remote_address;	tpport_t remote_port;	RTPStream *rtp;	bool update_pos;	Linear peer_buffer;	AudioCodec *peer_codec;	uint8 dtmf_payload, data_payload;	bool dtmf_sipinfo;	volatile bool dtmf_inband;	int cid, did;	bool peerAudio(Encoded encoded);	void sendDTMFInfo(char digit, unsigned timeout = 160);	void setDTMFMode(const char *mode);public:	Session(timeslot_t ts);	~Session();	timeout_t audioFraming(void);	const char *audioEncoding(void);	const char *audioExtension(void);	const char *checkAudio(bool live);	// core timer virtuals all port session objects need to define	timeout_t getRemaining(void);	void startTimer(timeout_t timer);	void stopTimer(void);	void startRTP(void);		void stopRTP(void);	void makeIdle(void);	void clrAudio(void);	bool enterJoin(Event *event);	bool enterSeize(Event *event);	bool enterRunning(Event *event);	bool enterHangup(Event *event);	bool enterPickup(Event *event);	bool enterPlay(Event *event);	bool enterRecord(Event *event);	bool enterTone(Event *event);	bool enterXfer(Event *event);	timeout_t getToneFraming(void);	tpport_t getLocalPort(void);	void sipHangup(void);	inline tpport_t getRemotePort(void)		{return remote_port;};	inline InetHostAddress getLocalAddress(void)		{return local_address;};	inline InetHostAddress getRemoteAddress(void)		{return remote_address;};	void setEncoding(const char *encoding, timeout_t framing);};}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -