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

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.

peers-0.4.3 various improvements

A new version of peers is available on sourceforge. This version includes an important fix on CANCEL which was not accepted by Asterisk.

This version also includes an important improvement about media quality and delay. This version also supports INVITEs and reINVITEs with empty body. This feature makes peers compatible with simple server applications like click2call from Mobicents Media Server.

peers-0.4.1 is out, bug fixes

This version integrates a few patches from tuijldert and a new feature: Authentication on BYE request (aka Challenge).

This version has been tested on Windows 7, windows xp and Debian GNU/Linux Squeeze.

This new release has also been tested with Avaya proxy/registrar.

Documentation updated for peers-0.4

Peers documentation has been updated to reflect latest release. As usual, you can read peers latest documentation here.

This new version of the documentation contains information about new RTP stack, new GUI package, media implementation, new way to communicate between sip core layer and GUI, and much more. Feedback is always appreciated.

Enjoy and stay tuned!

peers-0.4 release, small is beautiful

A new release of peers is available, the smallest complete java sip softphone.
New codecs, new GUI, no external dependency, more interoperability tests. Try it now!

The latest thing that lacks in this release for a full internet compatible sip softphone is ICE (Internet Connectivity Establishment) to pass all NATs. Nevertheless, if you’re using a media gateway or an internet provider sip account, you should not have any issue.

Blackberry compatibility and others

From time to time, I receive questions about how to port peers to non-standard java environments (android, blackberry, etc.).

As I receive this question quite often, I post this article here, it may help people willing to use non-J2SE virtual machines.

Peers uses generics, which came with java 5. It means that you have to rewrite all classes using generics if you want to run peers on a java 1.4 JVM.
In peers source code, annotations are not extensively used. You will only find basic @Override. You will find more complicated annotations in test/ folder, but as its name implies those annotations are just used for tests. Those annotations correspond to testng annotations. Testng is the test framework employed in peers.

As you can see, if you want to port peers to a standard java 1.4 environement, it may be long, but not complicated.

It may be more complicated when you want to port peers to an environment where all J2SE packages are not available.

In this case, you have to find the differences between the java APIs provided by your environment and J2SE.

Generally, the critical point to write a voip application for a mobile phone is microphone access. In mobile environments, there may be manufacturer-specific java APIs or java wrappers for custom native APIs.

There are at most three APIs for mobile phones that differ from standard PC JRE:
- GUI
- sound playback/sound capture,
- network.

Peers uses standard DatagramSocket and DatagramPackets for networking. As GUI is the first thing that is demonstrated on mobile phones when new software development kits are released, comprehensive tutorials are generally provided. Peers uses swing for GUI, and swing is generally not provided in exotic environments, so you have to consider it seriously. As already said, the most complicated will probably be on microphone access, as mobile phone providers often restrict access to microphone in development environments. But as always, it’s worth a try!

Italian book about peers

The first book about peers has been published: VoIP & JAVA PARTENDO DA ZERO:

VoIP & JAVA PARTENDO DA ZERO, volume 1 VoIP & JAVA PARTENDO DA ZERO, volume 2

This is an italian book in two volumes. The first volume (google translation) gives general considerations about voip and java implementation of voip applications. And the second volume (google translation) presents several java sip stacks, including peers. The publishing house of this book is EdizioniFutora and the two authors of this book are Antonio Agliata and Luisa Romano.

Many thanks to them for talking about peers.

Antonio and his team will make a presentation of their new book in Napoli, Italy on 14 july 2010. Attendees can register to this presentation here. Let’s cheer them, Italy is a nice country to visit and july is vacation period…

Android compatibility

Peers is not android-compatible for the moment. A few steps would be necessary to make peers android-compatible. Actually, here are the packages not provided by android (or imcomplete) and necessary for peers:

  • java.awt
  • javax.swing
  • javax.sound

Thus, GUI should be ported to android using Activity or something similar, and sound management should also be ported using MediaRecorder and MediaPlayer.

Configuration should also probably be updated to use XMLReader and drop dom4j dependency.

It seems that jrtp is directly compatible with android APIs except package gov.nist.jrtp.test.send_recv, but this package is not necessary. Thus, using jrtp and peers, you have the following stacks ready for android:

  • SIP
  • SDP
  • RTP

But no native API is available for GUI and sound management.

Peers documentation online!

You have been asking for more documentation for long… and now it’s there! Patience pays, Peers documentation contains two parts: one for all SIP softphones and one for Peers source code. It’s important to read both. The first part gives an overview and a technical background to cope with Peers source code. The second part first gives architecture overview, then many UML diagrams are provided to understand quickly Peers source code, and to illustrate Peers implementation.

Enjoy, and please give feedback by e-mail: yohann.martineau at gmail dot com.