1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// 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