📄 callbase.cpp
字号:
//
// 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.
//
#include "CallBase.hpp"
#include "CommonFunctions.hpp"
#include <auto_xxx.hxx> //for auto_bstr etc.
#include <rtcerr.h> //for RTC error codes
#include "Debug.hpp"
void
InvalidateTime(
__inout SYSTEMTIME* pSystemTime
)
{
if (!pSystemTime)
{
return;
}
FILETIME FileTime = {0};
FileTimeToSystemTime(
&FileTime,
pSystemTime
);
return;
}
/*------------------------------------------------------------------------------
Call_t::Call_t
Ctor
------------------------------------------------------------------------------*/
Call_t::Call_t()
{
TRACE(ZONE_PHONEAPP_CTOR);
m_RefCount = 1;
m_NetworkStatus = 0;
m_IsRejected = false;
InvalidateTime(&m_StartTime);
InvalidateTime(&m_EndTime);
}
/*------------------------------------------------------------------------------
Call_t::Call_t
Ctor
------------------------------------------------------------------------------*/
Call_t::~Call_t()
{
TRACE(ZONE_PHONEAPP_CTOR);
ASSERT(m_RefCount == 0);
}
/*------------------------------------------------------------------------------
Call_t::AddRef
Add's a reference to this object (not thread-safe)
------------------------------------------------------------------------------*/
ULONG
Call_t::AddRef(
void
)
{
//-- DESIGN -- not thread safe call - we will not be called from multiple threads
int ReturnValue = ++m_RefCount;
PHONEAPP_DEBUGMSG(ZONE_PHONEAPP_REFCOUNT, (L"Call_t>> New ref count: %d", ReturnValue));
return ReturnValue;
}
/*------------------------------------------------------------------------------
Call_t::Release
Releases an object from this object (not thread-safe)
------------------------------------------------------------------------------*/
ULONG
Call_t::Release(
void
)
{
//-- DESIGN -- not thread safe call - we will not be called from multiple threads
int ReturnValue = --m_RefCount;
PHONEAPP_DEBUGMSG(ZONE_PHONEAPP_REFCOUNT, (L"Call_t>> New ref count: %d", ReturnValue));
if (! m_RefCount)
{
delete this;
}
return ReturnValue;
}
HRESULT
Call_t::DoPhoneVerb(
PH_VERB Verb,
VPARAM Parameter
)
{
return E_NOTIMPL;
}
HRESULT
Call_t::OnRTCSessionStateChangeEvent(
__in IRTCSessionStateChangeEvent* pEvent
)
{
return E_NOTIMPL;
}
HRESULT
Call_t::OnRTCParticipantStateChangeEvent(
__in IRTCParticipantStateChangeEvent* pEvent
)
{
return E_NOTIMPL;
}
HRESULT
Call_t::OnRTCSessionReferredEvent(
__in IRTCSessionReferredEvent* pEvent
)
{
return E_NOTIMPL;
}
HRESULT
Call_t::OnRTCSessionReferStatusChangeEvent(
__in IRTCSessionReferStatusEvent* pEvent
)
{
return E_NOTIMPL;
}
HRESULT
Call_t::SetInfoAboutBeingTransferred(
IRTCSessionReferredEvent* pRTCSessionReferredEvent,
Call_t* pReferringCall
)
{
return E_NOTIMPL;
}
HRESULT
Call_t::GetDisplayNumber(
WCHAR* pBuffer,
unsigned int BufferSize
)
{
if (pBuffer == NULL || BufferSize <= 0)
{
return E_INVALIDARG;
}
if (m_bstrFriendlyNumber != NULL)
{
StringCchCopy(
pBuffer,
BufferSize,
m_bstrFriendlyNumber
);
if (pBuffer != NULL && pBuffer[0] != NULL)
{
return S_OK;
}
}
if (m_bstrURI != NULL)
{
StringCchCopy(
pBuffer,
BufferSize,
m_bstrURI
);
if (pBuffer != NULL && pBuffer[0] != NULL)
{
return S_OK;
}
}
return E_FAIL;
}
HRESULT
Call_t::GetDisplayName(
WCHAR* pBuffer,
unsigned int BufferSize
)
{
if (pBuffer == NULL || BufferSize <= 0)
{
return E_INVALIDARG;
}
if (m_bstrFriendlyName != NULL)
{
StringCchCopy(
pBuffer,
BufferSize,
m_bstrFriendlyName
);
if (pBuffer != NULL && pBuffer[0] != NULL)
{
return S_OK;
}
}
if (m_bstrName != NULL)
{
StringCchCopy(
pBuffer,
BufferSize,
m_bstrName
);
if (pBuffer != NULL && pBuffer[0] != NULL)
{
return S_OK;
}
}
return GetDisplayNumber(
pBuffer,
BufferSize
);
}
ce::auto_bstr&
Call_t::GetDisplayName(
void
)
{
if (m_bstrFriendlyName != NULL &&
m_bstrFriendlyName[0] != L'\0')
{
return m_bstrFriendlyName;
}
if (m_bstrName != NULL &&
m_bstrName[0] != L'\0')
{
return m_bstrName;
}
return GetDisplayNumber();
}
ce::auto_bstr&
Call_t::GetDisplayNumber(
void
)
{
if (m_bstrFriendlyNumber != NULL &&
m_bstrFriendlyNumber[0] != L'\0')
{
return m_bstrFriendlyNumber;
}
return m_bstrURI;
}
HRESULT
Call_t::GetRingTonePath(
WCHAR* pBuffer,
unsigned int BufferSize
)
{
if (pBuffer == NULL || BufferSize <= 0)
{
return E_INVALIDARG;
}
if (m_bstrRingTonePath != NULL)
{
StringCchCopy(
pBuffer,
BufferSize,
m_bstrRingTonePath
);
if (pBuffer != NULL && pBuffer[0] != NULL)
{
return S_OK;
}
}
return E_FAIL;
}
#ifdef DEBUG
void
Call_t::DebugState(
void
)
{
PHONEAPP_DEBUGMSG(ZONE_PHONEAPP_STATE, (L"\t\t Participant URI: %s \r\n", m_bstrURI));
PHONEAPP_DEBUGMSG(ZONE_PHONEAPP_STATE, (L"\t\t Participant Name: %s \r\n", m_bstrName));
PHONEAPP_DEBUGMSG(ZONE_PHONEAPP_STATE, (L"\t\t Participant Display Number: %s \r\n", m_bstrFriendlyNumber));
PHONEAPP_DEBUGMSG(ZONE_PHONEAPP_STATE, (L"\t\t Participant Display Name: %s \r\n", m_bstrFriendlyName));
const WCHAR* pCallStatus = NULL;
switch (GetCallStatus())
{
case RTCSS_IDLE:
pCallStatus = L"RTCSS_IDLE";
break;
case RTCSS_INCOMING:
pCallStatus = L"RTCSS_INCOMING";
break;
case RTCSS_ANSWERING:
pCallStatus = L"RTCSS_ANSWERING";
break;
case RTCSS_INPROGRESS:
pCallStatus = L"RTCSS_INPROGRESS";
break;
case RTCSS_CONNECTED:
pCallStatus = L"RTCSS_CONNECTED";
break;
case RTCSS_DISCONNECTED:
pCallStatus = L"RTCSS_DISCONNECTED";
break;
case RTCSS_HOLD:
pCallStatus = L"RTCSS_HOLD";
break;
case RTCSS_REFER:
pCallStatus = L"RTCSS_REFER";
break;
default:
ASSERT(FALSE);
break;
}
PHONEAPP_DEBUGMSG(ZONE_PHONEAPP_STATE, (L"\t\t Call Status: %s \r\n", pCallStatus));
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -