Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"ENABLE_QT": true,
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
"BUILD_PLUGIN": true,
"MOQ_VERSION": "0.2.14",
"MOQ_VERSION": "0.3.6",
"MOQ_ARCHIVE": "tar.gz"
}
},
Expand Down
15 changes: 9 additions & 6 deletions src/moq-output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,20 @@ bool MoQOutput::Start()

connect_start = std::chrono::steady_clock::now();

// Create a callback to log when the session is connected or closed
auto session_connect_callback = [](void *user_data, int error_code) {
// Create a callback to log when the session is connected or closed.
// libmoq status codes (>= 0.3.0): > 0 = (re)connected (epoch), 0 = closed
// cleanly (terminal), < 0 = fatal/reconnect-gave-up (terminal).
auto session_connect_callback = [](void *user_data, int code) {
auto self = static_cast<MoQOutput *>(user_data);

if (error_code == 0) {
if (code > 0) {
auto elapsed = std::chrono::steady_clock::now() - self->connect_start;
self->connect_time_ms = static_cast<int>(std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count());
LOG_INFO("MoQ session established (%d ms): %s", self->connect_time_ms,
self->connect_time_ms = static_cast<int>(
std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count());
LOG_INFO("MoQ session connected (%d ms, epoch %d): %s", self->connect_time_ms, code,
self->server_url.c_str());
} else {
LOG_INFO("MoQ session closed (%d): %s", error_code, self->server_url.c_str());
LOG_INFO("MoQ session closed (%d): %s", code, self->server_url.c_str());
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment on lines +93 to 107

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Critical: Reset connect_time_ms to zero when the session closes.

When code <= 0 (session closed or failed), the callback does not reset connect_time_ms to zero. The UI determines connection state by checking obs_output_get_connect_time_ms(output) > 0 (see moq-dock.cpp:326), so leaving connect_time_ms at its previous positive value will cause the UI to incorrectly display "● Connected" even after the session has closed.

🐛 Proposed fix to reset connection time on close
 	if (code > 0) {
 		auto elapsed = std::chrono::steady_clock::now() - self->connect_start;
 		self->connect_time_ms = static_cast<int>(
 			std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count());
 		LOG_INFO("MoQ session connected (%d ms, epoch %d): %s", self->connect_time_ms, code,
 			 self->server_url.c_str());
 	} else {
+		self->connect_time_ms = 0;
 		LOG_INFO("MoQ session closed (%d): %s", code, self->server_url.c_str());
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (code > 0) {
auto elapsed = std::chrono::steady_clock::now() - self->connect_start;
self->connect_time_ms = static_cast<int>(std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count());
LOG_INFO("MoQ session established (%d ms): %s", self->connect_time_ms,
self->connect_time_ms = static_cast<int>(
std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count());
LOG_INFO("MoQ session connected (%d ms, epoch %d): %s", self->connect_time_ms, code,
self->server_url.c_str());
} else {
LOG_INFO("MoQ session closed (%d): %s", error_code, self->server_url.c_str());
LOG_INFO("MoQ session closed (%d): %s", code, self->server_url.c_str());
}
if (code > 0) {
auto elapsed = std::chrono::steady_clock::now() - self->connect_start;
self->connect_time_ms = static_cast<int>(
std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count());
LOG_INFO("MoQ session connected (%d ms, epoch %d): %s", self->connect_time_ms, code,
self->server_url.c_str());
} else {
self->connect_time_ms = 0;
LOG_INFO("MoQ session closed (%d): %s", code, self->server_url.c_str());
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/moq-output.cpp` around lines 84 - 92, The connect_time_ms field is not
being reset when the session closes (code <= 0), which causes the UI to
incorrectly display the connection as active based on checking if
connect_time_ms is greater than zero. In the else block that handles the session
closed condition (where code <= 0), add a statement to reset
self->connect_time_ms to zero before or after the LOG_INFO call. This ensures
the UI will correctly reflect that the connection is no longer active.

};

Expand Down
Loading
Loading