Skip to content

Commit ce077e2

Browse files
Refined constructGoLivePost for enhanced broadcasting to accept desired canvases
1 parent 9bf5f0f commit ce077e2

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

obs-studio-server/source/nodeobs_service.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,17 @@ bool OBS_service::startMultiTrackStreaming(StreamServiceId serviceId, bool dualS
13731373

13741374
auto vod_track_mixer = IsVodTrackEnabled(services[serviceId]) ? std::optional{vodTrackIndex} : std::nullopt;
13751375

1376-
auto go_live_post = osn::constructGoLivePost(serviceId, dualStreamingMode, key, std::nullopt, std::nullopt, vod_track_mixer.has_value());
1376+
std::vector<obs_video_info*> canvases;
1377+
canvases.push_back(videoInfo[serviceId]);
1378+
if (dualStreamingMode) {
1379+
if (serviceId == StreamServiceId::Main) {
1380+
canvases.push_back(videoInfo[StreamServiceId::Second]);
1381+
} else if (serviceId == StreamServiceId::Second) {
1382+
canvases.push_back(videoInfo[StreamServiceId::Main]);
1383+
}
1384+
}
1385+
1386+
auto go_live_post = osn::constructGoLivePost(canvases, key, std::nullopt, std::nullopt, vod_track_mixer.has_value());
13771387
std::optional<osn::Config> go_live_config = osn::DownloadGoLiveConfig(auto_config_url, go_live_post);
13781388
if (!go_live_config.has_value()) {
13791389
throw std::runtime_error("startStreaming - go live config is empty");

obs-studio-server/source/osn-multitrack-video-configuration.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,11 @@ std::string MultitrackVideoAutoConfigURL(obs_service_t *service)
218218
return url;
219219
}
220220

221-
PostData constructGoLivePost(StreamServiceId serviceId, bool dualStreamingMode, std::string streamKey, const std::optional<uint64_t> &maximum_aggregate_bitrate,
222-
const std::optional<uint32_t> &maximum_video_tracks, bool vod_track_enabled)
221+
PostData constructGoLivePost(std::vector<obs_video_info*> canvases,
222+
std::string streamKey,
223+
const std::optional<uint64_t> &maximum_aggregate_bitrate,
224+
const std::optional<uint32_t> &maximum_video_tracks,
225+
bool vod_track_enabled)
223226
{
224227
PostData post_data{};
225228
post_data.service = "IVS";
@@ -255,6 +258,19 @@ PostData constructGoLivePost(StreamServiceId serviceId, bool dualStreamingMode,
255258
if (obs_get_video_info(&ovi))
256259
preferences.composition_gpu_index = ovi.adapter;
257260

261+
262+
for (const auto& c : canvases) {
263+
if (!c) {
264+
blog(LOG_WARNING, "constructGoLivePost - empty canvas, skipping");
265+
continue;
266+
}
267+
268+
preferences.canvases.emplace_back(
269+
Canvas{c->output_width, c->output_height, c->base_width, c->base_height, {c->fps_num, c->fps_den}});
270+
}
271+
272+
// TODO: remove
273+
/*
258274
const size_t contexts = obs_get_video_info_count();
259275
for (size_t i = 0; i < contexts; i++) {
260276
if (obs_get_video_info_by_index(i, &ovi)) {
@@ -273,6 +289,7 @@ PostData constructGoLivePost(StreamServiceId serviceId, bool dualStreamingMode,
273289
Canvas{ovi.output_width, ovi.output_height, ovi.base_width, ovi.base_height, {ovi.fps_num, ovi.fps_den}});
274290
}
275291
}
292+
*/
276293

277294
obs_audio_info2 oai2;
278295
if (obs_get_audio_info2(&oai2)) {

obs-studio-server/source/osn-multitrack-video-configuration.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77

88
#include <optional>
99
#include <string>
10+
#include <vector>
1011

1112
namespace osn {
1213

1314
std::string MultitrackVideoAutoConfigURL(obs_service_t *service);
1415

1516
Config DownloadGoLiveConfig(std::string url, const PostData &post_data);
1617

17-
PostData constructGoLivePost(StreamServiceId serviceId, bool dualStreamingMode, std::string streamKey, const std::optional<uint64_t> &maximum_aggregate_bitrate,
18+
PostData constructGoLivePost(std::vector<obs_video_info*> canvases, std::string streamKey, const std::optional<uint64_t> &maximum_aggregate_bitrate,
1819
const std::optional<uint32_t> &maximum_video_tracks, bool vod_track_enabled);
1920

2021
}

obs-studio-server/source/osn-multitrack-video-system-info.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ void system_info(Capabilities &capabilities)
241241
system_data.build = ver.build;
242242
system_data.release = win_release_id;
243243
system_data.revision = std::to_string(ver.revis);
244-
;
245244
system_data.bits = is_64_bit_windows() ? 64 : 32;
246245
system_data.arm = is_arm64_windows();
247246
system_data.armEmulation = os_get_emulation_status();

obs-studio-server/source/osn-streaming.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,7 @@ void osn::Streaming::StartEnhancedBroadcastingStream(std::optional<size_t> vod_t
446446
auto auto_config_url = osn::MultitrackVideoAutoConfigURL(this->service);
447447
blog(LOG_INFO, "Auto config URL: %s", auto_config_url.c_str());
448448

449-
const bool dualStreamingMode = true; // TODO: revise this??????? Make this dynamic?????
450-
auto go_live_post = osn::constructGoLivePost(StreamServiceId::Main, dualStreamingMode, key, std::nullopt, std::nullopt, vod_track_mixer.has_value());
449+
auto go_live_post = osn::constructGoLivePost({this->GetCanvas()}, key, std::nullopt, std::nullopt, vod_track_mixer.has_value());
451450
std::optional<osn::Config> go_live_config = osn::DownloadGoLiveConfig(auto_config_url, go_live_post);
452451
if (!go_live_config.has_value()) {
453452
throw std::runtime_error("startStreaming - go live config is empty");

0 commit comments

Comments
 (0)