Skip to content

Commit

Permalink
UI: Pre-stream wizard show & hide button correctly
Browse files Browse the repository at this point in the history
Show pre-stream wizard only when in simple mode since it only operates
on simple mode for now. Later, will look into expanding capability.
Additionally, fix a bug where was making a copy of a QPair instead of
creating a reference so settings were not being written.
  • Loading branch information
JohannMG committed Oct 8, 2020
1 parent b191c7c commit 5414d37
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 40 deletions.
2 changes: 1 addition & 1 deletion UI/common-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "audio-encoders.hpp"

static bool IsAdvancedMode(config_t *config)
bool CommonSettings::IsAdvancedMode(config_t *config)
{
const char *outputMode = config_get_string(config, "Output", "Mode");
return (strcmp(outputMode, "Advanced") == 0);
Expand Down
1 change: 1 addition & 0 deletions UI/common-settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class CommonSettings {

public:
static bool IsAdvancedMode(config_t *config);
/* Shared Utility Functions --------------------------*/
static OBSData GetDataFromJsonFile(const char *jsonFile);

Expand Down
7 changes: 2 additions & 5 deletions UI/pre-stream-wizard/page-select-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <QSpacerItem>
#include <QPushButton>
#include <QDesktopServices>
#include <QDebug>
#include <QVariant>
#include <QPair>

Expand Down Expand Up @@ -167,8 +166,7 @@ void SelectionPage::setSettingsMap(QSharedPointer<SettingsMap> settingsMap)
QVariant data =
mapInfo->value(SettingsResponseKeys.streamBufferSize)
.first;
QString bufferSizeString =
QString::number(data.toInt()) + " Kb";
QString bufferSizeString = QString::number(data.toInt()) + "Kb";
addRow(QTStr("Basic.Settings.Output.Mode.StreamBuffer"),
bufferSizeString, SettingsResponseKeys.streamBufferSize);
}
Expand All @@ -192,12 +190,11 @@ void SelectionPage::checkboxRowChanged(const char *propertyKey, bool selected)
}

SettingsMap *mapInfo = settingsMap_.data();

if (mapInfo == nullptr || !mapInfo->contains(propertyKey)) {
return;
}

QPair dataPair = mapInfo->value(propertyKey);
QPair<QVariant, bool> &dataPair = (*mapInfo)[propertyKey];
dataPair.second = selected;
}

Expand Down
37 changes: 4 additions & 33 deletions UI/streaming-settings-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,6 @@

#include <QPair>

/*
We are detecting the stream settings so if they're using a large canvas but
already have the rescaler on, they will be streaming correctly.
*/
void UpdateStreamingResolution(int *resolutionXY, bool isRescaled,
config_t *config)
{

// If scaled, that's the stream resolution sent to servers
if (isRescaled) {
// Only use if there is a resolution in text
const char *rescaleRes =
config_get_string(config, "AdvOut", "RescaleRes");
if (rescaleRes && *rescaleRes) {
int count = sscanf(rescaleRes, "%ux%u",
&resolutionXY[0], &resolutionXY[1]);
// If text was valid, exit
if (count == 2) {
return;
}
}
}

// Resolution is not rescaled, use "output resolution" from video tab
resolutionXY[0] = (int)config_get_uint(config, "Video", "OutputCX");
resolutionXY[1] = (int)config_get_uint(config, "Video", "OutputCY");
};

QSharedPointer<StreamWizard::EncoderSettingsRequest>
StreamingSettingsUtility::makeEncoderSettingsFromCurrentState(config_t *config)
{
Expand All @@ -45,11 +17,10 @@ StreamingSettingsUtility::makeEncoderSettingsFromCurrentState(config_t *config)
// only live and rmpts is supported for now
currentSettings->protocol = StreamWizard::StreamProtocol::rtmps;
/* Video */
bool isRescaled = config_get_bool(config, "AdvOut", "Rescale");
int resolutionXY[2] = {0, 0};
UpdateStreamingResolution(resolutionXY, isRescaled, config);
currentSettings->videoWidth = resolutionXY[0];
currentSettings->videoHeight = resolutionXY[1];
currentSettings->videoWidth =
(int)config_get_uint(config, "Video", "OutputCX");
currentSettings->videoHeight =
(int)config_get_uint(config, "Video", "OutputCY");
currentSettings->framerate = CommonSettings::GetConfigFPSDouble(config);

currentSettings->videoBitrate =
Expand Down
8 changes: 7 additions & 1 deletion UI/window-basic-settings-stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ void OBSBasicSettings::UpdateKeyLink()
ui->getStreamKeyButton->setTargetUrl(QUrl(streamKeyLink));
ui->getStreamKeyButton->show();
}

hasStreamWizard &= ui->outputMode->currentText().contains("Simple");
ui->settingWizardBtn->setHidden(!hasStreamWizard);
}

Expand All @@ -267,6 +269,9 @@ void OBSBasicSettings::preStreamWizardLaunch()
return;
}

// Save any changes so far since we'll refrence them from config files
SaveSettings();

QSharedPointer<StreamWizard::EncoderSettingsRequest> currentSettings =
StreamingSettingsUtility::makeEncoderSettingsFromCurrentState(
main->Config());
Expand All @@ -287,10 +292,11 @@ void OBSBasicSettings::preStreamWizardApplySettings(
{
blog(LOG_INFO, "OBSBasicSettings::preStreamWizardApplySettings");

// Apply and reload
// Apply
StreamingSettingsUtility::applyWizardSettings(newSettings,
main->Config());

// Reload
LoadSettings(false);
}

Expand Down
2 changes: 2 additions & 0 deletions UI/window-basic-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
SLOT(UpdateStreamDelayEstimate()));
connect(ui->outputMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(UpdateStreamDelayEstimate()));
connect(ui->outputMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(UpdateKeyLink()));
connect(ui->simpleOutputVBitrate, SIGNAL(valueChanged(int)), this,
SLOT(UpdateStreamDelayEstimate()));
connect(ui->simpleOutputABitrate, SIGNAL(currentIndexChanged(int)),
Expand Down

0 comments on commit 5414d37

Please sign in to comment.