Month: February 2014

MSPL Script How-to

Microsoft SIP Processing Language [MSPL], is a scripting language that you can use to customize how Lync Server handles and routes SIP messages. MSPL scripts run in the context of the Lync Server process itself (in the front end), so they can intercept messages between users, filter messages, reroute messages, and so on.

MSPL unlike UCMA applications, they don’t run as a separate process, nor do they create endpoints of their own. they aren’t limited to controlling messages to and from a single endpoint it deals with all endpoints of that Lync Server.

How you can decide to use MSPL or UCMA?

  1. MSPL
    • The MSPL code itself is included directly in the application manifest.
    • The MSPL modifies the Front End behavior of the Lync Server. It has control over every message that is proxied through the Front End Server, regardless of where it comes from which endpoint or where it goes.
  1. UCMA
    • The UCMA application runs on a separate server from Lync Server, and creates an endpoint which communicates with other Lync endpoints via the Lync Front End Server.
    • The UCMA application can participate in and control a conversation between the remote endpoint and itself but can’t control other conversations between other endpoints that are not in the same conversation.


MSPL Script Structure

The following is the form that your MSPL script must be which is an ordinary XML file. The application Manifest is an XML file can be edited using any XML editor, Text editor or even you can open it using Microsoft Visual Studio, so you will find it started with the xml declaration, The following script to filter the sip requests that used to join conference as follow:

<?xml version="1.0" ?>


    <!-- Define properties of the application -->
    <lc:requestFilter methodNames="INVITE" 
    <lc:responseFilter reasonCodes="NONE" />
    <lc:proxyByDefault action="true" />

    <!-- The message filtering script -->

if (sipRequest && (sipRequest.Method == StandardMethod.Invite)) 
    if (sipRequest)
        Log("Event", false, "Joined the conference");
	DispatchNotification("OnRequest", sipMessage.To);


MSPL Script Syntax


the root element of the MSPL script is the <lc:applicationManifest> it contains the appUri attribute, which is basically a unique identifier for your application and you need it when you installing your application to the Lync Server.

<lc:requestFilter methodNames="INVITE" strictRoute="false"/>

Using the <lc:requestFilter> you can control what types of messages this application should handle so it controls the types of requests. it contains the methodNames attribute which can contains a list of SIP method names separated by commas i.e. invite also can monitor ALL method names or NONE of them. the next one is strictRoute attribute, which is false by default, controls whether the application sees requests for which explicit routing details have already been specified. If this is set to true, these messages that have a “strict” route will also go through the application.

<lc:responseFilter reasonCodes="NONE" />

The <lc:responseFilter> also specify what types of messages this application should handle and contain The reasonCodes attribute holds a comma-delimited list of SIP response codes, or ALL, or NONE.

<lc:proxyByDefault action="true" />

The <lc:proxyByDefault> element, which is used to decide how application will handle the sip message by setting the action attribute, If this is set to false, any messages that are not proxied, responded to, or otherwise handled by the application are simply dropped. If it’s true, messages that are not handled are proxied to their destination by Lync Server, just as they would were the application not installed.

<lc:scriptOnly />

If application will consist only of an MSPL script, and will not use any managed code, we can add the <lc:scriptOnly /> element, if not there is no need to add it.

    <![CDATA[ /* Start writing your script here */ ]]>

After that The MSPL script itself is included in the manifest within the <lc:splScript> element.

if (sipRequest) {
    /* do something */
    Log("Event", false, "Log somthing - ", sipMessage.To);
if (sipResponse) {
    /* do something else */

If you need to access the message. The sipMessage variable provides access to a class that contains the message details. However, in many cases, the application’s behavior will depend on whether it is handling a request or a response; and the data available will depend on which type of message it is. the same as sipResponse if you want to access the response.

Helpful References


Inside UCWA

The Unified Communications Web API (UCWA) is a REST-like API to enable real-time communications over the web on Server-Side based works for Microsoft Lync on-primes. See the UCWA previous post

Technology Boundaries

  • Only users homed on a Lync Server 2013 pool can take advantage of UCWA capabilities.
  • Supported only for The On Prime Lync Server.
  • Server-to-server authentication between an on-premises server and an Office 365 component is not supported.
  • HD Photos, Voicemail and meetings are dependent on the version of Exchange Server 2013.
  • Supported only for The On Prime Exchange Server.
  • Exchange 2010 On prime and Online are not supported.
  • Compatible with Internet Explorer versions 9 and 10 are both supported, as are the latest versions of Chrome, Safari, and Firefox.
  • The developers needs to know HTTP: POST and GET and PUT and DELETE and HTTP headers, REST SERVICE and indeed JavaScript and JQuery.

What We Can Do With The Technology

  1. Contacts and Groups
    • Access, search, federated organizations, monitor on contact list, subscribing to the presence, Presence, Location, and Note can publish and view her presence and note, View own photos or the photos of their contacts.
  2. Two-party and Multi-party IM
    • Supports instant messaging between two parties in a peer-to-peer fashion as well as multi-party IM sessions that are hosted by the server.
    • Add Participant for a Multi-Party IM.
    • Escalate the conversation to conference.
  3. Working with Online Meetings
    • Schedule an online meeting that can be joined by via this API or there Lync services.
    • Joining of online meetings with messaging and phone audio modalities (for future use).
    • A roster of meeting attendees is provided; this information includes participant name, contact information, and modalities. And can update Meeting.
    • Exchange APIs can be used to place meeting information on the user’s calendar you will only see meetings created by UCWA.

Technology Barriers (What we can’t do)

  • No Audio, Video or other Real Time Media (at this time). According to the Channel 9 video, UCWA is on the Roadmap to get voice/video/screen sharing capability over IP after Lync 2013 goes RTM.
  • Only allow you connect at a user level i.e. can’t do action on behalf of others.
  • No Office 365 support.
  • No User Impersonation.
  • No custom presence Support.
  • Can’t start group IM conversations.

Development Ability

  1. People
    • Search.
    • Presence Subscription and Presence Subscription Membership.
    • Get contact and contact information i.e. Location, Note, Photo, Presence, Privacy Relationship and Supported Modalities.
    • Get group, Group Contacts, Default Group, Distribution Group, Expand Distribution Group.
    • Start/Refresh/Stop Subscription to Contacts and Groups.
    • Subscribed Contacts.
    • Subscribe To Group Presence.
    • Get contacts forward call information i.e. Immediate Forward Settings, Immediate Forward to Contact, Immediate Forward to Delegates and Immediate Forward to Voicemail.
  2. Me
    • Call Forwarding Settings.
    • Change Phone Number.
    • Change Visibility: Changes the visibility of a phone number to other contacts.
    • Change location.
    • Presence: get a representation of the user’s availability and activity.
    • Note, Photo and Report My Activity: Indicates that the user is actively using this application.
    • Call settings i.e. Reset Unanswered Call Settings, Simultaneous Ring Settings, Simultaneous Ring to Contact, Simultaneous Ring to Delegates, Simultaneous Ring to Team, Unanswered Call Settings, Unanswered Call to Contact and Unanswered Call to Voicemail.
  3. Online Meetings
    • Dial in Region: get a representation of the access information for phone users who wish to join an online Meeting.
    • Group.
    • My Assigned Online Meetings.
    • My Online Meetings.
    • Online Meeting Default Values: get a representation of the values of my Online Meeting properties if not specified at scheduling time.
    • Online Meeting Eligible Values: get a representation of the eligible values that the application can choose from when scheduling an Online Meeting.
    • Online Meeting Extensions: get a representation of the data that is needed by a custom meeting extension, stored as a collection of key-value pair properties.
    • Online Meeting Invitation.
    • Online Meeting Invitation Customization.
    • Online Meeting Policies.
    • Meeting Organizer.
    • Phone Dial in Information.
  4. Communications and Modalities
    • Accept/decline incoming conversation.
    • Send invitation to contact/Participant and knows the Acceptance state.
    • Add Messaging.
    • Add Participant.
    • Attendees.
    • Cancel/Reject.
    • Conversations: get a representation of the user’s ongoing conversations.
    • Data Collaboration to return the current modality.
    • Demote: user can demote the participant from leader to attendee in the online Meeting.
    • Derived Conversation.
    • Derived Messaging.
    • Disable/Disable Audience Messaging and Disable/Disable Audience Mute Lock.
    • Failed Delivery Participant.
    • Forwarded By.
    • From: get a representation of the participant that sent an invitation.
    • Hold Phone Audio.
    • Join Online Meeting.
    • Leaders.
    • Lobby.
    • Local Participant.
    • Messaging and Messaging Invitation.
    • Mute Audio/Video.
    • Participant.
    • Participant Application Sharing : track when a participant joins or leaves this modality.
    • Participant Audio : track when a participant joins or leaves this modality.
    • Participant Data Collaboration: track when a participant joins or leaves this modality.
    • Participant Invitation.
    • Participant Messaging.
    • Participant Panoramic Video.
    • Participant Video.
    • Phone Audio Invitation.
    • Promote.
    • Reject.
    • Resume Phone Audio.
    • Send Message.
    • Set Is Typing.
    • Start Messaging.
    • Start Online Meeting.
    • Start Phone Audio.
    • Stop Messaging.
    • Transferred By.
    • Typing Participants.
    • Video Locked On Participant.

Endpoints of UCMA Applications

Network Endpoints

The Network endpoints are the agents that Microsoft Lync uses internally in the UCMA applications to represent the users’ agents in code by creating instances or objects of the UserEndpoint class or the ApplicationEndpoint class and can handle all operations that concern a single user agent with the assistant of other related classes.

UCMA application can run without any endpoints, but it would not be able to do any useful services or tasks because the application would have no SIP user agents to send or receive messages. Therefore, any useful UCMA application must when starting up initialize and establish at least one user endpoint or application endpoint.


The UserEndpoint class allows an application to perform communication operations on behalf of a single Lync Server user. When established, the user endpoint always registers with Lync Server and retrieves presence and contact information for specific user. Through the UserEndpoint class, you can perform contact and contact group operations as well as publish a presence, but because the user endpoint represents a single user, an application cannot use it to perform trusted operations such as impersonating another Lync Server user.

The UserEndpoint class is best suited for an application that acts on behalf of a number of different existing users simultaneously such as Web – based client applications (like Communicator Web Access)

We can use it also in Contact and Group Operations to perform contact list operations and Publishing presence information for a user which automatically assigns access control information and instance IDs to presence elements.

The user endpoint is not as robust in recovering from connection failures as the application endpoint, so it is less appropriate for server applications that must be highly available. When a user endpoint loses connectivity with Lync Server, it attempts to re-register with Lync Server once, but if this attempt fails it gives up and makes no further attempts to recover the connection.


The ApplicationEndpoint class is acts for highly available server applications that provide a service to many different users simultaneously. It does not represent an individual user, it has a separate identity defined by a Contact object in Active Directory such as Automatic call distributors and Message broadcasting

Because an application endpoint is automatically trusted by Lync Server, it is able to “impersonate” any individual user in order to perform communications operations on behalf of that user.

The ApplicationEndpoint class is able to load – balance connections across several frontend servers. In addition, it is more persistent than the UserEndpoint class in recovering connectivity with Lync Server. When an application endpoint loses its connection to Lync Server, it goes into the Reestablishing state and tries to regain its connection with the server until it succeeds, regardless of how long it remains without a connection.

The application endpoint ’ s trusted status with Lync server allows it to perform conference operations that would otherwise be restricted to conference leaders, as well as some special operations that cannot be performed at all through the Lync client. It can also join conferences as a trusted participant; in this state, it is not shown in the conference roster and has the same rights as a conference leader.

Application endpoints are not able to perform any contact operations, nor can they publish presence.

PTZ Camera

What is the PTZ Camera?

PTZ is an abbreviation for pantilt, and zoom which reflects the movement options of the camera. A pan–tilt–zoom camera (PTZ camera) is a camera that is capable of remote directional and zoom control.

You can physically control the camera horizontally or vertically using electrical motors. The zoom is controlled by mechanically moving two lenses closer together or further apart dependent on whether you are zooming in or out with the effect that objects in view appear larger or smaller.

With these cameras you can now capture footage from 360° around the camera and digitally zoom in on certain areas. Because you are recording the entire field of view it doesn’t matter if you are zoomed in on the entry gates or not, all angles are recorded.

Pan and Tilt Control

On a conventional PTZ camera, when you pan and tilt you physically rotate the camera using electrical motors i.e. pan (horizontally) or tilt (vertically).

The movement of the motor could be controlled relatively or absolutely and this is depending on how much you want the camera to move steps or degrees. In addition to controlling the speed of the move.

The Pan and tilt motors also could have the signal to move without stop horizontally or vertically.

Zooming Control

In the Mechanical PTZ Cameras, zoom is controlled by mechanically moving two lenses closer together or further apart dependent on whether you are zooming in or out with the effect that objects in view appear larger or smaller.

Digital PTZ cameras don’t work in this manner. The camera will first capture a full image, usually in megapixel resolution. When a user decides to zoom in they are provided with a section of the overall picture. The pixels in this are then enlarged so that the cropped image is the same size as the original. This gives the appearance that you have zoomed in as objects are now larger.

Controlling the PTZ Camera

PTZ cameras could be controlled by any of the following ways

  • Control the PTZ camera by its remote control, not all vendors support remote controls and not all cameras support remote controls.
  • Controlling the PTZ camera by COM ports and it work with one of the following protocols PelcoP, PelcoD and VISCA
  • Controlling the PTZ camera by USB and it work with UVC and this can use some components like DirectShow.NET

We can implement the software component to control the camera using C++ and C#

Other Cameras’ Types

As stated earlier, conventional PTZ cameras use motors to move the camera around. There are multiple different ways of using these to pan the camera such as bands, cogs or direct drive. There are even some which use electromagnetism to accurately aim the camera in some higher end cameras.

Digital PTZ systems perform their functionality in software. As a result there are no moving parts and nothing to break, freeze or move. So long as the camera is functioning, the digital PTZ system will work. So from a reliability point of view, digital PTZ cameras win hands down.

(Source: Network Webcams)