v1.1.0 : Fixed multithreading & added timeout to ffmpeg
This commit is contained in:
@@ -13,10 +13,13 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include <describe.h>
|
#include <describe.h>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
namespace etix {
|
namespace etix {
|
||||||
namespace cameradar {
|
namespace cameradar {
|
||||||
|
|
||||||
|
std::mutex m;
|
||||||
|
|
||||||
// Ugly workaround
|
// Ugly workaround
|
||||||
size_t
|
size_t
|
||||||
write_data(void* buffer, size_t size, size_t nmemb, void* userp) {
|
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;
|
struct curl_slist* custom_msg = NULL;
|
||||||
char URL[256];
|
char URL[256];
|
||||||
long rc;
|
long rc;
|
||||||
|
m.lock();
|
||||||
|
curl_global_init(0);
|
||||||
|
m.unlock();
|
||||||
csession = curl_easy_init();
|
csession = curl_easy_init();
|
||||||
if (csession == NULL) return -1;
|
if (csession == NULL) return -1;
|
||||||
sprintf(URL, "%s", path.c_str());
|
sprintf(URL, "%s", path.c_str());
|
||||||
@@ -78,6 +84,10 @@ curl_describe(const std::string& path, bool logs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
curl_easy_cleanup(csession);
|
curl_easy_cleanup(csession);
|
||||||
|
|
||||||
|
m.lock();
|
||||||
|
curl_global_cleanup();
|
||||||
|
m.unlock();
|
||||||
LOG_DEBUG_("Response code : " + std::to_string(rc), "describe");
|
LOG_DEBUG_("Response code : " + std::to_string(rc), "describe");
|
||||||
if (logs) {
|
if (logs) {
|
||||||
// Some cameras return 400 instead of 401, don't know why.
|
// 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;
|
return false;
|
||||||
std::string ffmpeg_cmd =
|
std::string ffmpeg_cmd =
|
||||||
"mkdir -p %s ; "
|
"mkdir -p %s ; "
|
||||||
|
"timeout 20 "
|
||||||
"ffmpeg "
|
"ffmpeg "
|
||||||
"-rtsp_transport tcp "
|
"-rtsp_transport tcp "
|
||||||
"-y "
|
"-y "
|
||||||
|
|||||||
Reference in New Issue
Block a user