Build Your Own UA App

  1. Create a WAR (or SIP application) with SIP Servlet and javax/javaee dependencies

Create a SIP Servlet Application

  1. Create a SIP Servlet application packaged as a WAR (or SIP application archive) and include the SIP Servlet API dependencies required by your project.
  2. Add mediagateway-api to your project dependencies (use provided scope so the server supplies the runtime library).
  3. Add sip.xml and, if needed, web.xml.
  4. If you do not want time-based session expiration, set session-timeout to 0.

Obtain the MediaGatewayServiceApi

  1. In your SIP servlet (or a service class), obtain MediaFactory and the API instance.
    MediaFactory factory = MediaFactory.getInstance();
    MediaGatewayServiceApi api = factory.createMediaGatewayServiceApi();
  2. Optional: Create a small application wrapper (for example, a MediaGatewayClient interface and implementation) so the rest of the application does not depend directly on MGS API types.

Map INVITEs to CreateMediaRequest

  1. When you receive an INVITE (or equivalent) that contains SDP, parse the SDP and metadata if present.
  2. For each media line you want the Media Gateway to handle:
    1. Extract the call ID, stream ID, media type, direction, source IP, source port, and codecs.
    2. Determine the egress destination IP address and port (for example, from configuration or from an AI service).
    3. Use the MediaFactory builders to construct the Identifiers, OfferedSDP, IngressMediaStream, and EgressMediaStream.
    4. Build the CreateMediaRequest with one ingress and one egress stream.

      You must set the call ID, stream ID, participant ID, session ID, and stream direction. This information is used to add metadata and headers for each egress UDP packet.

  3. Create the media session.
    MediaSessionUpsertResponse response = api.createMediaSession(createRequest);
  4. Check response.getSessionState() and response.getMediaSessionId();
  5. Use response.getMediaSessionDetails() to get negotiated SDP (receiver IP, port, and codecs) and build your 200 OK SDP.

Store media session id and link to SIP dialog

  1. Store mediaSessionId and any negotiated details in your application call state, keyed by Call-ID and stream/label.
  2. If you use a MediaSessionErrorListener, register a mapping from mediaSessionId to SipSession (or dialog ID). This enables your application to correlate Media Gateway errors to the correct SIP dialog and trigger cleanup (for example, send BYE and delete the media session) for errors.

A listener dependency example:

<dependency>
  <groupId>oracle.occas</groupId>
  <artifactId>wlssapi</artifactId>
  <version>8.3.0.0.0</version>
</dependency>

To register the listener:

<!-- WEB-INF/sip.xml -->
<listener>
  <javaee:listener-class>com.oracle.occas.app.listener.MediaSessionErrorListenerImpl</javaee:listener-class>
</listener>

Handle re-INVITEs

If the caller sends a re-INVITE with SDP changes, build a ModifyMediaRequest (e.g. updated offered SDP) and call api.modifyMediaSession(mediaSessionId, modifyRequest);. Use the response to update your state and build the 200 OK SDP.

Handle the BYE or CANEL

When the call ends, for each media session you created for that call, call:
MediaSessionActionRequest actionReq = factory.createMediaSessionActionRequestBuilder()
    .reason("BYE")
    .build();
api.deleteMediaSession(mediaSessionId, actionReq);
Or use a simple reason string. The reference uses a small adapter for MediaSessionActionRequest with a reason. Then clear your call state and send 200 OK (or 487 for CANCEL as appropriate).

Deactivate

Optionally, you can deactivate the call.
deactivateMediaSession(sessionId, actionRequest)

The actionRequest should carry the reason.

Deploy and Configure

Assuming you've set up and configured the , the Media Flow Engines, and the RTP Proxies as documented in the Intelligent Media Connector, the last step is to deploy your WAR or SIP application.