|
@@ -229,8 +229,6 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
|
|
|
if (audioOnly) {
|
|
|
//移除视频画面
|
|
|
- fullscreen_video_frame.visibility = View.GONE
|
|
|
- pip_video_frame.visibility = View.GONE
|
|
|
ll_voice_call.visibility = View.VISIBLE
|
|
|
} else {
|
|
|
//显示视频画面
|
|
@@ -293,155 +291,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
|
|
|
- } else {
|
|
|
- callEnd()
|
|
|
- }
|
|
|
- } else {
|
|
|
- localSurfaceView!!.setZOrderMediaOverlay(true)
|
|
|
- }
|
|
|
-
|
|
|
- if (localSurfaceView!!.parent != null) {
|
|
|
- (localSurfaceView!!.parent as ViewGroup).removeView(localSurfaceView)
|
|
|
- }
|
|
|
-
|
|
|
- if (outGoing && remoteSurfaceView == null) {
|
|
|
- if (fullscreen_video_frame != null && fullscreen_video_frame.getChildCount() != 0) {
|
|
|
- fullscreen_video_frame.removeAllViews()
|
|
|
- }
|
|
|
- fullscreen_video_frame.addView(localSurfaceView)
|
|
|
- } else {
|
|
|
- if (pip_video_frame != null && pip_video_frame.getChildCount() != 0) {
|
|
|
- pip_video_frame.removeAllViews()
|
|
|
- }
|
|
|
- pip_video_frame.addView(localSurfaceView)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //处理远端视频画面
|
|
|
- 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 (outGoing) {
|
|
|
- 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 && fullscreen_video_frame != 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更新的需要在主线程处理,务必注意
|
|
|
********************************************************/
|
|
@@ -563,8 +412,10 @@ class SkyCallFragment: BaseCallFragment(), CallSessionCallback {
|
|
|
//我方呼出,对方不在线,设备离线或其它错误
|
|
|
callSuccess = true
|
|
|
showMessage("呼叫失败,找不到设备或对方不在线!")
|
|
|
- RingPlayHelper.stopRingTone()
|
|
|
- cancelCall()
|
|
|
+ AppTool.Time.delay(1500) {
|
|
|
+ RingPlayHelper.stopRingTone()
|
|
|
+ cancelCall()
|
|
|
+ }
|
|
|
} else if (curTcpModel.getAction() == TcpAction.VoiceAction.HANDOFF) {
|
|
|
//对方挂断,不论我方呼出或呼入
|
|
|
if (Constant.interactionId == curInteractionVO.id) {
|