Skip to content

Commit

Permalink
Add stream stopping check for replay buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed Jun 20, 2024
1 parent 31ec80c commit b9de340
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions vertical-canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ void CanvasDock::CheckReplayBuffer(bool start)
bool active = obs_frontend_streaming_active() || obs_frontend_recording_active() ||
(recordOutput && obs_output_active(recordOutput));
for (auto it = streamOutputs.begin(); !active && it != streamOutputs.end(); ++it) {
active = it->enabled && it->output && obs_output_active(it->output);
active = it->enabled && it->output && !it->stopping && obs_output_active(it->output);
}

if (start && active) {
Expand Down Expand Up @@ -5729,12 +5729,14 @@ void CanvasDock::StreamButtonMultiMenu(QMenu *menu)
const bool started_video = StartVideo();
obs_output_set_video_encoder(it->output, GetStreamVideoEncoder());
obs_output_set_audio_encoder(it->output, GetStreamAudioEncoder(), 0);
it->stopping = false;
if (!obs_output_start(it->output)) {
if (started_video) {
video = nullptr;
obs_view_remove(view);
obs_view_set_source(view, 0, nullptr);
}
it->stopping = true;
QMetaObject::invokeMethod(this, "OnStreamStop", Q_ARG(int, OBS_OUTPUT_ERROR),
Q_ARG(QString,
QString::fromUtf8(obs_output_get_last_error(it->output))),
Expand Down Expand Up @@ -5948,14 +5950,16 @@ void CanvasDock::StartStream()
obs_data_set_string(output_settings, "ip_family", config_get_string(config, "Output", "IPFamily"));
obs_output_update(it->output, output_settings);
}

if (obs_output_start(it->output))
it->stopping = false;
if (obs_output_start(it->output)) {
success = true;
else
} else {
it->stopping = true;
QMetaObject::invokeMethod(this, "OnStreamStop", Q_ARG(int, OBS_OUTPUT_ERROR),
Q_ARG(QString, QString::fromUtf8(obs_output_get_last_error(it->output))),
Q_ARG(QString, QString::fromUtf8(it->stream_server)),
Q_ARG(QString, QString::fromUtf8(it->stream_key)));
}
}
if (!success && started_video) {
video = nullptr;
Expand Down Expand Up @@ -6002,6 +6006,7 @@ void CanvasDock::stream_output_stop(void *data, calldata_t *calldata)
if (it->output == t) {
stream_server = QString::fromUtf8(it->stream_server);
stream_key = QString::fromUtf8(it->stream_key);
it->stopping = true;
}
}

Expand Down
1 change: 1 addition & 0 deletions vertical-canvas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class StreamServer {
std::string stream_key;
std::string stream_server;
bool enabled = true;
bool stopping = false;
};

class CanvasDock : public QFrame {
Expand Down

0 comments on commit b9de340

Please sign in to comment.