wiki:PJSIP_Tutorial

PJSIP Tutorial (Using PJSUA-API)

As you can see from the diagram in PJSIP Documentation page, PJSIP software consists of multiple API abstractions. This tutorial uses PJSUA-API, the highest layer of abstraction of all, which combines PJSIP (the SIP stack library) and PJMEDIA (the media stack library).

A Simple SIP User Agent

Is it possible to create a simple but rather complete SIP user agent, with registration, digest authentication, SDP negotiation, and fully featured media in under than 100 lines of code? Bear in mind that SIP is quite a complex protocol, and so is managing media is quite complicated.

Well, turns out it's not quite possible (at least if we want to have a rather responsible and readable code).

Source Code

Have a look at the simple_pjsua.c for complete source code.

Extending the Example

The best source information on using the API is of course PJSUA-API Reference Manual. But here are some information about configuring some features.

Supporting STUN

Just configure stun_config member of pjsua_transport_config when creating the UDP transport.

TCP and TLS Transports

Just call pjsua_transport_create() with PJSIP_TRANSPORT_UDP or PJSIP_TRANSPORT_TLS as the transport type. In addition, optional TLS settings can be configured in tls_setting member of pjsua_transport_config.

Supporting SIP SRV Resolution

To enable SIP SRV resolution, configure the nameserver and nameserver_count in pjsua_config.

Call Conferencing

Use pjsua_conf_connect() to connect any channels in the bridge (calls, files, sound device, etc.) When more than two media sources are transmitting to the same sink, the conference bridge will automatically mix the signal from all the sources.

Multiple Accounts

Just add another account with pjsua_acc_add().

Last modified 13 years ago Last modified on Jan 17, 2012 5:05:57 PM