Package com.brightcove.player.edge
Class OfflineStoreManager
java.lang.Object
com.brightcove.player.store.BaseStore
com.brightcove.player.edge.OfflineStoreManager
Store manager can be used to persist data into an application specific private database.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic @interface
Any method attempting to callchangeDownloadIdentifier(Video)
must be annotated explicitly with this annotation. -
Field Summary
Fields inherited from class com.brightcove.player.store.BaseStore
context, dataStore, MAX_SQL_EXPRESSIONS, MAX_SQL_VARIABLES, source
-
Method Summary
Modifier and TypeMethodDescriptioncom.brightcove.player.store.DownloadRequestSet
addDownloadRequests
(com.brightcove.player.store.DownloadRequestSet requestSet, IDownloadManager.IRequest... requests) Creates a new blank download request set.com.brightcove.player.store.OfflineVideo
changeDownloadIdentifier
(Video video) Changes the download identifier associated with given video.int
countDownloadRequestsInState
(Long requestSetKey, int statusCode) Counts the download requests belonging to a DownloadRequestSet with the specified status code.com.brightcove.player.store.DownloadRequestSet
createDownloadRequestSet
(RequestConfig requestConfig, long estimatedSize) Creates a new blank download request set.boolean
Deletes the specified request set from the store.boolean
deleteOfflineVideo
(String videoId) Deletes the first offline video entity with the given video identifier.List<com.brightcove.player.store.OfflineVideo>
Finds all offline video entities.List<com.brightcove.player.store.OfflineVideo>
findAllOfflineVideo
(int status) Finds all offline video entities with the specified statusList<com.brightcove.player.store.DownloadRequest>
findCurrentDownloadBatchInProgress
(int batchSize) Finds the current set of download request which are still being processed.List<com.brightcove.player.store.DownloadRequestSet>
Finds the current set of download request set which are still being processed.com.brightcove.player.store.DownloadRequestSet
Finds a download request set with the specified unique key.Collection<com.brightcove.player.store.DownloadRequestSet>
findDownloadRequestSets
(Long... requestIds) Finds the download request sets to which the given requests belong to.List<com.brightcove.player.store.DownloadRequest>
findDownloadsToBeQueued
(int batchSize, boolean excludeWifiOnly) Fetches a list of download requests that not have been queued for download by theDownloadManager
.android.net.Uri
findOfflineAssetUri
(android.net.Uri uri) Finds the local URI of a remote asset that has been downloaded successfully.com.brightcove.player.store.OfflineVideo
findOfflineVideo
(String videoId) Finds the first offline video entity with the given video identifier.static OfflineStoreManager
getInstance
(android.content.Context context) Gets reference to the single instance ofOfflineStoreManager
boolean
Checks if the current set of download request are still being processed.boolean
isDownloadCompleted
(Long requestSetKey) Checks if the DownloadRequestSet is completed.List<com.brightcove.player.store.DownloadRequest>
Marks the specified request set for removal.List<com.brightcove.player.store.DownloadRequest>
Marks a download request set as paused.<E extends IdentifiableEntity>
ErefreshEntity
(E entity) Refresh the given entity.com.brightcove.player.store.DownloadRequestSet
Marks a download request set as waiting to be queued.<T extends IdentifiableEntity>
TsaveEntity
(T entity) Inserts or updates the given entity.com.brightcove.player.store.OfflineVideo
saveOfflineLicense
(Video video) Updates the entity with given unique video identifier to save the video license information.com.brightcove.player.store.OfflineVideo
saveOfflineVideo
(Video video) Updates the entity with given unique video identifier to save the video metadata object, while retaining the previously saved license information.com.brightcove.player.store.OfflineVideo
saveOfflineVideo
(Video video, File downloadDirectory, com.brightcove.player.store.DownloadRequestSet requestSet) Saves the offline video information into the store.toVideoList
(List<com.brightcove.player.store.OfflineVideo> entityList) Converts the given list ofOfflineVideo
objects into a list ofVideo
objects.boolean
updateDownloadId
(Long key, Long downloadId) Sets the download identifier for the request with the specified primary key.com.brightcove.player.store.OfflineVideo
updateDownloadRequestIdList
(String videoId, List<Long> requestIdList, long estimatedSize) Updates the entity with given unique video identifier to save the current list of download request identifiers.boolean
updateDownloadRequestSetStatus
(com.brightcove.player.store.DownloadRequestSet requestSet, int statusCode, int reasonCode, com.brightcove.player.store.DownloadRequest downloadRequest, boolean evaluateAllSegments) Updates the status of Download Request Set.com.brightcove.player.store.DownloadRequest
updateDownloadRequestStatusByDownloadId
(Long downloadId, int statusCode, int reasonCode, long bytesDownloaded, long actualSize, boolean updateParentRecord) Updates the status of download request.Methods inherited from class com.brightcove.player.store.BaseStore
compact, deleteEntity, getDefaultDatabaseName, getDefaultDatabasePassword, getFileSize, onCreated, onUpgraded
-
Method Details
-
getInstance
Gets reference to the single instance ofOfflineStoreManager
- Parameters:
context
- reference to the host application context.- Returns:
- reference to the
OfflineStoreManager
-
refreshEntity
Refresh the given entity. This refreshes the already loaded properties in the entity. If no properties are loaded then the default properties will be loaded.- Overrides:
refreshEntity
in classBaseStore
- Type Parameters:
E
- the expected type of the entity;- Parameters:
entity
- reference to the entity to be refreshed.- Returns:
- null if the entity is null or if it does not exist in the store, otherwise reference to the updated entity
-
saveEntity
Inserts or updates the given entity.- Overrides:
saveEntity
in classBaseStore
- Parameters:
entity
- the entity to be save.- Returns:
- the updated the entity.;
-
updateDownloadRequestIdList
@Nullable public com.brightcove.player.store.OfflineVideo updateDownloadRequestIdList(@NonNull String videoId, @Nullable List<Long> requestIdList, long estimatedSize) Updates the entity with given unique video identifier to save the current list of download request identifiers.- Parameters:
videoId
- the unique video identifier.requestIdList
- a list of download request identifiers.- Returns:
- null if an entity with specified video identifier was found, otherwise reference to the updated entity.
-
saveOfflineVideo
public com.brightcove.player.store.OfflineVideo saveOfflineVideo(@NonNull Video video, @NonNull File downloadDirectory, @NonNull com.brightcove.player.store.DownloadRequestSet requestSet) Saves the offline video information into the store.- Parameters:
video
- the video information to be saved.downloadDirectory
- the download directory for this video.requestSet
- the download request set related to this video.- Returns:
- reference to the newly created entity.
-
saveOfflineVideo
Updates the entity with given unique video identifier to save the video metadata object, while retaining the previously saved license information.- Parameters:
video
- the video to be saved.- Returns:
- reference to the updated entity.
- See Also:
-
saveOfflineLicense
Updates the entity with given unique video identifier to save the video license information.- Parameters:
video
- the video to be saved.- Returns:
- reference to the updated entity.
- See Also:
-
findOfflineVideo
Finds the first offline video entity with the given video identifier.- Parameters:
videoId
- the unique video identifier.- Returns:
- null if there is no offline entity with the given identifier, otherwise reference to first matching entity.
-
findAllOfflineVideo
Finds all offline video entities.- Returns:
- a list of offline video entities.
-
findAllOfflineVideo
Finds all offline video entities with the specified status- Returns:
- a list of offline video entities.
-
deleteOfflineVideo
Deletes the first offline video entity with the given video identifier.- Parameters:
videoId
- the unique video identifier.- Returns:
- true if a matching entity was found and deleted, otherwise false.
-
createDownloadRequestSet
@NonNull public com.brightcove.player.store.DownloadRequestSet createDownloadRequestSet(@Nullable RequestConfig requestConfig, long estimatedSize) Creates a new blank download request set.- Returns:
- reference to the newly created entity
-
addDownloadRequests
@NonNull public com.brightcove.player.store.DownloadRequestSet addDownloadRequests(@NonNull com.brightcove.player.store.DownloadRequestSet requestSet, @NonNull IDownloadManager.IRequest... requests) Creates a new blank download request set.- Returns:
- reference to the newly created entity
-
findDownloadRequestSetByKey
@Nullable public com.brightcove.player.store.DownloadRequestSet findDownloadRequestSetByKey(@NonNull Long key) Finds a download request set with the specified unique key.- Parameters:
key
- the primary key of the request set.- Returns:
- null if the entity was not found, otherwise reference to the entity.
-
findOfflineAssetUri
@Nullable public android.net.Uri findOfflineAssetUri(@Nullable android.net.Uri uri) Finds the local URI of a remote asset that has been downloaded successfully.- Parameters:
uri
- the remote URI to the asset.- Returns:
- null if the asset is not available, otherwise URI to the local copy of the asset.
-
findDownloadRequestSets
public Collection<com.brightcove.player.store.DownloadRequestSet> findDownloadRequestSets(@NonNull Long... requestIds) Finds the download request sets to which the given requests belong to.- Parameters:
requestIds
- an array of one or more download requests.- Returns:
- a list of download request sets.
-
deleteDownloadRequestSet
Deletes the specified request set from the store.- Parameters:
key
- the primary key of the request set to be deleted.- Returns:
- true if a matching entity was found and deleted, otherwise false.
-
updateDownloadRequestStatusByDownloadId
@Nullable public com.brightcove.player.store.DownloadRequest updateDownloadRequestStatusByDownloadId(@NonNull Long downloadId, int statusCode, int reasonCode, long bytesDownloaded, long actualSize, boolean updateParentRecord) Updates the status of download request.- Parameters:
downloadId
- the unique identifier of the download request that caused the status change.statusCode
- the new status of the download.reasonCode
- the reason code for the new status, if any.bytesDownloaded
- the number of bytes downloaded so far.actualSize
- the total size of the download.updateParentRecord
- true to update the DownloadRequestSet parent record.- Returns:
- reference to the updated entity if it was found and updated, otherwise null.
-
updateDownloadRequestSetStatus
public boolean updateDownloadRequestSetStatus(com.brightcove.player.store.DownloadRequestSet requestSet, int statusCode, int reasonCode, com.brightcove.player.store.DownloadRequest downloadRequest, boolean evaluateAllSegments) Updates the status of Download Request Set.- Parameters:
requestSet
- the Download Request SetstatusCode
- the new status of the download segment.reasonCode
- the reason code for the new status, if any.downloadRequest
- the new segment Download RequestevaluateAllSegments
- if true, it makes sure to evaluate all download request segments to get the overall status.- Returns:
- true if updated.
-
pauseDownloadRequestSet
@NonNull public List<com.brightcove.player.store.DownloadRequest> pauseDownloadRequestSet(@NonNull Long key) Marks a download request set as paused.- Parameters:
key
- the primary key of the request set to be paused.- Returns:
- a list of download requests that have to be removed from the active download queue.
-
resumeDownloadRequestSet
@Nullable public com.brightcove.player.store.DownloadRequestSet resumeDownloadRequestSet(@NonNull Long key) Marks a download request set as waiting to be queued.- Parameters:
key
- the primary key of the request set to be paused.- Returns:
- null if the request set was not found, otherwise reference to the updated request set.
-
updateDownloadId
Sets the download identifier for the request with the specified primary key.- Parameters:
key
- the primary key of the request to be updated.downloadId
- the unique identifier to the download request in theDownloadManager
- Returns:
- true if the entity was found and updated, otherwise false.
-
changeDownloadIdentifier
@Nullable public com.brightcove.player.store.OfflineVideo changeDownloadIdentifier(@NonNull Video video) Changes the download identifier associated with given video. This method is intended for internal use only. Please do not call this in the application project.- Parameters:
video
- reference to the video.- Returns:
- the offline video entity associated with this video, if any.
-
markRequestSetForRemoval
@NonNull public List<com.brightcove.player.store.DownloadRequest> markRequestSetForRemoval(@NonNull Long key) Marks the specified request set for removal. A request set that has been marked for removal will not be queued or checked for further status changes. Any download requests in the set that has been queued already will be removed. The request set itself will be deleted once all the requests have been removed.- Parameters:
key
- the primary key of the request set to be updated.- Returns:
- a list download requests that must be removed from the download queue.
-
findDownloadsToBeQueued
@NonNull public List<com.brightcove.player.store.DownloadRequest> findDownloadsToBeQueued(int batchSize, boolean excludeWifiOnly) Fetches a list of download requests that not have been queued for download by theDownloadManager
.- Parameters:
batchSize
- the maximum number of entities to fetch.excludeWifiOnly
- true if the requests that allowed only on wifi networks must be excluded, otherwise false.- Returns:
- a list of pending download requests.
-
isCurrentDownloadBatchInProgress
public boolean isCurrentDownloadBatchInProgress()Checks if the current set of download request are still being processed.- Returns:
- true if the current set of download request are still being processed, otherwise false.
-
countDownloadRequestsInState
Counts the download requests belonging to a DownloadRequestSet with the specified status code.- Parameters:
requestSetKey
- the Download Request Set key.statusCode
- the status code.- Returns:
- the count.
-
isDownloadCompleted
Checks if the DownloadRequestSet is completed.- Parameters:
requestSetKey
- the Download Request Set key.- Returns:
- true is download is completed.
-
findCurrentDownloadBatchInProgress
public List<com.brightcove.player.store.DownloadRequest> findCurrentDownloadBatchInProgress(int batchSize) Finds the current set of download request which are still being processed.- Parameters:
batchSize
- the maximum number of entities to fetch- Returns:
- a list of download requests
-
findCurrentDownloadRequestSetInProgress
public List<com.brightcove.player.store.DownloadRequestSet> findCurrentDownloadRequestSetInProgress()Finds the current set of download request set which are still being processed.- Returns:
- a list of download request sets
-
toVideoList
public static List<Video> toVideoList(@NonNull List<com.brightcove.player.store.OfflineVideo> entityList) Converts the given list ofOfflineVideo
objects into a list ofVideo
objects.- Parameters:
entityList
- the list to be converted.- Returns:
- the converted list.
-