Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Negotiating Media in a Signaling Session

In this topic three of the most common SIP offer/answer media negotiation scenarios in the Microsoft Unified Communications infrastructure are presented. Each scenario shows the steps taken by two applications, a local application, and a remote application. The programming pattern for media negotiation requires the following steps on the local and remote sides.

In the first scenario a local application sends an initial offer in the body of an INVITE request. The remote application sends its answer in the body of a 200 OK response.

  1. (Local side) The local application creates a new SignalingSession to make an outbound call.
  2. (Local side) The local application binds an implementation of the IOfferAnswer interface to the SignalingSession instance. The offer is prepared in this step.
  3. (Local side) The local application calls Participate on the SignalingSession.
  4. (Local side) Unified Communications Managed API version 1.0 calls the GetOffer method that was implemented in Step 2. The local application formats the offer and passes it in the initial INVITE request to be sent to the remote participant.
  5. (Remote side) The SessionReceived event is raised on the remote RealTimeEndpoint object, which causes the developer-implemented handler for this event to execute. For more information about the SessionReceived event handler, see Receiving an Incoming Signaling Session. The media offer is accessible from the SessionReceivedEventArgs parameter that is associated with this event handler. The remote application can now start preparing the answer.
  6. (Remote side) When the answer is ready, the remote application binds an implementation of the IOfferAnswer interface to the SignalingSession created upon receiving the INVITE request. It then calls Participate on the SignalingSession instance to accept the session.
  7. (Remote side) Unified Communications Managed API version 1.0 calls the GetAnswer method on the remote-side implementation of the IOfferAnswer interface. This method will return the answer prepared in Step 2. The answer is then included as part of the 200 OK response that is sent back to the session initiator.
  8. (Local side) Unified Communications Managed API version 1.0 then calls the SetAnswer method on the remote-side implementation of the IOfferAnswer interface so that the local application can consume the answer.

In the second scenario, the local application first sends an INVITE message with an empty offer. The remote application then responds with its offer contained in a 200 OK response. Finally, the local application replies with an ACK request that contains its answer to the offer sent by the remote side.

  1. (Local side) The local application creates a new SignalingSession instance to make an outbound call.
  2. (Local side) The local application binds an implementation of IOfferAnswer to the SignalingSession instance.
  3. (Local side) The local application calls Participate on the SignalingSession object.
  4. (Local side) Unified Communications Managed API version 1.0 calls the GetOffer method on the local-side implementation of the IOfferAnswer interface, which returns a null ContentDescription object. Unified Communications Managed API version 1.0 then sends an initial INVITE without any offer. That is, there is no Content-Type header, and the Content-Length value is zero (0).
  5. (Remote side) The SessionReceived event is raised on the remote RealTimeEndpoint object, which causes the developer-implemented handler for this event to execute. For more information about the SessionReceived event handler, see Receiving an Incoming Signaling Session. The SessionReceivedEventArgs parameter that is associated with this event handler can be examined to discover that the INVITE was sent with an empty offer. Because there is no offer, Unified Communications Managed API version 1.0 asks the receiving party for an offer by calling the GetOffer method on the remote-side implementation of the IOfferAnswer interface to present an offer.
  6. (Remote side) When the remote application chooses to accept the session, it binds an implementation of the IOfferAnswer interface to the SignalingSession object created when the INVITE request was received. The application then calls Participate on the SignalingSession object to accept the session.
  7. (Remote side) Unified Communications Managed API version 1.0 calls the GetOffer method on the remote-side implementation of the IOfferAnswer interface, and sends a 200 OK response that contains the offer as its payload.
  8. (Local side) On receiving the 200 OK response from the remote participant, Unified Communications Managed API version 1.0 calls the HandleOfferInInviteResponse method on the local-side implementation of the IOfferAnswer interface, passing the offer in the OfferInInviteResponseEventArgs parameter. The application can then prepare its answer, and when it is ready, can call ReadyToAnswer. At this time, Unified Communications Managed API version 1.0 calls GetAnswer on the local-side implementation of the IOfferAnswer interface, and passes this answer to the remote endpoint as part of an ACK request.
  9. (Remote side) Upon receiving the acknowledgement, Unified Communications Managed API version 1.0 calls the SetAnswer method on the remote-side implementation of the IOfferAnswer interface to pass the answer to the application. The application can choose to reconcile any differences in media description based on the newly arrived answer.

Subsequent offers can be sent or received as part of media renegotiation inside a signaling session.

  1. (Local side) The local application prepares an offer in order to renegotiate media capabilities of an established session.
  2. (Local side) The local application calls the RenegotiateDescription method.
  3. (Local side) Unified Communications Managed API version 1.0 calls the GetOffer method on the local-side implementation of the IOfferAnswer interface.
  4. (Local side) Unified Communications Managed API version 1.0 sends a re-INVITE request that contains a new media description in the SIP message body in the existing signaling session.
  5. (Remote side) Upon receiving the INVITE request on the remote side, Unified Communications Managed API version 1.0 calls the HandleOfferInReInvite method on the remote-side implementation of the IOfferAnswer interface. The offer can be accessed from the OfferInReInviteEventArgs argument.
  6. (Remote side) The application extracts the media description from the OfferInReInviteEventArgs argument and uses it to asynchronously prepare an answer.
  7. (Remote side) When the answer is prepared, the remote application optionally calls SendProvisionalResponse on the OfferInReInviteEventArgs instance. When the application is ready with its answer, it can call Accept to accept the offer or Decline to decline the offer. A call to Accept results in GetAnswer being called.
  8. (Local side) After the 200 OK response is received, Unified Communications Managed API version 1.0 calls the SetAnswer method on the local-side implementation of the IOfferAnswer interface to process the accompanying answer.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.