📄 voipcall.hpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#pragma once
#ifndef __VOIPCALL_HPP__
#define __VOIPCALL_HPP__
#include <atlbase.h> //for CComPtr
#include "rtccore.h"
#include "Timers.hpp"
#include "callbase.hpp"
//forward declarations
enum VoIPCallType;
class VoIPCall_t : public Call_t,
public ITimerHandler_t
{
public:
//public ctor
static HRESULT
CreateNewCall(
bool IsOutgoingCall, //outgoing call or incoming call?
__in_opt const WCHAR* pFriendlyNumber, //optional, FriendlyNumber that is already known when we create the call
__in_opt const WCHAR* pFriendlyName, //optional, FriendlyName that is already known when we create the call
__in IRTCSession* pRTCSession,
__deref_out_opt Call_t** ppNewCall
);
//Dtor must be public to use CComPtr
~VoIPCall_t(
void
);
//ITimerHandler_t implementation
void
OnTimerExpires(
UINT TimerID
);
void
ForceDestroy(
void
);
bool
Contains(
__in IRTCSession* pRTCSession
);
bool
Contains(
__in IRTCParticipant* pParticipant
);
//perform some verb for the phone canvas application
HRESULT
DoPhoneVerb(
PH_VERB Verb,
VPARAM Parameter = NULL
);
//send DTMF to the current participant
HRESULT
SendDTMF(
RTC_DTMF DTMFCode
);
//Notification sink
//handles an IRTCParticipantStateChangeEvent
HRESULT
OnRTCSessionStateChangeEvent(
__in IRTCSessionStateChangeEvent* pEvent
);
HRESULT
OnRTCParticipantStateChangeEvent(
__in IRTCParticipantStateChangeEvent* pEvent
);
HRESULT
OnRTCSessionReferredEvent(
__in IRTCSessionReferredEvent* pEvent
);
HRESULT
OnRTCSessionReferStatusChangeEvent(
__in IRTCSessionReferStatusEvent* pEvent
);
//Accessor for current Session status
RTC_SESSION_STATE
GetCallStatus(
void
);
HRESULT
GetURI(
__deref_out_opt BSTR* pURI
);
HRESULT
GetDuration(
__out SYSTEMTIME* pDuration
);
HRESULT
SetInfoAboutBeingTransferred(
__in IRTCSessionReferredEvent* pRTCSessionReferredEvent,
__in Call_t* pReferringCall
);
private:
//internal ctor
VoIPCall_t();
//initializes the call
HRESULT
Initialize(
bool IsOutgoingCall, //indicate it is incoming or outgoing
__in_opt const WCHAR* pFriendlyNumber, //opt, FriendlyNumber if it is already known when we initialize
__in_opt const WCHAR* pFriendlyName, //opt, FriendlyNumber if it is already known when we initialize
__in IRTCSession* pNewSession
);
//Caches the reason the call was disconnected (in case of error)
HRESULT
UpdateDisconnectReason(
__in IRTCParticipantStateChangeEvent* pEvent
);
HRESULT
DoVerbHoldUnhold(
PH_VERB verb
);
HRESULT
DoVerbAcceptRejectIncomingCall(
PH_VERB verb
);
HRESULT
DoVerbTalk(
void
);
HRESULT
DoVerbEnd(
void
);
HRESULT
DoVerbTransfer(
VPARAM Parameter
);
HRESULT
End(
void
);
void
KillTimer(
__inout UINT* pTimerId
);
void
StartRingbackTone(
void
);
void
StopRingbackTone(
void
);
HRESULT
StateChangeWhileBeingTransferred(
RTC_SESSION_STATE NewSessionState
);
void
LogCallIfNecessary(
void
);
void
UpdateNewLoggedCall(
VoIPCallType CallType
);
bool
IsBeingTransferred(
void
)
{
return ((m_cpRTCSessionReferredEvent != NULL) &&
(m_cpReferringCall != NULL));
};
void
ClearInfoAboutBeingTransferred(
void
)
{
m_cpRTCSessionReferredEvent = NULL;
m_cpReferringCall = NULL;
};
private:
static const UINT sc_TransferDoneTimeout;
static const UINT sc_RingbackStartTimeout;
//RTC COM pointers
CComPtr<IRTCParticipant> m_cpRTCParticipant;
CComPtr<IRTCSession> m_cpRTCSession;
CComPtr<IRTCSessionReferredEvent> m_cpRTCSessionReferredEvent;
CComPtr<Call_t> m_cpReferringCall;
bool m_CouldBeMissed; //helps verify if a call is incoming or possibly missed
VoIPCallType m_CallType; //call type
bool m_IsLogged; //indicate whether the call has been logged
bool m_PlayingRingbackTone;
UINT m_StartRingbackTimerId;
UINT m_TransferDoneTimerId;
};
#endif /* __VOIPCALL_HPP__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -