Peers evolutions

Most developers come to peers for its portability (100% java), its extensibility and its documentation.

Several important evolutions occurred in peers.

Peers is moving to maven. The project has split in several maven modules:

  • peers-doc: documentation converted to docbook
  • peers-lib: sip, sdp, rtp and media related code
  • peers-gui: swing graphical user interface
  • peers-jws: java web start application to start peers

Documentation is now integrated in source tree and converted to docbook standard. Documentation is not yet up-to-date in source tree, but it’s now generated dynamically.

Hackers

Here are the steps to tweak peers source code using eclipse:

svn co https://peers.svn.sourceforge.net/svnroot/peers/trunk peers
cd peers
mvn install
mvn eclipse:eclipse

In eclipse, add a new java build path classpath variable:

Window > Preferences > Java > Build Path > Classpath Variable, click on New:

  • Name: M2_REPO
  • Path: /home/yohann/.m2/repository

Then, you have to import eclipse projects generated by mvn eclipse:eclipse in eclipse: File > Import… > Existing Projects into Workspace > Browse, select the root peers folder and click Finish.

Architects

To generate documentation, use:

mvn pre-site

A pdf is generated in peers/peers-doc/target/docbkx/pdf and the html version is in peers/peers-doc/target/docbkx/html/peers.html.

Developers

To create a hello world project based on peers, first install peers in your local repo, create project and provide peers dependency:

~/peers$ mvn install
~/peers$ cd ..
~$ mvn archetype:create -DgroupId=test -DartifactId=demo -Dversion=0.1-SNAPSHOT

Then edit your new pom.xml file and add the following dependency:

    <dependency>
      <groupId>net.sourceforge.peers</groupId>
      <artifactId>peers-lib</artifactId>
      <version>0.5-SNAPSHOT</version>
      <scope>compile</scope>
    </dependency>

Copy logs, media and conf folders from peers root directory to your demo project:

cp -r peers/conf/ peers/media/ peers/logs/ demo/

Edit your peers.xml file in conf/ folder. You have to provide at least <userpart> and and <domain>:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<peers xmlns="http://peers.sourceforge.net"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://peers.sourceforge.net peers.xsd">
  <network>
    <interfaces>
      <interface id="eth1">
        <name>Ethernet network interface</name>
        <address/>
      </interface>
    </interfaces>
  </network>
  <devices>
    <audio/>
    <video/>
  </devices>
  <sip>
    <profile>
      <userpart>hello</userpart>
      <domain>world</domain>
      <password></password>
      <outboundProxy/>
      <interface ref="eth1"/>
      <port>0</port>
    </profile>
  </sip>
  <codecs>
    <codec>
      <family>audio</family>
      <name>PCMU</name>
      <payloadType>0</payloadType>
    </codec>
    <mediaMode>captureAndPlayback</mediaMode>
    <mediaDebug>false</mediaDebug>
  </codecs>
  <rtp>
    <interface ref="eth1"/>
    <port>8000</port>
  </rtp>
</peers>

Generate your eclipse project using mvn eclipse:eclipse and import it in eclipse.

Edit your main App class:

package test;

import java.net.SocketException;

import net.sourceforge.peers.sip.core.useragent.SipListener;
import net.sourceforge.peers.sip.core.useragent.UserAgent;
import net.sourceforge.peers.sip.syntaxencoding.SipUriSyntaxException;
import net.sourceforge.peers.sip.transport.SipRequest;
import net.sourceforge.peers.sip.transport.SipResponse;

public class App implements SipListener
{
    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
        new App();
    }

    public App() {
        try {
            UserAgent userAgent = new UserAgent(this, null, null);
            // start a new call
            userAgent.getUac().invite("sip:localhost", null);
        } catch (SocketException e) {
            e.printStackTrace();
        } catch (SipUriSyntaxException e) {
            e.printStackTrace();
        }
    }

    @Override public void registering(SipRequest sipRequest) { }
    @Override public void registerSuccessful(SipResponse sipResponse) { }
    @Override public void registerFailed(SipResponse sipResponse) { }
    @Override public void incomingCall(SipRequest sipRequest, SipResponse provResponse) { }
    @Override public void remoteHangup(SipRequest sipRequest) { }
    @Override public void ringing(SipResponse sipResponse) { }
    @Override public void calleePickup(SipResponse sipResponse) { }
    @Override public void error(SipResponse sipResponse) { }
}

Start a wireshark capture or even better launch a sipp uas script with echo option to play the role of the callee:

sipp -sn uas -rtp_echo

Launch your application in eclipse: right-click App > Run As > Java Application. You should get a exception. Provide a program argument to specify peers home (to locate configuration file): Run > Run Configurations… Select App, select Arguments tab, add .. in Program arguments. You should now be able to launch your application with no exception.

If you talk in your microphone, you should now hear your echo, thanks to sipp who is automatically picking-up the call and sending back media traffic to its origin.

For your convenience, you can find this demo project demo.

This entry was posted in Uncategorized by yohann. Bookmark the permalink.

10 thoughts on “Peers evolutions

  1. the line

    UserAgent userAgent = new UserAgent(this, null, null);

    gives a Constructor is ambugious error.
    When I replace it with

    UserAgent userAgent = new UserAgent(this, “.”, null);

    (without the program argument since it’s not needed then) then
    the program will start.

    However sipp gives an error:
    “Last Error: non SIP message discarded.”

    Also there is no sound.

    Any ideas? Is my profile ok?
    Thanks

    demo
    nist.gov
    demo
    sip:192.168.2.8:5060

    5062

    • Seems, the site deleted my xml tags. Any way the data that’s left is (in order) from the profile element of the conf/peers.xml.

    • Still no sound. I discovered that the app is calling to localhost while sipp runs on my server. Changing that I see App calling out and sipp picking up.
      However, still no sound.

      The log displays a problem with rtp sockets. I didn’t change the default port 8000 in the App and didn tweak sipp:
      [code]
      2012-05-03 03:31:19,340 ERROR [Thread-9] cannot send rtp packet
      java.net.BindException: Cannot assign requested address: Datagram send failed
      at java.net.DualStackPlainDatagramSocketImpl.socketSend(Native Method)
      at java.net.DualStackPlainDatagramSocketImpl.send(DualStackPlainDatagramSocketImpl.java:117)
      at java.net.DatagramSocket.send(DatagramSocket.java:675)
      at net.sourceforge.peers.rtp.RtpSession.send(RtpSession.java:116)[/code]

      Any ideas?

  2. Thanks. Great work. Any idea how to add video conferencing to the application?????? I mean how to detect webcam and video call etc….

    • hi,
      if you want to add video conferencing, you have to use native interfaces to retrieve webcam and display video. Maybe you can use xuggle to play with video, but i don’t know if it can capture webcam.
      good luck,
      yohann

  3. Hi,
    I found this project really intersting and starting to use it. Please advice me how can I accept the call?
    I know the method on “userAgent.getUas().acceptCall” But any idea How I used it?

  4. Hello Yohann, your project seems to be a good job !

    I am trying to execute your demo project but I have problem during the launch. I am launching sipp -sn uas -rtp_echo -trace_err also in a view to try the “echo” as you said.
    Here is the stack trace of the demo program :
    Exception in thread “main” java.lang.NullPointerException
    at net.sourceforge.peers.sip.transaction.InviteClientTransaction.start(InviteClientTransaction.java:129)
    at net.sourceforge.peers.sip.core.useragent.InitialRequestManager.createInitialRequestEnd(InitialRequestManager.java:198)
    at net.sourceforge.peers.sip.core.useragent.InitialRequestManager.createInitialRequest(InitialRequestManager.java:179)
    at net.sourceforge.peers.sip.core.useragent.InitialRequestManager.createInitialRequest(InitialRequestManager.java:152)
    at net.sourceforge.peers.sip.core.useragent.UAC.invite(UAC.java:131)
    at application.App.(App.java:21)
    at application.App.main(App.java:15)

    The config file is well existing on conf/peers.xml and I tried launching the program with the “..” argument.

    Thanks in advance

    Guillaume

    • Hello Yohann,

      It seems that the error was due to the 0 option : if 0 is specified, the port is not chosen randomly but the port number 0 is choose.

      here are the logs :
      2012-07-02 01:19:33,045 INFO [main] starting user agent [myAddress: 192.168.2.6, sipPort: 0, userpart: hello, domain: localhost]
      2012-07-02 01:19:33,135 INFO [main] added datagram socket 192.168.2.6:0/UDP
      2012-07-02 01:19:33,138 INFO [main] added 192.168.2.6:0/UDP: net.sourceforge.peers.sip.transport.UdpMessageReceiver@5dd582 to message receivers
      2012-07-02 01:19:33,801 ERROR [main] input/output error
      java.net.BindException: Adresse déjà utilisée
      at java.net.PlainDatagramSocketImpl.bind0(Native Method)
      at java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:82)
      at java.net.DatagramSocket.bind(DatagramSocket.java:368)
      at java.net.DatagramSocket.(DatagramSocket.java:210)
      at java.net.DatagramSocket.(DatagramSocket.java:261)

      Then I specified the 8080 port and the exception doesn’t happen anymore.
      Keep looking on your interesting project :)

      Thanks !

      Guillaume