SIP Servlet Engine© Documentations
 
  Top >   System Management >   Development Tools >   RecorderServlet
 
 

RecorderServlet

Overview

The SIP servlet that records a voice mail.

RecorderServlet is an SIP servlet that uses JMF (Java Media Framework) to record voice information from an SIP terminal to a hard disk on the server. RecorderServlet does not provide the function that replays its recorded voice data, but it saves the data in the AVI format. Therefore, you can replay the data easily using your media player (such as Windows Media Player) on your PC.

RecorderServlet provides the following two methods for recording. RecorderServlet works as UAS in the first method, and it works as UAC in the second method.

  1. The method that RecorderServlet receives a INVITE method.
  2. The method that RecorderServlet sends a request using SipRequestDispatcher.

In both methods, RecorderServlet replays the sound source data specified in the initialization parameters after a real-time session is established, and then starts to record. The recording process will continue until a BYE is received from the terminal or the maximum recording time is reached.

Initialization Parameters

The following table lists the initialization parameters you can set in RecorderServlet.

Parameter name Default value Description
store-directory None Specifies the directory that stores the sound source files and recorded file. This parameter should be specified as a context parameter.
Example: /tmp/sip-demo
use-contact false The flag that specifies whether location information should be set in the request URI when RecorderServlet sends a SIP request. Set to false if you want SIP Servlet Engine to work with an exchange server (such as CenterStage-NS).
max-duration 20 Specifies the maximum recording time in seconds.
recorder-uri None Specifies the SIP URI used in the From header when RecorderServlet sends a SIP request. This is required.
welcome-file /WEB-INF/welcome.wav Specifies the sound source data for guidance that is replayed just after a real-time session is established. If not specified, the guidance will not be replayed.
beep-file /WEB-INF/beep.wav Specifies the sound source data for start signal that is replayed after a real-time session is established. This sound source data is replayed just after the welcome-file is replayed.
dataSource None Specifies the data source for the database that stores the recorded voice mail information. This is required.
db.server None Specifies one of the following database products: Oracle, PostgreSQL, or MySQL. This is required.
db.version None Specifies the version number of the database product specified in the db.server parameter. This is required.

You can create sound source files that can be set in welcome-file and beep-file using the sound recorder shipped with Windows, etc. The format of these sound source files should be CCITT u-Law 8.000 kHz, 8 bit, monaural. A sound source file whose format is not that can not be replayed successfully.

External Interfaces

RecorderServlet uses the following SPI:

  • User Management Interface
  • Location Management Interface

RecorderServlet stores information about the received voice mail as application-specific information in a database. For information about the database schema, see this page.

RecorderServlet determines the directory that stores the recorded file and sound source files for guidance by looking up in the following order:

  1. If the store-directory context parameter is specified, the voicebox directory under that directory.
  2. If the ServletContext.getRealPath("/") returns a not-null value, the voicebox directory under that directory.
  3. If the javax.servlet.context.tempdir attribute on the ServletContext is specified, the voicebox directory under that directory.
  4. The voicebox directory under the directory specified in the system property java.io.tmpdir.

If the store-directory context parameter is not specified in WebLogic Server, the default is 3. in the above directories.

When RecorderServlet starts to record by sending a request, invoke an SipRequestDispatcher with the makeCall method. You can set the following parameters in SipRequestParams.

Parameter name Class Description
voiceMail.sender com.oki.sip.equips.signal.CallingEntity The sender information of the voice mail.
voiceMail.receiver com.oki.sip.equips.signal.CallingEntity The receiver information of the voice mail.

Here is a code example.

SipRequestParams params = new SipRequestParams();
params.setParam("voiceMail.sender", sender);
params.setParama("voiceMail.receiver", receiver);

SipRequestDispatcher.getInstance(this, context, "recorder").invoke("makeCall", params);

Related Files

The RecorderServlet setting should be defined in the sip.xml.

The database used by RecorderServlet should be created in advance.

The data source used by RecorderServlet should be set on your application server in advance.

Example

Here is an example of the sip.xml.

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE sip-app
   PUBLIC "-//Java Community Process//DTD SIP Application 1.0//EN"
   "http://www.jcp.org/dtd/sip-app_1_0.dtd">

<sip-app>
  <display-name>Voice Recorder Servlet</display-name>

  <context-param>
    <param-name>store-directory</param-name>
    <param-value>/tmp/sip-demo</param-value>
  </context-param>

  <servlet>
    <servlet-name>recorder</servlet-name>
    <servlet-class>com.oki.sip.apps.recorder.RecorderServlet</servlet-class>

    <init-param>
      <param-name>use-contact</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>max-duration</param-name>
      <param-value>20</param-value>
    </init-param>
    <init-param>
      <param-name>recorder-uri</param-name>
      <param-value>sip:recorder@oki.com</param-value>
    </init-param>
    <init-param>
      <param-name>welcome-file</param-name>
      <param-value>/WEB-INF/welcome.wav</param-value>
    </init-param>
    <init-param>
      <param-name>beep-file</param-name>
      <param-value>/WEB-INF/beep.wav</param-value>
    </init-param>
    <init-param>
      <param-name>dataSource</param-name>
      <param-value>applicationServer.dataSource</param-value>
    </init-param>
    <init-param>
      <param-name>db.server</param-name>
      <param-value>Oracle</param-value>
    </init-param>
    <init-param>
      <param-name>db.version</param-name>
      <param-value>Release 9.2.0</param-value>
    </init-param>

    <load-on-startup/>
  </servlet>

  <servlet-mapping>
    <servlet-name>recorder</servlet-name>
    <pattern>
      <and>
        <equal>
          <var>request.method</var>
          <value>INVITE</value>
        </equal>
        <equal>
          <var>request.uri.user</var>
          <value>recorder</value>
        </equal>
      </and>
    </pattern>
  </servlet-mapping>

  <session-config>
    <session-timeout>15</session-timeout>
  </session-config>
</sip-app>

Reference

Last Modified:Modified:Tue Dec 28 14:13:49 JST 2004