2014-11-24 09:38:23 +00:00
/*
Copyright 2014 OpenMarket Ltd
Licensed under the Apache License , Version 2.0 ( the " License " ) ;
you may not use this file except in compliance with the License .
You may obtain a copy of the License at
http : //www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing , software
distributed under the License is distributed on an " AS IS " BASIS ,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
See the License for the specific language governing permissions and
limitations under the License .
*/
# import <AVFoundation / AVFoundation.h>
2015-01-08 20:23:49 +00:00
# import "MediaLoader.h"
2014-11-24 09:38:23 +00:00
extern NSString * const kMediaManagerPrefixForDummyURL ;
2015-01-19 13:33:57 +00:00
extern NSString * const kMediaManagerThumbnailFolder ;
2015-01-07 14:49:29 +00:00
2015-01-12 17:07:39 +00:00
// notify when a media download is finished (object: URL)
2015-01-07 16:26:37 +00:00
extern NSString * const kMediaDownloadDidFinishNotification ;
extern NSString * const kMediaDownloadDidFailNotification ;
2014-11-24 09:38:23 +00:00
@ interface MediaManager : NSObject
2015-01-12 17:07:39 +00:00
// Download data from the provided URL. Return a mediaLoader reference in order to let the user cancel this action.
2015-01-19 13:33:57 +00:00
+ ( MediaLoader * ) downloadMediaFromURL : ( NSString * ) mediaURL withType : ( NSString * ) mimeType inFolder : ( NSString * ) folder ;
2015-01-12 10:00:53 +00:00
// Check whether a download is already running for this media url. Return loader if any
2015-01-19 13:33:57 +00:00
+ ( MediaLoader * ) existingDownloaderForURL : ( NSString * ) url inFolder : ( NSString * ) folder ;
// cancel any pending download, within the folder
+ ( void ) cancelDownloadsInFolder : ( NSString * ) folder ;
// cancel any pending download
+ ( void ) cancelDownloads ;
2014-11-24 09:38:23 +00:00
2015-01-12 17:07:39 +00:00
// Prepares and returns a media loader to upload data to matrix content repository.
// initialRange / range: an upload could be a subpart of uploads. initialRange defines the global upload progress already did done before this current upload.
// range is the range value of this upload in the global scope.
// e.g. : Upload a media can be split in two parts :
// 1 - upload the thumbnail -> initialRange = 0, range = 0.1 : assume that the thumbnail upload is 10% of the upload process
// 2 - upload the media -> initialRange = 0.1, range = 0.9 : the media upload is 90% of the global upload
2015-01-19 13:33:57 +00:00
+ ( MediaLoader * ) prepareUploaderWithId : ( NSString * ) uploadId initialRange : ( CGFloat ) initialRange andRange : ( CGFloat ) range inFolder : ( NSString * ) folder ;
2015-01-12 17:07:39 +00:00
// Check whether an upload is already running with this id. Return loader if any
2015-01-19 13:33:57 +00:00
+ ( MediaLoader * ) existingUploaderWithId : ( NSString * ) uploadId inFolder : ( NSString * ) folder ;
+ ( void ) removeUploaderWithId : ( NSString * ) uploadId inFolder : ( NSString * ) folder ;
// cancel pending MediaLoader in folder
+ ( void ) cancelUploadsInFolder : ( NSString * ) folder ;
// cancel any pending upload
+ ( void ) cancelUploads ;
2015-01-12 17:07:39 +00:00
2015-01-08 17:20:34 +00:00
// Load a picture from the local cache (Do not start any remote requests)
2015-01-19 13:33:57 +00:00
+ ( UIImage * ) loadCachePictureForURL : ( NSString * ) pictureURL inFolder : ( NSString * ) folder ;
2015-01-12 10:00:53 +00:00
// Store in cache the provided data for the media URL, return the path of the resulting file
2015-01-19 13:33:57 +00:00
+ ( NSString * ) cacheMediaData : ( NSData * ) mediaData forURL : ( NSString * ) mediaURL andType : ( NSString * ) mimeType inFolder : ( NSString * ) folder ;
2015-01-12 10:00:53 +00:00
// Return the cache path deduced from media URL and type
2015-01-19 13:33:57 +00:00
+ ( NSString * ) cachePathForMediaURL : ( NSString * ) mediaURL andType : ( NSString * ) mimeType inFolder : ( NSString * ) folder ;
2015-01-19 15:53:29 +00:00
// check if the media cache size must be reduced to fit the user expected cache size
+ ( void ) reduceCacheSizeToInsert : ( NSUInteger ) bytes ;
2015-01-19 07:58:45 +00:00
// cache size management (values are in bytes)
2015-01-09 16:14:09 +00:00
+ ( NSUInteger ) cacheSize ;
2015-01-19 07:58:45 +00:00
+ ( NSUInteger ) minCacheSize ;
+ ( NSUInteger ) currentMaxCacheSize ;
+ ( void ) setCurrentMaxCacheSize : ( NSUInteger ) maxCacheSize ;
+ ( NSUInteger ) maxAllowedCacheSize ;
2014-11-24 09:38:23 +00:00
2015-01-19 07:58:45 +00:00
+ ( void ) clearCache ;
2014-11-24 09:38:23 +00:00
@ end