mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-19 21:13:12 -07:00
Add Bitrate Setting
This commit is contained in:
parent
1f62756b85
commit
3f6cc3647e
6 changed files with 54 additions and 2 deletions
|
@ -54,9 +54,17 @@ class Settings : public QObject
|
||||||
ChiakiVideoResolutionPreset GetResolution() const;
|
ChiakiVideoResolutionPreset GetResolution() const;
|
||||||
void SetResolution(ChiakiVideoResolutionPreset resolution);
|
void SetResolution(ChiakiVideoResolutionPreset resolution);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 0 if set to "automatic"
|
||||||
|
*/
|
||||||
ChiakiVideoFPSPreset GetFPS() const;
|
ChiakiVideoFPSPreset GetFPS() const;
|
||||||
void SetFPS(ChiakiVideoFPSPreset fps);
|
void SetFPS(ChiakiVideoFPSPreset fps);
|
||||||
|
|
||||||
|
unsigned int GetBitrate() const;
|
||||||
|
void SetBitrate(unsigned int bitrate);
|
||||||
|
|
||||||
|
ChiakiConnectVideoProfile GetVideoProfile();
|
||||||
|
|
||||||
QList<RegisteredHost> GetRegisteredHosts() const { return registered_hosts.values(); }
|
QList<RegisteredHost> GetRegisteredHosts() const { return registered_hosts.values(); }
|
||||||
void AddRegisteredHost(const RegisteredHost &host);
|
void AddRegisteredHost(const RegisteredHost &host);
|
||||||
void RemoveRegisteredHost(const HostMAC &mac);
|
void RemoveRegisteredHost(const HostMAC &mac);
|
||||||
|
|
|
@ -24,6 +24,7 @@ class Settings;
|
||||||
class QListWidget;
|
class QListWidget;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
|
class QLineEdit;
|
||||||
|
|
||||||
class SettingsDialog : public QDialog
|
class SettingsDialog : public QDialog
|
||||||
{
|
{
|
||||||
|
@ -36,15 +37,19 @@ class SettingsDialog : public QDialog
|
||||||
|
|
||||||
QComboBox *resolution_combo_box;
|
QComboBox *resolution_combo_box;
|
||||||
QComboBox *fps_combo_box;
|
QComboBox *fps_combo_box;
|
||||||
|
QLineEdit *bitrate_edit;
|
||||||
|
|
||||||
QListWidget *registered_hosts_list_widget;
|
QListWidget *registered_hosts_list_widget;
|
||||||
QPushButton *delete_registered_host_button;
|
QPushButton *delete_registered_host_button;
|
||||||
|
|
||||||
|
void UpdateBitratePlaceholder();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void LogVerboseChanged();
|
void LogVerboseChanged();
|
||||||
|
|
||||||
void ResolutionSelected();
|
void ResolutionSelected();
|
||||||
void FPSSelected();
|
void FPSSelected();
|
||||||
|
void BitrateEdited();
|
||||||
|
|
||||||
void UpdateRegisteredHosts();
|
void UpdateRegisteredHosts();
|
||||||
void UpdateRegisteredHostsButtons();
|
void UpdateRegisteredHostsButtons();
|
||||||
|
|
|
@ -73,6 +73,25 @@ void Settings::SetFPS(ChiakiVideoFPSPreset fps)
|
||||||
settings.setValue("settings/fps", fps_values[fps]);
|
settings.setValue("settings/fps", fps_values[fps]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int Settings::GetBitrate() const
|
||||||
|
{
|
||||||
|
return settings.value("settings/bitrate", 0).toUInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetBitrate(unsigned int bitrate)
|
||||||
|
{
|
||||||
|
settings.setValue("settings/bitrate", bitrate);
|
||||||
|
}
|
||||||
|
|
||||||
|
ChiakiConnectVideoProfile Settings::GetVideoProfile()
|
||||||
|
{
|
||||||
|
ChiakiConnectVideoProfile profile;
|
||||||
|
chiaki_connect_video_profile_preset(&profile, GetResolution(), GetFPS());
|
||||||
|
unsigned int bitrate = GetBitrate();
|
||||||
|
if(bitrate)
|
||||||
|
profile.bitrate = bitrate;
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::LoadRegisteredHosts()
|
void Settings::LoadRegisteredHosts()
|
||||||
{
|
{
|
||||||
|
|
|
@ -122,6 +122,14 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
|
||||||
connect(fps_combo_box, SIGNAL(currentIndexChanged(int)), this, SLOT(FPSSelected()));
|
connect(fps_combo_box, SIGNAL(currentIndexChanged(int)), this, SLOT(FPSSelected()));
|
||||||
stream_settings_layout->addRow(tr("FPS:"), fps_combo_box);
|
stream_settings_layout->addRow(tr("FPS:"), fps_combo_box);
|
||||||
|
|
||||||
|
bitrate_edit = new QLineEdit(this);
|
||||||
|
bitrate_edit->setValidator(new QIntValidator(2000, 50000, bitrate_edit));
|
||||||
|
unsigned int bitrate = settings->GetBitrate();
|
||||||
|
bitrate_edit->setText(bitrate ? QString::number(bitrate) : "");
|
||||||
|
stream_settings_layout->addRow(tr("Bitrate:"), bitrate_edit);
|
||||||
|
connect(bitrate_edit, &QLineEdit::textEdited, this, &SettingsDialog::BitrateEdited);
|
||||||
|
UpdateBitratePlaceholder();
|
||||||
|
|
||||||
|
|
||||||
// Registered Consoles
|
// Registered Consoles
|
||||||
|
|
||||||
|
@ -150,6 +158,7 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
|
||||||
auto button_box = new QDialogButtonBox(QDialogButtonBox::Close, this);
|
auto button_box = new QDialogButtonBox(QDialogButtonBox::Close, this);
|
||||||
layout->addWidget(button_box);
|
layout->addWidget(button_box);
|
||||||
connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
button_box->button(QDialogButtonBox::Close)->setDefault(true);
|
||||||
|
|
||||||
UpdateRegisteredHosts();
|
UpdateRegisteredHosts();
|
||||||
UpdateRegisteredHostsButtons();
|
UpdateRegisteredHostsButtons();
|
||||||
|
@ -161,6 +170,7 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
|
||||||
void SettingsDialog::ResolutionSelected()
|
void SettingsDialog::ResolutionSelected()
|
||||||
{
|
{
|
||||||
settings->SetResolution((ChiakiVideoResolutionPreset)resolution_combo_box->currentData().toInt());
|
settings->SetResolution((ChiakiVideoResolutionPreset)resolution_combo_box->currentData().toInt());
|
||||||
|
UpdateBitratePlaceholder();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::LogVerboseChanged()
|
void SettingsDialog::LogVerboseChanged()
|
||||||
|
@ -173,6 +183,16 @@ void SettingsDialog::FPSSelected()
|
||||||
settings->SetFPS((ChiakiVideoFPSPreset)fps_combo_box->currentData().toInt());
|
settings->SetFPS((ChiakiVideoFPSPreset)fps_combo_box->currentData().toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::BitrateEdited()
|
||||||
|
{
|
||||||
|
settings->SetBitrate(bitrate_edit->text().toUInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::UpdateBitratePlaceholder()
|
||||||
|
{
|
||||||
|
bitrate_edit->setPlaceholderText(tr("Automatic (%1)").arg(settings->GetVideoProfile().bitrate));
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsDialog::UpdateRegisteredHosts()
|
void SettingsDialog::UpdateRegisteredHosts()
|
||||||
{
|
{
|
||||||
registered_hosts_list_widget->clear();
|
registered_hosts_list_widget->clear();
|
||||||
|
|
|
@ -41,7 +41,7 @@ StreamSessionConnectInfo::StreamSessionConnectInfo(Settings *settings, QString h
|
||||||
{
|
{
|
||||||
log_level_mask = settings->GetLogLevelMask();
|
log_level_mask = settings->GetLogLevelMask();
|
||||||
log_file = CreateLogFilename();
|
log_file = CreateLogFilename();
|
||||||
chiaki_connect_video_profile_preset(&video_profile, settings->GetResolution(), settings->GetFPS());
|
video_profile = settings->GetVideoProfile();
|
||||||
this->host = host;
|
this->host = host;
|
||||||
this->regist_key = regist_key;
|
this->regist_key = regist_key;
|
||||||
this->morning = morning;
|
this->morning = morning;
|
||||||
|
|
|
@ -64,7 +64,7 @@ CHIAKI_EXPORT void chiaki_connect_video_profile_preset(ChiakiConnectVideoProfile
|
||||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_720p:
|
case CHIAKI_VIDEO_RESOLUTION_PRESET_720p:
|
||||||
profile->width = 1280;
|
profile->width = 1280;
|
||||||
profile->height = 720;
|
profile->height = 720;
|
||||||
profile->bitrate = 6000; // TODO: 10000 by default
|
profile->bitrate = 10000;
|
||||||
break;
|
break;
|
||||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_1080p:
|
case CHIAKI_VIDEO_RESOLUTION_PRESET_1080p:
|
||||||
profile->width = 1920;
|
profile->width = 1920;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue