// // VICacheConfiguration.h // VIMediaCacheDemo // // Created by Vito on 4/21/16. // Copyright © 2016 Vito. All rights reserved. // #import <Foundation/Foundation.h> #import "VIContentInfo.h" @interface VICacheConfiguration : NSObject <NSCopying> + (NSString *)configurationFilePathForFilePath:(NSString *)filePath; + (instancetype)configurationWithFilePath:(NSString *)filePath; @property (nonatomic, copy, readonly) NSString *filePath; @property (nonatomic, strong) VIContentInfo *contentInfo; @property (nonatomic, strong) NSURL *url; - (NSArray<NSValue *> *)cacheFragments; /** * cached progress */ @property (nonatomic, readonly) float progress; @property (nonatomic, readonly) long long downloadedBytes; @property (nonatomic, readonly) float downloadSpeed; // kb/s #pragma mark - update API - (void)save; - (void)addCacheFragment:(NSRange)fragment; /** * Record the download speed */ - (void)addDownloadedBytes:(long long)bytes spent:(NSTimeInterval)time; @end @interface VICacheConfiguration (VIConvenient) + (BOOL)createAndSaveDownloadedConfigurationForURL:(NSURL *)url error:(NSError **)error; @end