mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 01:26:58 +00:00
Add a brand new codec config. Still needs i and h config.
This commit is contained in:
148
fscomm/widgets/codecwidget.cpp
Normal file
148
fscomm/widgets/codecwidget.cpp
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
33
fscomm/widgets/codecwidget.h
Normal file
33
fscomm/widgets/codecwidget.h
Normal file
@@ -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
|
157
fscomm/widgets/codecwidget.ui
Normal file
157
fscomm/widgets/codecwidget.ui
Normal file
@@ -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>
|
Reference in New Issue
Block a user