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