亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pjsua_app.py

?? 基于sip協議的網絡電話源碼
?? PY
?? 第 1 頁 / 共 2 頁
字號:
# $Id: pjsua_app.py 972 2007-02-18 23:49:14Z bennylp $## Sample and simple Python script to make and receive calls, and do# presence and instant messaging/IM using PJSUA-API binding for Python.## Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>#import py_pjsuaimport sysimport thread## Configurations#THIS_FILE = "pjsua_app.py"C_QUIT = 0C_LOG_LEVEL = 4# STUN config.# Set C_STUN_SRV to the address of the STUN server to enable STUN#C_STUN_SRV = ""C_SIP_PORT = 5060C_STUN_PORT = 3478# Globals#g_ua_cfg = Noneg_acc_id = py_pjsua.PJSUA_INVALID_IDg_current_call = py_pjsua.PJSUA_INVALID_IDg_wav_files = []g_wav_id = 0g_wav_port = 0g_rec_file = ""g_rec_id = 0g_rec_port = 0# Utility: display PJ error and exit#def err_exit(title, rc):    py_pjsua.perror(THIS_FILE, title, rc)    exit(1)# Logging function (also callback, called by pjsua-lib)#def log_cb(level, str, len):    if level <= C_LOG_LEVEL:        print str,def write_log(level, str):    log_cb(level, str + "\n", 0)# Utility to get call info#def call_name(call_id):	ci = py_pjsua.call_get_info(call_id)	return "[Call " + `call_id` + " " + ci.remote_info + "]"# Callback when call state has changed.#def on_call_state(call_id, e):		global g_current_call	ci = py_pjsua.call_get_info(call_id)	write_log(3, call_name(call_id) + " state = " + `ci.state_text`)	if ci.state == py_pjsua.PJSIP_INV_STATE_DISCONNECTED:		g_current_call = py_pjsua.PJSUA_INVALID_ID# Callback for incoming call#def on_incoming_call(acc_id, call_id, rdata):	global g_current_call		if g_current_call != py_pjsua.PJSUA_INVALID_ID:		# There's call in progress - answer Busy		py_pjsua.call_answer(call_id, 486, None, None)		return		g_current_call = call_id	ci = py_pjsua.call_get_info(call_id)	write_log(3, "*** Incoming call: " + call_name(call_id) + "***")	write_log(3, "*** Press a to answer or h to hangup  ***")			# Callback when media state has changed (e.g. established or terminated)#def on_call_media_state(call_id):	ci = py_pjsua.call_get_info(call_id)	if ci.media_status == py_pjsua.PJSUA_CALL_MEDIA_ACTIVE:		py_pjsua.conf_connect(ci.conf_slot, 0)		py_pjsua.conf_connect(0, ci.conf_slot)		write_log(3, call_name(call_id) + ": media is active")	else:		write_log(3, call_name(call_id) + ": media is inactive")# Callback when account registration state has changed#def on_reg_state(acc_id):	acc_info = py_pjsua.acc_get_info(acc_id)	if acc_info.has_registration != 0:		cmd = "registration"	else:		cmd = "unregistration"	if acc_info.status != 0 and acc_info.status != 200:		write_log(3, "Account " + cmd + " failed: rc=" + `acc_info.status` + " " + acc_info.status_text)	else:		write_log(3, "Account " + cmd + " success")# Callback when buddy's presence state has changed#def on_buddy_state(buddy_id):	write_log(3, "On Buddy state called")	buddy_info = py_pjsua.buddy_get_info(buddy_id)	if buddy_info.status != 0 and buddy_info.status != 200:		write_log(3, "Status of " + `buddy_info.uri` + " is " + `buddy_info.status_text`)	else:		write_log(3, "Status : " + `buddy_info.status`)# Callback on incoming pager (MESSAGE)#		def on_pager(call_id, strfrom, strto, contact, mime_type, text):	write_log(3, "MESSAGE from " + `strfrom` + " : " + `text`)# Callback on the delivery status of outgoing pager (MESSAGE)#	def on_pager_status(call_id, strto, body, user_data, status, reason):	write_log(3, "MESSAGE to " + `strto` + " status " + `status` + " reason " + `reason`)# Received typing indication#def on_typing(call_id, strfrom, to, contact, is_typing):	str_t = ""	if is_typing:		str_t = "is typing.."	else:		str_t = "has stopped typing"	write_log(3, "IM indication: " + strfrom + " " + str_t)# Received the status of previous call transfer request#def on_call_transfer_status(call_id,status_code,status_text,final,p_cont):	strfinal = ""	if final == 1:		strfinal = "[final]"		write_log(3, "Call " + `call_id` + ": transfer status= " + `status_code` + " " + status_text+ " " + strfinal)	      	if status_code/100 == 2:		write_log(3, "Call " + `call_id` + " : call transfered successfully, disconnecting call")		status = py_pjsua.call_hangup(call_id, 410, None, None)		p_cont = 0# Callback on incoming call transfer request#		def on_call_transfer_request(call_id, dst, code):	write_log(3, "Call transfer request from " + `call_id` + " to " + dst + " with code " + `code`)## Initialize pjsua.#def app_init():	global g_acc_id, g_ua_cfg	# Create pjsua before anything else	status = py_pjsua.create()	if status != 0:		err_exit("pjsua create() error", status)	# Create and initialize logging config	log_cfg = py_pjsua.logging_config_default()	log_cfg.level = C_LOG_LEVEL	log_cfg.cb = log_cb	# Create and initialize pjsua config	# Note: for this Python module, thread_cnt must be 0 since Python	#       doesn't like to be called from alien thread (pjsua's thread	#       in this case)	    	ua_cfg = py_pjsua.config_default()	ua_cfg.thread_cnt = 0	ua_cfg.user_agent = "PJSUA/Python 0.1"	ua_cfg.cb.on_incoming_call = on_incoming_call	ua_cfg.cb.on_call_media_state = on_call_media_state	ua_cfg.cb.on_reg_state = on_reg_state	ua_cfg.cb.on_call_state = on_call_state	ua_cfg.cb.on_buddy_state = on_buddy_state	ua_cfg.cb.on_pager = on_pager	ua_cfg.cb.on_pager_status = on_pager_status	ua_cfg.cb.on_typing = on_typing	ua_cfg.cb.on_call_transfer_status = on_call_transfer_status	ua_cfg.cb.on_call_transfer_request = on_call_transfer_request	# Create and initialize media config	med_cfg = py_pjsua.media_config_default()	med_cfg.ec_tail_len = 0	#	# Initialize pjsua!!	#	status = py_pjsua.init(ua_cfg, log_cfg, med_cfg)	if status != 0:		err_exit("pjsua init() error", status)	# Configure STUN config	stun_cfg = py_pjsua.stun_config_default()	stun_cfg.stun_srv1 = C_STUN_SRV	stun_cfg.stun_srv2 = C_STUN_SRV	stun_cfg.stun_port1 = C_STUN_PORT	stun_cfg.stun_port2 = C_STUN_PORT	# Configure UDP transport config	transport_cfg = py_pjsua.transport_config_default()	transport_cfg.port = C_SIP_PORT	transport_cfg.stun_config = stun_cfg	if C_STUN_SRV != "":		transport_cfg.use_stun = 1	# Create UDP transport	status, transport_id = \	    py_pjsua.transport_create(py_pjsua.PJSIP_TRANSPORT_UDP, transport_cfg)	if status != 0:		py_pjsua.destroy()		err_exit("Error creating UDP transport", status)	# Create initial default account	status, acc_id = py_pjsua.acc_add_local(transport_id, 1)	if status != 0:		py_pjsua.destroy()		err_exit("Error creating account", status)	g_acc_id = acc_id	g_ua_cfg = ua_cfg# Add SIP account interractively#def add_account():	global g_acc_id	acc_domain = ""	acc_username = ""	acc_passwd =""	confirm = ""		# Input account configs	print "Your SIP domain (e.g. myprovider.com): ",	acc_domain = sys.stdin.readline()	if acc_domain == "\n": 		return	acc_domain = acc_domain.replace("\n", "")	print "Your username (e.g. alice): ",	acc_username = sys.stdin.readline()	if acc_username == "\n":		return	acc_username = acc_username.replace("\n", "")	print "Your password (e.g. secret): ",	acc_passwd = sys.stdin.readline()	if acc_passwd == "\n":		return	acc_passwd = acc_passwd.replace("\n", "")	# Configure account configuration	acc_cfg = py_pjsua.acc_config_default()	acc_cfg.id = "sip:" + acc_username + "@" + acc_domain	acc_cfg.reg_uri = "sip:" + acc_domain	acc_cfg.cred_count = 1	acc_cfg.cred_info[0].realm = acc_domain	acc_cfg.cred_info[0].scheme = "digest"	acc_cfg.cred_info[0].username = acc_username	acc_cfg.cred_info[0].data_type = 0	acc_cfg.cred_info[0].data = acc_passwd	# Add new SIP account	status, acc_id = py_pjsua.acc_add(acc_cfg, 1)	if status != 0:		py_pjsua.perror(THIS_FILE, "Error adding SIP account", status)	else:		g_acc_id = acc_id		write_log(3, "Account " + acc_cfg.id + " added")def add_player():	global g_wav_files	global g_wav_id	global g_wav_port		file_name = ""	status = -1	wav_id = 0		print "Enter the path of the file player(e.g. /tmp/audio.wav): ",	file_name = sys.stdin.readline()	if file_name == "\n": 		return	file_name = file_name.replace("\n", "")	status, wav_id = py_pjsua.player_create(file_name, 0)	if status != 0:		py_pjsua.perror(THIS_FILE, "Error adding file player ", status)	else:		g_wav_files.append(file_name)		if g_wav_id == 0:			g_wav_id = wav_id			g_wav_port = py_pjsua.player_get_conf_port(wav_id)		write_log(3, "File player " + file_name + " added")		def add_recorder():	global g_rec_file	global g_rec_id	global g_rec_port		file_name = ""	status = -1	rec_id = 0		print "Enter the path of the file recorder(e.g. /tmp/audio.wav): ",	file_name = sys.stdin.readline()	if file_name == "\n": 		return	file_name = file_name.replace("\n", "")	status, rec_id = py_pjsua.recorder_create(file_name, 0, None, 0, 0)	if status != 0:		py_pjsua.perror(THIS_FILE, "Error adding file recorder ", status)	else:		g_rec_file = file_name		g_rec_id = rec_id		g_rec_port = py_pjsua.recorder_get_conf_port(rec_id)		write_log(3, "File recorder " + file_name + " added")def conf_list():	ports = None	print "Conference ports : "	ports = py_pjsua.enum_conf_ports()	for port in ports:		info = None		info = py_pjsua.conf_get_port_info(port)		txlist = ""		for i in range(info.listener_cnt):			txlist = txlist + "#" + `info.listeners[i]` + " "				print "Port #" + `info.slot_id` + "[" + `(info.clock_rate/1000)` + "KHz/" + `(info.samples_per_frame * 1000 / info.clock_rate)` + "ms] " + info.name + " transmitting to: " + txlist		def connect_port():	src_port = 0	dst_port = 0		print "Connect src port # (empty to cancel): "	src_port = sys.stdin.readline()	if src_port == "\n": 		return	src_port = src_port.replace("\n", "")	src_port = int(src_port)	print "To dst port # (empty to cancel): "	dst_port = sys.stdin.readline()	if dst_port == "\n": 		return	dst_port = dst_port.replace("\n", "")	dst_port = int(dst_port)	status = py_pjsua.conf_connect(src_port, dst_port)	if status != 0:		py_pjsua.perror(THIS_FILE, "Error connecting port ", status)	else:				write_log(3, "Port connected from " + `src_port` + " to " + `dst_port`)		def disconnect_port():	src_port = 0	dst_port = 0		print "Disconnect src port # (empty to cancel): "	src_port = sys.stdin.readline()	if src_port == "\n": 		return	src_port = src_port.replace("\n", "")	src_port = int(src_port)	print "From dst port # (empty to cancel): "	dst_port = sys.stdin.readline()	if dst_port == "\n": 		return	dst_port = dst_port.replace("\n", "")	dst_port = int(dst_port)	status = py_pjsua.conf_disconnect(src_port, dst_port)	if status != 0:		py_pjsua.perror(THIS_FILE, "Error disconnecting port ", status)	else:				write_log(3, "Port disconnected " + `src_port` + " from " + `dst_port`)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区三区四区| 欧美日韩一级视频| 国产一区二区在线观看免费| 日本免费新一区视频| 欧美aaa在线| 久久精品国产77777蜜臀| 免费成人小视频| 国产美女久久久久| 国产91在线观看| 91无套直看片红桃| 欧美三级电影在线看| 欧美久久婷婷综合色| 欧美日韩一级二级| 日韩欧美一区在线| 久久久久久久久久久久久久久99| 日本一区二区三级电影在线观看 | 国产白丝精品91爽爽久久| 国产一区欧美一区| 成人毛片在线观看| 在线不卡中文字幕| 久久综合久久鬼色中文字| 中文字幕的久久| 一级日本不卡的影视| 久久成人av少妇免费| 99天天综合性| 欧美人牲a欧美精品| 久久伊人蜜桃av一区二区| 中文字幕在线播放不卡一区| 亚洲成人自拍偷拍| 精品一区二区免费视频| 91久久精品一区二区三区| 欧美一区二区三区在线观看视频| 久久免费国产精品| 亚洲自拍另类综合| 国产成人一级电影| 欧美日韩成人在线| 国产精品国产三级国产aⅴ原创| 午夜亚洲福利老司机| 国产露脸91国语对白| 欧美日韩精品一区二区三区| 国产色综合久久| 五月天网站亚洲| 97久久人人超碰| 欧美大片一区二区| 亚洲一区二区欧美激情| 成人app在线| 精品国产一区二区三区久久影院 | 亚洲免费观看高清在线观看| 国产在线看一区| 91精品国产欧美一区二区成人| 亚洲特级片在线| 懂色av一区二区夜夜嗨| 91精品国产色综合久久久蜜香臀| 亚洲女人****多毛耸耸8| 国产精品白丝jk黑袜喷水| 欧美日本乱大交xxxxx| 亚洲三级小视频| av电影天堂一区二区在线| 精品播放一区二区| 久久99精品国产91久久来源| 欧美日韩久久一区| 亚洲成人在线免费| 欧美视频一区在线观看| 日韩毛片一二三区| 91在线看国产| 亚洲色欲色欲www在线观看| 成人精品视频网站| 国产精品久久久久久久久搜平片 | 九九九久久久精品| 欧美电视剧免费观看| 蜜臀久久99精品久久久久久9 | 亚洲激情成人在线| 一本一道综合狠狠老| 最近日韩中文字幕| 色综合亚洲欧洲| 亚洲国产日韩一级| 欧美日韩国产免费一区二区| 性感美女极品91精品| 欧美日韩免费在线视频| 天堂资源在线中文精品| 在线播放中文字幕一区| 免费成人小视频| 久久综合av免费| 国产传媒日韩欧美成人| 1024成人网| 欧美日韩一区久久| 麻豆极品一区二区三区| 久久色.com| 91蜜桃视频在线| 日本不卡免费在线视频| 久久综合视频网| 精品一区免费av| 欧美韩日一区二区三区四区| 99久久99久久精品国产片果冻| 一区二区三区日韩在线观看| 在线成人av网站| 国产成人丝袜美腿| 亚洲aⅴ怡春院| 精品国产第一区二区三区观看体验| 国产成人精品三级麻豆| 亚洲精品国产精华液| 日韩精品一区国产麻豆| 成人国产精品免费观看动漫| 亚洲va欧美va人人爽| 久久久久久久久久久久久女国产乱| 99国产精品久久久| 首页亚洲欧美制服丝腿| 中文文精品字幕一区二区| 欧美性欧美巨大黑白大战| 精品亚洲国内自在自线福利| 亚洲天堂2016| 久久综合中文字幕| 欧美日韩三级视频| 不卡的av中国片| 蜜臀av性久久久久蜜臀aⅴ四虎| 国产亚洲精品bt天堂精选| 欧美三级电影网站| 99视频超级精品| 国产精选一区二区三区| 亚洲成人资源在线| 国产精品乱人伦中文| 在线观看成人小视频| 一区二区三区国产| 欧美一区2区视频在线观看| 久久www免费人成看片高清| 亚洲免费色视频| 亚洲国产激情av| 日韩三级视频在线看| 91久久国产综合久久| 东方aⅴ免费观看久久av| 免费观看在线色综合| 亚洲午夜久久久久久久久电影院| 欧美韩日一区二区三区四区| 日韩一区二区精品| 欧美欧美欧美欧美首页| 99久久精品一区二区| 国产成人午夜99999| 久久精品国产亚洲5555| 亚洲自拍另类综合| 亚洲一区二区五区| 亚洲免费伊人电影| 亚洲精品视频在线观看免费| 中文字幕一区二区在线观看| 中日韩免费视频中文字幕| 国产色91在线| 国产精品乱人伦一区二区| 国产亚洲综合在线| 久久人人超碰精品| 国产亚洲成年网址在线观看| 2021久久国产精品不只是精品| 久久综合av免费| 中文字幕精品一区二区三区精品| 久久精品亚洲国产奇米99| 久久久高清一区二区三区| 国产日韩欧美电影| 日本一区二区三区国色天香| 中文字幕精品综合| 亚洲精品视频自拍| 五月天国产精品| 美国av一区二区| 国产毛片精品视频| 波多野结衣一区二区三区| 91影视在线播放| 在线成人免费观看| 日韩精品最新网址| 国产日韩欧美精品在线| 亚洲免费毛片网站| 视频一区二区三区在线| 久久97超碰国产精品超碰| 国产91高潮流白浆在线麻豆 | 99精品一区二区| 欧美天堂亚洲电影院在线播放| 678五月天丁香亚洲综合网| 日韩欧美卡一卡二| 欧美激情一区二区三区| 亚洲最大的成人av| 精品亚洲欧美一区| 91麻豆.com| 精品成a人在线观看| 亚洲欧美另类在线| 奇米精品一区二区三区在线观看| 国产一区二区电影| 91免费观看视频| 欧美成人性福生活免费看| √…a在线天堂一区| 男男成人高潮片免费网站| bt欧美亚洲午夜电影天堂| 欧美美女视频在线观看| 久久久噜噜噜久久人人看| 亚洲综合清纯丝袜自拍| 国内成+人亚洲+欧美+综合在线| 9i看片成人免费高清| 日韩欧美在线不卡| 亚洲精品成人精品456| 韩国一区二区视频| 欧美日韩高清一区二区三区| 国产精品免费视频一区| 久久精品国产一区二区| 在线观看亚洲一区| 亚洲欧洲日产国产综合网|