Skip to content

Commit

Permalink
UI: Fix multitrack video autoconfig option
Browse files Browse the repository at this point in the history
When using the Auto-Configuration Wizard with the
Twitch service, testing for Enhanced Broadcasting would
always run, even if deselected. Add a conditional check
to only run the test if selected.
  • Loading branch information
lexano-ivs authored and RytoEX committed Sep 10, 2024
1 parent de2e42b commit 97d9826
Showing 1 changed file with 77 additions and 65 deletions.
142 changes: 77 additions & 65 deletions UI/window-basic-auto-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,79 +422,91 @@ bool AutoConfigStreamPage::validatePage()
if (wiz->service == AutoConfig::Service::Twitch) {
wiz->testMultitrackVideo = ui->useMultitrackVideo->isChecked();

auto postData =
constructGoLivePost(QString::fromStdString(wiz->key),
std::nullopt, std::nullopt, false);

OBSDataAutoRelease service_settings =
obs_service_get_settings(service);
auto multitrack_video_name =
QTStr("Basic.Settings.Stream.MultitrackVideoLabel");
if (obs_data_has_user_value(service_settings,
"multitrack_video_name")) {
multitrack_video_name = obs_data_get_string(
service_settings, "multitrack_video_name");
}

try {
auto config = DownloadGoLiveConfig(
this, MultitrackVideoAutoConfigURL(service),
postData, multitrack_video_name);

for (const auto &endpoint : config.ingest_endpoints) {
if (qstrnicmp("RTMP", endpoint.protocol.c_str(),
4) != 0)
continue;

std::string address = endpoint.url_template;
auto pos = address.find("/{stream_key}");
if (pos != address.npos)
address.erase(pos);

wiz->serviceConfigServers.push_back(
{address, address});
if (wiz->testMultitrackVideo) {
auto postData = constructGoLivePost(
QString::fromStdString(wiz->key), std::nullopt,
std::nullopt, false);

OBSDataAutoRelease service_settings =
obs_service_get_settings(service);
auto multitrack_video_name = QTStr(
"Basic.Settings.Stream.MultitrackVideoLabel");
if (obs_data_has_user_value(service_settings,
"multitrack_video_name")) {
multitrack_video_name = obs_data_get_string(
service_settings,
"multitrack_video_name");
}

int multitrackVideoBitrate = 0;
for (auto &encoder_config :
config.encoder_configurations) {
auto it =
encoder_config.settings.find("bitrate");
if (it == encoder_config.settings.end())
continue;
try {
auto config = DownloadGoLiveConfig(
this,
MultitrackVideoAutoConfigURL(service),
postData, multitrack_video_name);

for (const auto &endpoint :
config.ingest_endpoints) {
if (qstrnicmp("RTMP",
endpoint.protocol.c_str(),
4) != 0)
continue;

std::string address =
endpoint.url_template;
auto pos =
address.find("/{stream_key}");
if (pos != address.npos)
address.erase(pos);

wiz->serviceConfigServers.push_back(
{address, address});
}

if (!it->is_number_integer())
continue;
int multitrackVideoBitrate = 0;
for (auto &encoder_config :
config.encoder_configurations) {
auto it = encoder_config.settings.find(
"bitrate");
if (it == encoder_config.settings.end())
continue;

int bitrate = 0;
it->get_to(bitrate);
multitrackVideoBitrate += bitrate;
}
if (!it->is_number_integer())
continue;

// grab a streamkey from the go live config if we can
for (auto &endpoint : config.ingest_endpoints) {
const char *p = endpoint.protocol.c_str();
const char *auth =
endpoint.authentication
? endpoint.authentication
->c_str()
: nullptr;
if (qstrnicmp("RTMP", p, 4) == 0 && auth &&
*auth) {
wiz->key = auth;
break;
int bitrate = 0;
it->get_to(bitrate);
multitrackVideoBitrate += bitrate;
}
}

if (multitrackVideoBitrate > 0) {
wiz->startingBitrate = multitrackVideoBitrate;
wiz->idealBitrate = multitrackVideoBitrate;
wiz->multitrackVideo.targetBitrate =
multitrackVideoBitrate;
wiz->multitrackVideo.testSuccessful = true;
// grab a streamkey from the go live config if we can
for (auto &endpoint : config.ingest_endpoints) {
const char *p =
endpoint.protocol.c_str();
const char *auth =
endpoint.authentication
? endpoint.authentication
->c_str()
: nullptr;
if (qstrnicmp("RTMP", p, 4) == 0 &&
auth && *auth) {
wiz->key = auth;
break;
}
}

if (multitrackVideoBitrate > 0) {
wiz->startingBitrate =
multitrackVideoBitrate;
wiz->idealBitrate =
multitrackVideoBitrate;
wiz->multitrackVideo.targetBitrate =
multitrackVideoBitrate;
wiz->multitrackVideo.testSuccessful =
true;
}
} catch (const MultitrackVideoError & /*err*/) {
// FIXME: do something sensible
}
} catch (const MultitrackVideoError & /*err*/) {
// FIXME: do something sensible
}
}

Expand Down

0 comments on commit 97d9826

Please sign in to comment.