diff options
-rw-r--r-- | src/dls.cpp | 1 | ||||
-rw-r--r-- | src/dls.h | 13 | ||||
-rw-r--r-- | src/odr-padenc.cpp | 9 | ||||
-rw-r--r-- | src/sls.cpp | 10 | ||||
-rw-r--r-- | src/sls.h | 18 |
5 files changed, 27 insertions, 24 deletions
diff --git a/src/dls.cpp b/src/dls.cpp index 08297cb..1c680c0 100644 --- a/src/dls.cpp +++ b/src/dls.cpp @@ -34,7 +34,6 @@ const size_t DLSManager::MAXDLS = 128; // chars const size_t DLSManager::DLS_SEG_LEN_PREFIX = 2; const size_t DLSManager::DLS_SEG_LEN_CHAR_MAX = 16; -const int DLSManager::DLS_REPETITION_WHILE_SLS = 50; const std::string DLSManager::DL_PARAMS_OPEN = "##### parameters { #####"; const std::string DLSManager::DL_PARAMS_CLOSE = "##### parameters } #####"; @@ -128,6 +128,12 @@ struct DL_STATE { // --- DLSManager ----------------------------------------------------------------- class DLSManager { private: + static const size_t MAXDLS; + static const size_t DLS_SEG_LEN_PREFIX; + static const size_t DLS_SEG_LEN_CHAR_MAX; + static const std::string DL_PARAMS_OPEN; + static const std::string DL_PARAMS_CLOSE; + DATA_GROUP* createDynamicLabelCommand(uint8_t command); DATA_GROUP* createDynamicLabelPlus(const DL_STATE& dl_state); bool parse_dl_param_bool(const std::string &key, const std::string &value, bool &target); @@ -142,13 +148,6 @@ private: bool dls_toggle; DL_STATE dl_state_prev; public: - static const size_t MAXDLS; - static const size_t DLS_SEG_LEN_PREFIX; - static const size_t DLS_SEG_LEN_CHAR_MAX; - static const int DLS_REPETITION_WHILE_SLS; - static const std::string DL_PARAMS_OPEN; - static const std::string DL_PARAMS_CLOSE; - DLSManager(PADPacketizer* pad_packetizer) : pad_packetizer(pad_packetizer), dls_toggle(false) {} void writeDLS(const std::string& dls_file, const DL_PARAMS& dl_params); }; diff --git a/src/odr-padenc.cpp b/src/odr-padenc.cpp index 0d19fd6..320389a 100644 --- a/src/odr-padenc.cpp +++ b/src/odr-padenc.cpp @@ -45,7 +45,7 @@ static const int SLEEPDELAY_DEFAULT = 10; // seconds - +static const int DLS_REPETITION_WHILE_SLS = 50; static void usage(const char* name) { @@ -110,8 +110,7 @@ static int filter_slides(const struct dirent* file) { return 0; // skip slide params files - if(name.length() >= SLSManager::SLS_PARAMS_SUFFIX.length() && - name.substr(name.length() - SLSManager::SLS_PARAMS_SUFFIX.length()) == SLSManager::SLS_PARAMS_SUFFIX) + if(SLSManager::isSlideParamFileFilename(name)) return 0; return 1; @@ -303,7 +302,7 @@ int main(int argc, char *argv[]) { SLSManager sls_manager(&pad_packetizer); std::list<slide_metadata_t> slides_to_transmit; - History slides_history(History::MAXHISTORYLEN); + History slides_history; std::chrono::steady_clock::time_point next_run = std::chrono::steady_clock::now(); @@ -337,7 +336,7 @@ int main(int argc, char *argv[]) { if (not dls_files.empty()) dls_manager.writeDLS(dls_files[curr_dls_file], dl_params); - pad_packetizer.WriteAllPADs(output_fd, DLSManager::DLS_REPETITION_WHILE_SLS); + pad_packetizer.WriteAllPADs(output_fd, DLS_REPETITION_WHILE_SLS); } } diff --git a/src/sls.cpp b/src/sls.cpp index cb6e750..5031451 100644 --- a/src/sls.cpp +++ b/src/sls.cpp @@ -32,7 +32,7 @@ // --- History ----------------------------------------------------------------- const size_t History::MAXHISTORYLEN = 50; // How many slides to keep in history - +const int History::MAXSLIDEID = 9999; // Roll-over value for fidx int History::find(const fingerprint_t& fp) const { @@ -88,7 +88,7 @@ int History::get_fidx(const char* filepath) idx = m_last_given_fidx++; fp.fidx = idx; - if (m_last_given_fidx > SLSManager::MAXSLIDEID) { + if (m_last_given_fidx > MAXSLIDEID) { m_last_given_fidx = 0; } @@ -192,7 +192,6 @@ void MOTHeader::AddExtension(int param_id, const uint8_t* data_field, size_t dat // --- SLSManager ----------------------------------------------------------------- const size_t SLSManager::MAXSEGLEN = 8189; // Bytes (EN 301 234 v2.1.1, ch. 5.1.1) const size_t SLSManager::MAXSLIDESIZE = 51200; // Bytes (TS 101 499 v3.1.1, ch. 9.1.2) -const int SLSManager::MAXSLIDEID = 9999; // Roll-over value for fidx const int SLSManager::MINQUALITY = 40; // Do not allow the image compressor to go below JPEG quality 40 const std::string SLSManager::SLS_PARAMS_SUFFIX = ".sls_params"; @@ -698,3 +697,8 @@ DATA_GROUP* SLSManager::packMscDG(MSCDG* msc) return dg; } + +bool SLSManager::isSlideParamFileFilename(const std::string& filename) { + return filename.length() >= SLS_PARAMS_SUFFIX.length() && + filename.substr(filename.length() - SLS_PARAMS_SUFFIX.length()) == SLS_PARAMS_SUFFIX; +} @@ -150,8 +150,7 @@ struct fingerprint_t { */ class History { public: - static const size_t MAXHISTORYLEN; - + History() : History(MAXHISTORYLEN) {} History(size_t hist_size) : m_hist_size(hist_size), m_last_given_fidx(0) {} @@ -160,6 +159,9 @@ class History { int get_fidx(const char* filepath); private: + static const size_t MAXHISTORYLEN; + static const int MAXSLIDEID; + std::deque<fingerprint_t> m_database; size_t m_hist_size; @@ -199,6 +201,11 @@ public: // --- SLSManager ----------------------------------------------------------------- class SLSManager { private: + static const size_t MAXSEGLEN; + static const size_t MAXSLIDESIZE; + static const int MINQUALITY; + static const std::string SLS_PARAMS_SUFFIX; + void warnOnSmallerImage(size_t height, size_t width, const std::string& fname); #if HAVE_MAGICKWAND size_t resizeImage(MagickWand* m_wand, unsigned char** blob, const std::string& fname, bool* jfif_not_png); @@ -217,15 +224,10 @@ private: int cindex_header; int cindex_body; public: - static const size_t MAXSEGLEN; - static const size_t MAXSLIDESIZE; - static const int MAXSLIDEID; - static const int MINQUALITY; - static const std::string SLS_PARAMS_SUFFIX; - SLSManager(PADPacketizer* pad_packetizer) : pad_packetizer(pad_packetizer), cindex_header(0), cindex_body(0) {} bool encodeFile(const std::string& fname, int fidx, bool raw_slides); + static bool isSlideParamFileFilename(const std::string& filename); }; #endif /* SLS_H_ */ |