接收通話
下列程式代碼範例示範如何處理新的通話通知,例如尋找或建立適當的終端機來轉譯媒體。 此範例是應用程式必須針對事件處理實作的 switch 語句的一部分。 程序代碼本身可能包含在ITTAPIEventNotification::Event的實作中,或 Event 方法可能會將訊息張貼至包含 參數的背景工作線程。
使用此程式代碼範例之前,您必須在 Initialize TAPI中執行作業,選取位址,然後 註冊事件。
此外,您必須在擷取 ITBasicCallControl 和 ITAddress 介面指標之後,執行 選取終端機 中所述的作業。
注意
此範例沒有適用於實際執行程式代碼的錯誤檢查和版本。
// pEvent is an IDispatch pointer for the ITCallNotificationEvent interface of the
// call object created by TAPI, and is passed into the event handler by TAPI.
case TE_CALLNOTIFICATION:
{
// Get the ITCallNotification interface.
ITCallNotificationEvent * pNotify;
hr = pEvent->QueryInterface(
IID_ITCallNotificationEvent,
(void **)&pNotify
);
// If ( hr != S_OK ) process the error here.
// Get the ITCallInfo interface.
ITCallInfo * pCallInfo;
hr = pNotify->get_Call( &pCallInfo);
// If ( hr != S_OK ) process the error here.
// Get the ITBasicCallControl interface.
ITBasicCallControl * pBasicCall;
hr = pCallInfo->QueryInterface(
IID_ITBasicCallControl,
(void**)&pBasicCall
);
// If ( hr != S_OK ) process the error here.
// Get the ITAddress interface.
ITAddress * pAddress;
hr = pCallInfo->get_Address( &pAddress );
// If ( hr != S_OK ) process the error here.
// Create the required terminals for this call.
{
// See the Select a Terminal code example.
}
// Complete incoming call processing.
hr = pBasicCall->Answer();
// If ( hr != S_OK ) process the error here.
}
相關主題