From e1862af2300b68c8689f766eeeae4bacdfcf52ee Mon Sep 17 00:00:00 2001 From: yangdan07 Date: Wed, 9 Sep 2020 14:23:35 +0800 Subject: [PATCH] refactor(utility.h): delete the utility.h --- ijkmedia/ijkplayer/utility.h | 207 ------------------ .../IJKMoviePlayerViewController.h | 1 - 2 files changed, 208 deletions(-) delete mode 100644 ijkmedia/ijkplayer/utility.h diff --git a/ijkmedia/ijkplayer/utility.h b/ijkmedia/ijkplayer/utility.h deleted file mode 100644 index 074ca127..00000000 --- a/ijkmedia/ijkplayer/utility.h +++ /dev/null @@ -1,207 +0,0 @@ -#pragma once -#include -#ifdef _WIN32 -#include -#pragma comment(lib,"ws2_32.lib") -#else -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -using namespace std; - -namespace kuaishou { -namespace kpbase { - -class NonCopyable { - protected: - NonCopyable() {} - virtual ~NonCopyable() {} - - private: - NonCopyable(NonCopyable const&) = delete; - NonCopyable& operator=(NonCopyable const&) = delete; - NonCopyable(NonCopyable&&) = delete; - NonCopyable& operator=(NonCopyable&&) = delete; -}; - -template -class Nullable { - public: - Nullable() : is_null_(true) {} - Nullable(const T& v) : value_(v), is_null_(false) {} - Nullable(const Nullable& o) : value_(o.value_), is_null_(o.is_null_) {} - - bool IsNull() { - return is_null_; - } - - const T& Value() const { - return value_; - } - - operator T() const { - return value_; - } - - private: - T value_; - bool is_null_; -}; - -class SystemUtil { - public: - static uint64_t GetCPUTime(); - static uint64_t GetEpochTime(); - static unordered_map GetLocalIPs(); - static string GetDocumentPath(); - static string GetExecFilePath(); - static string GetTimeString(uint64_t ms_epoch, int timezone, bool with_delimiter = true); - static string GetDayString(uint64_t ms_epoch, int timezone); - static string GetHourString(uint64_t ms_epoch, int timezone); - static string GetSystemOSVersion(); - static string GetDeviceModel(); - //static bool EnableCrashDump(void(*log_func)(const char*)); - - private: - SystemUtil(); -}; - -class StringUtil { - public: - static string Int2Str(long long val); - static string Uint2Str(unsigned long long val); - static Nullable Str2Int(string str); - static Nullable Str2Uint(string str); - static string GetHumanReadableString(int64_t val); - static string ConcealStr(const string& src); - static string UnConcealStr(const string& src); - static string Trim(const string& src); - static bool EndWith(const string& origin, const string& substr); - static bool StartWith(const string& origin, const string& substr); - static vector Split(const string& str, const string& pattern); - static string UrlEncode(const string& str); - static string HmacSha1(const void* data, size_t data_len, const void* key, size_t key_len); - static string Replace(string& str, const string& old_value, const string& new_value); - - private: - StringUtil(); -}; - -class SocketUtil { - public: - SocketUtil() = delete; - SocketUtil(const SocketUtil&) = delete; - - static bool FillInSockaddr(const char* ip, uint16_t port, void* sockaddr, size_t* addrlen); - static pair GetAddress(const struct sockaddr* addr); -}; - -template -class Singleton { - public: - static T& GetInstance() { - static T instance; - return instance; - } -}; - -template -class Profiler { - public: - Profiler(uint64_t* val = nullptr, function finish_func = nullptr) : val_(val), - finish_func_(finish_func), start_(chrono::steady_clock::now()) {} - - ~Profiler() { - chrono::steady_clock::duration delta = chrono::steady_clock::now() - start_; - uint64_t diff = chrono::duration_cast(delta).count(); - if (val_) - *val_ = diff; - if (finish_func_) - finish_func_(diff); - } - - uint64_t GetTime() { - chrono::steady_clock::duration delta = chrono::steady_clock::now() - start_; - uint64_t diff = chrono::duration_cast(delta).count(); - return diff; - } - - private: - uint64_t* val_; - function finish_func_; - chrono::steady_clock::time_point start_; -}; - -template -class ArrayUtil { - public: - static void EnsureArraySize(T*& array, size_t& array_size, size_t new_size) { - if (array_size < new_size) { - T* new_array = new T[new_size]; - if (array) { - memcpy(new_array, array, sizeof(T) * array_size); - delete[] array; - } - array = new_array; - array_size = new_size; - } - } -}; - -template -struct Trituple { - T1 first; - T2 second; - T3 third; -}; - -// lack of support for range > int32 -template -class UniformRandomIntGenerator { - public: - explicit UniformRandomIntGenerator(IntType a = 0, IntType b = std::numeric_limits::max()) - : dis_(a, b) { - std::random_device rd; - gen_.seed(rd()); - } - - ~UniformRandomIntGenerator() {} - - IntType Next() { - return dis_(gen_); - } - - private: - std::mt19937 gen_; - std::uniform_int_distribution dis_; -}; - -template -class UniformRandomRealGenerator { - public: - explicit UniformRandomRealGenerator(RealType a = 0, RealType b = std::numeric_limits::max()) - : dis_(a, b) { - std::random_device rd; - gen_.seed(rd()); - } - - ~UniformRandomRealGenerator() {} - - RealType Next() { - return dis_(gen_); - } - - private: - std::mt19937 gen_; - std::uniform_real_distribution dis_; -}; - -} -} diff --git a/ios/IJKMediaDemo/IJKMediaDemo/IJKMoviePlayerViewController.h b/ios/IJKMediaDemo/IJKMediaDemo/IJKMoviePlayerViewController.h index 189d57a4..d07fcef4 100644 --- a/ios/IJKMediaDemo/IJKMediaDemo/IJKMoviePlayerViewController.h +++ b/ios/IJKMediaDemo/IJKMediaDemo/IJKMoviePlayerViewController.h @@ -23,7 +23,6 @@ @property(atomic,strong) NSURL *url; @property(strong,nonatomic) NSDictionary* headers; -@property(strong,nonatomic) NSString* manifest; @property(atomic, retain) id player; - (id)initWithURL:(NSURL *)url manifest_string:(NSString*)manifest_string; -- GitLab