From 13ee39b1e9fb8b4103acb0a71e71d71b13031c4b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 18 Jan 2022 13:44:21 -0500 Subject: [PATCH] Log errors talking to Janus. Log if janus is turned on but not compiled in --- src/zm_monitor.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index aea0c0000..454e7068c 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1126,6 +1126,9 @@ bool Monitor::connect() { } } } +#else + if (janus_enabled) + Error("zmc not compiled with LIBCURL. Janus support not built in!"); #endif } else if (!shared_data->valid) { @@ -3390,7 +3393,10 @@ int Monitor::add_to_janus() { CURLcode res; curl = curl_easy_init(); - if(!curl) return -1; + if (!curl) { + Error("Failed to init curl"); + return -1; + } //parse username and password pos = path.find(":", 7); if (pos == std::string::npos) return -1; @@ -3408,7 +3414,11 @@ int Monitor::add_to_janus() { curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData.c_str()); res = curl_easy_perform(curl); - if (res != CURLE_OK) return -1; + if (res != CURLE_OK) { + Error("Failed to curl_easy_perform getting session/handle id"); + curl_easy_cleanup(curl); + return -1; + } pos = response.find("\"id\": "); if (pos == std::string::npos) return -1; @@ -3421,7 +3431,11 @@ int Monitor::add_to_janus() { curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData.c_str()); res = curl_easy_perform(curl); - if (res != CURLE_OK) return -1; + if (res != CURLE_OK) { + Error("Failed to curl_easy_perform attaching"); + curl_easy_cleanup(curl); + return -1; + } pos = response.find("\"id\": "); if (pos == std::string::npos) return -1; std::string handle_id = response.substr(pos + 6, 16); //TODO: This is an assumption that the string is always 16 @@ -3446,7 +3460,11 @@ int Monitor::add_to_janus() { curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData.c_str()); res = curl_easy_perform(curl); - if (res != CURLE_OK) return -1; + if (res != CURLE_OK) { + Error("Failed to curl_easy_perform adding rtsp stream"); + curl_easy_cleanup(curl); + return -1; + } Debug(1,"Added stream to Janus: %s", response.c_str()); curl_easy_cleanup(curl); return 0;