diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt index 7a852690fd915b..ba08f87f565fe3 100644 --- a/UI/CMakeLists.txt +++ b/UI/CMakeLists.txt @@ -190,6 +190,7 @@ set(obs_SOURCES ${obs_PLATFORM_SOURCES} ${obs_libffutil_SOURCES} ../deps/json11/json11.cpp + pre-stream-wizard/pre-stream-current-settings.cpp pre-stream-wizard/pre-stream-wizard.cpp pre-stream-wizard/page-input-display.cpp pre-stream-wizard/page-start-prompt.cpp diff --git a/UI/common-settings.cpp b/UI/common-settings.cpp index 4bd4ab6a49c22a..444107c1fc5cc4 100644 --- a/UI/common-settings.cpp +++ b/UI/common-settings.cpp @@ -23,6 +23,7 @@ OBSData CommonSettings::GetDataFromJsonFile(const char *jsonFile) if (!data) data = obs_data_create(); + OBSData dataRet(data); obs_data_release(data); return dataRet; @@ -135,9 +136,7 @@ int CommonSettings::GetAudioChannelCount(config_t *config) int CommonSettings::GetStreamingAudioBitrate(config_t *config) { - bool isAdvancedMode = IsAdvancedMode(config); - - if (isAdvancedMode) { + if (IsAdvancedMode(config)) { return GetAdvancedAudioBitrate(config); } return GetSimpleAudioBitrate(config); @@ -164,10 +163,11 @@ int CommonSettings::GetAdvancedAudioBitrateForTrack(config_t *config, }; // Sanity check for out of bounds, clamp to bounds - if (trackIndex > 5) + if (trackIndex > 5) { trackIndex = 5; - if (trackIndex < 0) + } else if (trackIndex < 0) { trackIndex = 0; + } int bitrate = (int)config_get_uint(config, "AdvOut", names[trackIndex]); return FindClosestAvailableAACBitrate(bitrate); @@ -180,6 +180,5 @@ int CommonSettings::GetVideoBitrateInUse(config_t *config) } OBSData streamEncSettings = GetDataFromJsonFile("streamEncoder.json"); - int bitrate = obs_data_get_int(streamEncSettings, "bitrate"); - return bitrate; + return obs_data_get_int(streamEncSettings, "bitrate"); } diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index b3dbdad7a42e39..b86a8a3ddd4d38 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -712,13 +712,13 @@ Basic.Settings.Stream.MissingStreamKey="Stream key is missing.\n\nOpen settings Basic.Settings.Stream.PreLiveWizard.RunNow="Check stream settings" PreLiveWizard.Title="Verify Stream Settings" PreLiveWizard.Prompt.Title="Verify stream settings before stream" -PreLiveWizard.Prompt.Subtitle.Default="The streaming wizard suggests the most up-to-date settings to improve your stream’s reliability, quality, and latency. \n\nSelect the resolution to stream to your account:" +PreLiveWizard.Prompt.Subtitle.Default="The streaming wizard suggests the most up-to-date settings to improve your stream's reliability, quality, and latency. \n\nSelect the resolution to stream to your account:" PreLiveWizard.Prompt.Subtitle.FB="Your destination is set to Facebook Live." -PreLiveWizard.Prompt.Explainer="The Streaming wizard suggests the most up-to-date settings to improve your stream’s reliability, quality, and latency." +PreLiveWizard.Prompt.Explainer="The Streaming wizard suggests the most up-to-date settings to improve your stream's reliability, quality, and latency." PreLiveWizard.Prompt.ResSelectTitle="Select a resolution to stream:" -PreLiveWizard.Prompt.FBResolutionHelp.FB="If you’re unsure, click Open Facebook Live, then click on the \"Stream Health\" tab and scroll down to find your maximum resolution." -PreLiveWizard.Prompt.FBResolutionHelpButton.FB="Open Facebook Live" -PreLiveWizard.Prompt.FBResolutionHelpButton.FB.ToolTip="Opens Facebook Facebook Live in your default internet browser" +PreLiveWizard.Prompt.ResolutionHelp.FB="If you're unsure, click Open Facebook Live, then click on the \"Stream Health\" tab and scroll down to find your maximum resolution." +PreLiveWizard.Prompt.ResolutionHelpButton.FB="Open Facebook Live" +PreLiveWizard.Prompt.ResolutionHelpButton.FB.ToolTip="Open Facebook Live in your default web browser" PreLiveWizard.Prompt.Resolution.720="720p (Recommended for general purpose)" PreLiveWizard.Prompt.Resolution.1080="1080p (Recommended for gaming)" PreLiveWizard.Prompt.Resolution.Current="%1x%2 (Current setting)" @@ -727,18 +727,23 @@ PreLiveWizard.Configure.ServiceNotAvailable.Title="Service not supported" PreLiveWizard.Configure.ServiceNotAvailable.Description="The service selected in stream settings does not yet have an encoder configuration service." PreLiveWizard.Configure.Error.Url="Settings setup failed. Query: " PreLiveWizard.Configure.Error.JsonParse="Problem with server response" -PreLiveWizard.Configure.Error.JsonParse.Description="Wizard is unavailble at the moment." +PreLiveWizard.Configure.Error.JsonParse.Description="Wizard is unavailable at the moment." PreLiveWizard.Configure.Error.NoData="No new settings recieved." +PreLiveWizard.Configure.Error.NoData.Description=" " PreLiveWizard.Selection.Title="Suggested Settings" PreLiveWizard.Selection.Description="Suggested video settings for your best stream:" PreLiveWizard.Completed.Title="Encoder configured" PreLiveWizard.Completed.BodyText="Applied suggested settings and encoder is setup to stream. You can now close the wizard." PreLiveWizard.Completed.FacebookOnly="To finish going live go to Facebook Live:" PreLiveWizard.Error.Title="There was an issue verifying settings" -PreLiveWizard.Error.Subtitle="This doesn’t block you from starting your stream." +PreLiveWizard.Error.Subtitle="This doesn't block you from starting your stream." PreLiveWizard.Error.Generic.Headline="Encoder service is not working right now." PreLiveWizard.Error.Generic.BodyText="You can exit the wizard and try again." PreLiveWizard.Error.NetworkTimeout="Check your network connection before starting a stream." +PreLiveWizard.Output.Mode.CodecProfile="Profile" +PreLiveWizard.Output.Mode.CodecLevel="Level" +PreLiveWizard.Output.Mode.RateControl="Rate Control" +PreLiveWizard.Output.Mode.StreamBuffer="Stream Buffer" # basic mode 'output' settings Basic.Settings.Output="Output" @@ -754,10 +759,6 @@ Basic.Settings.Output.Mode="Output Mode" Basic.Settings.Output.Mode.Simple="Simple" Basic.Settings.Output.Mode.Adv="Advanced" Basic.Settings.Output.Mode.FFmpeg="FFmpeg Output" -Basic.Settings.Output.Mode.CodecProfile="Profile" -Basic.Settings.Output.Mode.CodecLevel="Level" -Basic.Settings.Output.Mode.RateControl="Rate Control" -Basic.Settings.Output.Mode.StreamBuffer="Stream Buffer" Basic.Settings.Output.UseReplayBuffer="Enable Replay Buffer" Basic.Settings.Output.ReplayBuffer.SecondsMax="Maximum Replay Time" Basic.Settings.Output.ReplayBuffer.MegabytesMax="Maximum Memory (Megabytes)" diff --git a/UI/pre-stream-wizard/encoder-settings-provider-facebook.cpp b/UI/pre-stream-wizard/encoder-settings-provider-facebook.cpp index 733f33c56909b2..34b29e6ff9293c 100644 --- a/UI/pre-stream-wizard/encoder-settings-provider-facebook.cpp +++ b/UI/pre-stream-wizard/encoder-settings-provider-facebook.cpp @@ -130,23 +130,9 @@ QUrlQuery FacebookEncoderSettingsProvider::inputVideoQueryFromCurrentSettings() return inputVideoSettingsQuery; } -QString FacebookEncoderSettingsProvider::getOBSVersionString() -{ - QString versionString; - -#ifdef HAVE_OBSCONFIG_H - versionString += OBS_VERSION; -#else - versionString += LIBOBS_API_MAJOR_VER + "." + LIBOBS_API_MINOR_VER + - "." + LIBOBS_API_PATCH_VER; -#endif - - return versionString; -} - // Helper methods for FacebookEncoderSettingsProvider::handleResponse void addInt(const QJsonObject &json, const char *jsonKey, SettingsMap *map, - const char *mapKey) + QString mapKey) { if (json[jsonKey].isDouble()) { map->insert(mapKey, @@ -159,7 +145,7 @@ void addInt(const QJsonObject &json, const char *jsonKey, SettingsMap *map, } void addStringDouble(const QJsonObject &json, const char *jsonKey, - SettingsMap *map, const char *mapKey) + SettingsMap *map, QString mapKey) { if (!json[jsonKey].isString()) { return; @@ -177,7 +163,7 @@ void addStringDouble(const QJsonObject &json, const char *jsonKey, } void addQString(const QJsonObject &json, const char *jsonKey, SettingsMap *map, - const char *mapKey) + QString mapKey) { if (json[jsonKey].isString()) { map->insert(mapKey, @@ -190,7 +176,7 @@ void addQString(const QJsonObject &json, const char *jsonKey, SettingsMap *map, } void addBool(const QJsonObject &json, const char *jsonKey, SettingsMap *map, - const char *mapKey) + QString mapKey) { if (json[jsonKey].isBool()) { map->insert(mapKey, @@ -224,51 +210,49 @@ void FacebookEncoderSettingsProvider::handleResponse(QByteArray reply) jsonParseError(); return; } - QJsonObject rmtpSettings = responseObject["rtmps_settings"].toObject(); + QJsonObject rtmpSettings = responseObject["rtmps_settings"].toObject(); // Get the video codec object - if (!rmtpSettings["video_codec_settings"].isObject()) { + if (!rtmpSettings["video_codec_settings"].isObject()) { blog(LOG_INFO, "FacebookEncoderSettingsProvider video_codec_settings not an object"); jsonParseError(); return; } - QJsonObject videoSettingsJsob = - rmtpSettings["video_codec_settings"].toObject(); + QJsonObject videoSettingsJson = + rtmpSettings["video_codec_settings"].toObject(); - if (videoSettingsJsob.isEmpty()) { + if (videoSettingsJson.isEmpty()) { handleEmpty(); } // Create map to send to wizard SettingsMap *settingsMap = new SettingsMap(); - addInt(videoSettingsJsob, "video_bitrate", settingsMap, - SettingsResponseKeys.videoBitrate); - addInt(videoSettingsJsob, "video_width", settingsMap, - SettingsResponseKeys.videoWidth); - addInt(videoSettingsJsob, "video_height", settingsMap, - SettingsResponseKeys.videoHeight); - addStringDouble(videoSettingsJsob, "video_framerate", settingsMap, - SettingsResponseKeys.framerate); - addQString(videoSettingsJsob, "video_h264_profile", settingsMap, - SettingsResponseKeys.h264Profile); - addQString(videoSettingsJsob, "video_h264_level", settingsMap, - SettingsResponseKeys.h264Level); - addInt(videoSettingsJsob, "video_gop_size", settingsMap, - SettingsResponseKeys.gopSizeInFrames); - addQString(videoSettingsJsob, "video_gop_type", settingsMap, - SettingsResponseKeys.gopType); - addBool(videoSettingsJsob, "video_gop_closed", settingsMap, - SettingsResponseKeys.gopClosed); - addInt(videoSettingsJsob, "video_gop_num_b_frames", settingsMap, - SettingsResponseKeys.gopBFrames); - addInt(videoSettingsJsob, "video_gop_num_ref_frames", settingsMap, - SettingsResponseKeys.gopRefFrames); - addQString(videoSettingsJsob, "rate_control_mode", settingsMap, - SettingsResponseKeys.streamRateControlMode); - addInt(videoSettingsJsob, "buffer_size", settingsMap, - SettingsResponseKeys.streamBufferSize); + addInt(videoSettingsJson, "video_bitrate", settingsMap, + kSettingsResponseKeys.videoBitrate); + addInt(videoSettingsJson, "video_width", settingsMap, + kSettingsResponseKeys.videoWidth); + addInt(videoSettingsJson, "video_height", settingsMap, + kSettingsResponseKeys.videoHeight); + addStringDouble(videoSettingsJson, "video_framerate", settingsMap, + kSettingsResponseKeys.framerate); + addQString(videoSettingsJson, "video_h264_profile", settingsMap, + kSettingsResponseKeys.h264Profile); + addQString(videoSettingsJson, "video_h264_level", settingsMap, + kSettingsResponseKeys.h264Level); + addInt(videoSettingsJson, "video_gop_size", settingsMap, + kSettingsResponseKeys.gopSizeInFrames); + addBool(videoSettingsJson, "video_gop_closed", settingsMap, + kSettingsResponseKeys.gopClosed); + addInt(videoSettingsJson, "video_gop_num_b_frames", settingsMap, + kSettingsResponseKeys.gopBFrames); + addInt(videoSettingsJson, "video_gop_num_ref_frames", settingsMap, + kSettingsResponseKeys.gopRefFrames); + addQString(videoSettingsJson, "rate_control_mode", settingsMap, + kSettingsResponseKeys.streamRateControlMode); + addInt(videoSettingsJson, "buffer_size", settingsMap, + kSettingsResponseKeys.streamBufferSize); // If Empty emit to empty / error state if (settingsMap->isEmpty()) { diff --git a/UI/pre-stream-wizard/encoder-settings-provider-facebook.hpp b/UI/pre-stream-wizard/encoder-settings-provider-facebook.hpp index b665f73bdcf74d..f32ec8914161c3 100644 --- a/UI/pre-stream-wizard/encoder-settings-provider-facebook.hpp +++ b/UI/pre-stream-wizard/encoder-settings-provider-facebook.hpp @@ -38,7 +38,6 @@ class FacebookEncoderSettingsProvider : public QObject { void makeRequest(QUrl &url); QUrlQuery inputVideoQueryFromCurrentSettings(); - QString getOBSVersionString(); void handleResponse(QByteArray reply); void handleTimeout(); void handleEmpty(); diff --git a/UI/pre-stream-wizard/page-completed.cpp b/UI/pre-stream-wizard/page-completed.cpp index 6db3416387757c..909c227ce757f6 100644 --- a/UI/pre-stream-wizard/page-completed.cpp +++ b/UI/pre-stream-wizard/page-completed.cpp @@ -37,10 +37,10 @@ CompletedPage::CompletedPage(Destination destination, QTStr("PreLiveWizard.Completed.FacebookOnly"), this); facebookGoLiveLabel->setWordWrap(true); QPushButton *launchButton = new QPushButton( - QTStr("PreLiveWizard.Prompt.FBResolutionHelpButton.FB"), + QTStr("PreLiveWizard.Prompt.ResolutionHelpButton.FB"), this); launchButton->setToolTip(QTStr( - "PreLiveWizard.Prompt.FBResolutionHelpButton.FB.ToolTip")); + "PreLiveWizard.Prompt.ResolutionHelpButton.FB.ToolTip")); connect(launchButton, &QPushButton::clicked, this, &CompletedPage::didPushOpenWebsite); diff --git a/UI/pre-stream-wizard/page-select-settings.cpp b/UI/pre-stream-wizard/page-select-settings.cpp index fd8be3bf909d59..e350ac4e3a0d79 100644 --- a/UI/pre-stream-wizard/page-select-settings.cpp +++ b/UI/pre-stream-wizard/page-select-settings.cpp @@ -60,119 +60,112 @@ void SelectionPage::setSettingsMap(QSharedPointer settingsMap) settingsMap_ = settingsMap; SettingsMap *mapInfo = settingsMap_.data(); - if (mapInfo->contains(SettingsResponseKeys.videoBitrate)) { + if (mapInfo->contains(kSettingsResponseKeys.videoBitrate)) { QVariant data = - mapInfo->value(SettingsResponseKeys.videoBitrate).first; + mapInfo->value(kSettingsResponseKeys.videoBitrate).first; QString bitrateString = QString::number(data.toInt()) + "kbps"; addRow(QTStr("Basic.Settings.Output.VideoBitrate"), - bitrateString, SettingsResponseKeys.videoBitrate); + bitrateString, kSettingsResponseKeys.videoBitrate); } - // Uses SettingsResponseKeys.videoHeight to signal change - if (mapInfo->contains(SettingsResponseKeys.videoWidth) && - mapInfo->contains(SettingsResponseKeys.videoHeight)) { - int vidW = mapInfo->value(SettingsResponseKeys.videoWidth) + // Uses kSettingsResponseKeys.videoHeight to signal change + if (mapInfo->contains(kSettingsResponseKeys.videoWidth) && + mapInfo->contains(kSettingsResponseKeys.videoHeight)) { + int vidW = mapInfo->value(kSettingsResponseKeys.videoWidth) .first.toInt(); QString videoWidthString = QString::number(vidW); - int vidH = mapInfo->value(SettingsResponseKeys.videoHeight) + int vidH = mapInfo->value(kSettingsResponseKeys.videoHeight) .first.toInt(); QString videoHeightString = QString::number(vidH); QString valueString = videoWidthString + "x" + videoHeightString; addRow(QTStr("Basic.Settings.Video.ScaledResolution"), - valueString, SettingsResponseKeys.videoHeight); + valueString, kSettingsResponseKeys.videoHeight); } - if (mapInfo->contains(SettingsResponseKeys.framerate)) { + if (mapInfo->contains(kSettingsResponseKeys.framerate)) { QVariant data = - mapInfo->value(SettingsResponseKeys.framerate).first; + mapInfo->value(kSettingsResponseKeys.framerate).first; double framerate = data.toDouble(); - QString fpsString = QString().sprintf("%.3f", framerate); + QString fpsString = QString().asprintf("%.3f", framerate); addRow(QTStr("Basic.Settings.Video.FPS"), fpsString, - SettingsResponseKeys.framerate); + kSettingsResponseKeys.framerate); } - if (mapInfo->contains(SettingsResponseKeys.h264Profile)) { + if (mapInfo->contains(kSettingsResponseKeys.h264Profile)) { QVariant data = - mapInfo->value(SettingsResponseKeys.h264Profile).first; + mapInfo->value(kSettingsResponseKeys.h264Profile).first; QString profileString = data.toString(); - addRow(QTStr("Basic.Settings.Output.Mode.CodecProfile"), - profileString, SettingsResponseKeys.h264Profile); + addRow(QTStr("PreLiveWizard.Output.Mode.CodecProfile"), + profileString, kSettingsResponseKeys.h264Profile); } - if (mapInfo->contains(SettingsResponseKeys.h264Level)) { + if (mapInfo->contains(kSettingsResponseKeys.h264Level)) { QVariant data = - mapInfo->value(SettingsResponseKeys.h264Level).first; + mapInfo->value(kSettingsResponseKeys.h264Level).first; QString level = data.toString(); - addRow(QTStr("Basic.Settings.Output.Mode.CodecLevel"), level, - SettingsResponseKeys.h264Level); + addRow(QTStr("PreLiveWizard.Output.Mode.CodecLevel"), level, + kSettingsResponseKeys.h264Level); } - if (mapInfo->contains(SettingsResponseKeys.gopSizeInFrames)) { + if (mapInfo->contains(kSettingsResponseKeys.gopSizeInFrames)) { QVariant data = - mapInfo->value(SettingsResponseKeys.gopSizeInFrames) + mapInfo->value(kSettingsResponseKeys.gopSizeInFrames) .first; QString gopFramesString = QString::number(data.toInt()); addRow(QTStr("Basic.Settings.Output.Adv.FFmpeg.GOPSize"), - gopFramesString, SettingsResponseKeys.gopSizeInFrames); + gopFramesString, kSettingsResponseKeys.gopSizeInFrames); } - if (mapInfo->contains(SettingsResponseKeys.gopType)) { + if (mapInfo->contains(kSettingsResponseKeys.gopClosed)) { QVariant data = - mapInfo->value(SettingsResponseKeys.gopType).first; - QString gopTypeString = data.toString(); - addRow(QTStr("Basic.Settings.Output.Adv.FFmpeg.GOPType"), - gopTypeString, SettingsResponseKeys.gopType); - } - - if (mapInfo->contains(SettingsResponseKeys.gopClosed)) { - QVariant data = - mapInfo->value(SettingsResponseKeys.gopClosed).first; + mapInfo->value(kSettingsResponseKeys.gopClosed).first; QString gopClosedString = data.toBool() ? QTStr("Yes") : QTStr("No"); addRow(QTStr("Basic.Settings.Output.Adv.FFmpeg.GOPClosed"), - gopClosedString, SettingsResponseKeys.gopClosed); + gopClosedString, kSettingsResponseKeys.gopClosed); } - if (mapInfo->contains(SettingsResponseKeys.gopBFrames)) { + if (mapInfo->contains(kSettingsResponseKeys.gopBFrames)) { QVariant data = - mapInfo->value(SettingsResponseKeys.gopBFrames).first; + mapInfo->value(kSettingsResponseKeys.gopBFrames).first; QString bFramesString = QString::number(data.toInt()); addRow(QTStr("Basic.Settings.Output.Adv.FFmpeg.BFrames"), - bFramesString, SettingsResponseKeys.gopBFrames); + bFramesString, kSettingsResponseKeys.gopBFrames); } - if (mapInfo->contains(SettingsResponseKeys.gopRefFrames)) { + if (mapInfo->contains(kSettingsResponseKeys.gopRefFrames)) { QVariant data = - mapInfo->value(SettingsResponseKeys.gopRefFrames).first; + mapInfo->value(kSettingsResponseKeys.gopRefFrames).first; QString gopRefFramesCountString = QString::number(data.toInt()); addRow(QTStr("Basic.Settings.Output.Adv.FFmpeg.ReferenceFrames"), gopRefFramesCountString, - SettingsResponseKeys.gopRefFrames); + kSettingsResponseKeys.gopRefFrames); } - if (mapInfo->contains(SettingsResponseKeys.streamRateControlMode)) { - QVariant data = mapInfo->value(SettingsResponseKeys + if (mapInfo->contains(kSettingsResponseKeys.streamRateControlMode)) { + QVariant data = mapInfo->value(kSettingsResponseKeys .streamRateControlMode) .first; QString rateControlString = data.toString().toUpper(); - addRow(QTStr("Basic.Settings.Output.Mode.RateControl"), + addRow(QTStr("PreLiveWizard.Output.Mode.RateControl"), rateControlString, - SettingsResponseKeys.streamRateControlMode); + kSettingsResponseKeys.streamRateControlMode); } - if (mapInfo->contains(SettingsResponseKeys.streamBufferSize)) { + if (mapInfo->contains(kSettingsResponseKeys.streamBufferSize)) { QVariant data = - mapInfo->value(SettingsResponseKeys.streamBufferSize) + mapInfo->value(kSettingsResponseKeys.streamBufferSize) .first; QString bufferSizeString = QString::number(data.toInt()) + "Kb"; - addRow(QTStr("Basic.Settings.Output.Mode.StreamBuffer"), - bufferSizeString, SettingsResponseKeys.streamBufferSize); + addRow(QTStr("PreLiveWizard.Output.Mode.StreamBuffer"), + bufferSizeString, + kSettingsResponseKeys.streamBufferSize); } } -void SelectionPage::addRow(QString title, QString value, const char *mapKey) +void SelectionPage::addRow(QString title, QString value, QString mapKey) { SelectionRow *row = new SelectionRow(); row->setName(title); @@ -183,7 +176,7 @@ void SelectionPage::addRow(QString title, QString value, const char *mapKey) &SelectionPage::checkboxRowChanged); } -void SelectionPage::checkboxRowChanged(const char *propertyKey, bool selected) +void SelectionPage::checkboxRowChanged(QString propertyKey, bool selected) { if (settingsMap_ == nullptr) { return; diff --git a/UI/pre-stream-wizard/page-select-settings.hpp b/UI/pre-stream-wizard/page-select-settings.hpp index 1d31ee1a89d1fb..fb859a6af59262 100644 --- a/UI/pre-stream-wizard/page-select-settings.hpp +++ b/UI/pre-stream-wizard/page-select-settings.hpp @@ -31,7 +31,7 @@ class SelectionPage : public QWizardPage { void mapContainsVariant(); // Adds a row only if map contains values for it - void addRow(QString title, QString value, const char *mapKey); + void addRow(QString title, QString value, QString mapKey); // Data QSharedPointer settingsMap_; @@ -43,7 +43,7 @@ class SelectionPage : public QWizardPage { QVBoxLayout *scrollVBoxLayout_; private slots: - void checkboxRowChanged(const char *propertyKey, bool selected); + void checkboxRowChanged(QString propertyKey, bool selected); }; // class SelectionPage diff --git a/UI/pre-stream-wizard/page-start-prompt.cpp b/UI/pre-stream-wizard/page-start-prompt.cpp index f18fbcdd159c31..080a9cab16e580 100644 --- a/UI/pre-stream-wizard/page-start-prompt.cpp +++ b/UI/pre-stream-wizard/page-start-prompt.cpp @@ -76,14 +76,13 @@ void StartPage::createLayout() if (destination_ == Destination::Facebook) { // If FB, specfic help section helpLabel = new QLabel( - QTStr("PreLiveWizard.Prompt.FBResolutionHelp.FB"), - this); + QTStr("PreLiveWizard.Prompt.ResolutionHelp.FB"), this); helpLabel->setWordWrap(true); helpButton = new QPushButton( - QTStr("PreLiveWizard.Prompt.FBResolutionHelpButton.FB"), + QTStr("PreLiveWizard.Prompt.ResolutionHelpButton.FB"), this); helpButton->setToolTip(QTStr( - "PreLiveWizard.Prompt.FBResolutionHelpButton.FB.ToolTip")); + "PreLiveWizard.Prompt.ResolutionHelpButton.FB.ToolTip")); connect(helpButton, &QPushButton::clicked, this, &StartPage::didPushOpenWebsiteHelp); } diff --git a/UI/pre-stream-wizard/pre-stream-current-settings.cpp b/UI/pre-stream-wizard/pre-stream-current-settings.cpp new file mode 100644 index 00000000000000..751e5aa47d0bc9 --- /dev/null +++ b/UI/pre-stream-wizard/pre-stream-current-settings.cpp @@ -0,0 +1,22 @@ +#include "pre-stream-current-settings.hpp" + +namespace StreamWizard { + +SettingsResponseKeys kSettingsResponseKeys = { + "videoWidth", + "videoHeight", + "framerate", + "videoBitrate", + "protocol", + "videoCodec", + "h264Profile", + "h264Level", + "gopSizeInFrames", + "gopClosed", + "gopBFrames", + "gopRefFrames", + "streamRateControlMode", + "streamBufferSize", +}; + +} // namespace StreamWizard diff --git a/UI/pre-stream-wizard/pre-stream-current-settings.hpp b/UI/pre-stream-wizard/pre-stream-current-settings.hpp index 86ddaf01781b65..ad268e8584cc4c 100644 --- a/UI/pre-stream-wizard/pre-stream-current-settings.hpp +++ b/UI/pre-stream-wizard/pre-stream-current-settings.hpp @@ -73,35 +73,29 @@ struct EncoderSettingsRequest { }; // Map for the repsonse passed to UI and settings is: -using SettingsMap = QMap>; +using SettingsMap = QMap>; // where String = map key from kSettingsResponseKeys, and // where QVariant is the Settings value, and // where bool is if the user wants to apply the settings // Keys for new settings QMap -static const struct { - const char *videoWidth; //int - const char *videoHeight; //int - const char *framerate; // double (FPS) - const char *videoBitrate; //int - const char *protocol; // string - const char *videoCodec; // string - const char *h264Profile; // string ("High") - const char *h264Level; // string ("4.1") - const char *gopSizeInFrames; // int - const char *gopType; // string ("fixed") - const char *gopClosed; // bool - const char *gopBFrames; // int - const char *gopRefFrames; // int - const char *streamRateControlMode; // string "CBR" - const char *streamBufferSize; // int (5000 kb) -} SettingsResponseKeys = { - "videoWidth", "videoHeight", - "framerate", "videoBitrate", - "protocol", "videoCodec", - "h264Profile", "h264Level", - "gopSizeInFrames", "gopType", - "gopClosed", "gopBFrames", - "gopRefFrames", "streamRateControlMode", - "streamBufferSize", +struct SettingsResponseKeys { + QString videoWidth; //int + QString videoHeight; //int + QString framerate; // double (FPS) + QString videoBitrate; //int + QString protocol; // string + QString videoCodec; // string + QString h264Profile; // string ("High") + QString h264Level; // string ("4.1") + QString gopSizeInFrames; // int + QString gopClosed; // bool + QString gopBFrames; // int + QString gopRefFrames; // int + QString streamRateControlMode; // string "CBR" + QString streamBufferSize; // int (5000 kb) }; -} + +// Defined in pre-stream-current-settings.cpp +extern SettingsResponseKeys kSettingsResponseKeys; + +} // namespace StreamWizard diff --git a/UI/pre-stream-wizard/setting-selection-row.cpp b/UI/pre-stream-wizard/setting-selection-row.cpp index 86fe8012b07880..321d5e4e62a401 100644 --- a/UI/pre-stream-wizard/setting-selection-row.cpp +++ b/UI/pre-stream-wizard/setting-selection-row.cpp @@ -60,12 +60,12 @@ QString SelectionRow::getValueLabel() return valueLabel_; } -void SelectionRow::setPropertyKey(const char *newKey) +void SelectionRow::setPropertyKey(QString newKey) { propertyKey_ = newKey; } -const char *SelectionRow::getPropertyKey() +QString SelectionRow::getPropertyKey() { return propertyKey_; } diff --git a/UI/pre-stream-wizard/setting-selection-row.hpp b/UI/pre-stream-wizard/setting-selection-row.hpp index 3e941ec5469946..1492d3b7981b7d 100644 --- a/UI/pre-stream-wizard/setting-selection-row.hpp +++ b/UI/pre-stream-wizard/setting-selection-row.hpp @@ -31,12 +31,12 @@ class SelectionRow : public QWidget { QString getValueLabel(); // Key to mapping property to Settings Map - void setPropertyKey(const char *newKey); - const char *getPropertyKey(); + void setPropertyKey(QString newKey); + QString getPropertyKey(); signals: // User changed if they want to apply an option - void didChangeSelectedStatus(const char *propertyKey, bool selected); + void didChangeSelectedStatus(QString propertyKey, bool selected); private: void createLayout(); @@ -46,7 +46,7 @@ class SelectionRow : public QWidget { // Visual from upper class QString name_; QString valueLabel_; - const char *propertyKey_; + QString propertyKey_; // Layout and subwidgets QString separator_ = ": "; diff --git a/UI/streaming-settings-util.cpp b/UI/streaming-settings-util.cpp index 4010c7bee09f3a..ce80fde3c4078f 100644 --- a/UI/streaming-settings-util.cpp +++ b/UI/streaming-settings-util.cpp @@ -43,7 +43,7 @@ StreamingSettingsUtility::makeEncoderSettingsFromCurrentState(config_t *config) /* * StreamWizard::SettingsMap is sparse in that it wont have all keys * as well, the user can opt out of settings being applied. -* The map looks like [ SettingsResponseKeys : QPair ] +* The map looks like [ kSettingsResponseKeys : QPair ] * AKA [KEY : SetttingPair ] * if the key is available, it means the wizard provider added a value for it * but the bool in the QPair is false if the user selected in the wizard not to @@ -52,7 +52,7 @@ StreamingSettingsUtility::makeEncoderSettingsFromCurrentState(config_t *config) * Returns TRUE is map contrains something for the key and it is marked true */ -bool CheckInMapAndSelected(StreamWizard::SettingsMap *map, const char *key) +bool CheckInMapAndSelected(StreamWizard::SettingsMap *map, QString key) { if (!map->contains(key)) { return false; @@ -62,28 +62,28 @@ bool CheckInMapAndSelected(StreamWizard::SettingsMap *map, const char *key) } // Helper Functions for ::applyWizardSettings -int intFromMap(StreamWizard::SettingsMap *map, const char *key) +int intFromMap(StreamWizard::SettingsMap *map, QString key) { QPair settingPair = map->value(key); QVariant data = settingPair.first; return data.toInt(); } -QString stringFromMap(StreamWizard::SettingsMap *map, const char *key) +QString stringFromMap(StreamWizard::SettingsMap *map, QString key) { QPair settingPair = map->value(key); QVariant data = settingPair.first; return data.toString(); } -double doubleFromMap(StreamWizard::SettingsMap *map, const char *key) +double doubleFromMap(StreamWizard::SettingsMap *map, QString key) { QPair settingPair = map->value(key); QVariant data = settingPair.first; return data.toDouble(); } -bool boolFromMap(StreamWizard::SettingsMap *map, const char *key) +bool boolFromMap(StreamWizard::SettingsMap *map, QString key) { QPair settingPair = map->value(key); QVariant data = settingPair.first; @@ -91,7 +91,7 @@ bool boolFromMap(StreamWizard::SettingsMap *map, const char *key) } /* -* Given a settings map [ SettingsResponseKeys : QPair ] apply +* Given a settings map [ kSettingsResponseKeys : QPair ] apply * settings that are in the sparse map as well selected by the user (which is * marked by the bool in the pair). * Apply to Basic encoder settings. @@ -113,20 +113,21 @@ void StreamingSettingsUtility::applyWizardSettings( config_set_bool(config, "SimpleOutput", "UseAdvanced", true); // Resolution must have both - if (CheckInMapAndSelected(map, SettingsResponseKeys.videoHeight) && - CheckInMapAndSelected(map, SettingsResponseKeys.videoWidth)) { + if (CheckInMapAndSelected(map, kSettingsResponseKeys.videoHeight) && + CheckInMapAndSelected(map, kSettingsResponseKeys.videoWidth)) { - int canvasX = intFromMap(map, SettingsResponseKeys.videoWidth); - int canvasY = intFromMap(map, SettingsResponseKeys.videoHeight); + int canvasX = intFromMap(map, kSettingsResponseKeys.videoWidth); + int canvasY = + intFromMap(map, kSettingsResponseKeys.videoHeight); config_set_uint(config, "Video", "OutputCX", canvasX); config_set_uint(config, "Video", "OutputCY", canvasY); } //TODO: FPS is hacky but covers all integer and standard drop frame cases - if (CheckInMapAndSelected(map, SettingsResponseKeys.framerate)) { + if (CheckInMapAndSelected(map, kSettingsResponseKeys.framerate)) { double currentFPS = CommonSettings::GetConfigFPSDouble(config); double newFPS = - doubleFromMap(map, SettingsResponseKeys.framerate); + doubleFromMap(map, kSettingsResponseKeys.framerate); if (abs(currentFPS - newFPS) > 0.001) { // Only change if different if (abs(floor(newFPS) - newFPS) > @@ -146,40 +147,34 @@ void StreamingSettingsUtility::applyWizardSettings( } } - if (CheckInMapAndSelected(map, SettingsResponseKeys.videoBitrate)) { + if (CheckInMapAndSelected(map, kSettingsResponseKeys.videoBitrate)) { int newBitrate = - intFromMap(map, SettingsResponseKeys.videoBitrate); + intFromMap(map, kSettingsResponseKeys.videoBitrate); config_set_int(config, "SimpleOutput", "VBitrate", newBitrate); } - if (CheckInMapAndSelected(map, SettingsResponseKeys.h264Profile)) { + if (CheckInMapAndSelected(map, kSettingsResponseKeys.h264Profile)) { QString profile = - stringFromMap(map, SettingsResponseKeys.h264Profile); + stringFromMap(map, kSettingsResponseKeys.h264Profile); profile = profile.toLower(); x264SettingList.append("profile=" + profile); } - if (CheckInMapAndSelected(map, SettingsResponseKeys.h264Level)) { + if (CheckInMapAndSelected(map, kSettingsResponseKeys.h264Level)) { QString levelString = - stringFromMap(map, SettingsResponseKeys.h264Level); + stringFromMap(map, kSettingsResponseKeys.h264Level); x264SettingList.append("level=" + levelString); } - if (CheckInMapAndSelected(map, SettingsResponseKeys.gopSizeInFrames)) { + if (CheckInMapAndSelected(map, kSettingsResponseKeys.gopSizeInFrames)) { int gopSize = - intFromMap(map, SettingsResponseKeys.gopSizeInFrames); + intFromMap(map, kSettingsResponseKeys.gopSizeInFrames); x264SettingList.append("keyint=" + QString::number(gopSize)); } - if (CheckInMapAndSelected(map, SettingsResponseKeys.gopType)) { - QString gopType = - stringFromMap(map, SettingsResponseKeys.gopType); - x264SettingList.append("slice_mode=" + gopType); - } - - if (CheckInMapAndSelected(map, SettingsResponseKeys.gopClosed)) { + if (CheckInMapAndSelected(map, kSettingsResponseKeys.gopClosed)) { bool gopClose = - boolFromMap(map, SettingsResponseKeys.gopClosed); + boolFromMap(map, kSettingsResponseKeys.gopClosed); if (gopClose) { x264SettingList.append("open_gop=0"); } else { @@ -187,29 +182,31 @@ void StreamingSettingsUtility::applyWizardSettings( } } - if (CheckInMapAndSelected(map, SettingsResponseKeys.gopBFrames)) { - int bFrames = intFromMap(map, SettingsResponseKeys.gopBFrames); + if (CheckInMapAndSelected(map, kSettingsResponseKeys.gopBFrames)) { + int bFrames = intFromMap(map, kSettingsResponseKeys.gopBFrames); x264SettingList.append("bframes=" + QString::number(bFrames)); } - if (CheckInMapAndSelected(map, SettingsResponseKeys.gopRefFrames)) { + if (CheckInMapAndSelected(map, kSettingsResponseKeys.gopRefFrames)) { int refFrames = - intFromMap(map, SettingsResponseKeys.gopRefFrames); + intFromMap(map, kSettingsResponseKeys.gopRefFrames); x264SettingList.append("ref=" + QString::number(refFrames)); } - // SettingsResponseKeys.streamRateControlMode defaults to CBR in Simple + // kSettingsResponseKeys.streamRateControlMode defaults to CBR in Simple // encoder mode. Can add later for advanced panel. - if (CheckInMapAndSelected(map, SettingsResponseKeys.streamBufferSize)) { + if (CheckInMapAndSelected(map, + kSettingsResponseKeys.streamBufferSize)) { int bufferSize = - intFromMap(map, SettingsResponseKeys.streamBufferSize); - x264SettingList.append("bufsize=" + + intFromMap(map, kSettingsResponseKeys.streamBufferSize); + x264SettingList.append("vbv-bufsize=" + QString::number(bufferSize)); } - QString x264String = x264SettingList.join(" "); - const char *x264_c_String = x264String.toStdString().c_str(); + std::string x264String = + x264SettingList.join(" ").toUtf8().toStdString(); + const char *x264_c_String = x264String.c_str(); config_set_string(config, "SimpleOutput", "x264Settings", x264_c_String); };