From: Aviv Shaham <firstname.lastname@example.org>
Date: Fri, 07 Nov 2014 09:18:23 -0700
Nexmo doesn't seem to handle it well if your first specified codec is L16. Try to set
absolute_codec_string to PCMU and see if that helps.
Also note that there is no need to include custom SIP headers such as api_key, api_secret, and answer_url when you make an outbound call.
Since you mentioned also needing inbound - keep in mind that when you use Nexmo's built-in "Forward to SIP" setting for each number in the dashboard, the dialed number will not be passed as a SIP variable and you have no way of knowing it once you receive the SIP invite. One way to get around this is to have your application buy & update numbers via the Nexmo API and set a custom SIP address per Nexmo DID, for example:
email@example.com and then have a dialplan such as:
<condition field="destination_number" expression="^nexmo_(\d+)$">
<action application="set" data="nexmo_forwarded_for=$1"/>
<action application="lua" data="nexmo_handler.lua"/>
nexmo_forwarded_for session variable will now expose to you the dialed Nexmo phone number allowing your application or XML dialplan to use it.