#pragma once #include #include #include #include #include namespace laya { class VideoCache { public: VideoCache(); ~VideoCache() {} bool IsDownloaded(const std::string& url); const std::string& GetCacheFilePath(const std::string& url); void DownloadFile(const std::string& url); void OnLastFileDownloaded(std::function callback); void CancelDownload(); private: bool onDownloaded(void* p_pRes, std::weak_ptr callbackref); bool onDownloadErr(void* p_pRes, int p_nErrCode, std::weak_ptr callbackref); private: static std::map ms_cachePathMap; std::function m_onLastFileDownloaded; std::shared_ptr m_callbackRef; std::queue m_pendingUrls; std::string m_curDownloadUrl; bool m_isDownloading; }; };