Add a brand new codec config. Still needs i and h config.
This commit is contained in:
parent
6314075859
commit
a763ddff81
|
@ -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
|
||||
|
|
|
@ -201,7 +201,7 @@
|
|||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
|
@ -490,28 +490,17 @@
|
|||
<string>Codecs</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout_7">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_21">
|
||||
<property name="text">
|
||||
<string>codec-prefs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="sofiaCodecPrefsEdit">
|
||||
<property name="text">
|
||||
<string>CELT@48000h,G7221@32000h,G7221@16000h,G722,PCMU,PCMA,GSM</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_30">
|
||||
<property name="text">
|
||||
<string>inbound-codec-negotiation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="sofiaInboundCodecNegotiationCombo">
|
||||
<item>
|
||||
<property name="text">
|
||||
|
@ -525,15 +514,15 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_42">
|
||||
<property name="text">
|
||||
<string>Codecs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QListWidget" name="listAvailableCodecs"/>
|
||||
<item row="1" column="1">
|
||||
<widget class="CodecWidget" name="sofiaProfileCodecWidget" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -1028,6 +1017,14 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CodecWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>widgets/codecwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
</resources>
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
QList<QListWidgetItem *>items = 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()
|
||||
{
|
||||
QList<QListWidgetItem *>items = 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()
|
||||
{
|
||||
QList<QListWidgetItem *>items = ui->listAvailCodecs->selectedItems();
|
||||
foreach(QListWidgetItem *item, items)
|
||||
{
|
||||
ui->listEnabledCodecs->insertItem(0,item->text());
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
void CodecWidget::disableCodecs()
|
||||
{
|
||||
QList<QListWidgetItem *>items = 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<QHash<QString, QString> > implList;
|
||||
QHash<QString, QString> 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<QString, QString> 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; i<ui->listEnabledCodecs->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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef CODECWIDGET_H
|
||||
#define CODECWIDGET_H
|
||||
|
||||
#include <QtGui>
|
||||
|
||||
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<QString, QList<QHash<QString, QString> > > _listCodecs;
|
||||
};
|
||||
|
||||
#endif // CODECWIDGET_H
|
|
@ -0,0 +1,157 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CodecWidget</class>
|
||||
<widget class="QWidget" name="CodecWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>612</width>
|
||||
<height>235</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Available Codecs</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listAvailCodecs">
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragDrop</enum>
|
||||
</property>
|
||||
<property name="defaultDropAction">
|
||||
<enum>Qt::MoveAction</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnEnable">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::RightArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnDisable">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::LeftArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Enabled Codecs</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listEnabledCodecs">
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragDrop</enum>
|
||||
</property>
|
||||
<property name="defaultDropAction">
|
||||
<enum>Qt::MoveAction</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnUp">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::UpArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnAdv">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnDown">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::DownArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue