diff --git a/src/common.cpp b/src/common.cpp index a417e68..b04e1c7 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -361,39 +361,3 @@ uint64_t genEpoch() { return duration_cast(system_clock::now().time_since_epoch()).count(); } - -void wrOutm3u8(const pls_t &pls) -{ - recLog("live-to-event-src: " + pls.clipPath); - recLog("live-to-event-dst: " + pls.dstPath); - - createDirTree(path(pls.dstPath).parent_path().string()); - copy_file(pls.clipPath, pls.dstPath); - - auto plsFile = pls.fileName + ".m3u8"; - - if (exists(plsFile)) - { - ofstream file(plsFile.c_str(), ofstream::app); - - file << endl; - file << pls.extINF << endl; - file << pls.dstPath; - - file.close(); - } - else - { - ofstream file(plsFile.c_str()); - - file << "#EXTM3U" << endl; - file << "#EXT-X-VERSION:3" << endl; - file << "#EXT-X-TARGETDURATION:10" << endl; - file << "#EXT-X-MEDIA-SEQUENCE:0" << endl; - file << "#EXT-X-DISCONTINUITY" << endl; - file << pls.extINF << endl; - file << pls.dstPath; - - file.close(); - } -} diff --git a/src/common.h b/src/common.h index 4c483d7..8ae2444 100644 --- a/src/common.h +++ b/src/common.h @@ -37,7 +37,7 @@ using namespace std; using namespace std::filesystem; using namespace std::chrono; -#define APP_VER "2.0.t3" +#define APP_VER "2.0.t4" #define APP_NAME "Motion Watch" #define REC_LOG_NAME "rec_log_lines.html" #define DET_LOG_NAME "det_log_lines.html" @@ -93,7 +93,6 @@ void rdLine(const string ¶m, const string &line, string *value); void rdLine(const string ¶m, const string &line, int *value); void cleanupEmptyDirs(const string &path); void cleanupStream(const string &plsPath); -void wrOutm3u8(const pls_t &pls); void enforceMaxEvents(shared_t *share); bool rdConf(shared_t *share); vector lsFilesInDir(const string &path, const string &ext = string()); diff --git a/src/main.cpp b/src/main.cpp index 7453bbd..af554fa 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,7 +42,7 @@ void eventLoop(shared_t *share) try { - wrOutm3u8(pls); + wrOutm3u8(pls, share); genHTMLvid(pls.fileName); if (!exists(pls.fileName + ".jpg")) @@ -52,7 +52,7 @@ void eventLoop(shared_t *share) } catch (filesystem_error &ex) { - recLog("err: " + ex.what(), share); + recLog(string("err: ") + ex.what(), share); } share->recList.erase(share->recList.begin()); diff --git a/src/mo_detect.cpp b/src/mo_detect.cpp index 4a6dbe1..ce51f80 100644 --- a/src/mo_detect.cpp +++ b/src/mo_detect.cpp @@ -99,7 +99,7 @@ bool moDetect(const string &buffFile, Mat &vidThumb, shared_t *share) mod = true; break; } } - + prev.release(); next.release(); } @@ -116,3 +116,39 @@ bool moDetect(const string &buffFile, Mat &vidThumb, shared_t *share) return mod; } + +void wrOutm3u8(const pls_t &pls, shared_t *share) +{ + recLog("live-to-event-src: " + pls.clipPath, share); + recLog("live-to-event-dst: " + pls.dstPath, share); + + createDirTree(path(pls.dstPath).parent_path().string()); + copy_file(pls.clipPath, pls.dstPath); + + auto plsFile = pls.fileName + ".m3u8"; + + if (exists(plsFile)) + { + ofstream file(plsFile.c_str(), ofstream::app); + + file << endl; + file << pls.extINF << endl; + file << pls.dstPath; + + file.close(); + } + else + { + ofstream file(plsFile.c_str()); + + file << "#EXTM3U" << endl; + file << "#EXT-X-VERSION:3" << endl; + file << "#EXT-X-TARGETDURATION:10" << endl; + file << "#EXT-X-MEDIA-SEQUENCE:0" << endl; + file << "#EXT-X-DISCONTINUITY" << endl; + file << pls.extINF << endl; + file << pls.dstPath; + + file.close(); + } +} diff --git a/src/mo_detect.h b/src/mo_detect.h index fc0c823..ccc7fd4 100644 --- a/src/mo_detect.h +++ b/src/mo_detect.h @@ -19,5 +19,6 @@ bool imgDiff(Mat &prev, Mat &next, shared_t *share); bool moDetect(const string &buffFile, Mat &vidThumb, shared_t *share); void detectMoInStream(const string &bufPath, shared_t *share); +void wrOutm3u8(const pls_t &pls, shared_t *share); #endif // MO_DETECT_H