主頁 > 服務(wù)與支持 > 開發(fā)平臺(tái) > 客戶端SDK參考 > iOS Native SDK > 音視頻呼叫 音頻通話轉(zhuǎn)視頻通話
更新時(shí)間:2019-11-20
音頻通話中,通話的一方發(fā)起音頻通話切換為視頻通話。
音頻通話已建立,主被叫正在通話中。
通話中,主被叫雙方均可以發(fā)起音頻轉(zhuǎn)視頻操作。
-(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; }
只有被請求方用戶接受時(shí),才需要此步驟。
若用戶長時(shí)間沒有響應(yīng),被請求端應(yīng)用程序應(yīng)該自動(dòng)拒絕轉(zhuǎn)視頻的請求。建議時(shí)間為45s。
- (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); }
若被請求方接受視頻請求,請求方向UI上報(bào)打開視頻通知事件TSDK_E_CALL_EVT_OPEN_VIDEO_IND,UI根據(jù)事件顯示遠(yuǎn)端和近端視頻窗口;被請求方點(diǎn)擊接受后,UI顯示遠(yuǎn)端和近端視頻窗口。
若被請求方拒絕視頻請求,請求方向UI上報(bào)遠(yuǎn)端拒絕請求打開視頻通知事件TSDK_E_CALL_EVT_REFUSE_OPEN_VIDEO_IND,UI銷毀遠(yuǎn)端和近端視頻窗口。
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; }
無。