Skip to content

frontend: Allow 5 multitrack reconnect attempts before re-running GCC #11997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions frontend/utility/MultitrackVideoOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ static const char *hevc_main = "Main";
static const char *hevc_main10 = "Main 10";
static const char *av1_main = "Main";

// Maximum reconnect attempts with an invalid key error before giving up (roughly 30 seconds with default start value)
static constexpr uint8_t MAX_RECONNECT_ATTEMPTS = 5;

Qt::ConnectionType BlockingConnectionTypeFor(QObject *object)
{
return object->thread() == QThread::currentThread() ? Qt::DirectConnection : Qt::BlockingQueuedConnection;
Expand Down Expand Up @@ -454,10 +457,11 @@ void MultitrackVideoOutput::PrepareStreaming(QWidget *parent, const char *servic
obs_output_add_packet_callback(output, bpm_inject, NULL);

// Set callback to prevent reconnection attempts once the stream key has become invalid
static auto reconnect_cb = [](void *, obs_output_t *, int code) -> bool {
return code != OBS_OUTPUT_INVALID_STREAM;
static auto reconnect_cb = [](void *param, obs_output_t *, int code) -> bool {
auto _this = static_cast<MultitrackVideoOutput *>(param);
return code != OBS_OUTPUT_INVALID_STREAM || (_this->reconnect_attempts++ < MAX_RECONNECT_ATTEMPTS);
};
obs_output_set_reconnect_callback(output, reconnect_cb, nullptr);
obs_output_set_reconnect_callback(output, reconnect_cb, this);

OBSSignal start_streaming;
OBSSignal stop_streaming;
Expand Down Expand Up @@ -869,6 +873,7 @@ void StreamStartHandler(void *arg, calldata_t *)
{
auto self = static_cast<MultitrackVideoOutput *>(arg);
self->restart_on_error = true;
self->reconnect_attempts = 0;
}

void StreamStopHandler(void *arg, calldata_t *data)
Expand Down
1 change: 1 addition & 0 deletions frontend/utility/MultitrackVideoOutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct MultitrackVideoOutput {
std::optional<OBSOutputObjects> current_stream_dump;

bool restart_on_error = false;
uint8_t reconnect_attempts = 0;

friend void StreamStartHandler(void *arg, calldata_t *data);
friend void StreamStopHandler(void *arg, calldata_t *data);
Expand Down
Loading