Microsoft SIP Processing Language, a.k.a. MSPL, can be handy for changing Lync’s routing behavior, to do things like block or reroute calls based on their origin, or send all calls of a certain type to a UCMA application. In certain cases, when writing MSPL scripts, you may want your script to behave differently depending on whether it is dealing with an audio call or an instant messaging session. It’s not immediately obvious how to distinguish between these two types of calls in MSPL, so I wanted to write up a quick description of how you can do this.

In UCMA, you don’t have to do anything special to distinguish these call types; the UCMA runtime does it for you, and supplies your application with either an AudioVideoCall or InstantMessagingCall object. In MSPL scripts, however, there is no such easy distinction. You can’t check the value of a property to determine whether you’re looking at an INVITE message for an audio call or an IM session. What you can look at, though, is the Session Description Protocol content in the body of the INVITE message.

SDP is the protocol that SIP endpoints use to negotiate how media will be transmitted during the communication session. It consists of key/value pairs that look like this–

c=IN IP4 192.168.0.10

–where c is the key and everything after the equal sign is the value.

If you look at the SDP in an INVITE message, you will see a line that begins with m=. The first part of the value in this line tells you a type of media that is being transmitted on this call. For instance, here is an example for an audio-only call:

m=audio 15713 RTP/SAVP 112 111 0 8 114 6 15 110 94 101

Here is the corresponding line in an IM-only call:

m=message 5060 sip null

If you look at it this way, it’s fairly simple. To look for a specific type of media, you can check for the first part of that m= line in the content of the INVITE request:

if (ContainsString(sipRequest.Content, "m=audio", true)) {
// Do something that should only happen to audio calls.
}

The same principle works for application sharing calls (m=application) and video (m=video).

Enjoy, and let me know if you have any questions!

Leave a Reply

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