主頁(yè) > 服務(wù)與支持 > 開(kāi)發(fā)平臺(tái) > 客戶端SDK參考 > Windows Native SDK > 音視頻呼叫 建立視頻通話
更新時(shí)間:2019-11-20
用戶點(diǎn)對(duì)點(diǎn)視頻通話。
主被叫客戶端均已注冊(cè)。
呼叫ID作為一路通話的唯一標(biāo)識(shí),UI應(yīng)保存并管理,以用于后繼的呼叫相關(guān)操作。
//c code int result; TSDK_RESULT ret; TSDK_UINT32 call_id = 0; LOG_D_CALL_INFO("call number[%s], local video wind[%#x], remote video wind[%#x]", call_number, local_video_wnd, remote_video_wnd); result = tsdk_start_call(&call_id, call_number,TRUE); if (TSDK_SUCCESS != result) { LOG_D_CALL_ERROR("start call failed. result=%#x", result); return result; } |
//c code TSDK_S_VIDEO_WND_INFO video_window_info[SERVICE_CALL_D_VIDEO_WINDOW_NUM] = { TSDK_E_VIDEO_WND_REMOTE }; video_window_info[TSDK_E_VIDEO_WND_LOCAL].render = (TSDK_UINT32)local_video_wnd; video_window_info[TSDK_E_VIDEO_WND_LOCAL].video_wnd_type = TSDK_E_VIDEO_WND_LOCAL; video_window_info[TSDK_E_VIDEO_WND_LOCAL].index = 1; video_window_info[TSDK_E_VIDEO_WND_LOCAL].display_mode = TSDK_E_VIDEO_WND_DISPLAY_FULL; video_window_info[TSDK_E_VIDEO_WND_REMOTE].render = (TSDK_UINT32)remote_video_wnd; video_window_info[TSDK_E_VIDEO_WND_REMOTE].video_wnd_type = TSDK_E_VIDEO_WND_REMOTE; video_window_info[TSDK_E_VIDEO_WND_REMOTE].index = 0; video_window_info[TSDK_E_VIDEO_WND_REMOTE].display_mode = TSDK_E_VIDEO_WND_DISPLAY_FULL; ret = tsdk_set_video_window(call_id, SERVICE_CALL_D_VIDEO_WINDOW_NUM, video_window_info); if (TSDK_SUCCESS != result) { LOG_D_CALL_ERROR("set video window failed. result=%#x", result); return result; } return TSDK_SUCCESS; |
//c code case TSDK_E_CALL_EVT_CALL_OUTGOING: { CHECK_POINTER(data); TSDK_S_CALL_INFO* callInfo = (TSDK_S_CALL_INFO*)data; TSDK_S_CALL_INFO* notifyInfo = new TSDK_S_CALL_INFO; memset(notifyInfo, 0, sizeof(TSDK_S_CALL_INFO)); memcpy_s(notifyInfo, sizeof(TSDK_S_CALL_INFO), callInfo, sizeof(TSDK_S_CALL_INFO)); ::PostMessage(maindlg->GetSafeHwnd(), WM_CALL_STARTCALL, WPARAM(notifyInfo), NULL); break; } case TSDK_E_CALL_EVT_CALL_INCOMING: { CHECK_POINTER(data); TSDK_S_CALL_INFO* callInfo = (TSDK_S_CALL_INFO*)data; TSDK_S_CALL_INFO* notifyInfo = new TSDK_S_CALL_INFO; memset(notifyInfo, 0, sizeof(TSDK_S_CALL_INFO)); memcpy_s(notifyInfo, sizeof(TSDK_S_CALL_INFO), callInfo, sizeof(TSDK_S_CALL_INFO)); ::PostMessage(maindlg->GetSafeHwnd(), WM_CALL_INCOMMING, (WPARAM)notifyInfo, NULL); break; } |
//c code case TSDK_E_CALL_EVT_CALL_RINGBACK: { LOG_D_CALL_INFO("call ringback"); break; } |
被叫若拒絕呼叫參見(jiàn)結(jié)束通話(或呼叫)章節(jié)描述。
//c code TSDK_RESULT ret; ret = tsdk_accept_call(callid, (TSDK_BOOL)isVideo); if (TSDK_SUCCESS != ret) { LOG_D_CALL_ERROR("accept call failed. result=%#x", ret); return -1; } return TSDK_SUCCESS; |
被叫用戶若選擇音頻接聽(tīng),則被叫用戶無(wú)需此步驟。
RTP通道已建立,可以進(jìn)行一些二次撥號(hào)等操作。
//c code case TSDK_E_CALL_EVT_CALL_RTP_CREATED: { LOG_D_CALL_INFO("call rtp created Event"); break; } |
//c code case TSDK_E_CALL_EVT_CALL_CONNECTED: { TSDK_S_CALL_INFO* callInfo = (TSDK_S_CALL_INFO*)data; TSDK_S_CALL_INFO* notifyInfo = new TSDK_S_CALL_INFO; memset(notifyInfo, 0, sizeof(TSDK_S_CALL_INFO)); memcpy_s(notifyInfo, sizeof(TSDK_S_CALL_INFO), callInfo, sizeof(TSDK_S_CALL_INFO)); ::PostMessage(maindlg->GetSafeHwnd(), WM_CALL_CONNECTED, (WPARAM)notifyInfo, NULL); break; } |
無(wú)。