

function incomingTrue(){
	$(".videoBtn").show();
	$(".videoCall").show();
	$(".vidDrop").hide();
	$(".videoList").hide();
	$(".videoMy").hide();
	$('.maxOpen').trigger("click");
	localMediaStream()
	if(!nativeStream) {
		captureLocalMediaVideo()
	}
}
// 电话呼入呼出事件
function sipCallRTCSession(e, state) {
	console.log(e.session)
	console.log(state) // 1是呼出，2是呼入
	e.session.on("confirmed", function(data) {
		console.log(data)
		callVideoFail = false;
		incomingSession = data.session;
		timeOut = setInterval(function() {
			if(incomingSession.isEnded()) {
				$(".videoBtn").hide();
				$(".videoCall").hide();
				clearTimeout(timeOut)
			}
		}, 2000)
		
		if(e.session.connection.getReceivers) {
			console.log(e.session.connection.getReceivers())
			remoteStream = new MediaStream();
			e.session.connection.getReceivers().forEach(element => {
				// track可能一个音轨或者视频轨迹
				remoteStream.addTrack(element.track)
			})
			console.log(remoteStream)
			if(inComing) {
				inComing = false;
				videoView_1.srcObject = remoteStream
				videoView_1.onloadedmetadata = function() {
					videoView_1.play();
					videoView_1.muted = true;
					state === 1 ? console.log("呼叫成功") : console.log("接听成功")
					$(".videoCall").show();
					$(".videoMy").show();    
		      		$(".videoBtn").hide();
		      		$(".videoList").show();
		      		$(".vidDrop").show();
				}
			}

		}
	})
}


//注册成功
function loginTrue() {
	$(".titText").show();
	$(".titText").html(selectExten + "注册成功");
	captureLocalMediaVideo()
}
// 呼叫失败处理
function callVideoFail() {
	if(callVideoFail) {
		setTimeout(function() {
			videoCall()
		}, 2000)
	}
}
//呼叫结束挂断
function dropCall() {
	$(".callStyle").text("")
	$(".videoCall").hide();
	userAgent.terminateSessions();
	resScreen()
	closeMediaVideo();
}

// 注册成功
function loginTrue(){
	console.log("初始化成功");
}
//	注销成功
function logoutTrue(){
	console.log("注销成功");
}
// 来电振铃
function incomingTrue(){
	console.log("接听成功");
}
// 通话中
function inCallTrue(){
	console.log("通话中");
}
// 挂断成功
function hangupCallTrue(){
	console.log("挂断成功");
}