[Asterisk-Users] Registering Microsoft RTC Client API SDK with
Asterisk
Jeremy Davis
jmd at jvf.co.uk
Tue Feb 8 03:27:40 MST 2005
Last week I asked how to register the Microsoft Real_time Communications
Client with Asterisk. No replys came, however I managed to figure it out
myself. I thought I'd just post the solution for anyone else in the
future wanting to do the same.
Regards
Jerry
CString gXMLProfile = "\
<provision key=\"5B29C449-29EE-4fd8-9E3F-04AED077690E\"\n\
name=\"Asterisk\">\n\
\n\
<user account=\"username\"\n\
uri=\"username\"\
/>\n\
\n\
<sipsrv addr=\"Asterisk_Address\"\n\
protocol=\"udp\"\n\
auth=\"digest\"\n\
role=\"registrar\">\n\
<session party=\"first\" type=\"pc2ph\" />\n\
</sipsrv>\n\
\n\
</provision>\n";
IRTCClient2 *g_pClient = NULL;
BSTR bstrXMLProfile;
HRESULT hr = E_FAIL;
// initialize COM.
hr = CoInitialize(NULL);
if (FAILED(hr))
{
TRACE("CoInitialize failed:hr=%x\n", hr);
return;
}
// Create the RTC client
hr = CoCreateInstance(
__uuidof(RTCClient),
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IRTCClient2),
(LPVOID *)&g_pClient
);
if (FAILED(hr))
{
TRACE("CoCreateInstance failed: hr=%x\n", hr);
return;
}
hr = g_pClient->Initialize();
if (hr != S_OK)
TRACE("Unable to initialise\n");
else
{
TRACE("Hello, RTC!\n");
TRACE("\nXML Schema = \n%s\n", gXMLProfile);
IRTCClientProvisioning *pIRTCClientProvisioning = NULL;
IRTCProfile *pIRTCProfile = NULL;
bstrXMLProfile = gXMLProfile.AllocSysString();
// Perform QI for the Provisioning interface.
hr = g_pClient->QueryInterface(IID_IRTCClientProvisioning,
reinterpret_cast<void **>(&pIRTCClientProvisioning));
// If (hr != S_OK), process the error here.
if (hr != S_OK)
TRACE("QueryInterface failed\n");
else
{
// Create the Profile object.
hr = pIRTCClientProvisioning->CreateProfile(bstrXMLProfile,
&pIRTCProfile);
// If (hr != S_OK), process the error here.
if (hr != S_OK)
TRACE("CreateProfile failed 0x%X\n", hr);
else
{
// Enable the Profile and Register.
hr =
pIRTCClientProvisioning->EnableProfile(pIRTCProfile, RTCRF_REGISTER_ALL);
// If (hr != S_OK), process the error here.
if (hr != S_OK)
{
TRACE("Enable Profile failed\n");
}
else
{
TRACE("ALL OK\n");
}
}
}
}
More information about the asterisk-users
mailing list