mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-21 05:53: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;
|
||||
void SetResolution(ChiakiVideoResolutionPreset resolution);
|
||||
|
||||
/**
|
||||
* @return 0 if set to "automatic"
|
||||
*/
|
||||
ChiakiVideoFPSPreset GetFPS() const;
|
||||
void SetFPS(ChiakiVideoFPSPreset fps);
|
||||
|
||||
unsigned int GetBitrate() const;
|
||||
void SetBitrate(unsigned int bitrate);
|
||||
|
||||
ChiakiConnectVideoProfile GetVideoProfile();
|
||||
|
||||
QList<RegisteredHost> GetRegisteredHosts() const { return registered_hosts.values(); }
|
||||
void AddRegisteredHost(const RegisteredHost &host);
|
||||
void RemoveRegisteredHost(const HostMAC &mac);
|
||||
|
|
|
@ -24,6 +24,7 @@ class Settings;
|
|||
class QListWidget;
|
||||
class QComboBox;
|
||||
class QCheckBox;
|
||||
class QLineEdit;
|
||||
|
||||
class SettingsDialog : public QDialog
|
||||
{
|
||||
|
@ -36,15 +37,19 @@ class SettingsDialog : public QDialog
|
|||
|
||||
QComboBox *resolution_combo_box;
|
||||
QComboBox *fps_combo_box;
|
||||
QLineEdit *bitrate_edit;
|
||||
|
||||
QListWidget *registered_hosts_list_widget;
|
||||
QPushButton *delete_registered_host_button;
|
||||
|
||||
void UpdateBitratePlaceholder();
|
||||
|
||||
private slots:
|
||||
void LogVerboseChanged();
|
||||
|
||||
void ResolutionSelected();
|
||||
void FPSSelected();
|
||||
void BitrateEdited();
|
||||
|
||||
void UpdateRegisteredHosts();
|
||||
void UpdateRegisteredHostsButtons();
|
||||
|
|
|
@ -73,6 +73,25 @@ void Settings::SetFPS(ChiakiVideoFPSPreset 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()
|
||||
{
|
||||
|
|
|
@ -122,6 +122,14 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
|
|||
connect(fps_combo_box, SIGNAL(currentIndexChanged(int)), this, SLOT(FPSSelected()));
|
||||
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
|
||||
|
||||
|
@ -150,6 +158,7 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
|
|||
auto button_box = new QDialogButtonBox(QDialogButtonBox::Close, this);
|
||||
layout->addWidget(button_box);
|
||||
connect(button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
button_box->button(QDialogButtonBox::Close)->setDefault(true);
|
||||
|
||||
UpdateRegisteredHosts();
|
||||
UpdateRegisteredHostsButtons();
|
||||
|
@ -161,6 +170,7 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
|
|||
void SettingsDialog::ResolutionSelected()
|
||||
{
|
||||
settings->SetResolution((ChiakiVideoResolutionPreset)resolution_combo_box->currentData().toInt());
|
||||
UpdateBitratePlaceholder();
|
||||
}
|
||||
|
||||
void SettingsDialog::LogVerboseChanged()
|
||||
|
@ -173,6 +183,16 @@ void SettingsDialog::FPSSelected()
|
|||
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()
|
||||
{
|
||||
registered_hosts_list_widget->clear();
|
||||
|
|
|
@ -41,7 +41,7 @@ StreamSessionConnectInfo::StreamSessionConnectInfo(Settings *settings, QString h
|
|||
{
|
||||
log_level_mask = settings->GetLogLevelMask();
|
||||
log_file = CreateLogFilename();
|
||||
chiaki_connect_video_profile_preset(&video_profile, settings->GetResolution(), settings->GetFPS());
|
||||
video_profile = settings->GetVideoProfile();
|
||||
this->host = host;
|
||||
this->regist_key = regist_key;
|
||||
this->morning = morning;
|
||||
|
|
|
@ -64,7 +64,7 @@ CHIAKI_EXPORT void chiaki_connect_video_profile_preset(ChiakiConnectVideoProfile
|
|||
case CHIAKI_VIDEO_RESOLUTION_PRESET_720p:
|
||||
profile->width = 1280;
|
||||
profile->height = 720;
|
||||
profile->bitrate = 6000; // TODO: 10000 by default
|
||||
profile->bitrate = 10000;
|
||||
break;
|
||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_1080p:
|
||||
profile->width = 1920;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue