|
@@ -89,7 +89,7 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
RingPlayHelper.playRingTone(baseActivity, R.raw.ring_back2, true)
|
|
|
if (!startOutgoing()) {
|
|
|
AppTool.Time.delay(2000) {
|
|
|
- callEnd()
|
|
|
+ cancelCall()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -120,7 +120,7 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
RingPlayHelper.playRingTone(baseActivity, R.raw.ring_back2, true)
|
|
|
if (!startOutgoing()) {
|
|
|
AppTool.Time.delay(2000) {
|
|
|
- callEnd()
|
|
|
+ cancelCall()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -141,7 +141,7 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
if (sky_voice_call_timer != null) {
|
|
|
sky_voice_call_timer.stop()
|
|
|
}
|
|
|
- callEnd()
|
|
|
+ callEnd(true)
|
|
|
} else {
|
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
|
if (callState == 0) {
|
|
@@ -160,7 +160,7 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
RingPlayHelper.stopRingTone()
|
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
|
VoiceUtil.rejectAudioCall(Constant.DEVICE_ID, fromId, interactionVO?.id)
|
|
|
- callEnd()
|
|
|
+ callEnd(false)
|
|
|
}
|
|
|
|
|
|
//来电接听
|
|
@@ -252,7 +252,7 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
if (sky_voice_call_timer != null) {
|
|
|
sky_voice_call_timer.stop()
|
|
|
}
|
|
|
- callEnd()
|
|
|
+ callEnd(false)
|
|
|
}
|
|
|
|
|
|
private fun showCalling(audioOnly: Boolean) {
|
|
@@ -282,7 +282,7 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
}
|
|
|
|
|
|
//通话结束
|
|
|
- override fun callEnd() {
|
|
|
+ override fun callEnd(handoff: Boolean) {
|
|
|
synchronized(this) {
|
|
|
RingPlayHelper.stopRingTone()
|
|
|
if (callEnded) {
|
|
@@ -296,6 +296,10 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
|
|
|
Log.e(TAG, "call end !!!!!!!!!!!!!!!!!!")
|
|
|
|
|
|
+ if (handoff) {
|
|
|
+ VoiceUtil.handoffAudioCall(Constant.DEVICE_ID, fromId, Constant.interactionId)
|
|
|
+ }
|
|
|
+
|
|
|
if (janusClient!!.webSocketChannel != null) {
|
|
|
janusClient!!.callState = EnumType.CallState.Idle
|
|
|
|
|
@@ -317,131 +321,6 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
- ********************* webrtc通话回调 ********************
|
|
|
- * 注意: 如涉及到UI更新的需要在主线程处理,务必注意
|
|
|
- *******************************************************/
|
|
|
-/* override fun didChangeState(state: EnumType.CallState?) {
|
|
|
- Log.e("dds", "didChangeState: " + state)
|
|
|
- handler.post {
|
|
|
- if (state == EnumType.CallState.Connected) {
|
|
|
- //更新界面显示
|
|
|
- showCalling(audioCall)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- override fun didDisconnected(userId: String?) {
|
|
|
- handler.post {
|
|
|
- showMessage("断开连接")
|
|
|
- callEnd()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- override fun didError(error: String?) {
|
|
|
- handler.post {
|
|
|
- showMessage("通话错误")
|
|
|
- callEnd()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //处理本地视频画面
|
|
|
- override fun didCreateLocalVideoTrack() {
|
|
|
- Log.e("dds", "didCreateLocalVideoTrack")
|
|
|
- handler.post {
|
|
|
- val session = gEngineKit!!.currentSession
|
|
|
- if (session != null && !callEnded) {
|
|
|
- if (localSurfaceView == null) {
|
|
|
- val surfaceView = gEngineKit!!.currentSession.setupLocalVideo(true)
|
|
|
- Log.e("dds", "didCreateLocalVideoTrack surfaceView: " + surfaceView)
|
|
|
- if (surfaceView != null) {
|
|
|
- localSurfaceView = surfaceView as SurfaceViewRenderer
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //处理远端视频画面
|
|
|
- override fun didReceiveRemoteVideoTrack(userId: String?) {
|
|
|
- Log.e("dds", "didReceiveRemoteVideoTrack userId: " + userId)
|
|
|
- handler.post {
|
|
|
- val session = gEngineKit!!.currentSession
|
|
|
- if (session != null && !callEnded) {
|
|
|
- //本地画面
|
|
|
- if (localSurfaceView != null) {
|
|
|
- localSurfaceView!!.setZOrderMediaOverlay(true)
|
|
|
- if (localSurfaceView!!.parent != null) {
|
|
|
- (localSurfaceView!!.parent as ViewGroup).removeView(localSurfaceView)
|
|
|
- }
|
|
|
- pip_video_frame!!.addView(localSurfaceView)
|
|
|
- }
|
|
|
-
|
|
|
- //远端画面
|
|
|
- val surfaceView = gEngineKit!!.currentSession.setupRemoteVideo(userId, false)
|
|
|
- Log.e("dds", "didReceiveRemoteVideoTrack,surfaceView = $surfaceView")
|
|
|
- if (surfaceView != null) {
|
|
|
- remoteSurfaceView = surfaceView as SurfaceViewRenderer
|
|
|
- fullscreen_video_frame.removeAllViews()
|
|
|
- if (remoteSurfaceView!!.parent != null) {
|
|
|
- (remoteSurfaceView!!.parent as ViewGroup).removeView(remoteSurfaceView)
|
|
|
- }
|
|
|
- fullscreen_video_frame.addView(remoteSurfaceView)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- override fun didCallEndWithReason(callEndReason: EnumType.CallEndReason?) {
|
|
|
- handler.post {
|
|
|
- when (callEndReason) {
|
|
|
- EnumType.CallEndReason.Busy -> {
|
|
|
- showMessage("对方忙线中")
|
|
|
- }
|
|
|
- EnumType.CallEndReason.AcceptByOtherClient -> {
|
|
|
- showMessage("通话中")
|
|
|
- }
|
|
|
- EnumType.CallEndReason.Hangup -> {
|
|
|
- showMessage("通话结束")
|
|
|
- }
|
|
|
- EnumType.CallEndReason.MediaError -> {
|
|
|
- showMessage("媒体错误")
|
|
|
- }
|
|
|
- EnumType.CallEndReason.OpenCameraFailure -> {
|
|
|
- showMessage("打开摄像头错误")
|
|
|
- }
|
|
|
- EnumType.CallEndReason.RemoteHangup -> {
|
|
|
- showMessage("对方挂断")
|
|
|
- }
|
|
|
- EnumType.CallEndReason.RemoteSignalError -> {
|
|
|
- showMessage("对方网络断开")
|
|
|
- }
|
|
|
- EnumType.CallEndReason.SignalError -> {
|
|
|
- showMessage("连接断开")
|
|
|
- }
|
|
|
- EnumType.CallEndReason.Timeout -> {
|
|
|
- showMessage("对方未接听")
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- callEnd()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- override fun didChangeMode(isAudioOnly: Boolean) {
|
|
|
- handler.post {
|
|
|
- //
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- override fun didUserLeave(userId: String?) {
|
|
|
- handler.post {
|
|
|
- showMessage("通话结束")
|
|
|
- callEnd()
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
-
|
|
|
- /********************************************************
|
|
|
********************* 通话回调 ********************
|
|
|
* 注意: 如涉及到UI更新的需要在主线程处理,务必注意
|
|
|
********************************************************/
|
|
@@ -461,7 +340,7 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
Log.w(TAG, "didDisconnected: $userId")
|
|
|
handler.post {
|
|
|
showMessage("$userId 失去连接")
|
|
|
- callEnd()
|
|
|
+ callEnd(true)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -474,14 +353,14 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
Log.e(TAG, "didError: $error")
|
|
|
handler.post {
|
|
|
showMessage("通话错误")
|
|
|
- callEnd()
|
|
|
+ callEnd(true)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
override fun didHangUp(handlerId: BigInteger) {
|
|
|
Log.e("hangup", "socket hangup")
|
|
|
handler.post {
|
|
|
- callEnd()
|
|
|
+ callEnd(true)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -492,7 +371,7 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
|
|
|
override fun didCallEndWithReason(var1: EnumType.CallEndReason?) {
|
|
|
handler.post {
|
|
|
- callEnd()
|
|
|
+ callEnd(true)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -503,7 +382,7 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
override fun didUserLeave(userId: BigInteger?) {
|
|
|
Log.w(TAG, "didUserLeave:"+userId)
|
|
|
handler.post {
|
|
|
- callEnd()
|
|
|
+ callEnd(true)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -526,11 +405,10 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
//通话失败,重置并返回主界面
|
|
|
showMessage("通话失败,targetSipId为空!")
|
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
|
- VoiceUtil.handoffAudioCall(Constant.DEVICE_ID, fromId, Constant.interactionId)
|
|
|
if (sky_voice_call_timer != null) {
|
|
|
sky_voice_call_timer.stop()
|
|
|
}
|
|
|
- callEnd()
|
|
|
+ callEnd(true)
|
|
|
}
|
|
|
} else if (curTcpModel.getAction() == TcpAction.VoiceAction.REJECT) {
|
|
|
//我方呼出,对方拒绝
|