diff --git a/config-dialog.cpp b/config-dialog.cpp index 5140bc5..be207e1 100644 --- a/config-dialog.cpp +++ b/config-dialog.cpp @@ -971,7 +971,7 @@ void OBSBasicSettings::RefreshProperties(obs_properties_t *properties, QFormLayo static bool obs_encoder_parent_video_loaded = false; static video_t *(*obs_encoder_parent_video_wrapper)(const obs_encoder_t *encoder) = nullptr; -void OBSBasicSettings::LoadOutputStats() +void OBSBasicSettings::LoadOutputStats(std::vector *oldVideos) { if (!obs_encoder_parent_video_loaded) { void *dl = os_dlopen("obs"); @@ -1047,6 +1047,8 @@ void OBSBasicSettings::LoadOutputStats() stats += "Vertical Canvas "; } else if (video == obs_get_video()) { stats += "Main Canvas "; + } else if (std::find(oldVideos->begin(), oldVideos->end(), video) != oldVideos->end()) { + stats += "Old Main Canvas "; } else { if (last_video != video) { video_count++; @@ -1056,7 +1058,9 @@ void OBSBasicSettings::LoadOutputStats() stats += std::to_string(video_count); stats += " "; } - if (encoder) { + if (video && std::find(oldVideos->begin(), oldVideos->end(), video) != oldVideos->end()) { + stats += obs_output_active(output) ? "Active " : "Inactive "; + } else if (encoder) { stats += "("; stats += std::to_string(obs_encoder_get_width(encoder)); stats += "x"; @@ -1070,6 +1074,13 @@ void OBSBasicSettings::LoadOutputStats() video_output_get_frame_rate(video) / obs_encoder_get_frame_rate_divisor(encoder), 2); stats += "fps "; stats += obs_encoder_active(encoder) ? "Active " : "Inactive "; + if (video) { + stats += "skipped frames "; + stats += std::to_string(video_output_get_skipped_frames(video)); + stats += "/"; + stats += std::to_string(video_output_get_total_frames(video)); + stats += " "; + } } else if (video) { stats += "("; stats += std::to_string(video_output_get_width(video)); @@ -1079,6 +1090,11 @@ void OBSBasicSettings::LoadOutputStats() stats += to_string_with_precision(video_output_get_frame_rate(video), 2); stats += "fps "; stats += video_output_active(video) ? "Active " : "Inactive "; + stats += "skipped frames "; + stats += std::to_string(video_output_get_skipped_frames(video)); + stats += "/"; + stats += std::to_string(video_output_get_total_frames(video)); + stats += " "; } else { stats += "("; stats += std::to_string(obs_output_get_width(output)); @@ -1087,13 +1103,6 @@ void OBSBasicSettings::LoadOutputStats() stats += ") "; stats += obs_output_active(output) ? "Active " : "Inactive "; } - if (video) { - stats += "skipped frames "; - stats += std::to_string(video_output_get_skipped_frames(video)); - stats += "/"; - stats += std::to_string(video_output_get_total_frames(video)); - stats += " "; - } stats += obs_output_get_name(output); stats += "("; stats += obs_output_get_id(output); diff --git a/config-dialog.hpp b/config-dialog.hpp index 3c66301..30dbdb0 100644 --- a/config-dialog.hpp +++ b/config-dialog.hpp @@ -68,7 +68,7 @@ public: void LoadSettings(obs_data_t *settings); void LoadVerticalSettings(); void SaveVerticalSettings(); - void LoadOutputStats(); + void LoadOutputStats(std::vector* oldVideos); void SetNewerVersion(QString newer_version_available); public slots: }; diff --git a/multistream.cpp b/multistream.cpp index e57dfb0..1702b40 100644 --- a/multistream.cpp +++ b/multistream.cpp @@ -248,7 +248,7 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent) obs_data_apply(settings, current_config); configDialog->LoadSettings(settings); configDialog->LoadVerticalSettings(); - configDialog->LoadOutputStats(); + configDialog->LoadOutputStats(&oldVideo); configDialog->SetNewerVersion(newer_version_available); configDialog->setResult(QDialog::Rejected); if (configDialog->exec() == QDialog::Accepted) { @@ -281,6 +281,20 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent) mainLayout->addLayout(buttonRow); obs_frontend_add_event_callback(frontend_event, this); + + mainVideo = obs_get_video(); + connect(&videoCheckTimer, &QTimer::timeout, [this] { + if (obs_get_video() != mainVideo) { + oldVideo.push_back(mainVideo); + mainVideo = obs_get_video(); + for (auto it = outputs.begin(); it != outputs.end(); it++) { + auto venc = obs_output_get_video_encoder(it->second); + if (venc && !obs_encoder_active(venc)) + obs_encoder_set_video(venc, mainVideo); + } + } + }); + videoCheckTimer.start(1000); } MultistreamDock::~MultistreamDock() diff --git a/multistream.hpp b/multistream.hpp index c774a02..a20da7e 100644 --- a/multistream.hpp +++ b/multistream.hpp @@ -6,6 +6,7 @@ #include #include #include +#include class OBSBasicSettings; @@ -24,6 +25,10 @@ private: QString newer_version_available; + QTimer videoCheckTimer; + video_t *mainVideo = nullptr; + std::vector oldVideo; + std::map outputs; void LoadSettingsFile();