v1.1.0 : Fixed multithreading & added timeout to ffmpeg

This commit is contained in:
Brendan LE GLAUNEC
2016-11-02 07:56:03 +01:00
parent 37176292d0
commit 6685f74a90
2 changed files with 11 additions and 0 deletions
+10
View File
@@ -13,10 +13,13 @@
// limitations under the License.
#include <describe.h>
#include <mutex>
namespace etix {
namespace cameradar {
std::mutex m;
// Ugly workaround
size_t
write_data(void* buffer, size_t size, size_t nmemb, void* userp) {
@@ -37,6 +40,9 @@ curl_describe(const std::string& path, bool logs) {
struct curl_slist* custom_msg = NULL;
char URL[256];
long rc;
m.lock();
curl_global_init(0);
m.unlock();
csession = curl_easy_init();
if (csession == NULL) return -1;
sprintf(URL, "%s", path.c_str());
@@ -78,6 +84,10 @@ curl_describe(const std::string& path, bool logs) {
}
curl_easy_cleanup(csession);
m.lock();
curl_global_cleanup();
m.unlock();
LOG_DEBUG_("Response code : " + std::to_string(rc), "describe");
if (logs) {
// Some cameras return 400 instead of 401, don't know why.
@@ -48,6 +48,7 @@ thumbnail::generate_thumbnail(const stream_model& stream) const {
return false;
std::string ffmpeg_cmd =
"mkdir -p %s ; "
"timeout 20 "
"ffmpeg "
"-rtsp_transport tcp "
"-y "