Add H265 Streaming to GUI

This commit is contained in:
Florian Märkl 2020-12-28 17:27:10 +01:00
commit e6d18155af
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
8 changed files with 57 additions and 4 deletions

View file

@ -75,6 +75,9 @@ class Settings : public QObject
unsigned int GetBitrate() const;
void SetBitrate(unsigned int bitrate);
ChiakiCodec GetCodec() const;
void SetCodec(ChiakiCodec codec);
Decoder GetDecoder() const;
void SetDecoder(Decoder decoder);

View file

@ -24,6 +24,7 @@ class SettingsDialog : public QDialog
QComboBox *resolution_combo_box;
QComboBox *fps_combo_box;
QLineEdit *bitrate_edit;
QComboBox *codec_combo_box;
QLineEdit *audio_buffer_size_edit;
QComboBox *audio_device_combo_box;
QCheckBox *pi_decoder_check_box;
@ -41,6 +42,7 @@ class SettingsDialog : public QDialog
void ResolutionSelected();
void FPSSelected();
void BitrateEdited();
void CodecSelected();
void AudioBufferSizeEdited();
void AudioOutputSelected();
void HardwareDecodeEngineSelected();

View file

@ -132,6 +132,24 @@ void Settings::SetBitrate(unsigned int 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
{
return 9600;
@ -202,7 +220,7 @@ ChiakiConnectVideoProfile Settings::GetVideoProfile()
unsigned int bitrate = GetBitrate();
if(bitrate)
profile.bitrate = bitrate;
profile.codec = CHIAKI_CODEC_H264; // TODO: add a setting
profile.codec = GetCodec();
return profile;
}

View file

@ -174,6 +174,21 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
connect(bitrate_edit, &QLineEdit::textEdited, this, &SettingsDialog::BitrateEdited);
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->setValidator(new QIntValidator(1024, 0x20000, audio_buffer_size_edit));
unsigned int audio_buffer_size = settings->GetAudioBufferSizeRaw();
@ -317,6 +332,11 @@ void SettingsDialog::BitrateEdited()
settings->SetBitrate(bitrate_edit->text().toUInt());
}
void SettingsDialog::CodecSelected()
{
settings->SetCodec((ChiakiCodec)codec_combo_box->currentData().toInt());
}
void SettingsDialog::AudioBufferSizeEdited()
{
settings->SetAudioBufferSize(audio_buffer_size_edit->text().toUInt());

View file

@ -68,7 +68,7 @@ StreamSession::StreamSession(const StreamSessionConnectInfo &connect_info, QObje
chiaki_log_sniffer_init(&sniffer, CHIAKI_LOG_ALL, GetChiakiLog());
ChiakiErrorCode err = chiaki_ffmpeg_decoder_init(ffmpeg_decoder,
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(),
FfmpegFrameCb, this);
if(err != CHIAKI_ERR_SUCCESS)

View file

@ -85,9 +85,10 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_lib_init();
typedef enum
{
// values must not change
CHIAKI_CODEC_H264 = 0,
CHIAKI_CODEC_H265,
CHIAKI_CODEC_H265_HDR
CHIAKI_CODEC_H265 = 1,
CHIAKI_CODEC_H265_HDR = 2
} ChiakiCodec;
static inline bool chiaki_codec_is_h265(ChiakiCodec codec)

View file

@ -971,6 +971,7 @@ static ChiakiErrorCode ctrl_connect(ChiakiCtrl *ctrl)
&& session->connect_info.video_profile_auto_downgrade
&& 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_connect_video_profile_preset(
&session->connect_info.video_profile,
@ -979,6 +980,13 @@ static ChiakiErrorCode ctrl_connect(ChiakiCtrl *ctrl)
? CHIAKI_VIDEO_FPS_PRESET_60
: 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
CHIAKI_LOGE(session->log, "No valid Server Type in ctrl response");

View file

@ -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)
{
profile->codec = CHIAKI_CODEC_H264;
switch(resolution)
{
case CHIAKI_VIDEO_RESOLUTION_PRESET_360p: