@@ -13,12 +13,17 @@ import com.example.ivdemo.adapter.UserListAdapter
1313import com.tencent.iot.twcall.R
1414import com.tencent.iot.twcall.databinding.ActivityTweCallBinding
1515import com.tencent.iot.video.device.VideoNativeInterface
16+ import com.tencent.iot.video.device.annotations.AudioEncType
1617import com.tencent.iot.video.device.annotations.CallType
1718import com.tencent.iot.video.device.annotations.PixelType
1819import com.tencent.iot.video.device.annotations.StreamType
20+ import com.tencent.iot.video.device.annotations.VideoEncType
1921import com.tencent.iot.video.device.annotations.VoipActivateType
22+ import com.tencent.iot.video.device.annotations.VoipRecvVFpsType
23+ import com.tencent.iot.video.device.annotations.VoipRecvVRotateType
2024import com.tencent.iot.video.device.callback.IvVoipCallback
2125import com.tencent.iot.video.device.model.AvDataInfo
26+ import com.tencent.iot.video.device.model.VoipVideoInfo
2227import com.tencent.iotvideo.link.CameraRecorder
2328import com.tencent.iotvideo.link.SimplePlayer
2429import com.tencent.iotvideo.link.entity.UserEntity
@@ -33,6 +38,7 @@ private const val DATA_PATH = "/storage/emulated/0/"
3338
3439class TweCallActivity : BaseIPCActivity <ActivityTweCallBinding >(), IvVoipCallback {
3540
41+ @Volatile
3642 private var initStatus = - 1 // 未初始化 -1, 初始化成功 0, 其他
3743
3844 private var condition1 = false
@@ -120,7 +126,6 @@ class TweCallActivity : BaseIPCActivity<ActivityTweCallBinding>(), IvVoipCallbac
120126
121127 override fun initView () {
122128 cameraRecorder.init (this )
123- cameraRecorder.isSaveRecord(true )
124129 with (binding) {
125130 titleLayout.tvTitle.text = getString(R .string.title_tweCall)
126131 titleLayout.ivRightBtn.isVisible = true
@@ -199,7 +204,7 @@ class TweCallActivity : BaseIPCActivity<ActivityTweCallBinding>(), IvVoipCallbac
199204 } else {
200205 showToast(" twecall初始化成功" )
201206 val activeDeviceInfo = VideoNativeInterface .getInstance().voipActiveDeviceInfoV2
202- if (activeDeviceInfo == null || activeDeviceInfo.expireTime < System .currentTimeMillis()/ 1000 ) {
207+ if (activeDeviceInfo == null || activeDeviceInfo.expireTime < System .currentTimeMillis() / 1000 ) {
203208 val activateRes = VideoNativeInterface .getInstance()
204209 .activateVoipLicenseV2(VoipActivateType .VOIP_ACT_IPC )
205210 if (activateRes == 0 ) {
@@ -280,9 +285,17 @@ class TweCallActivity : BaseIPCActivity<ActivityTweCallBinding>(), IvVoipCallbac
280285 if (isVideo) QualitySetting .getInstance(this @TweCallActivity).isWxCameraOn else true
281286 val callType =
282287 if (isVideo) CallType .IV_CM_STREAM_TYPE_VIDEO else CallType .IV_CM_STREAM_TYPE_AUDIO
288+ val videoInfo = VoipVideoInfo (
289+ VideoEncType .IV_CM_VENC_TYPE_H264 ,
290+ VideoEncType .IV_CM_VENC_TYPE_H264 ,
291+ recvPixel,
292+ AudioEncType .IV_CM_AENC_TYPE_AAC ,
293+ VoipRecvVFpsType .VOIP_RECV_V_FPS_MAX ,
294+ VoipRecvVRotateType .VOIP_RECV_V_ROTATE_NONE
295+ )
283296 val res = VideoNativeInterface .getInstance().doWxCloudVoipCall(
284297 modelId, wxaAppId, openId, deviceId,
285- callType, recvPixel , true , calleeCameraSwitch
298+ callType, videoInfo , true , calleeCameraSwitch
286299 )
287300 val result = when (res) {
288301 - 2 -> " 通话中"
@@ -310,8 +323,16 @@ class TweCallActivity : BaseIPCActivity<ActivityTweCallBinding>(), IvVoipCallbac
310323 if (isVideo) QualitySetting .getInstance(this @TweCallActivity).isWxCameraOn else true
311324 val callType =
312325 if (isVideo) CallType .IV_CM_STREAM_TYPE_VIDEO else CallType .IV_CM_STREAM_TYPE_AUDIO
326+ val videoInfo = VoipVideoInfo (
327+ VideoEncType .IV_CM_VENC_TYPE_H264 ,
328+ VideoEncType .IV_CM_VENC_TYPE_H264 ,
329+ recvPixel,
330+ AudioEncType .IV_CM_AENC_TYPE_AAC ,
331+ VoipRecvVFpsType .VOIP_RECV_V_FPS_MAX ,
332+ VoipRecvVRotateType .VOIP_RECV_V_ROTATE_NONE
333+ )
313334 val res = VideoNativeInterface .getInstance()
314- .doWxCloudVoipCallV2(openId, callType, recvPixel , true , calleeCameraSwitch)
335+ .doWxCloudVoipCallV2(openId, callType, videoInfo , true , calleeCameraSwitch)
315336 val result = when (res) {
316337 - 2 -> " 通话中"
317338 0 -> " 呼叫成功"
@@ -372,8 +393,10 @@ class TweCallActivity : BaseIPCActivity<ActivityTweCallBinding>(), IvVoipCallbac
372393 Log .d(TAG , " destory" )
373394 checkDefaultThreadActiveAndExecuteTask {
374395// VideoNativeInterface.getInstance().exitWxCloudVoip()
375- VideoNativeInterface .getInstance().exitWxCloudVoipV2()
376- Log .d(TAG , " exit twecall v2" )
396+ if (initStatus == 0 ) {
397+ VideoNativeInterface .getInstance().exitWxCloudVoipV2()
398+ Log .d(TAG , " exit twecall v2" )
399+ }
377400 }
378401 super .onDestroy()
379402 }
0 commit comments