Hi, I think you should modify the SDP after SDP negotiated in the pjsip_inv_answer(), since the SDP negotiator may rearrange the SDP answer regarding RFC 3264 Section 6: For each "m=" line in the offer, there MUST be a corresponding "m=" line in the answer. The answer MUST contain exactly the same number of "m=" lines as the offer. For example, you can modify the SDP in pjsip_inv_callback.on_media_update (call_on_media_update() in simpleua.c). Please notice about corresponding 'm=' line, so instead of resetting media_count to zero and reassign it, I guess it is better to iterate the media in the local_sdp to find the m=application line and modify it there, except you are sure there will be only one media. Regards, nanang On Mon, Nov 17, 2008 at 10:02 PM, pierrick grasland <pierrick.grasland at nexcom.fr> wrote: > Hello all, > > I'm currently working with pjsip, in order to exchange information with > m=application SDP header. > > Actually, what I need is to do the following : > > receive SDP offer with : > > m=application \r\n a=crypto:values (easily done with pjsua.) > > Generate a new sdp media, with updated value (media2): > > something like that : m=application \r\n a=crypto:updated_values (done) > > I add this new media in my current sdp, and try to respond to my INVITE (I'm > starting from simpleua.c,). > > status = pjmedia_endpt_create_sdp( g_med_endpt, rdata->tp_info.pool, 1, > &g_med_tpinfo.sock_info, > &local_sdp); > PJ_ASSERT_RETURN(status == PJ_SUCCESS, PJ_TRUE); > /* removing all sdp value */ > local_sdp->media_count = 0; > /* updating local_sdp */ > local_sdp->media_count ++; /* increment media count */ > local_sdp->media[local_sdp->media_count - 1] = media2; /* store media in > sdp's array of media */ > > > I'm only interested in exchanging media2, so all other medias has been > deleted. > Then, I'm using simple_ua to send my 200 OK : > > /* > * Create invite session, and pass the UAS dialog > */ > status = pjsip_inv_create_uas( dlg, rdata, local_sdp, 0, &g_inv); > PJ_ASSERT_RETURN(status == PJ_SUCCESS, PJ_TRUE); > > /* > * Now create 180 response. > */ > status = pjsip_inv_initial_answer(g_inv, rdata, > 180, > NULL, NULL, &tdata); > PJ_ASSERT_RETURN(status == PJ_SUCCESS, PJ_TRUE); > > /* Send the 180 response. */ > status = pjsip_inv_send_msg(g_inv, tdata); > PJ_ASSERT_RETURN(status == PJ_SUCCESS, PJ_TRUE); > > /* > * Now create 200 response. > */ > status = pjsip_inv_answer( g_inv, > 200, NULL, /* st_code and st_text */ > NULL, /* SDP specified now, in order to solve > local/remote confusion */ > &tdata); > PJ_ASSERT_RETURN(status == PJ_SUCCESS, PJ_TRUE); > > /* > * Send the 200 response. > */ > status = pjsip_inv_send_msg(g_inv, tdata); > PJ_ASSERT_RETURN(status == PJ_SUCCESS, PJ_TRUE); > > > return PJ_TRUE; > > But, now, I have a problem : > > the body of my 200 OK contain the following media : > > m=application \r\n a=crypto:values > > instead of m=application \r\n a=crypto:updated_values > > After several search in PJLIB documentation, I found pj_bool_t > prefer_remote_codec_order; > Initialized at true, it first seem to be the origin of my problem. But after > some trials, it doesn't have any effect on my response. > > I don't want to modify PJLIB, for future upgrade. Can someone help me, and > show me some documentation on how to create our sdp ? > > Thanks for your help. > -- > Pierrick Grasland > > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip at lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > >