The new negotiator is more promising and nearly finished. You can already use and test it, but be aware that this is still work in progress and even the API has not yet been fixed.
Advanced applications may find it inappropriate, but as you can modify the SDP answer after running the negotiation, I see no reason why you should not use it. It will just simplify the amount of code you'll need to negotiate medias.
If by using the new negotiator, you find some nice ideas to improve it, I'll be glad to think about implementing them. Trying to build a generic SDP negotiatior gave me headache... I hope the new one will be suitable for all needs.
struct osip_rfc3264 *cnf; int i;
i = osip_rfc3264_init(&cnf); if (i!=0) { fprintf(stderr, "Cannot Initialize Negotiator feature.\n"); return -1; }
sdp_media_t *med; sdp_attribute_t *attr; i = sdp_media_init(&med); med->m_proto = osip_strdup("RTP/AVP"); med->m_media = osip_strdup("audio"); osip_list_add(med->m_payloads, osip_strdup("18"), -1);
i = sdp_attribute_init (&attr); attr->a_att_field = osip_strdup("rtpmap"); attr->a_att_value = osip_strdup("G729/8000"); osip_list_add (med->a_attributes, attr, -1);
osip_rfc3264_add_audio_media(cnf, med, -1);
The test program is located in the source files of libosip2 in src/test/torture_rfc3262.c. You'll find a complete negotiation process to build an answer to an offer.
When the negotiation is finished for all media lines, you still MUST modify some elements missing in the SDP message. Especially, you must replace the IP addresses and port numbers to reflect your configuration.
Note that at the end of the negotiation process, you can still modify the SDP message to make it closer to your own media capabilities. For example, you can add attributes such as "ptime" options for audio and video payloads.