VICacheConfiguration.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // VICacheConfiguration.h
  3. // VIMediaCacheDemo
  4. //
  5. // Created by Vito on 4/21/16.
  6. // Copyright © 2016 Vito. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "VIContentInfo.h"
  10. @interface VICacheConfiguration : NSObject <NSCopying>
  11. + (NSString *)configurationFilePathForFilePath:(NSString *)filePath;
  12. + (instancetype)configurationWithFilePath:(NSString *)filePath;
  13. @property (nonatomic, copy, readonly) NSString *filePath;
  14. @property (nonatomic, strong) VIContentInfo *contentInfo;
  15. @property (nonatomic, strong) NSURL *url;
  16. - (NSArray<NSValue *> *)cacheFragments;
  17. /**
  18. * cached progress
  19. */
  20. @property (nonatomic, readonly) float progress;
  21. @property (nonatomic, readonly) long long downloadedBytes;
  22. @property (nonatomic, readonly) float downloadSpeed; // kb/s
  23. #pragma mark - update API
  24. - (void)save;
  25. - (void)addCacheFragment:(NSRange)fragment;
  26. /**
  27. * Record the download speed
  28. */
  29. - (void)addDownloadedBytes:(long long)bytes spent:(NSTimeInterval)time;
  30. @end
  31. @interface VICacheConfiguration (VIConvenient)
  32. + (BOOL)createAndSaveDownloadedConfigurationForURL:(NSURL *)url error:(NSError **)error;
  33. @end