From: Steve K. <st...@st...> - 2004-10-18 23:16:24
|
So, this appears to be the way negotiation works: 1) The caller sends both format and capabilities when it makes a new call. 2) The remote side chooses a format, based on it's own capabilities, preferences, and the caller's capabilities and preferences. 3) The remote side ACCEPTs the call, and sends back the format to use. So, this is what I implemented in iaxclient and libiax2. In step2, asterisk seems to do this: 1) Use the caller's preferred format, if it supports it, 2) Choose amongst all capabilities, using a hard-coded order of preference. In step2, in iaxclient, I implemented it as: 1) Use the caller's preferred format, if we support it, 2) Use _our_ preferred format, if they support it, 3) finally, look at the union of capabilities, and (the same) hard-coded order. Attached is a patch which implements this. There's a few changes: iaxclient API: Rename codec selection API, and add "preffered" vs allowed selection. In using this, preferred should be _one_ codec, allowed should be as many as you want. NOTE: you can set allowed to whatever you want, but things won't work so well if you allow something that iaxclient doesn't support internally -- but it doesn't check what you pass it. -void iaxc_set_encode_format(int fmt); +void iaxc_set_formats(int preferred, int allowed); libiax2 API: Add params to iax_call to set format and capability. Add param to iax_accept to tell it what format we want. -extern int iax_call(struct iax_session *session, char *cidnum, char *cidname, char *ich, char *lang, int wait); -extern int iax_accept(struct iax_session *session); +extern int iax_call(struct iax_session *session, char *cidnum, char *cidname, char *ich, char *lang, int wait, int format, int capability); +extern int iax_accept(struct iax_session *session, int format); Let me know what you think.. I've only tested this on one outgoing calls, so a review and testing is in order.. A known issue is that I think we try to send audio right after we send NEW, even before the other side ACCEPTs. at this point, our call format is set to zero, and we get some errors printed about not being able to use format 0, etc.. -SteveK |