mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-20 05:23:12 -07:00
Add H265 Streaming to GUI
This commit is contained in:
parent
c19c7869d5
commit
e6d18155af
8 changed files with 57 additions and 4 deletions
|
@ -75,6 +75,9 @@ class Settings : public QObject
|
||||||
unsigned int GetBitrate() const;
|
unsigned int GetBitrate() const;
|
||||||
void SetBitrate(unsigned int bitrate);
|
void SetBitrate(unsigned int bitrate);
|
||||||
|
|
||||||
|
ChiakiCodec GetCodec() const;
|
||||||
|
void SetCodec(ChiakiCodec codec);
|
||||||
|
|
||||||
Decoder GetDecoder() const;
|
Decoder GetDecoder() const;
|
||||||
void SetDecoder(Decoder decoder);
|
void SetDecoder(Decoder decoder);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ class SettingsDialog : public QDialog
|
||||||
QComboBox *resolution_combo_box;
|
QComboBox *resolution_combo_box;
|
||||||
QComboBox *fps_combo_box;
|
QComboBox *fps_combo_box;
|
||||||
QLineEdit *bitrate_edit;
|
QLineEdit *bitrate_edit;
|
||||||
|
QComboBox *codec_combo_box;
|
||||||
QLineEdit *audio_buffer_size_edit;
|
QLineEdit *audio_buffer_size_edit;
|
||||||
QComboBox *audio_device_combo_box;
|
QComboBox *audio_device_combo_box;
|
||||||
QCheckBox *pi_decoder_check_box;
|
QCheckBox *pi_decoder_check_box;
|
||||||
|
@ -41,6 +42,7 @@ class SettingsDialog : public QDialog
|
||||||
void ResolutionSelected();
|
void ResolutionSelected();
|
||||||
void FPSSelected();
|
void FPSSelected();
|
||||||
void BitrateEdited();
|
void BitrateEdited();
|
||||||
|
void CodecSelected();
|
||||||
void AudioBufferSizeEdited();
|
void AudioBufferSizeEdited();
|
||||||
void AudioOutputSelected();
|
void AudioOutputSelected();
|
||||||
void HardwareDecodeEngineSelected();
|
void HardwareDecodeEngineSelected();
|
||||||
|
|
|
@ -132,6 +132,24 @@ void Settings::SetBitrate(unsigned int bitrate)
|
||||||
settings.setValue("settings/bitrate", bitrate);
|
settings.setValue("settings/bitrate", bitrate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const QMap<ChiakiCodec, QString> codecs = {
|
||||||
|
{ CHIAKI_CODEC_H264, "h264"},
|
||||||
|
{ CHIAKI_CODEC_H265, "h265"}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const ChiakiCodec codec_default = CHIAKI_CODEC_H265;
|
||||||
|
|
||||||
|
ChiakiCodec Settings::GetCodec() const
|
||||||
|
{
|
||||||
|
auto v = settings.value("settings/codec", codecs[codec_default]).toString();
|
||||||
|
return codecs.key(v, codec_default);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::SetCodec(ChiakiCodec codec)
|
||||||
|
{
|
||||||
|
settings.setValue("settings/codec", codecs[codec]);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int Settings::GetAudioBufferSizeDefault() const
|
unsigned int Settings::GetAudioBufferSizeDefault() const
|
||||||
{
|
{
|
||||||
return 9600;
|
return 9600;
|
||||||
|
@ -202,7 +220,7 @@ ChiakiConnectVideoProfile Settings::GetVideoProfile()
|
||||||
unsigned int bitrate = GetBitrate();
|
unsigned int bitrate = GetBitrate();
|
||||||
if(bitrate)
|
if(bitrate)
|
||||||
profile.bitrate = bitrate;
|
profile.bitrate = bitrate;
|
||||||
profile.codec = CHIAKI_CODEC_H264; // TODO: add a setting
|
profile.codec = GetCodec();
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,21 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
|
||||||
connect(bitrate_edit, &QLineEdit::textEdited, this, &SettingsDialog::BitrateEdited);
|
connect(bitrate_edit, &QLineEdit::textEdited, this, &SettingsDialog::BitrateEdited);
|
||||||
UpdateBitratePlaceholder();
|
UpdateBitratePlaceholder();
|
||||||
|
|
||||||
|
codec_combo_box = new QComboBox(this);
|
||||||
|
static const QList<QPair<ChiakiCodec, QString>> codec_strings = {
|
||||||
|
{ CHIAKI_CODEC_H264, "H264" },
|
||||||
|
{ CHIAKI_CODEC_H265, "H265 (PS5 only)" }
|
||||||
|
};
|
||||||
|
auto current_codec = settings->GetCodec();
|
||||||
|
for(const auto &p : codec_strings)
|
||||||
|
{
|
||||||
|
codec_combo_box->addItem(p.second, (int)p.first);
|
||||||
|
if(current_codec == p.first)
|
||||||
|
codec_combo_box->setCurrentIndex(codec_combo_box->count() - 1);
|
||||||
|
}
|
||||||
|
connect(codec_combo_box, SIGNAL(currentIndexChanged(int)), this, SLOT(CodecSelected()));
|
||||||
|
stream_settings_layout->addRow(tr("Codec:"), codec_combo_box);
|
||||||
|
|
||||||
audio_buffer_size_edit = new QLineEdit(this);
|
audio_buffer_size_edit = new QLineEdit(this);
|
||||||
audio_buffer_size_edit->setValidator(new QIntValidator(1024, 0x20000, audio_buffer_size_edit));
|
audio_buffer_size_edit->setValidator(new QIntValidator(1024, 0x20000, audio_buffer_size_edit));
|
||||||
unsigned int audio_buffer_size = settings->GetAudioBufferSizeRaw();
|
unsigned int audio_buffer_size = settings->GetAudioBufferSizeRaw();
|
||||||
|
@ -317,6 +332,11 @@ void SettingsDialog::BitrateEdited()
|
||||||
settings->SetBitrate(bitrate_edit->text().toUInt());
|
settings->SetBitrate(bitrate_edit->text().toUInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::CodecSelected()
|
||||||
|
{
|
||||||
|
settings->SetCodec((ChiakiCodec)codec_combo_box->currentData().toInt());
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsDialog::AudioBufferSizeEdited()
|
void SettingsDialog::AudioBufferSizeEdited()
|
||||||
{
|
{
|
||||||
settings->SetAudioBufferSize(audio_buffer_size_edit->text().toUInt());
|
settings->SetAudioBufferSize(audio_buffer_size_edit->text().toUInt());
|
||||||
|
|
|
@ -68,7 +68,7 @@ StreamSession::StreamSession(const StreamSessionConnectInfo &connect_info, QObje
|
||||||
chiaki_log_sniffer_init(&sniffer, CHIAKI_LOG_ALL, GetChiakiLog());
|
chiaki_log_sniffer_init(&sniffer, CHIAKI_LOG_ALL, GetChiakiLog());
|
||||||
ChiakiErrorCode err = chiaki_ffmpeg_decoder_init(ffmpeg_decoder,
|
ChiakiErrorCode err = chiaki_ffmpeg_decoder_init(ffmpeg_decoder,
|
||||||
chiaki_log_sniffer_get_log(&sniffer),
|
chiaki_log_sniffer_get_log(&sniffer),
|
||||||
connect_info.video_profile.codec,
|
chiaki_target_is_ps5(connect_info.target) ? connect_info.video_profile.codec : CHIAKI_CODEC_H264,
|
||||||
connect_info.hw_decoder.isEmpty() ? NULL : connect_info.hw_decoder.toUtf8().constData(),
|
connect_info.hw_decoder.isEmpty() ? NULL : connect_info.hw_decoder.toUtf8().constData(),
|
||||||
FfmpegFrameCb, this);
|
FfmpegFrameCb, this);
|
||||||
if(err != CHIAKI_ERR_SUCCESS)
|
if(err != CHIAKI_ERR_SUCCESS)
|
||||||
|
|
|
@ -85,9 +85,10 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_lib_init();
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
// values must not change
|
||||||
CHIAKI_CODEC_H264 = 0,
|
CHIAKI_CODEC_H264 = 0,
|
||||||
CHIAKI_CODEC_H265,
|
CHIAKI_CODEC_H265 = 1,
|
||||||
CHIAKI_CODEC_H265_HDR
|
CHIAKI_CODEC_H265_HDR = 2
|
||||||
} ChiakiCodec;
|
} ChiakiCodec;
|
||||||
|
|
||||||
static inline bool chiaki_codec_is_h265(ChiakiCodec codec)
|
static inline bool chiaki_codec_is_h265(ChiakiCodec codec)
|
||||||
|
|
|
@ -971,6 +971,7 @@ static ChiakiErrorCode ctrl_connect(ChiakiCtrl *ctrl)
|
||||||
&& session->connect_info.video_profile_auto_downgrade
|
&& session->connect_info.video_profile_auto_downgrade
|
||||||
&& session->connect_info.video_profile.height == 1080)
|
&& session->connect_info.video_profile.height == 1080)
|
||||||
{
|
{
|
||||||
|
// regular PS4 doesn't support >= 1080p
|
||||||
CHIAKI_LOGI(session->log, "1080p was selected but server would not support it. Downgrading.");
|
CHIAKI_LOGI(session->log, "1080p was selected but server would not support it. Downgrading.");
|
||||||
chiaki_connect_video_profile_preset(
|
chiaki_connect_video_profile_preset(
|
||||||
&session->connect_info.video_profile,
|
&session->connect_info.video_profile,
|
||||||
|
@ -979,6 +980,13 @@ static ChiakiErrorCode ctrl_connect(ChiakiCtrl *ctrl)
|
||||||
? CHIAKI_VIDEO_FPS_PRESET_60
|
? CHIAKI_VIDEO_FPS_PRESET_60
|
||||||
: CHIAKI_VIDEO_FPS_PRESET_30);
|
: CHIAKI_VIDEO_FPS_PRESET_30);
|
||||||
}
|
}
|
||||||
|
if((server_type == 0 || server_type == 1)
|
||||||
|
&& session->connect_info.video_profile.codec != CHIAKI_CODEC_H264)
|
||||||
|
{
|
||||||
|
// PS4 doesn't support anything except h264
|
||||||
|
CHIAKI_LOGI(session->log, "A codec other than H264 was selected but server would not support it. Downgrading.");
|
||||||
|
session->connect_info.video_profile.codec = CHIAKI_CODEC_H264;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
CHIAKI_LOGE(session->log, "No valid Server Type in ctrl response");
|
CHIAKI_LOGE(session->log, "No valid Server Type in ctrl response");
|
||||||
|
|
|
@ -88,6 +88,7 @@ CHIAKI_EXPORT ChiakiTarget chiaki_rp_version_parse(const char *rp_version_str, b
|
||||||
|
|
||||||
CHIAKI_EXPORT void chiaki_connect_video_profile_preset(ChiakiConnectVideoProfile *profile, ChiakiVideoResolutionPreset resolution, ChiakiVideoFPSPreset fps)
|
CHIAKI_EXPORT void chiaki_connect_video_profile_preset(ChiakiConnectVideoProfile *profile, ChiakiVideoResolutionPreset resolution, ChiakiVideoFPSPreset fps)
|
||||||
{
|
{
|
||||||
|
profile->codec = CHIAKI_CODEC_H264;
|
||||||
switch(resolution)
|
switch(resolution)
|
||||||
{
|
{
|
||||||
case CHIAKI_VIDEO_RESOLUTION_PRESET_360p:
|
case CHIAKI_VIDEO_RESOLUTION_PRESET_360p:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue