Use pjsip_uri_get_uri here - it handles the case where the name_addr field holds just a URI and also the case where it is "display_name <URI>".