Commit d1f7e4d1 authored by yanmorin's avatar yanmorin

IAX Gui interface configuration

Patch for libosip2 3.0.
parent f3780c76
2006-12-07 Yan Morin
* First implementation of IAX account in QT Gui
* First implementation of sending sound (very unstable!) in iax
* Handling incompatibilities in libosip2 ABI (2.2.2 -> 3.0.1)
Quick patch that should be remove after 3.0.1 is very stable and in
distribution
2006-11-30 Yan Morin
* Fix .spec problem on fedora core 6
......
......@@ -3,6 +3,6 @@
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = libs src ringtones skins
EXTRA_DIST = m4/*.m4 tools/*.sh platform/* images/*
EXTRA_DIST = m4/*.m4 tools/*.sh platform/* images/* README.gentoo
......@@ -142,6 +142,12 @@ dnl AM_CONDITIONAL(USE_SAMPLERATE, test x$with_samplerate = xyes)
dnl Check for GNU ccRTP
PKG_PROG_PKG_CONFIG
LIBOSIP2_OSIPLISTNOPOINTER_MIN_VERSION=3.0.0
PKG_CHECK_MODULES([libosip2], [libosip2 >= ${LIBOSIP2_OSIPLISTNOPOINTER_MIN_VERSION}],
[LIBOSIP2_CFLAGS=""], [LIBOSIP2_CFLAGS="-DLIBOSIP2_WITHPOINTER"])
SIP_CFLAGS="$SIP_CFLAGS $LIBOSIP2_CFLAGS";
AC_SUBST(SIP_CFLAGS)
LIBSAMPLERATE_MIN_VERSION=0.1.1
PKG_CHECK_MODULES(samplerate, samplerate >= ${LIBSAMPLERATE_MIN_VERSION})
SFLPHONE_CFLAGS="$SFLPHONE_CFLAGS $samplerate_CFLAGS"
......
......@@ -33,7 +33,7 @@ sflphoned_SOURCES = eventthread.cpp main.cpp voIPLink.cpp \
sipvoiplink.cpp call.cpp sipcall.cpp \
$(IAXSOURCES)
sflphoned_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" $(ZEROCONFFLAGS) $(IAX_FLAGS) $(SFLPHONE_CFLAGS)
sflphoned_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" $(ZEROCONFFLAGS) $(IAX_FLAGS) $(SFLPHONE_CFLAGS) $(SIP_CFLAGS)
#sflphoned_LDFLAGS = -static
sflphoned_LDADD = ./libsflphone.la $(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) $(IAX_LIBS) $(EXOSIP_LIBS)
......
This diff is collapsed.
......@@ -56,6 +56,7 @@ void ConfigurationPanel::init()
_cutStringCombo = 30;
//DebugOutput::instance() << "ConfigurationPanel::init()\n";
lblError->hide();
lblIAXError->hide();
Tab_Signalisations->show();
Tab_Audio->hide();
Tab_Preferences->hide();
......@@ -126,11 +127,15 @@ ConfigurationPanel::generate()
ringsChoice->setCurrentText(ConfigurationManager::instance().get(AUDIO_SECTION, AUDIO_RINGTONE));
// For signalisations tab
// Account
QComboBox* cbo = 0;
int nbItem = 0;
// Load account
QComboBox* cbo = cboSIPAccount;
cbo = cboSIPAccount;
cbo->clear();
int nbItem = 4;
nbItem = 4;
for (int iItem = 0; iItem < nbItem; iItem++) {
QString accountId = "SIP" + QString::number(iItem);
QString aliasName = ConfigurationManager::instance().get(accountId, ACCOUNT_ALIAS);
......@@ -147,6 +152,28 @@ ConfigurationPanel::generate()
}
loadSIPAccount(0);
// Load IAX Account
cbo = cboIAXAccount;
cbo->clear();
nbItem = 1;
for (int iItem = 0; iItem < nbItem; iItem++) {
QString accountId = "IAX" + QString::number(iItem);
QString aliasName = ConfigurationManager::instance().get(accountId, ACCOUNT_ALIAS);
if (aliasName != "") {
QString accountName;
if (aliasName.isEmpty()) {
accountName = QObject::tr("IAX Account #%1").arg(iItem+1);
} else {
if (aliasName.length() > 30) {
aliasName = aliasName.left(30) + "...";
}
accountName = aliasName + " (" + QObject::tr("IAX Account #%1").arg(iItem+1) + ")";
}
cbo->insertItem(accountName,iItem);
}
}
loadIAXAccount(0);
sendDTMFas->setCurrentItem(ConfigurationManager::instance().get(SIGNALISATION_SECTION,
SIGNALISATION_SEND_DTMF_AS).toUInt());
playTones->setChecked(ConfigurationManager::instance().get(SIGNALISATION_SECTION,
......@@ -201,6 +228,7 @@ ConfigurationPanel::generate()
void ConfigurationPanel::saveSlot()
{
saveSIPAccount(cboSIPAccount->currentItem());
saveIAXAccount(cboIAXAccount->currentItem());
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_PULSE_LENGTH,
......@@ -396,23 +424,36 @@ ConfigurationPanel::SkinChoice_selected( const QString & )
}
void
ConfigurationPanel::slotRegister()
ConfigurationPanel::slotSIPRegister()
{
saveSIPAccount(cboSIPAccount->currentItem());
emit needRegister("SIP" + QString::number(cboSIPAccount->currentItem()));
}
void
ConfigurationPanel::slotIAXRegister()
{
saveIAXAccount(cboIAXAccount->currentItem());
emit needRegister("IAX" + QString::number(cboIAXAccount->currentItem()));
}
void
ConfigurationPanel::slotRegisterReturn( bool hasError, QString )
{
// here we check the current page...
if (hasError) {
lblError->setPaletteForegroundColor(red); // red
lblError->setText(QObject::tr("Register failed"));
lblIAXError->setPaletteForegroundColor(red); // red
lblIAXError->setText(QObject::tr("Register failed"));
} else {
lblError->setPaletteForegroundColor(black); // black
lblError->setText(QObject::tr("Register Succeed"));
lblIAXError->setPaletteForegroundColor(black); // black
lblIAXError->setText(QObject::tr("Register Succeed"));
}
lblError->show();
lblIAXError->show();
}
/**
......@@ -558,3 +599,64 @@ ConfigurationPanel::saveSIPAccount(int number)
SIGNALISATION_STUN_SERVER,
STUNserver->text());
}
void
ConfigurationPanel::slotIAXAccountChange(int index)
{
if (lastIAXAccount!=index) {
QString account = "IAX" + QString::number(index);
saveIAXAccount(lastIAXAccount);
loadIAXAccount(index);
lblIAXError->setText("");
}
}
void
ConfigurationPanel::loadIAXAccount(int number)
{
QString account = "IAX" + QString::number(number);
QString type = ConfigurationManager::instance().get(account, ACCOUNT_TYPE);
chkIAXAutoregister->setChecked(ConfigurationManager::instance()
.get(account,ACCOUNT_AUTO_REGISTER).toUInt());
chkIAXEnable->setChecked(ConfigurationManager::instance()
.get(account,ACCOUNT_ENABLE).toUInt());
QString aliasName = ConfigurationManager::instance().get(account, ACCOUNT_ALIAS);
IAXalias->setText(aliasName);
IAXuser->setText(ConfigurationManager::instance().get(account,SIGNALISATION_IAXUSER));
IAXpass->setText(ConfigurationManager::instance().get(account,SIGNALISATION_IAXPASS));
IAXhost->setText(ConfigurationManager::instance().get(account,SIGNALISATION_IAXHOST));
lastIAXAccount = number;
}
void
ConfigurationPanel::saveIAXAccount(int number)
{
QString account = "IAX" + QString::number(number);
QString aliasName = IAXalias->text();
ConfigurationManager::instance().set(account, ACCOUNT_ALIAS, aliasName);
QString accountName;
if (aliasName.isEmpty()) {
accountName = QObject::tr("IAX Account #%1").arg(number+1);
} else {
if (aliasName.length() > 30) {
aliasName = aliasName.left(30) + "...";
}
accountName = aliasName + " (" + QObject::tr("IAX Account #%1").arg(number+1) + ")";
}
cboIAXAccount->changeItem(accountName, number);
ConfigurationManager::instance().set(account, SIGNALISATION_IAXUSER, IAXuser->text());
ConfigurationManager::instance().set(account, SIGNALISATION_IAXPASS, IAXpass->text());
ConfigurationManager::instance().set(account, SIGNALISATION_IAXHOST, IAXhost->text());
ConfigurationManager::instance().set(account,
ACCOUNT_AUTO_REGISTER,
QString::number(chkAutoregister->isChecked()));
ConfigurationManager::instance().set(account,
ACCOUNT_ENABLE,
QString::number(chkEnable->isChecked()));
}
......@@ -48,6 +48,9 @@
#define SIGNALISATION_PLAY_TONES "DTMF.playTones"
#define SIGNALISATION_PULSE_LENGTH "DTMF.pulseLength"
#define SIGNALISATION_SEND_DTMF_AS "DTMF.sendDTMFas"
#define SIGNALISATION_IAXHOST "IAX.host"
#define SIGNALISATION_IAXPASS "IAX.pass"
#define SIGNALISATION_IAXUSER "IAX.user"
#define ACCOUNT_DEFAULT_NAME "SIP0"
#define ACCOUNT_TYPE "Account.type"
......
......@@ -210,6 +210,19 @@ IAXVoIPLink::getEvent()
}
iax_event_free(event);
}
// send sound here
if(_currentCall != 0 && audiolayer != 0) {
int samples = audiolayer->canGetMic();
if (samples != 0) {
int datalen = audiolayer->getMic(_sendDataEncoded, samples);
_debug("iax_send_voice(%p, %d, ,%d, %d)\n", _currentCall->getSession(), _currentCall->getFormat(), datalen, samples);
//if ( iax_send_voice(_currentCall->getSession(), _currentCall->getFormat(), (char*)_sendDataEncoded, datalen, samples) == -1) {
// // error sending voice
//}
}
}
// unlock mutex here
_mutexIAX.leaveMutex();
//iaxRefreshRegistrations();
......@@ -458,6 +471,7 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
case IAX_EVENT_HANGUP:
Manager::instance().peerHungupCall(id);
if (Manager::instance().isCurrentCall(id)) {
_currentCall = 0;
audiolayer->stopStream();
// stop audio
}
......@@ -468,6 +482,7 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
Manager::instance().peerHungupCall(id);
if (Manager::instance().isCurrentCall(id)) {
// stop audio
_currentCall = 0;
audiolayer->stopStream();
}
removeCall(id);
......@@ -487,6 +502,7 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
call->setFormat(event->ies.format);
Manager::instance().peerAnsweredCall(id);
_currentCall = call;
audiolayer->startStream();
// start audio here?
} else {
......@@ -539,19 +555,19 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
nbSample = ( src_data.output_frames_gen > IAX__20S_48KHZ_MAX) ? IAX__20S_48KHZ_MAX : src_data.output_frames_gen;
#ifdef DATAFORMAT_IS_FLOAT
toAudioLayer = _floatBuffer48000;
#else
#else
src_float_to_short_array(_floatBuffer48000, _dataAudioLayer, nbSample);
toAudioLayer = _dataAudioLayer;
#endif
toAudioLayer = _dataAudioLayer;
#endif
} else {
nbSample = nbInt16;
#ifdef DATAFORMAT_IS_FLOAT
// convert _receiveDataDecoded to float inside _receiveData
// convert _receiveDataDecoded to float inside _receiveData
src_short_to_float_array(_receiveDataDecoded, _floatBuffer8000, nbSample);
toAudioLayer = _floatBuffer8000;
toAudioLayer = _floatBuffer8000;
#else
toAudioLayer = _receiveDataDecoded; // int to int
toAudioLayer = _receiveDataDecoded; // int to int
#endif
}
audiolayer->putMain(toAudioLayer, nbSample * sizeof(SFLDataFormat));
......
......@@ -139,6 +139,9 @@ private:
/** Buffer for 8000hz samples for mic conversion */
int16* _intBuffer8000;
/** Current IAX call pointer, used for sending, change when starting audio, switching */
IAXCall* _currentCall;
};
#endif
......@@ -283,12 +283,12 @@ SIPCall::SIPCallAnswered(eXosip_event_t *event)
* @return true if ok (change / no change) or false on error
*/
bool
SIPCall::SIPCallAnsweredWithoutHold(eXosip_event_t *event)
SIPCall::SIPCallAnsweredWithoutHold(eXosip_event_t* event)
{
if (event->response == NULL || event->request == NULL) { return false; }
eXosip_lock();
sdp_message_t *remote_sdp = eXosip_get_sdp_info (event->response);
sdp_message_t* remote_sdp = eXosip_get_sdp_info (event->response);
eXosip_unlock();
if (remote_sdp == NULL) {
_debug("SIP Failure: no remote sdp\n");
......@@ -296,7 +296,7 @@ SIPCall::SIPCallAnsweredWithoutHold(eXosip_event_t *event)
return false;
}
sdp_media_t *remote_med = getRemoteMedia(event->tid, remote_sdp);
sdp_media_t* remote_med = getRemoteMedia(event->tid, remote_sdp);
if (remote_med==NULL) {
sdp_message_free(remote_sdp);
return false;
......@@ -306,8 +306,11 @@ SIPCall::SIPCallAnsweredWithoutHold(eXosip_event_t *event)
return false;
}
char *tmp = (char *) osip_list_get (remote_med->m_payloads, 0);
#ifdef LIBOSIP2_WITHPOINTER
char *tmp = (char*) osip_list_get (remote_med->m_payloads, 0);
#else
char *tmp = (char*) osip_list_get (&(remote_med->m_payloads), 0);
#endif
setAudioCodec(0);
if (tmp != NULL) {
int payload = atoi (tmp);
......@@ -400,8 +403,15 @@ SIPCall::sdp_complete_message(sdp_message_t * remote_sdp, osip_message_t * msg)
// for each medias
int iMedia = 0;
char *tmp = NULL;
while (!osip_list_eol(remote_sdp->m_medias, iMedia)) {
sdp_media_t *remote_med = (sdp_media_t *)osip_list_get(remote_sdp->m_medias, iMedia);
#ifdef LIBOSIP2_WITHPOINTER
const osip_list_t* remote_sdp_m_medias = remote_sdp->m_medias; // old abi
#else
const osip_list_t* remote_sdp_m_medias = &(remote_sdp->m_medias);
#endif
osip_list_t* remote_med_m_payloads = 0;
while (!osip_list_eol(remote_sdp_m_medias, iMedia)) {
sdp_media_t *remote_med = (sdp_media_t *)osip_list_get(remote_sdp_m_medias, iMedia);
if (remote_med == 0) { continue; }
if (0 != osip_strcasecmp (remote_med->m_media, "audio")) {
......@@ -413,8 +423,14 @@ SIPCall::sdp_complete_message(sdp_message_t * remote_sdp, osip_message_t * msg)
// search for compatible codec: foreach payload
int iPayload = 0;
while (!osip_list_eol(remote_med->m_payloads, iPayload)) {
tmp = (char *)osip_list_get(remote_med->m_payloads, iPayload);
#ifdef LIBOSIP2_WITHPOINTER
remote_med_m_payloads = remote_med->m_payloads; // old abi
#else
remote_med_m_payloads = &(remote_med->m_payloads);
#endif
while (!osip_list_eol(remote_med_m_payloads, iPayload)) {
tmp = (char *)osip_list_get(remote_med_m_payloads, iPayload);
if (tmp!=NULL) {
int payload = atoi(tmp);
AudioCodec* audiocodec = _codecMap.getCodec((CodecType)payload);
......@@ -464,10 +480,15 @@ SIPCall::sdp_analyse_attribute (sdp_message_t * sdp, sdp_media_t * med)
/* test media attributes */
pos = 0;
while (!osip_list_eol (med->a_attributes, pos)) {
#ifdef LIBOSIP2_WITHPOINTER
const osip_list_t* med_a_attributes = med->a_attributes; // old abi
#else
const osip_list_t* med_a_attributes = &(med->a_attributes);
#endif
while (!osip_list_eol (med_a_attributes, pos)) {
sdp_attribute_t *at;
at = (sdp_attribute_t *) osip_list_get (med->a_attributes, pos);
at = (sdp_attribute_t *) osip_list_get (med_a_attributes, pos);
if (at->a_att_field != NULL &&
0 == strcmp (at->a_att_field, "sendonly")) {
return _SENDONLY;
......@@ -484,10 +505,15 @@ SIPCall::sdp_analyse_attribute (sdp_message_t * sdp, sdp_media_t * med)
/* test global attributes */
pos_media = -1;
pos = 0;
while (!osip_list_eol (sdp->a_attributes, pos)) {
#ifdef LIBOSIP2_WITHPOINTER
const osip_list_t* sdp_a_attributes = sdp->a_attributes; // old abi
#else
const osip_list_t* sdp_a_attributes = &(sdp->a_attributes);
#endif
while (!osip_list_eol (sdp_a_attributes, pos)) {
sdp_attribute_t *at;
at = (sdp_attribute_t *) osip_list_get (sdp->a_attributes, pos);
at = (sdp_attribute_t *) osip_list_get (sdp_a_attributes, pos);
if (at->a_att_field != NULL &&
0 == strcmp (at->a_att_field, "sendonly")) {
return _SENDONLY;
......@@ -622,8 +648,13 @@ SIPCall::setAudioCodecFromSDP(sdp_media_t* remote_med, int tid)
// Remote Payload
char *tmp = NULL;
int pos = 0;
while (!osip_list_eol (remote_med->m_payloads, pos)) {
tmp = (char *) osip_list_get (remote_med->m_payloads, pos);
#ifdef LIBOSIP2_WITHPOINTER
const osip_list_t* remote_med_m_payloads = remote_med->m_payloads; // old abi
#else
const osip_list_t* remote_med_m_payloads = &(remote_med->m_payloads);
#endif
while (!osip_list_eol (remote_med_m_payloads, pos)) {
tmp = (char *) osip_list_get (remote_med_m_payloads, pos);
if (tmp != NULL ) {
int payload = atoi(tmp);
// stop if we find a correct codec
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment