[Nice] New SDP parsing API

Rohan Garg rohan16garg at gmail.com
Mon Feb 4 21:58:00 PST 2013


Any particular reason why this :
http://cgit.collabora.com/git/user/kakaroto/libnice.git/commit/?id=80334dc8419f5694485304d5b2f83849ce296195
cannot be refactored as :

nice_agent_get_selected_pair (NiceAgent *agent, guint stream_id,
    guint component_id, NiceCandidate **local, NiceCandidate **remote)
{
  Component *component;
  Stream *stream;
  gboolean ret = FALSE;

  agent_lock();

  /* step: check that params specify an existing pair */
  if (agent_find_component (agent, stream_id, component_id,
          &stream, &component)) {
    if (component->selected_pair.local && component->selected_pair.remote) {
      *local = component->selected_pair.local;
      *remote = component->selected_pair.remote;
      ret = TRUE;
    }
  }

  agent_unlock();

  return ret;
}

I notice that you use goto quite liberally elsewhere, but isn't usage
of goto generally frowned upon? ( I haven't looked the rest of the
code thoroughly enough to say if it can be converted to not use goto
).


On Tue, Feb 5, 2013 at 10:09 AM, Youness Alaoui
<youness.alaoui at collabora.co.uk> wrote:
> 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 :
> http://cgit.collabora.com/git/user/kakaroto/libnice.git/log/
> And I've compiled an updated version of the documentation and uploaded it here :
> http://people.collabora.com/~kakaroto/libnice-docs/
> 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 24.37.55.154
> a=rtcp:58126
> a=ice-ufrag:uAlM
> a=ice-pwd:bL+6urz5IKg5tMlMusHdB6
> a=candidate:1 1 UDP 2013266431 192.168.1.101 56095 typ host
> a=candidate:2 1 UDP 1677721855 24.37.x.y 56095 typ srflx raddr 192.168.1.101
> rport 56095
> a=candidate:1 2 UDP 2013266430 192.168.1.101 58126 typ host
> a=candidate:2 2 UDP 1677721854 24.37.x.y 58126 typ srflx raddr 192.168.1.101
> rport 58126
> m=video 50836 RTP/AVP
> c=IN IP4 24.37.55.154
> a=rtcp:60317
> a=ice-ufrag:hijo
> a=ice-pwd:OXuxMqY3gnIRsguf50NLxC
> a=candidate:3 1 UDP 2013266431 192.168.1.101 50836 typ host
> a=candidate:4 1 UDP 1677721855 24.37.x.y 50836 typ srflx raddr 192.168.1.101
> rport 50836
> a=candidate:3 2 UDP 2013266430 192.168.1.101 60317 typ host
> a=candidate:4 2 UDP 1677721854 24.37.x.y 60317 typ srflx raddr 192.168.1.101
> rport 60317
>
>
> Let me know if you have any comments!
>
> Thank you,
> Youness.
>
>
> _______________________________________________
> nice mailing list
> nice at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/nice
>


More information about the nice mailing list