= PJSIP Tutorial (Using PJSUA-API) = As you can see from the diagram in [http://www.pjsip.org/docs.htm PJSIP Documentation] page, PJSIP software consists of multiple API abstractions. This tutorial uses [http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB.htm 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 '''[http://www.pjsip.org/pjsip/docs/html/page_pjsip_sample_simple_pjsuaua_c.htm simple_pjsua.c]''' for complete source code. == Extending the Example == The best source information on using the API is of course [http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB.htm PJSUA-API Reference Manual]. But here are some information about configuring some features. === Supporting STUN === Just configure {{{stun_config}}} member of [http://www.pjsip.org/pjsip/docs/html/structpjsua__transport__config.htm pjsua_transport_config] when creating the UDP transport. === TCP and TLS Transports === Just call [http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB__TRANSPORT.htm#g1c077d205f7df9fae39a179b2fe47533 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 [http://www.pjsip.org/pjsip/docs/html/structpjsua__transport__config.htm pjsua_transport_config]. === Supporting SIP SRV Resolution === To enable SIP SRV resolution, configure the {{{nameserver}}} and {{{nameserver_count}}} in [http://www.pjsip.org/pjsip/docs/html/structpjsua__config.htm pjsua_config]. === Call Conferencing === Use [http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB__MEDIA.htm#g3451304d677e013130dfb9e6b37e3ee6 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 [http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB__ACC.htm#g18ff1b0e9d62682b6d64a321eb0106d8 pjsua_acc_add()].