Escalating an AudioVideoCall to a conference in UCMA 2.0
Posted by: Clarity Blogs: ASP.NET,
on 08 May 2009 |
View original | Bookmarked: 0 time(s)
If youve ever tried to escalate an AudioVideoCall to a conference, you will know that it isnt the smooth, carefree experience that the words conference escalation call to mind. It has its pitfalls. Take a look at the following code:
private
void CreateCallAndEscalate()
{
// Create a conversation and a call.
_conversation = new Conversation(_endpoint);
_call = new AudioVideoCall(_conversation);
_call.BeginEstablish(_yourSipUri, null, CallEstablishCompleted, null);
}
private void CallEstablishCompleted(IAsyncResult result)
{
_call.EndEstablish(result);
_conversation.ConferenceSession.BeginJoin(JoinCompleted, null);
}
private void JoinCompleted(IAsyncResult result)
{
_conversation.ConferenceSession.EndJoin(result);
try
{
_conversation.BeginEscalateToConference(EscalateCompleted, null);
}
catch (InvalidOperationException ex)
{
Console.WriteLine("Escalate failed:");
Console.WriteLine(ex.ToString());
}
}
private void EscalateCompleted(IAsyncResult result)
{
try
{
_conversation.EndEscalateToConference(result);
}
catch (RealTimeException ex)
{
Console.WriteLine("Escalate failed:");
Console.WriteLine(ex.ToString());
}
}
At first glance, you might expect this code to cheerfully bump your AudioVideoCall up into the ad hoc conference and frolic off into the sunset. But no such luck. Run it, and you will be furnished with the following exception message:
Microsoft.Rtc.Signaling.OperationFailureException: The EscalateToConferenceAsyncResult operation has failed with message: "Call cannot escalate to conference, mediaProvider does not support escalation". See the InnerException and FailureReason properties as well as the logs for additional information. ---> System.InvalidOperationException: Call cannot escalate to conference, mediaProvider does not support escalation at Microsoft.Rtc.Collaboration.Call.BeginEscalate(McuSession mcuSession, AsyncCallback userCallback, Object state)
To make a long story short, the media provider for AudioVideoCalls doesnt have built-in support for escalation to a conference. Thankfully, there IS a way to get an existing two-party call into an ad hoc conference. The ConferenceSession object that belongs to the Conversation in turn has its own AudioVideoMcuSession. You can call the BeginTransfer method on the AudioVideoMcuSession to transfer an existing two-party call to the MCU, effectively bringing it into the conference. The new JoinCompleted method would look something like this:
private void JoinCompleted(IAsyncResult result)
{
_conversation.ConferenceSession.EndJoin(result);
try
{
_conversation.ConferenceSession.AudioVideoMcuSession.BeginTransfer(
_call, null, McuTransferCompleted, null);
}
catch (InvalidOperationException ex)
{
Console.WriteLine("MCU transfer failed:");
Console.WriteLine(ex.ToString());
}
}
You also need a callback method:
private void McuTransferCompleted(IAsyncResult result)
{
try
{
_conversation.ConferenceSession.AudioVideoMcuSession.EndTransfer(result);
}
catch (RealTimeException ex)
{
Console.WriteLine("MCU transfer failed:");
Console.WriteLine(ex.ToString());
}
}
When you run this code (youll need to do the extra work of setting up a CollaborationPlatform and endpoint and so forth) it will look very much like the application is placing a call and then escalating it to a conference. For a lot of situations (such as accepting incoming two-party calls and then bringing them into a conference) this will fit the bill perfectly well.
Feel free to email me if you have questions about this or if youd like the code for the full sample application.