diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-08-09 13:53:59 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-08-09 13:53:59 +0000 |
commit | e8b11d39cd89a716e3580db2b0dc4fca2412cd22 (patch) | |
tree | 7dc79e5d0b0049904dcd5d954376c6e8fe8d431d /pjsip-apps/src/samples/simpleua.c | |
parent | 5b11a53fd76ef35ac96bf86ed973f53dc342f52c (diff) |
Fixed run-time bug with simple_ua and pjsip-perf sample.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@668 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps/src/samples/simpleua.c')
-rw-r--r-- | pjsip-apps/src/samples/simpleua.c | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/pjsip-apps/src/samples/simpleua.c b/pjsip-apps/src/samples/simpleua.c index 1f682a6d..d7b65086 100644 --- a/pjsip-apps/src/samples/simpleua.c +++ b/pjsip-apps/src/samples/simpleua.c @@ -256,39 +256,33 @@ int main(int argc, char *argv[]) status = pjmedia_codec_g711_init(g_med_endpt); PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); + /* - * Initialize RTP socket info for the media. - * The RTP socket is hard-codec to port 4000. + * Create media transport used to send/receive RTP/RTCP socket. + * One media transport is needed for each call. Application may + * opt to re-use the same media transport for subsequent calls. */ - status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &g_med_skinfo.rtp_sock); - PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1); - - pj_sockaddr_in_init( &g_med_skinfo.rtp_addr_name, - pjsip_endpt_name(g_endpt), 4000); - - status = pj_sock_bind(g_med_skinfo.rtp_sock, &g_med_skinfo.rtp_addr_name, - sizeof(pj_sockaddr_in)); + status = pjmedia_transport_udp_create(g_med_endpt, NULL, 4000, 0, + &g_med_transport); if (status != PJ_SUCCESS) { - app_perror( THIS_FILE, - "Unable to bind RTP socket", - status); + app_perror(THIS_FILE, "Unable to create media transport", status); return 1; } + /* + * Get socket info (address, port) of the media transport. We will + * need this info to create SDP (i.e. the address and port info in + * the SDP). + */ + { + pjmedia_transport_udp_info udp_info; - /* For simplicity, ignore RTCP socket. */ - g_med_skinfo.rtcp_sock = PJ_INVALID_SOCKET; - g_med_skinfo.rtcp_addr_name = g_med_skinfo.rtp_addr_name; - - - /* Create media transport */ - status = pjmedia_transport_udp_attach(g_med_endpt, NULL, &g_med_skinfo, - 0, &g_med_transport); - if (status != PJ_SUCCESS) { - app_perror(THIS_FILE, "Unable to create media transport", status); - return 1; + pjmedia_transport_udp_get_info(g_med_transport, &udp_info); + pj_memcpy(&g_med_skinfo, &udp_info.skinfo, + sizeof(pjmedia_sock_info)); } + /* * If URL is specified, then make call immediately. */ |