diff --git a/fscomm/FSComm.pro b/fscomm/FSComm.pro
index 4bb59b669a..32d76548a8 100644
--- a/fscomm/FSComm.pro
+++ b/fscomm/FSComm.pro
@@ -31,7 +31,8 @@ SOURCES += main.cpp \
preferences/prefsofia.cpp \
preferences/accountdialog.cpp \
preferences/prefaccounts.cpp \
- account.cpp
+ account.cpp \
+ widgets/codecwidget.cpp
HEADERS += mainwindow.h \
fshost.h \
call.h \
@@ -41,9 +42,11 @@ HEADERS += mainwindow.h \
preferences/prefsofia.h \
preferences/accountdialog.h \
preferences/prefaccounts.h \
- account.h
+ account.h \
+ widgets/codecwidget.h
FORMS += mainwindow.ui \
preferences/prefdialog.ui \
- preferences/accountdialog.ui
+ preferences/accountdialog.ui \
+ widgets/codecwidget.ui
RESOURCES += resources.qrc
OTHER_FILES += conf/freeswitch.xml
diff --git a/fscomm/preferences/prefdialog.ui b/fscomm/preferences/prefdialog.ui
index 4b0bfbec94..1192631e70 100644
--- a/fscomm/preferences/prefdialog.ui
+++ b/fscomm/preferences/prefdialog.ui
@@ -201,7 +201,7 @@
-
- 2
+ 0
@@ -490,28 +490,17 @@
Codecs
+
+ QFormLayout::AllNonFixedFieldsGrow
+
-
-
-
- codec-prefs
-
-
-
- -
-
-
- CELT@48000h,G7221@32000h,G7221@16000h,G722,PCMU,PCMA,GSM
-
-
-
- -
inbound-codec-negotiation
- -
+
-
-
@@ -525,15 +514,15 @@
- -
+
-
Codecs
- -
-
+
-
+
@@ -1028,6 +1017,14 @@
+
+
+ CodecWidget
+ QWidget
+
+ 1
+
+
diff --git a/fscomm/preferences/prefsofia.cpp b/fscomm/preferences/prefsofia.cpp
index 3642b3a34e..01347184ff 100644
--- a/fscomm/preferences/prefsofia.cpp
+++ b/fscomm/preferences/prefsofia.cpp
@@ -42,7 +42,7 @@ void PrefSofia::readConfig()
_ui->sofiaSipPortSpin->setValue(settings.value("sip-port").toInt());
_ui->sofiaDialplanEdit->setText(settings.value("dialplan").toString());
_ui->sofiaDtmfDurationSpin->setValue(settings.value("dtmf-duration").toInt());
- _ui->sofiaCodecPrefsEdit->setText(settings.value("codec-prefs").toString());
+ _ui->sofiaProfileCodecWidget->setCodecString(settings.value("codec-prefs").toString());
_ui->sofiaUseRtpTimerCombo->setCurrentIndex(_ui->sofiaUseRtpTimerCombo->findText(settings.value("use-rtp-timer").toString()));
_ui->sofiaRtpTimerNameEdit->setText(settings.value("rtp-timer-name").toString());
_ui->sofiaRtpIpEdit->setText(settings.value("rtp-ip").toString());
@@ -68,15 +68,6 @@ void PrefSofia::readConfig()
settings.endGroup();
settings.endGroup();
- /* This is here to show the proper codec config! */
- const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
- uint32_t num_codecs = switch_loadable_module_get_codecs(codecs, sizeof(codecs) / sizeof(codecs[0]));
- uint32_t x;
-
- for (x = 0; x < num_codecs; x++) {
- _ui->listAvailableCodecs->addItem(codecs[x]->iananame);
- }
-
}
void PrefSofia::writeConfig()
@@ -110,7 +101,7 @@ void PrefSofia::writeConfig()
settings.setValue("sip-port", _ui->sofiaSipPortSpin->value());
settings.setValue("dialplan", _ui->sofiaDialplanEdit->text());
settings.setValue("dtmf-duration", _ui->sofiaDtmfDurationSpin->value());
- settings.setValue("codec-prefs", _ui->sofiaCodecPrefsEdit->text());
+ settings.setValue("codec-prefs", _ui->sofiaProfileCodecWidget->getCodecString());
settings.setValue("use-rtp-timer", _ui->sofiaUseRtpTimerCombo->currentText());
settings.setValue("rtp-timer-name", _ui->sofiaRtpTimerNameEdit->text());
settings.setValue("rtp-ip", _ui->sofiaRtpIpEdit->text());
diff --git a/fscomm/widgets/codecwidget.cpp b/fscomm/widgets/codecwidget.cpp
new file mode 100644
index 0000000000..049fc4ba4d
--- /dev/null
+++ b/fscomm/widgets/codecwidget.cpp
@@ -0,0 +1,148 @@
+#include "codecwidget.h"
+#include "ui_codecwidget.h"
+#include "fshost.h"
+
+CodecWidget::CodecWidget(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::CodecWidget)
+{
+ ui->setupUi(this);
+ connect(ui->btnEnable, SIGNAL(clicked()), this, SLOT(enableCodecs()));
+ connect(ui->btnDisable, SIGNAL(clicked()), this, SLOT(disableCodecs()));
+ connect(ui->btnUp, SIGNAL(clicked()), this, SLOT(moveUp()));
+ connect(ui->btnDown, SIGNAL(clicked()), this, SLOT(moveDown()));
+ readCodecs();
+}
+
+CodecWidget::~CodecWidget()
+{
+ delete ui;
+}
+
+void CodecWidget::moveUp()
+{
+ QListitems = ui->listEnabledCodecs->selectedItems();
+ foreach(QListWidgetItem *item, items)
+ {
+ int row = ui->listEnabledCodecs->row(item);
+ if (row != 0)
+ ui->listEnabledCodecs->insertItem(row-1, ui->listEnabledCodecs->takeItem(row));
+ }
+}
+
+void CodecWidget::moveDown()
+{
+ QListitems = ui->listEnabledCodecs->selectedItems();
+ foreach(QListWidgetItem *item, items)
+ {
+ int row = ui->listEnabledCodecs->row(item);
+ if (row != ui->listEnabledCodecs->count())
+ ui->listEnabledCodecs->insertItem(row+1, ui->listEnabledCodecs->takeItem(row));
+ }
+}
+
+void CodecWidget::enableCodecs()
+{
+ QListitems = ui->listAvailCodecs->selectedItems();
+ foreach(QListWidgetItem *item, items)
+ {
+ ui->listEnabledCodecs->insertItem(0,item->text());
+ delete item;
+ }
+}
+
+void CodecWidget::disableCodecs()
+{
+ QListitems = ui->listEnabledCodecs->selectedItems();
+ foreach(QListWidgetItem *item, items)
+ {
+ ui->listAvailCodecs->insertItem(0,item->text());
+ delete item;
+ }
+}
+
+void CodecWidget::changeEvent(QEvent *e)
+{
+ QWidget::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+
+void CodecWidget::readCodecs(void)
+{
+ /* This is here to show the proper codec config! */
+ const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
+ uint32_t num_codecs = switch_loadable_module_get_codecs(codecs, sizeof(codecs) / sizeof(codecs[0]));
+ uint32_t x;
+
+ for (x = 0; x < num_codecs; x++) {
+
+ /* Codecs we cannot enable/disable or dont want to */
+ if (QString(codecs[x]->iananame) == "PROXY" ||
+ QString(codecs[x]->iananame) == "PROXY-VID")
+ {
+ continue;
+ }
+
+ QList > implList;
+ QHash implPair;
+ implPair.insert(QString::number(codecs[x]->samples_per_second), QString::number(codecs[x]->microseconds_per_packet/1000));
+ implList.append(implPair);
+
+ /* Iterate over the other implementations */
+ switch_codec_implementation_t *curr = codecs[x]->next;
+ while (curr != NULL)
+ {
+ QHash implPair;
+ implPair.insert(QString::number(curr->samples_per_second), QString::number(curr->microseconds_per_packet/1000));
+ implList.append(implPair);
+ curr = curr->next;
+ }
+ _listCodecs.insert(codecs[x]->iananame, implList);
+ ui->listAvailCodecs->insertItem(0, codecs[x]->iananame);
+ }
+ ui->listAvailCodecs->sortItems(Qt::AscendingOrder);
+}
+
+QString CodecWidget::getCodecString()
+{
+ QString codecList;
+ for(int i = 0; ilistEnabledCodecs->count(); i++)
+ {
+ QString codecName = ui->listEnabledCodecs->item(i)->text();
+ if (!_listCodecs.contains(codecName))
+ QMessageBox::warning(this, tr("Error"), tr("Codec %1 does not exist as loaded codec, therefore will not be used.").arg(codecName), QMessageBox::Ok);
+ codecList += codecName;
+ if (i!= ui->listEnabledCodecs->count()-1)
+ codecList += ",";
+ }
+ return codecList;
+}
+
+void CodecWidget::setCodecString(QString codecList)
+{
+ QStringList rawEnCodecs;
+ QStringList split = codecList.split(",");
+ foreach(QString s, split)
+ {
+ QStringList cs = s.split("@");
+ if (!rawEnCodecs.contains(cs[0]))
+ {
+ ui->listEnabledCodecs->insertItem(ui->listEnabledCodecs->count(), cs[0]);
+ rawEnCodecs.append(cs[0]);
+ }
+ }
+
+ foreach(QString c, rawEnCodecs)
+ {
+ foreach(QListWidgetItem *i, ui->listAvailCodecs->findItems(c, Qt::MatchExactly))
+ {
+ delete i;
+ }
+ }
+}
diff --git a/fscomm/widgets/codecwidget.h b/fscomm/widgets/codecwidget.h
new file mode 100644
index 0000000000..0e836b1a6f
--- /dev/null
+++ b/fscomm/widgets/codecwidget.h
@@ -0,0 +1,33 @@
+#ifndef CODECWIDGET_H
+#define CODECWIDGET_H
+
+#include
+
+namespace Ui {
+ class CodecWidget;
+}
+
+class CodecWidget : public QWidget {
+ Q_OBJECT
+public:
+ CodecWidget(QWidget *parent = 0);
+ ~CodecWidget();
+ QString getCodecString();
+ void setCodecString(QString);
+
+protected:
+ void changeEvent(QEvent *e);
+
+private slots:
+ void enableCodecs();
+ void disableCodecs();
+ void moveUp();
+ void moveDown();
+
+private:
+ void readCodecs(void);
+ Ui::CodecWidget *ui;
+ QHash > > _listCodecs;
+};
+
+#endif // CODECWIDGET_H
diff --git a/fscomm/widgets/codecwidget.ui b/fscomm/widgets/codecwidget.ui
new file mode 100644
index 0000000000..91a749075e
--- /dev/null
+++ b/fscomm/widgets/codecwidget.ui
@@ -0,0 +1,157 @@
+
+
+ CodecWidget
+
+
+
+ 0
+ 0
+ 612
+ 235
+
+
+
+ Form
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Available Codecs
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ true
+
+
+ QAbstractItemView::DragDrop
+
+
+ Qt::MoveAction
+
+
+ true
+
+
+ QAbstractItemView::ExtendedSelection
+
+
+ true
+
+
+
+
+
+ -
+
+
-
+
+
+ ...
+
+
+ Qt::RightArrow
+
+
+
+ -
+
+
+ ...
+
+
+ Qt::LeftArrow
+
+
+
+
+
+ -
+
+
-
+
+
+ Enabled Codecs
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ true
+
+
+ QAbstractItemView::DragDrop
+
+
+ Qt::MoveAction
+
+
+ true
+
+
+ QAbstractItemView::ExtendedSelection
+
+
+ false
+
+
+
+
+
+ -
+
+
-
+
+
+ ...
+
+
+ Qt::UpArrow
+
+
+
+ -
+
+
+ false
+
+
+ ...
+
+
+
+ -
+
+
+ ...
+
+
+ Qt::DownArrow
+
+
+
+
+
+
+
+
+
+