mirror of
https://github.com/Aitum/obs-aitum-multistream.git
synced 2024-11-25 11:42:58 +01:00
Add video reset check
This commit is contained in:
parent
3d708f8c7b
commit
ad33461aaa
@ -971,7 +971,7 @@ void OBSBasicSettings::RefreshProperties(obs_properties_t *properties, QFormLayo
|
|||||||
static bool obs_encoder_parent_video_loaded = false;
|
static bool obs_encoder_parent_video_loaded = false;
|
||||||
static video_t *(*obs_encoder_parent_video_wrapper)(const obs_encoder_t *encoder) = nullptr;
|
static video_t *(*obs_encoder_parent_video_wrapper)(const obs_encoder_t *encoder) = nullptr;
|
||||||
|
|
||||||
void OBSBasicSettings::LoadOutputStats()
|
void OBSBasicSettings::LoadOutputStats(std::vector<video_t *> *oldVideos)
|
||||||
{
|
{
|
||||||
if (!obs_encoder_parent_video_loaded) {
|
if (!obs_encoder_parent_video_loaded) {
|
||||||
void *dl = os_dlopen("obs");
|
void *dl = os_dlopen("obs");
|
||||||
@ -1047,6 +1047,8 @@ void OBSBasicSettings::LoadOutputStats()
|
|||||||
stats += "Vertical Canvas ";
|
stats += "Vertical Canvas ";
|
||||||
} else if (video == obs_get_video()) {
|
} else if (video == obs_get_video()) {
|
||||||
stats += "Main Canvas ";
|
stats += "Main Canvas ";
|
||||||
|
} else if (std::find(oldVideos->begin(), oldVideos->end(), video) != oldVideos->end()) {
|
||||||
|
stats += "Old Main Canvas ";
|
||||||
} else {
|
} else {
|
||||||
if (last_video != video) {
|
if (last_video != video) {
|
||||||
video_count++;
|
video_count++;
|
||||||
@ -1056,7 +1058,9 @@ void OBSBasicSettings::LoadOutputStats()
|
|||||||
stats += std::to_string(video_count);
|
stats += std::to_string(video_count);
|
||||||
stats += " ";
|
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 += "(";
|
||||||
stats += std::to_string(obs_encoder_get_width(encoder));
|
stats += std::to_string(obs_encoder_get_width(encoder));
|
||||||
stats += "x";
|
stats += "x";
|
||||||
@ -1070,6 +1074,13 @@ void OBSBasicSettings::LoadOutputStats()
|
|||||||
video_output_get_frame_rate(video) / obs_encoder_get_frame_rate_divisor(encoder), 2);
|
video_output_get_frame_rate(video) / obs_encoder_get_frame_rate_divisor(encoder), 2);
|
||||||
stats += "fps ";
|
stats += "fps ";
|
||||||
stats += obs_encoder_active(encoder) ? "Active " : "Inactive ";
|
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) {
|
} else if (video) {
|
||||||
stats += "(";
|
stats += "(";
|
||||||
stats += std::to_string(video_output_get_width(video));
|
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 += to_string_with_precision(video_output_get_frame_rate(video), 2);
|
||||||
stats += "fps ";
|
stats += "fps ";
|
||||||
stats += video_output_active(video) ? "Active " : "Inactive ";
|
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 {
|
} else {
|
||||||
stats += "(";
|
stats += "(";
|
||||||
stats += std::to_string(obs_output_get_width(output));
|
stats += std::to_string(obs_output_get_width(output));
|
||||||
@ -1087,13 +1103,6 @@ void OBSBasicSettings::LoadOutputStats()
|
|||||||
stats += ") ";
|
stats += ") ";
|
||||||
stats += obs_output_active(output) ? "Active " : "Inactive ";
|
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 += obs_output_get_name(output);
|
||||||
stats += "(";
|
stats += "(";
|
||||||
stats += obs_output_get_id(output);
|
stats += obs_output_get_id(output);
|
||||||
|
@ -68,7 +68,7 @@ public:
|
|||||||
void LoadSettings(obs_data_t *settings);
|
void LoadSettings(obs_data_t *settings);
|
||||||
void LoadVerticalSettings();
|
void LoadVerticalSettings();
|
||||||
void SaveVerticalSettings();
|
void SaveVerticalSettings();
|
||||||
void LoadOutputStats();
|
void LoadOutputStats(std::vector<video_t *>* oldVideos);
|
||||||
void SetNewerVersion(QString newer_version_available);
|
void SetNewerVersion(QString newer_version_available);
|
||||||
public slots:
|
public slots:
|
||||||
};
|
};
|
||||||
|
@ -248,7 +248,7 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent)
|
|||||||
obs_data_apply(settings, current_config);
|
obs_data_apply(settings, current_config);
|
||||||
configDialog->LoadSettings(settings);
|
configDialog->LoadSettings(settings);
|
||||||
configDialog->LoadVerticalSettings();
|
configDialog->LoadVerticalSettings();
|
||||||
configDialog->LoadOutputStats();
|
configDialog->LoadOutputStats(&oldVideo);
|
||||||
configDialog->SetNewerVersion(newer_version_available);
|
configDialog->SetNewerVersion(newer_version_available);
|
||||||
configDialog->setResult(QDialog::Rejected);
|
configDialog->setResult(QDialog::Rejected);
|
||||||
if (configDialog->exec() == QDialog::Accepted) {
|
if (configDialog->exec() == QDialog::Accepted) {
|
||||||
@ -281,6 +281,20 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent)
|
|||||||
mainLayout->addLayout(buttonRow);
|
mainLayout->addLayout(buttonRow);
|
||||||
|
|
||||||
obs_frontend_add_event_callback(frontend_event, this);
|
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()
|
MultistreamDock::~MultistreamDock()
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
class OBSBasicSettings;
|
class OBSBasicSettings;
|
||||||
|
|
||||||
@ -24,6 +25,10 @@ private:
|
|||||||
|
|
||||||
QString newer_version_available;
|
QString newer_version_available;
|
||||||
|
|
||||||
|
QTimer videoCheckTimer;
|
||||||
|
video_t *mainVideo = nullptr;
|
||||||
|
std::vector<video_t *> oldVideo;
|
||||||
|
|
||||||
std::map<std::string, obs_output_t *> outputs;
|
std::map<std::string, obs_output_t *> outputs;
|
||||||
|
|
||||||
void LoadSettingsFile();
|
void LoadSettingsFile();
|
||||||
|
Loading…
Reference in New Issue
Block a user