media_proxy library
Classes
- CacheEntry
- 缓存项元数据
- CacheEvictionPolicy
- 缓存清理策略接口
- DownloadProgressInfo
- 下载进度信息
- GlobalDownloadQueue
- 全局下载队列管理器(单例)
- MediaCacheProxy
- 媒体缓存代理服务器
- MediaDownloadManager
- 缓存信息类(内部使用)已被 CacheEntry 替代 全局下载管理器(单例)
- MediaDownloadProgressListener
- 媒体下载进度监听器
- MediaDownloadTask
- 单个媒体文件的下载任务
- MediaFormatHelper
- 媒体格式辅助类
- MediaProxyConfig
- 媒体代理配置类
- MediaSegment
- 媒体分片信息类
- PlayerSession
- 播放器会话
- PreloadRequest
- 预加载任务请求
- PreloadScheduler
- 智能预加载调度器
- SmartCachePolicy
- 组合策略:TTL (过期时间) + LRU (最近最少使用)
Enums
- MediaType
- 媒体类型枚举
- SegmentStatus
- 分片的下载状态
Constants
- kDefaultMaxCacheSize → const int
- 默认最大缓存大小: 500MB
- kDefaultSegmentSize → const int
- 默认分片大小: 2MB
- kEnableLogging → const bool
- 日志开关
- kGlobalMaxConcurrentDownloads → const int
- 全局最大并发下载数
- kPriorityBackground → const int
- 后台下载的默认优先级
- kPriorityPlaying → const int
- 当前播放媒体的下载优先级 (普通分片)
- kPriorityPlayingUrgent → const int
- 当前播放媒体的紧急下载优先级 (当前播放位置的分片)
- kPriorityPreload → const int
- 预加载媒体的下载优先级
Functions
-
canonicalizeHeaders(
Map< String, String> ? headers) → String - 标准化 Headers 以便进行哈希计算
-
closeHttpClientSafely(
HttpClient? client) → Future< void> - 安全的 HttpClient 关闭
-
computeMd5Hash(
String input) → String - 计算 MD5 哈希(用于目录名)
-
createHttpClient(
) → HttpClient - 创建 HttpClient(配置连接池和超时)
-
formatFileSize(
int bytes) → String - 格式化文件大小
-
formatSpeed(
int? bytesPerSecond) → String? - 格式化下载速度
-
generateSessionId(
) → String - 生成唯一的会话ID
-
log(
String messageBuilder()) → void - 打印日志(仅在开启日志时打印,使用函数式参数避免不必要的字符串构建)
-
retryWithExponentialBackoff(
{required Future< bool> operation(), required int maxRetries, required int initialDelayMs}) → Future<void> - 延迟重试(指数退避)
-
waitForCondition(
{required bool condition(), required Duration timeout, required Duration pollInterval}) → Future< bool> - 等待条件满足或超时