[Nice] New SDP parsing API

Youness Alaoui youness.alaoui at collabora.co.uk
Mon Feb 4 20:39:18 PST 2013

Hi everyone,

I have just finished implementing a new API for libnice which will generate and
parse an SDP string containing the candidates and credentials.
I'd like to have everyone's opinion on what the API looks like, if they like it,
if there's anything to change, if the docs are unclear, etc...
I'd be happy to receive feedback from you guys before I finalize the API in the
next release.

To summarize the new API, you can now call :
   sdp_string = nice_agent_generate_local_sdp(agent);
which will generate a single string containing a listing of all your streams,
components, their credentials and candidates. You can then send that string as
is to a remote user, which would call :
   added = nice_agent_parse_remote_sdp(agent, sdp_string);
Which will then parse that string, and set the credentials and candidates on
every stream it finds, and returns to you how many candidates were successfully
parsed and added (if there is a parsing error, it will return -1).
The SDP can also be used in a SIP call, but of course, you'd need to add your
codec list to it and parse it to change the 'm' line to add the payload types to
it. Other than that, it's a valid SDP according to the ICE RFC.

The other change required is that you can now name your streams with the new API
call :
    nice_agent_set_stream_name (agent, stream_id, "name");
This is *required* if you plan on parsing the SDP, because otherwise, there is
no way to identify which stream from the SDP corresponds to which stream in the
NiceAgent. If a stream has no name set, then nice_agent_parse_remote_sdp() will
automatically fail. This does not affect anything else though.

You can check the changes here :
And I've compiled an updated version of the documentation and uploaded it here :
I have also added an sdp-example file that you can test with and see how the API
is being used. It will however base64 the SDP string, simply so it appears as a
single line, and makes it easier to copy/paste through a terminal... it also
looks cooler :p

Here is an example result of calling nice_agent_generate_local_sdp() with 2
streams of 2 components each, with streams named "audio" and "video" :

m=audio 56095 RTP/AVP
c=IN IP4
a=candidate:1 1 UDP 2013266431 56095 typ host
a=candidate:2 1 UDP 1677721855 24.37.x.y 56095 typ srflx raddr
rport 56095
a=candidate:1 2 UDP 2013266430 58126 typ host
a=candidate:2 2 UDP 1677721854 24.37.x.y 58126 typ srflx raddr
rport 58126
m=video 50836 RTP/AVP
c=IN IP4
a=candidate:3 1 UDP 2013266431 50836 typ host
a=candidate:4 1 UDP 1677721855 24.37.x.y 50836 typ srflx raddr
rport 50836
a=candidate:3 2 UDP 2013266430 60317 typ host
a=candidate:4 2 UDP 1677721854 24.37.x.y 60317 typ srflx raddr
rport 60317

Let me know if you have any comments!

Thank you,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/nice/attachments/20130204/0914365e/attachment-0001.pgp>

More information about the nice mailing list