123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- #ifndef CNSTREAM_COMMON_PRI_HPP_
- #define CNSTREAM_COMMON_PRI_HPP_
- #include <string.h>
- #include <unistd.h>
- #include <string>
- #include <vector>
- #if defined(__GNUC__) || defined(__clang__)
- #define CNS_DEPRECATED __attribute__((deprecated))
- #elif defined(_MSC_VER)
- #define CNS_DEPRECATED __declspec(deprecated)
- #else
- #error You need to implement CNS_DEPRECATED for this compiler
- #define CNS_DEPRECATED
- #endif
- #if defined(__GNUC__)
- #define CNS_IGNORE_DEPRECATED_PUSH \
- _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
- #define CNS_IGNORE_DEPRECATED_POP _Pragma("GCC diagnostic pop")
- #elif defined(__clang__)
- #define CNS_IGNORE_DEPRECATED_PUSH \
- _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
- #define CNS_IGNORE_DEPRECATED_POP _Pragma("clang diagnostic pop")
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CNS_IGNORE_DEPRECATED_PUSH \
- __pragma(warning(push)) __pragma(warning(disable : 4996)) #define CNS_IGNORE_DEPRECATED_POP __pragma(warning(pop))
- #else
- #error You need to implement CNS_IGNORE_DEPRECATED_PUSH and \
- CNS_IGNORE_DEPRECATED_POP for this compiler
- #define CNS_IGNORE_DEPRECATED_PUSH
- #define CNS_IGNORE_DEPRECATED_POP
- #endif
- namespace cnstream {
- enum class CNPixelFormat {
- YUV420P = 0,
- RGB24,
- BGR24,
- NV21,
- NV12,
- I422,
- I444,
- };
- enum class CNCodecType {
- H264 = 0,
- HEVC,
- MPEG4,
- JPEG
- };
- class NonCopyable {
- protected:
-
- NonCopyable() = default;
-
- ~NonCopyable() = default;
- private:
- NonCopyable(const NonCopyable&) = delete;
- NonCopyable(NonCopyable&&) = delete;
- NonCopyable& operator=(const NonCopyable&) = delete;
- NonCopyable& operator=(NonCopyable&&) = delete;
- };
- constexpr size_t INVALID_MODULE_ID = (size_t)(-1);
- constexpr uint32_t INVALID_STREAM_IDX = (uint32_t)(-1);
- static constexpr uint32_t MAX_STREAM_NUM = 128;
- #define CNS_JSON_DIR_PARAM_NAME "json_file_dir"
- static constexpr char kProfilerConfigName[] = "profiler_config";
- static constexpr char kSubgraphConfigPrefix[] = "subgraph:";
- inline bool IsSubgraphItem(const std::string &item_name) {
- return item_name.size() > strlen(kSubgraphConfigPrefix) &&
- kSubgraphConfigPrefix == item_name.substr(0, strlen(kSubgraphConfigPrefix));
- }
- bool CheckStreamEosReached(const std::string &stream_id, bool sync = true);
- void SetStreamRemoved(const std::string &stream_id, bool value = true);
- bool IsStreamRemoved(const std::string &stream_id);
- inline std::vector<std::string> StringSplit(const std::string& s, char c) {
- std::stringstream ss(s);
- std::string piece;
- std::vector<std::string> result;
- while (std::getline(ss, piece, c)) {
- result.push_back(piece);
- }
- return result;
- }
- }
- #endif
|