|
@@ -119,6 +119,10 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
private var serverSuccess = false
|
|
|
|
|
|
private var janusClient: JanusClient? = null
|
|
|
+ private var broadcastOn = false
|
|
|
+ private var broadcastChannelId: String = ""
|
|
|
+ private var playing = false
|
|
|
+ private val myHandler = Handler(Looper.getMainLooper())
|
|
|
|
|
|
//主信息
|
|
|
private val mainFragment = "main_fragment"
|
|
@@ -356,7 +360,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
CommonUtils.setUrl(activity, info.thirdServer)
|
|
|
CommonUtils.setUrlPort(activity, info.thirdServerPort.toString())
|
|
|
showMsgMain("restart...")
|
|
|
- handler.postDelayed({
|
|
|
+ myHandler.postDelayed({
|
|
|
AppUpdateHelper.restartApp(activity)
|
|
|
}, 10000)
|
|
|
}
|
|
@@ -448,6 +452,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
EventBus.getDefault().unregister(this)
|
|
|
unRegReceiver()
|
|
|
handler.removeCallbacksAndMessages(null)
|
|
|
+ myHandler.removeCallbacksAndMessages(null)
|
|
|
SoundPoolManager.getInstance().release()
|
|
|
isTimeWorking = false
|
|
|
stopBroadcast(false)
|
|
@@ -917,6 +922,14 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //如果当前正在播放广播
|
|
|
+ if (buffer[5].toInt() == 1 || buffer[6].toInt() == 1 || buffer[5].toInt() == 2 || buffer[6].toInt() == 2) {
|
|
|
+ if (playing) {
|
|
|
+ stopBroadcast(true)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//首页
|
|
|
if (buffer[0].toInt() == 1 || buffer[0].toInt() == 2) {
|
|
|
if (skyCallFragment == null) {
|
|
@@ -962,12 +975,14 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
|
|
|
//呼叫
|
|
|
else if (buffer[4].toInt() == 1 || buffer[4].toInt() == 2) {
|
|
|
- runOnUiThread {
|
|
|
- clickVCall(true)
|
|
|
+ if (skyCallFragment == null) {
|
|
|
+ runOnUiThread {
|
|
|
+ clickVCall(true)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //呼叫护士键短按或长按松开
|
|
|
+ //面板呼叫护士键短按或长按松开
|
|
|
else if (buffer[5].toInt() == 1 || buffer[5].toInt() == 2) {
|
|
|
runOnUiThread {
|
|
|
clickVCall(false)
|
|
@@ -1177,7 +1192,10 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
//开始呼叫
|
|
|
fun startCall(type: Int) {
|
|
|
if (Constant.CUSTOM_ID != -1) {
|
|
|
- stopBroadcast(false)
|
|
|
+ if (playing) {
|
|
|
+ stopBroadcast(false)
|
|
|
+ }
|
|
|
+
|
|
|
//通话之前先判断webrtc socket和tcp是否连接正常,否则不能建立通话
|
|
|
if (Constant.TCP_CONNECTED && !TextUtils.isEmpty(Constant.SIP_ID)) {
|
|
|
//去电界面
|
|
@@ -1186,6 +1204,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
var fragment = SkyCallFragment()
|
|
|
var bundle = Bundle()
|
|
|
bundle.putInt("call_state", 0)
|
|
|
+ bundle.putBoolean("bc_play", false)
|
|
|
fragment.arguments = bundle
|
|
|
addCallFragment(fragment)
|
|
|
} else {
|
|
@@ -1212,6 +1231,13 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
|
removeCallFragment()
|
|
|
}
|
|
|
+
|
|
|
+ //退出通话,如果还有广播在播放则重新启动广播
|
|
|
+ myHandler.postDelayed({
|
|
|
+ if (broadcastOn) {
|
|
|
+ startBroadcast()
|
|
|
+ }
|
|
|
+ }, 2000)
|
|
|
}
|
|
|
|
|
|
//Sip注册状态
|
|
@@ -1255,7 +1281,9 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
Log.d("TCP", "received tcp action: " + tcpModel.action + ", type: " + tcpModel.type)
|
|
|
if (tcpModel.getType() == TcpType.VOICE) {
|
|
|
if (tcpModel.data != null) {
|
|
|
- stopBroadcast(false)
|
|
|
+ if (playing) {
|
|
|
+ stopBroadcast(false)
|
|
|
+ }
|
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
if (tcpModel.action == TcpAction.VoiceAction.CALL) {
|
|
|
Constant.fromId = tcpModel.fromId
|
|
@@ -1269,16 +1297,13 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
var bundle = Bundle()
|
|
|
bundle.putInt("call_state", 1)
|
|
|
bundle.putSerializable("tcp_model", tcpModel)
|
|
|
+ bundle.putBoolean("bc_play", broadcastOn)
|
|
|
fragment.arguments = bundle
|
|
|
addCallFragment(fragment)
|
|
|
} else {
|
|
|
showMessage(R.string.call_init_error)
|
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
|
- VoiceUtil.rejectAudioCall(
|
|
|
- Constant.DEVICE_ID,
|
|
|
- Constant.fromId,
|
|
|
- Constant.interactionId
|
|
|
- )
|
|
|
+ VoiceUtil.rejectAudioCall(Constant.DEVICE_ID, Constant.fromId, Constant.interactionId)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1309,14 +1334,16 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
} else if (tcpModel.type == TcpType.BROADCAST) {
|
|
|
if (tcpModel.action == TcpAction.BroadcastAction.START) {
|
|
|
if (Constant.TCP_CONNECTED && !TextUtils.isEmpty(Constant.SIP_ID)) {
|
|
|
- if (tcpModel.data != null) {
|
|
|
- val channelId = tcpModel.data.toString()
|
|
|
- startBroadcast(channelId)
|
|
|
+ if (tcpModel.data != null && !broadcastOn) {
|
|
|
+ broadcastOn = true
|
|
|
+ broadcastChannelId = tcpModel.data.toString()
|
|
|
+ startBroadcast()
|
|
|
}
|
|
|
} else {
|
|
|
showMessage("服务未连接或sipId为空")
|
|
|
}
|
|
|
} else if (tcpModel.action == TcpAction.BroadcastAction.STOP) {
|
|
|
+ broadcastOn = false
|
|
|
stopBroadcast(true)
|
|
|
}
|
|
|
} else if (tcpModel.type == TcpType.DEVICE) {
|
|
@@ -1401,14 +1428,20 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private fun startBroadcast(channelId: String) {
|
|
|
+ private fun startBroadcast() {
|
|
|
+ if (TextUtils.isEmpty(broadcastChannelId)) {
|
|
|
+ broadcastOn = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ playing = true
|
|
|
showMsgMain(getString(R.string.broadcast_start))
|
|
|
//初始化 engine
|
|
|
WebRTCEngine.getInstance().init(true, this)
|
|
|
//初始化 janusClient
|
|
|
janusClient = JanusClient(JanusConstant.JANUS_URL, Constant.SIP_ID.toBigInteger())
|
|
|
//初始化 StreamingCallback
|
|
|
- val streamingCallback = StreamingCallback(janusClient, Constant.SIP_ID.toBigInteger(), channelId.toBigInteger())
|
|
|
+ val streamingCallback = StreamingCallback(janusClient, Constant.SIP_ID.toBigInteger(), broadcastChannelId.toBigInteger())
|
|
|
janusClient?.setJanusCallback(streamingCallback)
|
|
|
|
|
|
janusClient?.connect()
|
|
@@ -1419,6 +1452,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
}
|
|
|
|
|
|
private fun stopBroadcast(showMsg: Boolean) {
|
|
|
+ playing = false
|
|
|
if (showMsg) {
|
|
|
showMsgMain(getString(R.string.broadcast_stop))
|
|
|
}
|
|
@@ -1428,6 +1462,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
}
|
|
|
if (janusClient != null) {
|
|
|
janusClient?.destroySession()
|
|
|
+ janusClient = null
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1491,7 +1526,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
if (count < 8) {
|
|
|
count++
|
|
|
SettingConfig.setNetErrResetCount(this, count)
|
|
|
- Handler().postDelayed({
|
|
|
+ myHandler.postDelayed({
|
|
|
AppUpdateHelper.reboot(activity)
|
|
|
}, 5000)
|
|
|
} else {
|