Microsoft Lync and Skype for Business have a rich set of .NET APIs which make it easy to extend the platform and integrate it with other applications. This blog helps explain how to use those APIs.

Escalating an AudioVideoCall to a conference in UCMA 2.0

Posted: May 8th, 2009 | Author: | Filed under: OCS Development, UCMA 2.0 | 4 Comments »

If you’ve ever tried to escalate an AudioVideoCall to a conference, you will know that it isn’t 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 doesn’t 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 (you’ll 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 you’d like the code for the full sample application.


4 Comments on “Escalating an AudioVideoCall to a conference in UCMA 2.0”

  1. 1 Ossi Merjovaara said at 4:05 am on September 19th, 2012:

    Hi Michael,

    We would like to forward Lync call from one customers Lync user (over federation) to our conferencing sip URI. I think your code can do it? Am I right?

    BR,

    Ossi Merjovaara

  2. 2 Michael said at 6:46 pm on September 25th, 2012:

    I’m not sure I completely understand your requirement. Who will the federated Lync users be calling before you forward the call to your conference?

  3. 3 Kris said at 6:32 pm on December 3rd, 2014:

    Hi,

    Can you share the code sample ? I am trying to do a A calls B AudioVideoCall and escalating to conference. But I am not able to so far, if you share your sample, that would help me greatly, thank you.

    Kris

  4. 4 Kris said at 12:44 am on December 5th, 2014:

    Hi Michael,

    I am new to UCMA and learning , from the samples I am trying to do a simple A calls B audiovideo call and escalating to conference, but I hit this problem you talk about and cant seem to get it working. If you can share a sample for a A calls b audiovideo call escalating to conference, that would help me so much to learn this. Thanks so much again.

    Kris


Leave a Reply

  • Note: Comment moderation is in use because of excessive spam. Your comment may not appear immediately.

  •