更新時(shí)間:2019-11-20
用戶可以將正在進(jìn)行的視頻通話保持,待需要的時(shí)候再恢復(fù)通話,能減少撥號次數(shù),使用更方便。
視頻通話已建立,主被叫正在通話中。
保持通話
通話中,主被叫雙方均可以發(fā)起保持通話操作。
視頻通話保持,需先移除視頻,再保持音頻通話;恢復(fù)通話,需先恢復(fù)音頻通話,再打開視頻。
當(dāng)前服務(wù)器暫不支持視頻通話保持,需要先移除視頻窗口,轉(zhuǎn)換為語音通話后再保持通話。
-(BOOL)holdCallWithCallId:(unsigned int)callId { TSDK_RESULT ret = tsdk_hold_call(callId); DDLogInfo(@"Call_Log: tsdk_hold_call = %@",(TSDK_SUCCESS == ret)?@"YES":@"NO"); return ret == TSDK_SUCCESS ? YES : NO; }
case TSDK_E_CALL_EVT_HOLD_SUCCESS: { DDLogInfo(@"TSDK_E_CALL_EVT_HOLD_SUCCESS"); NSDictionary *resultInfo = @{ TSDK_CALL_HOLD_RESULT_KEY:[NSNumber numberWithBool:YES], CALL_ID : callId }; [self respondsCallDelegateWithType:CALL_HOLD_RESULT result:resultInfo]; break; }
恢復(fù)通話
保持通話發(fā)起方才可進(jìn)行恢復(fù)通話操作。
-(BOOL)unHoldCallWithCallId:(unsigned int)callId { TSDK_RESULT ret = tsdk_unhold_call(callId); return ret == TSDK_SUCCESS ? YES : NO; }
恢復(fù)通話可能由于網(wǎng)絡(luò)側(cè)極低概率的沖突或異常,導(dǎo)致用戶恢復(fù)通話失敗,此時(shí)SDK向UI上報(bào)恢復(fù)通話失敗事件TSDK_E_CALL_EVT_UNHOLD_FAILED,并自動掛斷通話。
case TSDK_E_CALL_EVT_UNHOLD_SUCCESS: { DDLogInfo(@"TSDK_E_CALL_EVT_UNHOLD_SUCCESS"); NSDictionary *resultInfo = @{ TSDK_CALL_UNHOLD_RESULT_KEY:[NSNumber numberWithBool:YES], CALL_ID : callId }; [self respondsCallDelegateWithType:CALL_UNHOLD_RESULT result:resultInfo]; break; }
-(BOOL)upgradeAudioToVideoCallWithCallId:(unsigned int)callId { TSDK_RESULT ret = tsdk_add_video((TSDK_UINT32)callId); DDLogInfo(@"Call_Log: tsdk_add_video = %d",ret); return ret == TSDK_SUCCESS ? YES : NO; }
- (BOOL)updateVideoWindowWithLocal:(id)localVideoView andRemote:(id)remoteVideoView andBFCP:(id)bfcpVideoView callId:(unsigned int)callId { TSDK_S_VIDEO_WND_INFO videoInfo[3]; memset_s(videoInfo, sizeof(TSDK_S_VIDEO_WND_INFO) * 2, 0, sizeof(TSDK_S_VIDEO_WND_INFO) * 2); videoInfo[0].video_wnd_type = TSDK_E_VIDEO_WND_LOCAL; videoInfo[0].render = (TSDK_UPTR)localVideoView; videoInfo[0].display_mode = TSDK_E_VIDEO_WND_DISPLAY_FULL; videoInfo[1].video_wnd_type = TSDK_E_VIDEO_WND_REMOTE; videoInfo[1].render = (TSDK_UPTR)remoteVideoView; videoInfo[1].display_mode = TSDK_E_VIDEO_WND_DISPLAY_CUT; videoInfo[2].video_wnd_type = TSDK_E_VIDEO_WND_AUX_DATA; videoInfo[2].render = (TSDK_UPTR)bfcpVideoView; TSDK_RESULT ret; videoInfo[2].display_mode = TSDK_E_VIDEO_WND_DISPLAY_CUT; ret = tsdk_set_video_window((TSDK_UINT32)callId, 3, videoInfo); DDLogInfo(@"Call_Log: tsdk_set_video_window = %d",ret); [self updateVideoRenderInfoWithVideoIndex:CameraIndexFront withRenderType:TSDK_E_VIDEO_WND_LOCAL andCallId:callId]; [self updateVideoRenderInfoWithVideoIndex:CameraIndexFront withRenderType:TSDK_E_VIDEO_WND_REMOTE andCallId:callId]; return (TSDK_SUCCESS == ret); }
case TSDK_E_CALL_EVT_OPEN_VIDEO_REQ: { NSString *callId = [NSString stringWithFormat:@"%d",notify.param1]; NSDictionary *callUpgradePassiveInfo = [NSDictionary dictionaryWithObjectsAndKeys:callId,CALL_ID,nil]; [self respondsCallDelegateWithType:CALL_UPGRADE_VIDEO_PASSIVE result:callUpgradePassiveInfo]; DDLogInfo(@"Call_Log: call revice CALL_E_EVT_CALL_ADD_VIDEO"); break; }
-(BOOL)replyAddVideoCallIsAccept:(BOOL)accept callId:(unsigned int)callId { TSDK_BOOL isAccept = accept; TSDK_RESULT ret = tsdk_reply_add_video((TSDK_UINT32)callId , isAccept); return ret == TSDK_SUCCESS ? YES : NO; }
- (BOOL)updateVideoWindowWithLocal:(id)localVideoView andRemote:(id)remoteVideoView andBFCP:(id)bfcpVideoView callId:(unsigned int)callId { TSDK_S_VIDEO_WND_INFO videoInfo[3]; memset_s(videoInfo, sizeof(TSDK_S_VIDEO_WND_INFO) * 2, 0, sizeof(TSDK_S_VIDEO_WND_INFO) * 2); videoInfo[0].video_wnd_type = TSDK_E_VIDEO_WND_LOCAL; videoInfo[0].render = (TSDK_UPTR)localVideoView; videoInfo[0].display_mode = TSDK_E_VIDEO_WND_DISPLAY_FULL; videoInfo[1].video_wnd_type = TSDK_E_VIDEO_WND_REMOTE; videoInfo[1].render = (TSDK_UPTR)remoteVideoView; videoInfo[1].display_mode = TSDK_E_VIDEO_WND_DISPLAY_CUT; videoInfo[2].video_wnd_type = TSDK_E_VIDEO_WND_AUX_DATA; videoInfo[2].render = (TSDK_UPTR)bfcpVideoView; TSDK_RESULT ret; videoInfo[2].display_mode = TSDK_E_VIDEO_WND_DISPLAY_CUT; ret = tsdk_set_video_window((TSDK_UINT32)callId, 3, videoInfo); DDLogInfo(@"Call_Log: tsdk_set_video_window = %d",ret); [self updateVideoRenderInfoWithVideoIndex:CameraIndexFront withRenderType:TSDK_E_VIDEO_WND_LOCAL andCallId:callId]; [self updateVideoRenderInfoWithVideoIndex:CameraIndexFront withRenderType:TSDK_E_VIDEO_WND_REMOTE andCallId:callId]; return (TSDK_SUCCESS == ret); }
case TSDK_E_CALL_EVT_OPEN_VIDEO_IND: { NSString *callId = [NSString stringWithFormat:@"%d",notify.param1]; NSDictionary *callUpgradePassiveInfo = [NSDictionary dictionaryWithObjectsAndKeys:callId,CALL_ID,nil]; [self respondsCallDelegateWithType:CALL_REFUSE_OPEN_VIDEO result:callUpgradePassiveInfo]; DDLogInfo(@"Call_Log: call CALL_E_EVT_CALL_DEL_VIDEO"); break; }
因通話雙方均可以在本端處于通話態(tài)發(fā)起保持操作,即通話可能會處于雙向保持態(tài),在任一保持方發(fā)起恢復(fù)通話時(shí),僅能恢復(fù)本端通話狀態(tài),不會恢復(fù)對端的通話狀態(tài);視頻通話雙向保持中任一方先恢復(fù)通話,不會自動打開視頻。